//***********************************************************************************
// TMS WEB CORE framework code is copyright (c) 2018 - 2021 by tmssoftware.com bvba
// The code or parts of the code cannot be used in any way outside 
// a TMS WEB Core application generated by a licensed user or company.
//***********************************************************************************
var pas = { $libimports: {}};

var rtl = {

  version: 30301,

  quiet: false,
  debug_load_units: false,
  debug_rtti: false,

  $res : {},

  debug: function(){
    if (rtl.quiet || !console || !console.log) return;
    console.log(arguments);
  },

  error: function(s){
    rtl.debug('Error: ',s);
    throw s;
  },

  warn: function(s){
    rtl.debug('Warn: ',s);
  },

  checkVersion: function(v){
    if (rtl.version != v) throw "expected rtl version "+v+", but found "+rtl.version;
  },

  hiInt: Math.pow(2,53),

  hasString: function(s){
    return rtl.isString(s) && (s.length>0);
  },

  isArray: function(a) {
    return Array.isArray(a);
  },

  isFunction: function(f){
    return typeof(f)==="function";
  },

  isModule: function(m){
    return rtl.isObject(m) && rtl.hasString(m.$name) && (pas[m.$name]===m);
  },

  isImplementation: function(m){
    return rtl.isObject(m) && rtl.isModule(m.$module) && (m.$module.$impl===m);
  },

  isNumber: function(n){
    return typeof(n)==="number";
  },

  isObject: function(o){
    var s=typeof(o);
    return (typeof(o)==="object") && (o!=null);
  },

  isString: function(s){
    return typeof(s)==="string";
  },

  getNumber: function(n){
    return typeof(n)==="number"?n:NaN;
  },

  getChar: function(c){
    return ((typeof(c)==="string") && (c.length===1)) ? c : "";
  },

  getObject: function(o){
    return ((typeof(o)==="object") || (typeof(o)==='function')) ? o : null;
  },

  isTRecord: function(type){
    return (rtl.isObject(type) && type.hasOwnProperty('$new') && (typeof(type.$new)==='function'));
  },

  isPasClass: function(type){
    return (rtl.isObject(type) && type.hasOwnProperty('$classname') && rtl.isObject(type.$module));
  },

  isPasClassInstance: function(type){
    return (rtl.isObject(type) && rtl.isPasClass(type.$class));
  },

  hexStr: function(n,digits){
    return ("000000000000000"+n.toString(16).toUpperCase()).slice(-digits);
  },

  m_loading: 0,
  m_loading_intf: 1,
  m_intf_loaded: 2,
  m_loading_impl: 3, // loading all used unit
  m_initializing: 4, // running initialization
  m_initialized: 5,

  module: function(module_name, intfuseslist, intfcode, impluseslist){
    var lModule = pas[module_name];
    if (lModule) {
      lModule.$intfcode = intfcode;
    } 
    else {
      rtl.modulenew(module_name, intfuseslist, intfcode, impluseslist);
    }
  },

  modulenew: function(module_name, intfuseslist, intfcode, impluseslist){
    if (rtl.debug_load_units) rtl.debug('rtl.module name="'+module_name+'" intfuses='+intfuseslist+' impluses='+impluseslist);
    if (!rtl.hasString(module_name)) rtl.error('invalid module name "'+module_name+'"');
    if (!rtl.isArray(intfuseslist)) rtl.error('invalid interface useslist of "'+module_name+'"');
    if (!rtl.isFunction(intfcode)) rtl.error('invalid interface code of "'+module_name+'"');
    if (!(impluseslist==undefined) && !rtl.isArray(impluseslist)) rtl.error('invalid implementation useslist of "'+module_name+'"');

    if (pas[module_name])
      rtl.error('module "'+module_name+'" is already registered');

    var r = Object.create(rtl.tSectionRTTI);
    var module = r.$module = pas[module_name] = {
      $name: module_name,
      $intfuseslist: intfuseslist,
      $impluseslist: impluseslist,
      $state: rtl.m_loading,
      $intfcode: intfcode,
      $implcode: null,
      $impl: null,
      $rtti: r
    };
    if (impluseslist) module.$impl = {
          $module: module,
          $rtti: r
        };
  },

  exitcode: 0,

  run: function(module_name){
    try {
      if (!rtl.hasString(module_name)) module_name='program';
      if (rtl.debug_load_units) rtl.debug('rtl.run module="'+module_name+'"');
      rtl.initRTTI();
      var module = pas[module_name];
      if (!module) rtl.error('rtl.run module "'+module_name+'" missing');
      rtl.loadintf(module);
      rtl.loadimpl(module);
      if ((module_name=='program') || (module_name=='library')){
        if (rtl.debug_load_units) rtl.debug('running $main');
        var r = pas[module_name].$main();
        if (rtl.isNumber(r)) rtl.exitcode = r;
      }
    } catch(re) {
      if (!rtl.showUncaughtExceptions) {
        throw re
      } else {  
        if (!rtl.handleUncaughtException(re)) {
          rtl.showException(re);
          rtl.exitcode = 216;
        }  
      }
    } 
    return rtl.exitcode;
  },
  
  showException : function (re) {
    var errStack="";
    if (rtl.isObject(re) && re.hasOwnProperty('FJSError') && rtl.isObject(re.FJSError) && !(re.FJSError.stack==undefined)) // rtl Exception
      errStack=re.FJSError.stack
    else if (rtl.isObject(re) && re.hasOwnProperty('stack') && !(re.stack==undefined)) // native JS Error
      errStack=re.stack
    else
      errStack=re; // unknown object
    var errMsg = rtl.hasString(re.$classname) ? re.$classname : '';
    errMsg += ((errMsg) ? ': ' : '') + (re.hasOwnProperty('fMessage') ? re.fMessage : '');
    errMsg += ((errMsg) ? "\n" : '') + errStack;
    errMsg = "Uncaught Exception:\n" + errMsg;
    console.log(errMsg);
    alert(errMsg);
  },

  handleUncaughtException: function (e) {
    if (rtl.onUncaughtException) {
      try {
        rtl.onUncaughtException(e);
        return true;
      } catch (ee) {
        return false; 
      }
    } else {
      return false;
    }
  },

  loadintf: function(module){
    if (module.$state>rtl.m_loading_intf) return; // already finished
    if (rtl.debug_load_units) rtl.debug('loadintf: "'+module.$name+'"');
    if (module.$state===rtl.m_loading_intf)
      rtl.error('unit cycle detected "'+module.$name+'"');
    module.$state=rtl.m_loading_intf;
    // load interfaces of interface useslist
    rtl.loaduseslist(module,module.$intfuseslist,rtl.loadintf);
    // run interface
    if (rtl.debug_load_units) rtl.debug('loadintf: run intf of "'+module.$name+'"');
    module.$intfcode(module.$intfuseslist);
    // success
    module.$state=rtl.m_intf_loaded;
    // Note: units only used in implementations are not yet loaded (not even their interfaces)
  },

  loaduseslist: function(module,useslist,f){
    if (useslist==undefined) return;
    var len = useslist.length;
    for (var i = 0; i<len; i++) {
      var unitname=useslist[i];
      if (rtl.debug_load_units) rtl.debug('loaduseslist of "'+module.$name+'" uses="'+unitname+'"');
      if (pas[unitname]==undefined)
        rtl.error('module "'+module.$name+'" misses "'+unitname+'"');
      f(pas[unitname]);
    }
  },

  loadimpl: function(module){
    if (module.$state>=rtl.m_loading_impl) return; // already processing
    if (module.$state<rtl.m_intf_loaded) rtl.error('loadimpl: interface not loaded of "'+module.$name+'"');
    if (rtl.debug_load_units) rtl.debug('loadimpl: load uses of "'+module.$name+'"');
    module.$state=rtl.m_loading_impl;
    // load interfaces of implementation useslist
    rtl.loaduseslist(module,module.$impluseslist,rtl.loadintf);
    // load implementation of interfaces useslist
    rtl.loaduseslist(module,module.$intfuseslist,rtl.loadimpl);
    // load implementation of implementation useslist
    rtl.loaduseslist(module,module.$impluseslist,rtl.loadimpl);
    // Note: At this point all interfaces used by this unit are loaded. If
    //   there are implementation uses cycles some used units might not yet be
    //   initialized. This is by design.
    // run implementation
    if (rtl.debug_load_units) rtl.debug('loadimpl: run impl of "'+module.$name+'"');
    if (rtl.isFunction(module.$implcode)) module.$implcode(module.$impluseslist);
    // run initialization
    if (rtl.debug_load_units) rtl.debug('loadimpl: run init of "'+module.$name+'"');
    module.$state=rtl.m_initializing;
    if (rtl.isFunction(module.$init)) module.$init();
    // unit initialized
    module.$state=rtl.m_initialized;
  },

  createCallback: function(scope, fn){
    var cb;
    if (typeof(fn)==='string'){
      if (!scope.hasOwnProperty('$events')) scope.$events = {};
      cb = scope.$events[fn];
      if (cb) return cb;
      scope.$events[fn] = cb = function(){
        return scope[fn].apply(scope,arguments);
      };
    } else {
      cb = function(){
        return fn.apply(scope,arguments);
      };
    };
    cb.scope = scope;
    cb.fn = fn;
    return cb;
  },

  createSafeCallback: function(scope, fn){
    var cb;
    if (typeof(fn)==='string'){
      if (!scope[fn]) return null;
      if (!scope.hasOwnProperty('$events')) scope.$events = {};
      cb = scope.$events[fn];
      if (cb) return cb;
      scope.$events[fn] = cb = function(){
        try{
          return scope[fn].apply(scope,arguments);
        } catch (err) {
          if (!rtl.handleUncaughtException(err)) throw err;
        }
      };
    } else if(!fn) {
      return null;
    } else {
      cb = function(){
        try{
          return fn.apply(scope,arguments);
        } catch (err) {
          if (!rtl.handleUncaughtException(err)) throw err;
        }
      };
    };
    cb.scope = scope;
    cb.fn = fn;
    return cb;
  },

  eqCallback: function(a,b){
    // can be a function or a function wrapper
    if (a===b){
      return true;
    } else {
      return (a!=null) && (b!=null) && (a.fn) && (a.scope===b.scope) && (a.fn===b.fn);
    }
  },

  initStruct: function(c,parent,name){
    if ((parent.$module) && (parent.$module.$impl===parent)) parent=parent.$module;
    c.$parent = parent;
    if (rtl.isModule(parent)){
      c.$module = parent;
      c.$name = name;
    } else {
      c.$module = parent.$module;
      c.$name = parent.$name+'.'+name;
    };
    return parent;
  },

  initClass: function(c,parent,name,initfn,rttiname){
    parent[name] = c;
    c.$class = c; // Note: o.$class === Object.getPrototypeOf(o)
    c.$classname = rttiname?rttiname:name;
    parent = rtl.initStruct(c,parent,name);
    c.$fullname = parent.$name+'.'+name;
    // rtti
    if (rtl.debug_rtti) rtl.debug('initClass '+c.$fullname);
    var t = c.$module.$rtti.$Class(c.$classname,{ "class": c });
    c.$rtti = t;
    if (rtl.isObject(c.$ancestor)) t.ancestor = c.$ancestor.$rtti;
    if (!t.ancestor) t.ancestor = null;
    // init members
    initfn.call(c);
  },

  createClass: function(parent,name,ancestor,initfn,rttiname){
    // create a normal class,
    // ancestor must be null or a normal class,
    // the root ancestor can be an external class
    var lClass = parent[name];
    if (lClass) {
      rtl.initClass(lClass, parent, name, initfn, rttiname);
      return lClass; 
    }

    var c = null;
    if (ancestor != null){
      c = Object.create(ancestor);
      c.$ancestor = ancestor;
      // Note:
      // if root is an "object" then c.$ancestor === Object.getPrototypeOf(c)
      // if root is a "function" then c.$ancestor === c.__proto__, Object.getPrototypeOf(c) returns the root
    } else {
      c = { $ancestor: null };
      c.$create = function(fn,args){
        if (args == undefined) args = [];
        var o = Object.create(this);
        o.$init();
        try{
          if (typeof(fn)==="string"){
            o[fn].apply(o,args);
          } else {
            fn.apply(o,args);
          };
          o.AfterConstruction();
        } catch($e){
          // do not call BeforeDestruction
          if (o.Destroy) o.Destroy();
          o.$final();
          throw $e;
        }
        return o;
      };
      c.$destroy = function(fnname){
        this.BeforeDestruction();
        if (this[fnname]) this[fnname]();
        this.$final();
      };
    };
    rtl.initClass(c,parent,name,initfn,rttiname);
  },

  createClassExt: function(parent,name,ancestor,newinstancefnname,initfn,rttiname){
    // Create a class using an external ancestor.
    // If newinstancefnname is given, use that function to create the new object.
    // If exist call BeforeDestruction and AfterConstruction.
    var lClass = parent[name];
    if (lClass) {
      rtl.initClass(lClass, parent, name, initfn, rttiname);
      return lClass; 
    }

    var isFunc = rtl.isFunction(ancestor);
    var c = null;
    if (isFunc){
      // create pascal class descendent from JS function
      c = Object.create(ancestor.prototype);
      c.$ancestorfunc = ancestor;
      c.$ancestor = null; // no pascal ancestor
    } else if (ancestor.$func){
      // create pascal class descendent from a pascal class descendent of a JS function
      isFunc = true;
      c = Object.create(ancestor);
      c.$ancestor = ancestor;
    } else {
      c = Object.create(ancestor);
      c.$ancestor = null; // no pascal ancestor
    }
    c.$create = function(fn,args){
      if (args == undefined) args = [];
      var o = null;
      if (newinstancefnname.length>0){
        o = this[newinstancefnname](fn,args);
      } else if(isFunc) {
        o = new this.$func(args);
      } else {
        o = Object.create(c);
      }
      if (o.$init) o.$init();
      try{
        if (typeof(fn)==="string"){
          this[fn].apply(o,args);
        } else {
          fn.apply(o,args);
        };
        if (o.AfterConstruction) o.AfterConstruction();
      } catch($e){
        // do not call BeforeDestruction
        if (o.Destroy) o.Destroy();
        if (o.$final) o.$final();
        throw $e;
      }
      return o;
    };
    c.$destroy = function(fnname){
      if (this.BeforeDestruction) this.BeforeDestruction();
      if (this[fnname]) this[fnname]();
      if (this.$final) this.$final();
    };
    rtl.initClass(c,parent,name,initfn,rttiname);
    if (isFunc){
      function f(){}
      f.prototype = c;
      c.$func = f;
    }
  },

  createHelper: function(parent,name,ancestor,initfn,rttiname){
    // create a helper,
    // ancestor must be null or a helper,
    var lHelper = parent[name];
    if (lHelper) {
      initfn.call(lHelper);
      return lHelper; 
    }

    var c = null;
    if (ancestor != null){
      c = Object.create(ancestor);
      c.$ancestor = ancestor;
      // c.$ancestor === Object.getPrototypeOf(c)
    } else {
      c = { $ancestor: null };
    };
    parent[name] = c;
    c.$class = c; // Note: o.$class === Object.getPrototypeOf(o)
    c.$classname = rttiname?rttiname:name;
    parent = rtl.initStruct(c,parent,name);
    c.$fullname = parent.$name+'.'+name;
    // rtti
    var t = c.$module.$rtti.$Helper(c.$classname,{ "helper": c });
    c.$rtti = t;
    if (rtl.isObject(ancestor)) t.ancestor = ancestor.$rtti;
    if (!t.ancestor) t.ancestor = null;
    // init members
    initfn.call(c);
  },

  tObjectDestroy: "Destroy",

  free: function(obj,name){
    if (obj[name]==null) return null;
    obj[name].$destroy(rtl.tObjectDestroy);
    obj[name]=null;
  },

  freeLoc: function(obj){
    if (obj==null) return null;
    obj.$destroy(rtl.tObjectDestroy);
    return null;
  },

  hideProp: function(o,p,v){
    Object.defineProperty(o,p, {
      enumerable: false,
      configurable: true,
      writable: true
    });
    if(arguments.length>2){ o[p]=v; }
  },

  recNewT: function(parent,name,initfn,full){
    if (parent) {
      var lRec = parent[name];
      if (lRec) {
        initfn.call(lRec);
        return lRec;
      }
    } 

    // create new record type
    var t = {};
    if (parent) parent[name] = t;
    var h = rtl.hideProp;
    if (full){
      rtl.initStruct(t,parent,name);
      t.$record = t;
      h(t,'$record');
      h(t,'$name');
      h(t,'$parent');
      h(t,'$module');
      h(t,'$initSpec');
    }
    initfn.call(t);
    if (!t.$new){
      t.$new = function(){ return Object.create(t); };
    }
    t.$clone = function(r){ return t.$new().$assign(r); };
    h(t,'$new');
    h(t,'$clone');
    h(t,'$eq');
    h(t,'$assign');
    return t;
  },

  is: function(instance,type){
    return type.isPrototypeOf(instance) || (instance===type);
  },

  isExt: function(instance,type,mode){
    // mode===1 means instance must be a Pascal class instance
    // mode===2 means instance must be a Pascal class
    // Notes:
    // isPrototypeOf and instanceof return false on equal
    // isPrototypeOf does not work for Date.isPrototypeOf(new Date())
    //   so if isPrototypeOf is false test with instanceof
    // instanceof needs a function on right side
    if (instance == null) return false; // Note: ==null checks for undefined too
    if ((typeof(type) !== 'object') && (typeof(type) !== 'function')) return false;
    if (instance === type){
      if (mode===1) return false;
      if (mode===2) return rtl.isPasClass(instance);
      return true;
    }
    if (type.isPrototypeOf && type.isPrototypeOf(instance)){
      if (mode===1) return rtl.isPasClassInstance(instance);
      if (mode===2) return rtl.isPasClass(instance);
      return true;
    }
    if ((typeof type == 'function') && (instance instanceof type)) return true;
    return false;
  },

  Exception: null,
  EInvalidCast: null,
  EAbstractError: null,
  ERangeError: null,
  EIntOverflow: null,
  EPropWriteOnly: null,

  raiseE: function(typename){
    var t = rtl[typename];
    if (t==null){
      var mod = pas.SysUtils;
      if (!mod) mod = pas.sysutils;
      if (!mod) mod = pas["System.SysUtils"];
      if (mod){
        t = mod[typename];
        if (!t) t = mod[typename.toLowerCase()];
        if (!t) t = mod['Exception'];
        if (!t) t = mod['exception'];
      }
      if (t) rtl[typename]=t;
    }
    if (t) {
      
      if (t.Create){
        var e = t.$create("Create");
      } else if (t.create) {
        var e = t.$create("create");
      }
      if (e) {
        e.FJSError = new Error;
        throw e ;
      }
    }
    if (typename === "EInvalidCast") throw new Error("invalid type cast");
    if (typename === "EAbstractError") throw new Error("Abstract method called");
    if (typename === "ERangeError") throw new Error("range error");
    throw typename;
  },

  as: function(instance,type){
    if((instance === null) || rtl.is(instance,type)) return instance;
    rtl.raiseE("EInvalidCast");
  },

  asExt: function(instance,type,mode){
    if((instance === null) || rtl.isExt(instance,type,mode)) return instance;
    rtl.raiseE("EInvalidCast");
  },

  createInterface: function(module, name, guid, fnnames, ancestor, initfn, rttiname){
    //console.log('createInterface name="'+name+'" guid="'+guid+'" names='+fnnames);
    var lInterface = module[name];
    if (lInterface) {
      if (rtl.isFunction(initfn)) {
        initfn.call(lInterface);
      }
      return lInterface; 
    }

    var i = ancestor?Object.create(ancestor):{};
    module[name] = i;
    i.$module = module;
    i.$name = rttiname?rttiname:name;
    i.$fullname = module.$name+'.'+i.$name;
    i.$guid = guid;
    i.$guidr = null;
    i.$names = fnnames?fnnames:[];
    if (rtl.isFunction(initfn)){
      // rtti
      if (rtl.debug_rtti) rtl.debug('createInterface '+i.$fullname);
      var t = i.$module.$rtti.$Interface(i.$name,{ "interface": i, module: module });
      i.$rtti = t;
      if (ancestor) t.ancestor = ancestor.$rtti;
      if (!t.ancestor) t.ancestor = null;
      initfn.call(i);
    }
    return i;
  },

  strToGUIDR: function(s,g){
    var p = 0;
    function n(l){
      var h = s.substr(p,l);
      p+=l;
      return parseInt(h,16);
    }
    p+=1; // skip {
    g.D1 = n(8);
    p+=1; // skip -
    g.D2 = n(4);
    p+=1; // skip -
    g.D3 = n(4);
    p+=1; // skip -
    if (!g.D4) g.D4=[];
    g.D4[0] = n(2);
    g.D4[1] = n(2);
    p+=1; // skip -
    for(var i=2; i<8; i++) g.D4[i] = n(2);
    return g;
  },

  guidrToStr: function(g){
    if (g.$intf) return g.$intf.$guid;
    var h = rtl.hexStr;
    var s='{'+h(g.D1,8)+'-'+h(g.D2,4)+'-'+h(g.D3,4)+'-'+h(g.D4[0],2)+h(g.D4[1],2)+'-';
    for (var i=2; i<8; i++) s+=h(g.D4[i],2);
    s+='}';
    return s;
  },

  createTGUID: function(guid){
    var TGuid = (pas.System)?pas.System.TGuid:pas.system.tguid;
    var g = rtl.strToGUIDR(guid,TGuid.$new());
    return g;
  },

  getIntfGUIDR: function(intfTypeOrVar){
    if (!intfTypeOrVar) return null;
    if (!intfTypeOrVar.$guidr){
      var g = rtl.createTGUID(intfTypeOrVar.$guid);
      if (!intfTypeOrVar.hasOwnProperty('$guid')) intfTypeOrVar = Object.getPrototypeOf(intfTypeOrVar);
      g.$intf = intfTypeOrVar;
      intfTypeOrVar.$guidr = g;
    }
    return intfTypeOrVar.$guidr;
  },

  addIntf: function (aclass, intf, map){
    function jmp(fn){
      if (typeof(fn)==="function"){
        return function(){ return fn.apply(this.$o,arguments); };
      } else {
        return function(){ rtl.raiseE('EAbstractError'); };
      }
    }
    if(!map) map = {};
    var t = intf;
    var item = Object.create(t);
    if (!aclass.hasOwnProperty('$intfmaps')) aclass.$intfmaps = {};
    aclass.$intfmaps[intf.$guid] = item;
    do{
      var names = t.$names;
      if (!names) break;
      for (var i=0; i<names.length; i++){
        var intfname = names[i];
        var fnname = map[intfname];
        if (!fnname) fnname = intfname;
        //console.log('addIntf: intftype='+t.$name+' index='+i+' intfname="'+intfname+'" fnname="'+fnname+'" old='+typeof(item[intfname]));
        item[intfname] = jmp(aclass[fnname]);
      }
      t = Object.getPrototypeOf(t);
    }while(t!=null);
  },

  getIntfG: function (obj, guid, query){
    if (!obj) return null;
    //console.log('getIntfG: obj='+obj.$classname+' guid='+guid+' query='+query);
    // search
    var maps = obj.$intfmaps;
    if (!maps) return null;
    var item = maps[guid];
    if (!item) return null;
    // check delegation
    //console.log('getIntfG: obj='+obj.$classname+' guid='+guid+' query='+query+' item='+typeof(item));
    if (typeof item === 'function') return item.call(obj); // delegate. Note: COM contains _AddRef
    // check cache
    var intf = null;
    if (obj.$interfaces){
      intf = obj.$interfaces[guid];
      //console.log('getIntfG: obj='+obj.$classname+' guid='+guid+' cache='+typeof(intf));
    }
    if (!intf){ // intf can be undefined!
      intf = Object.create(item);
      intf.$o = obj;
      if (!obj.$interfaces) obj.$interfaces = {};
      obj.$interfaces[guid] = intf;
    }
    if (typeof(query)==='object'){
      // called by queryIntfT
      var o = null;
      if (intf.QueryInterface(rtl.getIntfGUIDR(query),
          {get:function(){ return o; }, set:function(v){ o=v; }}) === 0){
        return o;
      } else {
        return null;
      }
    } else if(query===2){
      // called by TObject.GetInterfaceByStr
      if (intf.$kind === 'com') intf._AddRef();
    }
    return intf;
  },

  getIntfT: function(obj,intftype){
    return rtl.getIntfG(obj,intftype.$guid);
  },

  queryIntfT: function(obj,intftype){
    return rtl.getIntfG(obj,intftype.$guid,intftype);
  },

  queryIntfIsT: function(obj,intftype){
    var i = rtl.getIntfG(obj,intftype.$guid);
    if (!i) return false;
    if (i.$kind === 'com') i._Release();
    return true;
  },

  asIntfT: function (obj,intftype){
    var i = rtl.getIntfG(obj,intftype.$guid);
    if (i!==null) return i;
    rtl.raiseEInvalidCast();
  },

  intfIsIntfT: function(intf,intftype){
    return (intf!==null) && rtl.queryIntfIsT(intf.$o,intftype);
  },

  intfAsIntfT: function (intf,intftype){
    if (!intf) return null;
    var i = rtl.getIntfG(intf.$o,intftype.$guid);
    if (i) return i;
    rtl.raiseEInvalidCast();
  },

  intfIsClass: function(intf,classtype){
    return (intf!=null) && (rtl.is(intf.$o,classtype));
  },

  intfAsClass: function(intf,classtype){
    if (intf==null) return null;
    return rtl.as(intf.$o,classtype);
  },

  intfToClass: function(intf,classtype){
    if ((intf!==null) && rtl.is(intf.$o,classtype)) return intf.$o;
    return null;
  },

  // interface reference counting
  intfRefs: { // base object for temporary interface variables
    ref: function(id,intf){
      // called for temporary interface references needing delayed release
      var old = this[id];
      //console.log('rtl.intfRefs.ref: id='+id+' old="'+(old?old.$name:'null')+'" intf="'+(intf?intf.$name:'null')+' $o='+(intf?intf.$o:'null'));
      if (old){
        // called again, e.g. in a loop
        delete this[id];
        old._Release(); // may fail
      }
      if(intf) {
        this[id]=intf;
      }
      return intf;
    },
    free: function(){
      //console.log('rtl.intfRefs.free...');
      for (var id in this){
        if (this.hasOwnProperty(id)){
          var intf = this[id];
          if (intf){
            //console.log('rtl.intfRefs.free: id='+id+' '+intf.$name+' $o='+intf.$o.$classname);
            intf._Release();
          }
        }
      }
    }
  },

  createIntfRefs: function(){
    //console.log('rtl.createIntfRefs');
    return Object.create(rtl.intfRefs);
  },

  setIntfP: function(path,name,value,skipAddRef){
    var old = path[name];
    //console.log('rtl.setIntfP path='+path+' name='+name+' old="'+(old?old.$name:'null')+'" value="'+(value?value.$name:'null')+'"');
    if (old === value) return;
    if (old !== null){
      path[name]=null;
      old._Release();
    }
    if (value !== null){
      if (!skipAddRef) value._AddRef();
      path[name]=value;
    }
  },

  setIntfL: function(old,value,skipAddRef){
    //console.log('rtl.setIntfL old="'+(old?old.$name:'null')+'" value="'+(value?value.$name:'null')+'"');
    if (old !== value){
      if (value!==null){
        if (!skipAddRef) value._AddRef();
      }
      if (old!==null){
        old._Release();  // Release after AddRef, to avoid double Release if Release creates an exception
      }
    } else if (skipAddRef){
      if (old!==null){
        old._Release();  // value has an AddRef
      }
    }
    return value;
  },

  _AddRef: function(intf){
    //if (intf) console.log('rtl._AddRef intf="'+(intf?intf.$name:'null')+'"');
    if (intf) intf._AddRef();
    return intf;
  },

  _Release: function(intf){
    //if (intf) console.log('rtl._Release intf="'+(intf?intf.$name:'null')+'"');
    if (intf) intf._Release();
    return intf;
  },

  trunc: function(a){
    return a<0 ? Math.ceil(a) : Math.floor(a);
  },

  checkMethodCall: function(obj,type){
    if (rtl.isObject(obj) && rtl.is(obj,type)) return;
    rtl.raiseE("EInvalidCast");
  },

  oc: function(i){
    // overflow check integer
    if ((Math.floor(i)===i) && (i>=-0x1fffffffffffff) && (i<=0x1fffffffffffff)) return i;
    rtl.raiseE('EIntOverflow');
  },

  rc: function(i,minval,maxval){
    // range check integer
    if ((Math.floor(i)===i) && (i>=minval) && (i<=maxval)) return i;
    rtl.raiseE('ERangeError');
  },

  rcc: function(c,minval,maxval){
    // range check char
    if ((typeof(c)==='string') && (c.length===1)){
      var i = c.charCodeAt(0);
      if ((i>=minval) && (i<=maxval)) return c;
    }
    rtl.raiseE('ERangeError');
  },

  rcSetCharAt: function(s,index,c){
    // range check setCharAt
    if ((typeof(s)!=='string') || (index<0) || (index>=s.length)) rtl.raiseE('ERangeError');
    return rtl.setCharAt(s,index,c);
  },

  rcCharAt: function(s,index){
    // range check charAt
    if ((typeof(s)!=='string') || (index<0) || (index>=s.length)) rtl.raiseE('ERangeError');
    return s.charAt(index);
  },

  rcArrR: function(arr,index){
    // range check read array
    if (Array.isArray(arr) && (typeof(index)==='number') && (index>=0) && (index<arr.length)){
      if (arguments.length>2){
        // arr,index1,index2,...
        arr=arr[index];
        for (var i=2; i<arguments.length; i++) arr=rtl.rcArrR(arr,arguments[i]);
        return arr;
      }
      return arr[index];
    }
    rtl.raiseE('ERangeError');
  },

  rcArrW: function(arr,index,value){
    // range check write array
    // arr,index1,index2,...,value
    for (var i=3; i<arguments.length; i++){
      arr=rtl.rcArrR(arr,index);
      index=arguments[i-1];
      value=arguments[i];
    }
    if (Array.isArray(arr) && (typeof(index)==='number') && (index>=0) && (index<arr.length)){
      return arr[index]=value;
    }
    rtl.raiseE('ERangeError');
  },

  length: function(arr){
    return (arr == null) ? 0 : arr.length;
  },

  arrayRef: function(a){
    if (a!=null) rtl.hideProp(a,'$pas2jsrefcnt',2);
    return a;
  },

  arrayManaged: function(refCnt,mode,a){
    // mode: 0: don't touch elements, 1: null elements, 2: _AddRef elements
    if(!a) a = [];
    a.$pas2jsrefcnt = refCnt?refCnt:0;
    a._AddRef = function(){
      this.$pas2jsrefcnt++;
    };
    a._Release = function(){
      this.$pas2jsrefcnt--;
      if (this.$pas2jsrefcnt==0){
        for (var i=0; i<this.length; i++){
          rtl.setIntfP(this,i,null);
        }
      }
    };
    if (mode>0){
      for (var i=0; i<a.length; i++){
        if (mode === 2){
          rtl._AddRef(a[i]);
        } else {
          a[i]=null;
        }
      }
    }
    return a;
  },

  arraySetLength: function(arr,defaultvalue,newlength){
    var stack = [];
    var s = 9999;
    for (var i=2; i<arguments.length; i++){
      var j = arguments[i];
      if (j==='s'){ s = i-2; }
      else {
        stack.push({ dim:j+0, a:null, i:0, src:null });
      }
    }
    var dimmax = stack.length-1;
    var depth = 0;
    var newlen = 0;
    var item = null;
    var a = null;
    var src = arr;
    var srclen = 0, oldlen = 0;
    var type = 0;
    var managed = false;
    if (rtl.isArray(defaultvalue)){
      // array of dyn array
      type = 1;
    } else if (rtl.isObject(defaultvalue)) {
      if (rtl.isTRecord(defaultvalue)){
        // array of record
        type = 2;
      } else {
        // array of set
        type = 3;
      }
    } else if (defaultvalue == 'R'){
      // array of COM interface
      type = 4;
      managed = true;
    }

    do{
      if (depth>0){
        item = stack[depth-1];
        src = (item.src && item.src.length>item.i) ? item.src[item.i] : null;
      }
      if (!src){
        // init array
        managed ? a=rtl.arrayManaged(1) : a=[];
        srclen = 0;
        oldlen = 0;
      } else if (src.$pas2jsrefcnt>1 || depth>=s){
        // clone
        if (managed){
          a = rtl.arrayManaged(1);
          src.$pas2jsrefcnt--;
        } else {
          a = [];
        }
        srclen = src.length;
        oldlen = srclen;
      } else {
        // keep old
        a = src;
        srclen = 0;
        oldlen = a.length;
      }
      newlen = stack[depth].dim;
      if (managed){
        if (a.length>=newlen){
          // shrink -> release elements
          for (var i=a.length-1; i>=newlen; i--){
            rtl.setIntfP(a,i,null);
          }
          a.length = newlen;
        } else {
          // enlarge -> null elements
          var l = a.length;
          a.length = newlen;
          for (var i=l; i<newlen; i++){
            a[i]=null;
          }
          oldlen = newlen;
        }
      } else {
        a.length = newlen;
      }
      if (depth>0){
        item.a[item.i]=a;
        item.i++;
        if ((newlen===0) && (item.i<item.a.length)) continue;
      }
      if (newlen>0){
        if (depth<dimmax){
          item = stack[depth];
          item.a = a;
          item.i = 0;
          item.src = src;
          depth++;
          continue;
        } else {
          if (srclen>newlen) srclen=newlen;
          if (type == 0){
            // array of simple value
            for (var i=0; i<srclen; i++) a[i]=src[i];
            for (var i=oldlen; i<newlen; i++) a[i]=defaultvalue;
          } else if (type == 1){
            // array of dyn array
            for (var i=0; i<srclen; i++) a[i]=src[i];
            for (var i=oldlen; i<newlen; i++) a[i]=[];
          } else if (type == 2) {
            // array of record
            for (var i=0; i<srclen; i++) a[i]=defaultvalue.$clone(src[i]);
            for (var i=oldlen; i<newlen; i++) a[i]=defaultvalue.$new();
          } else if (type == 3) {
            // array of set
            for (var i=0; i<srclen; i++) a[i]=rtl.refSet(src[i]);
            for (var i=oldlen; i<newlen; i++) a[i]={};
          } else if (type == 4){
            // array of interface
            for (var i=0; i<srclen; i++) rtl.setIntfP(a,i,src[i]);
            for (var i=oldlen; i<newlen; i++) a[i]=null;
          }
        }
      }
      // backtrack
      while ((depth>0) && (stack[depth-1].i>=stack[depth-1].dim)){
        depth--;
      };
      if (depth===0){
        return dimmax===0 ? a : stack[0].a;
      }
    }while (true);
  },

  arrayEq: function(a,b){
    if (a===null) return b===null;
    if (b===null) return false;
    if (a.length!==b.length) return false;
    for (var i=0; i<a.length; i++) if (a[i]!==b[i]) return false;
    return true;
  },

  arrayClone: function(type,src,srcpos,endpos,dst,dstpos){
    // type: 0 for references or simple values
    // src must not be null
    // dst at dstpos must not contain managed old values
    // This function does not range check.
    if(type === 'refSet') {
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = rtl.refSet(src[srcpos]); // ref set
    } else if (type === 'slice'){
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = src[srcpos].slice(0); // clone static array of simple types
    } else if (typeof(type)==='function'){
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = type(src[srcpos]); // clone function
    } else if (rtl.isTRecord(type)){
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = type.$clone(src[srcpos]); // clone record
    } else if (type === 'R'){
      // clone managed instance
      for (; srcpos<endpos; srcpos++){
        dst[dstpos++]=rtl._AddRef(src[srcpos]);
      }
    } else {
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = src[srcpos]; // reference
    };
  },

  arrayConcat: function(type){
    // type: see rtl.arrayClone
    // returns refCnt=1
    var a = [];
    var l = 0;
    for (var i=1; i<arguments.length; i++){
      var src = arguments[i];
      if (src !== null) l+=src.length;
    };
    a.length = l;
    if (type === 'R'){
      rtl.arrayManaged(1,1,a);
    }
    l=0;
    for (var i=1; i<arguments.length; i++){
      var src = arguments[i];
      if (src === null) continue;
      rtl.arrayClone(type,src,0,src.length,a,l);
      l+=src.length;
    };
    return a;
  },

  arrayConcatN: function(){
    var a = null;
    for (var i=0; i<arguments.length; i++){
      var src = arguments[i];
      if (src === null) continue;
      if (a===null){
        a=rtl.arrayRef(src); // Note: concat(arr) does not clone
      } else if (a.$pas2jsrefcnt>1){
        a=a.concat(src); // clone a and append src
      } else {
        for (var i=0; i<src.length; i++){
          a.push(src[i]);
        }
      }
    };
    return a;
  },

  arrayPush: function(type,a){
    if(a===null){
      a=(type==='R') ? rtl.arrayManaged(1) : [];
    } else if (a.$pas2jsrefcnt>1){
      a=rtl.arrayCopy(type,a,0,a.length);
    }
    rtl.arrayClone(type,arguments,2,arguments.length,a,a.length);
    return a;
  },

  arrayPushN: function(a){
    if(a===null){
      a=[];
    } else if (a.$pas2jsrefcnt>1){
      a=a.concat();
    }
    for (var i=1; i<arguments.length; i++){
      a.push(arguments[i]);
    }
    return a;
  },

  arrayCopy: function(type, srcarray, index, count){
    // type: see rtl.arrayClone
    // if count is missing, use srcarray.length
    if (srcarray === null) return (type === 'R') ? null : [];
    if (count === undefined) count=srcarray.length;
    if (index < 0){
      count+=index;
      index = 0;
    }
    var end = index+count;
    if (end>srcarray.length) end = srcarray.length;
    if (index>=end) return (type === 'R') ? null : [];
    if (type===0){
      return srcarray.slice(index,end);
    } else {
      var a = [];
      a.length = end-index;
      if (type === 'R'){
        rtl.arrayManaged(1,1,a);
      }
      rtl.arrayClone(type,srcarray,index,end,a,0);
      return a;
    }
  },

  arrayInsert: function(item, a, index, type){
    var m = (type === 'R');
    if (m) rtl._AddRef(item);
    if (a){
      if (a.$pas2jsrefcnt>1){
        if (m){
          // clone
          a.$pas2jsrefcnt--;
          a=rtl.arrayManaged(1,2,a.concat());
        } else {
          a=a.concat();
        }
      }
      a.splice(index,0,item);
      return a;
    } else {
      a = [item];
      if (m) a=rtl.arrayManaged(1,0,a);
      return a;
    }
  },

  arrayDeleteR: function(a, index, count){
    if (a===null || index<0 || index>=a.length || count<=0) return a;
    if (index+count>a.length) count=a.length-index;
    if (a.$pas2jsrefcnt>1){
      // clone
      a.$pas2jsrefcnt--;
      a=rtl.arrayManaged(1,2,a.concat());
    }
    for (var i=0; i<count; i++) rtl.setIntfP(a,index+i,null);
    a.splice(index,count);
    return a;
  },

  setCharAt: function(s,index,c){
    return s.substr(0,index)+c+s.substr(index+1);
  },

  getResStr: function(mod,name){
    var rs = mod.$resourcestrings[name];
    return rs.current?rs.current:rs.org;
  },

  createSet: function(){
    var s = {};
    for (var i=0; i<arguments.length; i++){
      if (arguments[i]!=null){
        s[arguments[i]]=true;
      } else {
        var first=arguments[i+=1];
        var last=arguments[i+=1];
        for(var j=first; j<=last; j++) s[j]=true;
      }
    }
    return s;
  },

  cloneSet: function(s){
    var r = {};
    for (var key in s) r[key]=true;
    return r;
  },

  refSet: function(s){
    rtl.hideProp(s,'$shared',true);
    return s;
  },

  includeSet: function(s,enumvalue){
    if (s.$shared) s = rtl.cloneSet(s);
    s[enumvalue] = true;
    return s;
  },

  excludeSet: function(s,enumvalue){
    if (s.$shared) s = rtl.cloneSet(s);
    delete s[enumvalue];
    return s;
  },

  diffSet: function(s,t){
    var r = {};
    for (var key in s) if (!t[key]) r[key]=true;
    return r;
  },

  unionSet: function(s,t){
    var r = {};
    for (var key in s) r[key]=true;
    for (var key in t) r[key]=true;
    return r;
  },

  intersectSet: function(s,t){
    var r = {};
    for (var key in s) if (t[key]) r[key]=true;
    return r;
  },

  symDiffSet: function(s,t){
    var r = {};
    for (var key in s) if (!t[key]) r[key]=true;
    for (var key in t) if (!s[key]) r[key]=true;
    return r;
  },

  eqSet: function(s,t){
    for (var key in s) if (!t[key]) return false;
    for (var key in t) if (!s[key]) return false;
    return true;
  },

  neSet: function(s,t){
    return !rtl.eqSet(s,t);
  },

  leSet: function(s,t){
    for (var key in s) if (!t[key]) return false;
    return true;
  },

  geSet: function(s,t){
    for (var key in t) if (!s[key]) return false;
    return true;
  },

  strSetLength: function(s,newlen){
    var oldlen = s.length;
    if (oldlen > newlen){
      return s.substring(0,newlen);
    } else if (s.repeat){
      // Note: repeat needs ECMAScript6!
      return s+' '.repeat(newlen-oldlen);
    } else {
       while (oldlen<newlen){
         s+=' ';
         oldlen++;
       };
       return s;
    }
  },

  spaceLeft: function(s,width){
    var l=s.length;
    if (l>=width) return s;
    if (s.repeat){
      // Note: repeat needs ECMAScript6!
      return ' '.repeat(width-l) + s;
    } else {
      while (l<width){
        s=' '+s;
        l++;
      };
      return s;
    };
  },

  floatToStr: function(d,w,p){
    // input 1-3 arguments: double, width, precision
    if (arguments.length>2){
      return rtl.spaceLeft(d.toFixed(p),w);
    } else {
	  // exponent width
	  var pad = "";
	  var ad = Math.abs(d);
	  if (((ad>1) && (ad<1.0e+10)) ||  ((ad>1.e-10) && (ad<1))) {
		pad='00';
	  } else if ((ad>1) && (ad<1.0e+100) || (ad<1.e-10)) {
		pad='0';
      }  	
	  if (arguments.length<2) {
	    w=24;		
      } else if (w<9) {
		w=9;
      }		  
      var p = w-8;
      var s=(d>0 ? " " : "" ) + d.toExponential(p);
      s=s.replace(/e(.)/,'E$1'+pad);
      return rtl.spaceLeft(s,w);
    }
  },

  valEnum: function(s, enumType, setCodeFn){
    s = s.toLowerCase();
    for (var key in enumType){
      if((typeof(key)==='string') && (key.toLowerCase()===s)){
        setCodeFn(0);
        return enumType[key];
      }
    }
    setCodeFn(1);
    return 0;
  },

  lw: function(l){
    // fix longword bitwise operation
    return l<0?l+0x100000000:l;
  },

  and: function(a,b){
    var hi = 0x80000000;
    var low = 0x7fffffff;
    var h = (a / hi) & (b / hi);
    var l = (a & low) & (b & low);
    return h*hi + l;
  },

  or: function(a,b){
    var hi = 0x80000000;
    var low = 0x7fffffff;
    var h = (a / hi) | (b / hi);
    var l = (a & low) | (b & low);
    return h*hi + l;
  },

  xor: function(a,b){
    var hi = 0x80000000;
    var low = 0x7fffffff;
    var h = (a / hi) ^ (b / hi);
    var l = (a & low) ^ (b & low);
    return h*hi + l;
  },

  shr: function(a,b){
    if (a<0) a += rtl.hiInt;
    if (a<0x80000000) return a >> b;
    if (b<=0) return a;
    if (b>54) return 0;
    return Math.floor(a / Math.pow(2,b));
  },

  shl: function(a,b){
    if (a<0) a += rtl.hiInt;
    if (b<=0) return a;
    if (b>54) return 0;
    var r = a * Math.pow(2,b);
    if (r <= rtl.hiInt) return r;
    return r % rtl.hiInt;
  },

  initRTTI: function(){
    if (rtl.debug_rtti) rtl.debug('initRTTI');

    // base types
    rtl.tTypeInfo = { name: "tTypeInfo", kind: 0, $module: null, attr: null };
    function newBaseTI(name,kind,ancestor){
      if (!ancestor) ancestor = rtl.tTypeInfo;
      if (rtl.debug_rtti) rtl.debug('initRTTI.newBaseTI "'+name+'" '+kind+' ("'+ancestor.name+'")');
      var t = Object.create(ancestor);
      t.name = name;
      t.kind = kind;
      rtl[name] = t;
      return t;
    };
    function newBaseInt(name,minvalue,maxvalue,ordtype){
      var t = newBaseTI(name,1 /* tkInteger */,rtl.tTypeInfoInteger);
      t.minvalue = minvalue;
      t.maxvalue = maxvalue;
      t.ordtype = ordtype;
      return t;
    };
    newBaseTI("tTypeInfoInteger",1 /* tkInteger */);
    newBaseInt("shortint",-0x80,0x7f,0);
    newBaseInt("byte",0,0xff,1);
    newBaseInt("smallint",-0x8000,0x7fff,2);
    newBaseInt("word",0,0xffff,3);
    newBaseInt("longint",-0x80000000,0x7fffffff,4);
    newBaseInt("longword",0,0xffffffff,5);
    newBaseInt("nativeint",-0x10000000000000,0xfffffffffffff,6);
    newBaseInt("nativeuint",0,0xfffffffffffff,7);
    newBaseInt("char",0,65535,3 /* word */).kind=2 /* tkChar */;
    newBaseTI("string",3 /* tkString */);
    newBaseTI("tTypeInfoEnum",4 /* tkEnumeration */,rtl.tTypeInfoInteger);
    newBaseTI("tTypeInfoSet",5 /* tkSet */);
    newBaseTI("double",6 /* tkDouble */);
    newBaseTI("boolean",7 /* tkBool */);
    newBaseTI("tTypeInfoProcVar",8 /* tkProcVar */);
    newBaseTI("tTypeInfoMethodVar",9 /* tkMethod */,rtl.tTypeInfoProcVar);
    newBaseTI("tTypeInfoArray",10 /* tkArray */);
    newBaseTI("tTypeInfoDynArray",11 /* tkDynArray */);
    newBaseTI("tTypeInfoPointer",15 /* tkPointer */);
    var t = newBaseTI("pointer",15 /* tkPointer */,rtl.tTypeInfoPointer);
    t.reftype = null;
    newBaseTI("jsvalue",16 /* tkJSValue */);
    newBaseTI("tTypeInfoRefToProcVar",17 /* tkRefToProcVar */,rtl.tTypeInfoProcVar);

    // member kinds
    rtl.tTypeMember = { attr: null };
    function newMember(name,kind){
      var m = Object.create(rtl.tTypeMember);
      m.name = name;
      m.kind = kind;
      rtl[name] = m;
    };
    newMember("tTypeMemberField",1); // tmkField
    newMember("tTypeMemberMethod",2); // tmkMethod
    newMember("tTypeMemberProperty",3); // tmkProperty

    // base object for storing members: a simple object
    rtl.tTypeMembers = {};

    // tTypeInfoStruct - base object for tTypeInfoClass, tTypeInfoRecord, tTypeInfoInterface
    var tis = newBaseTI("tTypeInfoStruct",0);
    tis.$addMember = function(name,ancestor,vis,options){
      if (rtl.debug_rtti){
        if (!rtl.hasString(name) || (name.charAt()==='$')) throw 'invalid member "'+name+'", this="'+this.name+'"';
        if (!rtl.is(ancestor,rtl.tTypeMember)) throw 'invalid ancestor "'+ancestor+':'+ancestor.name+'", "'+this.name+'.'+name+'"';
        if ((options!=undefined) && (typeof(options)!='object')) throw 'invalid options "'+options+'", "'+this.name+'.'+name+'"';
      };
      var t = Object.create(ancestor);
      t.name = name;
      this.members[name] = t;
      this.names.push(name);
      t.visibility = vis;
      if (rtl.isObject(options)){
        for (var key in options) if (options.hasOwnProperty(key)) t[key] = options[key];
      };
      return t;
    };
    tis.addField = function(name,type,vis,options){
      var t = this.$addMember(name,rtl.tTypeMemberField,vis?vis:2,options);
      if (rtl.debug_rtti){
        if (!rtl.is(type,rtl.tTypeInfo)) throw 'invalid type "'+type+'", "'+this.name+'.'+name+'"';
      };
      t.typeinfo = type;
      this.fields.push(name);
      return t;
    };
    tis.addFields = function(){
      var i=0;
      while(i<arguments.length){
        var name = arguments[i++];
        var type = arguments[i++];
        if ((i<arguments.length) && (typeof(arguments[i])==='object')){
          this.addField(name,type,arguments[i++]);
        } else {
          this.addField(name,type);
        };
      };
    };
    tis.addMethod = function(name,methodkind,params,vis,result,flags,options){
      // optional: vis, result, flags, options
      var t = this.$addMember(name,rtl.tTypeMemberMethod,vis?vis:2,options);
      t.methodkind = methodkind;
      t.procsig = rtl.newTIProcSig(params,result,flags);
      this.methods.push(name);
      return t;
    };
    tis.addProperty = function(name,flags,result,getter,setter,vis,options){
      var t = this.$addMember(name,rtl.tTypeMemberProperty,vis?vis:4,options);
      t.flags = flags;
      t.typeinfo = result;
      t.getter = getter;
      t.setter = setter;
      // Note: in options: params, stored, defaultvalue
      t.params = rtl.isArray(t.params) ? rtl.newTIParams(t.params) : null;
      this.properties.push(name);
      if (!rtl.isString(t.stored)) t.stored = "";
      return t;
    };
    tis.getField = function(index){
      return this.members[this.fields[index]];
    };
    tis.getMethod = function(index){
      return this.members[this.methods[index]];
    };
    tis.getProperty = function(index){
      return this.members[this.properties[index]];
    };

    newBaseTI("tTypeInfoRecord",12 /* tkRecord */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoClass",13 /* tkClass */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoClassRef",14 /* tkClassRef */);
    newBaseTI("tTypeInfoInterface",18 /* tkInterface */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoHelper",19 /* tkHelper */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoExtClass",20 /* tkExtClass */,rtl.tTypeInfoClass);
  },

  tSectionRTTI: {
    $module: null,
    $inherited: function(name,ancestor,o){
      if (rtl.debug_rtti){
        rtl.debug('tSectionRTTI.newTI "'+(this.$module?this.$module.$name:"(no module)")
          +'"."'+name+'" ('+ancestor.name+') '+(o?'init':'forward'));
      };
      var t = this[name];
      if (t){
        if (!t.$forward) {
          return t;
        }
        if (!ancestor.isPrototypeOf(t)) throw 'typeinfo ancestor mismatch "'+name+'" ancestor="'+ancestor.name+'" t.name="'+t.name+'"';
      } else {
        t = Object.create(ancestor);
        t.name = name;
        t.$module = this.$module;
        this[name] = t;
      }
      if (o){
        delete t.$forward;
        for (var key in o) if (o.hasOwnProperty(key)) t[key]=o[key];
      } else {
        t.$forward = true;
      }
      return t;
    },
    $Scope: function(name,ancestor,o){
      var t=this.$inherited(name,ancestor,o);
      if (!t.members) {
        t.members = {};
      }
      if (!t.names) {
        t.names = [];
      }
      if (!t.fields) {
        t.fields = [];
      }  
      if (!t.methods) {
        t.methods = [];
      }  
      if (!t.properties) {
        t.properties = [];
      }  
      return t;
    },
    $TI: function(name,kind,o){ var t=this.$inherited(name,rtl.tTypeInfo,o); t.kind = kind; return t; },
    $Int: function(name,o){ return this.$inherited(name,rtl.tTypeInfoInteger,o); },
    $Enum: function(name,o){ return this.$inherited(name,rtl.tTypeInfoEnum,o); },
    $Set: function(name,o){ return this.$inherited(name,rtl.tTypeInfoSet,o); },
    $StaticArray: function(name,o){ return this.$inherited(name,rtl.tTypeInfoArray,o); },
    $DynArray: function(name,o){ return this.$inherited(name,rtl.tTypeInfoDynArray,o); },
    $ProcVar: function(name,o){ return this.$inherited(name,rtl.tTypeInfoProcVar,o); },
    $RefToProcVar: function(name,o){ return this.$inherited(name,rtl.tTypeInfoRefToProcVar,o); },
    $MethodVar: function(name,o){ return this.$inherited(name,rtl.tTypeInfoMethodVar,o); },
    $Record: function(name,o,typ){ if(typ) o.$record = typ; return this.$Scope(name,rtl.tTypeInfoRecord,o); },
    $Class: function(name,o){ return this.$Scope(name,rtl.tTypeInfoClass,o); },
    $ClassRef: function(name,o){ return this.$inherited(name,rtl.tTypeInfoClassRef,o); },
    $Pointer: function(name,o){ return this.$inherited(name,rtl.tTypeInfoPointer,o); },
    $Interface: function(name,o){ return this.$Scope(name,rtl.tTypeInfoInterface,o); },
    $Helper: function(name,o){ return this.$Scope(name,rtl.tTypeInfoHelper,o); },
    $ExtClass: function(name,o){ return this.$Scope(name,rtl.tTypeInfoExtClass,o); }
  },

  newTIParam: function(param){
    // param is an array, 0=name, 1=type, 2=optional flags
    var t = {
      name: param[0],
      typeinfo: param[1],
      flags: (rtl.isNumber(param[2]) ? param[2] : 0)
    };
    return t;
  },

  newTIParams: function(list){
    // list: optional array of [paramname,typeinfo,optional flags]
    var params = [];
    if (rtl.isArray(list)){
      for (var i=0; i<list.length; i++) params.push(rtl.newTIParam(list[i]));
    };
    return params;
  },

  newTIProcSig: function(params,result,flags){
    var s = {
      params: rtl.newTIParams(params),
      resulttype: result?result:null,
      flags: flags?flags:0
    };
    return s;
  },

  addResource: function(aRes){
    rtl.$res[aRes.name]=aRes;
  },

  getResource: function(aName){
    var res = rtl.$res[aName];
    if (res !== undefined) {
      return res;
    } else {
      return null;
    }
  },

  getResourceList: function(){
    return Object.keys(rtl.$res);
  }
}

rtl.module("System",[],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.LineEnding = "\n";
  this.sLineBreak = this.LineEnding;
  this.PathDelim = "/";
  this.$rtti.$Set("AllowDirectorySeparators$a",{comptype: rtl.char});
  this.AllowDirectorySeparators = rtl.createSet(47,92);
  this.$rtti.$Set("AllowDriveSeparators$a",{comptype: rtl.char});
  this.AllowDriveSeparators = rtl.createSet(58);
  this.ExtensionSeparator = ".";
  this.MaxSmallint = 32767;
  this.MinSmallint = -32768;
  this.MaxShortInt = 127;
  this.MinShortInt = -128;
  this.MaxByte = 0xFF;
  this.MaxWord = 0xFFFF;
  this.MaxLongint = 0x7fffffff;
  this.MaxCardinal = 0xffffffff;
  this.Maxint = 2147483647;
  this.IsMultiThread = false;
  this.$rtti.$inherited("Real",rtl.double,{});
  this.$rtti.$inherited("Extended",rtl.double,{});
  this.$rtti.$inherited("TDateTime",rtl.double,{});
  this.$rtti.$inherited("TTime",this.$rtti["TDateTime"],{});
  this.$rtti.$inherited("TDate",this.$rtti["TDateTime"],{});
  this.$rtti.$inherited("UInt64",rtl.nativeuint,{});
  this.$rtti.$inherited("QWord",rtl.nativeuint,{});
  this.$rtti.$inherited("Comp",rtl.nativeint,{});
  this.$rtti.$inherited("WideString",rtl.string,{});
  this.TTextLineBreakStyle = {"0": "tlbsLF", tlbsLF: 0, "1": "tlbsCRLF", tlbsCRLF: 1, "2": "tlbsCR", tlbsCR: 2};
  this.$rtti.$Enum("TTextLineBreakStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTextLineBreakStyle});
  this.TCompareOption = {"0": "coIgnoreCase", coIgnoreCase: 0, "1": "coDigitAsNumbers", coDigitAsNumbers: 1};
  this.$rtti.$Enum("TCompareOption",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TCompareOption});
  this.$rtti.$Set("TCompareOptions",{comptype: this.$rtti["TCompareOption"]});
  rtl.recNewT(this,"TGuid",function () {
    this.D1 = 0;
    this.D2 = 0;
    this.D3 = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.D4 = rtl.arraySetLength(null,0,8);
      return r;
    };
    this.$eq = function (b) {
      return (this.D1 === b.D1) && (this.D2 === b.D2) && (this.D3 === b.D3) && rtl.arrayEq(this.D4,b.D4);
    };
    this.$assign = function (s) {
      this.D1 = s.D1;
      this.D2 = s.D2;
      this.D3 = s.D3;
      this.D4 = s.D4.slice(0);
      return this;
    };
    var $r = $mod.$rtti.$Record("TGuid",{},this);
    $r.addField("D1",rtl.longword);
    $r.addField("D2",rtl.word);
    $r.addField("D3",rtl.word);
    $mod.$rtti.$StaticArray("TGuid.D4$a",{dims: [8], eltype: rtl.byte});
    $r.addField("D4",$mod.$rtti["TGuid.D4$a"]);
  });
  this.$rtti.$inherited("TGUIDString",rtl.string,{});
  this.$rtti.$Pointer("PMethod",{reftype: this.$rtti["TMethod"]});
  rtl.recNewT(this,"TMethod",function () {
    this.Code = null;
    this.Data = null;
    this.$eq = function (b) {
      return (this.Code === b.Code) && (this.Data === b.Data);
    };
    this.$assign = function (s) {
      this.Code = s.Code;
      this.Data = s.Data;
      return this;
    };
    var $r = $mod.$rtti.$Record("TMethod",{},this);
    $r.addField("Code",rtl.pointer);
    $r.addField("Data",rtl.pointer);
  });
  this.$rtti.$Class("TObject");
  this.$rtti.$ClassRef("TClass",{instancetype: this.$rtti["TObject"]});
  rtl.createClass(this,"TObject",null,function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
    this.Create = function () {
      return this;
    };
    this.Destroy = function () {
    };
    this.Free = function () {
      this.$destroy("Destroy");
    };
    this.ClassType = function () {
      return this;
    };
    this.ClassNameIs = function (Name) {
      var Result = false;
      Result = $impl.SameText(Name,this.$classname);
      return Result;
    };
    this.InheritsFrom = function (aClass) {
      return (aClass!=null) && ((this==aClass) || aClass.isPrototypeOf(this));
    };
    this.MethodName = function (aCode) {
      var Result = "";
      Result = "";
      if (aCode === null) return Result;
      if (typeof(aCode)!=='function') return "";
      var i = 0;
      var TI = this.$rtti;
      if (rtl.isObject(aCode.scope)){
        // callback
        if (typeof aCode.fn === "string") return aCode.fn;
        aCode = aCode.fn;
      }
      // Not a callback, check rtti
      while ((Result === "") && (TI != null)) {
        i = 0;
        while ((Result === "") && (i < TI.methods.length)) {
          if (this[TI.getMethod(i).name] === aCode)
            Result=TI.getMethod(i).name;
          i += 1;
        };
        if (Result === "") TI = TI.ancestor;
      };
      // return Result;
      return Result;
    };
    this.MethodAddress = function (aName) {
      var Result = null;
      Result = null;
      if (aName === "") return Result;
      var i = 0;
        var TI = this.$rtti;
        var N = "";
        var MN = "";
        N = aName.toLowerCase();
        while ((MN === "") && (TI != null)) {
          i = 0;
          while ((MN === "") && (i < TI.methods.length)) {
            if (TI.getMethod(i).name.toLowerCase() === N) MN = TI.getMethod(i).name;
            i += 1;
          };
          if (MN === "") TI = TI.ancestor;
        };
        if (MN !== "") Result = this[MN];
      //  return Result;
      return Result;
    };
    this.FieldAddress = function (aName) {
      var Result = null;
      Result = null;
      if (aName === "") return Result;
      var aClass = this.$class;
      var ClassTI = null;
      var myName = aName.toLowerCase();
      var MemberTI = null;
      while (aClass !== null) {
        ClassTI = aClass.$rtti;
        for (var i = 0, $end2 = ClassTI.fields.length - 1; i <= $end2; i++) {
          MemberTI = ClassTI.getField(i);
          if (MemberTI.name.toLowerCase() === myName) {
             return MemberTI;
          };
        };
        aClass = aClass.$ancestor ? aClass.$ancestor : null;
      };
      return Result;
    };
    this.ClassInfo = function () {
      var Result = null;
      Result = this.$rtti;
      return Result;
    };
    this.QualifiedClassName = function () {
      var Result = "";
      Result = this.$module.$name + "." + this.$classname;
      return Result;
    };
    this.AfterConstruction = function () {
    };
    this.BeforeDestruction = function () {
    };
    this.Dispatch = function (aMessage) {
      var aClass = null;
      var Id = undefined;
      if (!rtl.isObject(aMessage)) return;
      Id = aMessage["Msg"];
      if (!rtl.isNumber(Id)) return;
      aClass = this.$class.ClassType();
      while (aClass !== null) {
        var Handlers = aClass.$msgint;
        if (rtl.isObject(Handlers) && Handlers.hasOwnProperty(Id)){
          this[Handlers[Id]](aMessage);
          return;
        };
        aClass = aClass.$ancestor;
      };
      this.DefaultHandler(aMessage);
    };
    this.DispatchStr = function (aMessage) {
      var aClass = null;
      var Id = undefined;
      if (!rtl.isObject(aMessage)) return;
      Id = aMessage["MsgStr"];
      if (!rtl.isString(Id)) return;
      aClass = this.$class.ClassType();
      while (aClass !== null) {
        var Handlers = aClass.$msgstr;
        if (rtl.isObject(Handlers) && Handlers.hasOwnProperty(Id)){
          this[Handlers[Id]](aMessage);
          return;
        };
        aClass = aClass.$ancestor;
      };
      this.DefaultHandlerStr(aMessage);
    };
    this.DefaultHandler = function (aMessage) {
      if (aMessage) ;
    };
    this.DefaultHandlerStr = function (aMessage) {
      if (aMessage) ;
    };
    this.GetInterface = function (iid, obj) {
      var Result = false;
      var i = iid.$intf;
      if (i){
        // iid is the private TGuid of an interface
        i = rtl.getIntfG(this,i.$guid,2);
        if (i){
          obj.set(i);
          return true;
        }
      };
      Result = this.GetInterfaceByStr(rtl.guidrToStr(iid),obj);
      return Result;
    };
    this.GetInterface$1 = function (iidstr, obj) {
      var Result = false;
      Result = this.GetInterfaceByStr(iidstr,obj);
      return Result;
    };
    this.GetInterfaceByStr = function (iidstr, obj) {
      var Result = false;
      Result = false;
      if (!$mod.IObjectInstance["$str"]) $mod.IObjectInstance["$str"] = rtl.guidrToStr($mod.IObjectInstance);
      if (iidstr == $mod.IObjectInstance["$str"]) {
        obj.set(this);
        return true;
      };
      var i = rtl.getIntfG(this,iidstr,2);
      obj.set(i);
      Result=(i!==null);
      return Result;
    };
    this.GetInterfaceWeak = function (iid, obj) {
      var Result = false;
      Result = this.GetInterface(iid,obj);
      if (Result){
        var o = obj.get();
        if (o.$kind==='com'){
          o._Release();
        }
      };
      return Result;
    };
    this.Equals = function (Obj) {
      var Result = false;
      Result = Obj === this;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.$classname;
      return Result;
    };
  });
  rtl.createClass(this,"TCustomAttribute",this.TObject,function () {
  });
  this.$rtti.$DynArray("TCustomAttributeArray",{eltype: this.$rtti["TCustomAttribute"]});
  this.$rtti.$ClassRef("TCustomAttributeClass",{instancetype: this.$rtti["TCustomAttribute"]});
  this.S_OK = 0;
  this.S_FALSE = 1;
  this.E_NOINTERFACE = -2147467262;
  this.E_UNEXPECTED = -2147418113;
  this.E_NOTIMPL = -2147467263;
  rtl.createInterface(this,"IUnknown","{00000000-0000-0000-C000-000000000046}",["QueryInterface","_AddRef","_Release"],null,function () {
    this.$kind = "com";
    var $r = this.$rtti;
    $r.addMethod("QueryInterface",1,[["iid",$mod.$rtti["TGuid"],2],["obj",null,4]],2,rtl.longint);
    $r.addMethod("_AddRef",1,[],2,rtl.longint);
    $r.addMethod("_Release",1,[],2,rtl.longint);
  });
  rtl.createInterface(this,"IInvokable","{88387EF6-BCEE-3E17-9E85-5D491ED4FC10}",[],this.IUnknown,function () {
  });
  rtl.createInterface(this,"IEnumerator","{ECEC7568-4E50-30C9-A2F0-439342DE2ADB}",["GetCurrent","MoveNext","Reset"],this.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCurrent",1,[],2,$mod.$rtti["TObject"]);
    $r.addMethod("MoveNext",1,[],2,rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,$mod.$rtti["TObject"],"GetCurrent","",2);
  });
  rtl.createInterface(this,"IEnumerable","{9791C368-4E51-3424-A3CE-D4911D54F385}",["GetEnumerator"],this.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator"]);
  });
  rtl.createClass(this,"TInterfacedObject",this.TObject,function () {
    this.$init = function () {
      $mod.TObject.$init.call(this);
      this.fRefCount = 0;
    };
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      if (this.GetInterface(iid,obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    this._AddRef = function () {
      var Result = 0;
      this.fRefCount += 1;
      Result = this.fRefCount;
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      this.fRefCount -= 1;
      Result = this.fRefCount;
      if (this.fRefCount === 0) this.$destroy("Destroy");
      return Result;
    };
    this.BeforeDestruction = function () {
      if (this.fRefCount !== 0) rtl.raiseE('EHeapMemoryError');
    };
    rtl.addIntf(this,$mod.IUnknown);
  });
  this.$rtti.$ClassRef("TInterfacedClass",{instancetype: this.$rtti["TInterfacedObject"]});
  rtl.createClass(this,"TAggregatedObject",this.TObject,function () {
    this.$init = function () {
      $mod.TObject.$init.call(this);
      this.fController = null;
    };
    this.GetController = function () {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,this.fController);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      Result = this.fController.QueryInterface(iid,obj);
      return Result;
    };
    this._AddRef = function () {
      var Result = 0;
      Result = this.fController._AddRef();
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      Result = this.fController._Release();
      return Result;
    };
    this.Create$1 = function (aController) {
      $mod.TObject.Create.call(this);
      this.fController = aController;
      return this;
    };
  });
  rtl.createClass(this,"TContainedObject",this.TAggregatedObject,function () {
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      if (this.GetInterface(iid,obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    rtl.addIntf(this,$mod.IUnknown);
  });
  this.IObjectInstance = this.TGuid.$clone({D1: 0xD91C9AF4, D2: 0x3C93, D3: 0x420F, D4: [0xA3,0x03,0xBF,0x5B,0xA8,0x2B,0xFD,0x23]});
  this.TTypeKind = {"0": "tkUnknown", tkUnknown: 0, "1": "tkInteger", tkInteger: 1, "2": "tkChar", tkChar: 2, "3": "tkString", tkString: 3, "4": "tkEnumeration", tkEnumeration: 4, "5": "tkSet", tkSet: 5, "6": "tkDouble", tkDouble: 6, "7": "tkBool", tkBool: 7, "8": "tkProcVar", tkProcVar: 8, "9": "tkMethod", tkMethod: 9, "10": "tkArray", tkArray: 10, "11": "tkDynArray", tkDynArray: 11, "12": "tkRecord", tkRecord: 12, "13": "tkClass", tkClass: 13, "14": "tkClassRef", tkClassRef: 14, "15": "tkPointer", tkPointer: 15, "16": "tkJSValue", tkJSValue: 16, "17": "tkRefToProcVar", tkRefToProcVar: 17, "18": "tkInterface", tkInterface: 18, "19": "tkHelper", tkHelper: 19, "20": "tkExtClass", tkExtClass: 20};
  this.$rtti.$Enum("TTypeKind",{minvalue: 0, maxvalue: 20, ordtype: 1, enumtype: this.TTypeKind});
  this.$rtti.$Set("TTypeKinds",{comptype: this.$rtti["TTypeKind"]});
  this.tkFloat = this.TTypeKind.tkDouble;
  this.tkProcedure = this.TTypeKind.tkProcVar;
  this.tkAny = rtl.createSet(null,this.TTypeKind.tkUnknown,this.TTypeKind.tkExtClass);
  this.tkMethods = rtl.createSet(this.TTypeKind.tkMethod);
  this.tkProperties = rtl.diffSet(rtl.diffSet(this.tkAny,this.tkMethods),rtl.createSet(this.TTypeKind.tkUnknown));
  this.vtInteger = 0;
  this.vtBoolean = 1;
  this.vtExtended = 3;
  this.vtPointer = 5;
  this.vtObject = 7;
  this.vtClass = 8;
  this.vtWideChar = 9;
  this.vtCurrency = 12;
  this.vtInterface = 14;
  this.vtUnicodeString = 18;
  this.vtNativeInt = 19;
  this.vtJSValue = 20;
  this.$rtti.$Pointer("PVarRec",{reftype: this.$rtti["TVarRec"]});
  rtl.recNewT(this,"TVarRec",function () {
    this.VType = 0;
    this.VJSValue = undefined;
    this.$eq = function (b) {
      return (this.VType === b.VType) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue);
    };
    this.$assign = function (s) {
      this.VType = s.VType;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TVarRec",{},this);
    $r.addField("VType",rtl.byte);
    $r.addField("VJSValue",rtl.jsvalue);
    $r.addField("VJSValue",rtl.longint);
    $r.addField("VJSValue",rtl.boolean);
    $r.addField("VJSValue",rtl.double);
    $r.addField("VJSValue",rtl.pointer);
    $r.addField("VJSValue",$mod.$rtti["TObject"]);
    $r.addField("VJSValue",$mod.$rtti["TClass"]);
    $r.addField("VJSValue",rtl.char);
    $r.addField("VJSValue",rtl.nativeint);
    $r.addField("VJSValue",rtl.pointer);
    $r.addField("VJSValue",rtl.string);
    $r.addField("VJSValue",rtl.nativeint);
  });
  this.$rtti.$DynArray("TVarRecArray",{eltype: this.$rtti["TVarRec"]});
  this.VarRecs = function () {
    var Result = [];
    var i = 0;
    var v = null;
    Result = [];
    while (i < arguments.length) {
      v = $mod.TVarRec.$new();
      v.VType = rtl.trunc(arguments[i]);
      i += 1;
      v.VJSValue = arguments[i];
      i += 1;
      Result.push($mod.TVarRec.$clone(v));
    };
    return Result;
  };
  this.IsConsole = false;
  this.FirstDotAtFileNameStartIsExtension = false;
  this.$rtti.$ProcVar("TOnParamCount",{procsig: rtl.newTIProcSig([],rtl.longint)});
  this.$rtti.$ProcVar("TOnParamStr",{procsig: rtl.newTIProcSig([["Index",rtl.longint]],rtl.string)});
  this.OnParamCount = null;
  this.OnParamStr = null;
  this.ParamCount = function () {
    var Result = 0;
    if ($mod.OnParamCount != null) {
      Result = $mod.OnParamCount()}
     else Result = 0;
    return Result;
  };
  this.ParamStr = function (Index) {
    var Result = "";
    if ($mod.OnParamStr != null) {
      Result = $mod.OnParamStr(Index)}
     else if (Index === 0) {
      Result = "js"}
     else Result = "";
    return Result;
  };
  this.Frac = function (A) {
    return A % 1;
  };
  this.Odd = function (A) {
    return A&1 != 0;
  };
  this.Random = function (Range) {
    return Math.floor(Math.random()*Range);
  };
  this.Sqr = function (A) {
    return A*A;
  };
  this.Sqr$1 = function (A) {
    return A*A;
  };
  this.Trunc = function (A) {
    if (!Math.trunc) {
      Math.trunc = function(v) {
        v = +v;
        if (!isFinite(v)) return v;
        return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
      };
    }
    $mod.Trunc = Math.trunc;
    return Math.trunc(A);
  };
  this.DefaultTextLineBreakStyle = this.TTextLineBreakStyle.tlbsLF;
  this.Int = function (A) {
    var Result = 0.0;
    Result = $mod.Trunc(A);
    return Result;
  };
  this.Copy = function (S, Index, Size) {
    if (Index<1) Index = 1;
    return (Size>0) ? S.substring(Index-1,Index+Size-1) : "";
  };
  this.Copy$1 = function (S, Index) {
    if (Index<1) Index = 1;
    return S.substr(Index-1);
  };
  this.Delete = function (S, Index, Size) {
    var h = "";
    if ((Index < 1) || (Index > S.get().length) || (Size <= 0)) return;
    h = S.get();
    S.set($mod.Copy(h,1,Index - 1) + $mod.Copy$1(h,Index + Size));
  };
  this.Pos = function (Search, InString) {
    return InString.indexOf(Search)+1;
  };
  this.Pos$1 = function (Search, InString, StartAt) {
    return InString.indexOf(Search,StartAt-1)+1;
  };
  this.Insert = function (Insertion, Target, Index) {
    var t = "";
    if (Insertion === "") return;
    t = Target.get();
    if (Index < 1) {
      Target.set(Insertion + t)}
     else if (Index > t.length) {
      Target.set(t + Insertion)}
     else Target.set($mod.Copy(t,1,Index - 1) + Insertion + $mod.Copy(t,Index,t.length));
  };
  this.upcase = function (c) {
    return c.toUpperCase();
  };
  this.binstr = function (val, cnt) {
    var Result = "";
    var i = 0;
    Result = rtl.strSetLength(Result,cnt);
    for (var $l = cnt; $l >= 1; $l--) {
      i = $l;
      Result = rtl.setCharAt(Result,i - 1,String.fromCharCode(48 + (val & 1)));
      val = Math.floor(val / 2);
    };
    return Result;
  };
  this.val = function (S, NI, Code) {
    NI.set($impl.valint(S,-9007199254740991,9007199254740991,Code));
  };
  this.val$1 = function (S, NI, Code) {
    var x = 0.0;
    if (S === "") {
      Code.set(1);
      return;
    };
    x = Number(S);
    if (isNaN(x) || (x !== $mod.Int(x)) || (x < 0)) {
      Code.set(1)}
     else {
      Code.set(0);
      NI.set($mod.Trunc(x));
    };
  };
  this.val$2 = function (S, SI, Code) {
    SI.set($impl.valint(S,-128,127,Code));
  };
  this.val$3 = function (S, B, Code) {
    B.set($impl.valint(S,0,255,Code));
  };
  this.val$4 = function (S, SI, Code) {
    SI.set($impl.valint(S,-32768,32767,Code));
  };
  this.val$5 = function (S, W, Code) {
    W.set($impl.valint(S,0,65535,Code));
  };
  this.val$6 = function (S, I, Code) {
    I.set($impl.valint(S,-2147483648,2147483647,Code));
  };
  this.val$7 = function (S, C, Code) {
    C.set($impl.valint(S,0,4294967295,Code));
  };
  this.val$8 = function (S, d, Code) {
    var x = 0.0;
    if (S === "") {
      Code.set(1);
      return;
    };
    x = Number(S);
    if (isNaN(x)) {
      Code.set(1)}
     else {
      Code.set(0);
      d.set(x);
    };
  };
  this.val$9 = function (S, b, Code) {
    if ($impl.SameText(S,"true")) {
      Code.set(0);
      b.set(true);
    } else if ($impl.SameText(S,"false")) {
      Code.set(0);
      b.set(false);
    } else Code.set(1);
  };
  this.StringOfChar = function (c, l) {
    var Result = "";
    var i = 0;
    if ((l>0) && c.repeat) return c.repeat(l);
    Result = "";
    for (var $l = 1, $end = l; $l <= $end; $l++) {
      i = $l;
      Result = Result + c;
    };
    return Result;
  };
  this.Write = function () {
    var i = 0;
    for (var $l = 0, $end = arguments.length - 1; $l <= $end; $l++) {
      i = $l;
      if ($impl.WriteCallBack != null) {
        $impl.WriteCallBack(arguments[i],false)}
       else $impl.WriteBuf = $impl.WriteBuf + ("" + arguments[i]);
    };
  };
  this.Writeln = function () {
    var i = 0;
    var l = 0;
    var s = "";
    l = arguments.length - 1;
    if ($impl.WriteCallBack != null) {
      for (var $l = 0, $end = l; $l <= $end; $l++) {
        i = $l;
        $impl.WriteCallBack(arguments[i],i === l);
      };
    } else {
      s = $impl.WriteBuf;
      for (var $l1 = 0, $end1 = l; $l1 <= $end1; $l1++) {
        i = $l1;
        s = s + ("" + arguments[i]);
      };
      console.log(s);
      $impl.WriteBuf = "";
    };
  };
  this.$rtti.$ProcVar("TConsoleHandler",{procsig: rtl.newTIProcSig([["S",rtl.jsvalue],["NewLine",rtl.boolean]])});
  this.SetWriteCallBack = function (H) {
    var Result = null;
    Result = $impl.WriteCallBack;
    $impl.WriteCallBack = H;
    return Result;
  };
  this.Assigned = function (V) {
    return (V!=undefined) && (V!=null) && (!rtl.isArray(V) || (V.length > 0));
  };
  this.StrictEqual = function (A, B) {
    return A === B;
  };
  this.StrictInequal = function (A, B) {
    return A !== B;
  };
  this.$rtti.$DynArray("TArray<RTTI.TValue>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiType>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiField>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiParameter>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiMethod>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiProperty>",{});
  this.$rtti.$DynArray("TArray<Classes.TPersistentClass>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.Double,System.Double>>",{});
  this.$rtti.$DynArray("TArray<System.Longint>",{eltype: rtl.longint});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.String,System.TObject>>",{});
  this.$rtti.$DynArray("TArray<System.TObject>",{eltype: this.$rtti["TObject"]});
  this.$rtti.$DynArray("TArray<System.String>",{eltype: rtl.string});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.Longint,System.TObject>>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.Longint,System.Longint>>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.Longint,System.Boolean>>",{});
  this.$rtti.$DynArray("TArray<System.Boolean>",{eltype: rtl.boolean});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.Longint,System.Double>>",{});
  this.$rtti.$DynArray("TArray<System.Double>",{eltype: rtl.double});
  this.$rtti.$DynArray("TArray<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>",{});
  this.$rtti.$DynArray("TArray<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>",{});
  this.$rtti.$DynArray("TArray<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>",{});
  this.$rtti.$DynArray("TArray<Generics.Collections.TPair<System.String,WEBLib.DesignIntf.TIconData>>",{});
  this.$rtti.$DynArray("TArray<WEBLib.DesignIntf.TIconData>",{});
  $mod.$implcode = function () {
    $mod.$rtti.$ExtClass("TJSObj",{jsclass: "Object"});
    $mod.$rtti.$ExtClass("TJSArray",{jsclass: "Array"});
    $mod.$rtti.$ExtClass("TJSArguments",{jsclass: "arguments"});
    $impl.SameText = function (s1, s2) {
      return s1.toLowerCase() == s2.toLowerCase();
    };
    $impl.WriteBuf = "";
    $impl.WriteCallBack = null;
    $impl.valint = function (S, MinVal, MaxVal, Code) {
      var Result = 0;
      var x = 0.0;
      if (S === "") {
        Code.set(1);
        return Result;
      };
      x = Number(S);
      if (isNaN(x)) {
        var $tmp = $mod.Copy(S,1,1);
        if ($tmp === "$") {
          x = Number("0x" + $mod.Copy$1(S,2))}
         else if ($tmp === "&") {
          x = Number("0o" + $mod.Copy$1(S,2))}
         else if ($tmp === "%") {
          x = Number("0b" + $mod.Copy$1(S,2))}
         else {
          Code.set(1);
          return Result;
        };
      };
      if (isNaN(x) || (x !== $mod.Int(x))) {
        Code.set(1)}
       else if ((x < MinVal) || (x > MaxVal)) {
        Code.set(2)}
       else {
        Result = $mod.Trunc(x);
        Code.set(0);
      };
      return Result;
    };
  };
  $mod.$init = function () {
    rtl.exitcode = 0;
  };
},[]);
rtl.module("RTLConsts",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$resourcestrings = {SArgumentMissing: {org: 'Missing argument in format "%s"'}, SInvalidFormat: {org: 'Invalid format specifier : "%s"'}, SInvalidArgIndex: {org: 'Invalid argument index in format: "%s"'}, SListCapacityError: {org: "List capacity (%s) exceeded."}, SListCountError: {org: "List count (%s) out of bounds."}, SMapKeyError: {org: "Key not found : %s"}, SListIndexError: {org: "List index (%s) out of bounds"}, SSortedListError: {org: "Operation not allowed on sorted list"}, SDuplicateString: {org: "String list does not allow duplicates"}, SDuplicateItem: {org: "ThreadList does not allow duplicates"}, SErrFindNeedsSortedList: {org: "Cannot use find on unsorted list"}, SInvalidName: {org: 'Invalid component name: "%s"'}, SInvalidBoolean: {org: '"%s" is not a valid boolean.'}, SDuplicateName: {org: 'Duplicate component name: "%s"'}, SErrInvalidDate: {org: 'Invalid date: "%s"'}, SErrInvalidTimeFormat: {org: 'Invalid time format: "%s"'}, SInvalidDateFormat: {org: 'Invalid date format: "%s"'}, SCantReadPropertyS: {org: 'Cannot read property "%s"'}, SCantWritePropertyS: {org: 'Cannot write property "%s"'}, SErrPropertyNotFound: {org: 'Unknown property: "%s"'}, SIndexedPropertyNeedsParams: {org: 'Indexed property "%s" needs parameters'}, SErrInvalidTypecast: {org: "Invalid class typecast"}, SErrInvalidInteger: {org: 'Invalid integer value: "%s"'}, SErrInvalidFloat: {org: 'Invalid floating-point value: "%s"'}, SInvalidDateTime: {org: "Invalid date-time value: %s"}, SInvalidCurrency: {org: "Invalid currency value: %s"}, SErrInvalidDayOfWeek: {org: "%d is not a valid day of the week"}, SErrInvalidTimeStamp: {org: 'Invalid date/timestamp : "%s"'}, SErrInvalidDateWeek: {org: "%d %d %d is not a valid dateweek"}, SErrInvalidDayOfYear: {org: "Year %d does not have a day number %d"}, SErrInvalidDateMonthWeek: {org: "Year %d, month %d, Week %d and day %d is not a valid date."}, SErrInvalidDayOfWeekInMonth: {org: "Year %d Month %d NDow %d DOW %d is not a valid date"}, SInvalidJulianDate: {org: "%f Julian cannot be represented as a DateTime"}, SErrInvalidHourMinuteSecMsec: {org: "%d:%d:%d.%d is not a valid time specification"}, SInvalidGUID: {org: '"%s" is not a valid GUID value'}, SEmptyStreamIllegalReader: {org: "Illegal Nil stream for TReader constructor"}, SInvalidPropertyValue: {org: "Invalid value for property"}, SInvalidImage: {org: "Invalid stream format"}, SUnknownProperty: {org: 'Unknown property: "%s"'}, SUnknownPropertyType: {org: "Unknown property type %s"}, SAncestorNotFound: {org: 'Ancestor class for "%s" not found.'}, SUnsupportedPropertyVariantType: {org: "Unsupported property variant type %d"}, SPropertyException: {org: "Error reading %s%s%s: %s"}, SInvalidPropertyPath: {org: "Invalid property path"}, SReadOnlyProperty: {org: "Property is read-only"}, SClassNotFound: {org: 'Class "%s" not found'}, SEmptyStreamIllegalWriter: {org: "Illegal Nil stream for TWriter constructor"}, SErrInvalidPropertyType: {org: "Invalid property type from streamed property: %d"}, SParserExpected: {org: "Wrong token type: %s expected"}, SParserInvalidFloat: {org: "Invalid floating point number: %s"}, SParserInvalidInteger: {org: "Invalid integer number: %s"}, SParserUnterminatedString: {org: "Unterminated string"}, SParserWrongTokenType: {org: "Wrong token type: %s expected but %s found"}, SParserWrongTokenSymbol: {org: "Wrong token symbol: %s expected but %s found"}, SParserLocInfo: {org: " (at %d,%d, stream offset %.8x)"}, SParserUnterminatedBinValue: {org: "Unterminated byte value"}, SParserInvalidProperty: {org: "Invalid property"}, SRangeError: {org: "Range error"}, SParamIsNegative: {org: 'Parameter "%s" cannot be negative.'}, SErrNoStreaming: {org: 'Failed to initialize component class "%s": No streaming method available.'}, SResNotFound: {org: "Resource %s not found"}, SErrResourceStreamNoWrite: {org: "Cannot write to resource stream"}, SErrResourceNotBase64: {org: "Resource %s is not base64 encoded"}, SErrUnknownResourceEncoding: {org: 'Unknown encoding for resource: "%s"'}};
});
rtl.module("Types",["System"],function () {
  "use strict";
  var $mod = this;
  this.TDirection = {"0": "FromBeginning", FromBeginning: 0, "1": "FromEnd", FromEnd: 1};
  this.$rtti.$Enum("TDirection",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDirection});
  this.$rtti.$DynArray("TBooleanDynArray",{eltype: rtl.boolean});
  this.$rtti.$DynArray("TWordDynArray",{eltype: rtl.word});
  this.$rtti.$DynArray("TIntegerDynArray",{eltype: rtl.longint});
  this.$rtti.$DynArray("TNativeIntDynArray",{eltype: rtl.nativeint});
  this.$rtti.$DynArray("TStringDynArray",{eltype: rtl.string});
  this.$rtti.$DynArray("TDoubleDynArray",{eltype: rtl.double});
  this.$rtti.$DynArray("TJSValueDynArray",{eltype: rtl.jsvalue});
  this.$rtti.$DynArray("TObjectDynArray",{eltype: pas.System.$rtti["TObject"]});
  this.$rtti.$DynArray("TByteDynArray",{eltype: rtl.byte});
  this.TDuplicates = {"0": "dupIgnore", dupIgnore: 0, "1": "dupAccept", dupAccept: 1, "2": "dupError", dupError: 2};
  this.$rtti.$Enum("TDuplicates",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TDuplicates});
  this.$rtti.$RefToProcVar("TProc",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$RefToProcVar("TProcString",{procsig: rtl.newTIProcSig([["aString",rtl.string,2]])});
  this.$rtti.$MethodVar("TListCallback",{procsig: rtl.newTIProcSig([["data",rtl.jsvalue],["arg",rtl.jsvalue]]), methodkind: 0});
  this.$rtti.$ProcVar("TListStaticCallback",{procsig: rtl.newTIProcSig([["data",rtl.jsvalue],["arg",rtl.jsvalue]])});
  rtl.recNewT(this,"TSize",function () {
    this.cx = 0;
    this.cy = 0;
    this.$eq = function (b) {
      return (this.cx === b.cx) && (this.cy === b.cy);
    };
    this.$assign = function (s) {
      this.cx = s.cx;
      this.cy = s.cy;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSize",{},this);
    $r.addField("cx",rtl.longint);
    $r.addField("cy",rtl.longint);
  });
  rtl.recNewT(this,"TPoint",function () {
    this.x = 0;
    this.y = 0;
    this.$eq = function (b) {
      return (this.x === b.x) && (this.y === b.y);
    };
    this.$assign = function (s) {
      this.x = s.x;
      this.y = s.y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPoint",{},this);
    $r.addField("x",rtl.longint);
    $r.addField("y",rtl.longint);
  });
  rtl.recNewT(this,"TRect",function () {
    this.Left = 0;
    this.Top = 0;
    this.Right = 0;
    this.Bottom = 0;
    this.$eq = function (b) {
      return (this.Left === b.Left) && (this.Top === b.Top) && (this.Right === b.Right) && (this.Bottom === b.Bottom);
    };
    this.$assign = function (s) {
      this.Left = s.Left;
      this.Top = s.Top;
      this.Right = s.Right;
      this.Bottom = s.Bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TRect",{},this);
    $r.addField("Left",rtl.longint);
    $r.addField("Top",rtl.longint);
    $r.addField("Right",rtl.longint);
    $r.addField("Bottom",rtl.longint);
  });
  rtl.createHelper(this,"TRectHelper",null,function () {
    this.Width = function () {
      var Result = 0;
      Result = this.Right - this.Left;
      return Result;
    };
    this.Height = function () {
      var Result = 0;
      Result = this.Bottom - this.Top;
      return Result;
    };
  });
  this.EqualRect = function (r1, r2) {
    var Result = false;
    Result = (r1.Left === r2.Left) && (r1.Right === r2.Right) && (r1.Top === r2.Top) && (r1.Bottom === r2.Bottom);
    return Result;
  };
  this.Rect = function (Left, Top, Right, Bottom) {
    var Result = $mod.TRect.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Right = Right;
    Result.Bottom = Bottom;
    return Result;
  };
  this.Bounds = function (ALeft, ATop, AWidth, AHeight) {
    var Result = $mod.TRect.$new();
    Result.Left = ALeft;
    Result.Top = ATop;
    Result.Right = ALeft + AWidth;
    Result.Bottom = ATop + AHeight;
    return Result;
  };
  this.Point = function (x, y) {
    var Result = $mod.TPoint.$new();
    Result.x = x;
    Result.y = y;
    return Result;
  };
  this.PtInRect = function (aRect, p) {
    var Result = false;
    Result = (p.y >= aRect.Top) && (p.y < aRect.Bottom) && (p.x >= aRect.Left) && (p.x < aRect.Right);
    return Result;
  };
  this.IntersectRect = function (aRect, R1, R2) {
    var Result = false;
    var lRect = $mod.TRect.$new();
    lRect.$assign(R1);
    if (R2.Left > R1.Left) lRect.Left = R2.Left;
    if (R2.Top > R1.Top) lRect.Top = R2.Top;
    if (R2.Right < R1.Right) lRect.Right = R2.Right;
    if (R2.Bottom < R1.Bottom) lRect.Bottom = R2.Bottom;
    if ($mod.IsRectEmpty(lRect)) {
      aRect.$assign($mod.Rect(0,0,0,0));
      Result = false;
    } else {
      Result = true;
      aRect.$assign(lRect);
    };
    return Result;
  };
  this.UnionRect = function (aRect, R1, R2) {
    var Result = false;
    var lRect = $mod.TRect.$new();
    lRect.$assign(R1);
    if (R2.Left < R1.Left) lRect.Left = R2.Left;
    if (R2.Top < R1.Top) lRect.Top = R2.Top;
    if (R2.Right > R1.Right) lRect.Right = R2.Right;
    if (R2.Bottom > R1.Bottom) lRect.Bottom = R2.Bottom;
    if ($mod.IsRectEmpty(lRect)) {
      aRect.$assign($mod.Rect(0,0,0,0));
      Result = false;
    } else {
      aRect.$assign(lRect);
      Result = true;
    };
    return Result;
  };
  this.IsRectEmpty = function (aRect) {
    var Result = false;
    Result = (aRect.Right <= aRect.Left) || (aRect.Bottom <= aRect.Top);
    return Result;
  };
  this.OffsetRect = function (aRect, DX, DY) {
    var Result = false;
    aRect.Left += DX;
    aRect.Top += DY;
    aRect.Right += DX;
    aRect.Bottom += DY;
    Result = true;
    return Result;
  };
  this.CenterPoint = function (aRect) {
    var Result = $mod.TPoint.$new();
    function Avg(a, b) {
      var Result = 0;
      if (a < b) {
        Result = a + ((b - a) >>> 1)}
       else Result = b + ((a - b) >>> 1);
      return Result;
    };
    Result.x = Avg(aRect.Left,aRect.Right);
    Result.y = Avg(aRect.Top,aRect.Bottom);
    return Result;
  };
  this.InflateRect = function (aRect, dx, dy) {
    var Result = false;
    aRect.Left -= dx;
    aRect.Top -= dy;
    aRect.Right += dx;
    aRect.Bottom += dy;
    Result = true;
    return Result;
  };
  this.Size = function (AWidth, AHeight) {
    var Result = $mod.TSize.$new();
    Result.cx = AWidth;
    Result.cy = AHeight;
    return Result;
  };
  this.Size$1 = function (aRect) {
    var Result = $mod.TSize.$new();
    Result.cx = aRect.Right - aRect.Left;
    Result.cy = aRect.Bottom - aRect.Top;
    return Result;
  };
});
rtl.module("JS",["System","Types"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"AsyncAttribute",pas.System.TCustomAttribute,function () {
  });
  rtl.createClass(this,"ExternalJSAttribute",pas.System.TCustomAttribute,function () {
    this.$init = function () {
      pas.System.TCustomAttribute.$init.call(this);
      this.FName = "";
    };
    this.Create$1 = function (AName) {
      pas.System.TObject.Create.call(this);
      this.FName = AName;
      return this;
    };
  });
  rtl.createClass(this,"EJS",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FMessage = "";
    };
    this.Create$1 = function (Msg) {
      this.FMessage = Msg;
      return this;
    };
  });
  this.$rtti.$ExtClass("TJSObject",{jsclass: "Object"});
  this.$rtti.$DynArray("TJSObjectDynArray",{eltype: this.$rtti["TJSObject"]});
  this.$rtti.$DynArray("TJSObjectDynArrayArray",{eltype: this.$rtti["TJSObjectDynArray"]});
  this.$rtti.$DynArray("TJSStringDynArray",{eltype: rtl.string});
  this.$rtti.$ExtClass("TJSIteratorValue",{jsclass: "IteratorValue"});
  this.$rtti.$ExtClass("TJSIterator",{jsclass: "Iterator"});
  this.$rtti.$ExtClass("TJSSet");
  this.$rtti.$RefToProcVar("TJSSetEventProc",{procsig: rtl.newTIProcSig([["value",rtl.jsvalue],["key",rtl.nativeint],["set_",this.$rtti["TJSSet"]]])});
  this.$rtti.$RefToProcVar("TJSSetProcCallBack",{procsig: rtl.newTIProcSig([["value",rtl.jsvalue],["key",rtl.jsvalue]])});
  this.$rtti.$ExtClass("TJSSet",{jsclass: "Set"});
  this.$rtti.$RefToProcVar("TJSMapFunctionCallBack",{procsig: rtl.newTIProcSig([["arg",rtl.jsvalue]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSMapProcCallBack",{procsig: rtl.newTIProcSig([["value",rtl.jsvalue],["key",rtl.jsvalue]])});
  this.$rtti.$ExtClass("TJSMap",{jsclass: "Map"});
  this.$rtti.$ExtClass("TJSFunction",{ancestor: this.$rtti["TJSObject"], jsclass: "Function"});
  this.$rtti.$ExtClass("TJSDate",{ancestor: this.$rtti["TJSFunction"], jsclass: "Date"});
  rtl.recNewT(this,"TLocaleCompareOptions",function () {
    this.$eq = function (b) {
      return (this.localeMatcher === b.localeMatcher) && (this.usage === b.usage) && (this.sensitivity === b.sensitivity) && (this.ignorePunctuation === b.ignorePunctuation) && (this.numeric === b.numeric) && (this.caseFirst === b.caseFirst);
    };
    this.$assign = function (s) {
      this.localeMatcher = s.localeMatcher;
      this.usage = s.usage;
      this.sensitivity = s.sensitivity;
      this.ignorePunctuation = s.ignorePunctuation;
      this.numeric = s.numeric;
      this.caseFirst = s.caseFirst;
      return this;
    };
    var $r = $mod.$rtti.$Record("TLocaleCompareOptions",{},this);
    $r.addField("localeMatcher",rtl.string);
    $r.addField("usage",rtl.string);
    $r.addField("sensitivity",rtl.string);
    $r.addField("ignorePunctuation",rtl.boolean);
    $r.addField("numeric",rtl.boolean);
    $r.addField("caseFirst",rtl.string);
  });
  this.$rtti.$ExtClass("TJSRegexp",{jsclass: "RegExp"});
  this.$rtti.$RefToProcVar("TReplaceCallBack",{procsig: rtl.newTIProcSig([["match",rtl.string,2]],rtl.string,2)});
  this.$rtti.$RefToProcVar("TReplaceCallBack0",{procsig: rtl.newTIProcSig([["match",rtl.string,2],["offset",rtl.longint],["AString",rtl.string]],rtl.string)});
  this.$rtti.$RefToProcVar("TReplaceCallBack1",{procsig: rtl.newTIProcSig([["match",rtl.string,2],["p1",rtl.string,2],["offset",rtl.longint],["AString",rtl.string]],rtl.string)});
  this.$rtti.$RefToProcVar("TReplaceCallBack2",{procsig: rtl.newTIProcSig([["match",rtl.string,2],["p1",rtl.string,2],["p2",rtl.string,2],["offset",rtl.longint],["AString",rtl.string]],rtl.string)});
  this.$rtti.$ExtClass("TJSString",{jsclass: "String"});
  this.$rtti.$ExtClass("TJSArray");
  this.$rtti.$RefToProcVar("TJSArrayEventProc",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]])});
  this.$rtti.$RefToProcVar("TJSArrayEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]],rtl.boolean)});
  this.$rtti.$RefToProcVar("TJSArrayMapEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSArrayReduceEvent",{procsig: rtl.newTIProcSig([["accumulator",rtl.jsvalue],["currentValue",rtl.jsvalue],["currentIndex",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSArrayCompareEvent",{procsig: rtl.newTIProcSig([["a",rtl.jsvalue],["b",rtl.jsvalue]],rtl.nativeint)});
  this.$rtti.$ExtClass("TJSArray",{jsclass: "Array"});
  this.$rtti.$ExtClass("TJSArrayBuffer",{ancestor: this.$rtti["TJSObject"], jsclass: "ArrayBuffer"});
  this.$rtti.$ExtClass("TJSBufferSource",{jsclass: "BufferSource"});
  this.$rtti.$ExtClass("TJSTypedArray");
  this.$rtti.$ProcVar("TJSTypedArrayCallBack",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.boolean)});
  this.$rtti.$MethodVar("TJSTypedArrayEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.boolean), methodkind: 1});
  this.$rtti.$ProcVar("TJSTypedArrayMapCallBack",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.jsvalue)});
  this.$rtti.$MethodVar("TJSTypedArrayMapEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.jsvalue), methodkind: 1});
  this.$rtti.$ProcVar("TJSTypedArrayReduceCallBack",{procsig: rtl.newTIProcSig([["accumulator",rtl.jsvalue],["currentValue",rtl.jsvalue],["currentIndex",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.jsvalue)});
  this.$rtti.$ProcVar("TJSTypedArrayCompareCallBack",{procsig: rtl.newTIProcSig([["a",rtl.jsvalue],["b",rtl.jsvalue]],rtl.nativeint)});
  this.$rtti.$ExtClass("TJSTypedArray",{ancestor: this.$rtti["TJSBufferSource"], jsclass: "TypedArray"});
  this.$rtti.$ExtClass("TJSInt8Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Int8Array"});
  this.$rtti.$ExtClass("TJSUint8Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint8Array"});
  this.$rtti.$ExtClass("TJSUint8ClampedArray",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint8ClampedArray"});
  this.$rtti.$ExtClass("TJSInt16Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Int16Array"});
  this.$rtti.$ExtClass("TJSUint16Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint16Array"});
  this.$rtti.$ExtClass("TJSInt32Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Int32Array"});
  this.$rtti.$ExtClass("TJSUint32Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint32Array"});
  this.$rtti.$ExtClass("TJSFloat32Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Float32Array"});
  this.$rtti.$ExtClass("TJSFloat64Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Float64Array"});
  this.$rtti.$ExtClass("TJSDataView",{ancestor: this.$rtti["TJSBufferSource"], jsclass: "DataView"});
  this.$rtti.$ExtClass("TJSJSON",{ancestor: this.$rtti["TJSObject"], jsclass: "JSON"});
  this.$rtti.$ExtClass("TJSError",{ancestor: this.$rtti["TJSObject"], jsclass: "Error"});
  this.$rtti.$RefToProcVar("TJSPromiseResolver",{procsig: rtl.newTIProcSig([["aValue",rtl.jsvalue]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSPromiseExecutor",{procsig: rtl.newTIProcSig([["resolve",this.$rtti["TJSPromiseResolver"]],["reject",this.$rtti["TJSPromiseResolver"]]])});
  this.$rtti.$RefToProcVar("TJSPromiseFinallyHandler",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$ExtClass("TJSPromise");
  this.$rtti.$DynArray("TJSPromiseArray",{eltype: this.$rtti["TJSPromise"]});
  this.$rtti.$ExtClass("TJSPromise",{jsclass: "Promise"});
  rtl.createHelper(this,"TJSPromiseHelper",null,function () {
    this.From = function (AValue) {
      var Result = null;
      Result = AValue;
      return Result;
    };
  });
  this.$rtti.$ExtClass("TJSFunctionArguments",{jsclass: "arguments"});
  this.$rtti.$ExtClass("TJSIteratorResult",{ancestor: this.$rtti["TJSObject"], jsclass: "IteratorResult"});
  this.$rtti.$ExtClass("TJSAsyncIterator",{ancestor: this.$rtti["TJSObject"], jsclass: "AsyncIterator"});
  this.$rtti.$ExtClass("TJSSyntaxError",{ancestor: this.$rtti["TJSError"], jsclass: "SyntaxError"});
  this.$rtti.$ExtClass("TJSTextDecoderOptions",{ancestor: this.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSTextDecodeOptions",{ancestor: this.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSTextDecoder",{ancestor: this.$rtti["TJSObject"], jsclass: "TextDecoder"});
  this.$rtti.$ExtClass("TJSTextEncoderEncodeIntoResult",{ancestor: this.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSTextEncoder",{ancestor: this.$rtti["TJSObject"], jsclass: "TextEncoder"});
  this.New = function (aElements) {
    var Result = null;
    var L = 0;
    var I = 0;
    var S = "";
    L = rtl.length(aElements);
    if ((L % 2) === 1) throw $mod.EJS.$create("Create$1",["Number of arguments must be even"]);
    I = 0;
    while (I < L) {
      if (!rtl.isString(aElements[I])) {
        S = String(I);
        throw $mod.EJS.$create("Create$1",["Argument " + S + " must be a string."]);
      };
      I += 2;
    };
    I = 0;
    Result = new Object();
    while (I < L) {
      S = "" + aElements[I];
      Result[S] = aElements[I + 1];
      I += 2;
    };
    return Result;
  };
  this.JSDelete = function (Obj, PropName) {
    return delete Obj[PropName];
  };
  this.hasValue = function (v) {
    if(v){ return true; } else { return false; };
  };
  this.isBoolean = function (v) {
    return typeof(v) == 'boolean';
  };
  this.isDate = function (v) {
    return (v instanceof Date);
  };
  this.isCallback = function (v) {
    return rtl.isObject(v) && rtl.isObject(v.scope) && (rtl.isString(v.fn) || rtl.isFunction(v.fn));
  };
  this.isChar = function (v) {
    return (typeof(v)!="string") && (v.length==1);
  };
  this.isClass = function (v) {
    return (typeof(v)=="object") && (v!=null) && (v.$class == v);
  };
  this.isClassInstance = function (v) {
    return (typeof(v)=="object") && (v!=null) && (v.$class == Object.getPrototypeOf(v));
  };
  this.isInteger = function (v) {
    return Math.floor(v)===v;
  };
  this.isNull = function (v) {
    return v === null;
  };
  this.isRecord = function (v) {
    return (typeof(v)==="object")
    && (typeof(v.$new)==="function")
    && (typeof(v.$clone)==="function")
    && (typeof(v.$eq)==="function")
    && (typeof(v.$assign)==="function");
  };
  this.isUndefined = function (v) {
    return v == undefined;
  };
  this.isDefined = function (v) {
    return !(v == undefined);
  };
  this.isUTF16Char = function (v) {
    if (typeof(v)!="string") return false;
    if ((v.length==0) || (v.length>2)) return false;
    var code = v.charCodeAt(0);
    if (code < 0xD800){
      if (v.length == 1) return true;
    } else if (code <= 0xDBFF){
      if (v.length==2){
        code = v.charCodeAt(1);
        if (code >= 0xDC00 && code <= 0xDFFF) return true;
      };
    };
    return false;
  };
  this.jsInstanceOf = function (aFunction, aFunctionWithPrototype) {
    return aFunction instanceof aFunctionWithPrototype;
  };
  this.toNumber = function (v) {
    return v-0;
  };
  this.toInteger = function (v) {
    var Result = 0;
    if ($mod.isInteger(v)) {
      Result = rtl.trunc(v)}
     else Result = 0;
    return Result;
  };
  this.toObject = function (Value) {
    var Result = null;
    if (rtl.isObject(Value)) {
      Result = Value}
     else Result = null;
    return Result;
  };
  this.toArray = function (Value) {
    var Result = null;
    if (rtl.isArray(Value)) {
      Result = Value}
     else Result = null;
    return Result;
  };
  this.toBoolean = function (Value) {
    var Result = false;
    if ($mod.isBoolean(Value)) {
      Result = !(Value == false)}
     else Result = false;
    return Result;
  };
  this.ToString = function (Value) {
    var Result = "";
    if (rtl.isString(Value)) {
      Result = "" + Value}
     else Result = "";
    return Result;
  };
  this.TJSValueType = {"0": "jvtNull", jvtNull: 0, "1": "jvtBoolean", jvtBoolean: 1, "2": "jvtInteger", jvtInteger: 2, "3": "jvtFloat", jvtFloat: 3, "4": "jvtString", jvtString: 4, "5": "jvtObject", jvtObject: 5, "6": "jvtArray", jvtArray: 6};
  this.$rtti.$Enum("TJSValueType",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TJSValueType});
  this.GetValueType = function (JS) {
    var Result = 0;
    var t = "";
    if ($mod.isNull(JS)) {
      Result = $mod.TJSValueType.jvtNull}
     else {
      t = typeof(JS);
      if (t === "string") {
        Result = $mod.TJSValueType.jvtString}
       else if (t === "boolean") {
        Result = $mod.TJSValueType.jvtBoolean}
       else if (t === "object") {
        if (rtl.isArray(JS)) {
          Result = $mod.TJSValueType.jvtArray}
         else Result = $mod.TJSValueType.jvtObject;
      } else if (t === "number") if ($mod.isInteger(JS)) {
        Result = $mod.TJSValueType.jvtInteger}
       else Result = $mod.TJSValueType.jvtFloat;
    };
    return Result;
  };
});
rtl.module("SysUtils",["System","RTLConsts","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.FreeAndNil = function (Obj) {
    var o = null;
    o = Obj.get();
    if (o === null) return;
    Obj.set(null);
    o.$destroy("Destroy");
  };
  this.$rtti.$ProcVar("TProcedure",{procsig: rtl.newTIProcSig([])});
  this.FloatRecDigits = 19;
  this.$rtti.$Set("TSysCharSet",{comptype: rtl.char});
  rtl.recNewT(this,"TFloatRec",function () {
    this.Exponent = 0;
    this.Negative = false;
    this.$new = function () {
      var r = Object.create(this);
      r.Digits = rtl.arraySetLength(null,"\x00",19);
      return r;
    };
    this.$eq = function (b) {
      return (this.Exponent === b.Exponent) && (this.Negative === b.Negative) && rtl.arrayEq(this.Digits,b.Digits);
    };
    this.$assign = function (s) {
      this.Exponent = s.Exponent;
      this.Negative = s.Negative;
      this.Digits = s.Digits.slice(0);
      return this;
    };
    var $r = $mod.$rtti.$Record("TFloatRec",{},this);
    $r.addField("Exponent",rtl.longint);
    $r.addField("Negative",rtl.boolean);
    $mod.$rtti.$StaticArray("TFloatRec.Digits$a",{dims: [19], eltype: rtl.char});
    $r.addField("Digits",$mod.$rtti["TFloatRec.Digits$a"]);
  });
  this.TEndian = {"0": "Little", Little: 0, "1": "Big", Big: 1};
  this.$rtti.$Enum("TEndian",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TEndian});
  this.$rtti.$StaticArray("TByteArray",{dims: [32768], eltype: rtl.byte});
  this.$rtti.$StaticArray("TWordArray",{dims: [16384], eltype: rtl.word});
  this.$rtti.$DynArray("TBytes",{eltype: rtl.byte});
  this.$rtti.$DynArray("TStringArray",{eltype: rtl.string});
  this.$rtti.$StaticArray("TMonthNameArray",{dims: [12], eltype: rtl.string});
  this.$rtti.$StaticArray("TDayTable",{dims: [12], eltype: rtl.word});
  this.$rtti.$StaticArray("TWeekNameArray",{dims: [7], eltype: rtl.string});
  this.$rtti.$StaticArray("TDayNames",{dims: [7], eltype: rtl.string});
  rtl.recNewT(this,"TFormatSettings",function () {
    this.CurrencyDecimals = 0;
    this.CurrencyFormat = 0;
    this.CurrencyString = "";
    this.DateSeparator = "\x00";
    this.DecimalSeparator = "";
    this.LongDateFormat = "";
    this.LongTimeFormat = "";
    this.NegCurrFormat = 0;
    this.ShortDateFormat = "";
    this.ShortTimeFormat = "";
    this.ThousandSeparator = "";
    this.TimeAMString = "";
    this.TimePMString = "";
    this.TimeSeparator = "\x00";
    this.TwoDigitYearCenturyWindow = 0;
    $mod.$rtti.$ProcVar("TFormatSettings.TLocaleInitCallback",{procsig: rtl.newTIProcSig([["aLocale",rtl.string,2],["aInstance",$r]])});
    this.InitLocaleHandler = null;
    this.$new = function () {
      var r = Object.create(this);
      r.DateTimeToStrFormat = rtl.arraySetLength(null,"",2);
      r.LongDayNames = rtl.arraySetLength(null,"",7);
      r.LongMonthNames = rtl.arraySetLength(null,"",12);
      r.ShortDayNames = rtl.arraySetLength(null,"",7);
      r.ShortMonthNames = rtl.arraySetLength(null,"",12);
      return r;
    };
    this.$eq = function (b) {
      return (this.CurrencyDecimals === b.CurrencyDecimals) && (this.CurrencyFormat === b.CurrencyFormat) && (this.CurrencyString === b.CurrencyString) && (this.DateSeparator === b.DateSeparator) && rtl.arrayEq(this.DateTimeToStrFormat,b.DateTimeToStrFormat) && (this.DecimalSeparator === b.DecimalSeparator) && (this.LongDateFormat === b.LongDateFormat) && rtl.arrayEq(this.LongDayNames,b.LongDayNames) && rtl.arrayEq(this.LongMonthNames,b.LongMonthNames) && (this.LongTimeFormat === b.LongTimeFormat) && (this.NegCurrFormat === b.NegCurrFormat) && (this.ShortDateFormat === b.ShortDateFormat) && rtl.arrayEq(this.ShortDayNames,b.ShortDayNames) && rtl.arrayEq(this.ShortMonthNames,b.ShortMonthNames) && (this.ShortTimeFormat === b.ShortTimeFormat) && (this.ThousandSeparator === b.ThousandSeparator) && (this.TimeAMString === b.TimeAMString) && (this.TimePMString === b.TimePMString) && (this.TimeSeparator === b.TimeSeparator) && (this.TwoDigitYearCenturyWindow === b.TwoDigitYearCenturyWindow);
    };
    this.$assign = function (s) {
      this.CurrencyDecimals = s.CurrencyDecimals;
      this.CurrencyFormat = s.CurrencyFormat;
      this.CurrencyString = s.CurrencyString;
      this.DateSeparator = s.DateSeparator;
      this.DateTimeToStrFormat = s.DateTimeToStrFormat.slice(0);
      this.DecimalSeparator = s.DecimalSeparator;
      this.LongDateFormat = s.LongDateFormat;
      this.LongDayNames = s.LongDayNames.slice(0);
      this.LongMonthNames = s.LongMonthNames.slice(0);
      this.LongTimeFormat = s.LongTimeFormat;
      this.NegCurrFormat = s.NegCurrFormat;
      this.ShortDateFormat = s.ShortDateFormat;
      this.ShortDayNames = s.ShortDayNames.slice(0);
      this.ShortMonthNames = s.ShortMonthNames.slice(0);
      this.ShortTimeFormat = s.ShortTimeFormat;
      this.ThousandSeparator = s.ThousandSeparator;
      this.TimeAMString = s.TimeAMString;
      this.TimePMString = s.TimePMString;
      this.TimeSeparator = s.TimeSeparator;
      this.TwoDigitYearCenturyWindow = s.TwoDigitYearCenturyWindow;
      return this;
    };
    this.GetBrowserLocale = function () {
      return navigator.language;
    };
    this.GetJSLocale = function () {
      return Intl.DateTimeFormat().resolvedOptions().locale;
    };
    this.GetLocaleDecimalSeparator = function (ALocale) {
      var lNumber = 1.1;
      lNumber = lNumber.toLocaleString(ALocale).substring(1, 2);
      return lNumber;
    };
    this.GetLocaleLongDayName = function (ADayOfWeek, ALocale) {
      var lBaseDate = new Date(2017, 0, 1); // Sunday
      lBaseDate.setDate(lBaseDate.getDate() + ADayOfWeek - 1);
      return lBaseDate.toLocaleDateString(ALocale, { weekday: 'long' });
    };
    this.GetLocaleLongMonthName = function (AMonth, ALocale) {
      var lBaseDate = new Date(2017, AMonth - 1, 1);
      return lBaseDate.toLocaleDateString(ALocale, { month: 'long' });
    };
    this.GetLocaleLongTimeFormat = function (ALocale) {
      var Result = "";
      Result = "hh:nn:ss";
      if ($mod.UpperCase(ALocale) === "EN-US") Result = "hh:nn:ss AMPM";
      return Result;
    };
    var cDeli = "-";
    var cShortLength = 2;
    this.GetLocaleShortDateFormat = function (ALocale) {
      var Result = "";
      var lIndex = 0;
      var res = "";
      res = $mod.TStringHelper.Empty;
      ALocale = $mod.TStringHelper.ToLower.call({get: function () {
          return ALocale;
        }, set: function (v) {
          ALocale = v;
        }});
      lIndex = $mod.TStringHelper.IndexOf.call({get: function () {
          return ALocale;
        }, set: function (v) {
          ALocale = v;
        }},cDeli);
      if (lIndex >= 0) {
        ALocale = $mod.TStringHelper.Substring$1.call({get: function () {
            return ALocale;
          }, set: function (v) {
            ALocale = v;
          }},0,lIndex) + $mod.TStringHelper.ToUpper.call({a: $mod.TStringHelper.Substring.call({get: function () {
              return ALocale;
            }, set: function (v) {
              ALocale = v;
            }},lIndex), get: function () {
            return this.a;
          }, set: function (v) {
            this.a = v;
          }})}
       else {
        if ($mod.TStringHelper.GetLength.call({get: function () {
            return ALocale;
          }, set: function (v) {
            ALocale = v;
          }}) === 2) ALocale = ALocale + cDeli + $mod.TStringHelper.ToUpper.call({get: function () {
            return ALocale;
          }, set: function (v) {
            ALocale = v;
          }});
      };
      var lFormats = {
        "ar-SA" : "dd/MM/yy",
        "bg-BG" : "dd.M.yyyy",
        "ca-ES" : "dd/MM/yyyy",
        "zh-TW" : "yyyy/M/d",
        "cs-CZ" : "d.M.yyyy",
        "da-DK" : "dd-MM-yyyy",
        "de-DE" : "dd.MM.yyyy",
        "el-GR" : "d/M/yyyy",
        "en-US" : "M/d/yyyy",
        "fi-FI" : "d.M.yyyy",
        "fr-FR" : "dd/MM/yyyy",
        "he-IL" : "dd/MM/yyyy",
        "hu-HU" : "yyyy. MM. dd.",
        "is-IS" : "d.M.yyyy",
        "it-IT" : "dd/MM/yyyy",
        "ja-JP" : "yyyy/MM/dd",
        "ko-KR" : "yyyy-MM-dd",
        "nl-NL" : "d-M-yyyy",
        "nb-NO" : "dd.MM.yyyy",
        "pl-PL" : "yyyy-MM-dd",
        "pt-BR" : "d/M/yyyy",
        "ro-RO" : "dd.MM.yyyy",
        "ru-RU" : "dd.MM.yyyy",
        "hr-HR" : "d.M.yyyy",
        "sk-SK" : "d. M. yyyy",
        "sq-AL" : "yyyy-MM-dd",
        "sv-SE" : "yyyy-MM-dd",
        "th-TH" : "d/M/yyyy",
        "tr-TR" : "dd.MM.yyyy",
        "ur-PK" : "dd/MM/yyyy",
        "id-ID" : "dd/MM/yyyy",
        "uk-UA" : "dd.MM.yyyy",
        "be-BY" : "dd.MM.yyyy",
        "sl-SI" : "d.M.yyyy",
        "et-EE" : "d.MM.yyyy",
        "lv-LV" : "yyyy.MM.dd.",
        "lt-LT" : "yyyy.MM.dd",
        "fa-IR" : "MM/dd/yyyy",
        "vi-VN" : "dd/MM/yyyy",
        "hy-AM" : "dd.MM.yyyy",
        "az-Latn-AZ" : "dd.MM.yyyy",
        "eu-ES" : "yyyy/MM/dd",
        "mk-MK" : "dd.MM.yyyy",
        "af-ZA" : "yyyy/MM/dd",
        "ka-GE" : "dd.MM.yyyy",
        "fo-FO" : "dd-MM-yyyy",
        "hi-IN" : "dd-MM-yyyy",
        "ms-MY" : "dd/MM/yyyy",
        "kk-KZ" : "dd.MM.yyyy",
        "ky-KG" : "dd.MM.yy",
        "sw-KE" : "M/d/yyyy",
        "uz-Latn-UZ" : "dd/MM yyyy",
        "tt-RU" : "dd.MM.yyyy",
        "pa-IN" : "dd-MM-yy",
        "gu-IN" : "dd-MM-yy",
        "ta-IN" : "dd-MM-yyyy",
        "te-IN" : "dd-MM-yy",
        "kn-IN" : "dd-MM-yy",
        "mr-IN" : "dd-MM-yyyy",
        "sa-IN" : "dd-MM-yyyy",
        "mn-MN" : "yy.MM.dd",
        "gl-ES" : "dd/MM/yy",
        "kok-IN" : "dd-MM-yyyy",
        "syr-SY" : "dd/MM/yyyy",
        "dv-MV" : "dd/MM/yy",
        "ar-IQ" : "dd/MM/yyyy",
        "zh-CN" : "yyyy/M/d",
        "de-CH" : "dd.MM.yyyy",
        "en-GB" : "dd/MM/yyyy",
        "es-MX" : "dd/MM/yyyy",
        "fr-BE" : "d/MM/yyyy",
        "it-CH" : "dd.MM.yyyy",
        "nl-BE" : "d/MM/yyyy",
        "nn-NO" : "dd.MM.yyyy",
        "pt-PT" : "dd-MM-yyyy",
        "sr-Latn-CS" : "d.M.yyyy",
        "sv-FI" : "d.M.yyyy",
        "az-Cyrl-AZ" : "dd.MM.yyyy",
        "ms-BN" : "dd/MM/yyyy",
        "uz-Cyrl-UZ" : "dd.MM.yyyy",
        "ar-EG" : "dd/MM/yyyy",
        "zh-HK" : "d/M/yyyy",
        "de-AT" : "dd.MM.yyyy",
        "en-AU" : "d/MM/yyyy",
        "es-ES" : "dd/MM/yyyy",
        "fr-CA" : "yyyy-MM-dd",
        "sr-Cyrl-CS" : "d.M.yyyy",
        "ar-LY" : "dd/MM/yyyy",
        "zh-SG" : "d/M/yyyy",
        "de-LU" : "dd.MM.yyyy",
        "en-CA" : "dd/MM/yyyy",
        "es-GT" : "dd/MM/yyyy",
        "fr-CH" : "dd.MM.yyyy",
        "ar-DZ" : "dd-MM-yyyy",
        "zh-MO" : "d/M/yyyy",
        "de-LI" : "dd.MM.yyyy",
        "en-NZ" : "d/MM/yyyy",
        "es-CR" : "dd/MM/yyyy",
        "fr-LU" : "dd/MM/yyyy",
        "ar-MA" : "dd-MM-yyyy",
        "en-IE" : "dd/MM/yyyy",
        "es-PA" : "MM/dd/yyyy",
        "fr-MC" : "dd/MM/yyyy",
        "ar-TN" : "dd-MM-yyyy",
        "en-ZA" : "yyyy/MM/dd",
        "es-DO" : "dd/MM/yyyy",
        "ar-OM" : "dd/MM/yyyy",
        "en-JM" : "dd/MM/yyyy",
        "es-VE" : "dd/MM/yyyy",
        "ar-YE" : "dd/MM/yyyy",
        "en-029" : "MM/dd/yyyy",
        "es-CO" : "dd/MM/yyyy",
        "ar-SY" : "dd/MM/yyyy",
        "en-BZ" : "dd/MM/yyyy",
        "es-PE" : "dd/MM/yyyy",
        "ar-JO" : "dd/MM/yyyy",
        "en-TT" : "dd/MM/yyyy",
        "es-AR" : "dd/MM/yyyy",
        "ar-LB" : "dd/MM/yyyy",
        "en-ZW" : "M/d/yyyy",
        "es-EC" : "dd/MM/yyyy",
        "ar-KW" : "dd/MM/yyyy",
        "en-PH" : "M/d/yyyy",
        "es-CL" : "dd-MM-yyyy",
        "ar-AE" : "dd/MM/yyyy",
        "es-UY" : "dd/MM/yyyy",
        "ar-BH" : "dd/MM/yyyy",
        "es-PY" : "dd/MM/yyyy",
        "ar-QA" : "dd/MM/yyyy",
        "es-BO" : "dd/MM/yyyy",
        "es-SV" : "dd/MM/yyyy",
        "es-HN" : "dd/MM/yyyy",
        "es-NI" : "dd/MM/yyyy",
        "es-PR" : "dd/MM/yyyy",
        "am-ET" : "d/M/yyyy",
        "tzm-Latn-DZ" : "dd-MM-yyyy",
        "iu-Latn-CA" : "d/MM/yyyy",
        "sma-NO" : "dd.MM.yyyy",
        "mn-Mong-CN" : "yyyy/M/d",
        "gd-GB" : "dd/MM/yyyy",
        "en-MY" : "d/M/yyyy",
        "prs-AF" : "dd/MM/yy",
        "bn-BD" : "dd-MM-yy",
        "wo-SN" : "dd/MM/yyyy",
        "rw-RW" : "M/d/yyyy",
        "qut-GT" : "dd/MM/yyyy",
        "sah-RU" : "MM.dd.yyyy",
        "gsw-FR" : "dd/MM/yyyy",
        "co-FR" : "dd/MM/yyyy",
        "oc-FR" : "dd/MM/yyyy",
        "mi-NZ" : "dd/MM/yyyy",
        "ga-IE" : "dd/MM/yyyy",
        "se-SE" : "yyyy-MM-dd",
        "br-FR" : "dd/MM/yyyy",
        "smn-FI" : "d.M.yyyy",
        "moh-CA" : "M/d/yyyy",
        "arn-CL" : "dd-MM-yyyy",
        "ii-CN" : "yyyy/M/d",
        "dsb-DE" : "d. M. yyyy",
        "ig-NG" : "d/M/yyyy",
        "kl-GL" : "dd-MM-yyyy",
        "lb-LU" : "dd/MM/yyyy",
        "ba-RU" : "dd.MM.yy",
        "nso-ZA" : "yyyy/MM/dd",
        "quz-BO" : "dd/MM/yyyy",
        "yo-NG" : "d/M/yyyy",
        "ha-Latn-NG" : "d/M/yyyy",
        "fil-PH" : "M/d/yyyy",
        "ps-AF" : "dd/MM/yy",
        "fy-NL" : "d-M-yyyy",
        "ne-NP" : "M/d/yyyy",
        "se-NO" : "dd.MM.yyyy",
        "iu-Cans-CA" : "d/M/yyyy",
        "sr-Latn-RS" : "d.M.yyyy",
        "si-LK" : "yyyy-MM-dd",
        "sr-Cyrl-RS" : "d.M.yyyy",
        "lo-LA" : "dd/MM/yyyy",
        "km-KH" : "yyyy-MM-dd",
        "cy-GB" : "dd/MM/yyyy",
        "bo-CN" : "yyyy/M/d",
        "sms-FI" : "d.M.yyyy",
        "as-IN" : "dd-MM-yyyy",
        "ml-IN" : "dd-MM-yy",
        "en-IN" : "dd-MM-yyyy",
        "or-IN" : "dd-MM-yy",
        "bn-IN" : "dd-MM-yy",
        "tk-TM" : "dd.MM.yy",
        "bs-Latn-BA" : "d.M.yyyy",
        "mt-MT" : "dd/MM/yyyy",
        "sr-Cyrl-ME" : "d.M.yyyy",
        "se-FI" : "d.M.yyyy",
        "zu-ZA" : "yyyy/MM/dd",
        "xh-ZA" : "yyyy/MM/dd",
        "tn-ZA" : "yyyy/MM/dd",
        "hsb-DE" : "d. M. yyyy",
        "bs-Cyrl-BA" : "d.M.yyyy",
        "tg-Cyrl-TJ" : "dd.MM.yy",
        "sr-Latn-BA" : "d.M.yyyy",
        "smj-NO" : "dd.MM.yyyy",
        "rm-CH" : "dd/MM/yyyy",
        "smj-SE" : "yyyy-MM-dd",
        "quz-EC" : "dd/MM/yyyy",
        "quz-PE" : "dd/MM/yyyy",
        "hr-BA" : "d.M.yyyy.",
        "sr-Latn-ME" : "d.M.yyyy",
        "sma-SE" : "yyyy-MM-dd",
        "en-SG" : "d/M/yyyy",
        "ug-CN" : "yyyy-M-d",
        "sr-Cyrl-BA" : "d.M.yyyy",
        "es-US" : "M/d/yyyy"};
      res = lFormats[ALocale] || 'dd/MM/yyyy';
      Result = res;
      return Result;
    };
    this.GetLocaleShortDayName = function (ADayOfWeek, ALocale) {
      var lBaseDate = new Date(2017, 0, 1); // Sunday
        lBaseDate.setDate(lBaseDate.getDate() + ADayOfWeek - 1);
      
        var lLoc = "";
        if (ALocale == '')
          lLoc = navigator.language
        else
          lLoc = ALocale;
      
        return lBaseDate.toLocaleDateString(lLoc, { weekday: 'short' });
    };
    this.GetLocaleShortMonthName = function (AMonth, ALocale) {
      var lBaseDate = new Date(2017, AMonth - 1, 1);
      var lLoc = "";
      if (ALocale == '')
        lLoc = navigator.language
      else
        lLoc = ALocale;
      return lBaseDate.toLocaleDateString(lLoc, { month: 'short' });
    };
    this.GetLocaleShortTimeFormat = function (ALocale) {
      var Result = "";
      Result = "hh:nn";
      if ($mod.UpperCase(ALocale) === "EN-US") Result = "h:nn AMPM";
      return Result;
    };
    this.Create = function () {
      var Result = $mod.TFormatSettings.$new();
      Result.$assign($mod.TFormatSettings.Create$1($mod.TFormatSettings.GetJSLocale()));
      return Result;
    };
    var cDateSeps = ["/",".","-"];
    var cTimeSeps = [":",".","-"];
    var cDecSeps = [",","."];
    var cThousandSeps = [".",","];
    this.Create$1 = function (ALocale) {
      var Result = $mod.TFormatSettings.$new();
      var lTimeStr = "";
      var lCount = 0;
      var lLoc = "";
      lLoc = $mod.UpperCase(ALocale);
      if (pas.System.Pos("DE",lLoc) === 1) {
        Result.LongDayNames[0] = "Sonntag";
        Result.LongDayNames[1] = "Montag";
        Result.LongDayNames[2] = "Dienstag";
        Result.LongDayNames[3] = "Mittwoch";
        Result.LongDayNames[4] = "Donnerstag";
        Result.LongDayNames[5] = "Freitag";
        Result.LongDayNames[6] = "Samstag";
        Result.ShortDayNames[0] = "Son";
        Result.ShortDayNames[1] = "Mon";
        Result.ShortDayNames[2] = "Die";
        Result.ShortDayNames[3] = "Mit";
        Result.ShortDayNames[4] = "Don";
        Result.ShortDayNames[5] = "Fre";
        Result.ShortDayNames[6] = "Sam";
        Result.ShortMonthNames[0] = "Jan";
        Result.ShortMonthNames[1] = "Feb";
        Result.ShortMonthNames[2] = "Mär";
        Result.ShortMonthNames[3] = "Apr";
        Result.ShortMonthNames[4] = "Mai";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Aug";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Okt";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Dez";
        Result.LongMonthNames[0] = "Januar";
        Result.LongMonthNames[1] = "Februar";
        Result.LongMonthNames[2] = "März";
        Result.LongMonthNames[3] = "April";
        Result.LongMonthNames[4] = "Mai";
        Result.LongMonthNames[5] = "Juni";
        Result.LongMonthNames[6] = "Juli";
        Result.LongMonthNames[7] = "August";
        Result.LongMonthNames[8] = "September";
        Result.LongMonthNames[9] = "Oktober";
        Result.LongMonthNames[10] = "November";
        Result.LongMonthNames[11] = "Dezember";
      } else if (pas.System.Pos("FR",$mod.UpperCase(ALocale)) === 1) {
        Result.LongDayNames[0] = "Dimanche";
        Result.LongDayNames[1] = "Lundi";
        Result.LongDayNames[2] = "Mardi";
        Result.LongDayNames[3] = "Mecredi";
        Result.LongDayNames[4] = "Jeudi";
        Result.LongDayNames[5] = "Vendredi";
        Result.LongDayNames[6] = "Samedi";
        Result.ShortDayNames[0] = "Dim";
        Result.ShortDayNames[1] = "Lun";
        Result.ShortDayNames[2] = "Mar";
        Result.ShortDayNames[3] = "Mer";
        Result.ShortDayNames[4] = "Jeu";
        Result.ShortDayNames[5] = "Ven";
        Result.ShortDayNames[6] = "Sam";
        Result.ShortMonthNames[0] = "Jan";
        Result.ShortMonthNames[1] = "Fév";
        Result.ShortMonthNames[2] = "Mar";
        Result.ShortMonthNames[3] = "Avr";
        Result.ShortMonthNames[4] = "Mai";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Aoû";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Oct";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Déc";
        Result.LongMonthNames[0] = "Janvier";
        Result.LongMonthNames[1] = "Février";
        Result.LongMonthNames[2] = "Mars";
        Result.LongMonthNames[3] = "Avril";
        Result.LongMonthNames[4] = "Mai";
        Result.LongMonthNames[5] = "Juin";
        Result.LongMonthNames[6] = "Juillet";
        Result.LongMonthNames[7] = "Août";
        Result.LongMonthNames[8] = "Septembre";
        Result.LongMonthNames[9] = "Octobre";
        Result.LongMonthNames[10] = "Novembre";
        Result.LongMonthNames[11] = "Décembre";
      } else if (pas.System.Pos("ES",$mod.UpperCase(ALocale)) === 1) {
        Result.LongDayNames[0] = "Domingo";
        Result.LongDayNames[1] = "Lunes";
        Result.LongDayNames[2] = "Martes";
        Result.LongDayNames[3] = "Miércoles";
        Result.LongDayNames[4] = "Jueves";
        Result.LongDayNames[5] = "Viernes";
        Result.LongDayNames[6] = "Sábado";
        Result.ShortDayNames[0] = "Dom";
        Result.ShortDayNames[1] = "Lun";
        Result.ShortDayNames[2] = "Mar";
        Result.ShortDayNames[3] = "Mié";
        Result.ShortDayNames[4] = "Jue";
        Result.ShortDayNames[5] = "Vie";
        Result.ShortDayNames[6] = "Sáb";
        Result.ShortMonthNames[0] = "Ene";
        Result.ShortMonthNames[1] = "Feb";
        Result.ShortMonthNames[2] = "Mar";
        Result.ShortMonthNames[3] = "Abr";
        Result.ShortMonthNames[4] = "May";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Ago";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Oct";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Dic";
        Result.LongMonthNames[0] = "January";
        Result.LongMonthNames[1] = "Febrero";
        Result.LongMonthNames[2] = "Marzi";
        Result.LongMonthNames[3] = "Abril";
        Result.LongMonthNames[4] = "Mayo";
        Result.LongMonthNames[5] = "Junio";
        Result.LongMonthNames[6] = "Julio";
        Result.LongMonthNames[7] = "Agusto";
        Result.LongMonthNames[8] = "Septiembre";
        Result.LongMonthNames[9] = "Octubre";
        Result.LongMonthNames[10] = "Noviembre";
        Result.LongMonthNames[11] = "Diciembre";
      } else {
        Result.LongDayNames[0] = "Sunday";
        Result.LongDayNames[1] = "Monday";
        Result.LongDayNames[2] = "Tuesday";
        Result.LongDayNames[3] = "Wednesday";
        Result.LongDayNames[4] = "Thursday";
        Result.LongDayNames[5] = "Friday";
        Result.LongDayNames[6] = "Saturday";
        Result.ShortDayNames[0] = "Sun";
        Result.ShortDayNames[1] = "Mon";
        Result.ShortDayNames[2] = "Tue";
        Result.ShortDayNames[3] = "Wed";
        Result.ShortDayNames[4] = "Thu";
        Result.ShortDayNames[5] = "Fri";
        Result.ShortDayNames[6] = "Sat";
        Result.ShortMonthNames[0] = "Jan";
        Result.ShortMonthNames[1] = "Feb";
        Result.ShortMonthNames[2] = "Mar";
        Result.ShortMonthNames[3] = "Apr";
        Result.ShortMonthNames[4] = "May";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Aug";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Oct";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Dec";
        Result.LongMonthNames[0] = "January";
        Result.LongMonthNames[1] = "February";
        Result.LongMonthNames[2] = "March";
        Result.LongMonthNames[3] = "April";
        Result.LongMonthNames[4] = "May";
        Result.LongMonthNames[5] = "June";
        Result.LongMonthNames[6] = "July";
        Result.LongMonthNames[7] = "August";
        Result.LongMonthNames[8] = "September";
        Result.LongMonthNames[9] = "October";
        Result.LongMonthNames[10] = "November";
        Result.LongMonthNames[11] = "December";
      };
      Result.DateTimeToStrFormat[0] = "c";
      Result.DateTimeToStrFormat[1] = "f";
      Result.DateSeparator = "-";
      Result.TimeSeparator = ":";
      Result.ShortDateFormat = "yyyy-mm-dd";
      Result.LongDateFormat = "ddd, yyyy-mm-dd";
      Result.DecimalSeparator = ".";
      Result.ThousandSeparator = ",";
      Result.TimeAMString = "AM";
      Result.TimePMString = "PM";
      Result.TwoDigitYearCenturyWindow = 50;
      Result.ShortTimeFormat = $mod.TFormatSettings.GetLocaleShortTimeFormat(ALocale);
      Result.LongTimeFormat = $mod.TFormatSettings.GetLocaleLongTimeFormat(ALocale);
      Result.ShortDateFormat = $mod.TFormatSettings.GetLocaleShortDateFormat(ALocale);
      for (var $l = 0, $end = rtl.length(cDateSeps) - 1; $l <= $end; $l++) {
        lCount = $l;
        if ($mod.TStringHelper.IndexOf.call({p: Result, get: function () {
            return this.p.ShortDateFormat;
          }, set: function (v) {
            this.p.ShortDateFormat = v;
          }},cDateSeps[lCount]) >= 0) Result.DateSeparator = cDateSeps[lCount];
      };
      var lEvent = new Date('Jan 1, 1980 06:07:08 GMT+00:00');
      var lLoc1 = "";
      if (ALocale == "")
        lLoc1 = navigator.language;
      else
        lLoc1 = ALocale;
      lTimeStr = lEvent.toLocaleTimeString(lLoc1);
      for (var $l1 = 0, $end1 = rtl.length(cTimeSeps) - 1; $l1 <= $end1; $l1++) {
        lCount = $l1;
        if ($mod.TStringHelper.IndexOf.call({get: function () {
            return lTimeStr;
          }, set: function (v) {
            lTimeStr = v;
          }},cTimeSeps[lCount]) >= 0) Result.TimeSeparator = cTimeSeps[lCount];
      };
      for (lCount = 1; lCount <= 7; lCount++) Result.ShortDayNames[lCount - 1] = $mod.TFormatSettings.GetLocaleShortDayName(lCount,ALocale);
      for (lCount = 1; lCount <= 7; lCount++) Result.LongDayNames[lCount - 1] = $mod.TFormatSettings.GetLocaleLongDayName(lCount,ALocale);
      for (lCount = 1; lCount <= 12; lCount++) Result.ShortMonthNames[lCount - 1] = $mod.TFormatSettings.GetLocaleShortMonthName(lCount,ALocale);
      for (lCount = 1; lCount <= 12; lCount++) Result.LongMonthNames[lCount - 1] = $mod.TFormatSettings.GetLocaleLongMonthName(lCount,ALocale);
      Result.DecimalSeparator = $mod.TFormatSettings.GetLocaleDecimalSeparator(ALocale);
      for (var $l2 = 0, $end2 = rtl.length(cDecSeps) - 1; $l2 <= $end2; $l2++) {
        lCount = $l2;
        if (Result.DecimalSeparator === cDecSeps[lCount]) {
          Result.ThousandSeparator = cThousandSeps[lCount];
          break;
        };
      };
      if ($mod.TFormatSettings.InitLocaleHandler != null) $mod.TFormatSettings.InitLocaleHandler($mod.UpperCase(ALocale),$mod.TFormatSettings.$clone(Result));
      return Result;
    };
    this.Invariant = function () {
      var Result = $mod.TFormatSettings.$new();
      if (!$impl.FInvariantCreated) {
        $impl.FInvariant.$assign($mod.TFormatSettings.Create$1("EN-US"));
        $impl.FInvariant.CurrencyString = "¤";
        $impl.FInvariant.CurrencyFormat = 0;
        $impl.FInvariant.CurrencyDecimals = 2;
        $impl.FInvariant.DateSeparator = "/";
        $impl.FInvariant.TimeSeparator = ":";
        $impl.FInvariant.ShortDateFormat = "MM/dd/yyyy";
        $impl.FInvariant.LongDateFormat = "dddd, dd MMMMM yyyy HH:mm:ss";
        $impl.FInvariant.TimeAMString = "AM";
        $impl.FInvariant.TimePMString = "PM";
        $impl.FInvariant.ShortTimeFormat = "HH:mm";
        $impl.FInvariant.LongTimeFormat = "HH:mm:ss";
        $impl.FInvariant.ShortMonthNames = $impl.DefaultShortMonthNames.slice(0);
        $impl.FInvariant.LongMonthNames = $impl.DefaultLongMonthNames.slice(0);
        $impl.FInvariant.ShortDayNames = $impl.DefaultShortDayNames.slice(0);
        $impl.FInvariant.LongDayNames = $impl.DefaultLongDayNames.slice(0);
        $impl.FInvariant.ThousandSeparator = ",";
        $impl.FInvariant.DecimalSeparator = ".";
        $impl.FInvariant.TwoDigitYearCenturyWindow = 50;
        $impl.FInvariant.NegCurrFormat = 0;
        $impl.FInvariantCreated = true;
      };
      Result.$assign($impl.FInvariant);
      return Result;
    };
    var $r = $mod.$rtti.$Record("TFormatSettings",{},this);
    $r.addField("CurrencyDecimals",rtl.byte);
    $r.addField("CurrencyFormat",rtl.byte);
    $r.addField("CurrencyString",rtl.string);
    $r.addField("DateSeparator",rtl.char);
    $mod.$rtti.$StaticArray("TFormatSettings.DateTimeToStrFormat$a",{dims: [2], eltype: rtl.string});
    $r.addField("DateTimeToStrFormat",$mod.$rtti["TFormatSettings.DateTimeToStrFormat$a"]);
    $r.addField("DecimalSeparator",rtl.string);
    $r.addField("LongDateFormat",rtl.string);
    $r.addField("LongDayNames",$mod.$rtti["TDayNames"]);
    $r.addField("LongMonthNames",$mod.$rtti["TMonthNameArray"]);
    $r.addField("LongTimeFormat",rtl.string);
    $r.addField("NegCurrFormat",rtl.byte);
    $r.addField("ShortDateFormat",rtl.string);
    $r.addField("ShortDayNames",$mod.$rtti["TDayNames"]);
    $r.addField("ShortMonthNames",$mod.$rtti["TMonthNameArray"]);
    $r.addField("ShortTimeFormat",rtl.string);
    $r.addField("ThousandSeparator",rtl.string);
    $r.addField("TimeAMString",rtl.string);
    $r.addField("TimePMString",rtl.string);
    $r.addField("TimeSeparator",rtl.char);
    $r.addField("TwoDigitYearCenturyWindow",rtl.word);
    $r.addField("InitLocaleHandler",$mod.$rtti["TFormatSettings.TLocaleInitCallback"]);
    $r.addMethod("Create",5,[],2,$r,1);
    $r.addMethod("Create$1",5,[["ALocale",rtl.string,2]],2,$r,1);
    $r.addMethod("Invariant",5,[],2,$r,1);
  },true);
  rtl.createClass(this,"Exception",pas.System.TObject,function () {
    this.LogMessageOnCreate = false;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FMessage = "";
      this.FHelpContext = 0;
      this.FJSError = null;
      this.FStack = undefined;
    };
    this.$final = function () {
      this.FJSError = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (Msg) {
      this.FMessage = Msg;
      this.FJSError = new Error(Msg);
      this.FStack = this.FJSError.stack;
      this.FHelpContext = 0;
      if (this.LogMessageOnCreate) pas.System.Writeln("Created exception ",this.$classname," with message: ",Msg);
      return this;
    };
    this.CreateFmt = function (Msg, Args) {
      this.Create$1($mod.Format(Msg,Args));
      return this;
    };
    this.CreateHelp = function (Msg, AHelpContext) {
      this.Create$1(Msg);
      this.FHelpContext = AHelpContext;
      return this;
    };
    this.CreateFmtHelp = function (Msg, Args, AHelpContext) {
      this.Create$1($mod.Format(Msg,Args));
      this.FHelpContext = AHelpContext;
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.$classname + ": " + this.FMessage;
      return Result;
    };
  });
  this.$rtti.$ClassRef("ExceptClass",{instancetype: this.$rtti["Exception"]});
  rtl.createClass(this,"EExternal",this.Exception,function () {
  });
  rtl.createClass(this,"EMathError",this.EExternal,function () {
  });
  rtl.createClass(this,"EInvalidOp",this.EMathError,function () {
  });
  rtl.createClass(this,"EZeroDivide",this.EMathError,function () {
  });
  rtl.createClass(this,"EOverflow",this.EMathError,function () {
  });
  rtl.createClass(this,"EUnderflow",this.EMathError,function () {
  });
  rtl.createClass(this,"EAbort",this.Exception,function () {
  });
  rtl.createClass(this,"EInvalidCast",this.Exception,function () {
  });
  rtl.createClass(this,"EAssertionFailed",this.Exception,function () {
  });
  rtl.createClass(this,"EObjectCheck",this.Exception,function () {
  });
  rtl.createClass(this,"EConvertError",this.Exception,function () {
  });
  rtl.createClass(this,"EFormatError",this.Exception,function () {
  });
  rtl.createClass(this,"EIntError",this.EExternal,function () {
  });
  rtl.createClass(this,"EDivByZero",this.EIntError,function () {
  });
  rtl.createClass(this,"ERangeError",this.EIntError,function () {
  });
  rtl.createClass(this,"EIntOverflow",this.EIntError,function () {
  });
  rtl.createClass(this,"EInOutError",this.Exception,function () {
    this.$init = function () {
      $mod.Exception.$init.call(this);
      this.ErrorCode = 0;
    };
  });
  rtl.createClass(this,"EHeapMemoryError",this.Exception,function () {
  });
  rtl.createClass(this,"EExternalException",this.EExternal,function () {
  });
  rtl.createClass(this,"EInvalidPointer",this.EHeapMemoryError,function () {
  });
  rtl.createClass(this,"EOutOfMemory",this.EHeapMemoryError,function () {
  });
  rtl.createClass(this,"EVariantError",this.Exception,function () {
    this.$init = function () {
      $mod.Exception.$init.call(this);
      this.ErrCode = 0;
    };
    this.CreateCode = function (Code) {
      this.ErrCode = Code;
      return this;
    };
  });
  rtl.createClass(this,"EAccessViolation",this.EExternal,function () {
  });
  rtl.createClass(this,"EBusError",this.EAccessViolation,function () {
  });
  rtl.createClass(this,"EPrivilege",this.EExternal,function () {
  });
  rtl.createClass(this,"EStackOverflow",this.EExternal,function () {
  });
  rtl.createClass(this,"EControlC",this.EExternal,function () {
  });
  rtl.createClass(this,"EAbstractError",this.Exception,function () {
  });
  rtl.createClass(this,"EPropReadOnly",this.Exception,function () {
  });
  rtl.createClass(this,"EPropWriteOnly",this.Exception,function () {
  });
  rtl.createClass(this,"EIntfCastError",this.Exception,function () {
  });
  rtl.createClass(this,"EInvalidContainer",this.Exception,function () {
  });
  rtl.createClass(this,"EInvalidInsert",this.Exception,function () {
  });
  rtl.createClass(this,"EPackageError",this.Exception,function () {
  });
  rtl.createClass(this,"EOSError",this.Exception,function () {
    this.$init = function () {
      $mod.Exception.$init.call(this);
      this.ErrorCode = 0;
    };
  });
  rtl.createClass(this,"ESafecallException",this.Exception,function () {
  });
  rtl.createClass(this,"ENoThreadSupport",this.Exception,function () {
  });
  rtl.createClass(this,"ENoWideStringSupport",this.Exception,function () {
  });
  rtl.createClass(this,"ENotImplemented",this.Exception,function () {
  });
  rtl.createClass(this,"EArgumentException",this.Exception,function () {
  });
  rtl.createClass(this,"EArgumentOutOfRangeException",this.EArgumentException,function () {
  });
  rtl.createClass(this,"EArgumentNilException",this.EArgumentException,function () {
  });
  rtl.createClass(this,"EPathTooLongException",this.Exception,function () {
  });
  rtl.createClass(this,"ENotSupportedException",this.Exception,function () {
  });
  rtl.createClass(this,"EDirectoryNotFoundException",this.Exception,function () {
  });
  rtl.createClass(this,"EFileNotFoundException",this.Exception,function () {
  });
  rtl.createClass(this,"EPathNotFoundException",this.Exception,function () {
  });
  rtl.createClass(this,"ENoConstructException",this.Exception,function () {
  });
  this.EmptyStr = "";
  this.EmptyWideStr = "";
  this.HexDisplayPrefix = "$";
  this.LeadBytes = {};
  this.CharInSet = function (Ch, CSet) {
    var Result = false;
    var I = 0;
    Result = false;
    I = rtl.length(CSet) - 1;
    while (!Result && (I >= 0)) {
      Result = Ch === CSet[I];
      I -= 1;
    };
    return Result;
  };
  this.CharInSet$1 = function (Ch, CSet) {
    var Result = false;
    Result = Ch.charCodeAt() in CSet;
    return Result;
  };
  this.LeftStr = function (S, Count) {
    return (Count>0) ? S.substr(0,Count) : "";
  };
  this.RightStr = function (S, Count) {
    var l = S.length;
    return (Count<1) ? "" : ( Count>=l ? S : S.substr(l-Count));
  };
  this.Trim = function (S) {
    return S.replace(/^[\s\uFEFF\xA0\x00-\x1f]+/,'').replace(/[\s\uFEFF\xA0\x00-\x1f]+$/,'');
  };
  this.TrimLeft = function (S) {
    return S.replace(/^[\s\uFEFF\xA0\x00-\x1f]+/,'');
  };
  this.TrimRight = function (S) {
    return S.replace(/[\s\uFEFF\xA0\x00-\x1f]+$/,'');
  };
  this.UpperCase = function (s) {
    return s.toUpperCase();
  };
  this.LowerCase = function (s) {
    return s.toLowerCase();
  };
  this.CompareStr = function (s1, s2) {
    var l1 = s1.length;
    var l2 = s2.length;
    if (l1<=l2){
      var s = s2.substr(0,l1);
      if (s1<s){ return -1;
      } else if (s1>s){ return 1;
      } else { return l1<l2 ? -1 : 0; };
    } else {
      var s = s1.substr(0,l2);
      if (s<s2){ return -1;
      } else { return 1; };
    };
  };
  this.SameStr = function (s1, s2) {
    return s1 == s2;
  };
  this.CompareText = function (s1, s2) {
    var l1 = s1.toLowerCase();
    var l2 = s2.toLowerCase();
    if (l1>l2){ return 1;
    } else if (l1<l2){ return -1;
    } else { return 0; };
  };
  this.SameText = function (s1, s2) {
    return s1.toLowerCase() == s2.toLowerCase();
  };
  this.AnsiCompareText = function (s1, s2) {
    return s1.localeCompare(s2);
  };
  this.AnsiSameText = function (s1, s2) {
    return s1.toLowerCase() == s2.toLowerCase();
  };
  this.AnsiCompareStr = function (s1, s2) {
    var Result = 0;
    Result = $mod.CompareText(s1,s2);
    return Result;
  };
  this.AppendStr = function (Dest, S) {
    Dest.set(Dest.get() + S);
  };
  this.Format = function (Fmt, Args) {
    var Result = "";
    Result = $mod.Format$1(Fmt,Args,$mod.FormatSettings);
    return Result;
  };
  this.Format$1 = function (Fmt, Args, aSettings) {
    var Result = "";
    var ChPos = 0;
    var OldPos = 0;
    var ArgPos = 0;
    var DoArg = 0;
    var Len = 0;
    var Hs = "";
    var ToAdd = "";
    var Index = 0;
    var Width = 0;
    var Prec = 0;
    var Left = false;
    var Fchar = "\x00";
    var vq = 0;
    function ReadFormat() {
      var Result = "\x00";
      var Value = 0;
      function ReadInteger() {
        var Code = 0;
        var ArgN = 0;
        if (Value !== -1) return;
        OldPos = ChPos;
        while ((ChPos <= Len) && (Fmt.charAt(ChPos - 1) <= "9") && (Fmt.charAt(ChPos - 1) >= "0")) ChPos += 1;
        if (ChPos > Len) $impl.DoFormatError(1,Fmt);
        if (Fmt.charAt(ChPos - 1) === "*") {
          if (Index === 255) {
            ArgN = ArgPos}
           else {
            ArgN = Index;
            Index += 1;
          };
          if ((ChPos > OldPos) || (ArgN > (rtl.length(Args) - 1))) $impl.DoFormatError(1,Fmt);
          ArgPos = ArgN + 1;
          var $tmp = Args[ArgN].VType;
          if ($tmp === 0) {
            Value = Args[ArgN].VJSValue}
           else if ($tmp === 19) {
            Value = Args[ArgN].VJSValue}
           else {
            $impl.DoFormatError(1,Fmt);
          };
          ChPos += 1;
        } else {
          if (OldPos < ChPos) {
            pas.System.val(pas.System.Copy(Fmt,OldPos,ChPos - OldPos),{get: function () {
                return Value;
              }, set: function (v) {
                Value = v;
              }},{get: function () {
                return Code;
              }, set: function (v) {
                Code = v;
              }});
            if (Code > 0) $impl.DoFormatError(1,Fmt);
          } else Value = -1;
        };
      };
      function ReadIndex() {
        if (Fmt.charAt(ChPos - 1) !== ":") {
          ReadInteger()}
         else Value = 0;
        if (Fmt.charAt(ChPos - 1) === ":") {
          if (Value === -1) $impl.DoFormatError(2,Fmt);
          Index = Value;
          Value = -1;
          ChPos += 1;
        };
      };
      function ReadLeft() {
        if (Fmt.charAt(ChPos - 1) === "-") {
          Left = true;
          ChPos += 1;
        } else Left = false;
      };
      function ReadWidth() {
        ReadInteger();
        if (Value !== -1) {
          Width = Value;
          Value = -1;
        };
      };
      function ReadPrec() {
        if (Fmt.charAt(ChPos - 1) === ".") {
          ChPos += 1;
          ReadInteger();
          if (Value === -1) Value = 0;
          Prec = Value;
        };
      };
      Index = 255;
      Width = -1;
      Prec = -1;
      Value = -1;
      ChPos += 1;
      if (Fmt.charAt(ChPos - 1) === "%") {
        Result = "%";
        return Result;
      };
      ReadIndex();
      ReadLeft();
      ReadWidth();
      ReadPrec();
      Result = pas.System.upcase(Fmt.charAt(ChPos - 1));
      return Result;
    };
    function Checkarg(AT, err) {
      var Result = false;
      Result = false;
      if (Index === 255) {
        DoArg = ArgPos}
       else DoArg = Index;
      ArgPos = DoArg + 1;
      if ((DoArg > (rtl.length(Args) - 1)) || (Args[DoArg].VType !== AT)) {
        if (err) $impl.DoFormatError(3,Fmt);
        ArgPos -= 1;
        return Result;
      };
      Result = true;
      return Result;
    };
    Result = "";
    Len = Fmt.length;
    ChPos = 1;
    OldPos = 1;
    ArgPos = 0;
    while (ChPos <= Len) {
      while ((ChPos <= Len) && (Fmt.charAt(ChPos - 1) !== "%")) ChPos += 1;
      if (ChPos > OldPos) Result = Result + pas.System.Copy(Fmt,OldPos,ChPos - OldPos);
      if (ChPos < Len) {
        Fchar = ReadFormat();
        var $tmp = Fchar;
        if ($tmp === "D") {
          if (Checkarg(0,false)) {
            ToAdd = $mod.IntToStr(Args[DoArg].VJSValue)}
           else if (Checkarg(19,true)) ToAdd = $mod.IntToStr(Args[DoArg].VJSValue);
          Width = Math.abs(Width);
          Index = Prec - ToAdd.length;
          if (ToAdd.charAt(0) !== "-") {
            ToAdd = pas.System.StringOfChar("0",Index) + ToAdd}
           else pas.System.Insert(pas.System.StringOfChar("0",Index + 1),{get: function () {
              return ToAdd;
            }, set: function (v) {
              ToAdd = v;
            }},2);
        } else if ($tmp === "U") {
          if (Checkarg(0,false)) {
            ToAdd = $mod.IntToStr(Args[DoArg].VJSValue >>> 0)}
           else if (Checkarg(19,true)) ToAdd = $mod.IntToStr(Args[DoArg].VJSValue);
          Width = Math.abs(Width);
          Index = Prec - ToAdd.length;
          ToAdd = pas.System.StringOfChar("0",Index) + ToAdd;
        } else if ($tmp === "E") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffExponent,3,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffExponent,3,Prec,aSettings);
        } else if ($tmp === "F") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffFixed,9999,Prec,aSettings)}
           else if (Checkarg(0,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffFixed,9999,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffFixed,9999,Prec,aSettings);
        } else if ($tmp === "G") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffGeneral,Prec,3,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffGeneral,Prec,3,aSettings);
        } else if ($tmp === "N") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffNumber,9999,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffNumber,9999,Prec,aSettings);
        } else if ($tmp === "M") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffCurrency,9999,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffCurrency,9999,Prec,aSettings);
        } else if ($tmp === "S") {
          if (Checkarg(18,false)) {
            Hs = Args[DoArg].VJSValue}
           else if (Checkarg(9,true)) Hs = Args[DoArg].VJSValue;
          Index = Hs.length;
          if ((Prec !== -1) && (Index > Prec)) Index = Prec;
          ToAdd = pas.System.Copy(Hs,1,Index);
        } else if ($tmp === "P") {
          if (Checkarg(0,false)) {
            ToAdd = $mod.IntToHex(Args[DoArg].VJSValue,8)}
           else if (Checkarg(0,true)) ToAdd = $mod.IntToHex(Args[DoArg].VJSValue,16);
        } else if ($tmp === "X") {
          if (Checkarg(0,false)) {
            vq = Args[DoArg].VJSValue;
            Index = 16;
          } else if (Checkarg(19,true)) {
            vq = Args[DoArg].VJSValue;
            Index = 31;
          };
          if (Prec > Index) {
            ToAdd = $mod.IntToHex(vq,Index)}
           else {
            Index = 1;
            while ((rtl.shl(1,Index * 4) <= vq) && (Index < 16)) Index += 1;
            if (Index > Prec) Prec = Index;
            ToAdd = $mod.IntToHex(vq,Prec);
          };
        } else if ($tmp === "%") ToAdd = "%";
        if (Width !== -1) if (ToAdd.length < Width) if (!Left) {
          ToAdd = pas.System.StringOfChar(" ",Width - ToAdd.length) + ToAdd}
         else ToAdd = ToAdd + pas.System.StringOfChar(" ",Width - ToAdd.length);
        Result = Result + ToAdd;
      };
      ChPos += 1;
      OldPos = ChPos;
    };
    return Result;
  };
  this.BytesOf = function (AVal) {
    var Result = [];
    var I = 0;
    Result = rtl.arraySetLength(Result,0,AVal.length);
    for (var $l = 0, $end = AVal.length - 1; $l <= $end; $l++) {
      I = $l;
      Result[I] = AVal.charCodeAt((I + 1) - 1);
    };
    return Result;
  };
  this.StringOf = function (ABytes) {
    var Result = "";
    var I = 0;
    Result = "";
    for (var $l = 0, $end = rtl.length(ABytes) - 1; $l <= $end; $l++) {
      I = $l;
      Result = Result + String.fromCharCode(ABytes[I]);
    };
    return Result;
  };
  this.LocaleCompare = function (s1, s2, locales) {
    return s1.localeCompare(s2,locales) == 0;
  };
  this.NormalizeStr = function (S, Norm) {
    return S.normalize(Norm);
  };
  var Alpha = rtl.createSet(null,65,90,null,97,122,95);
  var AlphaNum = rtl.unionSet(Alpha,rtl.createSet(null,48,57));
  var Dot = ".";
  this.IsValidIdent = function (Ident, AllowDots, StrictDots) {
    var Result = false;
    var First = false;
    var I = 0;
    var Len = 0;
    Len = Ident.length;
    if (Len < 1) return false;
    First = true;
    Result = false;
    I = 1;
    while (I <= Len) {
      if (First) {
        if (!(Ident.charCodeAt(I - 1) in Alpha)) return Result;
        First = false;
      } else if (AllowDots && (Ident.charAt(I - 1) === Dot)) {
        if (StrictDots) {
          if (I >= Len) return Result;
          First = true;
        };
      } else if (!(Ident.charCodeAt(I - 1) in AlphaNum)) return Result;
      I = I + 1;
    };
    Result = true;
    return Result;
  };
  this.TStringReplaceFlag = {"0": "rfReplaceAll", rfReplaceAll: 0, "1": "rfIgnoreCase", rfIgnoreCase: 1};
  this.$rtti.$Enum("TStringReplaceFlag",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TStringReplaceFlag});
  this.$rtti.$Set("TStringReplaceFlags",{comptype: this.$rtti["TStringReplaceFlag"]});
  this.Randomize = function () {
  };
  this.StringReplace = function (aOriginal, aSearch, aReplace, Flags) {
    var Result = "";
    var REFlags = "";
    var REString = "";
    REFlags = "";
    if ($mod.TStringReplaceFlag.rfReplaceAll in Flags) REFlags = "g";
    if ($mod.TStringReplaceFlag.rfIgnoreCase in Flags) REFlags = REFlags + "i";
    REString = aSearch.replace(new RegExp($impl.RESpecials,"g"),"\\$1");
    Result = aOriginal.replace(new RegExp(REString,REFlags),aReplace);
    return Result;
  };
  this.QuoteString = function (aOriginal, AQuote) {
    var Result = "";
    Result = AQuote + $mod.StringReplace(aOriginal,AQuote,AQuote + AQuote,rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll)) + AQuote;
    return Result;
  };
  this.QuotedStr = function (s, QuoteChar) {
    var Result = "";
    Result = $mod.QuoteString(s,QuoteChar);
    return Result;
  };
  this.DeQuoteString = function (aQuoted, AQuote) {
    var Result = "";
    var i = 0;
    Result = aQuoted;
    if (Result.substr(0,1) !== AQuote) return Result;
    Result = Result.slice(1);
    i = 1;
    while (i <= Result.length) {
      if (Result.charAt(i - 1) === AQuote) {
        if ((i === Result.length) || (Result.charAt((i + 1) - 1) !== AQuote)) {
          Result = Result.slice(0,i - 1);
          return Result;
        } else Result = Result.slice(0,i - 1) + Result.slice(i);
      } else i += 1;
    };
    return Result;
  };
  this.LastDelimiter = function (Delimiters, S) {
    var Result = 0;
    Result = S.length;
    while ((Result > 0) && (pas.System.Pos(S.charAt(Result - 1),Delimiters) === 0)) Result -= 1;
    return Result;
  };
  this.IsDelimiter = function (Delimiters, S, Index) {
    var Result = false;
    Result = false;
    if ((Index > 0) && (Index <= S.length)) Result = pas.System.Pos(S.charAt(Index - 1),Delimiters) !== 0;
    return Result;
  };
  this.AdjustLineBreaks = function (S) {
    var Result = "";
    Result = $mod.AdjustLineBreaks$1(S,pas.System.DefaultTextLineBreakStyle);
    return Result;
  };
  this.AdjustLineBreaks$1 = function (S, Style) {
    var Result = "";
    var I = 0;
    var L = 0;
    var Res = "";
    function Add(C) {
      Res = Res + C;
    };
    I = 0;
    L = S.length;
    Result = "";
    while (I <= L) {
      var $tmp = S.charAt(I - 1);
      if ($tmp === "\n") {
        if (Style in rtl.createSet(pas.System.TTextLineBreakStyle.tlbsCRLF,pas.System.TTextLineBreakStyle.tlbsCR)) Add("\r");
        if (Style === pas.System.TTextLineBreakStyle.tlbsCRLF) Add("\n");
        I += 1;
      } else if ($tmp === "\r") {
        if (Style === pas.System.TTextLineBreakStyle.tlbsCRLF) Add("\r");
        Add("\n");
        I += 1;
        if (S.charAt(I - 1) === "\n") I += 1;
      } else {
        Add(S.charAt(I - 1));
        I += 1;
      };
    };
    Result = Res;
    return Result;
  };
  var Quotes = rtl.createSet(39,34);
  this.WrapText = function (Line, BreakStr, BreakChars, MaxCol) {
    var Result = "";
    var L = "";
    var C = "\x00";
    var LQ = "\x00";
    var BC = "\x00";
    var P = 0;
    var BLen = 0;
    var Len = 0;
    var HB = false;
    var IBC = false;
    Result = "";
    L = Line;
    BLen = BreakStr.length;
    if (BLen > 0) {
      BC = BreakStr.charAt(0)}
     else BC = "\x00";
    Len = L.length;
    while (Len > 0) {
      P = 1;
      LQ = "\x00";
      HB = false;
      IBC = false;
      while ((P <= Len) && ((P <= MaxCol) || !IBC) && ((LQ !== "\x00") || !HB)) {
        C = L.charAt(P - 1);
        if (C === LQ) {
          LQ = "\x00"}
         else if (C.charCodeAt() in Quotes) LQ = C;
        if (LQ !== "\x00") {
          P += 1}
         else {
          HB = (C === BC) && (BreakStr === pas.System.Copy(L,P,BLen));
          if (HB) {
            P += BLen}
           else {
            if (P >= MaxCol) IBC = $mod.CharInSet(C,BreakChars);
            P += 1;
          };
        };
      };
      Result = Result + pas.System.Copy(L,1,P - 1);
      pas.System.Delete({get: function () {
          return L;
        }, set: function (v) {
          L = v;
        }},1,P - 1);
      Len = L.length;
      if ((Len > 0) && !HB) Result = Result + BreakStr;
    };
    return Result;
  };
  this.WrapText$1 = function (Line, MaxCol) {
    var Result = "";
    Result = $mod.WrapText(Line,pas.System.sLineBreak,[" ","-","\t"],MaxCol);
    return Result;
  };
  this.SwapEndian = function (W) {
    var Result = 0;
    Result = ((W & 0xFF) << 8) | ((W >>> 8) & 0xFF);
    return Result;
  };
  this.SwapEndian$1 = function (C) {
    var Result = 0;
    Result = rtl.lw(rtl.lw(rtl.lw(rtl.lw((C & 0xFF) << 24) | rtl.lw((C & 0xFF00) << 8)) | (rtl.lw(C >>> 8) & 0xFF00)) | (rtl.lw(C >>> 24) & 0xFF));
    return Result;
  };
  this.IntToStr = function (Value) {
    var Result = "";
    Result = "" + Value;
    return Result;
  };
  this.TryStrToInt = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToInt$1(S,res,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToInt$1 = function (S, res, aSettings) {
    var Result = false;
    var NI = 0;
    Result = $mod.TryStrToInt$3(S,{get: function () {
        return NI;
      }, set: function (v) {
        NI = v;
      }},aSettings);
    Result = Result && (-2147483648 <= NI) && (NI <= 2147483647);
    if (Result) res.set(NI);
    return Result;
  };
  this.TryStrToInt$2 = function (S, res) {
    var Result = false;
    Result = $impl.IntTryStrToInt(S,res,$mod.FormatSettings.DecimalSeparator);
    return Result;
  };
  this.TryStrToInt$3 = function (S, res, aSettings) {
    var Result = false;
    Result = $impl.IntTryStrToInt(S,res,aSettings.DecimalSeparator);
    return Result;
  };
  this.StrToIntDef = function (S, aDef) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }})) {
      Result = R}
     else Result = aDef;
    return Result;
  };
  this.StrToIntDef$1 = function (S, aDef) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }})) {
      Result = R}
     else Result = aDef;
    return Result;
  };
  this.StrToInt = function (S) {
    var Result = 0;
    var R = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = R;
    return Result;
  };
  this.StrToNativeInt = function (S) {
    var Result = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.StrToUInt = function (s) {
    var Result = 0;
    if (!$mod.TryStrToUInt(s,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,s)]);
    return Result;
  };
  this.StrToUIntDef = function (s, aDef) {
    var Result = 0;
    if (!$mod.TryStrToUInt(s,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = aDef;
    return Result;
  };
  this.UIntToStr = function (Value) {
    var Result = "";
    Result = $mod.IntToStr(Value);
    return Result;
  };
  this.TryStrToUInt = function (s, C) {
    var Result = false;
    var N = 0;
    Result = $mod.TryStrToInt$2(s,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }});
    Result = (N >= 0) && (N <= 4294967295);
    if (Result) C.set(N);
    return Result;
  };
  this.StrToInt64 = function (S) {
    var Result = 0;
    var N = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = N;
    return Result;
  };
  this.StrToInt64Def = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToInt64(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToInt64 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToInt64$1(S,res,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToInt64$1 = function (S, res, ASettings) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$3(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }},ASettings);
    if (Result) res.set(R);
    return Result;
  };
  this.StrToQWord = function (S) {
    var Result = 0;
    var N = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }}) || (N < 0)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = N;
    return Result;
  };
  this.StrToQWordDef = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToQWord(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToQWord = function (S, res) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }}) && (R >= 0);
    if (Result) res.set(R);
    return Result;
  };
  this.TryStrToQWord$1 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToQWord(S,res);
    return Result;
  };
  this.StrToUInt64 = function (S) {
    var Result = 0;
    var N = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }}) || (N < 0)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = N;
    return Result;
  };
  this.StrToUInt64Def = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToUInt64(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToUInt64 = function (S, res) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }}) && (R >= 0);
    if (Result) res.set(R);
    return Result;
  };
  this.TryStrToUInt64$1 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToUInt64(S,res);
    return Result;
  };
  this.StrToDWord = function (S) {
    var Result = 0;
    if (!$mod.TryStrToDWord(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.StrToDWordDef = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToDWord(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToDWord = function (S, res) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }}) && (R >= 0) && (R <= 0xFFFFFFFF);
    if (Result) res.set(R);
    return Result;
  };
  this.IntToHex = function (Value, Digits) {
    var Result = "";
    Result = "";
    if (Value < 0) if (Value<0) Value = 0xFFFFFFFF + Value + 1;
    Result=Value.toString(16);
    Result = $mod.UpperCase(Result);
    while (Result.length < Digits) Result = "0" + Result;
    return Result;
  };
  this.MaxCurrency = 900719925474.0991;
  this.MinCurrency = -900719925474.0991;
  this.TFloatFormat = {"0": "ffFixed", ffFixed: 0, "1": "ffGeneral", ffGeneral: 1, "2": "ffExponent", ffExponent: 2, "3": "ffNumber", ffNumber: 3, "4": "ffCurrency", ffCurrency: 4};
  this.$rtti.$Enum("TFloatFormat",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TFloatFormat});
  var Rounds = "123456789:";
  this.FloatToDecimal = function (Value, Precision, Decimals) {
    var Result = $mod.TFloatRec.$new();
    var Buffer = "";
    var InfNan = "";
    var OutPos = 0;
    var error = 0;
    var N = 0;
    var L = 0;
    var C = 0;
    var GotNonZeroBeforeDot = false;
    var BeforeDot = false;
    Result.Negative = false;
    Result.Exponent = 0;
    for (C = 0; C <= 19; C++) Result.Digits[C] = "0";
    if (Value === 0) return Result;
    Buffer = rtl.floatToStr(Value,24);
    N = 1;
    L = Buffer.length;
    while (Buffer.charAt(N - 1) === " ") N += 1;
    Result.Negative = Buffer.charAt(N - 1) === "-";
    if (Result.Negative) {
      N += 1}
     else if (Buffer.charAt(N - 1) === "+") N += 1;
    if (L >= (N + 2)) {
      InfNan = pas.System.Copy(Buffer,N,3);
      if (InfNan === "Inf") {
        Result.Digits[0] = "\x00";
        Result.Exponent = 32767;
        return Result;
      };
      if (InfNan === "Nan") {
        Result.Digits[0] = "\x00";
        Result.Exponent = -32768;
        return Result;
      };
    };
    OutPos = 0;
    Result.Exponent = 0;
    BeforeDot = true;
    GotNonZeroBeforeDot = false;
    while ((L >= N) && (Buffer.charAt(N - 1) !== "E")) {
      if (Buffer.charAt(N - 1) === ".") {
        BeforeDot = false}
       else {
        if (BeforeDot) {
          Result.Exponent += 1;
          Result.Digits[OutPos] = Buffer.charAt(N - 1);
          if (Buffer.charAt(N - 1) !== "0") GotNonZeroBeforeDot = true;
        } else Result.Digits[OutPos] = Buffer.charAt(N - 1);
        OutPos += 1;
      };
      N += 1;
    };
    N += 1;
    if (N <= L) {
      pas.System.val$6(pas.System.Copy(Buffer,N,(L - N) + 1),{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }},{get: function () {
          return error;
        }, set: function (v) {
          error = v;
        }});
      Result.Exponent += C;
    };
    N = OutPos;
    L = 19;
    while (N < L) {
      Result.Digits[N] = "0";
      N += 1;
    };
    if ((Decimals + Result.Exponent) < Precision) {
      N = Decimals + Result.Exponent}
     else N = Precision;
    if (N >= L) N = L - 1;
    if (N === 0) {
      if (Result.Digits[0] >= "5") {
        Result.Digits[0] = "1";
        Result.Digits[1] = "\x00";
        Result.Exponent += 1;
      } else Result.Digits[0] = "\x00";
    } else if (N > 0) {
      if (Result.Digits[N] >= "5") {
        do {
          Result.Digits[N] = "\x00";
          N -= 1;
          Result.Digits[N] = Rounds.charAt(($mod.StrToInt(Result.Digits[N]) + 1) - 1);
        } while (!((N === 0) || (Result.Digits[N] < ":")));
        if (Result.Digits[0] === ":") {
          Result.Digits[0] = "1";
          Result.Exponent += 1;
        };
      } else {
        Result.Digits[N] = "0";
        while ((N > -1) && (Result.Digits[N] === "0")) {
          Result.Digits[N] = "\x00";
          N -= 1;
        };
      };
    } else Result.Digits[0] = "\x00";
    if ((Result.Digits[0] === "\x00") && !GotNonZeroBeforeDot) {
      Result.Exponent = 0;
      Result.Negative = false;
    };
    return Result;
  };
  this.FloatToStr = function (Value) {
    var Result = "";
    Result = $mod.FloatToStr$1(Value,$mod.FormatSettings);
    return Result;
  };
  this.FloatToStr$1 = function (Value, aSettings) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value,$mod.TFloatFormat.ffGeneral,15,0,aSettings);
    return Result;
  };
  this.FloatToStrF = function (Value, format, Precision, Digits) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value,format,Precision,Digits,$mod.FormatSettings);
    return Result;
  };
  this.FloatToStrF$1 = function (Value, format, Precision, Digits, aSettings) {
    var Result = "";
    var TS = "";
    var DS = "";
    DS = aSettings.DecimalSeparator;
    TS = aSettings.ThousandSeparator;
    var $tmp = format;
    if ($tmp === $mod.TFloatFormat.ffGeneral) {
      Result = $impl.FormatGeneralFloat(Value,Precision,DS)}
     else if ($tmp === $mod.TFloatFormat.ffExponent) {
      Result = $impl.FormatExponentFloat(Value,Precision,Digits,DS)}
     else if ($tmp === $mod.TFloatFormat.ffFixed) {
      Result = $impl.FormatFixedFloat(Value,Digits,DS)}
     else if ($tmp === $mod.TFloatFormat.ffNumber) {
      Result = $impl.FormatNumberFloat(Value,Digits,DS,TS)}
     else if ($tmp === $mod.TFloatFormat.ffCurrency) Result = $impl.FormatNumberCurrency(Value * 10000,Digits,aSettings);
    if ((format !== $mod.TFloatFormat.ffCurrency) && (Result.length > 1) && (Result.charAt(0) === "-")) $impl.RemoveLeadingNegativeSign({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},DS,TS);
    return Result;
  };
  this.TryStrToFloat = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToFloat$2(S,res);
    return Result;
  };
  this.TryStrToFloat$1 = function (S, res, aSettings) {
    var Result = false;
    Result = $mod.TryStrToFloat$3(S,res,aSettings);
    return Result;
  };
  this.TryStrToFloat$2 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToFloat$3(S,res,$mod.FormatSettings);
    return Result;
  };
  var TDecimalPart = {"0": "dpDigit", dpDigit: 0, "1": "dpSignificand", dpSignificand: 1, "2": "dpExp", dpExp: 2};
  this.TryStrToFloat$3 = function (S, res, aSettings) {
    var Result = false;
    var J = undefined;
    var I = 0;
    var aStart = 0;
    var Len = 0;
    var N = "";
    var p = 0;
    Result = false;
    N = S;
    if (aSettings.ThousandSeparator !== "") N = $mod.StringReplace(N,aSettings.ThousandSeparator,"",rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll));
    if (aSettings.DecimalSeparator !== ".") N = $mod.StringReplace(N,aSettings.DecimalSeparator,".",{});
    p = TDecimalPart.dpDigit;
    I = 1;
    aStart = 1;
    Len = N.length;
    while (I <= Len) {
      var $tmp = N.charAt(I - 1);
      if (($tmp === "+") || ($tmp === "-")) {
        var $tmp1 = p;
        if ($tmp1 === TDecimalPart.dpSignificand) {
          return Result}
         else if ($tmp1 === TDecimalPart.dpDigit) {
          if (I > aStart) return Result}
         else if ($tmp1 === TDecimalPart.dpExp) if (I > (aStart + 1)) return Result;
      } else if (($tmp >= "0") && ($tmp <= "9")) {}
      else if ($tmp === ".") {
        if (p !== TDecimalPart.dpDigit) return Result;
        p = TDecimalPart.dpSignificand;
        aStart = I;
      } else if (($tmp === "E") || ($tmp === "e")) {
        if (p === TDecimalPart.dpExp) {
          return Result}
         else {
          p = TDecimalPart.dpExp;
          aStart = I;
        };
      } else {
        return Result;
      };
      I += 1;
    };
    J = parseFloat(N);
    Result = !isNaN(J);
    if (Result) res.set(rtl.getNumber(J));
    return Result;
  };
  this.StrToFloatDef = function (S, aDef) {
    var Result = 0.0;
    if (!$mod.TryStrToFloat$3(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},$mod.FormatSettings)) Result = aDef;
    return Result;
  };
  this.StrToFloatDef$1 = function (S, aDef, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToFloat$3(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) Result = aDef;
    return Result;
  };
  this.StrToFloat = function (S) {
    var Result = 0.0;
    Result = $mod.StrToFloat$1(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToFloat$1 = function (S, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToFloat$3(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidFloat"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.FormatFloat = function (Fmt, aValue) {
    var Result = "";
    Result = $mod.FormatFloat$1(Fmt,aValue,$mod.TFormatSettings.$clone($mod.FormatSettings));
    return Result;
  };
  var MaxPrecision = 18;
  this.FormatFloat$1 = function (Fmt, aValue, aSettings) {
    var Result = "";
    var E = 0.0;
    var FV = $mod.TFloatRec.$new();
    var Section = "";
    var SectionLength = 0;
    var ThousandSep = false;
    var IsScientific = false;
    var DecimalPos = 0;
    var FirstDigit = 0;
    var LastDigit = 0;
    var RequestedDigits = 0;
    var ExpSize = 0;
    var Available = 0;
    var Current = 0;
    var PadZeroes = 0;
    var DistToDecimal = 0;
    function InitVars() {
      E = aValue;
      Section = "";
      SectionLength = 0;
      ThousandSep = false;
      IsScientific = false;
      DecimalPos = 0;
      FirstDigit = 2147483647;
      LastDigit = 0;
      RequestedDigits = 0;
      ExpSize = 0;
      Available = -1;
    };
    function ToResult(AChar) {
      Result = Result + AChar;
    };
    function AddToResult(AStr) {
      Result = Result + AStr;
    };
    function WriteDigit(ADigit) {
      if (ADigit === "\x00") return;
      DistToDecimal -= 1;
      if (DistToDecimal === -1) {
        AddToResult(aSettings.DecimalSeparator);
        ToResult(ADigit);
      } else {
        ToResult(ADigit);
        if (ThousandSep && ((DistToDecimal % 3) === 0) && (DistToDecimal > 1)) AddToResult(aSettings.ThousandSeparator);
      };
    };
    function GetDigit() {
      var Result = "\x00";
      Result = "\x00";
      if (Current <= Available) {
        Result = FV.Digits[Current];
        Current += 1;
      } else if (DistToDecimal <= LastDigit) {
        DistToDecimal -= 1}
       else Result = "0";
      return Result;
    };
    function CopyDigit() {
      if (PadZeroes === 0) {
        WriteDigit(GetDigit())}
       else if (PadZeroes < 0) {
        PadZeroes += 1;
        if (DistToDecimal <= FirstDigit) {
          WriteDigit("0")}
         else DistToDecimal -= 1;
      } else {
        while (PadZeroes > 0) {
          WriteDigit(GetDigit());
          PadZeroes -= 1;
        };
        WriteDigit(GetDigit());
      };
    };
    function GetSections(SP) {
      var Result = 0;
      var FL = 0;
      var i = 0;
      var C = "\x00";
      var Q = "\x00";
      var inQuote = false;
      Result = 1;
      SP.get()[1] = -1;
      SP.get()[2] = -1;
      SP.get()[3] = -1;
      inQuote = false;
      Q = "\x00";
      i = 1;
      FL = Fmt.length;
      while (i <= FL) {
        C = Fmt.charAt(i - 1);
        var $tmp = C;
        if ($tmp === ";") {
          if (!inQuote) {
            if (Result > 3) throw $mod.Exception.$create("Create$1",["Invalid float format"]);
            SP.get()[Result] = i;
            Result += 1;
          };
        } else if (($tmp === '"') || ($tmp === "'")) {
          if (inQuote) {
            inQuote = C !== Q}
           else {
            inQuote = true;
            Q = C;
          };
        };
        i += 1;
      };
      if (SP.get()[Result] === -1) SP.get()[Result] = FL + 1;
      return Result;
    };
    function AnalyzeFormat() {
      var I = 0;
      var Len = 0;
      var Q = "\x00";
      var C = "\x00";
      var InQuote = false;
      Len = Section.length;
      I = 1;
      InQuote = false;
      Q = "\x00";
      while (I <= Len) {
        C = Section.charAt(I - 1);
        if (C.charCodeAt() in rtl.createSet(34,39)) {
          if (InQuote) {
            InQuote = C !== Q}
           else {
            InQuote = true;
            Q = C;
          };
        } else if (!InQuote) {
          var $tmp = C;
          if ($tmp === ".") {
            if (DecimalPos === 0) DecimalPos = RequestedDigits + 1}
           else if ($tmp === ",") {
            ThousandSep = aSettings.ThousandSeparator !== "\x00"}
           else if (($tmp === "e") || ($tmp === "E")) {
            I += 1;
            if (I < Len) {
              C = Section.charAt(I - 1);
              IsScientific = C.charCodeAt() in rtl.createSet(45,43);
              if (IsScientific) while ((I < Len) && (Section.charAt((I + 1) - 1) === "0")) {
                ExpSize += 1;
                I += 1;
              };
              if (ExpSize > 4) ExpSize = 4;
            };
          } else if ($tmp === "#") {
            RequestedDigits += 1}
           else if ($tmp === "0") {
            if (RequestedDigits < FirstDigit) FirstDigit = RequestedDigits + 1;
            RequestedDigits += 1;
            LastDigit = RequestedDigits + 1;
          };
        };
        I += 1;
      };
      if (DecimalPos === 0) DecimalPos = RequestedDigits + 1;
      LastDigit = DecimalPos - LastDigit;
      if (LastDigit > 0) LastDigit = 0;
      FirstDigit = DecimalPos - FirstDigit;
      if (FirstDigit < 0) FirstDigit = 0;
    };
    function ValueOutSideScope() {
      var Result = false;
      Result = ((FV.Exponent >= 18) && !IsScientific) || (FV.Exponent === 0x7FF) || (FV.Exponent === 0x800);
      return Result;
    };
    function CalcRunVars() {
      var D = 0;
      var P = 0;
      if (IsScientific) {
        P = RequestedDigits;
        D = 9999;
      } else {
        P = 18;
        D = (RequestedDigits - DecimalPos) + 1;
      };
      FV.$assign($mod.FloatToDecimal(aValue,P,D));
      DistToDecimal = DecimalPos - 1;
      if (IsScientific) {
        PadZeroes = 0}
       else {
        PadZeroes = FV.Exponent - (DecimalPos - 1);
        if (PadZeroes >= 0) DistToDecimal = FV.Exponent;
      };
      Available = -1;
      while ((Available < 18) && (FV.Digits[Available + 1] !== "\x00")) Available += 1;
    };
    function FormatExponent(ASign, aExponent) {
      var Result = "";
      Result = $mod.IntToStr(aExponent);
      Result = pas.System.StringOfChar("0",ExpSize - Result.length) + Result;
      if (aExponent < 0) {
        Result = "-" + Result}
       else if ((aExponent > 0) && (ASign === "+")) Result = ASign + Result;
      return Result;
    };
    var I = 0;
    var S = 0;
    var C = "\x00";
    var Q = "\x00";
    var PA = [];
    var InLiteral = false;
    PA = rtl.arraySetLength(PA,0,4);
    Result = "";
    InitVars();
    if (E > 0) {
      S = 1}
     else if (E < 0) {
      S = 2}
     else S = 3;
    PA[0] = 0;
    I = GetSections({get: function () {
        return PA;
      }, set: function (v) {
        PA = v;
      }});
    if ((I < S) || ((PA[S] - PA[S - 1]) === 0)) S = 1;
    SectionLength = PA[S] - PA[S - 1] - 1;
    Section = pas.System.Copy(Fmt,PA[S - 1] + 1,SectionLength);
    Section = rtl.strSetLength(Section,SectionLength);
    AnalyzeFormat();
    CalcRunVars();
    if ((SectionLength === 0) || ValueOutSideScope()) {
      Section=E.toPrecision(15);
      Result = Section;
    };
    I = 1;
    Current = 0;
    Q = " ";
    InLiteral = false;
    if (FV.Negative && (S === 1)) ToResult("-");
    while (I <= SectionLength) {
      C = Section.charAt(I - 1);
      if (C.charCodeAt() in rtl.createSet(34,39)) {
        if (InLiteral) {
          InLiteral = C !== Q}
         else {
          InLiteral = true;
          Q = C;
        };
      } else if (InLiteral) {
        ToResult(C)}
       else {
        var $tmp = C;
        if (($tmp === "0") || ($tmp === "#")) {
          CopyDigit()}
         else if (($tmp === ".") || ($tmp === ",")) {}
        else if (($tmp === "e") || ($tmp === "E")) {
          ToResult(C);
          I += 1;
          if (I <= Section.length) {
            C = Section.charAt(I - 1);
            if (C.charCodeAt() in rtl.createSet(43,45)) {
              AddToResult(FormatExponent(C,(FV.Exponent - DecimalPos) + 1));
              while ((I < SectionLength) && (Section.charAt((I + 1) - 1) === "0")) I += 1;
            };
          };
        } else {
          ToResult(C);
        };
      };
      I += 1;
    };
    return Result;
  };
  this.$rtti.$DynArray("FalseBoolStrs$a",{eltype: rtl.string});
  this.TrueBoolStrs = [];
  this.FalseBoolStrs = [];
  this.StrToBool = function (S) {
    var Result = false;
    if (!$mod.TryStrToBool(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidBoolean"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.BoolToStr = function (B, UseBoolStrs) {
    var Result = "";
    if (UseBoolStrs) {
      $impl.CheckBoolStrs();
      if (B) {
        Result = $mod.TrueBoolStrs[0]}
       else Result = $mod.FalseBoolStrs[0];
    } else if (B) {
      Result = "-1"}
     else Result = "0";
    return Result;
  };
  this.BoolToStr$1 = function (B, TrueS, FalseS) {
    var Result = "";
    if (B) {
      Result = TrueS}
     else Result = FalseS;
    return Result;
  };
  this.StrToBoolDef = function (S, Default) {
    var Result = false;
    if (!$mod.TryStrToBool(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = Default;
    return Result;
  };
  this.TryStrToBool = function (S, Value) {
    var Result = false;
    var Temp = "";
    var I = 0;
    var D = 0.0;
    var Code = 0;
    Temp = $mod.UpperCase(S);
    pas.System.val$8(Temp,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return Code;
      }, set: function (v) {
        Code = v;
      }});
    Result = true;
    if (Code === 0) {
      Value.set(D !== 0.0)}
     else {
      $impl.CheckBoolStrs();
      for (var $l = 0, $end = rtl.length($mod.TrueBoolStrs) - 1; $l <= $end; $l++) {
        I = $l;
        if (Temp === $mod.UpperCase($mod.TrueBoolStrs[I])) {
          Value.set(true);
          return Result;
        };
      };
      for (var $l1 = 0, $end1 = rtl.length($mod.FalseBoolStrs) - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        if (Temp === $mod.UpperCase($mod.FalseBoolStrs[I])) {
          Value.set(false);
          return Result;
        };
      };
      Result = false;
    };
    return Result;
  };
  this.ConfigExtension = ".cfg";
  this.SysConfigDir = "";
  this.$rtti.$ProcVar("TOnGetEnvironmentVariable",{procsig: rtl.newTIProcSig([["EnvVar",rtl.string,2]],rtl.string)});
  this.$rtti.$ProcVar("TOnGetEnvironmentString",{procsig: rtl.newTIProcSig([["Index",rtl.longint]],rtl.string)});
  this.$rtti.$ProcVar("TOnGetEnvironmentVariableCount",{procsig: rtl.newTIProcSig([],rtl.longint)});
  this.$rtti.$ProcVar("TShowExceptionHandler",{procsig: rtl.newTIProcSig([["Msg",rtl.string,2]])});
  this.$rtti.$RefToProcVar("TUncaughtPascalExceptionHandler",{procsig: rtl.newTIProcSig([["aObject",pas.System.$rtti["TObject"]]])});
  this.$rtti.$RefToProcVar("TUncaughtJSExceptionHandler",{procsig: rtl.newTIProcSig([["aObject",pas.JS.$rtti["TJSObject"]]])});
  this.OnGetEnvironmentVariable = null;
  this.OnGetEnvironmentString = null;
  this.OnGetEnvironmentVariableCount = null;
  this.OnShowException = null;
  this.SetOnUnCaughtExceptionHandler = function (aValue) {
    var Result = null;
    Result = $impl.OnPascalException;
    $impl.OnPascalException = aValue;
    $mod.HookUncaughtExceptions();
    return Result;
  };
  this.SetOnUnCaughtExceptionHandler$1 = function (aValue) {
    var Result = null;
    Result = $impl.OnJSException;
    $impl.OnJSException = aValue;
    $mod.HookUncaughtExceptions();
    return Result;
  };
  this.HookUncaughtExceptions = function () {
    rtl.onUncaughtException = $impl.RTLExceptionHook;
    rtl.showUncaughtExceptions = true;
  };
  this.GetEnvironmentVariable = function (EnvVar) {
    var Result = "";
    if ($mod.OnGetEnvironmentVariable != null) {
      Result = $mod.OnGetEnvironmentVariable(EnvVar)}
     else Result = "";
    return Result;
  };
  this.GetEnvironmentVariableCount = function () {
    var Result = 0;
    if ($mod.OnGetEnvironmentVariableCount != null) {
      Result = $mod.OnGetEnvironmentVariableCount()}
     else Result = 0;
    return Result;
  };
  this.GetEnvironmentString = function (Index) {
    var Result = "";
    if ($mod.OnGetEnvironmentString != null) {
      Result = $mod.OnGetEnvironmentString(Index)}
     else Result = "";
    return Result;
  };
  this.ShowException = function (ExceptObject, ExceptAddr) {
    var S = "";
    S = rtl.getResStr($mod,"SApplicationException") + ExceptObject.$classname;
    if ($mod.Exception.isPrototypeOf(ExceptObject)) S = S + " : " + ExceptObject.FMessage;
    $impl.DoShowException(S);
    if (ExceptAddr === null) ;
  };
  this.Abort = function () {
    throw $mod.EAbort.$create("Create$1",[rtl.getResStr($mod,"SAbortError")]);
  };
  this.TEventType = {"0": "etCustom", etCustom: 0, "1": "etInfo", etInfo: 1, "2": "etWarning", etWarning: 2, "3": "etError", etError: 3, "4": "etDebug", etDebug: 4};
  this.$rtti.$Enum("TEventType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TEventType});
  this.$rtti.$Set("TEventTypes",{comptype: this.$rtti["TEventType"]});
  rtl.recNewT(this,"TSystemTime",function () {
    this.Year = 0;
    this.Month = 0;
    this.Day = 0;
    this.DayOfWeek = 0;
    this.Hour = 0;
    this.Minute = 0;
    this.Second = 0;
    this.MilliSecond = 0;
    this.$eq = function (b) {
      return (this.Year === b.Year) && (this.Month === b.Month) && (this.Day === b.Day) && (this.DayOfWeek === b.DayOfWeek) && (this.Hour === b.Hour) && (this.Minute === b.Minute) && (this.Second === b.Second) && (this.MilliSecond === b.MilliSecond);
    };
    this.$assign = function (s) {
      this.Year = s.Year;
      this.Month = s.Month;
      this.Day = s.Day;
      this.DayOfWeek = s.DayOfWeek;
      this.Hour = s.Hour;
      this.Minute = s.Minute;
      this.Second = s.Second;
      this.MilliSecond = s.MilliSecond;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSystemTime",{},this);
    $r.addField("Year",rtl.word);
    $r.addField("Month",rtl.word);
    $r.addField("Day",rtl.word);
    $r.addField("DayOfWeek",rtl.word);
    $r.addField("Hour",rtl.word);
    $r.addField("Minute",rtl.word);
    $r.addField("Second",rtl.word);
    $r.addField("MilliSecond",rtl.word);
  });
  rtl.recNewT(this,"TTimeStamp",function () {
    this.Time = 0;
    this.Date = 0;
    this.$eq = function (b) {
      return (this.Time === b.Time) && (this.Date === b.Date);
    };
    this.$assign = function (s) {
      this.Time = s.Time;
      this.Date = s.Date;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTimeStamp",{},this);
    $r.addField("Time",rtl.longint);
    $r.addField("Date",rtl.longint);
  });
  this.TimeSeparator = "\x00";
  this.DateSeparator = "\x00";
  this.ShortDateFormat = "";
  this.LongDateFormat = "";
  this.ShortTimeFormat = "";
  this.LongTimeFormat = "";
  this.DecimalSeparator = "";
  this.ThousandSeparator = "";
  this.TimeAMString = "";
  this.TimePMString = "";
  this.HoursPerDay = 24;
  this.MinsPerHour = 60;
  this.SecsPerMin = 60;
  this.MSecsPerSec = 1000;
  this.MinsPerDay = 24 * 60;
  this.SecsPerHour = 60 * 60;
  this.SecsPerDay = 1440 * 60;
  this.MSecsPerDay = 86400 * 1000;
  this.MaxDateTime = 2958465.99999999;
  this.MinDateTime = -693593.99999999;
  this.JulianEpoch = -2415018.5;
  this.UnixEpoch = -2415018.5 + 2440587.5;
  this.DateDelta = 693594;
  this.UnixDateDelta = 25569;
  this.MonthDays$a$clone = function (a) {
    var b = [];
    b.length = 2;
    for (var c = 0; c < 2; c++) b[c] = a[c].slice(0);
    return b;
  };
  this.$rtti.$StaticArray("MonthDays$a",{dims: [2,12], eltype: rtl.word});
  this.MonthDays = [[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]];
  this.ShortMonthNames = rtl.arraySetLength(null,"",12);
  this.LongMonthNames = rtl.arraySetLength(null,"",12);
  this.ShortDayNames = rtl.arraySetLength(null,"",7);
  this.LongDayNames = rtl.arraySetLength(null,"",7);
  this.FormatSettings = this.TFormatSettings.$new();
  this.TwoDigitYearCenturyWindow = 50;
  this.DateTimeToJSDate = function (aDateTime, asUTC) {
    var Result = null;
    var Y = 0;
    var M = 0;
    var D = 0;
    var h = 0;
    var n = 0;
    var s = 0;
    var z = 0;
    $mod.DecodeDate(pas.System.Trunc(aDateTime),{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    $mod.DecodeTime(pas.System.Frac(aDateTime),{get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},{get: function () {
        return n;
      }, set: function (v) {
        n = v;
      }},{get: function () {
        return s;
      }, set: function (v) {
        s = v;
      }},{get: function () {
        return z;
      }, set: function (v) {
        z = v;
      }});
    if (asUTC) {
      Result = new Date(Date.UTC(Y,M - 1,D,h,n,s,z))}
     else Result = new Date(Y,M - 1,D,h,n,s,z);
    return Result;
  };
  this.JSDateToDateTime = function (aDate) {
    var Result = 0.0;
    Result = $mod.EncodeDate(aDate.getFullYear(),aDate.getMonth() + 1,aDate.getDate()) + $mod.EncodeTime(aDate.getHours(),aDate.getMinutes(),aDate.getSeconds(),aDate.getMilliseconds());
    return Result;
  };
  this.DateTimeToTimeStamp = function (DateTime) {
    var Result = $mod.TTimeStamp.$new();
    var D = 0.0;
    D = DateTime * 86400000;
    if (D < 0) {
      D = D - 0.5}
     else D = D + 0.5;
    Result.Time = pas.System.Trunc(Math.abs(pas.System.Trunc(D)) % 86400000);
    Result.Date = 693594 + rtl.trunc(pas.System.Trunc(D) / 86400000);
    return Result;
  };
  this.TimeStampToDateTime = function (TimeStamp) {
    var Result = 0.0;
    Result = $mod.ComposeDateTime(TimeStamp.Date - 693594,TimeStamp.Time / 86400000);
    return Result;
  };
  this.MSecsToTimeStamp = function (MSecs) {
    var Result = $mod.TTimeStamp.$new();
    Result.Date = pas.System.Trunc(MSecs / 86400000);
    MSecs = MSecs - (Result.Date * 86400000);
    Result.Time = Math.round(MSecs);
    return Result;
  };
  this.TimeStampToMSecs = function (TimeStamp) {
    var Result = 0;
    Result = TimeStamp.Time + (TimeStamp.Date * 86400000);
    return Result;
  };
  this.DateTimeToSystemTime = function (DateTime, SystemTime) {
    $mod.DecodeDateFully(DateTime,{p: SystemTime, get: function () {
        return this.p.Year;
      }, set: function (v) {
        this.p.Year = v;
      }},{p: SystemTime, get: function () {
        return this.p.Month;
      }, set: function (v) {
        this.p.Month = v;
      }},{p: SystemTime, get: function () {
        return this.p.Day;
      }, set: function (v) {
        this.p.Day = v;
      }},{p: SystemTime, get: function () {
        return this.p.DayOfWeek;
      }, set: function (v) {
        this.p.DayOfWeek = v;
      }});
    $mod.DecodeTime(DateTime,{p: SystemTime, get: function () {
        return this.p.Hour;
      }, set: function (v) {
        this.p.Hour = v;
      }},{p: SystemTime, get: function () {
        return this.p.Minute;
      }, set: function (v) {
        this.p.Minute = v;
      }},{p: SystemTime, get: function () {
        return this.p.Second;
      }, set: function (v) {
        this.p.Second = v;
      }},{p: SystemTime, get: function () {
        return this.p.MilliSecond;
      }, set: function (v) {
        this.p.MilliSecond = v;
      }});
    SystemTime.DayOfWeek -= 1;
  };
  this.SystemTimeToDateTime = function (SystemTime) {
    var Result = 0.0;
    Result = $mod.ComposeDateTime($impl.DoEncodeDate(SystemTime.Year,SystemTime.Month,SystemTime.Day),$impl.DoEncodeTime(SystemTime.Hour,SystemTime.Minute,SystemTime.Second,SystemTime.MilliSecond));
    return Result;
  };
  this.FloatToDateTime = function (Value) {
    var Result = 0.0;
    if ((Value < $mod.MinDateTime) || (Value > $mod.MaxDateTime)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidDateTime"),pas.System.VarRecs(18,$mod.FloatToStr(Value))]);
    Result = Value;
    return Result;
  };
  this.TryEncodeDate = function (Year, Month, Day, date) {
    var Result = false;
    var c = 0;
    var ya = 0;
    Result = (Year > 0) && (Year < 10000) && (Month >= 1) && (Month <= 12) && (Day > 0) && (Day <= $mod.MonthDays[+$mod.IsLeapYear(Year)][Month - 1]);
    if (Result) {
      if (Month > 2) {
        Month -= 3}
       else {
        Month += 9;
        Year -= 1;
      };
      c = rtl.trunc(Year / 100);
      ya = Year - (100 * c);
      date.set(((146097 * c) >>> 2) + ((1461 * ya) >>> 2) + rtl.trunc(((153 * Month) + 2) / 5) + Day);
      date.set(date.get() - 693900);
    };
    return Result;
  };
  this.TryEncodeTime = function (Hour, Min, Sec, MSec, Time) {
    var Result = false;
    Result = (Hour < 24) && (Min < 60) && (Sec < 60) && (MSec < 1000);
    if (Result) Time.set(((Hour * 3600000) + (Min * 60000) + (Sec * 1000) + MSec) / 86400000);
    return Result;
  };
  this.EncodeDate = function (Year, Month, Day) {
    var Result = 0.0;
    if (!$mod.TryEncodeDate(Year,Month,Day,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",["%s-%s-%s is not a valid date specification",pas.System.VarRecs(18,$mod.IntToStr(Year),18,$mod.IntToStr(Month),18,$mod.IntToStr(Day))]);
    return Result;
  };
  this.EncodeTime = function (Hour, Minute, Second, MilliSecond) {
    var Result = 0.0;
    if (!$mod.TryEncodeTime(Hour,Minute,Second,MilliSecond,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",["%s:%s:%s.%s is not a valid time specification",pas.System.VarRecs(18,$mod.IntToStr(Hour),18,$mod.IntToStr(Minute),18,$mod.IntToStr(Second),18,$mod.IntToStr(MilliSecond))]);
    return Result;
  };
  this.DecodeDate = function (date, Year, Month, Day) {
    var ly = 0;
    var ld = 0;
    var lm = 0;
    var j = 0;
    if (date <= -693594) {
      Year.set(0);
      Month.set(0);
      Day.set(0);
    } else {
      if (date > 0) {
        date = date + (1 / (86400000 * 2))}
       else date = date - (1 / (86400000 * 2));
      if (date > $mod.MaxDateTime) date = $mod.MaxDateTime;
      j = rtl.shl(pas.System.Trunc(date) + 693900,2) - 1;
      ly = rtl.trunc(j / 146097);
      j = j - (146097 * ly);
      ld = rtl.lw(j >>> 2);
      j = rtl.trunc((rtl.lw(ld << 2) + 3) / 1461);
      ld = rtl.lw(((rtl.lw(ld << 2) + 7) - (1461 * j)) >>> 2);
      lm = rtl.trunc(((5 * ld) - 3) / 153);
      ld = rtl.trunc((((5 * ld) + 2) - (153 * lm)) / 5);
      ly = (100 * ly) + j;
      if (lm < 10) {
        lm += 3}
       else {
        lm -= 9;
        ly += 1;
      };
      Year.set(ly);
      Month.set(lm);
      Day.set(ld);
    };
  };
  this.DecodeTime = function (Time, Hour, Minute, Second, MilliSecond) {
    var l = 0;
    l = $mod.DateTimeToTimeStamp(Time).Time;
    Hour.set(rtl.trunc(l / 3600000));
    l = l % 3600000;
    Minute.set(rtl.trunc(l / 60000));
    l = l % 60000;
    Second.set(rtl.trunc(l / 1000));
    l = l % 1000;
    MilliSecond.set(l);
  };
  this.DecodeDateFully = function (DateTime, Year, Month, Day, DOW) {
    var Result = false;
    $mod.DecodeDate(DateTime,Year,Month,Day);
    DOW.set($mod.DayOfWeek(DateTime));
    Result = $mod.IsLeapYear(Year.get());
    return Result;
  };
  this.ComposeDateTime = function (date, Time) {
    var Result = 0.0;
    if (date < 0) {
      Result = pas.System.Trunc(date) - Math.abs(pas.System.Frac(Time))}
     else Result = pas.System.Trunc(date) + Math.abs(pas.System.Frac(Time));
    return Result;
  };
  this.ReplaceTime = function (dati, NewTime) {
    dati.set($mod.ComposeDateTime(dati.get(),NewTime));
  };
  this.ReplaceDate = function (DateTime, NewDate) {
    var tmp = 0.0;
    tmp = NewDate;
    $mod.ReplaceTime({get: function () {
        return tmp;
      }, set: function (v) {
        tmp = v;
      }},DateTime.get());
    DateTime.set(tmp);
  };
  this.Date = function () {
    var Result = 0.0;
    Result = pas.System.Trunc($mod.Now());
    return Result;
  };
  this.Time = function () {
    var Result = 0.0;
    Result = $mod.Now() - $mod.Date();
    return Result;
  };
  this.Now = function () {
    var Result = 0.0;
    Result = $mod.JSDateToDateTime(new Date());
    return Result;
  };
  this.DayOfWeek = function (DateTime) {
    var Result = 0;
    Result = 1 + ((pas.System.Trunc(DateTime) - 1) % 7);
    if (Result <= 0) Result += 7;
    return Result;
  };
  this.IncMonth = function (DateTime, NumberOfMonths) {
    var Result = 0.0;
    var Year = 0;
    var Month = 0;
    var Day = 0;
    $mod.DecodeDate(DateTime,{get: function () {
        return Year;
      }, set: function (v) {
        Year = v;
      }},{get: function () {
        return Month;
      }, set: function (v) {
        Month = v;
      }},{get: function () {
        return Day;
      }, set: function (v) {
        Day = v;
      }});
    $mod.IncAMonth({get: function () {
        return Year;
      }, set: function (v) {
        Year = v;
      }},{get: function () {
        return Month;
      }, set: function (v) {
        Month = v;
      }},{get: function () {
        return Day;
      }, set: function (v) {
        Day = v;
      }},NumberOfMonths);
    Result = $mod.ComposeDateTime($impl.DoEncodeDate(Year,Month,Day),DateTime);
    return Result;
  };
  this.IncAMonth = function (Year, Month, Day, NumberOfMonths) {
    var TempMonth = 0;
    var S = 0;
    if (NumberOfMonths >= 0) {
      S = 1}
     else S = -1;
    Year.set(Year.get() + rtl.trunc(NumberOfMonths / 12));
    TempMonth = (Month.get() + (NumberOfMonths % 12)) - 1;
    if ((TempMonth > 11) || (TempMonth < 0)) {
      TempMonth -= S * 12;
      Year.set(Year.get() + S);
    };
    Month.set(TempMonth + 1);
    if (Day.get() > $mod.MonthDays[+$mod.IsLeapYear(Year.get())][Month.get() - 1]) Day.set($mod.MonthDays[+$mod.IsLeapYear(Year.get())][Month.get() - 1]);
  };
  this.IsLeapYear = function (Year) {
    var Result = false;
    Result = ((Year % 4) === 0) && (((Year % 100) !== 0) || ((Year % 400) === 0));
    return Result;
  };
  this.CurrentYear = function () {
    var Result = 0;
    Result = (new Date()).getFullYear();
    return Result;
  };
  this.DateTimeToString = function (Result, Format, DateTime) {
    $mod.DateTimeToString$1(Result,Format,DateTime,$mod.FormatSettings);
  };
  this.DateTimeToString$1 = function (Result, Format, DateTime, AFormatSettings) {
    Result.set($mod.FormatDateTime$1(Format,DateTime,AFormatSettings));
  };
  this.DateToStr = function (date) {
    var Result = "";
    Result = $mod.DateToStr$1(date,$mod.FormatSettings);
    return Result;
  };
  this.DateToStr$1 = function (date, aSettings) {
    var Result = "";
    Result = $mod.FormatDateTime$1("ddddd",date,aSettings);
    return Result;
  };
  this.StrToDate = function (S) {
    var Result = 0.0;
    Result = $mod.StrToDate$3(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToDate$1 = function (S, separator) {
    var Result = 0.0;
    Result = $mod.StrToDate$2(S,$mod.FormatSettings.ShortDateFormat,separator);
    return Result;
  };
  this.StrToDate$2 = function (S, useformat, separator) {
    var Result = 0.0;
    var MSg = "";
    Result = $impl.IntStrToDate({get: function () {
        return MSg;
      }, set: function (v) {
        MSg = v;
      }},S,useformat,separator);
    if (MSg !== "") throw $mod.EConvertError.$create("Create$1",[MSg]);
    return Result;
  };
  this.StrToDate$3 = function (S, aSettings) {
    var Result = 0.0;
    Result = $mod.StrToDate$2(S,aSettings.ShortDateFormat,aSettings.DateSeparator);
    return Result;
  };
  this.TryStrToDate = function (S, Value) {
    var Result = false;
    Result = $mod.TryStrToDate$1(S,Value,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToDate$1 = function (S, Value, aSettings) {
    var Result = false;
    Result = $mod.TryStrToDate$3(S,Value,aSettings.ShortDateFormat,aSettings.DateSeparator);
    return Result;
  };
  this.TryStrToDate$2 = function (S, Value, separator) {
    var Result = false;
    Result = $mod.TryStrToDate$3(S,Value,$mod.FormatSettings.ShortDateFormat,separator);
    return Result;
  };
  this.TryStrToDate$3 = function (S, Value, useformat, separator) {
    var Result = false;
    var Msg = "";
    Result = S.length !== 0;
    if (Result) {
      Value.set($impl.IntStrToDate({get: function () {
          return Msg;
        }, set: function (v) {
          Msg = v;
        }},S,useformat,separator));
      Result = Msg === "";
    };
    return Result;
  };
  this.StrToDateDef = function (S, Defvalue) {
    var Result = 0.0;
    Result = $mod.StrToDateDef$1(S,Defvalue,"\x00");
    return Result;
  };
  this.StrToDateDef$1 = function (S, Defvalue, separator) {
    var Result = 0.0;
    if (!$mod.TryStrToDate$2(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},separator)) Result = Defvalue;
    return Result;
  };
  this.StrToDateDef$2 = function (S, Defvalue, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToDate$1(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) Result = Defvalue;
    return Result;
  };
  this.TimeToStr = function (Time) {
    var Result = "";
    Result = $mod.TimeToStr$1(Time,$mod.FormatSettings);
    return Result;
  };
  this.TimeToStr$1 = function (Time, aSettings) {
    var Result = "";
    Result = $mod.FormatDateTime$1("tt",Time,aSettings);
    return Result;
  };
  this.StrToTime = function (S) {
    var Result = 0.0;
    Result = $mod.StrToTime$2(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToTime$1 = function (S, separator) {
    var Result = 0.0;
    var aSettings = $mod.TFormatSettings.$new();
    aSettings.$assign($mod.TFormatSettings.Create());
    aSettings.TimeSeparator = separator;
    Result = $mod.StrToTime$2(S,aSettings);
    return Result;
  };
  this.StrToTime$2 = function (S, aSettings) {
    var Result = 0.0;
    var Msg = "";
    Result = $impl.IntStrToTime({get: function () {
        return Msg;
      }, set: function (v) {
        Msg = v;
      }},S,S.length,aSettings);
    if (Msg !== "") throw $mod.EConvertError.$create("Create$1",[Msg]);
    return Result;
  };
  this.TryStrToTime = function (S, Value) {
    var Result = false;
    Result = $mod.TryStrToTime$1(S,Value,$mod.TFormatSettings.$clone($mod.FormatSettings));
    return Result;
  };
  this.TryStrToTime$1 = function (S, Value, aSettings) {
    var Result = false;
    var Msg = "";
    Result = S.length !== 0;
    if (Result) {
      Value.set($impl.IntStrToTime({get: function () {
          return Msg;
        }, set: function (v) {
          Msg = v;
        }},S,S.length,aSettings));
      Result = Msg === "";
    };
    return Result;
  };
  this.TryStrToTime$2 = function (S, Value, separator) {
    var Result = false;
    var Fmt = $mod.TFormatSettings.$new();
    Fmt.$assign($mod.TFormatSettings.Create());
    Fmt.TimeSeparator = separator;
    Result = $mod.TryStrToTime$1(S,Value,$mod.TFormatSettings.$clone(Fmt));
    return Result;
  };
  this.StrToTimeDef = function (S, Defvalue) {
    var Result = 0.0;
    Result = $mod.StrToTimeDef$1(S,Defvalue,"\x00");
    return Result;
  };
  this.StrToTimeDef$1 = function (S, Defvalue, separator) {
    var Result = 0.0;
    if (!$mod.TryStrToTime$2(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},separator)) Result = Defvalue;
    return Result;
  };
  this.StrToTimeDef$2 = function (AString, ADefault, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToTime$1(AString,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},$mod.TFormatSettings.$clone(aSettings))) Result = ADefault;
    return Result;
  };
  this.DateTimeToStr = function (DateTime, ForceTimeIfZero) {
    var Result = "";
    Result = $mod.DateTimeToStr$1(DateTime,$mod.FormatSettings,ForceTimeIfZero);
    return Result;
  };
  this.DateTimeToStr$1 = function (DateTime, aSettings, ForceTimeIfZero) {
    var Result = "";
    Result = $mod.FormatDateTime$1($impl.DateTimeToStrFormat[+ForceTimeIfZero],DateTime,aSettings);
    return Result;
  };
  this.StrToDateTime = function (S) {
    var Result = 0.0;
    Result = $mod.StrToDateTime$1(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToDateTime$1 = function (s, aSettings) {
    var Result = 0.0;
    var TimeStr = "";
    var DateStr = "";
    var PartsFound = 0;
    PartsFound = $impl.SplitDateTimeStr(s,{get: function () {
        return DateStr;
      }, set: function (v) {
        DateStr = v;
      }},{get: function () {
        return TimeStr;
      }, set: function (v) {
        TimeStr = v;
      }},aSettings);
    var $tmp = PartsFound;
    if ($tmp === 0) {
      Result = $mod.StrToDate("")}
     else if ($tmp === 1) {
      if (DateStr.length > 0) {
        Result = $mod.StrToDate$2(DateStr,aSettings.ShortDateFormat,aSettings.DateSeparator)}
       else Result = $mod.StrToTime(TimeStr)}
     else if ($tmp === 2) Result = $mod.ComposeDateTime($mod.StrToDate$2(DateStr,aSettings.ShortDateFormat,aSettings.DateSeparator),$mod.StrToTime(TimeStr));
    return Result;
  };
  this.TryStrToDateTime = function (S, Value) {
    var Result = false;
    Result = $mod.TryStrToDateTime$1(S,Value,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToDateTime$1 = function (S, Value, aSettings) {
    var Result = false;
    var I = 0;
    var dtdate = 0.0;
    var dttime = 0.0;
    Result = false;
    I = pas.System.Pos(aSettings.TimeSeparator,S);
    if (I > 0) {
      while ((I > 0) && (S.charAt(I - 1) !== " ")) I -= 1;
      if (I > 0) {
        if (!$mod.TryStrToDate$1(pas.System.Copy(S,1,I - 1),{get: function () {
            return dtdate;
          }, set: function (v) {
            dtdate = v;
          }},aSettings)) return Result;
        if (!$mod.TryStrToTime$1(pas.System.Copy(S,I + 1,S.length - I),{get: function () {
            return dttime;
          }, set: function (v) {
            dttime = v;
          }},$mod.TFormatSettings.$clone(aSettings))) return Result;
        Value.set($mod.ComposeDateTime(dtdate,dttime));
        Result = true;
      } else Result = $mod.TryStrToTime$1(S,Value,$mod.TFormatSettings.$clone(aSettings));
    } else Result = $mod.TryStrToDate$1(S,Value,aSettings);
    return Result;
  };
  this.StrToDateTimeDef = function (S, Defvalue) {
    var Result = 0.0;
    Result = $mod.StrToDateTimeDef$1(S,Defvalue,$mod.TFormatSettings.$clone($mod.FormatSettings));
    return Result;
  };
  this.StrToDateTimeDef$1 = function (S, Defvalue, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToDateTime$1(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) Result = Defvalue;
    return Result;
  };
  this.FormatDateTime = function (FormatStr, DateTime) {
    var Result = "";
    Result = $mod.FormatDateTime$1(FormatStr,DateTime,$mod.FormatSettings);
    return Result;
  };
  this.FormatDateTime$1 = function (FormatStr, DateTime, aSettings) {
    var Result = "";
    function StoreStr(FormatStr, APos, Len) {
      Result = Result + pas.System.Copy(FormatStr,APos,Len);
    };
    function StoreString(AStr) {
      Result = Result + AStr;
    };
    function StoreInt(Value, Digits) {
      var S = "";
      S = $mod.IntToStr(Value);
      while (S.length < Digits) S = "0" + S;
      StoreString(S);
    };
    var Year = 0;
    var Month = 0;
    var Day = 0;
    var DayOfWeek = 0;
    var Hour = 0;
    var Minute = 0;
    var Second = 0;
    var MilliSecond = 0;
    function StoreFormat(FormatStr, Nesting, TimeFlag) {
      var Token = "\x00";
      var lastformattoken = "\x00";
      var prevlasttoken = "\x00";
      var Count = 0;
      var Clock12 = false;
      var tmp = 0;
      var isInterval = false;
      var P = 0;
      var FormatCurrent = 0;
      var FormatEnd = 0;
      if (Nesting > 1) return;
      FormatCurrent = 1;
      FormatEnd = FormatStr.length;
      Clock12 = false;
      isInterval = false;
      P = 1;
      while (P <= FormatEnd) {
        Token = FormatStr.charAt(P - 1);
        var $tmp = Token;
        if (($tmp === "'") || ($tmp === '"')) {
          P += 1;
          while ((P < FormatEnd) && (FormatStr.charAt(P - 1) !== Token)) P += 1;
        } else if (($tmp === "A") || ($tmp === "a")) {
          if (($mod.CompareText(pas.System.Copy(FormatStr,P,3),"A/P") === 0) || ($mod.CompareText(pas.System.Copy(FormatStr,P,4),"AMPM") === 0) || ($mod.CompareText(pas.System.Copy(FormatStr,P,5),"AM/PM") === 0)) {
            Clock12 = true;
            break;
          };
        };
        P += 1;
      };
      Token = "ÿ";
      lastformattoken = " ";
      prevlasttoken = "H";
      while (FormatCurrent <= FormatEnd) {
        Token = $mod.UpperCase(FormatStr.charAt(FormatCurrent - 1)).charAt(0);
        Count = 1;
        P = FormatCurrent + 1;
        var $tmp1 = Token;
        if (($tmp1 === "'") || ($tmp1 === '"')) {
          while ((P < FormatEnd) && (FormatStr.charAt(P - 1) !== Token)) P += 1;
          P += 1;
          Count = P - FormatCurrent;
          StoreStr(FormatStr,FormatCurrent + 1,Count - 2);
        } else if ($tmp1 === "A") {
          if ($mod.CompareText(pas.System.Copy(FormatStr,FormatCurrent,4),"AMPM") === 0) {
            Count = 4;
            if (Hour < 12) {
              StoreString(aSettings.TimeAMString)}
             else StoreString(aSettings.TimePMString);
          } else if ($mod.CompareText(pas.System.Copy(FormatStr,FormatCurrent,5),"AM/PM") === 0) {
            Count = 5;
            if (Hour < 12) {
              StoreStr(FormatStr,FormatCurrent,2)}
             else StoreStr(FormatStr,FormatCurrent + 3,2);
          } else if ($mod.CompareText(pas.System.Copy(FormatStr,FormatCurrent,3),"A/P") === 0) {
            Count = 3;
            if (Hour < 12) {
              StoreStr(FormatStr,FormatCurrent,1)}
             else StoreStr(FormatStr,FormatCurrent + 2,1);
          } else throw $mod.EConvertError.$create("Create$1",["Illegal character in format string"]);
        } else if ($tmp1 === "/") {
          StoreString(aSettings.DateSeparator);
        } else if ($tmp1 === ":") {
          StoreString(aSettings.TimeSeparator)}
         else if (($tmp1 === " ") || ($tmp1 === "C") || ($tmp1 === "D") || ($tmp1 === "H") || ($tmp1 === "M") || ($tmp1 === "N") || ($tmp1 === "S") || ($tmp1 === "T") || ($tmp1 === "Y") || ($tmp1 === "Z") || ($tmp1 === "F")) {
          while ((P <= FormatEnd) && ($mod.UpperCase(FormatStr.charAt(P - 1)) === Token)) P += 1;
          Count = P - FormatCurrent;
          var $tmp2 = Token;
          if ($tmp2 === " ") {
            StoreStr(FormatStr,FormatCurrent,Count)}
           else if ($tmp2 === "Y") {
            if (Count > 2) {
              StoreInt(Year,4)}
             else StoreInt(Year % 100,2);
          } else if ($tmp2 === "M") {
            if (isInterval && ((prevlasttoken === "H") || TimeFlag)) {
              StoreInt(Minute + ((Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24)) * 60),0)}
             else if ((lastformattoken === "H") || TimeFlag) {
              if (Count === 1) {
                StoreInt(Minute,0)}
               else StoreInt(Minute,2);
            } else {
              var $tmp3 = Count;
              if ($tmp3 === 1) {
                StoreInt(Month,0)}
               else if ($tmp3 === 2) {
                StoreInt(Month,2)}
               else if ($tmp3 === 3) {
                StoreString(aSettings.ShortMonthNames[Month - 1])}
               else {
                StoreString(aSettings.LongMonthNames[Month - 1]);
              };
            };
          } else if ($tmp2 === "D") {
            var $tmp4 = Count;
            if ($tmp4 === 1) {
              StoreInt(Day,0)}
             else if ($tmp4 === 2) {
              StoreInt(Day,2)}
             else if ($tmp4 === 3) {
              StoreString(aSettings.ShortDayNames[DayOfWeek - 1])}
             else if ($tmp4 === 4) {
              StoreString(aSettings.LongDayNames[DayOfWeek - 1])}
             else if ($tmp4 === 5) {
              StoreFormat(aSettings.ShortDateFormat,Nesting + 1,false)}
             else {
              StoreFormat(aSettings.LongDateFormat,Nesting + 1,false);
            };
          } else if ($tmp2 === "H") {
            if (isInterval) {
              StoreInt(Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24),0)}
             else if (Clock12) {
              tmp = Hour % 12;
              if (tmp === 0) tmp = 12;
              if (Count === 1) {
                StoreInt(tmp,0)}
               else StoreInt(tmp,2);
            } else {
              if (Count === 1) {
                StoreInt(Hour,0)}
               else StoreInt(Hour,2);
            }}
           else if ($tmp2 === "N") {
            if (isInterval) {
              StoreInt(Minute + ((Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24)) * 60),0)}
             else if (Count === 1) {
              StoreInt(Minute,0)}
             else StoreInt(Minute,2)}
           else if ($tmp2 === "S") {
            if (isInterval) {
              StoreInt(Second + ((Minute + ((Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24)) * 60)) * 60),0)}
             else if (Count === 1) {
              StoreInt(Second,0)}
             else StoreInt(Second,2)}
           else if ($tmp2 === "Z") {
            if (Count === 1) {
              StoreInt(MilliSecond,0)}
             else StoreInt(MilliSecond,3)}
           else if ($tmp2 === "T") {
            if (Count === 1) {
              StoreFormat(aSettings.ShortTimeFormat,Nesting + 1,true)}
             else StoreFormat(aSettings.LongTimeFormat,Nesting + 1,true)}
           else if ($tmp2 === "C") {
            StoreFormat(aSettings.ShortDateFormat,Nesting + 1,false);
            if ((Hour !== 0) || (Minute !== 0) || (Second !== 0)) {
              StoreString(" ");
              StoreFormat(aSettings.LongTimeFormat,Nesting + 1,true);
            };
          } else if ($tmp2 === "F") {
            StoreFormat(aSettings.ShortDateFormat,Nesting + 1,false);
            StoreString(" ");
            StoreFormat(aSettings.LongTimeFormat,Nesting + 1,true);
          };
          prevlasttoken = lastformattoken;
          lastformattoken = Token;
        } else {
          StoreString(Token);
        };
        FormatCurrent += Count;
      };
    };
    $mod.DecodeDateFully(DateTime,{get: function () {
        return Year;
      }, set: function (v) {
        Year = v;
      }},{get: function () {
        return Month;
      }, set: function (v) {
        Month = v;
      }},{get: function () {
        return Day;
      }, set: function (v) {
        Day = v;
      }},{get: function () {
        return DayOfWeek;
      }, set: function (v) {
        DayOfWeek = v;
      }});
    $mod.DecodeTime(DateTime,{get: function () {
        return Hour;
      }, set: function (v) {
        Hour = v;
      }},{get: function () {
        return Minute;
      }, set: function (v) {
        Minute = v;
      }},{get: function () {
        return Second;
      }, set: function (v) {
        Second = v;
      }},{get: function () {
        return MilliSecond;
      }, set: function (v) {
        MilliSecond = v;
      }});
    if (FormatStr !== "") {
      StoreFormat(FormatStr,0,false)}
     else StoreFormat("C",0,false);
    return Result;
  };
  this.CurrencyFormat = 0;
  this.NegCurrFormat = 0;
  this.CurrencyDecimals = 0;
  this.CurrencyString = "";
  this.FloattoCurr = function (Value) {
    var Result = 0;
    if (!$mod.TryFloatToCurr(Value,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidCurrency"),pas.System.VarRecs(18,$mod.FloatToStr(Value))]);
    return Result;
  };
  this.TryFloatToCurr = function (Value, AResult) {
    var Result = false;
    Result = ((Value * 10000) >= $mod.MinCurrency) && ((Value * 10000) <= $mod.MaxCurrency);
    if (Result) AResult.set(rtl.trunc(Value * 10000));
    return Result;
  };
  this.TryFloatToDateTime = function (Value, AResult) {
    var Result = false;
    Result = !((Value < $mod.MinDateTime) || (Value >= (pas.System.Int($mod.MaxDateTime) + 1.0)));
    if (Result) AResult.set(Value);
    return Result;
  };
  this.CurrToStr = function (Value) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value / 10000,$mod.TFloatFormat.ffGeneral,-1,0,$mod.FormatSettings);
    return Result;
  };
  this.CurrToStr$1 = function (Value, aSettings) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value / 10000,$mod.TFloatFormat.ffGeneral,-1,0,aSettings);
    return Result;
  };
  this.StrToCurr = function (S) {
    var Result = 0;
    if (!$mod.TryStrToCurr(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidCurrency"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.StrToCurr$1 = function (S, aSettings) {
    var Result = 0;
    if (!$mod.TryStrToCurr$1(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidCurrency"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.TryStrToCurr = function (S, Value) {
    var Result = false;
    var D = 0.0;
    Result = $mod.TryStrToFloat$3(S,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},$mod.FormatSettings);
    if (Result) Value.set(rtl.trunc(D * 10000));
    return Result;
  };
  this.TryStrToCurr$1 = function (S, Value, aSettings) {
    var Result = false;
    var D = 0.0;
    Result = $mod.TryStrToFloat$3(S,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},aSettings);
    if (Result) Value.set(rtl.trunc(D * 10000));
    return Result;
  };
  this.StrToCurrDef = function (S, Default) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToCurr$1(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }},$mod.FormatSettings)) {
      Result = R}
     else Result = Default;
    return Result;
  };
  this.StrToCurrDef$1 = function (S, Default, aSettings) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToCurr$1(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }},aSettings)) {
      Result = R}
     else Result = Default;
    return Result;
  };
  this.$rtti.$DynArray("TPathStrArray",{eltype: rtl.string});
  this.ChangeFileExt = function (FileName, Extension) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    var SOF = false;
    i = FileName.length;
    EndSep = rtl.unionSet(rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators),rtl.createSet(pas.System.ExtensionSeparator.charCodeAt()));
    while ((i > 0) && !(FileName.charCodeAt(i - 1) in EndSep)) i -= 1;
    if ((i === 0) || (FileName.charAt(i - 1) !== pas.System.ExtensionSeparator)) {
      i = FileName.length + 1}
     else {
      SOF = (i === 1) || (FileName.charCodeAt(i - 1 - 1) in pas.System.AllowDirectorySeparators);
      if (SOF && !pas.System.FirstDotAtFileNameStartIsExtension) i = FileName.length + 1;
    };
    Result = pas.System.Copy(FileName,1,i - 1) + Extension;
    return Result;
  };
  this.ExtractFilePath = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    i = FileName.length;
    EndSep = rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators);
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    if (i > 0) {
      Result = pas.System.Copy(FileName,1,i)}
     else Result = "";
    return Result;
  };
  this.ExtractFileDrive = function (FileName) {
    var Result = "";
    var i = 0;
    var l = 0;
    Result = "";
    l = FileName.length;
    if (l < 2) return Result;
    if ($mod.CharInSet$1(FileName.charAt(1),pas.System.AllowDriveSeparators)) {
      Result = pas.System.Copy(FileName,1,2)}
     else if ($mod.CharInSet$1(FileName.charAt(0),pas.System.AllowDirectorySeparators) && $mod.CharInSet$1(FileName.charAt(1),pas.System.AllowDirectorySeparators)) {
      i = 2;
      while ((i < l) && !$mod.CharInSet$1(FileName.charAt((i + 1) - 1),pas.System.AllowDirectorySeparators)) i += 1;
      i += 1;
      while ((i < l) && !$mod.CharInSet$1(FileName.charAt((i + 1) - 1),pas.System.AllowDirectorySeparators)) i += 1;
      Result = pas.System.Copy(FileName,1,i);
    };
    return Result;
  };
  this.ExtractFileName = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    i = FileName.length;
    EndSep = rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators);
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    Result = pas.System.Copy(FileName,i + 1,2147483647);
    return Result;
  };
  this.ExtractFileExt = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    var SOF = false;
    Result = "";
    i = FileName.length;
    EndSep = rtl.unionSet(rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators),rtl.createSet(pas.System.ExtensionSeparator.charCodeAt()));
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    if ((i > 0) && (FileName.charAt(i - 1) === pas.System.ExtensionSeparator)) {
      SOF = (i === 1) || (FileName.charCodeAt(i - 1 - 1) in pas.System.AllowDirectorySeparators);
      if (!SOF || pas.System.FirstDotAtFileNameStartIsExtension) Result = pas.System.Copy(FileName,i,2147483647);
    } else Result = "";
    return Result;
  };
  this.ExtractFileDir = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    i = FileName.length;
    EndSep = rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators);
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    if ((i > 1) && $mod.CharInSet$1(FileName.charAt(i - 1),pas.System.AllowDirectorySeparators) && !$mod.CharInSet$1(FileName.charAt(i - 1 - 1),EndSep)) i -= 1;
    Result = pas.System.Copy(FileName,1,i);
    return Result;
  };
  this.ExtractRelativepath = function (BaseName, DestName) {
    var Result = "";
    var OneLevelBack = "";
    var Source = "";
    var Dest = "";
    var Sc = 0;
    var Dc = 0;
    var I = 0;
    var J = 0;
    var SD = [];
    var DD = [];
    OneLevelBack = ".." + pas.System.PathDelim;
    if ($mod.UpperCase($mod.ExtractFileDrive(BaseName)) !== $mod.UpperCase($mod.ExtractFileDrive(DestName))) {
      Result = DestName;
      return Result;
    };
    Source = $mod.ExcludeTrailingPathDelimiter($mod.ExtractFilePath(BaseName));
    Dest = $mod.ExcludeTrailingPathDelimiter($mod.ExtractFilePath(DestName));
    SD = $mod.GetDirs(Source);
    Sc = rtl.length(SD);
    DD = $mod.GetDirs(Dest);
    Dc = rtl.length(SD);
    I = 0;
    while ((I < Dc) && (I < Sc)) {
      if ($mod.SameText(DD[I],SD[I])) {
        I += 1}
       else break;
    };
    Result = "";
    for (var $l = I, $end = Sc; $l <= $end; $l++) {
      J = $l;
      Result = Result + OneLevelBack;
    };
    for (var $l1 = I, $end1 = Dc; $l1 <= $end1; $l1++) {
      J = $l1;
      Result = Result + DD[J] + pas.System.PathDelim;
    };
    Result = Result + $mod.ExtractFileName(DestName);
    return Result;
  };
  this.IncludeTrailingPathDelimiter = function (Path) {
    var Result = "";
    var l = 0;
    Result = Path;
    l = Result.length;
    if ((l === 0) || !$mod.CharInSet$1(Result.charAt(l - 1),pas.System.AllowDirectorySeparators)) Result = Result + pas.System.PathDelim;
    return Result;
  };
  this.ExcludeTrailingPathDelimiter = function (Path) {
    var Result = "";
    var L = 0;
    L = Path.length;
    if ((L > 0) && $mod.CharInSet$1(Path.charAt(L - 1),pas.System.AllowDirectorySeparators)) L -= 1;
    Result = pas.System.Copy(Path,1,L);
    return Result;
  };
  this.IncludeLeadingPathDelimiter = function (Path) {
    var Result = "";
    var l = 0;
    Result = Path;
    l = Result.length;
    if ((l === 0) || !$mod.CharInSet$1(Result.charAt(0),pas.System.AllowDirectorySeparators)) Result = pas.System.PathDelim + Result;
    return Result;
  };
  this.ExcludeLeadingPathDelimiter = function (Path) {
    var Result = "";
    var L = 0;
    Result = Path;
    L = Result.length;
    if ((L > 0) && $mod.CharInSet$1(Result.charAt(0),pas.System.AllowDirectorySeparators)) pas.System.Delete({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},1,1);
    return Result;
  };
  this.IsPathDelimiter = function (Path, Index) {
    var Result = false;
    Result = (Index > 0) && (Index <= Path.length) && $mod.CharInSet$1(Path.charAt(Index - 1),pas.System.AllowDirectorySeparators);
    return Result;
  };
  this.SetDirSeparators = function (FileName) {
    var Result = "";
    var I = 0;
    Result = FileName;
    for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
      I = $l;
      if ($mod.CharInSet$1(Result.charAt(I - 1),pas.System.AllowDirectorySeparators)) Result = rtl.setCharAt(Result,I - 1,pas.System.PathDelim);
    };
    return Result;
  };
  this.GetDirs = function (DirName) {
    var Result = [];
    var I = 0;
    var J = 0;
    var L = 0;
    var D = "";
    I = 1;
    J = 0;
    L = 0;
    Result = rtl.arraySetLength(Result,"",DirName.length);
    while (I <= DirName.length) {
      if ($mod.CharInSet$1(DirName.charAt(I - 1),pas.System.AllowDirectorySeparators)) {
        D = pas.System.Copy(DirName,J + 1,J - I);
        if (D !== "") {
          Result[L] = D;
          L += 1;
        };
        J = I;
      };
      I += 1;
    };
    Result = rtl.arraySetLength(Result,"",L);
    return Result;
  };
  this.ConcatPaths = function (Paths) {
    var Result = "";
    var I = 0;
    if (rtl.length(Paths) > 0) {
      Result = Paths[0];
      for (var $l = 1, $end = rtl.length(Paths) - 1; $l <= $end; $l++) {
        I = $l;
        Result = $mod.IncludeTrailingPathDelimiter(Result) + $mod.ExcludeLeadingPathDelimiter(Paths[I]);
      };
    } else Result = "";
    return Result;
  };
  this.GUID_NULL = pas.System.TGuid.$clone({D1: 0x00000000, D2: 0x0000, D3: 0x0000, D4: [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]});
  this.Supports = function (Instance, AClass, Obj) {
    var Result = false;
    Result = (Instance !== null) && (Instance.QueryInterface(pas.System.IObjectInstance,Obj) === 0) && Obj.get().$class.InheritsFrom(AClass);
    return Result;
  };
  this.Supports$1 = function (Instance, IID, Intf) {
    var Result = false;
    Result = (Instance !== null) && (Instance.QueryInterface(IID,Intf) === 0);
    return Result;
  };
  this.Supports$2 = function (Instance, IID, Intf) {
    var Result = false;
    Result = (Instance !== null) && Instance.GetInterface(IID,Intf);
    return Result;
  };
  this.Supports$3 = function (Instance, IID, Intf) {
    var Result = false;
    Result = (Instance !== null) && Instance.GetInterfaceByStr(IID,Intf);
    return Result;
  };
  this.Supports$4 = function (Instance, AClass) {
    var Result = false;
    var Temp = null;
    Result = $mod.Supports(Instance,AClass,{get: function () {
        return Temp;
      }, set: function (v) {
        Temp = v;
      }});
    return Result;
  };
  this.Supports$5 = function (Instance, IID) {
    var Result = false;
    var Temp = null;
    try {
      Result = $mod.Supports$1(Instance,IID,{get: function () {
          return Temp;
        }, set: function (v) {
          Temp = v;
        }});
    } finally {
      rtl._Release(Temp);
    };
    return Result;
  };
  this.Supports$6 = function (Instance, IID) {
    var Result = false;
    var Temp = null;
    Result = $mod.Supports$2(Instance,IID,{get: function () {
        return Temp;
      }, set: function (v) {
        Temp = v;
      }});
    if (Temp && Temp.$kind==='com') Temp._Release();
    return Result;
  };
  this.Supports$7 = function (Instance, IID) {
    var Result = false;
    var Temp = null;
    Result = $mod.Supports$3(Instance,IID,{get: function () {
        return Temp;
      }, set: function (v) {
        Temp = v;
      }});
    if (Temp && Temp.$kind==='com') Temp._Release();
    return Result;
  };
  this.Supports$8 = function (AClass, IID) {
    var Result = false;
    var maps = undefined;
    if (AClass === null) return false;
    maps = AClass["$intfmaps"];
    if (!maps) return false;
    if (maps[$mod.GUIDToString(IID)]) return true;
    Result = false;
    return Result;
  };
  this.Supports$9 = function (AClass, IID) {
    var Result = false;
    var maps = undefined;
    if (AClass === null) return false;
    maps = AClass["$intfmaps"];
    if (!maps) return false;
    if (maps[$mod.UpperCase(IID)]) return true;
    Result = false;
    return Result;
  };
  this.TryStringToGUID = function (s, Guid) {
    var Result = false;
    var re = null;
    if (s.length !== 38) return false;
    re = new RegExp("^\\{[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\}$");
    Result = re.test(s);
    if (!Result) {
      Guid.D1 = 0;
      return Result;
    };
    rtl.strToGUIDR(s,Guid);
    Result = true;
    return Result;
  };
  this.StringToGUID = function (S) {
    var Result = pas.System.TGuid.$new();
    if (!$mod.TryStringToGUID(S,Result)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidGUID"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.GUIDToString = function (guid) {
    var Result = "";
    Result = rtl.guidrToStr(guid);
    return Result;
  };
  this.IsEqualGUID = function (guid1, guid2) {
    var Result = false;
    var i = 0;
    if ((guid1.D1 !== guid2.D1) || (guid1.D2 !== guid2.D2) || (guid1.D3 !== guid2.D3)) return false;
    for (i = 0; i <= 7; i++) if (guid1.D4[i] !== guid2.D4[i]) return false;
    Result = true;
    return Result;
  };
  this.GuidCase = function (guid, List) {
    var Result = 0;
    for (var $l = rtl.length(List) - 1; $l >= 0; $l--) {
      Result = $l;
      if ($mod.IsEqualGUID(guid,List[Result])) return Result;
    };
    Result = -1;
    return Result;
  };
  this.CreateGUID = function (GUID) {
    var Result = 0;
    function R(B) {
      var Result = 0;
      var v = 0;
      v = pas.System.Random(256);
      while (B > 1) {
        v = (v * 256) + pas.System.Random(256);
        B -= 1;
      };
      Result = v;
      return Result;
    };
    var I = 0;
    Result = 0;
    GUID.D1 = R(4);
    GUID.D2 = R(2);
    GUID.D3 = R(2);
    for (I = 0; I <= 7; I++) GUID.D4[I] = R(1);
    return Result;
  };
  this.EncodeHTMLEntities = function (S) {
    var Result = "";
    Result = "";
    if (S === "") return Result;
    return S.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
      return '&#'+i.charCodeAt(0)+';';
    });
    return Result;
  };
  this.$rtti.$DynArray("TCharArray",{eltype: rtl.char});
  this.$rtti.$Int("TByteBitIndex",{minvalue: 0, maxvalue: 7, ordtype: 1});
  this.$rtti.$Int("TShortIntBitIndex",{minvalue: 0, maxvalue: 7, ordtype: 1});
  this.$rtti.$Int("TWordBitIndex",{minvalue: 0, maxvalue: 15, ordtype: 1});
  this.$rtti.$Int("TSmallIntBitIndex",{minvalue: 0, maxvalue: 15, ordtype: 1});
  this.$rtti.$Int("TCardinalBitIndex",{minvalue: 0, maxvalue: 31, ordtype: 1});
  this.$rtti.$Int("TIntegerBitIndex",{minvalue: 0, maxvalue: 31, ordtype: 1});
  this.$rtti.$Int("TQwordBitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.$rtti.$Int("TInt64BitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.$rtti.$Int("TNativeIntBitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.$rtti.$Int("TNativeUIntBitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.CPUEndian = this.TEndian.Big;
  rtl.createHelper(this,"TGuidHelper",null,function () {
    this.Create = function (Src, BigEndian) {
      var Result = pas.System.TGuid.$new();
      Result.$assign(Src);
      if (!BigEndian) {
        Result.D1 = $mod.SwapEndian$1(Result.D1);
        Result.D2 = $mod.SwapEndian(Result.D2);
        Result.D3 = $mod.SwapEndian(Result.D3);
      };
      return Result;
    };
    this.Create$1 = function (Buf, AStartIndex, BigEndian) {
      var Result = pas.System.TGuid.$new();
      var A = 0;
      var B = 0;
      var C = 0;
      var V = null;
      V = new DataView(Buf);
      if (BigEndian) {
        A = V.getUint32(AStartIndex);
        B = V.getUint16(AStartIndex + 4);
        C = V.getUint16(AStartIndex + 6);
      } else {
        A = $mod.SwapEndian$1(V.getUint32(AStartIndex));
        B = $mod.SwapEndian(V.getUint16(AStartIndex + 4));
        C = $mod.SwapEndian(V.getUint16(AStartIndex + 6));
      };
      Result.$assign($mod.TGuidHelper.Create$7(A,B,C,V.getUint8(AStartIndex + 8),V.getUint8(AStartIndex + 9),V.getUint8(AStartIndex + 10),V.getUint8(AStartIndex + 11),V.getUint8(AStartIndex + 12),V.getUint8(AStartIndex + 13),V.getUint8(AStartIndex + 14),V.getUint8(AStartIndex + 15)));
      return Result;
    };
    this.Create$2 = function (Data, AStartIndex, BigEndian) {
      var Result = pas.System.TGuid.$new();
      var D = null;
      if ((rtl.length(Data) - AStartIndex) < 16) throw $mod.EArgumentException.$create("CreateFmt",["The length of a GUID array must be at least %d",[]]);
      D = Uint8Array.from(Data);
      Result.$assign($mod.TGuidHelper.Create$1(D.buffer,AStartIndex,BigEndian));
      return Result;
    };
    this.Create$3 = function (B, DataEndian) {
      var Result = pas.System.TGuid.$new();
      Result.$assign($mod.TGuidHelper.Create$4(B,0,DataEndian));
      return Result;
    };
    this.Create$4 = function (B, AStartIndex, DataEndian) {
      var Result = pas.System.TGuid.$new();
      if ((rtl.length(B) - AStartIndex) < 16) throw $mod.EArgumentException.$create("CreateFmt",["The length of a GUID array must be at least %d",[]]);
      Result.$assign($mod.TGuidHelper.Create$2(B,AStartIndex,DataEndian === $mod.TEndian.Big));
      return Result;
    };
    this.Create$5 = function (S) {
      var Result = pas.System.TGuid.$new();
      Result.$assign($mod.StringToGUID(S));
      return Result;
    };
    this.Create$6 = function (A, B, C, D) {
      var Result = pas.System.TGuid.$new();
      if (rtl.length(D) !== 8) throw $mod.EArgumentException.$create("CreateFmt",["The length of a GUID array must be %d",[]]);
      Result.$assign($mod.TGuidHelper.Create$7(A >>> 0,B & 65535,C & 65535,D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7]));
      return Result;
    };
    this.Create$7 = function (A, B, C, D, E, F, G, H, I, J, K) {
      var Result = pas.System.TGuid.$new();
      Result.D1 = A;
      Result.D2 = B;
      Result.D3 = C;
      Result.D4[0] = D;
      Result.D4[1] = E;
      Result.D4[2] = F;
      Result.D4[3] = G;
      Result.D4[4] = H;
      Result.D4[5] = I;
      Result.D4[6] = J;
      Result.D4[7] = K;
      return Result;
    };
    this.NewGuid = function () {
      var Result = pas.System.TGuid.$new();
      $mod.CreateGUID(Result);
      return Result;
    };
    this.Empty = function () {
      var Result = pas.System.TGuid.$new();
      Result.$assign(pas.System.TGuid.$new());
      return Result;
    };
    this.IsEmpty = function () {
      var Result = false;
      var lCount = 0;
      Result = (this.D1 === 0) && (this.D2 === 0) && (this.D3 === 0);
      if (!Result) return Result;
      for (lCount = 0; lCount <= 7; lCount++) Result = Result && (this.D4[lCount] === 0);
      return Result;
    };
    this.ToByteArray = function (DataEndian) {
      var Result = [];
      var D = null;
      var V = null;
      var I = 0;
      D = new Uint8Array(16);
      V = new DataView(D.buffer);
      V.setUint32(0,this.D1,DataEndian === $mod.TEndian.Little);
      V.setUint16(4,this.D2,DataEndian === $mod.TEndian.Little);
      V.setUint16(6,this.D3,DataEndian === $mod.TEndian.Little);
      for (I = 0; I <= 7; I++) V.setUint8(8 + I,this.D4[I]);
      Result = rtl.arraySetLength(Result,0,16);
      for (I = 0; I <= 15; I++) Result[I] = V.getUint8(I);
      return Result;
    };
    this.ToString = function (SkipBrackets) {
      var Result = "";
      Result = $mod.GUIDToString(this);
      if (SkipBrackets) Result = pas.System.Copy(Result,2,Result.length - 2);
      return Result;
    };
  });
  this.TStringSplitOptions = {"0": "None", None: 0, "1": "ExcludeEmpty", ExcludeEmpty: 1};
  this.$rtti.$Enum("TStringSplitOptions",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TStringSplitOptions});
  rtl.createHelper(this,"TStringHelper",null,function () {
    this.Empty = "";
    this.GetChar = function (AIndex) {
      var Result = "\x00";
      Result = this.get().charAt((AIndex + 1) - 1);
      return Result;
    };
    this.GetLength = function () {
      var Result = 0;
      Result = this.get().length;
      return Result;
    };
    this.Set_Length = function (AValue) {
      this.set(rtl.strSetLength(this.get(),AValue));
    };
    this.Compare = function (A, B) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare$5(A,0,B,0,B.length,{});
      return Result;
    };
    this.Compare$1 = function (A, B, IgnoreCase) {
      var Result = 0;
      if (IgnoreCase) {
        Result = $mod.TStringHelper.Compare$2(A,B,rtl.createSet(pas.System.TCompareOption.coIgnoreCase))}
       else Result = $mod.TStringHelper.Compare$2(A,B,{});
      return Result;
    };
    this.Compare$2 = function (A, B, Options) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare$5(A,0,B,0,B.length,rtl.refSet(Options));
      return Result;
    };
    this.Compare$3 = function (A, IndexA, B, IndexB, ALen) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare$5(A,IndexA,B,IndexB,ALen,{});
      return Result;
    };
    this.Compare$4 = function (A, IndexA, B, IndexB, ALen, IgnoreCase) {
      var Result = 0;
      if (IgnoreCase) {
        Result = $mod.TStringHelper.Compare$5(A,IndexA,B,IndexB,ALen,rtl.createSet(pas.System.TCompareOption.coIgnoreCase))}
       else Result = $mod.TStringHelper.Compare$5(A,IndexA,B,IndexB,ALen,{});
      return Result;
    };
    this.Compare$5 = function (A, IndexA, B, IndexB, ALen, Options) {
      var Result = 0;
      var AL = "";
      var BL = "";
      var lOptions = pas.JS.TLocaleCompareOptions.$new();
      AL = pas.System.Copy(A,IndexA + 1,ALen);
      BL = pas.System.Copy(B,IndexB + 1,ALen);
      if (pas.System.TCompareOption.coDigitAsNumbers in Options) lOptions.numeric = true;
      if (pas.System.TCompareOption.coIgnoreCase in Options) {
        Result = $mod.TStringHelper.UpperCase(AL).localeCompare($mod.TStringHelper.UpperCase(BL),"default",pas.JS.TLocaleCompareOptions.$clone(lOptions))}
       else Result = AL.localeCompare(BL,"default",pas.JS.TLocaleCompareOptions.$clone(lOptions));
      return Result;
    };
    this.CompareOrdinal = function (A, B) {
      var Result = 0;
      var L = 0;
      L = B.length;
      if (L > A.length) L = A.length;
      Result = $mod.TStringHelper.CompareOrdinal$1(A,0,B,0,L);
      return Result;
    };
    this.CompareOrdinal$1 = function (A, IndexA, B, IndexB, ALen) {
      var Result = 0;
      var I = 0;
      var M = 0;
      M = A.length - IndexA;
      if (M > (B.length - IndexB)) M = B.length - IndexB;
      if (M > ALen) M = ALen;
      I = 0;
      Result = 0;
      while ((Result === 0) && (I < M)) {
        Result = A.charCodeAt(IndexA + I) - B.charCodeAt(IndexB + I);
        I += 1;
      };
      return Result;
    };
    this.CompareText = function (A, B) {
      var Result = 0;
      Result = $mod.CompareText(A,B);
      return Result;
    };
    this.Copy = function (Str) {
      var Result = "";
      Result = Str;
      return Result;
    };
    this.Create = function (AChar, ACount) {
      var Result = "";
      Result = pas.System.StringOfChar(AChar,ACount);
      return Result;
    };
    this.Create$1 = function (AValue) {
      var Result = "";
      Result = $mod.TStringHelper.Create$2(AValue,0,rtl.length(AValue));
      return Result;
    };
    this.Create$2 = function (AValue, StartIndex, ALen) {
      var Result = "";
      var I = 0;
      Result = rtl.strSetLength(Result,ALen);
      for (var $l = 1, $end = ALen; $l <= $end; $l++) {
        I = $l;
        Result = rtl.setCharAt(Result,I - 1,AValue[(StartIndex + I) - 1]);
      };
      return Result;
    };
    this.EndsText = function (ASubText, AText) {
      var Result = false;
      Result = (ASubText !== "") && ($mod.CompareText(pas.System.Copy(AText,(AText.length - ASubText.length) + 1,ASubText.length),ASubText) === 0);
      return Result;
    };
    this.Equals = function (a, b) {
      var Result = false;
      Result = a === b;
      return Result;
    };
    this.Format = function (AFormat, args) {
      var Result = "";
      Result = $mod.Format(AFormat,args);
      return Result;
    };
    this.IsNullOrEmpty = function (AValue) {
      var Result = false;
      Result = AValue.length === 0;
      return Result;
    };
    this.IsNullOrWhiteSpace = function (AValue) {
      var Result = false;
      Result = $mod.Trim(AValue).length === 0;
      return Result;
    };
    this.Join = function (Separator, Values) {
      var Result = "";
      Result = Values.join(Separator);
      return Result;
    };
    this.Join$1 = function (Separator, Values) {
      var Result = "";
      Result = Values.join(Separator);
      return Result;
    };
    this.Join$2 = function (Separator, Values, StartIndex, ACount) {
      var Result = "";
      var VLen = 0;
      VLen = rtl.length(Values) - 1;
      if ((ACount < 0) || ((StartIndex > 0) && (StartIndex > VLen))) throw $mod.ERangeError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SRangeError")]);
      if ((ACount === 0) || (VLen < 0)) {
        Result = ""}
       else Result = Values.slice(StartIndex,StartIndex + ACount).join(Separator);
      return Result;
    };
    this.LowerCase = function (S) {
      var Result = "";
      Result = $mod.LowerCase(S);
      return Result;
    };
    this.Parse = function (AValue) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,false);
      return Result;
    };
    this.Parse$1 = function (AValue) {
      var Result = "";
      Result = $mod.FloatToStr(AValue);
      return Result;
    };
    this.Parse$2 = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.Parse$3 = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.ToBoolean = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.ToDouble = function (S) {
      var Result = 0.0;
      Result = $mod.StrToFloat(S);
      return Result;
    };
    this.ToExtended = function (S) {
      var Result = 0.0;
      Result = $mod.StrToFloat(S);
      return Result;
    };
    this.ToNativeInt = function (S) {
      var Result = 0;
      Result = $mod.StrToInt64(S);
      return Result;
    };
    this.ToInteger = function (S) {
      var Result = 0;
      Result = $mod.StrToInt(S);
      return Result;
    };
    this.UpperCase = function (S) {
      var Result = "";
      Result = $mod.UpperCase(S);
      return Result;
    };
    this.ToCharArray = function (S) {
      var Result = [];
      var I = 0;
      var Len = 0;
      Len = S.length;
      Result = rtl.arraySetLength(Result,"\x00",Len);
      for (var $l = 1, $end = Len; $l <= $end; $l++) {
        I = $l;
        Result[I - 1] = S.charAt(I - 1);
      };
      return Result;
    };
    this.CompareTo = function (B) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare(this.get(),B);
      return Result;
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = (AValue !== "") && (pas.System.Pos(AValue,this.get()) > 0);
      return Result;
    };
    this.CountChar = function (C) {
      var Result = 0;
      var S = "\x00";
      Result = 0;
      for (var $in = this.get(), $l = 0, $end = $in.length - 1; $l <= $end; $l++) {
        S = $in.charAt($l);
        if (S === C) Result += 1;
      };
      return Result;
    };
    this.DeQuotedString = function () {
      var Result = "";
      Result = $mod.TStringHelper.DeQuotedString$1.call(this,"'");
      return Result;
    };
    this.DeQuotedString$1 = function (AQuoteChar) {
      var Result = "";
      var L = 0;
      var I = 0;
      var Res = [];
      var PS = 0;
      var PD = 0;
      var IsQuote = false;
      L = this.get().length;
      if ((L < 2) || !((this.get().charAt(0) === AQuoteChar) && (this.get().charAt(L - 1) === AQuoteChar))) return this.get();
      Res = rtl.arraySetLength(Res,"\x00",L);
      IsQuote = false;
      PS = 2;
      PD = 1;
      for (var $l = 2, $end = L - 1; $l <= $end; $l++) {
        I = $l;
        if (this.get().charAt(PS - 1) === AQuoteChar) {
          IsQuote = !IsQuote;
          if (!IsQuote) {
            Result = rtl.setCharAt(Result,PD - 1,this.get().charAt(PS - 1));
            PD += 1;
          };
        } else {
          if (IsQuote) IsQuote = false;
          Result = rtl.setCharAt(Result,PD - 1,this.get().charAt(PS - 1));
          PD += 1;
        };
        PS += 1;
      };
      Result = rtl.strSetLength(Result,PD - 1);
      return Result;
    };
    this.EndsWith = function (AValue) {
      var Result = false;
      Result = $mod.TStringHelper.EndsWith$1.call(this,AValue,false);
      return Result;
    };
    this.EndsWith$1 = function (AValue, IgnoreCase) {
      var Result = false;
      var L = 0;
      var S = "";
      L = AValue.length;
      Result = L === 0;
      if (!Result) {
        S = pas.System.Copy(this.get(),($mod.TStringHelper.GetLength.call(this) - L) + 1,L);
        Result = S.length === L;
        if (Result) if (IgnoreCase) {
          Result = $mod.TStringHelper.CompareText(S,AValue) === 0}
         else Result = S === AValue;
      };
      return Result;
    };
    this.Equals$1 = function (AValue) {
      var Result = false;
      Result = this.get() === AValue;
      return Result;
    };
    this.Format$1 = function (args) {
      var Result = "";
      Result = $mod.Format(this.get(),args);
      return Result;
    };
    this.GetHashCode = function () {
      var Result = 0;
      var P = 0;
      var pmax = 0;
      var L = null;
      L = this.get();
      Result = 0;
      P = 1;
      pmax = $mod.TStringHelper.GetLength.call(this) + 1;
      while (P < pmax) {
        Result = rtl.xor(((Result << 5) - Result) >>> 0,L.charCodeAt(P));
        P += 1;
      };
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$4.call(this,AValue,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$1 = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$5.call(this,AValue,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$2 = function (AValue, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$4.call(this,AValue,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$3 = function (AValue, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$5.call(this,AValue,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$4 = function (AValue, StartIndex, ACount) {
      var Result = 0;
      var S = "";
      S = pas.System.Copy(this.get(),StartIndex + 1,ACount);
      Result = pas.System.Pos(AValue,S) - 1;
      if (Result !== -1) Result = Result + StartIndex;
      return Result;
    };
    this.IndexOf$5 = function (AValue, StartIndex, ACount) {
      var Result = 0;
      var S = "";
      S = pas.System.Copy(this.get(),StartIndex + 1,ACount);
      Result = pas.System.Pos(AValue,S) - 1;
      if (Result !== -1) Result = Result + StartIndex;
      return Result;
    };
    this.IndexOfUnQuoted = function (AValue, StartQuote, EndQuote, StartIndex) {
      var $Self = this;
      var Result = 0;
      var LV = 0;
      var S = "";
      function MatchAt(I) {
        var Result = false;
        var J = 0;
        J = 1;
        do {
          Result = S.charAt((I + J) - 1 - 1) === AValue.charAt(J - 1);
          J += 1;
        } while (!(!Result || (J > LV)));
        return Result;
      };
      var I = 0;
      var L = 0;
      var Q = 0;
      S = $Self.get();
      Result = -1;
      LV = AValue.length;
      L = ($mod.TStringHelper.GetLength.call($Self) - LV) + 1;
      if (L < 0) L = 0;
      I = StartIndex + 1;
      Q = 0;
      if (StartQuote === EndQuote) {
        while ((Result === -1) && (I <= L)) {
          if (S.charAt(I - 1) === StartQuote) Q = 1 - Q;
          if ((Q === 0) && MatchAt(I)) Result = I - 1;
          I += 1;
        };
      } else {
        while ((Result === -1) && (I <= L)) {
          if (S.charAt(I - 1) === StartQuote) {
            Q += 1}
           else if ((S.charAt(I - 1) === EndQuote) && (Q > 0)) Q -= 1;
          if ((Q === 0) && MatchAt(I)) Result = I - 1;
          I += 1;
        };
      };
      return Result;
    };
    this.IndexOfAny = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$1.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return AnyOf;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.IndexOfAny$1 = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$5.call(this,AnyOf,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAny$2 = function (AnyOf, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$3.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return AnyOf;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),StartIndex);
      return Result;
    };
    this.IndexOfAny$3 = function (AnyOf, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$5.call(this,AnyOf,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAny$4 = function (AnyOf, StartIndex, ACount) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$5.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return AnyOf;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),StartIndex,ACount);
      return Result;
    };
    this.IndexOfAny$5 = function (AnyOf, StartIndex, ACount) {
      var Result = 0;
      var i = 0;
      var L = 0;
      i = StartIndex + 1;
      L = (i + ACount) - 1;
      if (L > $mod.TStringHelper.GetLength.call(this)) L = $mod.TStringHelper.GetLength.call(this);
      Result = -1;
      while ((Result === -1) && (i <= L)) {
        if ($impl.HaveChar(this.get().charAt(i - 1),AnyOf)) Result = i - 1;
        i += 1;
      };
      return Result;
    };
    this.IndexOfAny$6 = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$8.call(this,AnyOf,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAny$7 = function (AnyOf, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$8.call(this,AnyOf,StartIndex,$mod.TStringHelper.GetLength.call(this) - StartIndex);
      return Result;
    };
    this.IndexOfAny$8 = function (AnyOf, StartIndex, ACount) {
      var Result = 0;
      var M = 0;
      Result = $mod.TStringHelper.IndexOfAny$9.call(this,AnyOf,StartIndex,ACount,{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }});
      return Result;
    };
    this.IndexOfAny$9 = function (AnyOf, StartIndex, ACount, AMatch) {
      var Result = 0;
      var L = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = rtl.length(AnyOf) - 1; $l <= $end; $l++) {
        I = $l;
        L = $mod.TStringHelper.IndexOf$5.call(this,AnyOf[I],StartIndex,ACount);
        if ((L >= 0) && ((Result === -1) || (L < Result))) {
          Result = L;
          AMatch.set(I);
        };
      };
      return Result;
    };
    this.IndexOfAnyUnquoted = function (AnyOf, StartQuote, EndQuote) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAnyUnquoted$2.call(this,AnyOf,StartQuote,EndQuote,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAnyUnquoted$1 = function (AnyOf, StartQuote, EndQuote, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAnyUnquoted$2.call(this,AnyOf,StartQuote,EndQuote,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAnyUnquoted$2 = function (AnyOf, StartQuote, EndQuote, StartIndex, ACount) {
      var Result = 0;
      var I = 0;
      var L = 0;
      var Q = 0;
      Result = -1;
      L = (StartIndex + ACount) - 1;
      if (L > $mod.TStringHelper.GetLength.call(this)) L = $mod.TStringHelper.GetLength.call(this);
      I = StartIndex + 1;
      Q = 0;
      if (StartQuote === EndQuote) {
        while ((Result === -1) && (I <= L)) {
          if (this.get().charAt(I - 1) === StartQuote) Q = 1 - Q;
          if ((Q === 0) && $impl.HaveChar(this.get().charAt(I - 1),AnyOf)) Result = I - 1;
          I += 1;
        };
      } else {
        while ((Result === -1) && (I <= L)) {
          if (this.get().charAt(I - 1) === StartQuote) {
            Q += 1}
           else if ((this.get().charAt(I - 1) === EndQuote) && (Q > 0)) Q -= 1;
          if ((Q === 0) && $impl.HaveChar(this.get().charAt(I - 1),AnyOf)) Result = I - 1;
          I += 1;
        };
      };
      return Result;
    };
    this.IndexOfAnyUnquoted$3 = function (AnyOf, StartQuote, EndQuote, StartIndex, Matched) {
      var Result = 0;
      var L = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = rtl.length(AnyOf) - 1; $l <= $end; $l++) {
        I = $l;
        L = $mod.TStringHelper.IndexOfUnQuoted.call(this,AnyOf[I],StartQuote,EndQuote,StartIndex);
        if ((L >= 0) && ((Result === -1) || (L < Result))) {
          Result = L;
          Matched.set(I);
        };
      };
      return Result;
    };
    this.Insert = function (StartIndex, AValue) {
      var Result = "";
      pas.System.Insert(AValue,this,StartIndex + 1);
      Result = this.get();
      return Result;
    };
    this.IsDelimiter = function (Delimiters, Index) {
      var Result = false;
      Result = $mod.IsDelimiter(Delimiters,this.get(),Index + 1);
      return Result;
    };
    this.IsEmpty = function () {
      var Result = false;
      Result = $mod.TStringHelper.GetLength.call(this) === 0;
      return Result;
    };
    var cNumbers = rtl.createSet(null,48,57);
    this.IsNumber = function () {
      var Result = false;
      var lCount = 0;
      if ($mod.TStringHelper.IsEmpty.call(this)) return false;
      for (var $l = 0, $end = $mod.TStringHelper.GetLength.call(this) - 1; $l <= $end; $l++) {
        lCount = $l;
        if (!($mod.TStringHelper.GetChar.call(this,lCount).charCodeAt() in cNumbers)) return false;
      };
      Result = true;
      return Result;
    };
    this.LastDelimiter = function (Delims) {
      var Result = 0;
      Result = $mod.LastDelimiter(Delims,this.get()) - 1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$4.call(this,AValue,$mod.TStringHelper.GetLength.call(this) - 1,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$1 = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$5.call(this,AValue,$mod.TStringHelper.GetLength.call(this) - 1,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$2 = function (AValue, AStartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$4.call(this,AValue,AStartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$3 = function (AValue, AStartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$5.call(this,AValue,AStartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$4 = function (AValue, AStartIndex, ACount) {
      var Result = 0;
      var Min = 0;
      Result = AStartIndex + 1;
      Min = (Result - ACount) + 1;
      if (Min < 1) Min = 1;
      while ((Result >= Min) && (this.get().charAt(Result - 1) !== AValue)) Result -= 1;
      if (Result < Min) {
        Result = -1}
       else Result = Result - 1;
      return Result;
    };
    this.LastIndexOf$5 = function (AValue, AStartIndex, ACount) {
      var Result = 0;
      Result = this.get().lastIndexOf(AValue,AStartIndex);
      if ((AStartIndex - Result) > ACount) Result = -1;
      return Result;
    };
    this.LastIndexOfAny = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOfAny$2.call(this,AnyOf,$mod.TStringHelper.GetLength.call(this) - 1,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOfAny$1 = function (AnyOf, AStartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOfAny$2.call(this,AnyOf,AStartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOfAny$2 = function (AnyOf, AStartIndex, ACount) {
      var Result = 0;
      var Min = 0;
      Result = AStartIndex + 1;
      Min = (Result - ACount) + 1;
      if (Min < 1) Min = 1;
      while ((Result >= Min) && !$impl.HaveChar(this.get().charAt(Result - 1),AnyOf)) Result -= 1;
      if (Result < Min) {
        Result = -1}
       else Result = Result - 1;
      return Result;
    };
    this.PadLeft = function (ATotalWidth) {
      var Result = "";
      Result = $mod.TStringHelper.PadLeft$1.call(this,ATotalWidth," ");
      return Result;
    };
    this.PadLeft$1 = function (ATotalWidth, PaddingChar) {
      var Result = "";
      var L = 0;
      Result = this.get();
      L = ATotalWidth - $mod.TStringHelper.GetLength.call(this);
      if (L > 0) Result = pas.System.StringOfChar(PaddingChar,L) + Result;
      return Result;
    };
    this.PadRight = function (ATotalWidth) {
      var Result = "";
      Result = $mod.TStringHelper.PadRight$1.call(this,ATotalWidth," ");
      return Result;
    };
    this.PadRight$1 = function (ATotalWidth, PaddingChar) {
      var Result = "";
      var L = 0;
      Result = this.get();
      L = ATotalWidth - $mod.TStringHelper.GetLength.call(this);
      if (L > 0) Result = Result + pas.System.StringOfChar(PaddingChar,L);
      return Result;
    };
    this.QuotedString = function () {
      var Result = "";
      Result = $mod.QuotedStr(this.get(),"'");
      return Result;
    };
    this.QuotedString$1 = function (AQuoteChar) {
      var Result = "";
      Result = $mod.QuotedStr(this.get(),AQuoteChar);
      return Result;
    };
    this.Remove = function (StartIndex) {
      var Result = "";
      Result = $mod.TStringHelper.Remove$1.call(this,StartIndex,$mod.TStringHelper.GetLength.call(this) - StartIndex);
      return Result;
    };
    this.Remove$1 = function (StartIndex, ACount) {
      var Result = "";
      Result = this.get();
      pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},StartIndex + 1,ACount);
      return Result;
    };
    this.Replace = function (OldChar, NewChar) {
      var Result = "";
      Result = $mod.TStringHelper.Replace$1.call(this,OldChar,NewChar,rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll));
      return Result;
    };
    this.Replace$1 = function (OldChar, NewChar, ReplaceFlags) {
      var Result = "";
      Result = $mod.StringReplace(this.get(),OldChar,NewChar,rtl.refSet(ReplaceFlags));
      return Result;
    };
    this.Replace$2 = function (OldValue, NewValue) {
      var Result = "";
      Result = $mod.TStringHelper.Replace$3.call(this,OldValue,NewValue,rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll));
      return Result;
    };
    this.Replace$3 = function (OldValue, NewValue, ReplaceFlags) {
      var Result = "";
      Result = $mod.StringReplace(this.get(),OldValue,NewValue,rtl.refSet(ReplaceFlags));
      return Result;
    };
    this.Split = function (Separators) {
      var Result = [];
      Result = $mod.TStringHelper.Split$1.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.Split$1 = function (Separators) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,"\x00","\x00",$mod.TStringHelper.GetLength.call(this) + 1,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$2 = function (Separators, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$3.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),ACount);
      return Result;
    };
    this.Split$3 = function (Separators, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,"\x00","\x00",ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$4 = function (Separators, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$5.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),Options);
      return Result;
    };
    this.Split$5 = function (Separators, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$7.call(this,Separators,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$6 = function (Separators, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$7.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),ACount,Options);
      return Result;
    };
    this.Split$7 = function (Separators, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,"\x00","\x00",ACount,Options);
      return Result;
    };
    this.Split$8 = function (Separators) {
      var Result = [];
      Result = $mod.TStringHelper.Split$9.call(this,Separators,$mod.TStringHelper.GetLength.call(this) + 1);
      return Result;
    };
    this.Split$9 = function (Separators, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$11.call(this,Separators,ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$10 = function (Separators, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$11.call(this,Separators,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$11 = function (Separators, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,"\x00","\x00",ACount,Options);
      return Result;
    };
    this.Split$12 = function (Separators, AQuote) {
      var Result = [];
      Result = $mod.TStringHelper.Split$13.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuote);
      return Result;
    };
    this.Split$13 = function (Separators, AQuote) {
      var Result = [];
      Result = $mod.TStringHelper.Split$15.call(this,Separators,AQuote,AQuote);
      return Result;
    };
    this.Split$14 = function (Separators, AQuoteStart, AQuoteEnd) {
      var Result = [];
      Result = $mod.TStringHelper.Split$15.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd);
      return Result;
    };
    this.Split$15 = function (Separators, AQuoteStart, AQuoteEnd) {
      var Result = [];
      Result = $mod.TStringHelper.Split$17.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$16 = function (Separators, AQuoteStart, AQuoteEnd, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$17.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd,Options);
      return Result;
    };
    this.Split$17 = function (Separators, AQuoteStart, AQuoteEnd, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$18 = function (Separators, AQuoteStart, AQuoteEnd, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$19.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd,ACount);
      return Result;
    };
    this.Split$19 = function (Separators, AQuoteStart, AQuoteEnd, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,AQuoteStart,AQuoteEnd,ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$20 = function (Separators, AQuoteStart, AQuoteEnd, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd,ACount,Options);
      return Result;
    };
    var BlockSize = 10;
    this.Split$21 = function (Separators, AQuoteStart, AQuoteEnd, ACount, Options) {
      var $Self = this;
      var Result = [];
      var S = "";
      function NextSep(StartIndex) {
        var Result = 0;
        if (AQuoteStart !== "\x00") {
          Result = $mod.TStringHelper.IndexOfAnyUnquoted$1.call({get: function () {
              return S;
            }, set: function (v) {
              S = v;
            }},Separators,AQuoteStart,AQuoteEnd,StartIndex)}
         else Result = $mod.TStringHelper.IndexOfAny$3.call({get: function () {
            return S;
          }, set: function (v) {
            S = v;
          }},Separators,StartIndex);
        return Result;
      };
      function MaybeGrow(Curlen) {
        if (rtl.length(Result) <= Curlen) Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 10);
      };
      var Sep = 0;
      var LastSep = 0;
      var Len = 0;
      var T = "";
      S = $Self.get();
      Result = rtl.arraySetLength(Result,"",10);
      Len = 0;
      LastSep = 0;
      Sep = NextSep(0);
      while ((Sep !== -1) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring$1.call($Self,LastSep,Sep - LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
        LastSep = Sep + 1;
        Sep = NextSep(LastSep);
      };
      if ((LastSep <= $mod.TStringHelper.GetLength.call($Self)) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring.call($Self,LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
      };
      Result = rtl.arraySetLength(Result,"",Len);
      return Result;
    };
    this.Split$22 = function (Separators, AQuote) {
      var Result = [];
      Result = $mod.TStringHelper.Split$23.call(this,Separators,AQuote,AQuote);
      return Result;
    };
    this.Split$23 = function (Separators, AQuoteStart, AQuoteEnd) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringHelper.GetLength.call(this) + 1,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$24 = function (Separators, AQuoteStart, AQuoteEnd, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$25 = function (Separators, AQuoteStart, AQuoteEnd, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,AQuoteStart,AQuoteEnd,ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    var BlockSize$1 = 10;
    this.Split$26 = function (Separators, AQuoteStart, AQuoteEnd, ACount, Options) {
      var $Self = this;
      var Result = [];
      var S = "";
      function NextSep(StartIndex, Match) {
        var Result = 0;
        if (AQuoteStart !== "\x00") {
          Result = $mod.TStringHelper.IndexOfAnyUnquoted$3.call({get: function () {
              return S;
            }, set: function (v) {
              S = v;
            }},Separators,AQuoteStart,AQuoteEnd,StartIndex,Match)}
         else Result = $mod.TStringHelper.IndexOfAny$9.call({get: function () {
            return S;
          }, set: function (v) {
            S = v;
          }},Separators,StartIndex,$mod.TStringHelper.GetLength.call($Self),Match);
        return Result;
      };
      function MaybeGrow(Curlen) {
        if (rtl.length(Result) <= Curlen) Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 10);
      };
      var Sep = 0;
      var LastSep = 0;
      var Len = 0;
      var Match = 0;
      var T = "";
      S = $Self.get();
      Result = rtl.arraySetLength(Result,"",10);
      Len = 0;
      LastSep = 0;
      Sep = NextSep(0,{get: function () {
          return Match;
        }, set: function (v) {
          Match = v;
        }});
      while ((Sep !== -1) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring$1.call($Self,LastSep,Sep - LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
        LastSep = Sep + Separators[Match].length;
        Sep = NextSep(LastSep,{get: function () {
            return Match;
          }, set: function (v) {
            Match = v;
          }});
      };
      if ((LastSep <= $mod.TStringHelper.GetLength.call($Self)) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring.call($Self,LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
      };
      Result = rtl.arraySetLength(Result,"",Len);
      return Result;
    };
    this.StartsWith = function (AValue) {
      var Result = false;
      Result = $mod.TStringHelper.StartsWith$1.call(this,AValue,false);
      return Result;
    };
    this.StartsWith$1 = function (AValue, IgnoreCase) {
      var Result = false;
      var L = 0;
      var S = "";
      L = AValue.length;
      Result = L <= 0;
      if (!Result) {
        S = pas.System.Copy(this.get(),1,L);
        Result = S.length === L;
        if (Result) if (IgnoreCase) {
          Result = $mod.SameText(S,AValue)}
         else Result = $mod.SameStr(S,AValue);
      };
      return Result;
    };
    this.Substring = function (AStartIndex) {
      var Result = "";
      Result = $mod.TStringHelper.Substring$1.call(this,AStartIndex,$mod.TStringHelper.GetLength.call(this) - AStartIndex);
      return Result;
    };
    this.Substring$1 = function (AStartIndex, ALen) {
      var Result = "";
      Result = pas.System.Copy(this.get(),AStartIndex + 1,ALen);
      return Result;
    };
    this.ToBoolean$1 = function () {
      var Result = false;
      Result = $mod.StrToBool(this.get());
      return Result;
    };
    this.ToInteger$1 = function () {
      var Result = 0;
      Result = $mod.StrToInt(this.get());
      return Result;
    };
    this.ToNativeInt$1 = function () {
      var Result = 0;
      Result = $mod.StrToNativeInt(this.get());
      return Result;
    };
    this.ToDouble$1 = function () {
      var Result = 0.0;
      Result = $mod.StrToFloat(this.get());
      return Result;
    };
    this.ToExtended$1 = function () {
      var Result = 0.0;
      Result = $mod.StrToFloat(this.get());
      return Result;
    };
    this.ToCharArray$1 = function () {
      var Result = [];
      Result = $mod.TStringHelper.ToCharArray$2.call(this,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.ToCharArray$2 = function (AStartIndex, ALen) {
      var Result = [];
      var I = 0;
      Result = rtl.arraySetLength(Result,"\x00",ALen);
      for (var $l = 0, $end = ALen - 1; $l <= $end; $l++) {
        I = $l;
        Result[I] = this.get().charAt((AStartIndex + I + 1) - 1);
      };
      return Result;
    };
    this.ToLower = function () {
      var Result = "";
      Result = $mod.TStringHelper.LowerCase(this.get());
      return Result;
    };
    this.ToLowerInvariant = function () {
      var Result = "";
      Result = $mod.TStringHelper.LowerCase(this.get());
      return Result;
    };
    this.ToUpper = function () {
      var Result = "";
      Result = $mod.TStringHelper.UpperCase(this.get());
      return Result;
    };
    this.ToUpperInvariant = function () {
      var Result = "";
      Result = $mod.TStringHelper.UpperCase(this.get());
      return Result;
    };
    this.Trim = function () {
      var Result = "";
      Result = $mod.Trim(this.get());
      return Result;
    };
    this.TrimLeft = function () {
      var Result = "";
      Result = $mod.TrimLeft(this.get());
      return Result;
    };
    this.TrimRight = function () {
      var Result = "";
      Result = $mod.TrimRight(this.get());
      return Result;
    };
    this.Trim$1 = function (ATrimChars) {
      var Result = "";
      Result = $mod.TStringHelper.TrimRight$1.call({a: $mod.TStringHelper.TrimLeft$1.call(this,ATrimChars), get: function () {
          return this.a;
        }, set: function (v) {
          this.a = v;
        }},ATrimChars);
      return Result;
    };
    this.TrimLeft$1 = function (ATrimChars) {
      var Result = "";
      var I = 0;
      var Len = 0;
      I = 1;
      Len = $mod.TStringHelper.GetLength.call(this);
      while ((I <= Len) && $impl.HaveChar(this.get().charAt(I - 1),ATrimChars)) I += 1;
      if (I === 1) {
        Result = this.get()}
       else if (I > Len) {
        Result = ""}
       else Result = pas.System.Copy(this.get(),I,(Len - I) + 1);
      return Result;
    };
    this.TrimRight$1 = function (ATrimChars) {
      var Result = "";
      var I = 0;
      var Len = 0;
      Len = $mod.TStringHelper.GetLength.call(this);
      I = Len;
      while ((I >= 1) && $impl.HaveChar(this.get().charAt(I - 1),ATrimChars)) I -= 1;
      if (I < 1) {
        Result = ""}
       else if (I === Len) {
        Result = this.get()}
       else Result = pas.System.Copy(this.get(),1,I);
      return Result;
    };
    this.TrimEnd = function (ATrimChars) {
      var Result = "";
      Result = $mod.TStringHelper.TrimRight$1.call(this,ATrimChars);
      return Result;
    };
    this.TrimStart = function (ATrimChars) {
      var Result = "";
      Result = $mod.TStringHelper.TrimLeft$1.call(this,ATrimChars);
      return Result;
    };
  });
  rtl.createHelper(this,"TDoubleHelper",null,function () {
    this.Epsilon = 4.9406564584124654418e-324;
    this.MaxValue = 1.7976931348623157081e+308;
    this.MinValue = -1.7976931348623157081e+308;
    this.GetB = function (AIndex) {
      var Result = 0;
      var F = null;
      var B = null;
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = this.get();
      Result = B[AIndex];
      return Result;
    };
    this.GetW = function (AIndex) {
      var Result = 0;
      var F = null;
      var W = null;
      F = new Float64Array(1);
      W = new Uint16Array(F.buffer);
      F[0] = this.get();
      Result = W[AIndex];
      return Result;
    };
    this.GetE = function () {
      var Result = 0;
      Result = $impl.FloatToParts(this.get()).exp;
      return Result;
    };
    this.GetF = function () {
      var Result = 0;
      Result = 0;
      $impl.NotImplemented("GetF");
      return Result;
    };
    this.GetS = function () {
      var Result = false;
      Result = $impl.FloatToParts(this.get()).sign;
      return Result;
    };
    this.SetS = function (aValue) {
      var F = null;
      var B = null;
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = this.get();
      if (aValue) {
        B[7] = B[7] | (1 >>> 7)}
       else B[7] = B[7] & ~(1 >>> 7);
      this.set(F[0]);
    };
    this.SetB = function (AIndex, AValue) {
      var F = null;
      var B = null;
      if (AIndex >= 8) throw $mod.ERangeError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SRangeError")]);
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = this.get();
      B[AIndex] = AValue;
      this.set(F[0]);
    };
    this.SetW = function (AIndex, AValue) {
      var F = null;
      var W = null;
      if (AIndex >= 4) throw $mod.ERangeError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SRangeError")]);
      F = new Float64Array(1);
      W = new Uint16Array(F.buffer);
      F[0] = this.get();
      W[AIndex] = AValue;
      this.set(F[0]);
    };
    this.IsInfinity = function (AValue) {
      var Result = false;
      Result = !isFinite(AValue);
      return Result;
    };
    this.IsNan = function (AValue) {
      var Result = false;
      Result = isNaN(AValue);
      return Result;
    };
    this.IsNegativeInfinity = function (AValue) {
      var Result = false;
      return (AValue=Number.NEGATIVE_INFINITY);
      Result = AValue === 0;
      return Result;
    };
    this.IsPositiveInfinity = function (AValue) {
      var Result = false;
      return (AValue=Number.POSITIVE_INFINITY);
      Result = AValue === 0;
      return Result;
    };
    this.Parse = function (AString) {
      var Result = 0.0;
      Result = $mod.StrToFloat(AString);
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.FloatToStr(AValue);
      return Result;
    };
    this.ToString$1 = function (AValue, AFormat, APrecision, ADigits) {
      var Result = "";
      Result = $mod.FloatToStrF(AValue,AFormat,APrecision,ADigits);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      Result = $mod.TryStrToFloat$2(AString,AValue);
      return Result;
    };
    this.BuildUp = function (ASignFlag, AMantissa, AExponent) {
      $impl.NotImplemented("BuildUp");
      if (ASignFlag && (AMantissa > 0) && (AExponent < 0)) return;
    };
    this.Exponent = function () {
      var Result = 0;
      Result = $impl.FloatToParts(this.get()).exp;
      return Result;
    };
    this.Fraction = function () {
      var Result = 0.0;
      Result = pas.System.Frac(this.get());
      return Result;
    };
    this.IsInfinity$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsInfinity(this.get());
      return Result;
    };
    this.IsNan$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsNan(this.get());
      return Result;
    };
    this.IsNegativeInfinity$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsNegativeInfinity(this.get());
      return Result;
    };
    this.IsPositiveInfinity$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsPositiveInfinity(this.get());
      return Result;
    };
    this.Mantissa = function () {
      var Result = 0;
      Result = pas.System.Trunc($impl.FloatToParts(this.get()).mantissa);
      return Result;
    };
    this.ToString$2 = function (AFormat, APrecision, ADigits) {
      var Result = "";
      Result = $mod.FloatToStrF(this.get(),AFormat,APrecision,ADigits);
      return Result;
    };
    this.ToString$3 = function () {
      var Result = "";
      Result = $mod.FloatToStr(this.get());
      return Result;
    };
  });
  rtl.createHelper(this,"TByteHelper",null,function () {
    this.MaxValue = 255;
    this.MinValue = 0;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$3(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TByteHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TByteHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TShortIntHelper",null,function () {
    this.MaxValue = 127;
    this.MinValue = -128;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$2(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TShortIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      var B = 0;
      var U = null;
      var S = null;
      if (this.get() >= 0) {
        B = this.get()}
       else {
        S = new Int8Array(1);
        S[0] = this.get();
        U = new Uint8Array(S);
        B = U[0];
        if (AMinDigits > 2) B = 0xFF00 + B;
      };
      Result = $mod.IntToHex(B,AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.TShortIntHelper.ToHexString.call(this,$mod.TShortIntHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TSmallIntHelper",null,function () {
    this.MaxValue = 32767;
    this.MinValue = -32768;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 2;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$4(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TSmallIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function () {
      var Result = "";
      Result = $mod.TSmallIntHelper.ToHexString$1.call(this,$mod.TSmallIntHelper.Size() * 2);
      return Result;
    };
    this.ToHexString$1 = function (AMinDigits) {
      var Result = "";
      var B = 0;
      var U = null;
      var S = null;
      if (this.get() >= 0) {
        B = this.get()}
       else {
        S = new Int16Array(1);
        S[0] = this.get();
        U = new Uint16Array(S);
        B = U[0];
        if (AMinDigits > 6) {
          B = 0xFFFF0000 + B}
         else if (AMinDigits > 4) B = 0xFF0000 + B;
      };
      Result = $mod.IntToHex(B,AMinDigits);
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TWordHelper",null,function () {
    this.MaxValue = 65535;
    this.MinValue = 0;
    var cBitPerByte = 8;
    this.FromBytes = function (ALow, AHigh) {
      var Result = 0;
      Result = ALow + (AHigh << 8);
      return Result;
    };
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 2;
      return Result;
    };
    var cMask = 0xFF;
    var cBitPerByte$1 = 8;
    this.ToBytes = function (ALow, AHigh) {
      ALow.set(this.get() & cMask);
      AHigh.set((this.get() & (cMask << 8)) >>> 8);
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$5(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TWordHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TWordHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TCardinalHelper",null,function () {
    this.MaxValue = 4294967295;
    this.MinValue = 0;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 4;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$7(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TCardinalHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.TCardinalHelper.ToHexString.call(this,$mod.TCardinalHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(rtl.lw(this.get() | rtl.lw(1 << Index)));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(rtl.lw(this.get() & rtl.lw(~rtl.lw(1 << Index))));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(rtl.lw(this.get() ^ rtl.lw(1 << Index)));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = rtl.lw(this.get() & rtl.lw(1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TIntegerHelper",null,function () {
    this.MaxValue = 2147483647;
    this.MinValue = -2147483648;
    this.Size = function () {
      var Result = 0;
      Result = 4;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$6(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TIntegerHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      var B = 0;
      var U = null;
      var S = null;
      if (this.get() >= 0) {
        B = this.get()}
       else {
        S = new Int32Array(1);
        S[0] = this.get();
        U = new Uint32Array(S);
        B = U[0];
      };
      Result = $mod.IntToHex(B,AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.TIntegerHelper.ToHexString.call(this,$mod.TIntegerHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TUInt64Helper",null,function () {
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
  });
  rtl.createHelper(this,"TNativeIntHelper",null,function () {
    this.MaxValue = 9007199254740991;
    this.MinValue = -9007199254740991;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 7;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TNativeIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TNativeIntHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(rtl.or(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(rtl.and(this.get(),~rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(rtl.xor(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = rtl.and(this.get(),rtl.shl(1,Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TNativeUIntHelper",null,function () {
    this.MaxValue = 9007199254740991;
    this.MinValue = 0;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 7;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$1(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TNativeUIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TNativeUIntHelper.Size() * 2);
      return Result;
    };
    this.ToSingle = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(rtl.or(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(rtl.and(this.get(),~rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(rtl.xor(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = rtl.and(this.get(),rtl.shl(1,Index)) !== 0;
      return Result;
    };
  });
  this.TUseBoolStrs = {"0": "False", False: 0, "1": "True", True: 1};
  this.$rtti.$Enum("TUseBoolStrs",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TUseBoolStrs});
  rtl.createHelper(this,"TBooleanHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs === $mod.TUseBoolStrs.True);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs === $mod.TUseBoolStrs.True);
      return Result;
    };
  });
  rtl.createHelper(this,"TByteBoolHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs);
      return Result;
    };
  });
  rtl.createHelper(this,"TWordBoolHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 2;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs);
      return Result;
    };
  });
  rtl.createHelper(this,"TLongBoolHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 4;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs);
      return Result;
    };
  });
  rtl.createClass(this,"TStringBuilder",pas.System.TObject,function () {
    this.DefaultCapacity = 64;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FData = "";
      this.FMaxCapacity = 0;
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.FData.length;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue > this.FMaxCapacity) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SListCapacityError"),pas.System.VarRecs(0,AValue)]);
      if (AValue < this.GetLength()) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SListCapacityError"),pas.System.VarRecs(0,AValue)]);
    };
    this.GetC = function (Index) {
      var Result = "\x00";
      this.CheckNegative(Index + 1,"Index");
      this.CheckRange(Index + 1,0,this.GetLength());
      Result = this.FData.charAt((Index + 1) - 1);
      return Result;
    };
    this.SetC = function (Index, AValue) {
      this.CheckNegative(Index + 1,"Index");
      this.CheckRange(Index + 1,0,this.GetLength());
      this.FData = rtl.setCharAt(this.FData,(Index + 1) - 1,AValue);
    };
    this.GetLength = function () {
      var Result = 0;
      Result = this.FData.length;
      return Result;
    };
    this.SetLength = function (AValue) {
      this.CheckNegative(AValue,"AValue");
      this.CheckRange(AValue,0,this.FMaxCapacity);
      this.FData = rtl.strSetLength(this.FData,AValue);
    };
    this.CheckRange = function (Idx, Count, MaxLen) {
      if ((Idx < 0) || ((Idx + Count) > MaxLen)) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SListIndexError"),pas.System.VarRecs(0,Idx)]);
    };
    this.CheckNegative = function (AValue, AName) {
      if (AValue < 0) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SParamIsNegative"),pas.System.VarRecs(18,AName)]);
    };
    this.DoAppend = function (S) {
      this.FData = this.FData + S;
    };
    this.DoAppend$1 = function (AValue, Idx, aCount) {
      var S = "";
      var I = 0;
      S = "";
      this.CheckRange(Idx,aCount,rtl.length(AValue));
      for (var $l = Idx, $end = (Idx + aCount) - 1; $l <= $end; $l++) {
        I = $l;
        S = S + AValue[I];
      };
      this.DoAppend(S);
    };
    this.DoInsert = function (Index, AValue) {
      this.CheckRange(Index,0,this.GetLength() - 1);
      pas.System.Insert(AValue,{p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},Index + 1);
    };
    this.DoInsert$1 = function (Index, AValue, StartIndex, aCharCount) {
      var I = 0;
      var S = "";
      this.CheckRange(Index,0,this.GetLength() - 1);
      this.CheckNegative(StartIndex,"StartIndex");
      this.CheckNegative(aCharCount,"SBCharCount");
      this.CheckRange(StartIndex,aCharCount,rtl.length(AValue));
      S = "";
      for (var $l = StartIndex, $end = (StartIndex + aCharCount) - 1; $l <= $end; $l++) {
        I = $l;
        S = S + AValue[I];
      };
      this.DoInsert(Index,S);
    };
    this.DoReplace = function (Index, Old, New) {
      var OVLen = 0;
      OVLen = Old.length;
      pas.System.Delete({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},Index + 1,OVLen);
      pas.System.Insert(New,{p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},Index + 1);
    };
    this.Grow = function () {
      var NewCapacity = 0;
      NewCapacity = this.GetCapacity() * 2;
      if (NewCapacity > this.FMaxCapacity) NewCapacity = this.FMaxCapacity;
      this.SetCapacity(NewCapacity);
    };
    this.Shrink = function () {
      if (rtl.trunc(this.GetCapacity() / 4) >= this.GetLength()) this.SetCapacity(rtl.trunc(this.GetCapacity() / 2));
    };
    this.Create$1 = function () {
      this.Create$4(64,2147483647);
      return this;
    };
    this.Create$2 = function (aCapacity) {
      this.Create$4(aCapacity,2147483647);
      return this;
    };
    this.Create$3 = function (AValue) {
      this.Create$5(AValue,64);
      return this;
    };
    this.Create$4 = function (aCapacity, aMaxCapacity) {
      this.FMaxCapacity = aMaxCapacity;
      this.SetCapacity(aCapacity);
      return this;
    };
    this.Create$5 = function (AValue, aCapacity) {
      this.Create$4(aCapacity,2147483647);
      if (AValue.length > 0) this.Append$14(AValue);
      return this;
    };
    this.Create$6 = function (AValue, StartIndex, aLength, aCapacity) {
      this.Create$5(pas.System.Copy(AValue,StartIndex + 1,aLength),aCapacity);
      return this;
    };
    this.Append = function (AValue) {
      var Result = null;
      this.DoAppend($mod.BoolToStr(AValue,true));
      Result = this;
      return Result;
    };
    this.Append$1 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$2 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue);
      Result = this;
      return Result;
    };
    this.Append$3 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.CurrToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$4 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.FloatToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$5 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$6 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$7 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$8 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue.ToString());
      Result = this;
      return Result;
    };
    this.Append$9 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$10 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$11 = function (AValue) {
      var Result = null;
      var I = 0;
      var L = 0;
      I = -1;
      L = rtl.length(AValue);
      if (L === 0) return this;
      do {
        I += 1;
      } while (!((I >= L) || (AValue[I] === "\x00")));
      this.DoAppend$1(AValue,0,I);
      Result = this;
      return Result;
    };
    this.Append$12 = function (AValue) {
      var Result = null;
      this.Append$14($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$13 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$14 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue);
      Result = this;
      return Result;
    };
    this.Append$15 = function (AValue, RepeatCount) {
      var Result = null;
      this.DoAppend(pas.System.StringOfChar(AValue,RepeatCount));
      Result = this;
      return Result;
    };
    this.Append$16 = function (AValue, StartIndex, SBCharCount) {
      var Result = null;
      this.DoAppend$1(AValue,StartIndex,SBCharCount);
      Result = this;
      return Result;
    };
    this.Append$17 = function (AValue, StartIndex, Count) {
      var Result = null;
      this.CheckRange(StartIndex,Count,AValue.length);
      this.DoAppend(pas.System.Copy(AValue,StartIndex + 1,Count));
      Result = this;
      return Result;
    };
    this.Append$18 = function (Fmt, Args) {
      var Result = null;
      this.DoAppend($mod.Format(Fmt,Args));
      Result = this;
      return Result;
    };
    this.AppendFormat = function (Fmt, Args) {
      var Result = null;
      this.DoAppend($mod.Format(Fmt,Args));
      Result = this;
      return Result;
    };
    this.AppendLine = function () {
      var Result = null;
      this.DoAppend(pas.System.sLineBreak);
      Result = this;
      return Result;
    };
    this.AppendLine$1 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue);
      Result = this.AppendLine();
      return Result;
    };
    this.Clear = function () {
      this.SetLength(0);
      this.SetCapacity(64);
    };
    this.CopyTo = function (SourceIndex, Destination, DestinationIndex, Count) {
      var I = 0;
      this.CheckNegative(Count,"Count");
      this.CheckNegative(DestinationIndex,"DestinationIndex");
      this.CheckRange(DestinationIndex,Count,rtl.length(Destination.get()));
      if (Count > 0) {
        this.CheckRange(SourceIndex,Count,this.GetLength());
        for (var $l = SourceIndex + 1, $end = SourceIndex + Count; $l <= $end; $l++) {
          I = $l;
          Destination.get()[DestinationIndex] = this.FData.charAt(I - 1);
        };
      };
    };
    this.EnsureCapacity = function (aCapacity) {
      var Result = 0;
      this.CheckRange(aCapacity,0,this.FMaxCapacity);
      if (this.GetCapacity() < aCapacity) this.SetCapacity(aCapacity);
      Result = this.GetCapacity();
      return Result;
    };
    this.Equals$1 = function (StringBuilder) {
      var Result = false;
      Result = StringBuilder !== null;
      if (Result) Result = (this.GetLength() === StringBuilder.GetLength()) && (this.FMaxCapacity === StringBuilder.FMaxCapacity) && (this.FData === StringBuilder.FData.charAt(-1));
      return Result;
    };
    this.Insert = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.BoolToStr(AValue,true));
      Result = this;
      return Result;
    };
    this.Insert$1 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$2 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,AValue);
      Result = this;
      return Result;
    };
    this.Insert$3 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.CurrToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$4 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.FloatToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$5 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$6 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$7 = function (Index, AValue) {
      var Result = null;
      this.DoInsert$1(Index,AValue,0,rtl.length(AValue));
      Result = this;
      return Result;
    };
    this.Insert$8 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$9 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,AValue.ToString());
      Result = this;
      return Result;
    };
    this.Insert$10 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$11 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,AValue);
      Result = this;
      return Result;
    };
    this.Insert$12 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$13 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$14 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$15 = function (Index, AValue, aRepeatCount) {
      var Result = null;
      var I = 0;
      for (var $l = 0, $end = aRepeatCount - 1; $l <= $end; $l++) {
        I = $l;
        this.DoInsert(Index,AValue);
      };
      Result = this;
      return Result;
    };
    this.Insert$16 = function (Index, AValue, startIndex, SBCharCount) {
      var Result = null;
      this.DoInsert$1(Index,AValue,startIndex,SBCharCount);
      Result = this;
      return Result;
    };
    this.Remove = function (StartIndex, RemLength) {
      var Result = null;
      var MoveIndex = 0;
      if (RemLength === 0) return this;
      this.CheckNegative(RemLength,"RemLength");
      this.CheckRange(StartIndex,0,this.GetLength());
      MoveIndex = StartIndex + RemLength;
      this.CheckRange(MoveIndex,0,this.GetLength());
      pas.System.Delete({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},StartIndex + 1,RemLength);
      this.Shrink();
      Result = this;
      return Result;
    };
    this.Replace = function (OldValue, NewValue) {
      var Result = null;
      Result = this.Replace$1(OldValue,NewValue,0,this.GetLength());
      return Result;
    };
    this.Replace$1 = function (OldValue, NewValue, StartIndex, Count) {
      var Result = null;
      var I = 0;
      var Start = "";
      if (Count === 0) return this;
      this.CheckNegative(StartIndex,"StartIndex");
      this.CheckNegative(Count,"Count");
      this.CheckRange(StartIndex,Count,this.GetLength());
      Start = pas.System.Copy(this.FData,1,StartIndex);
      this.FData = pas.System.Copy$1(this.FData,StartIndex + 1);
      for (var $l = 1, $end = Count; $l <= $end; $l++) {
        I = $l;
        this.FData = $mod.StringReplace(this.FData,OldValue,NewValue,{});
      };
      this.FData = Start + this.FData;
      Result = this;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.ToString$2(0,this.GetLength());
      return Result;
    };
    this.ToString$2 = function (aStartIndex, aLength) {
      var Result = "";
      this.CheckNegative(aStartIndex,"aStartIndex");
      this.CheckNegative(aLength,"aLength");
      this.CheckRange(aStartIndex,aLength,this.GetLength());
      Result = pas.System.Copy(this.FData,1 + aStartIndex,aStartIndex + aLength);
      return Result;
    };
  });
  rtl.createClass(this,"TEncoding",pas.System.TObject,function () {
    this.FANSI = null;
    this.FASCII = null;
    this.FUnicode = null;
    this.FUTF7 = null;
    this.FUTF8 = null;
    this.GetANSI = function () {
      var Result = null;
      if (!(this.FANSI != null)) $mod.TEncoding.FANSI = $mod.TANSIEncoding.$create("Create");
      Result = this.FANSI;
      return Result;
    };
    this.GetASCII = function () {
      var Result = null;
      if (!(this.FASCII != null)) $mod.TEncoding.FASCII = $mod.TASCIIEncoding.$create("Create");
      Result = this.FASCII;
      return Result;
    };
    this.GetDefault = function () {
      var Result = null;
      Result = this.GetANSI();
      return Result;
    };
    this.GetUnicode = function () {
      var Result = null;
      if (!(this.FUnicode != null)) $mod.TEncoding.FUnicode = $mod.TUnicodeEncoding.$create("Create");
      Result = this.FUnicode;
      return Result;
    };
    this.GetUTF7 = function () {
      var Result = null;
      if (!(this.FUTF7 != null)) $mod.TEncoding.FUTF7 = $mod.TUTF7Encoding.$create("Create");
      Result = this.FUTF7;
      return Result;
    };
    this.GetUTF8 = function () {
      var Result = null;
      if (!(this.FUTF8 != null)) $mod.TEncoding.FUTF8 = $mod.TUTF8Encoding.$create("Create");
      Result = this.FUTF8;
      return Result;
    };
    var cEncoding = "utf-8";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding;
      return Result;
    };
    this.IsStandardEncoding = function (AEncoding) {
      var Result = false;
      Result = (AEncoding !== null) && ((AEncoding === this.GetANSI()) || (AEncoding === this.GetUnicode()));
      return Result;
    };
    this.GetByteCount$1 = function (AChars, ACharCount) {
      var Result = 0;
      Result = this.GetByteCount($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},0,ACharCount));
      return Result;
    };
    this.GetByteCount$2 = function (AChars, ACharIndex, ACharCount) {
      var Result = 0;
      Result = this.GetByteCount($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},ACharIndex,ACharCount));
      return Result;
    };
    this.GetBytes$1 = function (AChars, ACharCount) {
      var Result = [];
      Result = this.GetBytes($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},0,ACharCount));
      return Result;
    };
    this.GetBytes$2 = function (AChars, ACharIndex, ACharCount) {
      var Result = [];
      Result = this.GetBytes($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},ACharIndex,ACharCount));
      return Result;
    };
    this.GetString$1 = function (ABytes, ACharCount) {
      var Result = "";
      Result = this.GetString($impl.TBytesHelper.SubBytes.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},0,ACharCount));
      return Result;
    };
    this.GetString$2 = function (ABytes, ACharIndex, ACharCount) {
      var Result = "";
      Result = this.GetString($impl.TBytesHelper.SubBytes.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},ACharIndex,ACharCount));
      return Result;
    };
  });
  rtl.createClass(this,"TANSIEncoding",this.TEncoding,function () {
    var cEncoding$1 = "windows-1252";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$1;
      return Result;
    };
    this.GetByteCount = function (AChars) {
      var Result = 0;
      Result = $mod.TStringHelper.GetLength.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      return Result;
    };
    this.GetBytes = function (AChars) {
      var Result = [];
      Result = $mod.BytesOf(AChars);
      return Result;
    };
    this.GetString = function (ABytes) {
      var Result = "";
      Result = $mod.StringOf(ABytes);
      return Result;
    };
  });
  rtl.createClass(this,"TASCIIEncoding",this.TANSIEncoding,function () {
    var cEncoding$2 = "ISO-8859-2";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$2;
      return Result;
    };
  });
  rtl.createClass(this,"TUnicodeEncoding",this.TEncoding,function () {
    this.InternalGetBytes = function (AChars, ABytes) {
      var lWords = [];
      lWords = [];
      for (var lCount = 0; lCount < AChars.length; lCount++)
      lWords.push(AChars.charCodeAt(lCount));
      ABytes.set($impl.TWordsHelper.ToBytes.call({get: function () {
          return lWords;
        }, set: function (v) {
          lWords = v;
        }}));
    };
    var cEncoding$1 = "unicode";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$1;
      return Result;
    };
    var cCharSize = 2;
    this.GetByteCount = function (AChars) {
      var Result = 0;
      Result = 2 * $mod.TStringHelper.GetLength.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      return Result;
    };
    this.GetBytes = function (AChars) {
      var Result = [];
      this.InternalGetBytes(AChars,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetString = function (ABytes) {
      var Result = "";
      var lWords = [];
      var lBuffer = "";
      lBuffer = $mod.TStringHelper.Empty;
      lWords = $impl.TWordsHelper.FromBytes(ABytes);
      if (rtl.length(lWords) > 0) {
        for (var lCount = 0; lCount < lWords.length; lCount++)
        lBuffer += string.fromCharCode(lWords[lCount]);
      };
      Result = lBuffer;
      return Result;
    };
  });
  rtl.createClass(this,"TUTF8Encoding",this.TEncoding,function () {
    this.BytesToMemory = function (ABytes) {
      var Result = null;
      var lArray = null;
      Result = new ArrayBuffer($impl.TBytesHelper.GetLength.call({get: function () {
          return ABytes;
        }, set: function (v) {
          ABytes = v;
        }}));
      lArray = new Uint8Array(Result);
      lArray.set(ABytes);
      return Result;
    };
    this.MemoryToBytes = function (AMem) {
      var Result = [];
      var lCount = 0;
      for (var $l = 0, $end = AMem.length - 1; $l <= $end; $l++) {
        lCount = $l;
        Result[lCount] = AMem[lCount];
      };
      return Result;
    };
    var cEncoding$1 = "utf-8";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$1;
      return Result;
    };
    this.GetByteCount = function (AChars) {
      var Result = 0;
      Result = $impl.TBytesHelper.GetLength.call({a: this.GetBytes(AChars), get: function () {
          return this.a;
        }, set: function (v) {
          this.a = v;
        }});
      return Result;
    };
    this.GetBytes = function (AChars) {
      var Result = [];
      var lArray = null;
      var lEncoder = null;
      lEncoder = new TextEncoder();
      lArray = lEncoder.encode(AChars);
      Result = this.$class.MemoryToBytes(lArray);
      return Result;
    };
    this.GetString = function (ABytes) {
      var Result = "";
      var lArray = null;
      var lDecoder = null;
      lDecoder = new TextDecoder();
      lArray = this.$class.BytesToMemory(rtl.arrayRef(ABytes));
      Result = lDecoder.decode(lArray);
      return Result;
    };
  });
  rtl.createClass(this,"TUTF7Encoding",this.TUTF8Encoding,function () {
    var cEncoding$2 = "utf-7";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$2;
      return Result;
    };
  });
  this.TCmdLineSwitchType = {"0": "clstValueNextParam", clstValueNextParam: 0, "1": "clstValueAppended", clstValueAppended: 1, "2": "clstValueInternalUse", clstValueInternalUse: 2};
  this.$rtti.$Enum("TCmdLineSwitchType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCmdLineSwitchType});
  this.$rtti.$Set("TCmdLineSwitchTypes",{comptype: this.$rtti["TCmdLineSwitchType"]});
  this.clstValueNextParamForce = this.TCmdLineSwitchType.clstValueInternalUse;
  this.SwitchChars = rtl.createSet(45);
  this.FindCmdLineSwitch = function (ASwitch) {
    var Result = false;
    Result = $mod.FindCmdLineSwitch$2(ASwitch,$mod.SwitchChars,true);
    return Result;
  };
  this.FindCmdLineSwitch$1 = function (ASwitch, AIgnoreCase) {
    var Result = false;
    Result = $mod.FindCmdLineSwitch$2(ASwitch,$mod.SwitchChars,AIgnoreCase);
    return Result;
  };
  this.FindCmdLineSwitch$2 = function (ASwitch, AChars, AIgnoreCase) {
    var Result = false;
    var lSameSwitch = null;
    var lSwitch = "";
    var lSwitches = [];
    var lValue = "";
    if (AIgnoreCase) {
      lSameSwitch = $mod.AnsiSameText}
     else lSameSwitch = $impl.EqualsStr;
    lSwitches = $impl.ParseCmdLine();
    for (var $in = lSwitches, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
      lValue = $in[$l];
      if (rtl.eqSet(AChars,{}) || $mod.CharInSet$1(lValue.charAt(0),AChars)) {
        lSwitch = $mod.TStringHelper.Substring.call({get: function () {
            return lValue;
          }, set: function (v) {
            lValue = v;
          }},1);
        if (lSameSwitch(lSwitch,ASwitch)) return true;
      };
    };
    Result = false;
    return Result;
  };
  var cDeli$1 = ":";
  this.FindCmdLineSwitch$3 = function (ASwitch, AValue, AIgnoreCase, ASwitchTypes) {
    var Result = false;
    var lCompare = null;
    var lCount = 0;
    var lParam = "";
    var lSwitches = [];
    var lSwitchLen = 0;
    var lValueOfs = 0;
    Result = false;
    AValue.set($mod.TStringHelper.Empty);
    if (AIgnoreCase) {
      lCompare = $mod.SameText}
     else lCompare = $mod.SameStr;
    lSwitchLen = $mod.TStringHelper.GetLength.call({get: function () {
        return ASwitch;
      }, set: function (v) {
        rtl.raiseE("EPropReadOnly");
      }});
    lSwitches = $impl.ParseCmdLine();
    for (var $l = 0, $end = rtl.length(lSwitches) - 1; $l <= $end; $l++) {
      lCount = $l;
      lParam = lSwitches[lCount];
      if (!$mod.CharInSet$1($mod.TStringHelper.GetChar.call({get: function () {
          return lParam;
        }, set: function (v) {
          lParam = v;
        }},0),$mod.SwitchChars)) continue;
      if (!lCompare($mod.TStringHelper.Substring$1.call({get: function () {
          return lParam;
        }, set: function (v) {
          lParam = v;
        }},1,lSwitchLen),ASwitch)) continue;
      if ($mod.TStringHelper.GetLength.call({get: function () {
          return lParam;
        }, set: function (v) {
          lParam = v;
        }}) > (lSwitchLen + 1)) {
        if (!($mod.TCmdLineSwitchType.clstValueAppended in ASwitchTypes)) continue;
        lValueOfs = lSwitchLen + 1;
        if ($mod.TStringHelper.GetChar.call({get: function () {
            return lParam;
          }, set: function (v) {
            lParam = v;
          }},lValueOfs) === cDeli$1) lValueOfs += 1;
        AValue.set($mod.TStringHelper.Substring$1.call({get: function () {
            return lParam;
          }, set: function (v) {
            lParam = v;
          }},lValueOfs,2147483647));
      } else if (($mod.TCmdLineSwitchType.clstValueNextParam in ASwitchTypes) && (lCount < (rtl.length(lSwitches) - 1)) && !$mod.CharInSet$1($mod.TStringHelper.GetChar.call({a: lCount + 1, p: lSwitches, get: function () {
          return this.p[this.a];
        }, set: function (v) {
          this.p[this.a] = v;
        }},0),$mod.SwitchChars)) AValue.set(lSwitches[lCount + 1]);
      Result = true;
      break;
    };
    return Result;
  };
  this.$rtti.$RefToProcVar("TProc",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$RefToProcVar("TProc<System.Boolean>",{procsig: rtl.newTIProcSig([["AArg1",rtl.boolean]])});
  this.$rtti.$RefToProcVar("TProc<System.Longint>",{procsig: rtl.newTIProcSig([["AArg1",rtl.longint]])});
  $mod.$implcode = function () {
    rtl.createHelper($impl,"TBytesHelper",null,function () {
      this.GetLength = function () {
        var Result = 0;
        Result = rtl.length(this.get());
        return Result;
      };
      this.SetLength = function (AValue) {
        this.set(rtl.arraySetLength(this.get(),0,AValue));
      };
      this.High = function () {
        var Result = 0;
        Result = rtl.length(this.get()) - 1;
        return Result;
      };
      this.Low = function () {
        var Result = 0;
        Result = 0;
        return Result;
      };
      this.SubBytes = function (AStartIndex, ALength) {
        var Result = [];
        Result = rtl.arrayCopy(0,this.get(),AStartIndex,ALength);
        return Result;
      };
    });
    $mod.$rtti.$DynArray("TWords",{eltype: rtl.word});
    rtl.createHelper($impl,"TWordsHelper",null,function () {
      this.GetLength = function () {
        var Result = 0;
        Result = rtl.length(this.get());
        return Result;
      };
      this.SetLength = function (AValue) {
        this.set(rtl.arraySetLength(this.get(),0,AValue));
      };
      var cBytesPerWord = 2;
      this.FromBytes = function (ABytes) {
        var Result = [];
        var lCount = 0;
        var lLow = 0;
        var lHigh = 0;
        lCount = $impl.TBytesHelper.GetLength.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }});
        if (pas.System.Odd(lCount)) lCount += 1;
        $impl.TWordsHelper.SetLength.call({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},rtl.trunc(lCount / 2));
        lCount = $impl.TBytesHelper.Low.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }});
        while (lCount <= $impl.TBytesHelper.High.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }})) {
          lLow = ABytes[lCount];
          if ((lCount + 1) <= $impl.TBytesHelper.High.call({get: function () {
              return ABytes;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }})) {
            lHigh = ABytes[lCount + 1]}
           else lHigh = 0;
          Result[rtl.trunc(lCount / 2)] = $mod.TWordHelper.FromBytes(lLow,lHigh);
          lCount += 2;
        };
        return Result;
      };
      this.High = function () {
        var Result = 0;
        Result = rtl.length(this.get()) - 1;
        return Result;
      };
      this.Low = function () {
        var Result = 0;
        Result = 0;
        return Result;
      };
      var cBytesPerWord$1 = 2;
      this.ToBytes = function () {
        var Result = [];
        var lLow = 0;
        var lHigh = 0;
        var lCount = 0;
        var lNewIndex = 0;
        $impl.TBytesHelper.SetLength.call({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},$impl.TWordsHelper.GetLength.call(this) * 2);
        for (var $l = $impl.TWordsHelper.Low.call(this), $end = $impl.TWordsHelper.High.call(this); $l <= $end; $l++) {
          lCount = $l;
          $mod.TWordHelper.ToBytes.call({a: lCount, p: this.get(), get: function () {
              return this.p[this.a];
            }, set: function (v) {
              this.p[this.a] = v;
            }},{get: function () {
              return lLow;
            }, set: function (v) {
              lLow = v;
            }},{get: function () {
              return lHigh;
            }, set: function (v) {
              lHigh = v;
            }});
          lNewIndex = lCount * 2;
          Result[lNewIndex] = lLow;
          Result[lNewIndex + 1] = lHigh;
        };
        return Result;
      };
    });
    $impl.DefaultShortMonthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    $impl.DefaultLongMonthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
    $impl.DefaultShortDayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
    $impl.DefaultLongDayNames = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    $impl.FInvariant = $mod.TFormatSettings.$new();
    $impl.FInvariantCreated = false;
    $impl.DoShowException = function (S) {
      if ($mod.OnShowException != null) {
        $mod.OnShowException(S)}
       else {
        window.alert(S);
      };
    };
    $mod.$rtti.$ProcVar("TRTLExceptionHandler",{procsig: rtl.newTIProcSig([["aError",rtl.jsvalue]])});
    $impl.OnPascalException = null;
    $impl.OnJSException = null;
    $impl.RTLExceptionHook = function (aError) {
      var S = "";
      if (pas.JS.isClassInstance(aError)) {
        if ($impl.OnPascalException != null) {
          $impl.OnPascalException(rtl.getObject(aError))}
         else $mod.ShowException(rtl.getObject(aError),null);
      } else if (rtl.isObject(aError)) {
        if ($impl.OnJSException != null) {
          $impl.OnJSException(aError)}
         else {
          if (aError.hasOwnProperty("message")) {
            S = rtl.getResStr($mod,"SErrUnknownExceptionType") + ("" + aError["message"])}
           else S = rtl.getResStr($mod,"SErrUnknownExceptionType") + aError.toString();
          $impl.DoShowException(S);
        };
      } else {
        S = rtl.getResStr($mod,"SErrUnknownExceptionType") + ("" + aError);
        $impl.DoShowException(S);
      };
    };
    $impl.CheckBoolStrs = function () {
      if (rtl.length($mod.TrueBoolStrs) === 0) {
        $mod.TrueBoolStrs = rtl.arraySetLength($mod.TrueBoolStrs,"",1);
        $mod.TrueBoolStrs[0] = "True";
      };
      if (rtl.length($mod.FalseBoolStrs) === 0) {
        $mod.FalseBoolStrs = rtl.arraySetLength($mod.FalseBoolStrs,"",1);
        $mod.FalseBoolStrs[0] = "False";
      };
    };
    $impl.feInvalidFormat = 1;
    $impl.feMissingArgument = 2;
    $impl.feInvalidArgIndex = 3;
    $impl.DoFormatError = function (ErrCode, fmt) {
      var $tmp = ErrCode;
      if ($tmp === 1) {
        throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidFormat"),pas.System.VarRecs(18,fmt)])}
       else if ($tmp === 2) {
        throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SArgumentMissing"),pas.System.VarRecs(18,fmt)])}
       else if ($tmp === 3) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidArgIndex"),pas.System.VarRecs(18,fmt)]);
    };
    $impl.maxdigits = 15;
    $impl.ReplaceDecimalSep = function (S, DS) {
      var Result = "";
      var P = 0;
      P = pas.System.Pos(".",S);
      if (P > 0) {
        Result = pas.System.Copy(S,1,P - 1) + DS + pas.System.Copy(S,P + 1,S.length - P)}
       else Result = S;
      return Result;
    };
    $impl.FormatGeneralFloat = function (Value, Precision, DS) {
      var Result = "";
      var P = 0;
      var PE = 0;
      var Q = 0;
      var Exponent = 0;
      if ((Precision === -1) || (Precision > 15)) Precision = 15;
      Result = rtl.floatToStr(Value,Precision + 7);
      Result = $mod.TrimLeft(Result);
      P = pas.System.Pos(".",Result);
      if (P === 0) return Result;
      PE = pas.System.Pos("E",Result);
      if (PE === 0) {
        Result = $impl.ReplaceDecimalSep(Result,DS);
        return Result;
      };
      Q = PE + 2;
      Exponent = 0;
      while (Q <= Result.length) {
        Exponent = ((Exponent * 10) + Result.charCodeAt(Q - 1)) - 48;
        Q += 1;
      };
      if (Result.charAt((PE + 1) - 1) === "-") Exponent = -Exponent;
      if (((P + Exponent) < PE) && (Exponent > -6)) {
        Result = rtl.strSetLength(Result,PE - 1);
        if (Exponent >= 0) {
          for (var $l = 0, $end = Exponent - 1; $l <= $end; $l++) {
            Q = $l;
            Result = rtl.setCharAt(Result,P - 1,Result.charAt((P + 1) - 1));
            P += 1;
          };
          Result = rtl.setCharAt(Result,P - 1,".");
          P = 1;
          if (Result.charAt(P - 1) === "-") P += 1;
          while ((Result.charAt(P - 1) === "0") && (P < Result.length) && (pas.System.Copy(Result,P + 1,DS.length) !== DS)) pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P,1);
        } else {
          pas.System.Insert(pas.System.Copy("00000",1,-Exponent),{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P - 1);
          Result = rtl.setCharAt(Result,P - Exponent - 1,Result.charAt(P - Exponent - 1 - 1));
          Result = rtl.setCharAt(Result,P - 1,".");
          if (Exponent !== -1) Result = rtl.setCharAt(Result,P - Exponent - 1 - 1,"0");
        };
        Q = Result.length;
        while ((Q > 0) && (Result.charAt(Q - 1) === "0")) Q -= 1;
        if (Result.charAt(Q - 1) === ".") Q -= 1;
        if ((Q === 0) || ((Q === 1) && (Result.charAt(0) === "-"))) {
          Result = "0"}
         else Result = rtl.strSetLength(Result,Q);
      } else {
        while (Result.charAt(PE - 1 - 1) === "0") {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},PE - 1,1);
          PE -= 1;
        };
        if (Result.charAt(PE - 1 - 1) === DS) {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},PE - 1,1);
          PE -= 1;
        };
        if (Result.charAt((PE + 1) - 1) === "+") {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},PE + 1,1)}
         else PE += 1;
        while (Result.charAt((PE + 1) - 1) === "0") pas.System.Delete({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},PE + 1,1);
      };
      Result = $impl.ReplaceDecimalSep(Result,DS);
      return Result;
    };
    $impl.FormatExponentFloat = function (Value, Precision, Digits, DS) {
      var Result = "";
      var P = 0;
      DS = $mod.FormatSettings.DecimalSeparator;
      if ((Precision === -1) || (Precision > 15)) Precision = 15;
      Result = rtl.floatToStr(Value,Precision + 7);
      while (Result.charAt(0) === " ") pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      P = pas.System.Pos("E",Result);
      if (P === 0) {
        Result = $impl.ReplaceDecimalSep(Result,DS);
        return Result;
      };
      P += 2;
      if (Digits > 4) Digits = 4;
      Digits = (Result.length - P - Digits) + 1;
      if (Digits < 0) {
        pas.System.Insert(pas.System.Copy("0000",1,-Digits),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},P)}
       else while ((Digits > 0) && (Result.charAt(P - 1) === "0")) {
        pas.System.Delete({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},P,1);
        if (P > Result.length) {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P - 2,2);
          break;
        };
        Digits -= 1;
      };
      Result = $impl.ReplaceDecimalSep(Result,DS);
      return Result;
    };
    $impl.FormatFixedFloat = function (Value, Digits, DS) {
      var Result = "";
      if (Digits === -1) {
        Digits = 2}
       else if (Digits > 18) Digits = 18;
      Result = rtl.floatToStr(Value,0,Digits);
      if ((Result !== "") && (Result.charAt(0) === " ")) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      Result = $impl.ReplaceDecimalSep(Result,DS);
      return Result;
    };
    $impl.FormatNumberFloat = function (Value, Digits, DS, TS) {
      var Result = "";
      var P = 0;
      if (Digits === -1) {
        Digits = 2}
       else if (Digits > 15) Digits = 15;
      Result = rtl.floatToStr(Value,0,Digits);
      if ((Result !== "") && (Result.charAt(0) === " ")) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      P = pas.System.Pos(".",Result);
      if (P <= 0) P = Result.length + 1;
      Result = $impl.ReplaceDecimalSep(Result,DS);
      P -= 3;
      if ((TS !== "") && (TS !== "\x00")) while (P > 1) {
        if (Result.charAt(P - 1 - 1) !== "-") pas.System.Insert(TS,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},P);
        P -= 3;
      };
      return Result;
    };
    $impl.RemoveLeadingNegativeSign = function (AValue, DS, aThousandSeparator) {
      var Result = false;
      var i = 0;
      var TS = "";
      var StartPos = 0;
      Result = false;
      StartPos = 2;
      TS = aThousandSeparator;
      for (var $l = StartPos, $end = AValue.get().length; $l <= $end; $l++) {
        i = $l;
        Result = (AValue.get().charCodeAt(i - 1) in rtl.createSet(48,DS.charCodeAt(),69,43)) || (AValue.get().charAt(i - 1) === TS);
        if (!Result) break;
      };
      if (Result && (AValue.get().charAt(0) === "-")) pas.System.Delete(AValue,1,1);
      return Result;
    };
    $impl.FormatNumberCurrency = function (Value, Digits, aSettings) {
      var Result = "";
      var Negative = false;
      var P = 0;
      var CS = "";
      var DS = "";
      var TS = "";
      DS = aSettings.DecimalSeparator;
      TS = aSettings.ThousandSeparator;
      CS = aSettings.CurrencyString;
      if (Digits === -1) {
        Digits = aSettings.CurrencyDecimals}
       else if (Digits > 18) Digits = 18;
      Result = rtl.floatToStr(Value / 10000,0,Digits);
      Negative = Result.charAt(0) === "-";
      if (Negative) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      P = pas.System.Pos(".",Result);
      if (TS !== "") {
        if (P !== 0) {
          Result = $impl.ReplaceDecimalSep(Result,DS)}
         else P = Result.length + 1;
        P -= 3;
        while (P > 1) {
          pas.System.Insert(TS,{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P);
          P -= 3;
        };
      };
      if (Negative) $impl.RemoveLeadingNegativeSign({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},DS,TS);
      if (!Negative) {
        var $tmp = aSettings.CurrencyFormat;
        if ($tmp === 0) {
          Result = CS + Result}
         else if ($tmp === 1) {
          Result = Result + CS}
         else if ($tmp === 2) {
          Result = CS + " " + Result}
         else if ($tmp === 3) Result = Result + " " + CS;
      } else {
        var $tmp1 = aSettings.NegCurrFormat;
        if ($tmp1 === 0) {
          Result = "(" + CS + Result + ")"}
         else if ($tmp1 === 1) {
          Result = "-" + CS + Result}
         else if ($tmp1 === 2) {
          Result = CS + "-" + Result}
         else if ($tmp1 === 3) {
          Result = CS + Result + "-"}
         else if ($tmp1 === 4) {
          Result = "(" + Result + CS + ")"}
         else if ($tmp1 === 5) {
          Result = "-" + Result + CS}
         else if ($tmp1 === 6) {
          Result = Result + "-" + CS}
         else if ($tmp1 === 7) {
          Result = Result + CS + "-"}
         else if ($tmp1 === 8) {
          Result = "-" + Result + " " + CS}
         else if ($tmp1 === 9) {
          Result = "-" + CS + " " + Result}
         else if ($tmp1 === 10) {
          Result = Result + " " + CS + "-"}
         else if ($tmp1 === 11) {
          Result = CS + " " + Result + "-"}
         else if ($tmp1 === 12) {
          Result = CS + " " + "-" + Result}
         else if ($tmp1 === 13) {
          Result = Result + "-" + " " + CS}
         else if ($tmp1 === 14) {
          Result = "(" + CS + " " + Result + ")"}
         else if ($tmp1 === 15) Result = "(" + Result + " " + CS + ")";
      };
      return Result;
    };
    $impl.RESpecials = "([\\$\\+\\[\\]\\(\\)\\\\\\.\\*\\^\\?\\|])";
    $impl.DoEncodeDate = function (Year, Month, Day) {
      var Result = 0;
      var D = 0.0;
      if ($mod.TryEncodeDate(Year,Month,Day,{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }})) {
        Result = pas.System.Trunc(D)}
       else Result = 0;
      return Result;
    };
    $impl.DoEncodeTime = function (Hour, Minute, Second, MilliSecond) {
      var Result = 0.0;
      if (!$mod.TryEncodeTime(Hour,Minute,Second,MilliSecond,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = 0;
      return Result;
    };
    $mod.$rtti.$StaticArray("DateTimeToStrFormat$a",{dims: [2], eltype: rtl.string});
    $impl.DateTimeToStrFormat = ["c","f"];
    var WhiteSpace = " \b\t\n\f\r";
    var Digits = "0123456789";
    $impl.IntStrToDate = function (ErrorMsg, S, useformat, separator) {
      var Result = 0.0;
      function FixErrorMsg(errmarg) {
        ErrorMsg.set($mod.Format(rtl.getResStr(pas.RTLConsts,"SInvalidDateFormat"),pas.System.VarRecs(18,errmarg)));
      };
      var df = "";
      var d = 0;
      var m = 0;
      var y = 0;
      var ly = 0;
      var ld = 0;
      var lm = 0;
      var n = 0;
      var i = 0;
      var len = 0;
      var c = 0;
      var dp = 0;
      var mp = 0;
      var yp = 0;
      var which = 0;
      var s1 = "";
      var values = [];
      var YearMoreThenTwoDigits = false;
      values = rtl.arraySetLength(values,0,4);
      Result = 0;
      len = S.length;
      ErrorMsg.set("");
      while ((len > 0) && (pas.System.Pos(S.charAt(len - 1),WhiteSpace) > 0)) len -= 1;
      if (len === 0) {
        FixErrorMsg(S);
        return Result;
      };
      YearMoreThenTwoDigits = false;
      if (separator === "\x00") if ($mod.FormatSettings.DateSeparator !== "\x00") {
        separator = $mod.FormatSettings.DateSeparator}
       else separator = "-";
      df = $mod.UpperCase(useformat);
      yp = 0;
      mp = 0;
      dp = 0;
      which = 0;
      i = 0;
      while ((i < df.length) && (which < 3)) {
        i += 1;
        var $tmp = df.charAt(i - 1);
        if ($tmp === "Y") {
          if (yp === 0) {
            which += 1;
            yp = which;
          }}
         else if ($tmp === "M") {
          if (mp === 0) {
            which += 1;
            mp = which;
          }}
         else if ($tmp === "D") if (dp === 0) {
          which += 1;
          dp = which;
        };
      };
      for (i = 1; i <= 3; i++) values[i] = 0;
      s1 = "";
      n = 0;
      for (var $l = 1, $end = len; $l <= $end; $l++) {
        i = $l;
        if (pas.System.Pos(S.charAt(i - 1),Digits) > 0) s1 = s1 + S.charAt(i - 1);
        if ((separator !== " ") && (S.charAt(i - 1) === " ")) continue;
        if ((S.charAt(i - 1) === separator) || ((i === len) && (pas.System.Pos(S.charAt(i - 1),Digits) > 0))) {
          n += 1;
          if (n > 3) {
            FixErrorMsg(S);
            return Result;
          };
          if ((n === yp) && (s1.length > 2)) YearMoreThenTwoDigits = true;
          pas.System.val$6(s1,{a: n, p: values, get: function () {
              return this.p[this.a];
            }, set: function (v) {
              this.p[this.a] = v;
            }},{get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
          if (c !== 0) {
            FixErrorMsg(S);
            return Result;
          };
          s1 = "";
        } else if (pas.System.Pos(S.charAt(i - 1),Digits) === 0) {
          FixErrorMsg(S);
          return Result;
        };
      };
      if ((which < 3) && (n > which)) {
        FixErrorMsg(S);
        return Result;
      };
      $mod.DecodeDate($mod.Date(),{get: function () {
          return ly;
        }, set: function (v) {
          ly = v;
        }},{get: function () {
          return lm;
        }, set: function (v) {
          lm = v;
        }},{get: function () {
          return ld;
        }, set: function (v) {
          ld = v;
        }});
      if (n === 3) {
        y = values[yp];
        m = values[mp];
        d = values[dp];
      } else {
        y = ly;
        if (n < 2) {
          d = values[1];
          m = lm;
        } else if (dp < mp) {
          d = values[1];
          m = values[2];
        } else {
          d = values[2];
          m = values[1];
        };
      };
      if ((y >= 0) && (y < 100) && !YearMoreThenTwoDigits) {
        ly = ly - $mod.TwoDigitYearCenturyWindow;
        y += rtl.trunc(ly / 100) * 100;
        if (($mod.TwoDigitYearCenturyWindow > 0) && (y < ly)) y += 100;
      };
      if (!$mod.TryEncodeDate(y,m,d,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) ErrorMsg.set(rtl.getResStr(pas.RTLConsts,"SErrInvalidDate"));
      return Result;
    };
    var AMPM_None = 0;
    var AMPM_AM = 1;
    var AMPM_PM = 2;
    var tiHour = 0;
    var tiMin = 1;
    var tiSec = 2;
    var tiMSec = 3;
    var Digits$1 = "0123456789";
    $impl.IntStrToTime = function (ErrorMsg, S, Len, aSettings) {
      var Result = 0.0;
      var AmPm = 0;
      var TimeValues = [];
      function SplitElements(TimeValues, AmPm) {
        var Result = false;
        var Cur = 0;
        var Offset = 0;
        var ElemLen = 0;
        var Err = 0;
        var TimeIndex = 0;
        var FirstSignificantDigit = 0;
        var Value = 0;
        var DigitPending = false;
        var MSecPending = false;
        var AmPmStr = "";
        var CurChar = "\x00";
        var I = 0;
        var allowedchars = "";
        Result = false;
        AmPm.set(0);
        MSecPending = false;
        TimeIndex = 0;
        for (I = 0; I <= 3; I++) TimeValues.get()[I] = 0;
        Cur = 1;
        while ((Cur < Len) && (S.charAt(Cur - 1) === " ")) Cur += 1;
        Offset = Cur;
        if ((Cur > (Len - 1)) || (S.charAt(Cur - 1) === aSettings.TimeSeparator) || (S.charAt(Cur - 1) === aSettings.DecimalSeparator)) {
          return Result;
        };
        DigitPending = pas.System.Pos(S.charAt(Cur - 1),Digits$1) > 0;
        while (Cur <= Len) {
          CurChar = S.charAt(Cur - 1);
          if (pas.System.Pos(CurChar,Digits$1) > 0) {
            if (!DigitPending || (TimeIndex > 3)) {
              return Result;
            };
            Offset = Cur;
            if (CurChar !== "0") {
              FirstSignificantDigit = Offset}
             else FirstSignificantDigit = -1;
            while ((Cur < Len) && (pas.System.Pos(S.charAt((Cur + 1) - 1),Digits$1) > 0)) {
              if ((FirstSignificantDigit === -1) && (S.charAt(Cur - 1) !== "0")) FirstSignificantDigit = Cur;
              Cur += 1;
            };
            if (FirstSignificantDigit === -1) FirstSignificantDigit = Cur;
            ElemLen = (1 + Cur) - FirstSignificantDigit;
            if ((ElemLen <= 2) || ((ElemLen <= 3) && (TimeIndex === 3))) {
              pas.System.val$6(pas.System.Copy(S,FirstSignificantDigit,ElemLen),{get: function () {
                  return Value;
                }, set: function (v) {
                  Value = v;
                }},{get: function () {
                  return Err;
                }, set: function (v) {
                  Err = v;
                }});
              TimeValues.get()[TimeIndex] = Value;
              TimeIndex += 1;
              DigitPending = false;
            } else {
              return Result;
            };
          } else if (CurChar === " ") {}
          else if (CurChar === aSettings.TimeSeparator) {
            if (DigitPending || (TimeIndex > 2)) {
              return Result;
            };
            DigitPending = true;
            MSecPending = false;
          } else if (CurChar === aSettings.DecimalSeparator) {
            if (DigitPending || MSecPending || (TimeIndex !== 3)) {
              return Result;
            };
            DigitPending = true;
            MSecPending = true;
          } else {
            if ((AmPm.get() !== 0) || DigitPending) {
              return Result;
            };
            Offset = Cur;
            allowedchars = aSettings.DecimalSeparator + " ";
            if (aSettings.TimeSeparator !== "\x00") allowedchars = allowedchars + aSettings.TimeSeparator;
            while ((Cur < Len) && (pas.System.Pos(S.charAt((Cur + 1) - 1),allowedchars) === 0) && (pas.System.Pos(S.charAt((Cur + 1) - 1),Digits$1) === 0)) Cur += 1;
            ElemLen = (1 + Cur) - Offset;
            AmPmStr = pas.System.Copy(S,Offset,ElemLen);
            if ($mod.CompareText(AmPmStr,aSettings.TimeAMString) === 0) {
              AmPm.set(1)}
             else if ($mod.CompareText(AmPmStr,aSettings.TimePMString) === 0) {
              AmPm.set(2)}
             else if ($mod.CompareText(AmPmStr,"AM") === 0) {
              AmPm.set(1)}
             else if ($mod.CompareText(AmPmStr,"PM") === 0) {
              AmPm.set(2)}
             else {
              return Result;
            };
            if (TimeIndex === 0) {
              DigitPending = true;
            } else {
              TimeIndex = 3 + 1;
              DigitPending = false;
            };
          };
          Cur += 1;
        };
        if ((TimeIndex === 0) || ((AmPm.get() !== 0) && ((TimeValues.get()[0] > 12) || (TimeValues.get()[0] === 0))) || DigitPending) return Result;
        Result = true;
        return Result;
      };
      TimeValues = rtl.arraySetLength(TimeValues,0,4);
      AmPm = 0;
      if (!SplitElements({get: function () {
          return TimeValues;
        }, set: function (v) {
          TimeValues = v;
        }},{get: function () {
          return AmPm;
        }, set: function (v) {
          AmPm = v;
        }})) {
        ErrorMsg.set($mod.Format(rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeFormat"),pas.System.VarRecs(18,S)));
        return Result;
      };
      if ((AmPm === 2) && (TimeValues[0] !== 12)) {
        TimeValues[0] += 12}
       else if ((AmPm === 1) && (TimeValues[0] === 12)) TimeValues[0] = 0;
      if (!$mod.TryEncodeTime(TimeValues[0],TimeValues[1],TimeValues[2],TimeValues[3],{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) ErrorMsg.set($mod.Format(rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeFormat"),pas.System.VarRecs(18,S)));
      return Result;
    };
    var WhiteSpace$1 = "\t\n\r ";
    $impl.SplitDateTimeStr = function (DateTimeStr, DateStr, TimeStr, aSettings) {
      var Result = 0;
      var p = 0;
      var DummyDT = 0.0;
      Result = 0;
      DateStr.set("");
      TimeStr.set("");
      DateTimeStr = $mod.Trim(DateTimeStr);
      if (DateTimeStr.length === 0) return Result;
      if ((aSettings.DateSeparator === " ") && (aSettings.TimeSeparator === " ") && (pas.System.Pos(" ",DateTimeStr) > 0)) {
        DateStr.set(DateTimeStr);
        return 1;
      };
      p = 1;
      if (aSettings.DateSeparator !== " ") {
        while ((p < DateTimeStr.length) && !(pas.System.Pos(DateTimeStr.charAt((p + 1) - 1),WhiteSpace$1) > 0)) p += 1;
      } else {
        p = pas.System.Pos(aSettings.TimeSeparator,DateTimeStr);
        if (p !== 0) do {
          p -= 1;
        } while (!((p === 0) || (pas.System.Pos(DateTimeStr.charAt(p - 1),WhiteSpace$1) > 0)));
      };
      if (p === 0) p = DateTimeStr.length;
      DateStr.set(pas.System.Copy(DateTimeStr,1,p));
      TimeStr.set($mod.Trim(pas.System.Copy(DateTimeStr,p + 1,100)));
      if (TimeStr.get().length !== 0) {
        Result = 2}
       else {
        Result = 1;
        if (((aSettings.DateSeparator !== aSettings.TimeSeparator) && (pas.System.Pos(aSettings.TimeSeparator,DateStr.get()) > 0)) || ((aSettings.DateSeparator === aSettings.TimeSeparator) && !$mod.TryStrToDate(DateStr.get(),{get: function () {
            return DummyDT;
          }, set: function (v) {
            DummyDT = v;
          }}))) {
          TimeStr.set(DateStr.get());
          DateStr.set("");
        };
      };
      return Result;
    };
    $impl.IntTryStrToInt = function (S, res, aSep) {
      var Result = false;
      var Radix = 10;
      var N = "";
      var J = undefined;
      N = S;
      if ((pas.System.Pos(aSep,N) !== 0) || (pas.System.Pos(".",N) !== 0) || (pas.System.Pos(":",N) !== 0) || (pas.System.Pos("-",N) > 1)) return false;
      var $tmp = pas.System.Copy(N,1,1);
      if ($tmp === "$") {
        Radix = 16}
       else if ($tmp === "&") {
        Radix = 8}
       else if ($tmp === "%") Radix = 2;
      if ((Radix !== 16) && (pas.System.Pos("e",$mod.LowerCase(N)) !== 0)) return false;
      if (Radix !== 10) pas.System.Delete({get: function () {
          return N;
        }, set: function (v) {
          N = v;
        }},1,1);
      J = parseInt(N,Radix);
      Result = !isNaN(J);
      if (Result) res.set(rtl.trunc(J));
      return Result;
    };
    $impl.InitGlobalFormatSettings = function () {
      $mod.FormatSettings.$assign($mod.TFormatSettings.Create());
      $mod.TimeSeparator = $mod.FormatSettings.TimeSeparator;
      $mod.DateSeparator = $mod.FormatSettings.DateSeparator;
      $mod.ShortDateFormat = $mod.FormatSettings.ShortDateFormat;
      $mod.LongDateFormat = $mod.FormatSettings.LongDateFormat;
      $mod.ShortTimeFormat = $mod.FormatSettings.ShortTimeFormat;
      $mod.LongTimeFormat = $mod.FormatSettings.LongTimeFormat;
      $mod.DecimalSeparator = $mod.FormatSettings.DecimalSeparator;
      $mod.ThousandSeparator = $mod.FormatSettings.ThousandSeparator;
      $mod.TimeAMString = $mod.FormatSettings.TimeAMString;
      $mod.TimePMString = $mod.FormatSettings.TimePMString;
      $mod.CurrencyFormat = $mod.FormatSettings.CurrencyFormat;
      $mod.NegCurrFormat = $mod.FormatSettings.NegCurrFormat;
      $mod.CurrencyDecimals = $mod.FormatSettings.CurrencyDecimals;
      $mod.CurrencyString = $mod.FormatSettings.CurrencyString;
    };
    $impl.NotImplemented = function (S) {
      throw $mod.Exception.$create("Create$1",["Not yet implemented : " + S]);
    };
    $impl.HaveChar = function (AChar, AList) {
      var Result = false;
      var I = 0;
      I = 0;
      Result = false;
      while (!Result && (I < rtl.length(AList))) {
        Result = AList[I] === AChar;
        I += 1;
      };
      return Result;
    };
    rtl.recNewT($impl,"TFloatParts",function () {
      this.sign = false;
      this.exp = 0;
      this.mantissa = 0.0;
      this.$eq = function (b) {
        return (this.sign === b.sign) && (this.exp === b.exp) && (this.mantissa === b.mantissa);
      };
      this.$assign = function (s) {
        this.sign = s.sign;
        this.exp = s.exp;
        this.mantissa = s.mantissa;
        return this;
      };
      var $r = $mod.$rtti.$Record("TFloatParts",{},this);
      $r.addField("sign",rtl.boolean);
      $r.addField("exp",rtl.longint);
      $r.addField("mantissa",rtl.double);
    });
    $impl.FloatToParts = function (aValue) {
      var Result = $impl.TFloatParts.$new();
      var F = null;
      var B = null;
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = aValue;
      Result.sign = (B[7] >>> 7) === 0;
      Result.exp = (((B[7] & 0x7f) << 4) | (B[6] >>> 4)) - 0x3ff;
      B[3] = 0x3F;
      B[6] = B[6] | 0xF0;
      Result.mantissa = F[0];
      return Result;
    };
    $impl.EqualsStr = function (AValue1, AValue2) {
      var Result = false;
      Result = AValue1 === AValue2;
      return Result;
    };
    var cBlank = " ";
    $impl.ParseCmdLine = function () {
      var Result = [];
      var lCount = 0;
      var lParam = "";
      var lExtraParam = "";
      var lBuffer = "";
      var lChar = "\x00";
      var lIndex = 0;
      Result = [];
      for (var $l = 1, $end = pas.System.ParamCount(); $l <= $end; $l++) {
        lCount = $l;
        lParam = pas.System.ParamStr(lCount);
        lBuffer = $mod.TStringHelper.Substring.call({get: function () {
            return lParam;
          }, set: function (v) {
            lParam = v;
          }},1);
        lExtraParam = $mod.TStringHelper.Empty;
        for (var $l1 in $mod.SwitchChars) {
          lChar = String.fromCharCode($l1);
          lIndex = $mod.TStringHelper.IndexOf$1.call({get: function () {
              return lBuffer;
            }, set: function (v) {
              lBuffer = v;
            }},cBlank + lChar);
          if (lIndex >= 0) {
            lExtraParam = $mod.TStringHelper.TrimLeft.call({a: $mod.TStringHelper.Substring.call({get: function () {
                  return lParam;
                }, set: function (v) {
                  lParam = v;
                }},lIndex + 1), get: function () {
                return this.a;
              }, set: function (v) {
                this.a = v;
              }});
            lParam = $mod.TStringHelper.TrimRight.call({a: $mod.TStringHelper.Substring$1.call({get: function () {
                  return lParam;
                }, set: function (v) {
                  lParam = v;
                }},0,lIndex + 1), get: function () {
                return this.a;
              }, set: function (v) {
                this.a = v;
              }});
            break;
          };
        };
        Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 1);
        Result[rtl.length(Result) - 1] = lParam;
        if (!$mod.TStringHelper.IsEmpty.call({get: function () {
            return lExtraParam;
          }, set: function (v) {
            lExtraParam = v;
          }})) {
          Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 1);
          Result[rtl.length(Result) - 1] = lExtraParam;
        };
      };
      return Result;
    };
    $mod.$resourcestrings = {SAbortError: {org: "Operation aborted"}, SApplicationException: {org: "Application raised an exception: "}, SErrUnknownExceptionType: {org: "Caught unknown exception type : "}};
  };
  $mod.$init = function () {
    (function () {
      $impl.InitGlobalFormatSettings();
    })();
    $mod.ShortMonthNames = $impl.DefaultShortMonthNames.slice(0);
    $mod.LongMonthNames = $impl.DefaultLongMonthNames.slice(0);
    $mod.ShortDayNames = $impl.DefaultShortDayNames.slice(0);
    $mod.LongDayNames = $impl.DefaultLongDayNames.slice(0);
  };
},[]);
rtl.module("TypInfo",["System","SysUtils","Types","RTLConsts","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TCallConv = {"0": "ccReg", ccReg: 0, "1": "ccCdecl", ccCdecl: 1, "2": "ccPascal", ccPascal: 2, "3": "ccStdCall", ccStdCall: 3, "4": "ccSafeCall", ccSafeCall: 4, "5": "ccCppdecl", ccCppdecl: 5, "6": "ccFar16", ccFar16: 6, "7": "ccOldFPCCall", ccOldFPCCall: 7, "8": "ccInternProc", ccInternProc: 8, "9": "ccSysCall", ccSysCall: 9, "10": "ccSoftFloat", ccSoftFloat: 10, "11": "ccMWPascal", ccMWPascal: 11};
  this.$rtti.$Enum("TCallConv",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TCallConv});
  this.$rtti.$ExtClass("TSectionRTTI",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "rtl.tSectionRTTI"});
  this.$rtti.$ExtClass("TTypeInfoModule",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "pasmodule"});
  this.$rtti.$inherited("TTypeInfoAttributes",pas.Types.$rtti["TJSValueDynArray"],{});
  this.$rtti.$ExtClass("TTypeInfo",{jsclass: "rtl.tTypeInfo"});
  this.$rtti.$ClassRef("TTypeInfoClassOf",{instancetype: this.$rtti["TTypeInfo"]});
  this.TOrdType = {"0": "otSByte", otSByte: 0, "1": "otUByte", otUByte: 1, "2": "otSWord", otSWord: 2, "3": "otUWord", otUWord: 3, "4": "otSLong", otSLong: 4, "5": "otULong", otULong: 5, "6": "otSIntDouble", otSIntDouble: 6, "7": "otUIntDouble", otUIntDouble: 7};
  this.$rtti.$Enum("TOrdType",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TOrdType});
  this.$rtti.$ExtClass("TTypeInfoInteger",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoInteger"});
  this.$rtti.$ExtClass("TEnumType",{jsclass: "anonymous"});
  this.$rtti.$ExtClass("TTypeInfoEnum",{ancestor: this.$rtti["TTypeInfoInteger"], jsclass: "rtl.tTypeInfoEnum"});
  this.$rtti.$ExtClass("TTypeInfoSet",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoSet"});
  this.$rtti.$ExtClass("TTypeInfoStaticArray",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoStaticArray"});
  this.$rtti.$ExtClass("TTypeInfoDynArray",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoDynArray"});
  this.TParamFlag = {"0": "pfVar", pfVar: 0, "1": "pfConst", pfConst: 1, "2": "pfOut", pfOut: 2, "3": "pfArray", pfArray: 3, "4": "pfAddress", pfAddress: 4, "5": "pfReference", pfReference: 5};
  this.$rtti.$Enum("TParamFlag",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TParamFlag});
  this.$rtti.$Set("TParamFlags",{comptype: this.$rtti["TParamFlag"]});
  this.$rtti.$ExtClass("TProcedureParam",{jsclass: "anonymous"});
  this.$rtti.$DynArray("TProcedureParams",{eltype: this.$rtti["TProcedureParam"]});
  this.TProcedureFlag = {"0": "pfStatic", pfStatic: 0, "1": "pfVarargs", pfVarargs: 1, "2": "pfExternal", pfExternal: 2, "3": "pfSafeCall", pfSafeCall: 3, "4": "pfAsync", pfAsync: 4};
  this.$rtti.$Enum("TProcedureFlag",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TProcedureFlag});
  this.$rtti.$Set("TProcedureFlags",{comptype: this.$rtti["TProcedureFlag"]});
  this.$rtti.$ExtClass("TProcedureSignature",{jsclass: "anonymous"});
  this.$rtti.$ExtClass("TTypeInfoProcVar",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoProcVar"});
  this.$rtti.$ExtClass("TTypeInfoRefToProcVar",{ancestor: this.$rtti["TTypeInfoProcVar"], jsclass: "rtl.tTypeInfoRefToProcVar"});
  this.TMethodKind = {"0": "mkProcedure", mkProcedure: 0, "1": "mkFunction", mkFunction: 1, "2": "mkConstructor", mkConstructor: 2, "3": "mkDestructor", mkDestructor: 3, "4": "mkClassProcedure", mkClassProcedure: 4, "5": "mkClassFunction", mkClassFunction: 5};
  this.$rtti.$Enum("TMethodKind",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TMethodKind});
  this.$rtti.$Set("TMethodKinds",{comptype: this.$rtti["TMethodKind"]});
  this.$rtti.$ExtClass("TTypeInfoMethodVar",{ancestor: this.$rtti["TTypeInfoProcVar"], jsclass: "rtl.tTypeInfoMethodVar"});
  this.TTypeMemberKind = {"0": "tmkUnknown", tmkUnknown: 0, "1": "tmkField", tmkField: 1, "2": "tmkMethod", tmkMethod: 2, "3": "tmkProperty", tmkProperty: 3};
  this.$rtti.$Enum("TTypeMemberKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTypeMemberKind});
  this.$rtti.$Set("TTypeMemberKinds",{comptype: this.$rtti["TTypeMemberKind"]});
  this.$rtti.$ExtClass("TTypeMember",{jsclass: "rtl.tTypeMember"});
  this.$rtti.$DynArray("TTypeMemberDynArray",{eltype: this.$rtti["TTypeMember"]});
  this.$rtti.$ExtClass("TTypeMemberField",{ancestor: this.$rtti["TTypeMember"], jsclass: "rtl.tTypeMemberField"});
  this.$rtti.$ExtClass("TTypeMemberMethod",{ancestor: this.$rtti["TTypeMember"], jsclass: "rtl.tTypeMemberMethod"});
  this.$rtti.$DynArray("TTypeMemberMethodDynArray",{eltype: this.$rtti["TTypeMemberMethod"]});
  this.pfGetFunction = 1;
  this.pfSetProcedure = 2;
  this.pfStoredFalse = 4;
  this.pfStoredField = 8;
  this.pfStoredFunction = 12;
  this.pfHasIndex = 16;
  this.$rtti.$ExtClass("TTypeMemberProperty",{ancestor: this.$rtti["TTypeMember"], jsclass: "rtl.tTypeMemberProperty"});
  this.$rtti.$DynArray("TTypeMemberPropertyDynArray",{eltype: this.$rtti["TTypeMemberProperty"]});
  this.$rtti.$ExtClass("TTypeMembers",{jsclass: "rtl.tTypeMembers"});
  this.$rtti.$ExtClass("TTypeInfoStruct",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoStruct"});
  this.$rtti.$ExtClass("TTypeInfoRecord",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoRecord"});
  this.$rtti.$ExtClass("TTypeInfoClass",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoClass"});
  this.$rtti.$ExtClass("TTypeInfoExtClass",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoExtClass"});
  this.$rtti.$ExtClass("TTypeInfoClassRef",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoClassRef"});
  this.$rtti.$ExtClass("TTypeInfoPointer",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoPointer"});
  this.$rtti.$ExtClass("TInterfaceInfo",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TTypeInfoInterface",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoInterface"});
  this.$rtti.$ExtClass("TTypeInfoHelper",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoHelper"});
  this.$rtti.$ExtClass("TReferenceVariable",{jsclass: "Object"});
  this.$rtti.$ExtClass("TInterfaceObject",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  rtl.createClass(this,"EPropertyError",pas.SysUtils.Exception,function () {
  });
  this.GetTypeName = function (TypeInfo) {
    var Result = "";
    Result = TypeInfo.name;
    return Result;
  };
  this.GetClassMembers = function (aTIStruct) {
    var Result = [];
    var C = null;
    var i = 0;
    var PropName = "";
    var Names = null;
    Result = [];
    Names = new Object();
    C = aTIStruct;
    while (C !== null) {
      for (var $l = 0, $end = rtl.length(C.names) - 1; $l <= $end; $l++) {
        i = $l;
        PropName = C.names[i];
        if (Names.hasOwnProperty(PropName)) continue;
        Result.push(C.members[PropName]);
        Names[PropName] = true;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    return Result;
  };
  this.GetClassMember = function (aTIStruct, aName) {
    var Result = null;
    var C = null;
    var i = 0;
    C = aTIStruct;
    while (C !== null) {
      if (C.members.hasOwnProperty(aName)) return C.members[aName];
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    C = aTIStruct;
    while (C !== null) {
      for (var $l = 0, $end = rtl.length(C.names) - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.CompareText(C.names[i],aName) === 0) return C.members[C.names[i]];
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    Result = null;
    return Result;
  };
  this.GetInstanceMethod = function (Instance, aName) {
    var Result = null;
    var TI = null;
    if (Instance === null) return null;
    TI = $mod.GetClassMember(Instance.$rtti,aName);
    if (!rtl.isExt(TI,rtl.tTypeMemberMethod)) return null;
    Result = rtl.createCallback(Instance,TI.name);
    return Result;
  };
  this.GetClassMethods = function (aTIStruct) {
    var Result = [];
    var C = null;
    var i = 0;
    var Cnt = 0;
    var j = 0;
    Cnt = 0;
    C = aTIStruct;
    while (C !== null) {
      Cnt += C.methods.length;
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    Result = rtl.arraySetLength(Result,null,Cnt);
    C = aTIStruct;
    i = 0;
    while (C !== null) {
      for (var $l = 0, $end = C.methods.length - 1; $l <= $end; $l++) {
        j = $l;
        Result[i] = C.members[C.methods[j]];
        i += 1;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    return Result;
  };
  this.GetInterfaceMembers = function (aTIInterface) {
    var Result = [];
    var Intf = null;
    var i = 0;
    var Cnt = 0;
    var j = 0;
    Cnt = 0;
    Intf = aTIInterface;
    while (Intf !== null) {
      Cnt += rtl.length(Intf.names);
      Intf = Intf.ancestor;
    };
    Result = rtl.arraySetLength(Result,null,Cnt);
    Intf = aTIInterface;
    i = 0;
    while (Intf !== null) {
      for (var $l = 0, $end = rtl.length(Intf.names) - 1; $l <= $end; $l++) {
        j = $l;
        Result[i] = Intf.members[Intf.names[j]];
        i += 1;
      };
      Intf = Intf.ancestor;
    };
    return Result;
  };
  this.GetInterfaceMember = function (aTIInterface, aName) {
    var Result = null;
    var Intf = null;
    var i = 0;
    Intf = aTIInterface;
    while (Intf !== null) {
      if (Intf.members.hasOwnProperty(aName)) return Intf.members[aName];
      Intf = Intf.ancestor;
    };
    Intf = aTIInterface;
    while (Intf !== null) {
      for (var $l = 0, $end = rtl.length(Intf.names) - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.CompareText(Intf.names[i],aName) === 0) return Intf.members[Intf.names[i]];
      };
      Intf = Intf.ancestor;
    };
    Result = null;
    return Result;
  };
  this.GetInterfaceMethods = function (aTIInterface) {
    var Result = [];
    var Intf = null;
    var i = 0;
    var Cnt = 0;
    var j = 0;
    Cnt = 0;
    Intf = aTIInterface;
    while (Intf !== null) {
      Cnt += Intf.methods.length;
      Intf = Intf.ancestor;
    };
    Result = rtl.arraySetLength(Result,null,Cnt);
    Intf = aTIInterface;
    i = 0;
    while (Intf !== null) {
      for (var $l = 0, $end = Intf.methods.length - 1; $l <= $end; $l++) {
        j = $l;
        Result[i] = Intf.members[Intf.methods[j]];
        i += 1;
      };
      Intf = Intf.ancestor;
    };
    return Result;
  };
  this.GetRTTIAttributes = function (Attributes) {
    var Result = [];
    var i = 0;
    var len = 0;
    var AttrClass = null;
    var ProcName = "";
    var Attr = null;
    Result = [];
    if (Attributes == undefined) return Result;
    i = 0;
    len = rtl.length(Attributes);
    while (i < len) {
      AttrClass = rtl.getObject(Attributes[i]);
      i += 1;
      ProcName = "" + Attributes[i];
      i += 1;
      if ((i < len) && rtl.isArray(Attributes[i])) {
        Attr = AttrClass.$create(ProcName,Attributes[i]);
        i += 1;
      } else Attr = AttrClass.$create(ProcName);
      Result = rtl.arrayInsert(Attr,Result,rtl.length(Result));
    };
    return Result;
  };
  this.GetPropInfos = function (aTIStruct) {
    var Result = [];
    var C = null;
    var i = 0;
    var Names = null;
    var PropName = "";
    Result = [];
    C = aTIStruct;
    Names = new Object();
    while (C !== null) {
      for (var $l = 0, $end = C.properties.length - 1; $l <= $end; $l++) {
        i = $l;
        PropName = C.properties[i];
        if (Names.hasOwnProperty(PropName)) continue;
        Result.push(C.members[PropName]);
        Names[PropName] = true;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    return Result;
  };
  this.GetPropList = function (aTIStruct, TypeKinds, Sorted) {
    var Result = [];
    function NameSort(a, b) {
      var Result = 0;
      if (a.name < b.name) {
        Result = -1}
       else if (a.name > b.name) {
        Result = 1}
       else Result = 0;
      return Result;
    };
    var C = null;
    var i = 0;
    var Names = null;
    var PropName = "";
    var Prop = null;
    Result = [];
    C = aTIStruct;
    Names = new Object();
    while (C !== null) {
      for (var $l = 0, $end = C.properties.length - 1; $l <= $end; $l++) {
        i = $l;
        PropName = C.properties[i];
        if (Names.hasOwnProperty(PropName)) continue;
        Prop = C.members[PropName];
        if (!(Prop.typeinfo.kind in TypeKinds)) continue;
        Result.push(Prop);
        Names[PropName] = true;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    if (Sorted) Result.sort(NameSort);
    return Result;
  };
  this.GetPropList$1 = function (aTIStruct) {
    var Result = [];
    Result = $mod.GetPropInfos(aTIStruct);
    return Result;
  };
  this.GetPropList$2 = function (AClass) {
    var Result = [];
    Result = $mod.GetPropInfos(AClass.$rtti);
    return Result;
  };
  this.GetPropList$3 = function (Instance) {
    var Result = [];
    Result = $mod.GetPropList$2(Instance.$class.ClassType());
    return Result;
  };
  this.GetPropInfo = function (TI, PropName) {
    var Result = null;
    var m = null;
    var i = 0;
    var C = null;
    C = TI;
    while (C !== null) {
      m = C.members[PropName];
      if (rtl.isExt(m,rtl.tTypeMemberProperty)) return m;
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    Result = null;
    do {
      for (var $l = 0, $end = TI.properties.length - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.CompareText(PropName,TI.properties[i]) === 0) {
          m = TI.members[TI.properties[i]];
          if (rtl.isExt(m,rtl.tTypeMemberProperty)) Result = m;
          return Result;
        };
      };
      if (!rtl.isExt(TI,rtl.tTypeInfoClass)) break;
      TI = TI.ancestor;
    } while (!(TI === null));
    return Result;
  };
  this.GetPropInfo$1 = function (TI, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo(TI,PropName);
    if (rtl.neSet(Kinds,{}) && (Result !== null) && !(Result.typeinfo.kind in Kinds)) Result = null;
    return Result;
  };
  this.GetPropInfo$2 = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo$1(Instance.$rtti,PropName,{});
    return Result;
  };
  this.GetPropInfo$3 = function (Instance, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(Instance.$rtti,PropName,Kinds);
    return Result;
  };
  this.GetPropInfo$4 = function (aClass, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo$1(aClass.$rtti,PropName,{});
    return Result;
  };
  this.GetPropInfo$5 = function (aClass, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(aClass.$rtti,PropName,Kinds);
    return Result;
  };
  this.FindPropInfo = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo(Instance.$rtti,PropName);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.FindPropInfo$1 = function (Instance, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(Instance.$rtti,PropName,Kinds);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.FindPropInfo$2 = function (aClass, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo(aClass.$rtti,PropName);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.FindPropInfo$3 = function (aClass, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(aClass.$rtti,PropName,Kinds);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.IsStoredProp = function (Instance, PropInfo) {
    var Result = false;
    var $tmp = PropInfo.flags & 12;
    if ($tmp === 0) {
      Result = true}
     else if ($tmp === 4) {
      Result = false}
     else if ($tmp === 8) {
      Result = !(Instance[PropInfo.stored] == false)}
     else {
      Result = Instance[PropInfo.stored]();
    };
    return Result;
  };
  this.IsStoredProp$1 = function (Instance, PropName) {
    var Result = false;
    Result = $mod.IsStoredProp(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.IsPublishedProp = function (Instance, PropName) {
    var Result = false;
    Result = $mod.GetPropInfo$2(Instance,PropName) !== null;
    return Result;
  };
  this.IsPublishedProp$1 = function (aClass, PropName) {
    var Result = false;
    Result = $mod.GetPropInfo$4(aClass,PropName) !== null;
    return Result;
  };
  this.PropType = function (Instance, PropName) {
    var Result = 0;
    Result = $mod.FindPropInfo(Instance,PropName).typeinfo.kind;
    return Result;
  };
  this.PropType$1 = function (aClass, PropName) {
    var Result = 0;
    Result = $mod.FindPropInfo$2(aClass,PropName).typeinfo.kind;
    return Result;
  };
  this.PropIsType = function (Instance, PropName, TypeKind) {
    var Result = false;
    Result = $mod.PropType(Instance,PropName) === TypeKind;
    return Result;
  };
  this.PropIsType$1 = function (aClass, PropName, TypeKind) {
    var Result = false;
    Result = $mod.PropType$1(aClass,PropName) === TypeKind;
    return Result;
  };
  this.GetJSValueProp = function (Instance, TI, PropName) {
    var Result = undefined;
    var PropInfo = null;
    PropInfo = $mod.GetPropInfo(TI,PropName);
    if (PropInfo === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    Result = $mod.GetJSValueProp$1(Instance,PropInfo);
    return Result;
  };
  this.GetJSValueProp$1 = function (Instance, PropInfo) {
    var Result = undefined;
    var gk = 0;
    gk = $impl.GetPropGetterKind(PropInfo);
    var $tmp = gk;
    if ($tmp === $impl.TGetterKind.gkNone) {
      throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantReadPropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
     else if ($tmp === $impl.TGetterKind.gkField) {
      Result = Instance[PropInfo.getter]}
     else if ($tmp === $impl.TGetterKind.gkFunction) {
      if ((16 & PropInfo.flags) > 0) {
        Result = Instance[PropInfo.getter](PropInfo.index)}
       else Result = Instance[PropInfo.getter]()}
     else if ($tmp === $impl.TGetterKind.gkFunctionWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
    return Result;
  };
  this.GetJSValueProp$2 = function (Instance, PropName) {
    var Result = undefined;
    Result = $mod.GetJSValueProp$3(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetJSValueProp$3 = function (Instance, PropInfo) {
    var Result = undefined;
    Result = $mod.GetJSValueProp$1(Instance,PropInfo);
    return Result;
  };
  this.SetJSValueProp = function (Instance, TI, PropName, Value) {
    var PropInfo = null;
    PropInfo = $mod.GetPropInfo(TI,PropName);
    if (PropInfo === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    $mod.SetJSValueProp$1(Instance,PropInfo,Value);
  };
  this.SetJSValueProp$1 = function (Instance, PropInfo, Value) {
    var sk = 0;
    sk = $impl.GetPropSetterKind(PropInfo);
    var $tmp = sk;
    if ($tmp === $impl.TSetterKind.skNone) {
      throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantWritePropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
     else if ($tmp === $impl.TSetterKind.skField) {
      Instance[PropInfo.setter] = Value}
     else if ($tmp === $impl.TSetterKind.skProcedure) {
      if ((16 & PropInfo.flags) > 0) {
        Instance[PropInfo.setter](PropInfo.index,Value)}
       else Instance[PropInfo.setter](Value)}
     else if ($tmp === $impl.TSetterKind.skProcedureWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
  };
  this.SetJSValueProp$2 = function (Instance, PropName, Value) {
    $mod.SetJSValueProp$3(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetJSValueProp$3 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$1(Instance,PropInfo,Value);
  };
  this.GetNativeIntProp = function (Instance, PropName) {
    var Result = 0;
    Result = $mod.GetNativeIntProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetNativeIntProp$1 = function (Instance, PropInfo) {
    var Result = 0;
    Result = rtl.trunc($mod.GetJSValueProp$3(Instance,PropInfo));
    return Result;
  };
  this.SetNativeIntProp = function (Instance, PropName, Value) {
    $mod.SetJSValueProp$3(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetNativeIntProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetOrdProp = function (Instance, PropName) {
    var Result = 0;
    Result = $mod.GetOrdProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetOrdProp$1 = function (Instance, PropInfo) {
    var Result = 0;
    var o = null;
    var Key = "";
    var n = 0;
    var v = undefined;
    if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkSet) {
      o = $mod.GetJSValueProp$3(Instance,PropInfo);
      Result = 0;
      for (Key in o) {
        n = parseInt(Key,10);
        if (n < 32) Result = Result + (1 << n);
      };
    } else if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkChar) {
      v = $mod.GetJSValueProp$3(Instance,PropInfo);
      if (rtl.isNumber(v)) {
        Result = rtl.trunc(v)}
       else {
        Key = "" + v;
        if (Key === "") {
          Result = 0}
         else Result = Key.charCodeAt(0);
      };
    } else Result = rtl.trunc($mod.GetJSValueProp$3(Instance,PropInfo));
    return Result;
  };
  this.SetOrdProp = function (Instance, PropName, Value) {
    $mod.SetOrdProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetOrdProp$1 = function (Instance, PropInfo, Value) {
    var o = null;
    var i = 0;
    if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkSet) {
      o = new Object();
      for (i = 0; i <= 31; i++) if (((1 << i) & Value) > 0) o["" + i] = true;
      $mod.SetJSValueProp$3(Instance,PropInfo,o);
    } else if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkChar) {
      $mod.SetJSValueProp$3(Instance,PropInfo,String.fromCharCode(Value))}
     else $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetEnumProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetEnumProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetEnumProp$1 = function (Instance, PropInfo) {
    var Result = "";
    var n = 0;
    var TIEnum = null;
    TIEnum = rtl.asExt(PropInfo.typeinfo,rtl.tTypeInfoEnum);
    n = rtl.trunc($mod.GetJSValueProp$3(Instance,PropInfo));
    if ((n >= TIEnum.minvalue) && (n <= TIEnum.maxvalue)) {
      Result = TIEnum.enumtype[n]}
     else Result = "" + n;
    return Result;
  };
  this.SetEnumProp = function (Instance, PropName, Value) {
    $mod.SetEnumProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetEnumProp$1 = function (Instance, PropInfo, Value) {
    var TIEnum = null;
    var n = 0;
    TIEnum = rtl.asExt(PropInfo.typeinfo,rtl.tTypeInfoEnum);
    n = TIEnum.enumtype[Value];
    if (!pas.JS.isUndefined(n)) $mod.SetJSValueProp$3(Instance,PropInfo,n);
  };
  this.GetEnumName = function (TypeInfo, Value) {
    var Result = "";
    Result = TypeInfo.enumtype[Value];
    return Result;
  };
  this.GetEnumValue = function (TypeInfo, Name) {
    var Result = 0;
    Result = TypeInfo.enumtype[Name];
    return Result;
  };
  this.GetEnumNameCount = function (TypeInfo) {
    var Result = 0;
    var o = null;
    var l = 0;
    var r = 0;
    o = TypeInfo.enumtype;
    Result = 1;
    while (o.hasOwnProperty("" + Result)) Result = Result * 2;
    l = rtl.trunc(Result / 2);
    r = Result;
    while (l <= r) {
      Result = rtl.trunc((l + r) / 2);
      if (o.hasOwnProperty("" + Result)) {
        l = Result + 1}
       else r = Result - 1;
    };
    if (o.hasOwnProperty("" + Result)) Result += 1;
    return Result;
  };
  this.GetSetProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetSetProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetSetProp$1 = function (Instance, PropInfo) {
    var Result = "";
    var o = null;
    var key = "";
    var Value = "";
    var n = 0;
    var TIEnum = null;
    var TISet = null;
    Result = "";
    TISet = rtl.asExt(PropInfo.typeinfo,rtl.tTypeInfoSet);
    TIEnum = null;
    if (rtl.isExt(TISet.comptype,rtl.tTypeInfoEnum)) TIEnum = TISet.comptype;
    o = $mod.GetJSValueProp$3(Instance,PropInfo);
    for (key in o) {
      n = parseInt(key,10);
      if ((TIEnum !== null) && (n >= TIEnum.minvalue) && (n <= TIEnum.maxvalue)) {
        Value = TIEnum.enumtype[n]}
       else Value = "" + n;
      if (Result !== "") Result = Result + ",";
      Result = Result + Value;
    };
    Result = "[" + Result + "]";
    return Result;
  };
  this.GetSetPropArray = function (Instance, PropName) {
    var Result = [];
    Result = $mod.GetSetPropArray$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetSetPropArray$1 = function (Instance, PropInfo) {
    var Result = [];
    var o = null;
    var Key = "";
    Result = [];
    o = $mod.GetJSValueProp$3(Instance,PropInfo);
    for (Key in o) Result.push(parseInt(Key,10));
    return Result;
  };
  this.SetSetPropArray = function (Instance, PropName, Arr) {
    $mod.SetSetPropArray$1(Instance,$mod.FindPropInfo(Instance,PropName),Arr);
  };
  this.SetSetPropArray$1 = function (Instance, PropInfo, Arr) {
    var o = null;
    var i = 0;
    o = new Object();
    for (var $in = Arr, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
      i = $in[$l];
      o["" + i] = true;
    };
    $mod.SetJSValueProp$3(Instance,PropInfo,o);
  };
  this.GetBoolProp = function (Instance, PropName) {
    var Result = false;
    Result = $mod.GetBoolProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetBoolProp$1 = function (Instance, PropInfo) {
    var Result = false;
    Result = !($mod.GetJSValueProp$3(Instance,PropInfo) == false);
    return Result;
  };
  this.SetBoolProp = function (Instance, PropName, Value) {
    $mod.SetBoolProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetBoolProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetStrProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetStrProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetStrProp$1 = function (Instance, PropInfo) {
    var Result = "";
    Result = "" + $mod.GetJSValueProp$3(Instance,PropInfo);
    return Result;
  };
  this.SetStrProp = function (Instance, PropName, Value) {
    $mod.SetStrProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetStrProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetStringProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetStrProp(Instance,PropName);
    return Result;
  };
  this.GetStringProp$1 = function (Instance, PropInfo) {
    var Result = "";
    Result = $mod.GetStrProp$1(Instance,PropInfo);
    return Result;
  };
  this.SetStringProp = function (Instance, PropName, Value) {
    $mod.SetStrProp(Instance,PropName,Value);
  };
  this.SetStringProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetStrProp$1(Instance,PropInfo,Value);
  };
  this.GetFloatProp = function (Instance, PropName) {
    var Result = 0.0;
    Result = $mod.GetFloatProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetFloatProp$1 = function (Instance, PropInfo) {
    var Result = 0.0;
    Result = rtl.getNumber($mod.GetJSValueProp$3(Instance,PropInfo));
    return Result;
  };
  this.SetFloatProp = function (Instance, PropName, Value) {
    $mod.SetFloatProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetFloatProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetObjectProp = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetObjectProp$2(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetObjectProp$1 = function (Instance, PropName, MinClass) {
    var Result = null;
    Result = $mod.GetObjectProp$2(Instance,$mod.FindPropInfo(Instance,PropName));
    if ((MinClass !== null) && (Result !== null)) if (!Result.$class.InheritsFrom(MinClass)) Result = null;
    return Result;
  };
  this.GetObjectProp$2 = function (Instance, PropInfo) {
    var Result = null;
    Result = $mod.GetObjectProp$3(Instance,PropInfo,null);
    return Result;
  };
  this.GetObjectProp$3 = function (Instance, PropInfo, MinClass) {
    var Result = null;
    var O = null;
    O = rtl.getObject($mod.GetJSValueProp$3(Instance,PropInfo));
    if ((MinClass !== null) && !O.$class.InheritsFrom(MinClass)) {
      Result = null}
     else Result = O;
    return Result;
  };
  this.SetObjectProp = function (Instance, PropName, Value) {
    $mod.SetObjectProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetObjectProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetMethodProp = function (Instance, PropInfo) {
    var Result = pas.System.TMethod.$new();
    var v = undefined;
    var fn = undefined;
    Result.Code = null;
    Result.Data = null;
    v = $mod.GetJSValueProp$3(Instance,PropInfo);
    if (!rtl.isFunction(v)) return Result;
    Result.Data = v["scope"];
    fn = v["fn"];
    if (rtl.isString(fn)) {
      if (Result.Data !== null) {
        Result.Code = Result.Data["" + fn]}
       else Result.Code = v;
    } else Result.Code = fn;
    return Result;
  };
  this.GetMethodProp$1 = function (Instance, PropName) {
    var Result = pas.System.TMethod.$new();
    Result.$assign($mod.GetMethodProp(Instance,$mod.FindPropInfo(Instance,PropName)));
    return Result;
  };
  this.SetMethodProp = function (Instance, PropInfo, Value) {
    var cb = null;
    var Code = null;
    Code = Value.Code;
    if (Code === null) {
      cb = null}
     else if (rtl.isFunction(Code)) {
      if ((Code["scope"] === Value.Data) && (rtl.isFunction(Code["fn"]) || rtl.isString(Code["fn"]))) {
        cb = Code;
      } else if (rtl.isString(Code["fn"])) {
        cb = rtl.createCallback(Value.Data,"" + Code["fn"])}
       else cb = rtl.createCallback(Value.Data,Code);
    } else cb = rtl.createCallback(Value.Data,Code);
    $mod.SetJSValueProp$3(Instance,PropInfo,cb);
  };
  this.SetMethodProp$1 = function (Instance, PropName, Value) {
    $mod.SetMethodProp(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.GetInterfaceProp = function (Instance, PropName) {
    var Result = null;
    var $ok = false;
    try {
      Result = rtl.setIntfL(Result,$mod.GetInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName)),true);
      $ok = true;
    } finally {
      if (!$ok) rtl._Release(Result);
    };
    return Result;
  };
  this.GetInterfaceProp$1 = function (Instance, PropInfo) {
    var Result = null;
    var gk = 0;
    var $ok = false;
    try {
      if (PropInfo.typeinfo.kind !== pas.System.TTypeKind.tkInterface) throw pas.SysUtils.Exception.$create("Create$1",["Cannot get RAW interface from IInterface interface"]);
      gk = $impl.GetPropGetterKind(PropInfo);
      var $tmp = gk;
      if ($tmp === $impl.TGetterKind.gkNone) {
        throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantReadPropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
       else if ($tmp === $impl.TGetterKind.gkField) {
        Result = rtl.setIntfL(Result,rtl.getObject(Instance[PropInfo.getter]))}
       else if ($tmp === $impl.TGetterKind.gkFunction) {
        if ((16 & PropInfo.flags) > 0) {
          Result = rtl.setIntfL(Result,Instance[PropInfo.getter](PropInfo.index),true)}
         else Result = rtl.setIntfL(Result,Instance[PropInfo.getter](),true)}
       else if ($tmp === $impl.TGetterKind.gkFunctionWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
      $ok = true;
    } finally {
      if (!$ok) rtl._Release(Result);
    };
    return Result;
  };
  this.SetInterfaceProp = function (Instance, PropName, Value) {
    $mod.SetInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetInterfaceProp$1 = function (Instance, PropInfo, Value) {
    var sk = 0;
    var Setter = "";
    if (PropInfo.typeinfo.kind !== pas.System.TTypeKind.tkInterface) throw pas.SysUtils.Exception.$create("Create$1",["Cannot set RAW interface from IInterface interface"]);
    sk = $impl.GetPropSetterKind(PropInfo);
    Setter = PropInfo.setter;
    var $tmp = sk;
    if ($tmp === $impl.TSetterKind.skNone) {
      throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantWritePropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
     else if ($tmp === $impl.TSetterKind.skField) {
      rtl.setIntfP(Instance,Setter,Value)}
     else if ($tmp === $impl.TSetterKind.skProcedure) {
      if ((16 & PropInfo.flags) > 0) {
        Instance[Setter](PropInfo.index,Value)}
       else Instance[Setter](Value)}
     else if ($tmp === $impl.TSetterKind.skProcedureWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
  };
  this.GetRawInterfaceProp = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetRawInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetRawInterfaceProp$1 = function (Instance, PropInfo) {
    var Result = null;
    Result = $mod.GetJSValueProp$3(Instance,PropInfo);
    return Result;
  };
  this.SetRawInterfaceProp = function (Instance, PropName, Value) {
    $mod.SetRawInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetRawInterfaceProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  $mod.$implcode = function () {
    $mod.$rtti.$ExtClass("TCreatorAttribute",{jsclass: "attr"});
    $mod.$rtti.$ClassRef("TCreatorAttributeClass",{instancetype: $mod.$rtti["TCreatorAttribute"]});
    $impl.TGetterKind = {"0": "gkNone", gkNone: 0, "1": "gkField", gkField: 1, "2": "gkFunction", gkFunction: 2, "3": "gkFunctionWithParams", gkFunctionWithParams: 3};
    $mod.$rtti.$Enum("TGetterKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: $impl.TGetterKind});
    $impl.GetPropGetterKind = function (PropInfo) {
      var Result = 0;
      if (PropInfo.getter === "") {
        Result = $impl.TGetterKind.gkNone}
       else if ((1 & PropInfo.flags) > 0) {
        if (rtl.length(PropInfo.params) > 0) {
          Result = $impl.TGetterKind.gkFunctionWithParams}
         else Result = $impl.TGetterKind.gkFunction;
      } else Result = $impl.TGetterKind.gkField;
      return Result;
    };
    $impl.TSetterKind = {"0": "skNone", skNone: 0, "1": "skField", skField: 1, "2": "skProcedure", skProcedure: 2, "3": "skProcedureWithParams", skProcedureWithParams: 3};
    $mod.$rtti.$Enum("TSetterKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: $impl.TSetterKind});
    $impl.GetPropSetterKind = function (PropInfo) {
      var Result = 0;
      if (PropInfo.setter === "") {
        Result = $impl.TSetterKind.skNone}
       else if ((2 & PropInfo.flags) > 0) {
        if (rtl.length(PropInfo.params) > 0) {
          Result = $impl.TSetterKind.skProcedureWithParams}
         else Result = $impl.TSetterKind.skProcedure;
      } else Result = $impl.TSetterKind.skField;
      return Result;
    };
  };
},[]);
rtl.module("Web",["System","Types","JS"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$ExtClass("TJSEvent");
  this.$rtti.$ExtClass("TJSHTMLElement");
  this.$rtti.$ExtClass("TJSWindow");
  this.$rtti.$ExtClass("TJSDOMTokenList");
  this.$rtti.$ExtClass("TJSXPathResult");
  this.$rtti.$ExtClass("TJSNodeList");
  this.$rtti.$ExtClass("TJSDocument");
  this.$rtti.$ExtClass("TJSElement");
  this.$rtti.$ExtClass("TJSCSSStyleSheet");
  this.$rtti.$ExtClass("TJSNodeFilter");
  this.$rtti.$ExtClass("TJSIDBObjectStore");
  this.$rtti.$ExtClass("TIDBDatabase");
  this.$rtti.$ExtClass("TJSIDBRequest");
  this.$rtti.$ExtClass("TJSEventTarget");
  this.$rtti.$ExtClass("TJSMouseEvent");
  this.$rtti.$ExtClass("TJSWheelEvent");
  this.$rtti.$ExtClass("TJSKeyboardEvent");
  this.$rtti.$ExtClass("TJSPointerEvent");
  this.$rtti.$ExtClass("TJSUIEvent");
  this.$rtti.$ExtClass("TJSTouchEvent");
  this.$rtti.$ExtClass("TJSInputEvent");
  this.$rtti.$ExtClass("TJSBlob");
  this.$rtti.$ExtClass("TJSPermissions");
  this.$rtti.$ExtClass("TJSFileSystemFileHandle");
  this.$rtti.$DynArray("TJSFileSystemFileHandleArray",{eltype: this.$rtti["TJSFileSystemFileHandle"]});
  this.$rtti.$ExtClass("TJSFileSystemDirectoryHandle");
  this.$rtti.$DynArray("TJSFileSystemDirectoryHandleArray",{eltype: this.$rtti["TJSFileSystemDirectoryHandle"]});
  this.$rtti.$ExtClass("TJSShowOpenFilePickerOptions");
  this.$rtti.$ExtClass("TJSShowSaveFilePickerOptions");
  this.$rtti.$ExtClass("TJSServiceWorker");
  this.$rtti.$ExtClass("TJSClient");
  this.$rtti.$ExtClass("TJSRequest");
  this.$rtti.$ExtClass("TJSResponse");
  this.$rtti.$ExtClass("TJSServiceWorkerRegistration");
  this.$rtti.$ExtClass("TJSResizeObserver");
  this.$rtti.$RefToProcVar("TJSEventHandler",{procsig: rtl.newTIProcSig([["Event",this.$rtti["TJSEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSRawEventHandler",{procsig: rtl.newTIProcSig([["Event",this.$rtti["TJSEvent"]]],null,8)});
  this.$rtti.$RefToProcVar("TJSUIEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSUIEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSPointerEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPointerEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("THTMLClickEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSMouseEvent"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSEventTarget",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "EventTarget"});
  this.$rtti.$ExtClass("TJSNode",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Node"});
  this.$rtti.$RefToProcVar("TJSNodeListCallBack",{procsig: rtl.newTIProcSig([["currentValue",this.$rtti["TJSNode"]],["currentIndex",rtl.nativeint],["list",this.$rtti["TJSNodeList"]]])});
  this.$rtti.$MethodVar("TJSNodeListEvent",{procsig: rtl.newTIProcSig([["currentValue",this.$rtti["TJSNode"]],["currentIndex",rtl.nativeint],["list",this.$rtti["TJSNodeList"]]]), methodkind: 0});
  this.$rtti.$ExtClass("TJSNodeList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "NodeList"});
  this.$rtti.$ExtClass("TJSAttr",{ancestor: this.$rtti["TJSNode"], jsclass: "Attr"});
  this.$rtti.$ExtClass("TJSNamedNodeMap",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "NamedNodeMap"});
  this.$rtti.$ExtClass("TJSHTMLCollection",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "HTMLCollection"});
  this.$rtti.$ProcVar("TDOMTokenlistCallBack",{procsig: rtl.newTIProcSig([["Current",rtl.jsvalue],["currentIndex",rtl.nativeint],["list",this.$rtti["TJSDOMTokenList"]]])});
  this.$rtti.$ExtClass("TJSDOMTokenList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMTokenList"});
  this.$rtti.$ExtClass("TJSDOMRect",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMRect"});
  rtl.recNewT(this,"TJSClientRect",function () {
    this.left = 0.0;
    this.top = 0.0;
    this.right = 0.0;
    this.bottom = 0.0;
    this.$eq = function (b) {
      return (this.left === b.left) && (this.top === b.top) && (this.right === b.right) && (this.bottom === b.bottom);
    };
    this.$assign = function (s) {
      this.left = s.left;
      this.top = s.top;
      this.right = s.right;
      this.bottom = s.bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSClientRect",{},this);
    $r.addField("left",rtl.double);
    $r.addField("top",rtl.double);
    $r.addField("right",rtl.double);
    $r.addField("bottom",rtl.double);
  });
  this.$rtti.$DynArray("TJSClientRectArray",{eltype: this.$rtti["TJSClientRect"]});
  this.$rtti.$ExtClass("TJSElement",{ancestor: this.$rtti["TJSNode"], jsclass: "Element"});
  rtl.recNewT(this,"TJSElementCreationOptions",function () {
    this.named = "";
    this.$eq = function (b) {
      return this.named === b.named;
    };
    this.$assign = function (s) {
      this.named = s.named;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSElementCreationOptions",{},this);
    $r.addField("named",rtl.string);
  });
  this.$rtti.$ExtClass("TJSDocumentType",{ancestor: this.$rtti["TJSNode"], jsclass: "DocumentType"});
  this.$rtti.$ExtClass("TJSDOMImplementation",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DocumentImplementation"});
  this.$rtti.$ExtClass("TJSLocation",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Location"});
  this.$rtti.$ExtClass("TJSCSSStyleDeclaration");
  this.$rtti.$ExtClass("TJSStyleSheet",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "StyleSheet"});
  this.$rtti.$ExtClass("TJSCSSRule",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CSSRule"});
  this.$rtti.$ExtClass("TJSCSSStyleRule",{ancestor: this.$rtti["TJSCSSRule"], jsclass: "CSSStyleRule"});
  this.$rtti.$ExtClass("TJSCSSRuleList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CSSRuleList"});
  this.$rtti.$ExtClass("TJSCSSStyleSheet",{ancestor: this.$rtti["TJSStyleSheet"], jsclass: "CSSStyleSheet"});
  this.$rtti.$ExtClass("TJSStyleSheetList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "StyleSheetList"});
  this.$rtti.$ExtClass("TJSDocumentFragment",{ancestor: this.$rtti["TJSNode"], jsclass: "DocumentFragment"});
  rtl.recNewT(this,"TJSEventInit",function () {
    this.bubbles = false;
    this.cancelable = false;
    this.scoped = false;
    this.composed = false;
    this.$eq = function (b) {
      return (this.bubbles === b.bubbles) && (this.cancelable === b.cancelable) && (this.scoped === b.scoped) && (this.composed === b.composed);
    };
    this.$assign = function (s) {
      this.bubbles = s.bubbles;
      this.cancelable = s.cancelable;
      this.scoped = s.scoped;
      this.composed = s.composed;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSEventInit",{},this);
    $r.addField("bubbles",rtl.boolean);
    $r.addField("cancelable",rtl.boolean);
    $r.addField("scoped",rtl.boolean);
    $r.addField("composed",rtl.boolean);
  });
  this.$rtti.$ExtClass("TJSEvent",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Event"});
  this.$rtti.$ExtClass("TJSXPathExpression",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "XPathExpression"});
  this.$rtti.$ExtClass("TJSXPathNSResolver",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "XPathNSResolver"});
  this.$rtti.$ExtClass("TJSCharacterData",{ancestor: this.$rtti["TJSNode"], jsclass: "CharacterData"});
  this.$rtti.$ExtClass("TJSProcessingInstruction",{ancestor: this.$rtti["TJSCharacterData"], jsclass: "ProcessingInstruction"});
  this.$rtti.$ExtClass("TJSRange",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Range"});
  this.$rtti.$ExtClass("TJSTreeWalker",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TreeWalker"});
  this.$rtti.$ExtClass("TJSNodeFilter",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "NodeFilter"});
  this.$rtti.$ExtClass("TJSXPathResult",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "XPathResult"});
  this.$rtti.$ExtClass("TJSSelection",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Selection"});
  this.$rtti.$ProcVar("TJSNameSpaceMapperCallback",{procsig: rtl.newTIProcSig([["aNameSpace",rtl.string]],rtl.string)});
  this.$rtti.$ExtClass("TJSHTMLFile");
  this.$rtti.$ExtClass("TJSHTMLFileList");
  this.$rtti.$RefToProcVar("TJSDataTransferItemCallBack",{procsig: rtl.newTIProcSig([["aData",rtl.string]],null,8)});
  this.$rtti.$ExtClass("TJSDataTransferItem",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DataTransferItem"});
  this.$rtti.$ExtClass("TJSDataTransferItemList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DataTransferItemList"});
  this.$rtti.$ExtClass("TJSDataTransfer",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DataTransfer"});
  this.$rtti.$ExtClass("TJSDragEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "DragEvent"});
  this.$rtti.$RefToProcVar("TJSDragDropEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSDragEvent"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSClipBoardEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ClipboardEvent"});
  rtl.createClassExt(this,"TJSFocusEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSAnimationEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSLoadEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  this.$rtti.$ExtClass("TJSErrorEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ErrorEvent"});
  this.$rtti.$ExtClass("TJSPromiseRejectionEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "PromiseRejectionEvent"});
  rtl.createClassExt(this,"TJSPageTransitionEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  this.$rtti.$ExtClass("TJSHashChangeEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "HashChangeEvent"});
  this.$rtti.$ExtClass("TJSPopStateEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "PopStateEvent"});
  this.$rtti.$ExtClass("TJSStorageEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "StorageEvent"});
  this.$rtti.$ExtClass("TJSProgressEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ProgressEvent"});
  this.$rtti.$ExtClass("TJSCloseEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "CloseEvent"});
  this.$rtti.$RefToProcVar("TJSPageTransitionEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPageTransitionEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSHashChangeEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSHashChangeEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSMouseWheelEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSWheelEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSMouseEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSMouseEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("THTMLAnimationEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSAnimationEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSErrorEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSErrorEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSPromiseRejectionEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPromiseRejectionEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSFocusEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSFocusEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSKeyEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSKeyboardEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSLoadEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSLoadEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSPopStateEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPopStateEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSStorageEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSStorageEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSProgressEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSProgressEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSTouchEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSTouchEvent"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSDocument",{ancestor: this.$rtti["TJSNode"], jsclass: "Document"});
  this.$rtti.$ExtClass("TJSConsole",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Console"});
  this.$rtti.$ExtClass("TJSCryptoKey");
  this.$rtti.$ExtClass("TJSSubtleCrypto");
  rtl.recNewT(this,"Algorithm",function () {
    this.name = "";
    this.$eq = function (b) {
      return this.name === b.name;
    };
    this.$assign = function (s) {
      this.name = s.name;
      return this;
    };
    var $r = $mod.$rtti.$Record("Algorithm",{},this);
    $r.addField("name",rtl.string);
  });
  rtl.recNewT(this,"AesCbcParams",function () {
    this.iv = null;
    this.$eq = function (b) {
      return this.iv === b.iv;
    };
    this.$assign = function (s) {
      this.iv = s.iv;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesCbcParams",{},this);
    $r.addField("iv",pas.JS.$rtti["TJSBufferSource"]);
  });
  rtl.recNewT(this,"AesCtrParams",function () {
    this.counter = null;
    this.$eq = function (b) {
      return (this.counter === b.counter) && (this.length === b.length);
    };
    this.$assign = function (s) {
      this.counter = s.counter;
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesCtrParams",{},this);
    $r.addField("counter",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("length",rtl.byte);
  });
  rtl.recNewT(this,"AesGcmParams",function () {
    this.iv = null;
    this.additionalData = null;
    this.tagLength = 0;
    this.$eq = function (b) {
      return (this.iv === b.iv) && (this.additionalData === b.additionalData) && (this.tagLength === b.tagLength);
    };
    this.$assign = function (s) {
      this.iv = s.iv;
      this.additionalData = s.additionalData;
      this.tagLength = s.tagLength;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesGcmParams",{},this);
    $r.addField("iv",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("additionalData",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("tagLength",rtl.byte);
  });
  rtl.recNewT(this,"HmacImportParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return this.hash === b.hash;
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("HmacImportParams",{},this);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"Pbkdf2Params",function () {
    this.salt = null;
    this.iterations = 0;
    this.hash = undefined;
    this.$eq = function (b) {
      return (this.salt === b.salt) && (this.iterations === b.iterations) && (this.hash === b.hash);
    };
    this.$assign = function (s) {
      this.salt = s.salt;
      this.iterations = s.iterations;
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("Pbkdf2Params",{},this);
    $r.addField("salt",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("iterations",rtl.nativeint);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"RsaHashedImportParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return this.hash === b.hash;
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaHashedImportParams",{},this);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"AesKeyGenParams",function () {
    this.$eq = function (b) {
      return this.length === b.length;
    };
    this.$assign = function (s) {
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesKeyGenParams",{},this);
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"HmacKeyGenParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return (this.hash === b.hash) && (this.length === b.length);
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("HmacKeyGenParams",{},this);
    $r.addField("hash",rtl.jsvalue);
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"RsaHashedKeyGenParams",function () {
    this.modulusLength = 0;
    this.publicExponent = null;
    this.hash = undefined;
    this.$eq = function (b) {
      return (this.modulusLength === b.modulusLength) && (this.publicExponent === b.publicExponent) && (this.hash === b.hash);
    };
    this.$assign = function (s) {
      this.modulusLength = s.modulusLength;
      this.publicExponent = s.publicExponent;
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaHashedKeyGenParams",{},this);
    $r.addField("modulusLength",rtl.longint);
    $r.addField("publicExponent",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"RsaOaepParams",function () {
    this.$eq = function (b) {
      return this.label === b.label;
    };
    this.$assign = function (s) {
      this.label = s.label;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaOaepParams",{},this);
    $r.addField("label",pas.JS.$rtti["TJSBufferSource"]);
  });
  rtl.recNewT(this,"RsaPssParams",function () {
    this.saltLength = 0;
    this.$eq = function (b) {
      return this.saltLength === b.saltLength;
    };
    this.$assign = function (s) {
      this.saltLength = s.saltLength;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaPssParams",{},this);
    $r.addField("saltLength",rtl.longint);
  });
  rtl.recNewT(this,"DhKeyGenParams",function () {
    this.prime = null;
    this.generator = null;
    this.$eq = function (b) {
      return (this.prime === b.prime) && (this.generator === b.generator);
    };
    this.$assign = function (s) {
      this.prime = s.prime;
      this.generator = s.generator;
      return this;
    };
    var $r = $mod.$rtti.$Record("DhKeyGenParams",{},this);
    $r.addField("prime",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("generator",pas.JS.$rtti["TJSUint8Array"]);
  });
  rtl.recNewT(this,"EcKeyGenParams",function () {
    this.$eq = function (b) {
      return this.namedCurve === b.namedCurve;
    };
    this.$assign = function (s) {
      this.namedCurve = s.namedCurve;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcKeyGenParams",{},this);
    $r.addField("namedCurve",rtl.string);
  });
  rtl.recNewT(this,"AesDerivedKeyParams",function () {
    this.$eq = function (b) {
      return this.length === b.length;
    };
    this.$assign = function (s) {
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesDerivedKeyParams",{},this);
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"HmacDerivedKeyParams",function () {
    this.$eq = function (b) {
      return this.length === b.length;
    };
    this.$assign = function (s) {
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("HmacDerivedKeyParams",{},this);
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"EcdhKeyDeriveParams",function () {
    this.$eq = function (b) {
      return this.public === b.public;
    };
    this.$assign = function (s) {
      this.public = s.public;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcdhKeyDeriveParams",{},this);
    $r.addField("public",$mod.$rtti["TJSCryptoKey"]);
  });
  rtl.recNewT(this,"DhKeyDeriveParams",function () {
    this.$eq = function (b) {
      return this.public === b.public;
    };
    this.$assign = function (s) {
      this.public = s.public;
      return this;
    };
    var $r = $mod.$rtti.$Record("DhKeyDeriveParams",{},this);
    $r.addField("public",$mod.$rtti["TJSCryptoKey"]);
  });
  rtl.recNewT(this,"DhImportKeyParams",function () {
    this.prime = null;
    this.generator = null;
    this.$eq = function (b) {
      return (this.prime === b.prime) && (this.generator === b.generator);
    };
    this.$assign = function (s) {
      this.prime = s.prime;
      this.generator = s.generator;
      return this;
    };
    var $r = $mod.$rtti.$Record("DhImportKeyParams",{},this);
    $r.addField("prime",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("generator",pas.JS.$rtti["TJSUint8Array"]);
  });
  rtl.recNewT(this,"EcdsaParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return this.hash === b.hash;
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcdsaParams",{},this);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"EcKeyImportParams",function () {
    this.$eq = function (b) {
      return this.namedCurve === b.namedCurve;
    };
    this.$assign = function (s) {
      this.namedCurve = s.namedCurve;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcKeyImportParams",{},this);
    $r.addField("namedCurve",rtl.string);
  });
  rtl.recNewT(this,"HkdfParams",function () {
    this.hash = undefined;
    this.salt = null;
    this.info = null;
    this.$eq = function (b) {
      return (this.hash === b.hash) && (this.salt === b.salt) && (this.info === b.info);
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      this.salt = s.salt;
      this.info = s.info;
      return this;
    };
    var $r = $mod.$rtti.$Record("HkdfParams",{},this);
    $r.addField("hash",rtl.jsvalue);
    $r.addField("salt",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("info",pas.JS.$rtti["TJSBufferSource"]);
  });
  rtl.recNewT(this,"RsaOtherPrimesInfo",function () {
    this.r = "";
    this.d = "";
    this.t = "";
    this.$eq = function (b) {
      return (this.r === b.r) && (this.d === b.d) && (this.t === b.t);
    };
    this.$assign = function (s) {
      this.r = s.r;
      this.d = s.d;
      this.t = s.t;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaOtherPrimesInfo",{},this);
    $r.addField("r",rtl.string);
    $r.addField("d",rtl.string);
    $r.addField("t",rtl.string);
  });
  this.$rtti.$DynArray("TRsaOtherPrimesInfoDynArray",{eltype: this.$rtti["RsaOtherPrimesInfo"]});
  rtl.recNewT(this,"JsonWebKey",function () {
    this.kty = "";
    this.use = "";
    this.alg = "";
    this.ext = false;
    this.crv = "";
    this.x = "";
    this.y = "";
    this.d = "";
    this.n = "";
    this.e = "";
    this.p = "";
    this.q = "";
    this.dp = "";
    this.dq = "";
    this.qi = "";
    this.k = "";
    this.$new = function () {
      var r = Object.create(this);
      r.key_ops = [];
      r.oth = [];
      return r;
    };
    this.$eq = function (b) {
      return (this.kty === b.kty) && (this.use === b.use) && (this.key_ops === b.key_ops) && (this.alg === b.alg) && (this.ext === b.ext) && (this.crv === b.crv) && (this.x === b.x) && (this.y === b.y) && (this.d === b.d) && (this.n === b.n) && (this.e === b.e) && (this.p === b.p) && (this.q === b.q) && (this.dp === b.dp) && (this.dq === b.dq) && (this.qi === b.qi) && (this.oth === b.oth) && (this.k === b.k);
    };
    this.$assign = function (s) {
      this.kty = s.kty;
      this.use = s.use;
      this.key_ops = rtl.arrayRef(s.key_ops);
      this.alg = s.alg;
      this.ext = s.ext;
      this.crv = s.crv;
      this.x = s.x;
      this.y = s.y;
      this.d = s.d;
      this.n = s.n;
      this.e = s.e;
      this.p = s.p;
      this.q = s.q;
      this.dp = s.dp;
      this.dq = s.dq;
      this.qi = s.qi;
      this.oth = rtl.arrayRef(s.oth);
      this.k = s.k;
      return this;
    };
    var $r = $mod.$rtti.$Record("JsonWebKey",{},this);
    $r.addField("kty",rtl.string);
    $r.addField("use",rtl.string);
    $r.addField("key_ops",pas.Types.$rtti["TStringDynArray"]);
    $r.addField("alg",rtl.string);
    $r.addField("ext",rtl.boolean);
    $r.addField("crv",rtl.string);
    $r.addField("x",rtl.string);
    $r.addField("y",rtl.string);
    $r.addField("d",rtl.string);
    $r.addField("n",rtl.string);
    $r.addField("e",rtl.string);
    $r.addField("p",rtl.string);
    $r.addField("q",rtl.string);
    $r.addField("dp",rtl.string);
    $r.addField("dq",rtl.string);
    $r.addField("qi",rtl.string);
    $r.addField("oth",$mod.$rtti["TRsaOtherPrimesInfoDynArray"]);
    $r.addField("k",rtl.string);
  });
  rtl.recNewT(this,"CryptoKeyPair",function () {
    this.publicKey = null;
    this.privateKey = null;
    this.$eq = function (b) {
      return (this.publicKey === b.publicKey) && (this.privateKey === b.privateKey);
    };
    this.$assign = function (s) {
      this.publicKey = s.publicKey;
      this.privateKey = s.privateKey;
      return this;
    };
    var $r = $mod.$rtti.$Record("CryptoKeyPair",{},this);
    $r.addField("publicKey",$mod.$rtti["TJSCryptoKey"]);
    $r.addField("privateKey",$mod.$rtti["TJSCryptoKey"]);
  });
  this.$rtti.$DynArray("TKeyUsageDynArray",{eltype: rtl.string});
  this.$rtti.$ExtClass("TJSCryptoKey",{jsclass: "CryptoKey"});
  this.$rtti.$ExtClass("TJSSubtleCrypto",{jsclass: "SubtleCrypto"});
  this.$rtti.$ExtClass("TJSCrypto",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Crypto"});
  this.$rtti.$ExtClass("TJSHistory",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "History"});
  rtl.createClass(this,"TJSIDBTransactionMode",pas.System.TObject,function () {
    this.readonly = "readonly";
    this.readwrite = "readwrite";
    this.versionchange = "versionchange";
  });
  this.$rtti.$ExtClass("TJSIDBTransaction",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBTransaction"});
  this.$rtti.$ExtClass("TJSIDBKeyRange",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBKeyRange"});
  rtl.recNewT(this,"TJSIDBIndexParameters",function () {
    this.unique = false;
    this.multiEntry = false;
    this.locale = "";
    this.$eq = function (b) {
      return (this.unique === b.unique) && (this.multiEntry === b.multiEntry) && (this.locale === b.locale);
    };
    this.$assign = function (s) {
      this.unique = s.unique;
      this.multiEntry = s.multiEntry;
      this.locale = s.locale;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSIDBIndexParameters",{},this);
    $r.addField("unique",rtl.boolean);
    $r.addField("multiEntry",rtl.boolean);
    $r.addField("locale",rtl.string);
  });
  this.$rtti.$ExtClass("TJSIDBIndex",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBIndex"});
  this.$rtti.$ExtClass("TJSIDBCursorDirection",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBCursorDirection"});
  this.$rtti.$ExtClass("TJSIDBCursor",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBCursor"});
  this.$rtti.$ExtClass("TJSIDBObjectStore",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBObjectStore"});
  this.$rtti.$ExtClass("TJSIDBRequest",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBRequest"});
  this.$rtti.$ExtClass("TJSIDBOpenDBRequest",{ancestor: this.$rtti["TJSIDBRequest"], jsclass: "IDBOpenDBRequest"});
  rtl.recNewT(this,"TJSCreateObjectStoreOptions",function () {
    this.keyPath = undefined;
    this.autoIncrement = false;
    this.$eq = function (b) {
      return (this.keyPath === b.keyPath) && (this.autoIncrement === b.autoIncrement);
    };
    this.$assign = function (s) {
      this.keyPath = s.keyPath;
      this.autoIncrement = s.autoIncrement;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSCreateObjectStoreOptions",{},this);
    $r.addField("keyPath",rtl.jsvalue);
    $r.addField("autoIncrement",rtl.boolean);
  });
  this.$rtti.$ExtClass("TIDBDatabase",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBDatabase"});
  this.$rtti.$ExtClass("TJSIDBFactory",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBFactory"});
  this.$rtti.$ExtClass("TJSStorage",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Storage"});
  this.$rtti.$ExtClass("TJSVisibleItem",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IVisible"});
  this.$rtti.$ExtClass("TJSLocationBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "LocationBar"});
  this.$rtti.$ExtClass("TJSMenuBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "MenuBar"});
  this.$rtti.$ExtClass("TJSToolBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "ToolBar"});
  this.$rtti.$ExtClass("TJSPersonalBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "PersonalBar"});
  this.$rtti.$ExtClass("TJSScrollBars",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "ScrollBars"});
  rtl.recNewT(this,"TJSPositionError",function () {
    this.code = 0;
    this.message = "";
    this.$eq = function (b) {
      return (this.code === b.code) && (this.message === b.message);
    };
    this.$assign = function (s) {
      this.code = s.code;
      this.message = s.message;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSPositionError",{},this);
    $r.addField("code",rtl.longint);
    $r.addField("message",rtl.string);
  });
  rtl.recNewT(this,"TJSPositionOptions",function () {
    this.enableHighAccuracy = false;
    this.timeout = 0;
    this.maximumAge = 0;
    this.$eq = function (b) {
      return (this.enableHighAccuracy === b.enableHighAccuracy) && (this.timeout === b.timeout) && (this.maximumAge === b.maximumAge);
    };
    this.$assign = function (s) {
      this.enableHighAccuracy = s.enableHighAccuracy;
      this.timeout = s.timeout;
      this.maximumAge = s.maximumAge;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSPositionOptions",{},this);
    $r.addField("enableHighAccuracy",rtl.boolean);
    $r.addField("timeout",rtl.longint);
    $r.addField("maximumAge",rtl.longint);
  });
  rtl.recNewT(this,"TJSCoordinates",function () {
    this.latitude = 0.0;
    this.longitude = 0.0;
    this.altitude = 0.0;
    this.accuracy = 0.0;
    this.altitudeAccuracy = 0.0;
    this.heading = 0.0;
    this.speed = 0.0;
    this.$eq = function (b) {
      return (this.latitude === b.latitude) && (this.longitude === b.longitude) && (this.altitude === b.altitude) && (this.accuracy === b.accuracy) && (this.altitudeAccuracy === b.altitudeAccuracy) && (this.heading === b.heading) && (this.speed === b.speed);
    };
    this.$assign = function (s) {
      this.latitude = s.latitude;
      this.longitude = s.longitude;
      this.altitude = s.altitude;
      this.accuracy = s.accuracy;
      this.altitudeAccuracy = s.altitudeAccuracy;
      this.heading = s.heading;
      this.speed = s.speed;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSCoordinates",{},this);
    $r.addField("latitude",rtl.double);
    $r.addField("longitude",rtl.double);
    $r.addField("altitude",rtl.double);
    $r.addField("accuracy",rtl.double);
    $r.addField("altitudeAccuracy",rtl.double);
    $r.addField("heading",rtl.double);
    $r.addField("speed",rtl.double);
  });
  rtl.recNewT(this,"TJSPosition",function () {
    this.timestamp = "";
    this.$new = function () {
      var r = Object.create(this);
      r.coords = $mod.TJSCoordinates.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.coords.$eq(b.coords) && (this.timestamp === b.timestamp);
    };
    this.$assign = function (s) {
      this.coords.$assign(s.coords);
      this.timestamp = s.timestamp;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSPosition",{},this);
    $r.addField("coords",$mod.$rtti["TJSCoordinates"]);
    $r.addField("timestamp",rtl.string);
  });
  this.$rtti.$ProcVar("TJSGeoLocationCallback",{procsig: rtl.newTIProcSig([["aPosition",this.$rtti["TJSPosition"]]])});
  this.$rtti.$MethodVar("TJSGeoLocationEvent",{procsig: rtl.newTIProcSig([["aPosition",this.$rtti["TJSPosition"]]]), methodkind: 0});
  this.$rtti.$ProcVar("TJSGeoLocationErrorCallback",{procsig: rtl.newTIProcSig([["aValue",this.$rtti["TJSPositionError"]]])});
  this.$rtti.$MethodVar("TJSGeoLocationErrorEvent",{procsig: rtl.newTIProcSig([["aValue",this.$rtti["TJSPositionError"]]]), methodkind: 0});
  this.$rtti.$ExtClass("TJSGeoLocation",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "GeoLocation"});
  this.$rtti.$ExtClass("TJSMediaStreamTrack",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "MediaStreamTrack"});
  this.$rtti.$ExtClass("TJSMediaDevices",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "MediaDevices"});
  this.$rtti.$ExtClass("TJSWorker",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Worker"});
  this.$rtti.$ExtClass("TJSMessagePort",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "MessagePort"});
  this.$rtti.$DynArray("TJSMessagePortDynArray",{eltype: this.$rtti["TJSMessagePort"]});
  this.$rtti.$ExtClass("TJSSharedWorker",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "SharedWorker"});
  this.$rtti.$ExtClass("TJSExtendableEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ExtendableEvent"});
  this.$rtti.$ExtClass("TJSExtendableMessageEvent",{ancestor: this.$rtti["TJSExtendableEvent"], jsclass: "ExtendableMessageEvent"});
  this.$rtti.$ExtClass("TJSFetchEvent",{ancestor: this.$rtti["TJSExtendableEvent"], jsclass: "FetchEvent"});
  this.$rtti.$ExtClass("TJSClient",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Client"});
  this.$rtti.$ExtClass("TJSServiceWorker",{ancestor: this.$rtti["TJSWorker"], jsclass: "ServiceWorker"});
  this.$rtti.$ExtClass("TJSNavigationPreloadState",{jsclass: "navigationPreloadState"});
  this.$rtti.$ExtClass("TJSNavigationPreload",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "navigationPreload"});
  this.$rtti.$ExtClass("TJSServiceWorkerRegistration",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ServiceWorkerRegistration"});
  rtl.recNewT(this,"TJSServiceWorkerContainerOptions",function () {
    this.scope = "";
    this.$eq = function (b) {
      return this.scope === b.scope;
    };
    this.$assign = function (s) {
      this.scope = s.scope;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSServiceWorkerContainerOptions",{},this);
    $r.addField("scope",rtl.string);
  });
  this.$rtti.$ExtClass("TJSServiceWorkerContainer",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ServiceWorkerContainer"});
  this.$rtti.$ExtClass("TJSClipboardItemOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSClipBoardItem",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ClipboardItem"});
  this.$rtti.$ExtClass("TJSClipBoard",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Clipboard"});
  this.$rtti.$ExtClass("TJSNavigator",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Navigator"});
  this.$rtti.$ExtClass("TJSTouch",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Touch"});
  this.$rtti.$ExtClass("TJSTouchList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TouchList"});
  this.$rtti.$ExtClass("TJSPerformance",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Performance"});
  this.$rtti.$ExtClass("TJSScreen",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Screen"});
  this.$rtti.$RefToProcVar("TJSParamEnumCallBack",{procsig: rtl.newTIProcSig([["aKey",rtl.string,2],["aValue",rtl.string,2]])});
  this.$rtti.$ExtClass("TJSURLSearchParams",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "URLSearchParams"});
  this.$rtti.$ExtClass("TJSURL",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "URL"});
  this.$rtti.$DynArray("TJSURLDynArray",{eltype: this.$rtti["TJSURL"]});
  this.$rtti.$RefToProcVar("TJSTimerCallBack",{procsig: rtl.newTIProcSig([],null,8)});
  this.$rtti.$StaticArray("Theader",{dims: [2], eltype: rtl.string});
  this.$rtti.$DynArray("THeaderArray",{eltype: this.$rtti["Theader"]});
  this.$rtti.$ExtClass("TJSHTMLHeaders",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Headers"});
  this.$rtti.$ExtClass("TJSMediaQueryList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaQueryList"});
  this.$rtti.$ExtClass("TJSReadableStream",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ReadableStream"});
  this.$rtti.$ExtClass("TJSWritableStream",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "WritableStream"});
  this.$rtti.$ExtClass("TJSBody",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Body"});
  this.$rtti.$ExtClass("TJSResponse",{ancestor: this.$rtti["TJSBody"], jsclass: "Response"});
  this.$rtti.$RefToProcVar("TFrameRequestCallback",{procsig: rtl.newTIProcSig([["aTime",rtl.double]])});
  this.$rtti.$ExtClass("TJSPostMessageOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  rtl.createClass(this,"TJSIdleCallbackOptions",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.timeout = 0;
    };
  });
  this.$rtti.$ExtClass("TJSIdleDeadline",{jsclass: "IdleDeadline"});
  this.$rtti.$ExtClass("TJSCacheDeleteOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSRequest",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Request"});
  this.$rtti.$DynArray("TJSRequestDynArray",{eltype: this.$rtti["TJSRequest"]});
  this.$rtti.$ExtClass("TJSCache",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Cache"});
  this.$rtti.$ExtClass("TJSCacheStorage",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CacheStorage"});
  this.$rtti.$DynArray("TJSWindowArray",{eltype: this.$rtti["TJSWindow"]});
  this.$rtti.$RefToProcVar("TIdleCallbackProc",{procsig: rtl.newTIProcSig([["idleDeadline",this.$rtti["TJSIdleDeadline"]]])});
  this.$rtti.$ExtClass("TJSWindow",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Window"});
  this.$rtti.$ExtClass("TJSCSSStyleDeclaration",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CSSStyleDeclaration"});
  this.$rtti.$ExtClass("TJSScrollIntoViewOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSHTMLElement",{ancestor: this.$rtti["TJSElement"], jsclass: "HTMLElement"});
  this.$rtti.$DynArray("TJSHTMLElementArray",{eltype: this.$rtti["TJSHTMLElement"]});
  this.$rtti.$ExtClass("TJSHTMLDivElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLDivElement"});
  this.$rtti.$ExtClass("TJSHTMLFormControlsCollection",{ancestor: this.$rtti["TJSHTMLCollection"], jsclass: "HTMLFormControlsCollection"});
  this.$rtti.$ExtClass("TJSHTMLFormElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLFormElement"});
  this.$rtti.$ExtClass("TJSValidityState",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ValidityState"});
  rtl.createClassExt(this,"TJSBlobPropertyBag",Object,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
    this.Create$2 = function (aType) {
      this.type = aType;
      return this;
    };
    this.Create$3 = function (aType, aEndings) {
      this.type = aType;
      this.endings = aEndings;
      return this;
    };
  });
  this.$rtti.$ExtClass("TJSBlob",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Blob"});
  this.$rtti.$ExtClass("TJSHTMLFile",{ancestor: this.$rtti["TJSBlob"], jsclass: "File"});
  this.$rtti.$ExtClass("TJSHTMLFileList",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "FileList"});
  this.$rtti.$ExtClass("TJSHTMLInputElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLInputElement"});
  this.$rtti.$ExtClass("TJSDOMSettableTokenList",{ancestor: this.$rtti["TJSDOMTokenList"], jsclass: "DOMSettableTokenList"});
  this.$rtti.$ExtClass("TJSHTMLOutputElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLOutputElement"});
  this.$rtti.$ExtClass("TJSHTMLImageElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "Image"});
  this.$rtti.$ExtClass("TJSHTMLLinkElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLLinkElement"});
  this.$rtti.$ExtClass("TJSHTMLAnchorElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLAnchorElement"});
  this.$rtti.$ExtClass("TJSHTMLMenuElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLMenuElement"});
  this.$rtti.$ExtClass("TJSHTMLButtonElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLButtonElement"});
  this.$rtti.$ExtClass("TJSHTMLLabelElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLLabelElement"});
  this.$rtti.$ExtClass("TJSHTMLTextAreaElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTextAreaElement"});
  this.$rtti.$ExtClass("TJSHTMLEmbedElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLEmbedElement"});
  this.$rtti.$ExtClass("TJSHTMLOptionElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "Option"});
  this.$rtti.$ExtClass("TJSHTMLOptGroupElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLOptGroupElement"});
  this.$rtti.$ExtClass("TJSHTMLOptionsCollection",{ancestor: this.$rtti["TJSHTMLCollection"], jsclass: "HTMLOptionsCollection"});
  this.$rtti.$ExtClass("TJSHTMLSelectElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLSelectElement"});
  this.$rtti.$ExtClass("TJSHTMLTableSectionElement");
  this.$rtti.$ExtClass("TJSHTMLTableRowElement");
  this.$rtti.$ExtClass("TJSHTMLTableElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableElement"});
  this.$rtti.$ExtClass("TJSHTMLTableSectionElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableSectionElement"});
  this.$rtti.$ExtClass("TJSHTMLTableCellElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableCellElement"});
  this.$rtti.$ExtClass("TJSHTMLTableRowElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableRowElement"});
  this.$rtti.$ExtClass("TJSHTMLTableDataCellElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableDataCellElement"});
  this.$rtti.$ExtClass("TJSCanvasRenderingContext2D");
  this.$rtti.$RefToProcVar("THTMLCanvasToBlobCallback",{procsig: rtl.newTIProcSig([["aBlob",this.$rtti["TJSBlob"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSHTMLCanvasElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLCanvasElement"});
  this.$rtti.$ExtClass("TJSHTMLProgressElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLProgressElement"});
  this.$rtti.$ExtClass("TJSDOMException",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMException"});
  this.$rtti.$ExtClass("TJSFileReader",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "FileReader"});
  this.$rtti.$ExtClass("TJSCanvasGradient",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CanvasGradient"});
  this.$rtti.$ExtClass("TJSCanvasPattern",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CanvasPattern"});
  this.$rtti.$ExtClass("TJSPath2D",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Path2D"});
  this.$rtti.$ExtClass("TJSImageData",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ImageData"});
  this.$rtti.$ExtClass("TJSTextMetrics",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TextMetrics"});
  this.$rtti.$ExtClass("TJSCanvasRenderingContext2D",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CanvasRenderingContext2D"});
  this.$rtti.$ExtClass("TJSHTMLIFrameElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLIFrameElement"});
  this.$rtti.$ExtClass("TJSHTMLScriptElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLScriptElement"});
  this.$rtti.$ExtClass("TJSXMLHttpRequestEventTarget",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "XMLHttpRequestEventTarget"});
  this.$rtti.$ExtClass("TJSXMLHttpRequestUpload",{ancestor: this.$rtti["TJSXMLHttpRequestEventTarget"], jsclass: "XMLHttpRequestUpload"});
  this.$rtti.$RefToProcVar("TJSOnReadyStateChangeHandler",{procsig: rtl.newTIProcSig([],null,8)});
  this.$rtti.$ExtClass("TJSXMLHttpRequest",{ancestor: this.$rtti["TJSXMLHttpRequestEventTarget"], jsclass: "XMLHttpRequest"});
  this.$rtti.$ExtClass("TJSUIEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "UIEvent"});
  this.$rtti.$ExtClass("TJSMouseEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "MouseEvent"});
  rtl.recNewT(this,"TJSWheelEventInit",function () {
    this.deltaX = 0.0;
    this.deltaY = 0.0;
    this.deltaZ = 0.0;
    this.deltaMode = 0;
    this.$eq = function (b) {
      return (this.deltaX === b.deltaX) && (this.deltaY === b.deltaY) && (this.deltaZ === b.deltaZ) && (this.deltaMode === b.deltaMode);
    };
    this.$assign = function (s) {
      this.deltaX = s.deltaX;
      this.deltaY = s.deltaY;
      this.deltaZ = s.deltaZ;
      this.deltaMode = s.deltaMode;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSWheelEventInit",{},this);
    $r.addField("deltaX",rtl.double);
    $r.addField("deltaY",rtl.double);
    $r.addField("deltaZ",rtl.double);
    $r.addField("deltaMode",rtl.nativeint);
  });
  this.$rtti.$ExtClass("TJSWheelEvent",{ancestor: this.$rtti["TJSMouseEvent"], jsclass: "WheelEvent"});
  this.$rtti.$ExtClass("TJSPointerEvent",{ancestor: this.$rtti["TJSMouseEvent"], jsclass: "PointerEvent"});
  this.$rtti.$ExtClass("TJSTouchEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "TouchEvent"});
  rtl.createClass(this,"TJSKeyNames",pas.System.TObject,function () {
    this.Alt = "Alt";
    this.AltGraph = "AltGraph";
    this.CapsLock = "CapsLock";
    this.Control = "Control";
    this.Fn = "Fn";
    this.FnLock = "FnLock";
    this.Hyper = "Hyper";
    this.Meta = "Meta";
    this.NumLock = "NumLock";
    this.ScrollLock = "ScrollLock";
    this.Shift = "Shift";
    this.Super = "Super";
    this.Symbol = "Symbol";
    this.SymbolLock = "SymbolLock";
    this.Enter = "Enter";
    this.Tab = "Tab";
    this.Space = "Space";
    this.ArrowDown = "ArrowDown";
    this.ArrowLeft = "ArrowLeft";
    this.ArrowRight = "ArrowRight";
    this.ArrowUp = "ArrowUp";
    this._End = "End";
    this.Home = "Home";
    this.PageDown = "PageDown";
    this.PageUp = "PageUp";
    this.BackSpace = "Backspace";
    this.Clear = "Clear";
    this.Copy = "Copy";
    this.CrSel = "CrSel";
    this.Cut = "Cut";
    this.Delete = "Delete";
    this.EraseEof = "EraseEof";
    this.ExSel = "ExSel";
    this.Insert = "Insert";
    this.Paste = "Paste";
    this.Redo = "Redo";
    this.Undo = "Undo";
    this.Accept = "Accept";
    this.Again = "Again";
    this.Attn = "Attn";
    this.Cancel = "Cancel";
    this.ContextMenu = "Contextmenu";
    this.Escape = "Escape";
    this.Execute = "Execute";
    this.Find = "Find";
    this.Finish = "Finish";
    this.Help = "Help";
    this.Pause = "Pause";
    this.Play = "Play";
    this.Props = "Props";
    this.Select = "Select";
    this.ZoomIn = "ZoomIn";
    this.ZoomOut = "ZoomOut";
    this.BrightnessDown = "BrightnessDown";
    this.BrightnessUp = "BrightnessUp";
    this.Eject = "Eject";
    this.LogOff = "LogOff";
    this.Power = "Power";
    this.PowerOff = "PowerOff";
    this.PrintScreen = "PrintScreen";
    this.Hibernate = "Hibernate";
    this.Standby = "Standby";
    this.WakeUp = "WakeUp";
    this.AllCandidates = "AllCandidates";
    this.Alphanumeric = "Alphanumeric";
    this.CodeInput = "CodeInput";
    this.Compose = "Compose";
    this.Convert = "Convert";
    this.Dead = "Dead";
    this.FinalMode = "FinalMode";
    this.GroupFirst = "GroupFirst";
    this.GroupLast = "GroupLast";
    this.GroupNext = "GroupNext";
    this.GroupPrevious = "GroupPrevious";
    this.ModelChange = "ModelChange";
    this.NextCandidate = "NextCandidate";
    this.NonConvert = "NonConvert";
    this.PreviousCandidate = "PreviousCandidate";
    this.Process = "Process";
    this.SingleCandidate = "SingleCandidate";
    this.HangulMode = "HangulMode";
    this.HanjaMode = "HanjaMode";
    this.JunjaMode = "JunjaMode";
    this.Eisu = "Eisu";
    this.Hankaku = "Hankaku";
    this.Hiranga = "Hiranga";
    this.HirangaKatakana = "HirangaKatakana";
    this.KanaMode = "KanaMode";
    this.Katakana = "Katakana";
    this.Romaji = "Romaji";
    this.Zenkaku = "Zenkaku";
    this.ZenkakuHanaku = "ZenkakuHanaku";
    this.F1 = "F1";
    this.F2 = "F2";
    this.F3 = "F3";
    this.F4 = "F4";
    this.F5 = "F5";
    this.F6 = "F6";
    this.F7 = "F7";
    this.F8 = "F8";
    this.F9 = "F9";
    this.F10 = "F10";
    this.F11 = "F11";
    this.F12 = "F12";
    this.F13 = "F13";
    this.F14 = "F14";
    this.F15 = "F15";
    this.F16 = "F16";
    this.F17 = "F17";
    this.F18 = "F18";
    this.F19 = "F19";
    this.F20 = "F20";
    this.Soft1 = "Soft1";
    this.Soft2 = "Soft2";
    this.Soft3 = "Soft3";
    this.Soft4 = "Soft4";
    this.Decimal = "Decimal";
    this.Key11 = "Key11";
    this.Key12 = "Key12";
    this.Multiply = "Multiply";
    this.Add = "Add";
    this.NumClear = "Clear";
    this.Divide = "Divide";
    this.Subtract = "Subtract";
    this.Separator = "Separator";
    this.AppSwitch = "AppSwitch";
    this.Call = "Call";
    this.Camera = "Camera";
    this.CameraFocus = "CameraFocus";
    this.EndCall = "EndCall";
    this.GoBack = "GoBack";
    this.GoHome = "GoHome";
    this.HeadsetHook = "HeadsetHook";
    this.LastNumberRedial = "LastNumberRedial";
    this.Notification = "Notification";
    this.MannerMode = "MannerMode";
    this.VoiceDial = "VoiceDial";
  });
  this.$rtti.$ExtClass("TJSKeyboardEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "KeyboardEvent"});
  this.$rtti.$ExtClass("TJSMutationObserver");
  rtl.recNewT(this,"TJSMutationRecord",function () {
    this.type_ = "";
    this.target = null;
    this.addedNodes = null;
    this.removedNodes = null;
    this.previousSibling = null;
    this.nextSibling = null;
    this.attributeName = "";
    this.attributeNamespace = "";
    this.oldValue = "";
    this.$eq = function (b) {
      return (this.type_ === b.type_) && (this.target === b.target) && (this.addedNodes === b.addedNodes) && (this.removedNodes === b.removedNodes) && (this.previousSibling === b.previousSibling) && (this.nextSibling === b.nextSibling) && (this.attributeName === b.attributeName) && (this.attributeNamespace === b.attributeNamespace) && (this.oldValue === b.oldValue);
    };
    this.$assign = function (s) {
      this.type_ = s.type_;
      this.target = s.target;
      this.addedNodes = s.addedNodes;
      this.removedNodes = s.removedNodes;
      this.previousSibling = s.previousSibling;
      this.nextSibling = s.nextSibling;
      this.attributeName = s.attributeName;
      this.attributeNamespace = s.attributeNamespace;
      this.oldValue = s.oldValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSMutationRecord",{},this);
    $r.addField("type_",rtl.string);
    $r.addField("target",$mod.$rtti["TJSNode"]);
    $r.addField("addedNodes",$mod.$rtti["TJSNodeList"]);
    $r.addField("removedNodes",$mod.$rtti["TJSNodeList"]);
    $r.addField("previousSibling",$mod.$rtti["TJSNode"]);
    $r.addField("nextSibling",$mod.$rtti["TJSNode"]);
    $r.addField("attributeName",rtl.string);
    $r.addField("attributeNamespace",rtl.string);
    $r.addField("oldValue",rtl.string);
  });
  this.$rtti.$DynArray("TJSMutationRecordArray",{eltype: this.$rtti["TJSMutationRecord"]});
  this.$rtti.$RefToProcVar("TJSMutationCallback",{procsig: rtl.newTIProcSig([["mutations",this.$rtti["TJSMutationRecordArray"]],["observer",this.$rtti["TJSMutationObserver"]]],null,8)});
  rtl.recNewT(this,"TJSMutationObserverInit",function () {
    this.attributes = false;
    this.attributeOldValue = false;
    this.characterData = false;
    this.characterDataOldValue = false;
    this.childList = false;
    this.subTree = false;
    this.attributeFilter = null;
    this.$eq = function (b) {
      return (this.attributes === b.attributes) && (this.attributeOldValue === b.attributeOldValue) && (this.characterData === b.characterData) && (this.characterDataOldValue === b.characterDataOldValue) && (this.childList === b.childList) && (this.subTree === b.subTree) && (this.attributeFilter === b.attributeFilter);
    };
    this.$assign = function (s) {
      this.attributes = s.attributes;
      this.attributeOldValue = s.attributeOldValue;
      this.characterData = s.characterData;
      this.characterDataOldValue = s.characterDataOldValue;
      this.childList = s.childList;
      this.subTree = s.subTree;
      this.attributeFilter = s.attributeFilter;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSMutationObserverInit",{},this);
    $r.addField("attributes",rtl.boolean);
    $r.addField("attributeOldValue",rtl.boolean);
    $r.addField("characterData",rtl.boolean);
    $r.addField("characterDataOldValue",rtl.boolean);
    $r.addField("childList",rtl.boolean);
    $r.addField("subTree",rtl.boolean);
    $r.addField("attributeFilter",pas.JS.$rtti["TJSArray"]);
  });
  this.$rtti.$ExtClass("TJSMutationObserver",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MutationObserver"});
  this.$rtti.$DynArray("TJSMessagePortArray",{eltype: this.$rtti["TJSMessagePort"]});
  this.$rtti.$ExtClass("TJSInputEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "InputEvent"});
  this.$rtti.$ExtClass("TJSMessageEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "MessageEvent"});
  this.$rtti.$ExtClass("TJSWebSocket",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "WebSocket"});
  this.$rtti.$ExtClass("TJSHTMLAudioTrack",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "AudioTrack"});
  this.$rtti.$ExtClass("TJSHTMLAudioTrackList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "AudioTrackList"});
  this.$rtti.$ExtClass("TJSHTMLVideoTrack",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "VideoTrack"});
  this.$rtti.$ExtClass("TJSHTMLVideoTrackList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "VideoTrackList"});
  this.$rtti.$ExtClass("TJSHTMLTextTrack",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TextTrack"});
  this.$rtti.$ExtClass("TJSHTMLTextTrackList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TextTrackList"});
  this.$rtti.$ExtClass("TJSMEdiaError",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaError"});
  this.$rtti.$ExtClass("TJSHTMLMediaStream",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaStream"});
  this.$rtti.$ExtClass("TJSHTMLMediaController",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaController"});
  this.$rtti.$ExtClass("TJSHTMLMediaElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLMediaElement"});
  this.$rtti.$ExtClass("TJSHTMLAudioElement",{ancestor: this.$rtti["TJSHTMLMediaElement"], jsclass: "HTMLAudioElement"});
  this.$rtti.$ExtClass("TJSHTMLVideoElement",{ancestor: this.$rtti["TJSHTMLMediaElement"], jsclass: "HTMLVideoElement"});
  this.$rtti.$ExtClass("TJSHTMLStyleElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLStyleElement"});
  this.$rtti.$ExtClass("TJSHTMLDetailsElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLDetailsElement"});
  this.$rtti.$ExtClass("TJSResizeObserverEntry",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ResizeObserverEntry"});
  this.$rtti.$DynArray("TJSResizeObserverEntries",{eltype: this.$rtti["TJSResizeObserverEntry"]});
  this.$rtti.$ProcVar("TJSResizeObserverCallback",{procsig: rtl.newTIProcSig([["AEntries",this.$rtti["TJSResizeObserverEntries"]],["AObserver",this.$rtti["TJSResizeObserver"]]])});
  this.$rtti.$MethodVar("TJSResizeObserverCallbackObj",{procsig: rtl.newTIProcSig([["AEntries",this.$rtti["TJSResizeObserverEntries"]],["AObserver",this.$rtti["TJSResizeObserver"]]]), methodkind: 0});
  this.$rtti.$ExtClass("TJSResizeObserver",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ResizeObserver"});
  this.$rtti.$DynArray("TJSFormDataEntryValueArray",{eltype: rtl.string});
  this.$rtti.$ExtClass("TJSFormData",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "FormData"});
  this.$rtti.$ExtClass("TJSHTMLTemplateElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTemplateElement"});
  this.$rtti.$ExtClass("TJSHTMLOrXMLDocument",{ancestor: this.$rtti["TJSDocument"], jsclass: "Document"});
  this.$rtti.$ExtClass("TJSHTMLDocument",{ancestor: this.$rtti["TJSHTMLOrXMLDocument"], jsclass: "HTMLDocument"});
  this.$rtti.$ExtClass("TJSXMLDocument",{ancestor: this.$rtti["TJSHTMLOrXMLDocument"], jsclass: "HTMLDocument"});
  this.$rtti.$ExtClass("TDOMParser",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMParser"});
  this.$rtti.$RefToProcVar("TOnChangeProcedure",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$ExtClass("TJSPermissionDescriptor",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSPermissionStatus",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "PermissionStatus"});
  this.$rtti.$ExtClass("TJSPermissions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Permissions"});
  this.$rtti.$ExtClass("TJSFileSystemHandlePermissionDescriptor",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSFileSystemCreateWritableOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSFileSystemWritableFileStream");
  this.$rtti.$ExtClass("TJSFileSystemHandle",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "FileSystemHandle"});
  this.$rtti.$ExtClass("TJSFileSystemFileHandle",{ancestor: this.$rtti["TJSFileSystemHandle"], jsclass: "FileSystemFileHandle"});
  this.$rtti.$ExtClass("TJSGetFileHandleOptions",{jsclass: "Object"});
  this.$rtti.$ExtClass("TJSRemoveEntryOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSFileSystemDirectoryHandle",{ancestor: this.$rtti["TJSFileSystemHandle"], jsclass: "FileSystemDirectoryHandle"});
  this.$rtti.$ExtClass("TJSFileSystemWritableFileStream",{ancestor: this.$rtti["TJSWritableStream"], jsclass: "FileSystemWritableFileStream"});
  this.$rtti.$ExtClass("TJSShowOpenFilePickerTypeOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSShowOpenFilePickerOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSShowSaveFilePickerOptionsAccept",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSShowSaveFilePickerOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.HasServiceWorker = function () {
    var Result = false;
    if (window.navigator.serviceWorker) {
      return true}
     else return false;
    return Result;
  };
});
rtl.module("p2jsres",["System","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TResourceSource = {"0": "rsJS", rsJS: 0, "1": "rsHTML", rsHTML: 1};
  this.$rtti.$Enum("TResourceSource",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TResourceSource});
  rtl.recNewT(this,"TResourceInfo",function () {
    this.name = "";
    this.encoding = "";
    this.resourceunit = "";
    this.format = "";
    this.data = "";
    this.$eq = function (b) {
      return (this.name === b.name) && (this.encoding === b.encoding) && (this.resourceunit === b.resourceunit) && (this.format === b.format) && (this.data === b.data);
    };
    this.$assign = function (s) {
      this.name = s.name;
      this.encoding = s.encoding;
      this.resourceunit = s.resourceunit;
      this.format = s.format;
      this.data = s.data;
      return this;
    };
    var $r = $mod.$rtti.$Record("TResourceInfo",{},this);
    $r.addField("name",rtl.string);
    $r.addField("encoding",rtl.string);
    $r.addField("resourceunit",rtl.string);
    $r.addField("format",rtl.string);
    $r.addField("data",rtl.string);
  });
  this.$rtti.$RefToProcVar("TResourceEnumCallBack",{procsig: rtl.newTIProcSig([["resName",rtl.string,2]],rtl.boolean)});
  this.$rtti.$RefToProcVar("TResourcesLoadedEnumCallBack",{procsig: rtl.newTIProcSig([["LoadedResources",rtl.string,10]])});
  this.$rtti.$RefToProcVar("TResourcesLoadErrorCallBack",{procsig: rtl.newTIProcSig([["aError",rtl.string,2]])});
  this.SetResourceSource = function (aSource) {
    var Result = 0;
    Result = $impl.gMode;
    $impl.gMode = aSource;
    return Result;
  };
  this.GetResourceNames = function () {
    var Result = [];
    Result = $mod.GetResourceNames$1($impl.gMode);
    return Result;
  };
  this.GetResourceNames$1 = function (aSource) {
    var Result = [];
    var $tmp = aSource;
    if ($tmp === $mod.TResourceSource.rsJS) {
      Result = rtl.getResourceList()}
     else if ($tmp === $mod.TResourceSource.rsHTML) Result = $impl.GetHTMLResources();
    return Result;
  };
  this.EnumResources = function (aCallback) {
    var Result = 0;
    Result = $mod.EnumResources$1($impl.gMode,aCallback);
    return Result;
  };
  this.EnumResources$1 = function (aSource, aCallback) {
    var Result = 0;
    var RL = [];
    var I = 0;
    var ContinueEnum = false;
    Result = 0;
    RL = $mod.GetResourceNames$1(aSource);
    I = 0;
    Result = rtl.length(RL);
    ContinueEnum = true;
    while ((I < Result) && ContinueEnum) {
      ContinueEnum = aCallback(RL[I]);
      I += 1;
    };
    return Result;
  };
  this.GetResourceInfo = function (aName, aInfo) {
    var Result = false;
    Result = $mod.GetResourceInfo$1($impl.gMode,aName,aInfo);
    return Result;
  };
  this.GetResourceInfo$1 = function (aSource, aName, aInfo) {
    var Result = false;
    var $tmp = aSource;
    if ($tmp === $mod.TResourceSource.rsJS) {
      Result = $impl.GetRTLResourceInfo(aName,aInfo)}
     else if ($tmp === $mod.TResourceSource.rsHTML) Result = $impl.GetHTMLResourceInfo(aName,aInfo);
    return Result;
  };
  this.LoadHTMLLinkResources = function (aURL, OnLoad, OnError) {
    function FetchOK(Res) {
      var Result = undefined;
      Result = null;
      if (!Res.ok) {
        if (OnError != null) throw new Error("HTTP Error for URL aURL, status = " + pas.SysUtils.IntToStr(Res.status) + " : " + Res.statusText);
      } else Result = Res.text();
      return Result;
    };
    function BlobOK(Res) {
      var Result = undefined;
      var ID = "";
      var Tmpl = null;
      var El = null;
      var Arr = [];
      var aParent = null;
      Result = null;
      aParent = document.head;
      if (aParent === null) aParent = document.body;
      Arr = rtl.arraySetLength(Arr,"",0);
      Tmpl = document.createElement("template");
      Tmpl.innerHTML = Res.trim();
      El = Tmpl.content.firstElementChild;
      while (El !== null) {
        if (pas.SysUtils.SameText(El.tagName,"link") && $impl.IsResourceLink(El)) {
          aParent.append(document.importNode(El,true));
          ID = El.id;
          pas.System.Delete({get: function () {
              return ID;
            }, set: function (v) {
              ID = v;
            }},1,$impl.IDPrefix.length);
          if (ID !== "") Arr.push(ID);
        };
        El = El.nextElementSibling;
      };
      if (OnLoad != null) OnLoad(Arr);
      return Result;
    };
    function DoError(aValue) {
      var Result = undefined;
      Result = null;
      if (OnError != null) if (aValue === null) OnError("Error: " + aValue.message);
      return Result;
    };
    if (!$impl.HasTemplate()) {
      if (OnError != null) OnError("No template support in this browser");
    } else window.fetch(aURL).then(FetchOK).then(BlobOK).catch(DoError);
  };
  $mod.$implcode = function () {
    $impl.gMode = 0;
    $mod.$rtti.$ExtClass("TRTLResourceInfo",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
    $impl.GetRTLResourceInfo = function (aName, aInfo) {
      var Result = false;
      var RTLInfo = null;
      RTLInfo = rtl.getResource(pas.SysUtils.LowerCase(aName));
      Result = RTLInfo != null;
      if (Result) {
        aInfo.name = RTLInfo.name;
        aInfo.encoding = RTLInfo.encoding;
        aInfo.format = RTLInfo.format;
        aInfo.resourceunit = RTLInfo.unit;
        aInfo.data = RTLInfo.data;
      };
      return Result;
    };
    $impl.IDPrefix = "resource-";
    $impl.IsResourceLink = function (L) {
      var Result = false;
      Result = (pas.System.Copy(L.id,1,$impl.IDPrefix.length) === $impl.IDPrefix) && pas.JS.isDefined(L.dataset["unit"]) && (pas.System.Copy(L.href,1,4) === "data");
      return Result;
    };
    $impl.GetHTMLResources = function () {
      var Result = [];
      var LC = null;
      var L = null;
      var I = 0;
      var ID = "";
      Result = rtl.arraySetLength(Result,"",0);
      if (!pas.JS.isDefined(document)) return Result;
      LC = document.getElementsByTagName("link");
      for (var $l = 0, $end = LC.length - 1; $l <= $end; $l++) {
        I = $l;
        L = LC.item(I);
        ID = L.id;
        if ($impl.IsResourceLink(L)) {
          pas.System.Delete({get: function () {
              return ID;
            }, set: function (v) {
              ID = v;
            }},1,$impl.IDPrefix.length);
          if (ID !== "") Result.push(ID);
        };
      };
      return Result;
    };
    $impl.GetHTMLResourceInfo = function (aName, aInfo) {
      var Result = false;
      var el = null;
      var S = "";
      var I = 0;
      Result = false;
      if (!pas.JS.isDefined(document)) return Result;
      el = document.getElementById($impl.IDPrefix + pas.SysUtils.LowerCase(aName));
      Result = (el != null) && pas.SysUtils.SameText(el.tagName,"link");
      if (!Result) return Result;
      aInfo.name = pas.SysUtils.LowerCase(aName);
      aInfo.resourceunit = "" + el.dataset["unit"];
      S = el.href;
      S = pas.System.Copy(S,6,S.length - 5);
      I = pas.System.Pos(",",S);
      aInfo.data = pas.System.Copy(S,I + 1,S.length - 1);
      S = pas.System.Copy(S,1,I - 1);
      I = pas.System.Pos(";",S);
      if (I === 0) {
        aInfo.encoding = ""}
       else {
        aInfo.encoding = pas.System.Copy(S,I + 1,S.length - 1);
        S = pas.System.Copy(S,1,I - 1);
      };
      aInfo.format = S;
      return Result;
    };
    $impl.HasTemplate = function () {
      var Result = false;
      return ('content' in document.createElement('template'));
      Result = false;
      return Result;
    };
  };
},["SysUtils","JS","Web"]);
rtl.module("simplelinkedlist",["System"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TLinkedListItem",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.Next = null;
    };
    this.$final = function () {
      this.Next = undefined;
      pas.System.TObject.$final.call(this);
    };
  });
  this.$rtti.$ClassRef("TLinkedListItemClass",{instancetype: this.$rtti["TLinkedListItem"]});
  rtl.createClass(this,"TLinkedListVisitor",pas.System.TObject,function () {
  });
  rtl.createClass(this,"TLinkedList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FItemClass = null;
      this.FRoot = null;
    };
    this.$final = function () {
      this.FItemClass = undefined;
      this.FRoot = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      var I = null;
      I = this.FRoot;
      Result = 0;
      while (I !== null) {
        I = I.Next;
        Result += 1;
      };
      return Result;
    };
    this.Create$1 = function (AnItemClass) {
      this.FItemClass = AnItemClass;
      return this;
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      var I = null;
      I = this.FRoot;
      while (I !== null) {
        this.FRoot = I;
        I = I.Next;
        this.FRoot.Next = null;
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.FRoot;
          }, set: function (v) {
            this.p.FRoot = v;
          }});
      };
    };
    this.Add = function () {
      var Result = null;
      Result = this.FItemClass.$create("Create");
      Result.Next = this.FRoot;
      this.FRoot = Result;
      return Result;
    };
    this.ForEach = function (Visitor) {
      var I = null;
      I = this.FRoot;
      while ((I !== null) && Visitor.Visit(I)) I = I.Next;
    };
    this.RemoveItem = function (Item, FreeItem) {
      var I = null;
      if ((Item !== null) && (this.FRoot !== null)) {
        if (Item === this.FRoot) {
          this.FRoot = Item.Next}
         else {
          I = this.FRoot;
          while ((I.Next !== null) && (I.Next !== Item)) I = I.Next;
          if (I.Next === Item) I.Next = Item.Next;
        };
        if (FreeItem) Item = rtl.freeLoc(Item);
      };
    };
  });
},["SysUtils"]);
rtl.module("Classes",["System","RTLConsts","Types","SysUtils","JS","TypInfo","p2jsres"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$MethodVar("TNotifyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TNotifyEventRef",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]])});
  this.$rtti.$RefToProcVar("TStringNotifyEventRef",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["aString",rtl.string,2]])});
  this.TFPObservedOperation = {"0": "ooChange", ooChange: 0, "1": "ooFree", ooFree: 1, "2": "ooAddItem", ooAddItem: 2, "3": "ooDeleteItem", ooDeleteItem: 3, "4": "ooCustom", ooCustom: 4};
  this.$rtti.$Enum("TFPObservedOperation",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TFPObservedOperation});
  rtl.createClass(this,"EStreamError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EFCreateError",this.EStreamError,function () {
  });
  rtl.createClass(this,"EFOpenError",this.EStreamError,function () {
  });
  rtl.createClass(this,"EFilerError",this.EStreamError,function () {
  });
  rtl.createClass(this,"EReadError",this.EFilerError,function () {
  });
  rtl.createClass(this,"EWriteError",this.EFilerError,function () {
  });
  rtl.createClass(this,"EClassNotFound",this.EFilerError,function () {
  });
  rtl.createClass(this,"EMethodNotFound",this.EFilerError,function () {
  });
  rtl.createClass(this,"EInvalidImage",this.EFilerError,function () {
  });
  rtl.createClass(this,"EResNotFound",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EListError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EBitsError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EStringListError",this.EListError,function () {
  });
  rtl.createClass(this,"EComponentError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EParserError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EOutOfResources",pas.SysUtils.EOutOfMemory,function () {
  });
  rtl.createClass(this,"EInvalidOperation",pas.SysUtils.Exception,function () {
  });
  this.TListAssignOp = {"0": "laCopy", laCopy: 0, "1": "laAnd", laAnd: 1, "2": "laOr", laOr: 2, "3": "laXor", laXor: 3, "4": "laSrcUnique", laSrcUnique: 4, "5": "laDestUnique", laDestUnique: 5};
  this.$rtti.$Enum("TListAssignOp",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TListAssignOp});
  this.$rtti.$ProcVar("TListSortCompare",{procsig: rtl.newTIProcSig([["Item1",rtl.jsvalue],["Item2",rtl.jsvalue]],rtl.longint)});
  this.$rtti.$RefToProcVar("TListSortCompareFunc",{procsig: rtl.newTIProcSig([["Item1",rtl.jsvalue],["Item2",rtl.jsvalue]],rtl.longint)});
  this.TAlignment = {"0": "taLeftJustify", taLeftJustify: 0, "1": "taRightJustify", taRightJustify: 1, "2": "taCenter", taCenter: 2};
  this.$rtti.$Enum("TAlignment",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TAlignment});
  this.$rtti.$Class("TFPList");
  this.$rtti.$Class("TReader");
  this.$rtti.$Class("TWriter");
  this.$rtti.$Class("TFiler");
  rtl.createClass(this,"TFPListEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FList = AList;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = undefined;
      Result = this.FList.Get(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FList.FCount;
      return Result;
    };
  });
  rtl.createClass(this,"TFPList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = [];
      this.FCount = 0;
      this.FCapacity = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.CopyMove = function (aList) {
      var r = 0;
      this.Clear();
      for (var $l = 0, $end = aList.FCount - 1; $l <= $end; $l++) {
        r = $l;
        this.Add(aList.Get(r));
      };
    };
    this.MergeMove = function (aList) {
      var r = 0;
      for (var $l = 0, $end = aList.FCount - 1; $l <= $end; $l++) {
        r = $l;
        if (this.IndexOf(aList.Get(r)) < 0) this.Add(aList.Get(r));
      };
    };
    this.DoCopy = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListB)}
       else this.CopyMove(ListA);
    };
    this.DoSrcUnique = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.FCount - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
        };
      };
    };
    this.DoAnd = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) >= 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.FCount - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) < 0) this.Delete(r);
        };
      };
    };
    this.DoDestUnique = function (ListA, ListB) {
      var $Self = this;
      function MoveElements(Src, Dest) {
        var r = 0;
        $Self.Clear();
        for (var $l = 0, $end = Src.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (Dest.IndexOf(Src.Get(r)) < 0) $Self.Add(Src.Get(r));
        };
      };
      var Dest = null;
      if (ListB != null) {
        MoveElements(ListB,ListA)}
       else Dest = $mod.TFPList.$create("Create");
      try {
        Dest.CopyMove($Self);
        MoveElements(ListA,Dest);
      } finally {
        Dest.$destroy("Destroy");
      };
    };
    this.DoOr = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListA);
        this.MergeMove(ListB);
      } else this.MergeMove(ListA);
    };
    this.DoXOr = function (ListA, ListB) {
      var r = 0;
      var l = null;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
        for (var $l1 = 0, $end1 = ListB.FCount - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (ListA.IndexOf(ListB.Get(r)) < 0) this.Add(ListB.Get(r));
        };
      } else {
        l = $mod.TFPList.$create("Create");
        try {
          l.CopyMove(this);
          for (var $l2 = this.FCount - 1; $l2 >= 0; $l2--) {
            r = $l2;
            if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
          };
          for (var $l3 = 0, $end2 = ListA.FCount - 1; $l3 <= $end2; $l3++) {
            r = $l3;
            if (l.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
          };
        } finally {
          l.$destroy("Destroy");
        };
      };
    };
    this.Get = function (Index) {
      var Result = undefined;
      if ((Index < 0) || (Index >= this.FCount)) this.RaiseIndexError(Index);
      Result = this.FList[Index];
      return Result;
    };
    this.Put = function (Index, Item) {
      if ((Index < 0) || (Index >= this.FCount)) this.RaiseIndexError(Index);
      this.FList[Index] = Item;
    };
    this.SetCapacity = function (NewCapacity) {
      if (NewCapacity < this.FCount) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListCapacityError"),"" + NewCapacity);
      if (NewCapacity === this.FCapacity) return;
      this.FList = rtl.arraySetLength(this.FList,undefined,NewCapacity);
      this.FCapacity = NewCapacity;
    };
    this.SetCount = function (NewCount) {
      if (NewCount < 0) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListCountError"),"" + NewCount);
      if (NewCount > this.FCount) {
        if (NewCount > this.FCapacity) this.SetCapacity(NewCount);
      };
      this.FCount = NewCount;
    };
    this.RaiseIndexError = function (Index) {
      this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index);
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.AddList = function (AList) {
      var I = 0;
      if (this.FCapacity < (this.FCount + AList.FCount)) this.SetCapacity(this.FCount + AList.FCount);
      for (var $l = 0, $end = AList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        this.Add(AList.Get(I));
      };
    };
    this.Add = function (Item) {
      var Result = 0;
      if (this.FCount === this.FCapacity) this.Expand();
      this.FList[this.FCount] = Item;
      Result = this.FCount;
      this.FCount += 1;
      return Result;
    };
    this.Clear = function () {
      if (rtl.length(this.FList) > 0) {
        this.SetCount(0);
        this.SetCapacity(0);
      };
    };
    this.Delete = function (Index) {
      if ((Index < 0) || (Index >= this.FCount)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index);
      this.FCount = this.FCount - 1;
      this.FList.splice(Index,1);
      this.FCapacity -= 1;
    };
    this.Error = function (Msg, Data) {
      throw $mod.EListError.$create("CreateFmt",[Msg,pas.System.VarRecs(18,Data)]);
    };
    this.Exchange = function (Index1, Index2) {
      var Temp = undefined;
      if ((Index1 >= this.FCount) || (Index1 < 0)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index1);
      if ((Index2 >= this.FCount) || (Index2 < 0)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index2);
      Temp = this.FList[Index1];
      this.FList[Index1] = this.FList[Index2];
      this.FList[Index2] = Temp;
    };
    this.Expand = function () {
      var Result = null;
      var IncSize = 0;
      if (this.FCount < this.FCapacity) return this;
      IncSize = 4;
      if (this.FCapacity > 3) IncSize = IncSize + 4;
      if (this.FCapacity > 8) IncSize = IncSize + 8;
      if (this.FCapacity > 127) IncSize += this.FCapacity >>> 2;
      this.SetCapacity(this.FCapacity + IncSize);
      Result = this;
      return Result;
    };
    this.Extract = function (Item) {
      var Result = undefined;
      var i = 0;
      i = this.IndexOf(Item);
      if (i >= 0) {
        Result = Item;
        this.Delete(i);
      } else Result = null;
      return Result;
    };
    this.First = function () {
      var Result = undefined;
      if (this.FCount === 0) {
        Result = null}
       else Result = this.Get(0);
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TFPListEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.IndexOf = function (Item) {
      var Result = 0;
      var C = 0;
      Result = 0;
      C = this.FCount;
      while ((Result < C) && (this.FList[Result] != Item)) Result += 1;
      if (Result >= C) Result = -1;
      return Result;
    };
    this.IndexOfItem = function (Item, Direction) {
      var Result = 0;
      if (Direction === pas.Types.TDirection.FromBeginning) {
        Result = this.IndexOf(Item)}
       else {
        Result = this.FCount - 1;
        while ((Result >= 0) && (this.FList[Result] != Item)) Result = Result - 1;
      };
      return Result;
    };
    this.Insert = function (Index, Item) {
      if ((Index < 0) || (Index > this.FCount)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index);
      this.FList.splice(Index,0,Item);
      this.FCapacity += 1;
      this.FCount += 1;
    };
    this.Last = function () {
      var Result = undefined;
      if (this.FCount === 0) {
        Result = null}
       else Result = this.Get(this.FCount - 1);
      return Result;
    };
    this.Move = function (CurIndex, NewIndex) {
      var Temp = undefined;
      if ((CurIndex < 0) || (CurIndex > (this.FCount - 1))) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + CurIndex);
      if ((NewIndex < 0) || (NewIndex > (this.FCount - 1))) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + NewIndex);
      if (CurIndex === NewIndex) return;
      Temp = this.FList[CurIndex];
      this.FList.splice(CurIndex,1);
      this.FList.splice(NewIndex,0,Temp);
    };
    this.Assign = function (ListA, AOperator, ListB) {
      var $tmp = AOperator;
      if ($tmp === $mod.TListAssignOp.laCopy) {
        this.DoCopy(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laSrcUnique) {
        this.DoSrcUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laAnd) {
        this.DoAnd(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laDestUnique) {
        this.DoDestUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laOr) {
        this.DoOr(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laXor) this.DoXOr(ListA,ListB);
    };
    this.Remove = function (Item) {
      var Result = 0;
      Result = this.IndexOf(Item);
      if (Result !== -1) this.Delete(Result);
      return Result;
    };
    this.Pack = function () {
      var Dst = 0;
      var i = 0;
      var V = undefined;
      Dst = 0;
      for (var $l = 0, $end = this.FCount - 1; $l <= $end; $l++) {
        i = $l;
        V = this.FList[i];
        if (!pas.System.Assigned(V)) continue;
        this.FList[Dst] = V;
        Dst += 1;
      };
    };
    this.Sort = function (Compare) {
      var $Self = this;
      if (!(rtl.length(this.FList) > 0) || (this.FCount < 2)) return;
      $impl.QuickSort(rtl.arrayRef(this.FList),0,this.FCount - 1,function (Item1, Item2) {
        var Result = 0;
        Result = Compare(Item1,Item2);
        return Result;
      });
    };
    this.SortList = function (Compare) {
      if (!(rtl.length(this.FList) > 0) || (this.FCount < 2)) return;
      $impl.QuickSort(rtl.arrayRef(this.FList),0,this.FCount - 1,Compare);
    };
    this.ForEachCall = function (proc2call, arg) {
      var i = 0;
      var v = undefined;
      for (var $l = 0, $end = this.FCount - 1; $l <= $end; $l++) {
        i = $l;
        v = this.FList[i];
        if (pas.System.Assigned(v)) proc2call(v,arg);
      };
    };
    this.ForEachCall$1 = function (proc2call, arg) {
      var i = 0;
      var v = undefined;
      for (var $l = 0, $end = this.FCount - 1; $l <= $end; $l++) {
        i = $l;
        v = this.FList[i];
        if (pas.System.Assigned(v)) proc2call(v,arg);
      };
    };
  });
  this.TListNotification = {"0": "lnAdded", lnAdded: 0, "1": "lnExtracted", lnExtracted: 1, "2": "lnDeleted", lnDeleted: 2};
  this.$rtti.$Enum("TListNotification",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TListNotification});
  this.$rtti.$Class("TList");
  rtl.createClass(this,"TListEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FList = AList;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = undefined;
      Result = this.FList.Get(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FList.GetCount();
      return Result;
    };
  });
  rtl.createClass(this,"TList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.CopyMove = function (aList) {
      var r = 0;
      this.Clear();
      for (var $l = 0, $end = aList.GetCount() - 1; $l <= $end; $l++) {
        r = $l;
        this.Add(aList.Get(r));
      };
    };
    this.MergeMove = function (aList) {
      var r = 0;
      for (var $l = 0, $end = aList.GetCount() - 1; $l <= $end; $l++) {
        r = $l;
        if (this.IndexOf(aList.Get(r)) < 0) this.Add(aList.Get(r));
      };
    };
    this.DoCopy = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListB)}
       else this.CopyMove(ListA);
    };
    this.DoSrcUnique = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.GetCount() - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
        };
      };
    };
    this.DoAnd = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) >= 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.GetCount() - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) < 0) this.Delete(r);
        };
      };
    };
    this.DoDestUnique = function (ListA, ListB) {
      var $Self = this;
      function MoveElements(Src, Dest) {
        var r = 0;
        $Self.Clear();
        for (var $l = 0, $end = Src.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (Dest.IndexOf(Src.Get(r)) < 0) $Self.Add(Src.Get(r));
        };
      };
      var Dest = null;
      if (ListB != null) {
        MoveElements(ListB,ListA)}
       else try {
        Dest = $mod.TList.$create("Create$1");
        Dest.CopyMove($Self);
        MoveElements(ListA,Dest);
      } finally {
        Dest.$destroy("Destroy");
      };
    };
    this.DoOr = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListA);
        this.MergeMove(ListB);
      } else this.MergeMove(ListA);
    };
    this.DoXOr = function (ListA, ListB) {
      var r = 0;
      var l = null;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
        for (var $l1 = 0, $end1 = ListB.GetCount() - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (ListA.IndexOf(ListB.Get(r)) < 0) this.Add(ListB.Get(r));
        };
      } else try {
        l = $mod.TList.$create("Create$1");
        l.CopyMove(this);
        for (var $l2 = this.GetCount() - 1; $l2 >= 0; $l2--) {
          r = $l2;
          if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
        };
        for (var $l3 = 0, $end2 = ListA.GetCount() - 1; $l3 <= $end2; $l3++) {
          r = $l3;
          if (l.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
      } finally {
        l.$destroy("Destroy");
      };
    };
    this.Get = function (Index) {
      var Result = undefined;
      Result = this.FList.Get(Index);
      return Result;
    };
    this.Put = function (Index, Item) {
      var V = undefined;
      V = this.Get(Index);
      this.FList.Put(Index,Item);
      if (pas.System.Assigned(V)) this.Notify(V,$mod.TListNotification.lnDeleted);
      if (pas.System.Assigned(Item)) this.Notify(Item,$mod.TListNotification.lnAdded);
    };
    this.Notify = function (aValue, Action) {
      if (pas.System.Assigned(aValue)) ;
      if (Action === $mod.TListNotification.lnExtracted) ;
    };
    this.SetCapacity = function (NewCapacity) {
      this.FList.SetCapacity(NewCapacity);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.FList.FCapacity;
      return Result;
    };
    this.SetCount = function (NewCount) {
      if (NewCount < this.FList.FCount) {
        while (this.FList.FCount > NewCount) this.Delete(this.FList.FCount - 1)}
       else this.FList.SetCount(NewCount);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FList.FCount;
      return Result;
    };
    this.GetList = function () {
      var Result = [];
      Result = this.FList.FList;
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FList = $mod.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      if (this.FList != null) this.Clear();
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FList;
        }, set: function (v) {
          this.p.FList = v;
        }});
    };
    this.AddList = function (AList) {
      var I = 0;
      this.FList.AddList(AList.FList);
      for (var $l = 0, $end = AList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas.System.Assigned(AList.Get(I))) this.Notify(AList.Get(I),$mod.TListNotification.lnAdded);
      };
    };
    this.Add = function (Item) {
      var Result = 0;
      Result = this.FList.Add(Item);
      if (pas.System.Assigned(Item)) this.Notify(Item,$mod.TListNotification.lnAdded);
      return Result;
    };
    this.Clear = function () {
      while (this.FList.FCount > 0) this.Delete(this.GetCount() - 1);
    };
    this.Delete = function (Index) {
      var V = undefined;
      V = this.FList.Get(Index);
      this.FList.Delete(Index);
      if (pas.System.Assigned(V)) this.Notify(V,$mod.TListNotification.lnDeleted);
    };
    this.Error = function (Msg, Data) {
      throw $mod.EListError.$create("CreateFmt",[Msg,pas.System.VarRecs(18,Data)]);
    };
    this.Exchange = function (Index1, Index2) {
      this.FList.Exchange(Index1,Index2);
    };
    this.Expand = function () {
      var Result = null;
      this.FList.Expand();
      Result = this;
      return Result;
    };
    this.Extract = function (Item) {
      var Result = undefined;
      var c = 0;
      c = this.FList.FCount;
      Result = this.FList.Extract(Item);
      if (c !== this.FList.FCount) this.Notify(Result,$mod.TListNotification.lnExtracted);
      return Result;
    };
    this.First = function () {
      var Result = undefined;
      Result = this.FList.First();
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TListEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.IndexOf = function (Item) {
      var Result = 0;
      Result = this.FList.IndexOf(Item);
      return Result;
    };
    this.Insert = function (Index, Item) {
      this.FList.Insert(Index,Item);
      if (pas.System.Assigned(Item)) this.Notify(Item,$mod.TListNotification.lnAdded);
    };
    this.Last = function () {
      var Result = undefined;
      Result = this.FList.Last();
      return Result;
    };
    this.Move = function (CurIndex, NewIndex) {
      this.FList.Move(CurIndex,NewIndex);
    };
    this.Assign = function (ListA, AOperator, ListB) {
      var $tmp = AOperator;
      if ($tmp === $mod.TListAssignOp.laCopy) {
        this.DoCopy(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laSrcUnique) {
        this.DoSrcUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laAnd) {
        this.DoAnd(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laDestUnique) {
        this.DoDestUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laOr) {
        this.DoOr(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laXor) this.DoXOr(ListA,ListB);
    };
    this.Remove = function (Item) {
      var Result = 0;
      Result = this.IndexOf(Item);
      if (Result !== -1) this.Delete(Result);
      return Result;
    };
    this.Pack = function () {
      this.FList.Pack();
    };
    this.Sort = function (Compare) {
      this.FList.Sort(Compare);
    };
    this.SortList = function (Compare) {
      this.FList.SortList(Compare);
    };
  });
  rtl.createClass(this,"TPersistent",pas.System.TObject,function () {
    this.AssignError = function (Source) {
      var SourceName = "";
      if (Source !== null) {
        SourceName = Source.$classname}
       else SourceName = "Nil";
      throw pas.SysUtils.EConvertError.$create("Create$1",["Cannot assign a " + SourceName + " to a " + this.$classname + "."]);
    };
    this.DefineProperties = function (Filer) {
      if (Filer === null) return;
    };
    this.AssignTo = function (Dest) {
      Dest.AssignError(this);
    };
    this.GetOwner = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.Assign = function (Source) {
      if (Source !== null) {
        Source.AssignTo(this)}
       else this.AssignError(null);
    };
    this.GetNamePath = function () {
      var Result = "";
      var OwnerName = "";
      var TheOwner = null;
      Result = this.$classname;
      TheOwner = this.GetOwner();
      if (TheOwner !== null) {
        OwnerName = TheOwner.GetNamePath();
        if (OwnerName !== "") Result = OwnerName + "." + Result;
      };
      return Result;
    };
    this.SetEvent = function (ALookupRoot, APropName, AMethodName) {
      this.SetEvent$1(this,ALookupRoot,APropName,AMethodName);
    };
    this.SetEvent$1 = function (AInstance, ALookupRoot, APropName, AMethodName) {
      var lMethod = pas.System.TMethod.$new();
      lMethod.Code = ALookupRoot.$class.MethodAddress(AMethodName);
      if (lMethod.Code != null) {
        lMethod.Data = ALookupRoot;
        pas.TypInfo.SetMethodProp$1(AInstance,APropName,lMethod);
      };
    };
  });
  this.$rtti.$ClassRef("TPersistentClass",{instancetype: this.$rtti["TPersistent"]});
  rtl.createClass(this,"TInterfacedPersistent",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FOwnerInterface = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FOwnerInterface",null);
      $mod.TPersistent.$final.call(this);
    };
    this._AddRef = function () {
      var Result = 0;
      Result = -1;
      if (this.FOwnerInterface != null) Result = this.FOwnerInterface._AddRef();
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      Result = -1;
      if (this.FOwnerInterface != null) Result = this.FOwnerInterface._Release();
      return Result;
    };
    this.QueryInterface = function (IID, Obj) {
      var Result = 0;
      Result = -2147467262;
      if (this.GetInterface(IID,Obj)) Result = 0;
      return Result;
    };
    this.AfterConstruction = function () {
      try {
        pas.System.TObject.AfterConstruction.call(this);
        if (this.GetOwner() !== null) this.GetOwner().GetInterface(rtl.getIntfGUIDR(pas.System.IUnknown),{p: this, get: function () {
            return this.p.FOwnerInterface;
          }, set: function (v) {
            this.p.FOwnerInterface = v;
          }});
      } finally {
        rtl._Release(this.FOwnerInterface);
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TStrings");
  rtl.createClass(this,"TStringsEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FStrings = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FStrings = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AStrings) {
      pas.System.TObject.Create.call(this);
      this.FStrings = AStrings;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = "";
      Result = this.FStrings.Get(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FStrings.GetCount();
      return Result;
    };
  });
  rtl.createClass(this,"TStrings",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FSpecialCharsInited = false;
      this.FAlwaysQuote = false;
      this.FQuoteChar = "\x00";
      this.FDelimiter = "\x00";
      this.FNameValueSeparator = "\x00";
      this.FUpdateCount = 0;
      this.FLBS = 0;
      this.FSkipLastLineBreak = false;
      this.FStrictDelimiter = false;
      this.FLineBreak = "";
    };
    this.GetCommaText = function () {
      var Result = "";
      var C1 = "\x00";
      var C2 = "\x00";
      var FSD = false;
      this.CheckSpecialChars();
      FSD = this.FStrictDelimiter;
      C1 = this.GetDelimiter();
      C2 = this.GetQuoteChar();
      this.SetDelimiter(",");
      this.SetQuoteChar('"');
      this.FStrictDelimiter = false;
      try {
        Result = this.GetDelimitedText();
      } finally {
        this.SetDelimiter(C1);
        this.SetQuoteChar(C2);
        this.FStrictDelimiter = FSD;
      };
      return Result;
    };
    this.GetName = function (Index) {
      var Result = "";
      var V = "";
      this.GetNameValue(Index,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return V;
        }, set: function (v) {
          V = v;
        }});
      return Result;
    };
    this.GetValue = function (Name) {
      var Result = "";
      var L = 0;
      var N = "";
      Result = "";
      L = this.IndexOfName(Name);
      if (L !== -1) this.GetNameValue(L,{get: function () {
          return N;
        }, set: function (v) {
          N = v;
        }},{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetLBS = function () {
      var Result = 0;
      this.CheckSpecialChars();
      Result = this.FLBS;
      return Result;
    };
    this.SetLBS = function (AValue) {
      this.CheckSpecialChars();
      this.FLBS = AValue;
    };
    this.SetCommaText = function (Value) {
      var C1 = "\x00";
      var C2 = "\x00";
      this.CheckSpecialChars();
      C1 = this.GetDelimiter();
      C2 = this.GetQuoteChar();
      this.SetDelimiter(",");
      this.SetQuoteChar('"');
      try {
        this.SetDelimitedText(Value);
      } finally {
        this.SetDelimiter(C1);
        this.SetQuoteChar(C2);
      };
    };
    this.SetValue = function (Name, Value) {
      var L = 0;
      this.CheckSpecialChars();
      L = this.IndexOfName(Name);
      if (L === -1) {
        this.Add(Name + this.FNameValueSeparator + Value)}
       else this.Put(L,Name + this.FNameValueSeparator + Value);
    };
    this.SetDelimiter = function (c) {
      this.CheckSpecialChars();
      this.FDelimiter = c;
    };
    this.SetQuoteChar = function (c) {
      this.CheckSpecialChars();
      this.FQuoteChar = c;
    };
    this.SetNameValueSeparator = function (c) {
      this.CheckSpecialChars();
      this.FNameValueSeparator = c;
    };
    this.DoSetTextStr = function (Value, DoClear) {
      var S = "";
      var P = 0;
      try {
        this.BeginUpdate();
        if (DoClear) this.Clear();
        P = 1;
        while (this.GetNextLinebreak(Value,{get: function () {
            return S;
          }, set: function (v) {
            S = v;
          }},{get: function () {
            return P;
          }, set: function (v) {
            P = v;
          }})) this.Add(S);
      } finally {
        this.EndUpdate();
      };
    };
    this.GetDelimiter = function () {
      var Result = "\x00";
      this.CheckSpecialChars();
      Result = this.FDelimiter;
      return Result;
    };
    this.GetNameValueSeparator = function () {
      var Result = "\x00";
      this.CheckSpecialChars();
      Result = this.FNameValueSeparator;
      return Result;
    };
    this.GetQuoteChar = function () {
      var Result = "\x00";
      this.CheckSpecialChars();
      Result = this.FQuoteChar;
      return Result;
    };
    this.GetLineBreak = function () {
      var Result = "";
      this.CheckSpecialChars();
      Result = this.FLineBreak;
      return Result;
    };
    this.SetLineBreak = function (S) {
      this.CheckSpecialChars();
      this.FLineBreak = S;
    };
    this.GetSkipLastLineBreak = function () {
      var Result = false;
      this.CheckSpecialChars();
      Result = this.FSkipLastLineBreak;
      return Result;
    };
    this.SetSkipLastLineBreak = function (AValue) {
      this.CheckSpecialChars();
      this.FSkipLastLineBreak = AValue;
    };
    this.ReadData = function (Reader) {
      Reader.ReadListBegin();
      this.BeginUpdate();
      try {
        this.Clear();
        while (!Reader.EndOfList()) this.Add(Reader.ReadString());
      } finally {
        this.EndUpdate();
      };
      Reader.ReadListEnd();
    };
    this.WriteData = function (Writer) {
      var i = 0;
      Writer.WriteListBegin();
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        Writer.WriteString(this.Get(i));
      };
      Writer.WriteListEnd();
    };
    this.DefineProperties = function (Filer) {
      var HasData = false;
      if (Filer.FAncestor != null) {
        if (Filer.FAncestor.$class.InheritsFrom($mod.TStrings)) {
          HasData = !this.Equals$2(Filer.FAncestor)}
         else HasData = true}
       else HasData = this.GetCount() > 0;
      Filer.DefineProperty("Strings",rtl.createCallback(this,"ReadData"),rtl.createCallback(this,"WriteData"),HasData);
    };
    this.Error = function (Msg, Data) {
      throw $mod.EStringListError.$create("CreateFmt",[Msg,pas.System.VarRecs(18,pas.SysUtils.IntToStr(Data))]);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.GetCount();
      return Result;
    };
    this.GetObject = function (Index) {
      var Result = null;
      if (Index === 0) ;
      Result = null;
      return Result;
    };
    this.GetTextStr = function () {
      var Result = "";
      var I = 0;
      var S = "";
      var NL = "";
      this.CheckSpecialChars();
      if (this.FLineBreak !== pas.System.sLineBreak) {
        NL = this.FLineBreak}
       else {
        var $tmp = this.FLBS;
        if ($tmp === pas.System.TTextLineBreakStyle.tlbsLF) {
          NL = "\n"}
         else if ($tmp === pas.System.TTextLineBreakStyle.tlbsCRLF) {
          NL = "\r\n"}
         else if ($tmp === pas.System.TTextLineBreakStyle.tlbsCR) NL = "\r";
      };
      Result = "";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        S = this.Get(I);
        Result = Result + S;
        if ((I < (this.GetCount() - 1)) || !this.GetSkipLastLineBreak()) Result = Result + NL;
      };
      return Result;
    };
    this.Put = function (Index, S) {
      var Obj = null;
      Obj = this.GetObject(Index);
      this.Delete(Index);
      this.InsertObject(Index,S,Obj);
    };
    this.PutObject = function (Index, AObject) {
      if (Index === 0) return;
      if (AObject === null) return;
    };
    this.SetCapacity = function (NewCapacity) {
      if (NewCapacity === 0) ;
    };
    this.SetTextStr = function (Value) {
      this.CheckSpecialChars();
      this.DoSetTextStr(Value,true);
    };
    this.SetUpdateState = function (Updating) {
      if (Updating) ;
    };
    this.DoCompareText = function (s1, s2) {
      var Result = 0;
      Result = pas.SysUtils.CompareText(s1,s2);
      return Result;
    };
    this.GetDelimitedText = function () {
      var Result = "";
      var I = 0;
      var RE = "";
      var S = "";
      var doQuote = false;
      this.CheckSpecialChars();
      Result = "";
      RE = this.GetQuoteChar() + "|" + this.GetDelimiter();
      if (!this.FStrictDelimiter) RE = " |" + RE;
      RE = "/" + RE + "/";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        S = this.Get(I);
        doQuote = this.FAlwaysQuote || (S.search(RE) !== -1);
        if (doQuote) {
          Result = Result + pas.SysUtils.QuoteString(S,this.GetQuoteChar())}
         else Result = Result + S;
        if (I < (this.GetCount() - 1)) Result = Result + this.GetDelimiter();
      };
      if ((Result.length === 0) && (this.GetCount() === 1)) Result = this.GetQuoteChar() + this.GetQuoteChar();
      return Result;
    };
    this.SetDelimitedText = function (AValue) {
      var i = 0;
      var j = 0;
      var aNotFirst = false;
      this.CheckSpecialChars();
      this.BeginUpdate();
      i = 1;
      j = 1;
      aNotFirst = false;
      try {
        this.Clear();
        if (this.FStrictDelimiter) {
          while (i <= AValue.length) {
            if (aNotFirst && (i <= AValue.length) && (AValue.charAt(i - 1) === this.FDelimiter)) i += 1;
            if (i <= AValue.length) {
              if (AValue.charAt(i - 1) === this.FQuoteChar) {
                j = i + 1;
                while ((j <= AValue.length) && ((AValue.charAt(j - 1) !== this.FQuoteChar) || (((j + 1) <= AValue.length) && (AValue.charAt((j + 1) - 1) === this.FQuoteChar)))) {
                  if ((j <= AValue.length) && (AValue.charAt(j - 1) === this.FQuoteChar)) {
                    j += 2}
                   else j += 1;
                };
                this.Add(pas.SysUtils.StringReplace(pas.System.Copy(AValue,i + 1,j - i - 1),this.FQuoteChar + this.FQuoteChar,this.FQuoteChar,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
                i = j + 1;
              } else {
                j = i;
                while ((j <= AValue.length) && (AValue.charAt(j - 1) !== this.FDelimiter)) j += 1;
                this.Add(pas.System.Copy(AValue,i,j - i));
                i = j;
              };
            } else {
              if (aNotFirst) this.Add("");
            };
            aNotFirst = true;
          };
        } else {
          while (i <= AValue.length) {
            if (aNotFirst && (i <= AValue.length) && (AValue.charAt(i - 1) === this.FDelimiter)) i += 1;
            while ((i <= AValue.length) && (AValue.charCodeAt(i - 1) <= 32)) i += 1;
            if (i <= AValue.length) {
              if (AValue.charAt(i - 1) === this.FQuoteChar) {
                j = i + 1;
                while ((j <= AValue.length) && ((AValue.charAt(j - 1) !== this.FQuoteChar) || (((j + 1) <= AValue.length) && (AValue.charAt((j + 1) - 1) === this.FQuoteChar)))) {
                  if ((j <= AValue.length) && (AValue.charAt(j - 1) === this.FQuoteChar)) {
                    j += 2}
                   else j += 1;
                };
                this.Add(pas.SysUtils.StringReplace(pas.System.Copy(AValue,i + 1,j - i - 1),this.FQuoteChar + this.FQuoteChar,this.FQuoteChar,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
                i = j + 1;
              } else {
                j = i;
                while ((j <= AValue.length) && (AValue.charCodeAt(j - 1) > 32) && (AValue.charAt(j - 1) !== this.FDelimiter)) j += 1;
                this.Add(pas.System.Copy(AValue,i,j - i));
                i = j;
              };
            } else {
              if (aNotFirst) this.Add("");
            };
            while ((i <= AValue.length) && (AValue.charCodeAt(i - 1) <= 32)) i += 1;
            aNotFirst = true;
          };
        };
      } finally {
        this.EndUpdate();
      };
    };
    this.GetValueFromIndex = function (Index) {
      var Result = "";
      var N = "";
      this.GetNameValue(Index,{get: function () {
          return N;
        }, set: function (v) {
          N = v;
        }},{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.SetValueFromIndex = function (Index, Value) {
      if (Value === "") {
        this.Delete(Index)}
       else {
        if (Index < 0) Index = this.Add("");
        this.CheckSpecialChars();
        this.Put(Index,this.GetName(Index) + this.FNameValueSeparator + Value);
      };
    };
    this.CheckSpecialChars = function () {
      if (!this.FSpecialCharsInited) {
        this.FQuoteChar = '"';
        this.FDelimiter = ",";
        this.FNameValueSeparator = "=";
        this.FLBS = pas.System.DefaultTextLineBreakStyle;
        this.FSpecialCharsInited = true;
        this.FLineBreak = pas.System.sLineBreak;
      };
    };
    this.GetNextLinebreak = function (Value, S, P) {
      var Result = false;
      var PPLF = 0;
      var PPCR = 0;
      var PP = 0;
      var PL = 0;
      S.set("");
      Result = false;
      if ((Value.length - P.get()) < 0) return Result;
      PPLF = Value.indexOf("\n",P.get() - 1) + 1;
      PPCR = Value.indexOf("\r",P.get() - 1) + 1;
      PL = 1;
      if ((PPLF > 0) && (PPCR > 0)) {
        if ((PPLF - PPCR) === 1) PL = 2;
        if (PPLF < PPCR) {
          PP = PPLF}
         else PP = PPCR;
      } else if ((PPLF > 0) && (PPCR < 1)) {
        PP = PPLF}
       else if ((PPCR > 0) && (PPLF < 1)) {
        PP = PPCR}
       else PP = Value.length + 1;
      S.set(pas.System.Copy(Value,P.get(),PP - P.get()));
      P.set(PP + PL);
      Result = true;
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FAlwaysQuote = false;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.ToObjectArray = function () {
      var Result = [];
      Result = this.ToObjectArray$1(0,this.GetCount() - 1);
      return Result;
    };
    this.ToObjectArray$1 = function (aStart, aEnd) {
      var Result = [];
      var I = 0;
      Result = [];
      if (aStart > aEnd) return Result;
      Result = rtl.arraySetLength(Result,null,(aEnd - aStart) + 1);
      for (var $l = aStart, $end = aEnd; $l <= $end; $l++) {
        I = $l;
        Result[I - aStart] = this.GetObject(I);
      };
      return Result;
    };
    this.ToStringArray = function () {
      var Result = [];
      Result = this.ToStringArray$1(0,this.GetCount() - 1);
      return Result;
    };
    this.ToStringArray$1 = function (aStart, aEnd) {
      var Result = [];
      var I = 0;
      Result = [];
      if (aStart > aEnd) return Result;
      Result = rtl.arraySetLength(Result,"",(aEnd - aStart) + 1);
      for (var $l = aStart, $end = aEnd; $l <= $end; $l++) {
        I = $l;
        Result[I - aStart] = this.Get(I);
      };
      return Result;
    };
    this.Add = function (S) {
      var Result = 0;
      Result = this.GetCount();
      this.Insert(this.GetCount(),S);
      return Result;
    };
    this.Add$1 = function (Fmt, Args) {
      var Result = 0;
      Result = this.Add(pas.SysUtils.Format(Fmt,Args));
      return Result;
    };
    this.AddFmt = function (Fmt, Args) {
      var Result = 0;
      Result = this.Add(pas.SysUtils.Format(Fmt,Args));
      return Result;
    };
    this.AddObject = function (S, AObject) {
      var Result = 0;
      Result = this.Add(S);
      this.PutObject(Result,AObject);
      return Result;
    };
    this.AddObject$1 = function (Fmt, Args, AObject) {
      var Result = 0;
      Result = this.AddObject(pas.SysUtils.Format(Fmt,Args),AObject);
      return Result;
    };
    this.Append = function (S) {
      this.Add(S);
    };
    this.AddStrings = function (TheStrings) {
      var Runner = 0;
      for (var $l = 0, $end = TheStrings.GetCount() - 1; $l <= $end; $l++) {
        Runner = $l;
        this.AddObject(TheStrings.Get(Runner),TheStrings.GetObject(Runner));
      };
    };
    this.AddStrings$1 = function (TheStrings, ClearFirst) {
      this.BeginUpdate();
      try {
        if (ClearFirst) this.Clear();
        this.AddStrings(TheStrings);
      } finally {
        this.EndUpdate();
      };
    };
    this.AddStrings$2 = function (TheStrings) {
      var Runner = 0;
      if ((this.GetCount() + (rtl.length(TheStrings) - 1) + 1) > this.GetCapacity()) this.SetCapacity(this.GetCount() + (rtl.length(TheStrings) - 1) + 1);
      for (var $l = 0, $end = rtl.length(TheStrings) - 1; $l <= $end; $l++) {
        Runner = $l;
        this.Add(TheStrings[Runner]);
      };
    };
    this.AddStrings$3 = function (TheStrings, ClearFirst) {
      this.BeginUpdate();
      try {
        if (ClearFirst) this.Clear();
        this.AddStrings$2(TheStrings);
      } finally {
        this.EndUpdate();
      };
    };
    this.AddPair = function (AName, AValue) {
      var Result = null;
      Result = this.AddPair$1(AName,AValue,null);
      return Result;
    };
    this.AddPair$1 = function (AName, AValue, AObject) {
      var Result = null;
      Result = this;
      this.AddObject(AName + this.GetNameValueSeparator() + AValue,AObject);
      return Result;
    };
    this.AddText = function (S) {
      this.CheckSpecialChars();
      this.DoSetTextStr(S,false);
    };
    this.Assign = function (Source) {
      var S = null;
      if ($mod.TStrings.isPrototypeOf(Source)) {
        S = Source;
        this.BeginUpdate();
        try {
          this.Clear();
          this.FSpecialCharsInited = S.FSpecialCharsInited;
          this.FQuoteChar = S.FQuoteChar;
          this.FDelimiter = S.FDelimiter;
          this.FNameValueSeparator = S.FNameValueSeparator;
          this.FLBS = S.FLBS;
          this.FLineBreak = S.FLineBreak;
          this.AddStrings(S);
        } finally {
          this.EndUpdate();
        };
      } else $mod.TPersistent.Assign.call(this,Source);
    };
    this.BeginUpdate = function () {
      if (this.FUpdateCount === 0) this.SetUpdateState(true);
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      if (this.FUpdateCount > 0) this.FUpdateCount -= 1;
      if (this.FUpdateCount === 0) this.SetUpdateState(false);
    };
    this.Equals = function (Obj) {
      var Result = false;
      if ($mod.TStrings.isPrototypeOf(Obj)) {
        Result = this.Equals$2(Obj)}
       else Result = pas.System.TObject.Equals.call(this,Obj);
      return Result;
    };
    this.Equals$2 = function (TheStrings) {
      var Result = false;
      var Runner = 0;
      var Nr = 0;
      Result = false;
      Nr = this.GetCount();
      if (Nr !== TheStrings.GetCount()) return Result;
      for (var $l = 0, $end = Nr - 1; $l <= $end; $l++) {
        Runner = $l;
        if (this.Get(Runner) !== TheStrings.Get(Runner)) return Result;
      };
      Result = true;
      return Result;
    };
    this.Exchange = function (Index1, Index2) {
      var Obj = null;
      var Str = "";
      this.BeginUpdate();
      try {
        Obj = this.GetObject(Index1);
        Str = this.Get(Index1);
        this.PutObject(Index1,this.GetObject(Index2));
        this.Put(Index1,this.Get(Index2));
        this.PutObject(Index2,Obj);
        this.Put(Index2,Str);
      } finally {
        this.EndUpdate();
      };
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TStringsEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.IndexOf = function (S) {
      var Result = 0;
      Result = 0;
      while ((Result < this.GetCount()) && (this.DoCompareText(this.Get(Result),S) !== 0)) Result = Result + 1;
      if (Result === this.GetCount()) Result = -1;
      return Result;
    };
    this.IndexOfName = function (Name) {
      var Result = 0;
      var len = 0;
      var S = "";
      this.CheckSpecialChars();
      Result = 0;
      while (Result < this.GetCount()) {
        S = this.Get(Result);
        len = pas.System.Pos(this.FNameValueSeparator,S) - 1;
        if ((len >= 0) && (this.DoCompareText(Name,pas.System.Copy(S,1,len)) === 0)) return Result;
        Result += 1;
      };
      Result = -1;
      return Result;
    };
    this.IndexOfObject = function (AObject) {
      var Result = 0;
      Result = 0;
      while ((Result < this.GetCount()) && (this.GetObject(Result) !== AObject)) Result = Result + 1;
      if (Result === this.GetCount()) Result = -1;
      return Result;
    };
    this.InsertObject = function (Index, S, AObject) {
      this.Insert(Index,S);
      this.PutObject(Index,AObject);
    };
    this.Move = function (CurIndex, NewIndex) {
      var Obj = null;
      var Str = "";
      this.BeginUpdate();
      try {
        Obj = this.GetObject(CurIndex);
        Str = this.Get(CurIndex);
        this.PutObject(CurIndex,null);
        this.Delete(CurIndex);
        this.InsertObject(NewIndex,Str,Obj);
      } finally {
        this.EndUpdate();
      };
    };
    this.GetNameValue = function (Index, AName, AValue) {
      var L = 0;
      this.CheckSpecialChars();
      AValue.set(this.Get(Index));
      L = pas.System.Pos(this.FNameValueSeparator,AValue.get());
      if (L !== 0) {
        AName.set(pas.System.Copy(AValue.get(),1,L - 1));
        AValue.set(pas.System.Copy(AValue.get(),L + 1,AValue.get().length - L));
      } else AName.set("");
    };
    this.LoadFromURL = function (aURL, Async, OnLoaded, OnError) {
      var $Self = this;
      function DoLoaded(aString) {
        $Self.SetTextStr(aString);
        if (OnLoaded != null) OnLoaded($Self);
      };
      function DoError(AError) {
        if (OnError != null) {
          OnError($Self,AError)}
         else throw pas.SysUtils.EInOutError.$create("Create$1",["Failed to load from URL:" + AError]);
      };
      $impl.CheckLoadHelper();
      $impl.GlobalLoadHelper.LoadText(aURL,Async,DoLoaded,DoError);
    };
    this.LoadFromFile = function (aFileName) {
      var a = [];
      a = $impl.URLToArrayOfString(aFileName);
      this.AddStrings$3(a,true);
    };
    this.LoadFromFile$1 = function (aFileName, OnLoaded, AError) {
      var $Self = this;
      this.LoadFromURL(aFileName,false,function (Sender) {
        if (OnLoaded != null) OnLoaded();
      },function (Sender, ErrorMsg) {
        if (AError != null) AError(ErrorMsg);
      });
    };
    this.LoadFromFileAsync = function (aFileName) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $impl.ReqAsync(aFileName,function (AResponse) {
          ASuccess(true);
          $Self.SetTextStr(AResponse);
        },function () {
          ASuccess(false);
        });
      });
      return Result;
    };
    this.ExtractName = function (S) {
      var Result = "";
      var L = 0;
      this.CheckSpecialChars();
      L = pas.System.Pos(this.FNameValueSeparator,S);
      if (L !== 0) {
        Result = pas.System.Copy(S,1,L - 1)}
       else Result = "";
      return Result;
    };
    this.SaveToFile = function (FileName) {
      var AText = "";
      AText = this.GetTextStr();
      var element = document.createElement('a');
      element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(AText));
      if (FileName != ''){
        element.setAttribute('download', FileName);
      }
      element.style.display = 'none';
      document.body.appendChild(element);
      element.click();
      document.body.removeChild(element);
    };
  });
  rtl.recNewT(this,"TStringItem",function () {
    this.FString = "";
    this.FObject = null;
    this.$eq = function (b) {
      return (this.FString === b.FString) && (this.FObject === b.FObject);
    };
    this.$assign = function (s) {
      this.FString = s.FString;
      this.FObject = s.FObject;
      return this;
    };
    var $r = $mod.$rtti.$Record("TStringItem",{},this);
    $r.addField("FString",rtl.string);
    $r.addField("FObject",pas.System.$rtti["TObject"]);
  });
  this.TStringsOption = {"0": "soStrictDelimiter", soStrictDelimiter: 0, "1": "soWriteBOM", soWriteBOM: 1, "2": "soTrailingLineBreak", soTrailingLineBreak: 2, "3": "soUseLocale", soUseLocale: 3};
  this.$rtti.$Enum("TStringsOption",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TStringsOption});
  this.$rtti.$Set("TStringsOptions",{comptype: this.$rtti["TStringsOption"]});
  this.$rtti.$DynArray("TStringItemArray",{eltype: this.$rtti["TStringItem"]});
  this.$rtti.$Class("TStringList");
  this.$rtti.$ProcVar("TStringListSortCompare",{procsig: rtl.newTIProcSig([["List",this.$rtti["TStringList"]],["Index1",rtl.longint],["Index2",rtl.longint]],rtl.longint)});
  this.TStringsSortStyle = {"0": "sslNone", sslNone: 0, "1": "sslUser", sslUser: 1, "2": "sslAuto", sslAuto: 2};
  this.$rtti.$Enum("TStringsSortStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TStringsSortStyle});
  this.$rtti.$Set("TStringsSortStyles",{comptype: this.$rtti["TStringsSortStyle"]});
  rtl.createClass(this,"TStringList",this.TStrings,function () {
    this.$init = function () {
      $mod.TStrings.$init.call(this);
      this.FList = [];
      this.FCount = 0;
      this.FOnChange = null;
      this.FOnChanging = null;
      this.FDuplicates = 0;
      this.FCaseSensitive = false;
      this.FForceSort = false;
      this.FOwnsObjects = false;
      this.FSortStyle = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      this.FOnChange = undefined;
      this.FOnChanging = undefined;
      $mod.TStrings.$final.call(this);
    };
    this.ExchangeItemsInt = function (Index1, Index2) {
      var S = "";
      var O = null;
      S = this.FList[Index1].FString;
      O = this.FList[Index1].FObject;
      this.FList[Index1].FString = this.FList[Index2].FString;
      this.FList[Index1].FObject = this.FList[Index2].FObject;
      this.FList[Index2].FString = S;
      this.FList[Index2].FObject = O;
    };
    this.GetSorted = function () {
      var Result = false;
      Result = this.FSortStyle in rtl.createSet($mod.TStringsSortStyle.sslUser,$mod.TStringsSortStyle.sslAuto);
      return Result;
    };
    this.Grow = function () {
      var NC = 0;
      NC = this.GetCapacity();
      if (NC >= 256) {
        NC = NC + rtl.trunc(NC / 4)}
       else if (NC === 0) {
        NC = 4}
       else NC = NC * 4;
      this.SetCapacity(NC);
    };
    this.InternalClear = function (FromIndex, ClearOnly) {
      var I = 0;
      if (FromIndex < this.FCount) {
        if (this.FOwnsObjects) {
          for (var $l = FromIndex, $end = this.FCount - 1; $l <= $end; $l++) {
            I = $l;
            this.FList[I].FString = "";
            pas.SysUtils.FreeAndNil({p: this.FList[I], get: function () {
                return this.p.FObject;
              }, set: function (v) {
                this.p.FObject = v;
              }});
          };
        } else {
          for (var $l1 = FromIndex, $end1 = this.FCount - 1; $l1 <= $end1; $l1++) {
            I = $l1;
            this.FList[I].FString = "";
          };
        };
        this.FCount = FromIndex;
      };
      if (!ClearOnly) this.SetCapacity(0);
    };
    this.QuickSort = function (L, R, CompareFn) {
      var Pivot = 0;
      var vL = 0;
      var vR = 0;
      if ((R - L) <= 1) {
        if (L < R) if (CompareFn(this,L,R) > 0) this.ExchangeItems(L,R);
        return;
      };
      vL = L;
      vR = R;
      Pivot = L + pas.System.Random(R - L);
      while (vL < vR) {
        while ((vL < Pivot) && (CompareFn(this,vL,Pivot) <= 0)) vL += 1;
        while ((vR > Pivot) && (CompareFn(this,vR,Pivot) > 0)) vR -= 1;
        this.ExchangeItems(vL,vR);
        if (Pivot === vL) {
          Pivot = vR}
         else if (Pivot === vR) Pivot = vL;
      };
      if ((Pivot - 1) >= L) this.QuickSort(L,Pivot - 1,CompareFn);
      if ((Pivot + 1) <= R) this.QuickSort(Pivot + 1,R,CompareFn);
    };
    this.SetSorted = function (Value) {
      if (Value) {
        this.SetSortStyle($mod.TStringsSortStyle.sslAuto)}
       else this.SetSortStyle($mod.TStringsSortStyle.sslNone);
    };
    this.SetCaseSensitive = function (b) {
      if (b === this.FCaseSensitive) return;
      this.FCaseSensitive = b;
      if (this.FSortStyle === $mod.TStringsSortStyle.sslAuto) {
        this.FForceSort = true;
        try {
          this.Sort();
        } finally {
          this.FForceSort = false;
        };
      };
    };
    this.SetSortStyle = function (AValue) {
      if (this.FSortStyle === AValue) return;
      if (AValue === $mod.TStringsSortStyle.sslAuto) this.Sort();
      this.FSortStyle = AValue;
    };
    this.GetTrailingLineBreak = function () {
      var Result = false;
      Result = !this.GetSkipLastLineBreak();
      return Result;
    };
    this.SetTrailingLineBreak = function (Value) {
      this.SetSkipLastLineBreak(!Value);
    };
    this.CheckIndex = function (AIndex) {
      if ((AIndex < 0) || (AIndex >= this.FCount)) this.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),AIndex);
    };
    this.ExchangeItems = function (Index1, Index2) {
      this.ExchangeItemsInt(Index1,Index2);
    };
    this.Changed = function () {
      if (this.FUpdateCount === 0) {
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.Changing = function () {
      if (this.FUpdateCount === 0) if (this.FOnChanging != null) this.FOnChanging(this);
    };
    this.Get = function (Index) {
      var Result = "";
      this.CheckIndex(Index);
      Result = this.FList[Index].FString;
      return Result;
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FList);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FCount;
      return Result;
    };
    this.GetObject = function (Index) {
      var Result = null;
      this.CheckIndex(Index);
      Result = this.FList[Index].FObject;
      return Result;
    };
    this.Put = function (Index, S) {
      if (this.GetSorted()) this.Error(rtl.getResStr(pas.RTLConsts,"SSortedListError"),0);
      this.CheckIndex(Index);
      this.Changing();
      this.FList[Index].FString = S;
      this.Changed();
    };
    this.PutObject = function (Index, AObject) {
      this.CheckIndex(Index);
      this.Changing();
      this.FList[Index].FObject = AObject;
      this.Changed();
    };
    this.SetCapacity = function (NewCapacity) {
      if (NewCapacity < 0) this.Error(rtl.getResStr(pas.RTLConsts,"SListCapacityError"),NewCapacity);
      if (NewCapacity !== this.GetCapacity()) this.FList = rtl.arraySetLength(this.FList,$mod.TStringItem,NewCapacity);
    };
    this.SetUpdateState = function (Updating) {
      if (Updating) {
        this.Changing()}
       else this.Changed();
    };
    this.InsertItem = function (Index, S) {
      this.InsertItem$1(Index,S,null);
    };
    this.InsertItem$1 = function (Index, S, O) {
      var It = $mod.TStringItem.$new();
      this.Changing();
      if (this.FCount === this.GetCapacity()) this.Grow();
      It.FString = S;
      It.FObject = O;
      this.FList.splice(Index,0,It);
      this.FCount += 1;
      this.Changed();
    };
    this.DoCompareText = function (s1, s2) {
      var Result = 0;
      Result = this.CompareStrings(s1,s2);
      return Result;
    };
    this.CompareStrings = function (s1, s2) {
      var Result = 0;
      if (this.FCaseSensitive) {
        Result = pas.SysUtils.CompareStr(s1,s2)}
       else Result = pas.SysUtils.CompareText(s1,s2);
      return Result;
    };
    this.Create$2 = function (AOwnsObjects) {
      $mod.TStrings.Create$1.call(this);
      this.FOwnsObjects = AOwnsObjects;
      return this;
    };
    this.Create$3 = function (AQuoteChar, ADelimiter) {
      $mod.TStrings.Create$1.call(this);
      this.SetQuoteChar(AQuoteChar);
      this.SetDelimiter(ADelimiter);
      return this;
    };
    this.Create$4 = function (AQuoteChar, ADelimiter, AOptions) {
      $mod.TStrings.Create$1.call(this);
      this.SetQuoteChar(AQuoteChar);
      this.SetDelimiter(ADelimiter);
      this.FStrictDelimiter = $mod.TStringsOption.soStrictDelimiter in AOptions;
      return this;
    };
    this.Create$5 = function (ADuplicates, ASorted, ACaseSensitive) {
      $mod.TStrings.Create$1.call(this);
      this.FDuplicates = ADuplicates;
      this.SetSorted(ASorted);
      this.SetCaseSensitive(ACaseSensitive);
      return this;
    };
    this.Destroy = function () {
      this.InternalClear(0,false);
      $mod.TStrings.Destroy.call(this);
    };
    this.Add = function (S) {
      var Result = 0;
      if (!(this.FSortStyle === $mod.TStringsSortStyle.sslAuto)) {
        Result = this.FCount}
       else if (this.Find(S,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) {
        var $tmp = this.FDuplicates;
        if ($tmp === pas.Types.TDuplicates.dupIgnore) {
          return Result}
         else if ($tmp === pas.Types.TDuplicates.dupError) this.Error(rtl.getResStr(pas.RTLConsts,"SDuplicateString"),0);
      };
      this.InsertItem(Result,S);
      return Result;
    };
    this.Clear = function () {
      if (this.FCount === 0) return;
      this.Changing();
      this.InternalClear(0,false);
      this.Changed();
    };
    this.Delete = function (Index) {
      this.CheckIndex(Index);
      this.Changing();
      if (this.FOwnsObjects) pas.SysUtils.FreeAndNil({p: this.FList[Index], get: function () {
          return this.p.FObject;
        }, set: function (v) {
          this.p.FObject = v;
        }});
      this.FList.splice(Index,1);
      this.FList[this.GetCount() - 1].FString = "";
      this.FList[this.GetCount() - 1].FObject = null;
      this.FCount -= 1;
      this.Changed();
    };
    this.Exchange = function (Index1, Index2) {
      this.CheckIndex(Index1);
      this.CheckIndex(Index2);
      this.Changing();
      this.ExchangeItemsInt(Index1,Index2);
      this.Changed();
    };
    this.Find = function (S, Index) {
      var Result = false;
      var L = 0;
      var R = 0;
      var I = 0;
      var CompareRes = 0;
      Result = false;
      Index.set(-1);
      if (!this.GetSorted()) throw $mod.EListError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrFindNeedsSortedList")]);
      L = 0;
      R = this.GetCount() - 1;
      while (L <= R) {
        I = L + rtl.trunc((R - L) / 2);
        CompareRes = this.DoCompareText(S,this.FList[I].FString);
        if (CompareRes > 0) {
          L = I + 1}
         else {
          R = I - 1;
          if (CompareRes === 0) {
            Result = true;
            if (this.FDuplicates !== pas.Types.TDuplicates.dupAccept) L = I;
          };
        };
      };
      Index.set(L);
      return Result;
    };
    this.IndexOf = function (S) {
      var Result = 0;
      if (!this.GetSorted()) {
        Result = $mod.TStrings.IndexOf.call(this,S)}
       else if (!this.Find(S,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = -1;
      return Result;
    };
    this.Insert = function (Index, S) {
      if (this.FSortStyle === $mod.TStringsSortStyle.sslAuto) {
        this.Error(rtl.getResStr(pas.RTLConsts,"SSortedListError"),0)}
       else {
        if ((Index < 0) || (Index > this.FCount)) this.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),Index);
        this.InsertItem(Index,S);
      };
    };
    this.Sort = function () {
      this.CustomSort($impl.StringListAnsiCompare);
    };
    this.CustomSort = function (CompareFn) {
      if ((this.FForceSort || !(this.FSortStyle === $mod.TStringsSortStyle.sslAuto)) && (this.FCount > 1)) {
        this.Changing();
        this.QuickSort(0,this.FCount - 1,CompareFn);
        this.Changed();
      };
    };
  });
  this.$rtti.$Class("TCollection");
  rtl.createClass(this,"TCollectionItem",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FCollection = null;
      this.FID = 0;
      this.FUpdateCount = 0;
    };
    this.$final = function () {
      this.FCollection = undefined;
      $mod.TPersistent.$final.call(this);
    };
    this.GetIndex = function () {
      var Result = 0;
      if (this.FCollection != null) {
        Result = this.FCollection.FItems.IndexOf(this)}
       else Result = -1;
      return Result;
    };
    this.SetCollection = function (Value) {
      if (Value !== this.FCollection) {
        if (this.FCollection != null) this.FCollection.RemoveItem(this);
        if (Value != null) Value.InsertItem(this);
      };
    };
    this.Changed = function (AllItems) {
      if ((this.FCollection !== null) && (this.FCollection.FUpdateCount === 0)) {
        if (AllItems) {
          this.FCollection.Update(null)}
         else this.FCollection.Update(this);
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FCollection;
      return Result;
    };
    this.GetDisplayName = function () {
      var Result = "";
      Result = this.$classname;
      return Result;
    };
    this.SetIndex = function (Value) {
      var Temp = 0;
      Temp = this.GetIndex();
      if ((Temp > -1) && (Temp !== Value)) {
        this.FCollection.FItems.Move(Temp,Value);
        this.Changed(true);
      };
    };
    this.SetDisplayName = function (Value) {
      this.Changed(false);
      if (Value === "") ;
    };
    this.Create$1 = function (ACollection) {
      pas.System.TObject.Create.call(this);
      this.SetCollection(ACollection);
      return this;
    };
    this.Destroy = function () {
      this.SetCollection(null);
      pas.System.TObject.Destroy.call(this);
    };
    this.GetNamePath = function () {
      var Result = "";
      if (this.FCollection !== null) {
        Result = this.FCollection.GetNamePath() + "[" + pas.SysUtils.IntToStr(this.GetIndex()) + "]"}
       else Result = this.$classname;
      return Result;
    };
  });
  rtl.createClass(this,"TCollectionEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FCollection = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FCollection = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (ACollection) {
      pas.System.TObject.Create.call(this);
      this.FCollection = ACollection;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FCollection.GetItem(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FCollection.GetCount();
      return Result;
    };
  });
  this.$rtti.$ClassRef("TCollectionItemClass",{instancetype: this.$rtti["TCollectionItem"]});
  this.TCollectionNotification = {"0": "cnAdded", cnAdded: 0, "1": "cnExtracting", cnExtracting: 1, "2": "cnDeleting", cnDeleting: 2};
  this.$rtti.$Enum("TCollectionNotification",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCollectionNotification});
  this.$rtti.$ProcVar("TCollectionSortCompare",{procsig: rtl.newTIProcSig([["Item1",this.$rtti["TCollectionItem"]],["Item2",this.$rtti["TCollectionItem"]]],rtl.longint)});
  this.$rtti.$RefToProcVar("TCollectionSortCompareFunc",{procsig: rtl.newTIProcSig([["Item1",this.$rtti["TCollectionItem"]],["Item2",this.$rtti["TCollectionItem"]]],rtl.longint)});
  rtl.createClass(this,"TCollection",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FItemClass = null;
      this.FItems = null;
      this.FUpdateCount = 0;
      this.FNextID = 0;
      this.FPropName = "";
    };
    this.$final = function () {
      this.FItemClass = undefined;
      this.FItems = undefined;
      $mod.TPersistent.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FItems.FCount;
      return Result;
    };
    this.GetPropName = function () {
      var Result = "";
      Result = this.FPropName;
      this.SetPropName();
      Result = this.FPropName;
      return Result;
    };
    this.InsertItem = function (Item) {
      if (!this.FItemClass.isPrototypeOf(Item)) return;
      this.FItems.Add(Item);
      Item.FCollection = this;
      Item.FID = this.FNextID;
      this.FNextID += 1;
      this.SetItemName(Item);
      this.Notify(Item,$mod.TCollectionNotification.cnAdded);
      this.Changed();
    };
    this.RemoveItem = function (Item) {
      var I = 0;
      this.Notify(Item,$mod.TCollectionNotification.cnExtracting);
      I = this.FItems.IndexOfItem(Item,pas.Types.TDirection.FromEnd);
      if (I !== -1) this.FItems.Delete(I);
      Item.FCollection = null;
      this.Changed();
    };
    this.DoClear = function () {
      var Item = null;
      while (this.FItems.FCount > 0) {
        Item = rtl.getObject(this.FItems.Last());
        if (Item != null) Item.$destroy("Destroy");
      };
    };
    this.GetAttrCount = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetAttr = function (Index) {
      var Result = "";
      Result = "";
      if (Index === 0) ;
      return Result;
    };
    this.GetItemAttr = function (Index, ItemIndex) {
      var Result = "";
      Result = rtl.getObject(this.FItems.Get(ItemIndex)).GetDisplayName();
      if (Index === 0) ;
      return Result;
    };
    this.Changed = function () {
      if (this.FUpdateCount === 0) this.Update(null);
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.FItems.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      rtl.getObject(this.FItems.Get(Index)).Assign(Value);
    };
    this.SetItemName = function (Item) {
      if (Item === null) ;
    };
    this.SetPropName = function () {
      this.FPropName = "";
    };
    this.Update = function (Item) {
      if (Item === null) ;
    };
    this.Notify = function (Item, Action) {
      if (Item === null) ;
      if (Action === $mod.TCollectionNotification.cnAdded) ;
    };
    this.Create$1 = function (AItemClass) {
      pas.System.TObject.Create.call(this);
      this.FItemClass = AItemClass;
      this.FItems = $mod.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      this.FUpdateCount = 1;
      try {
        this.DoClear();
      } finally {
        this.FUpdateCount = 0;
      };
      if (this.FItems != null) this.FItems.$destroy("Destroy");
      pas.System.TObject.Destroy.call(this);
    };
    this.Owner = function () {
      var Result = null;
      Result = this.GetOwner();
      return Result;
    };
    this.Add = function () {
      var Result = null;
      Result = this.FItemClass.$create("Create$1",[this]);
      return Result;
    };
    this.Assign = function (Source) {
      var I = 0;
      if ($mod.TCollection.isPrototypeOf(Source)) {
        this.Clear();
        for (var $l = 0, $end = Source.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.Add().Assign(Source.GetItem(I));
        };
        return;
      } else $mod.TPersistent.Assign.call(this,Source);
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.Clear = function () {
      if (this.FItems.FCount === 0) return;
      this.BeginUpdate();
      try {
        this.DoClear();
      } finally {
        this.EndUpdate();
      };
    };
    this.EndUpdate = function () {
      if (this.FUpdateCount > 0) this.FUpdateCount -= 1;
      if (this.FUpdateCount === 0) this.Changed();
    };
    this.Delete = function (Index) {
      var Item = null;
      Item = rtl.getObject(this.FItems.Get(Index));
      this.Notify(Item,$mod.TCollectionNotification.cnDeleting);
      if (Item != null) Item.$destroy("Destroy");
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TCollectionEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.GetNamePath = function () {
      var Result = "";
      var o = null;
      o = this.GetOwner();
      if ((o != null) && (this.GetPropName() !== "")) {
        Result = o.GetNamePath() + "." + this.GetPropName()}
       else Result = this.$classname;
      return Result;
    };
    this.Insert = function (Index) {
      var Result = null;
      Result = this.Add();
      Result.SetIndex(Index);
      return Result;
    };
    this.FindItemID = function (ID) {
      var Result = null;
      var I = 0;
      for (var $l = 0, $end = this.FItems.FCount - 1; $l <= $end; $l++) {
        I = $l;
        Result = rtl.getObject(this.FItems.Get(I));
        if (Result.FID === ID) return Result;
      };
      Result = null;
      return Result;
    };
    this.Exchange = function (Index1, index2) {
      this.FItems.Exchange(Index1,index2);
    };
    this.Sort = function (Compare) {
      this.BeginUpdate();
      try {
        this.FItems.Sort(Compare);
      } finally {
        this.EndUpdate();
      };
    };
    this.SortList = function (Compare) {
      this.BeginUpdate();
      try {
        this.FItems.SortList(Compare);
      } finally {
        this.EndUpdate();
      };
    };
  });
  rtl.createClass(this,"TOwnedCollection",this.TCollection,function () {
    this.$init = function () {
      $mod.TCollection.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      $mod.TCollection.$final.call(this);
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.Create$2 = function (AOwner, AItemClass) {
      this.FOwner = AOwner;
      $mod.TCollection.Create$1.call(this,AItemClass);
      return this;
    };
  });
  this.$rtti.$Class("TComponent");
  this.TOperation = {"0": "opInsert", opInsert: 0, "1": "opRemove", opRemove: 1};
  this.$rtti.$Enum("TOperation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TOperation});
  this.TComponentStateItem = {"0": "csLoading", csLoading: 0, "1": "csReading", csReading: 1, "2": "csWriting", csWriting: 2, "3": "csDestroying", csDestroying: 3, "4": "csDesigning", csDesigning: 4, "5": "csAncestor", csAncestor: 5, "6": "csUpdating", csUpdating: 6, "7": "csFixups", csFixups: 7, "8": "csFreeNotification", csFreeNotification: 8, "9": "csInline", csInline: 9, "10": "csDesignInstance", csDesignInstance: 10};
  this.$rtti.$Enum("TComponentStateItem",{minvalue: 0, maxvalue: 10, ordtype: 1, enumtype: this.TComponentStateItem});
  this.$rtti.$Set("TComponentState",{comptype: this.$rtti["TComponentStateItem"]});
  this.TComponentStyleItem = {"0": "csInheritable", csInheritable: 0, "1": "csCheckPropAvail", csCheckPropAvail: 1, "2": "csSubComponent", csSubComponent: 2, "3": "csTransient", csTransient: 3};
  this.$rtti.$Enum("TComponentStyleItem",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TComponentStyleItem});
  this.$rtti.$Set("TComponentStyle",{comptype: this.$rtti["TComponentStyleItem"]});
  this.$rtti.$MethodVar("TGetChildProc",{procsig: rtl.newTIProcSig([["Child",this.$rtti["TComponent"]]]), methodkind: 0});
  this.$rtti.$inherited("TComponentName",rtl.string,{});
  rtl.createClass(this,"TComponentEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FComponent = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FComponent = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AComponent) {
      pas.System.TObject.Create.call(this);
      this.FComponent = AComponent;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FComponent.GetComponent(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FComponent.GetComponentCount();
      return Result;
    };
  });
  rtl.createClass(this,"TComponent",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FName = "";
      this.FTag = 0;
      this.FComponents = null;
      this.FFreeNotifies = null;
      this.FDesignInfo = 0;
      this.FComponentState = {};
      this.FComponentStyle = {};
      this.FLeft = 0;
      this.FTop = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FComponents = undefined;
      this.FFreeNotifies = undefined;
      this.FComponentState = undefined;
      this.FComponentStyle = undefined;
      $mod.TPersistent.$final.call(this);
    };
    this.GetComponent = function (AIndex) {
      var Result = null;
      if (!(this.FComponents != null)) {
        Result = null}
       else Result = rtl.getObject(this.FComponents.Get(AIndex));
      return Result;
    };
    this.GetComponentCount = function () {
      var Result = 0;
      if (!(this.FComponents != null)) {
        Result = 0}
       else Result = this.FComponents.FCount;
      return Result;
    };
    this.GetComponentIndex = function () {
      var Result = 0;
      if ((this.FOwner != null) && (this.FOwner.FComponents != null)) {
        Result = this.FOwner.FComponents.IndexOf(this)}
       else Result = -1;
      return Result;
    };
    this.Insert = function (AComponent) {
      if (!(this.FComponents != null)) this.FComponents = $mod.TFPList.$create("Create");
      this.FComponents.Add(AComponent);
      AComponent.FOwner = this;
    };
    this.ReadLeft = function (AReader) {
      this.FDesignInfo = (this.FDesignInfo & 0xffff0000) | (AReader.ReadInteger() & 0xffff);
    };
    this.ReadTop = function (AReader) {
      this.FDesignInfo = ((AReader.ReadInteger() & 0xffff) << 16) | (this.FDesignInfo & 0xffff);
    };
    this.Remove = function (AComponent) {
      AComponent.FOwner = null;
      if (this.FComponents != null) {
        this.FComponents.Remove(AComponent);
        if (this.FComponents.FCount === 0) {
          this.FComponents.$destroy("Destroy");
          this.FComponents = null;
        };
      };
    };
    this.RemoveNotification = function (AComponent) {
      if (this.FFreeNotifies !== null) {
        this.FFreeNotifies.Remove(AComponent);
        if (this.FFreeNotifies.FCount === 0) {
          this.FFreeNotifies.$destroy("Destroy");
          this.FFreeNotifies = null;
          this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csFreeNotification);
        };
      };
    };
    this.SetComponentIndex = function (Value) {
      var Temp = 0;
      var Count = 0;
      if (!(this.FOwner != null)) return;
      Temp = this.GetComponentIndex();
      if (Temp < 0) return;
      if (Value < 0) Value = 0;
      Count = this.FOwner.FComponents.FCount;
      if (Value >= Count) Value = Count - 1;
      if (Value !== Temp) {
        this.FOwner.FComponents.Delete(Temp);
        this.FOwner.FComponents.Insert(Value,this);
      };
    };
    this.SetReference = function (Enable) {
      var aField = null;
      var aValue = null;
      var aOwner = null;
      if (this.FName === "") return;
      if (this.FOwner != null) {
        aOwner = this.FOwner;
        aField = this.FOwner.$class.FieldAddress(this.FName);
        if (aField != null) {
          if (Enable) {
            aValue = this}
           else aValue = null;
          aOwner["" + aField["name"]] = aValue;
        };
      };
    };
    this.WriteLeft = function (AWriter) {
      AWriter.WriteInteger(this.FDesignInfo & 0xffff);
    };
    this.WriteTop = function (AWriter) {
      AWriter.WriteInteger((this.FDesignInfo >>> 16) & 0xffff);
    };
    this.ChangeName = function (NewName) {
      this.FName = NewName;
    };
    this.DefineProperties = function (Filer) {
      var Temp = 0;
      var Ancestor = null;
      Ancestor = Filer.FAncestor;
      if (Ancestor != null) {
        Temp = Ancestor.FDesignInfo}
       else Temp = 0;
      Filer.DefineProperty("Left",rtl.createCallback(this,"ReadLeft"),rtl.createCallback(this,"WriteLeft"),(this.FDesignInfo & 0xffff) !== (Temp & 0xffff));
      Filer.DefineProperty("Top",rtl.createCallback(this,"ReadTop"),rtl.createCallback(this,"WriteTop"),(this.FDesignInfo & 0xffff0000) !== (Temp & 0xffff0000));
    };
    this.GetChildren = function (Proc, Root) {
      if (Proc === null) ;
      if (Root === null) ;
    };
    this.GetChildOwner = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetChildParent = function () {
      var Result = null;
      Result = this;
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.Loaded = function () {
      this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csLoading);
    };
    this.Loading = function () {
      this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csLoading);
    };
    this.SetWriting = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csWriting)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csWriting);
    };
    this.SetReading = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csReading)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csReading);
    };
    this.Notification = function (AComponent, Operation) {
      var C = 0;
      if (Operation === $mod.TOperation.opRemove) this.RemoveFreeNotification(AComponent);
      if (!(this.FComponents != null)) return;
      C = this.FComponents.FCount - 1;
      while (C >= 0) {
        rtl.getObject(this.FComponents.Get(C)).Notification(AComponent,Operation);
        C -= 1;
        if (C >= this.FComponents.FCount) C = this.FComponents.FCount - 1;
      };
    };
    this.PaletteCreated = function () {
    };
    this.ReadState = function (Reader) {
      Reader.ReadData(this);
    };
    this.SetAncestor = function (Value) {
      var Runner = 0;
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csAncestor)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csAncestor);
      if (this.FComponents != null) for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        Runner = $l;
        rtl.getObject(this.FComponents.Get(Runner)).SetAncestor(Value);
      };
    };
    this.SetDesigning = function (Value, SetChildren) {
      var Runner = 0;
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csDesigning)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csDesigning);
      if ((this.FComponents != null) && SetChildren) for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        Runner = $l;
        rtl.getObject(this.FComponents.Get(Runner)).SetDesigning(Value,true);
      };
    };
    this.SetDesignInstance = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csDesignInstance)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csDesignInstance);
    };
    this.SetInline = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csInline)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csInline);
    };
    this.SetName = function (NewName) {
      if (this.FName === NewName) return;
      if ((NewName !== "") && !pas.SysUtils.IsValidIdent(NewName,false,false)) throw $mod.EComponentError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidName"),pas.System.VarRecs(18,NewName)]);
      if (this.FOwner != null) {
        this.FOwner.ValidateRename(this,this.FName,NewName)}
       else this.ValidateRename(null,this.FName,NewName);
      this.SetReference(false);
      this.ChangeName(NewName);
      this.SetReference(true);
    };
    this.SetChildOrder = function (Child, Order) {
      if (Child === null) ;
      if (Order === 0) ;
    };
    this.SetParentComponent = function (Value) {
      if (Value === null) ;
    };
    this.Updating = function () {
      this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csUpdating);
    };
    this.Updated = function () {
      this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csUpdating);
    };
    this.ValidateRename = function (AComponent, CurName, NewName) {
      if ((AComponent !== null) && (pas.SysUtils.CompareText(CurName,NewName) !== 0) && (AComponent.FOwner === this) && (this.FindComponent(NewName) !== null)) throw $mod.EComponentError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SDuplicateName"),pas.System.VarRecs(18,NewName)]);
      if (($mod.TComponentStateItem.csDesigning in this.FComponentState) && (this.FOwner !== null)) this.FOwner.ValidateRename(AComponent,CurName,NewName);
    };
    this.ValidateContainer = function (AComponent) {
      AComponent.ValidateInsert(this);
    };
    this.ValidateInsert = function (AComponent) {
      if (AComponent === null) ;
    };
    this._AddRef = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.GetLeft = function () {
      var Result = 0;
      Result = this.FLeft;
      return Result;
    };
    this.GetTop = function () {
      var Result = 0;
      Result = this.FTop;
      return Result;
    };
    this.SetLeft = function (AValue) {
      this.FLeft = AValue;
    };
    this.SetTop = function (AValue) {
      this.FTop = AValue;
    };
    this._Release = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      this.FComponentStyle = rtl.createSet($mod.TComponentStyleItem.csInheritable);
      if (AOwner != null) AOwner.InsertComponent(this);
      return this;
    };
    this.Destroy = function () {
      var I = 0;
      var C = null;
      this.Destroying();
      if (this.FFreeNotifies != null) {
        I = this.FFreeNotifies.FCount - 1;
        while (I >= 0) {
          C = rtl.getObject(this.FFreeNotifies.Get(I));
          this.FFreeNotifies.Delete(I);
          C.Notification(this,$mod.TOperation.opRemove);
          if (this.FFreeNotifies === null) {
            I = 0}
           else if (I > this.FFreeNotifies.FCount) I = this.FFreeNotifies.FCount;
          I -= 1;
        };
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.FFreeNotifies;
          }, set: function (v) {
            this.p.FFreeNotifies = v;
          }});
      };
      this.DestroyComponents();
      if (this.FOwner !== null) this.FOwner.RemoveComponent(this);
      pas.System.TObject.Destroy.call(this);
    };
    this.BeforeDestruction = function () {
      if (!($mod.TComponentStateItem.csDestroying in this.FComponentState)) this.Destroying();
    };
    this.DestroyComponents = function () {
      var acomponent = null;
      while (this.FComponents != null) {
        acomponent = rtl.getObject(this.FComponents.Last());
        this.Remove(acomponent);
        acomponent.$destroy("Destroy");
      };
    };
    this.Destroying = function () {
      var Runner = 0;
      if ($mod.TComponentStateItem.csDestroying in this.FComponentState) return;
      this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csDestroying);
      if (this.FComponents != null) for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        Runner = $l;
        rtl.getObject(this.FComponents.Get(Runner)).Destroying();
      };
    };
    this.QueryInterface = function (IID, Obj) {
      var Result = 0;
      if (this.GetInterface(IID,Obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    this.AfterLoadDFMValues = function () {
      this.EndUpdate();
      this.Loaded();
    };
    this.BeforeLoadDFMValues = function () {
      if (!($mod.TComponentStateItem.csDesigning in this.FComponentState)) this.Loading();
      this.BeginUpdate();
    };
    this.BeginUpdate = function () {
    };
    this.EndUpdate = function () {
    };
    this.WriteState = function (Writer) {
      Writer.WriteComponentData(this);
    };
    this.FindComponent = function (AName) {
      var Result = null;
      var I = 0;
      Result = null;
      if ((AName === "") || !(this.FComponents != null)) return Result;
      for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        I = $l;
        if (pas.SysUtils.CompareText(rtl.getObject(this.FComponents.Get(I)).FName,AName) === 0) {
          Result = rtl.getObject(this.FComponents.Get(I));
          return Result;
        };
      };
      return Result;
    };
    this.FreeNotification = function (AComponent) {
      if ((this.FOwner !== null) && (AComponent === this.FOwner)) return;
      if (!(this.FFreeNotifies != null)) this.FFreeNotifies = $mod.TFPList.$create("Create");
      if (this.FFreeNotifies.IndexOf(AComponent) === -1) {
        this.FFreeNotifies.Add(AComponent);
        AComponent.FreeNotification(this);
      };
    };
    this.RemoveFreeNotification = function (AComponent) {
      this.RemoveNotification(AComponent);
      AComponent.RemoveNotification(this);
    };
    this.GetNamePath = function () {
      var Result = "";
      Result = this.FName;
      return Result;
    };
    this.GetParentComponent = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.HasParent = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.InsertComponent = function (AComponent) {
      AComponent.ValidateContainer(this);
      this.ValidateRename(AComponent,"",AComponent.FName);
      if (AComponent.FOwner !== null) AComponent.FOwner.RemoveComponent(AComponent);
      this.Insert(AComponent);
      if ($mod.TComponentStateItem.csDesigning in this.FComponentState) AComponent.SetDesigning(true,true);
      this.Notification(AComponent,$mod.TOperation.opInsert);
    };
    this.RemoveComponent = function (AComponent) {
      this.Notification(AComponent,$mod.TOperation.opRemove);
      this.Remove(AComponent);
      AComponent.SetDesigning(false,true);
      this.ValidateRename(AComponent,AComponent.FName,"");
    };
    this.SetSubComponent = function (ASubComponent) {
      if (ASubComponent) {
        this.FComponentStyle = rtl.includeSet(this.FComponentStyle,$mod.TComponentStyleItem.csSubComponent)}
       else this.FComponentStyle = rtl.excludeSet(this.FComponentStyle,$mod.TComponentStyleItem.csSubComponent);
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TComponentEnumerator.$create("Create$1",[this]);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Name",6,$mod.$rtti["TComponentName"],"FName","SetName");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",4,{Default: 0});
  });
  this.$rtti.$ClassRef("TComponentClass",{instancetype: this.$rtti["TComponent"]});
  this.TSeekOrigin = {"0": "soBeginning", soBeginning: 0, "1": "soCurrent", soCurrent: 1, "2": "soEnd", soEnd: 2};
  this.$rtti.$Enum("TSeekOrigin",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TSeekOrigin});
  rtl.createClass(this,"TStream",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FEndian = 0;
    };
    this.MakeInt = function (B, aSize, Signed) {
      var Result = 0;
      var Mem = null;
      var A = null;
      var D = null;
      var isLittle = false;
      isLittle = this.FEndian === pas.SysUtils.TEndian.Little;
      Mem = new ArrayBuffer(rtl.length(B));
      A = new Uint8Array(Mem);
      A.set(B);
      D = new DataView(Mem);
      if (Signed) {
        var $tmp = aSize;
        if ($tmp === 1) {
          Result = D.getInt8(0)}
         else if ($tmp === 2) {
          Result = D.getInt16(0,isLittle)}
         else if ($tmp === 4) {
          Result = D.getInt32(0,isLittle)}
         else if ($tmp === 8) Result = Math.round(D.getFloat64(0,isLittle));
      } else {
        var $tmp1 = aSize;
        if ($tmp1 === 1) {
          Result = D.getUint8(0)}
         else if ($tmp1 === 2) {
          Result = D.getUint16(0,isLittle)}
         else if ($tmp1 === 4) {
          Result = D.getUint32(0,isLittle)}
         else if ($tmp1 === 8) Result = Math.round(D.getFloat64(0,isLittle));
      };
      return Result;
    };
    this.MakeBytes = function (B, aSize, Signed) {
      var Result = [];
      var Mem = null;
      var A = null;
      var D = null;
      var isLittle = false;
      isLittle = this.FEndian === pas.SysUtils.TEndian.Little;
      Mem = new ArrayBuffer(aSize);
      D = new DataView(Mem);
      if (Signed) {
        var $tmp = aSize;
        if ($tmp === 1) {
          D.setInt8(0,B)}
         else if ($tmp === 2) {
          D.setInt16(0,B,isLittle)}
         else if ($tmp === 4) {
          D.setInt32(0,B,isLittle)}
         else if ($tmp === 8) D.setFloat64(0,B,isLittle);
      } else {
        var $tmp1 = aSize;
        if ($tmp1 === 1) {
          D.setUint8(0,B)}
         else if ($tmp1 === 2) {
          D.setUint16(0,B,isLittle)}
         else if ($tmp1 === 4) {
          D.setUint32(0,B,isLittle)}
         else if ($tmp1 === 8) D.setFloat64(0,B,isLittle);
      };
      Result = rtl.arraySetLength(Result,0,aSize);
      A = new Uint8Array(Mem);
      Result = $mod.TMemoryStream.MemoryToBytes$1(A);
      return Result;
    };
    this.InvalidSeek = function () {
      throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr($mod,"SStreamInvalidSeek"),pas.System.VarRecs(18,this.$classname)]);
    };
    var CSmallSize = 255;
    var CLargeMaxBuffer = 32 * 1024;
    this.Discard = function (Count) {
      var Buffer = [];
      if (Count === 0) return;
      if (Count <= 255) {
        Buffer = rtl.arraySetLength(Buffer,0,255);
        this.ReadBuffer({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},Count);
      } else this.DiscardLarge(Count,32768);
    };
    this.DiscardLarge = function (Count, MaxBufferSize) {
      var Buffer = [];
      if (Count === 0) return;
      if (Count > MaxBufferSize) {
        Buffer = rtl.arraySetLength(Buffer,0,MaxBufferSize)}
       else Buffer = rtl.arraySetLength(Buffer,0,Count);
      while (Count >= rtl.length(Buffer)) {
        this.ReadBuffer({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},rtl.length(Buffer));
        Count -= rtl.length(Buffer);
      };
      if (Count > 0) this.ReadBuffer({get: function () {
          return Buffer;
        }, set: function (v) {
          Buffer = v;
        }},Count);
    };
    this.FakeSeekForward = function (Offset, Origin, Pos) {
      if (Origin === $mod.TSeekOrigin.soBeginning) Offset -= Pos;
      if ((Offset < 0) || (Origin === $mod.TSeekOrigin.soEnd)) this.InvalidSeek();
      if (Offset > 0) this.Discard(Offset);
    };
    this.GetPosition = function () {
      var Result = 0;
      Result = this.Seek(0,$mod.TSeekOrigin.soCurrent);
      return Result;
    };
    this.SetPosition = function (Pos) {
      this.Seek(Pos,$mod.TSeekOrigin.soBeginning);
    };
    this.GetSize = function () {
      var Result = 0;
      var p = 0;
      p = this.Seek(0,$mod.TSeekOrigin.soCurrent);
      Result = this.Seek(0,$mod.TSeekOrigin.soEnd);
      this.Seek(p,$mod.TSeekOrigin.soBeginning);
      return Result;
    };
    this.SetSize = function (NewSize) {
      if (NewSize < 0) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SerrInvalidStreamSize")]);
    };
    this.SetSize64 = function (NewSize) {
      this.SetSize(NewSize);
    };
    this.ReadNotImplemented = function () {
      throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr($mod,"SStreamNoReading"),pas.System.VarRecs(18,this.$classname)]);
    };
    this.WriteNotImplemented = function () {
      throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr($mod,"SStreamNoWriting"),pas.System.VarRecs(18,this.$classname)]);
    };
    this.ReadMaxSizeData = function (Buffer, aSize, aCount) {
      var Result = 0;
      var CP = 0;
      if (aCount <= aSize) {
        Result = this.Read({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},aCount)}
       else {
        Result = this.Read({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},aSize);
        CP = this.GetPosition();
        Result = (Result + this.Seek(aCount - aSize,$mod.TSeekOrigin.soCurrent)) - CP;
      };
      return Result;
    };
    this.ReadExactSizeData = function (Buffer, aSize, aCount) {
      if (this.ReadMaxSizeData(rtl.arrayRef(Buffer),aSize,aCount) !== aCount) throw $mod.EReadError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.WriteMaxSizeData = function (Buffer, aSize, aCount) {
      var Result = 0;
      var CP = 0;
      if (aCount <= aSize) {
        Result = this.Write(Buffer,aCount)}
       else {
        Result = this.Write(Buffer,aSize);
        CP = this.GetPosition();
        Result = (Result + this.Seek(aCount - aSize,$mod.TSeekOrigin.soCurrent)) - CP;
      };
      return Result;
    };
    this.WriteExactSizeData = function (Buffer, aSize, aCount) {
      this.WriteMaxSizeData(Buffer,aSize,aCount);
    };
    this.Read = function (Buffer, Count) {
      var Result = 0;
      Result = this.Read$1(rtl.arrayRef(Buffer.get()),0,Count);
      return Result;
    };
    this.Write = function (Buffer, Count) {
      var Result = 0;
      Result = this.Write$1(Buffer,0,Count);
      return Result;
    };
    this.ReadData = function (Buffer, Count) {
      var Result = 0;
      Result = this.Read$1(rtl.arrayRef(Buffer),0,Count);
      return Result;
    };
    this.ReadData$1 = function (Buffer) {
      var Result = 0;
      var B = 0;
      Result = this.ReadData$8({get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},1);
      if (Result === 1) Buffer.set(B !== 0);
      return Result;
    };
    this.ReadData$2 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),1,Count);
      if (Result > 0) Buffer.set(B[0] !== 0);
      return Result;
    };
    this.ReadData$3 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$4(Buffer,2);
      return Result;
    };
    this.ReadData$4 = function (Buffer, Count) {
      var Result = 0;
      var W = 0;
      Result = this.ReadData$12({get: function () {
          return W;
        }, set: function (v) {
          W = v;
        }},Count);
      if (Result === 2) Buffer.set(String.fromCharCode(W));
      return Result;
    };
    this.ReadData$5 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$6(Buffer,1);
      return Result;
    };
    this.ReadData$6 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),1,Count);
      if (Result >= 1) Buffer.set(this.MakeInt(rtl.arrayRef(B),1,true));
      return Result;
    };
    this.ReadData$7 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$8(Buffer,1);
      return Result;
    };
    this.ReadData$8 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),1,Count);
      if (Result >= 1) Buffer.set(this.MakeInt(rtl.arrayRef(B),1,false));
      return Result;
    };
    this.ReadData$9 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$10(Buffer,2);
      return Result;
    };
    this.ReadData$10 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),2,Count);
      if (Result >= 2) Buffer.set(this.MakeInt(rtl.arrayRef(B),2,true));
      return Result;
    };
    this.ReadData$11 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$12(Buffer,2);
      return Result;
    };
    this.ReadData$12 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),2,Count);
      if (Result >= 2) Buffer.set(this.MakeInt(rtl.arrayRef(B),2,false));
      return Result;
    };
    this.ReadData$13 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$14(Buffer,4);
      return Result;
    };
    this.ReadData$14 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),4,Count);
      if (Result >= 4) Buffer.set(this.MakeInt(rtl.arrayRef(B),4,true));
      return Result;
    };
    this.ReadData$15 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$16(Buffer,4);
      return Result;
    };
    this.ReadData$16 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),4,Count);
      if (Result >= 4) Buffer.set(this.MakeInt(rtl.arrayRef(B),4,false));
      return Result;
    };
    this.ReadData$17 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$18(Buffer,8);
      return Result;
    };
    this.ReadData$18 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),8,8);
      if (Result >= 8) Buffer.set(this.MakeInt(rtl.arrayRef(B),8,true));
      return Result;
    };
    this.ReadData$19 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$20(Buffer,8);
      return Result;
    };
    this.ReadData$20 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      var B1 = 0;
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),4,4);
      if (Result >= 4) {
        B1 = this.MakeInt(rtl.arrayRef(B),4,false);
        Result = Result + this.ReadMaxSizeData(rtl.arrayRef(B),4,4);
        Buffer.set(this.MakeInt(rtl.arrayRef(B),4,false));
        Buffer.set(rtl.or(rtl.shl(Buffer.get(),32),B1));
      };
      return Result;
    };
    this.ReadData$21 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$22(Buffer,8);
      return Result;
    };
    this.ReadData$22 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      var Mem = null;
      var A = null;
      var D = null;
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),8,Count);
      if (Result >= 8) {
        Mem = new ArrayBuffer(8);
        A = new Uint8Array(Mem);
        A.set(B);
        D = new DataView(Mem);
        Buffer.set(D.getFloat64(0));
      };
      return Result;
    };
    this.ReadBuffer = function (Buffer, Count) {
      this.ReadBuffer$1(Buffer,0,Count);
    };
    this.ReadBuffer$1 = function (Buffer, Offset, Count) {
      if (this.Read$1(rtl.arrayRef(Buffer.get()),Offset,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData = function (Buffer) {
      this.ReadBufferData$1(Buffer,1);
    };
    this.ReadBufferData$1 = function (Buffer, Count) {
      if (this.ReadData$2(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$2 = function (Buffer) {
      this.ReadBufferData$3(Buffer,2);
    };
    this.ReadBufferData$3 = function (Buffer, Count) {
      if (this.ReadData$4(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$4 = function (Buffer) {
      this.ReadBufferData$5(Buffer,1);
    };
    this.ReadBufferData$5 = function (Buffer, Count) {
      if (this.ReadData$6(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$6 = function (Buffer) {
      this.ReadBufferData$7(Buffer,1);
    };
    this.ReadBufferData$7 = function (Buffer, Count) {
      if (this.ReadData$8(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$8 = function (Buffer) {
      this.ReadBufferData$9(Buffer,2);
    };
    this.ReadBufferData$9 = function (Buffer, Count) {
      if (this.ReadData$10(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$10 = function (Buffer) {
      this.ReadBufferData$11(Buffer,2);
    };
    this.ReadBufferData$11 = function (Buffer, Count) {
      if (this.ReadData$12(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$12 = function (Buffer) {
      this.ReadBufferData$13(Buffer,4);
    };
    this.ReadBufferData$13 = function (Buffer, Count) {
      if (this.ReadData$14(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$14 = function (Buffer) {
      this.ReadBufferData$15(Buffer,4);
    };
    this.ReadBufferData$15 = function (Buffer, Count) {
      if (this.ReadData$16(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$16 = function (Buffer) {
      this.ReadBufferData$17(Buffer,8);
    };
    this.ReadBufferData$17 = function (Buffer, Count) {
      if (this.ReadData$18(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$18 = function (Buffer) {
      this.ReadBufferData$19(Buffer,8);
    };
    this.ReadBufferData$19 = function (Buffer, Count) {
      if (this.ReadData$20(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$20 = function (Buffer) {
      this.ReadBufferData$21(Buffer,8);
    };
    this.ReadBufferData$21 = function (Buffer, Count) {
      if (this.ReadData$22(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.WriteBuffer = function (Buffer, Count) {
      this.WriteBuffer$1(Buffer,0,Count);
    };
    this.WriteBuffer$1 = function (Buffer, Offset, Count) {
      if (this.Write$1(Buffer,Offset,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteData = function (Buffer, Count) {
      var Result = 0;
      Result = this.Write$1(Buffer,0,Count);
      return Result;
    };
    this.WriteData$1 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$2(Buffer,1);
      return Result;
    };
    this.WriteData$2 = function (Buffer, Count) {
      var Result = 0;
      var B = 0;
      B = Buffer + 0;
      Result = this.WriteData$6(B,Count);
      return Result;
    };
    this.WriteData$3 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$4(Buffer,2);
      return Result;
    };
    this.WriteData$4 = function (Buffer, Count) {
      var Result = 0;
      var U = 0;
      U = Buffer.charCodeAt();
      Result = this.WriteData$12(U,Count);
      return Result;
    };
    this.WriteData$5 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$6(Buffer,1);
      return Result;
    };
    this.WriteData$6 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,1,true),1,Count);
      return Result;
    };
    this.WriteData$7 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$8(Buffer,1);
      return Result;
    };
    this.WriteData$8 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,1,false),1,Count);
      return Result;
    };
    this.WriteData$9 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$10(Buffer,2);
      return Result;
    };
    this.WriteData$10 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,2,true),2,Count);
      return Result;
    };
    this.WriteData$11 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$12(Buffer,2);
      return Result;
    };
    this.WriteData$12 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,2,true),2,Count);
      return Result;
    };
    this.WriteData$13 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$14(Buffer,4);
      return Result;
    };
    this.WriteData$14 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,4,true),4,Count);
      return Result;
    };
    this.WriteData$15 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$16(Buffer,4);
      return Result;
    };
    this.WriteData$16 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,4,false),4,Count);
      return Result;
    };
    this.WriteData$17 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$18(Buffer,8);
      return Result;
    };
    this.WriteData$18 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,8,true),8,Count);
      return Result;
    };
    this.WriteData$19 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$20(Buffer,8);
      return Result;
    };
    this.WriteData$20 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,8,false),8,Count);
      return Result;
    };
    this.WriteData$21 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$22(Buffer,8);
      return Result;
    };
    this.WriteData$22 = function (Buffer, Count) {
      var Result = 0;
      var Mem = null;
      var A = null;
      var D = null;
      var B = [];
      var I = 0;
      Mem = new ArrayBuffer(8);
      D = new DataView(Mem);
      D.setFloat64(0,Buffer);
      B = rtl.arraySetLength(B,0,8);
      A = new Uint8Array(Mem);
      for (I = 0; I <= 7; I++) B[I] = A[I];
      Result = this.WriteMaxSizeData(B,8,Count);
      return Result;
    };
    this.WriteBufferData = function (Buffer) {
      this.WriteBufferData$1(Buffer,4);
    };
    this.WriteBufferData$1 = function (Buffer, Count) {
      if (this.WriteData$14(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$2 = function (Buffer) {
      this.WriteBufferData$3(Buffer,1);
    };
    this.WriteBufferData$3 = function (Buffer, Count) {
      if (this.WriteData$2(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$4 = function (Buffer) {
      this.WriteBufferData$5(Buffer,2);
    };
    this.WriteBufferData$5 = function (Buffer, Count) {
      if (this.WriteData$4(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$6 = function (Buffer) {
      this.WriteBufferData$7(Buffer,1);
    };
    this.WriteBufferData$7 = function (Buffer, Count) {
      if (this.WriteData$6(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$8 = function (Buffer) {
      this.WriteBufferData$9(Buffer,1);
    };
    this.WriteBufferData$9 = function (Buffer, Count) {
      if (this.WriteData$8(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$10 = function (Buffer) {
      this.WriteBufferData$11(Buffer,2);
    };
    this.WriteBufferData$11 = function (Buffer, Count) {
      if (this.WriteData$10(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$12 = function (Buffer) {
      this.WriteBufferData$13(Buffer,2);
    };
    this.WriteBufferData$13 = function (Buffer, Count) {
      if (this.WriteData$12(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$14 = function (Buffer) {
      this.WriteBufferData$15(Buffer,4);
    };
    this.WriteBufferData$15 = function (Buffer, Count) {
      if (this.WriteData$16(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$16 = function (Buffer) {
      this.WriteBufferData$17(Buffer,8);
    };
    this.WriteBufferData$17 = function (Buffer, Count) {
      if (this.WriteData$18(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$18 = function (Buffer) {
      this.WriteBufferData$19(Buffer,8);
    };
    this.WriteBufferData$19 = function (Buffer, Count) {
      if (this.WriteData$20(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$20 = function (Buffer) {
      this.WriteBufferData$21(Buffer,8);
    };
    this.WriteBufferData$21 = function (Buffer, Count) {
      if (this.WriteData$22(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    var MaxSize = 0x20000;
    this.CopyFrom = function (Source, Count) {
      var Result = 0;
      var Buffer = [];
      var BufferSize = 0;
      var i = 0;
      Result = 0;
      if (Count === 0) Source.SetPosition(0);
      BufferSize = 131072;
      if ((Count > 0) && (Count < BufferSize)) BufferSize = Count;
      Buffer = rtl.arraySetLength(Buffer,0,BufferSize);
      if (Count === 0) {
        do {
          i = Source.Read({get: function () {
              return Buffer;
            }, set: function (v) {
              Buffer = v;
            }},BufferSize);
          if (i > 0) this.WriteBuffer(Buffer,i);
          Result += i;
        } while (!(i < BufferSize))}
       else while (Count > 0) {
        if (Count > BufferSize) {
          i = BufferSize}
         else i = Count;
        Source.ReadBuffer({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},i);
        this.WriteBuffer(Buffer,i);
        Count -= i;
        Result += i;
      };
      return Result;
    };
    this.ReadComponent = function (Instance) {
      var Result = null;
      var Reader = null;
      Reader = $mod.TReader.$create("Create$1",[this]);
      try {
        Result = Reader.ReadRootComponent(Instance);
      } finally {
        Reader = rtl.freeLoc(Reader);
      };
      return Result;
    };
    this.ReadComponentRes = function (Instance) {
      var Result = null;
      this.ReadResHeader();
      Result = this.ReadComponent(Instance);
      return Result;
    };
    this.WriteComponent = function (Instance) {
      this.WriteDescendent(Instance,null);
    };
    this.WriteComponentRes = function (ResName, Instance) {
      this.WriteDescendentRes(ResName,Instance,null);
    };
    this.WriteDescendent = function (Instance, Ancestor) {
      var Driver = null;
      var Writer = null;
      Driver = $mod.TBinaryObjectWriter.$create("Create$1",[this]);
      try {
        Writer = $mod.TWriter.$create("Create$1",[Driver]);
        try {
          Writer.WriteDescendent(Instance,Ancestor);
        } finally {
          Writer.$destroy("Destroy");
        };
      } finally {
        Driver = rtl.freeLoc(Driver);
      };
    };
    this.WriteDescendentRes = function (ResName, Instance, Ancestor) {
      var FixupInfo = 0;
      this.WriteResourceHeader(ResName,{get: function () {
          return FixupInfo;
        }, set: function (v) {
          FixupInfo = v;
        }});
      this.WriteDescendent(Instance,Ancestor);
      this.FixupResourceHeader(FixupInfo);
    };
    this.WriteResourceHeader = function (ResName, FixupInfo) {
      var ResType = 0;
      var Flags = 0;
      var B = 0;
      var I = 0;
      ResType = 0xA;
      Flags = 0x1030;
      this.WriteByte(0xff);
      this.WriteWord(ResType);
      for (var $l = 1, $end = ResName.length; $l <= $end; $l++) {
        I = $l;
        B = ResName.charCodeAt(I - 1);
        this.WriteByte(B);
      };
      this.WriteByte(0);
      this.WriteWord(Flags);
      this.WriteDWord(0);
      FixupInfo.set(this.GetPosition());
    };
    this.FixupResourceHeader = function (FixupInfo) {
      var ResSize = 0;
      var TmpResSize = 0;
      ResSize = this.GetPosition() - FixupInfo;
      TmpResSize = ResSize >>> 0;
      this.SetPosition(FixupInfo - 4);
      this.WriteDWord(TmpResSize);
      this.SetPosition(FixupInfo + ResSize);
    };
    this.ReadResHeader = function () {
      var ResType = 0;
      var Flags = 0;
      try {
        if (this.ReadByte() !== 0xff) throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        ResType = this.ReadWord();
        if (ResType !== 0xa) throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        while (this.ReadByte() !== 0) {
        };
        Flags = this.ReadWord();
        if (Flags !== 0x1030) throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        this.ReadDWord();
      } catch ($e) {
        if ($mod.EInvalidImage.isPrototypeOf($e)) {
          throw $e}
         else {
          throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        }
      };
    };
    this.ReadByte = function () {
      var Result = 0;
      this.ReadBufferData$7({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1);
      return Result;
    };
    this.ReadWord = function () {
      var Result = 0;
      this.ReadBufferData$11({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},2);
      return Result;
    };
    this.ReadDWord = function () {
      var Result = 0;
      this.ReadBufferData$15({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},4);
      return Result;
    };
    this.ReadQWord = function () {
      var Result = 0;
      this.ReadBufferData$19({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},8);
      return Result;
    };
    this.WriteByte = function (b) {
      this.WriteBufferData$9(b,1);
    };
    this.WriteWord = function (w) {
      this.WriteBufferData$13(w,2);
    };
    this.WriteDWord = function (d) {
      this.WriteBufferData$15(d,4);
    };
    this.WriteQWord = function (q) {
      this.WriteBufferData$19(q,8);
    };
  });
  rtl.createClass(this,"TCustomMemoryStream",this.TStream,function () {
    this.$init = function () {
      $mod.TStream.$init.call(this);
      this.FMemory = null;
      this.FDataView = null;
      this.FDataArray = null;
      this.FSize = 0;
      this.FPosition = 0;
      this.FSizeBoundsSeek = false;
    };
    this.$final = function () {
      this.FMemory = undefined;
      this.FDataView = undefined;
      this.FDataArray = undefined;
      $mod.TStream.$final.call(this);
    };
    this.GetDataArray = function () {
      var Result = null;
      if (this.FDataArray === null) this.FDataArray = new Uint8Array(this.FMemory);
      Result = this.FDataArray;
      return Result;
    };
    this.GetDataView = function () {
      var Result = null;
      if (this.FDataView === null) this.FDataView = new DataView(this.FMemory);
      Result = this.FDataView;
      return Result;
    };
    this.GetSize = function () {
      var Result = 0;
      Result = this.FSize;
      return Result;
    };
    this.GetPosition = function () {
      var Result = 0;
      Result = this.FPosition;
      return Result;
    };
    this.SetPointer = function (Ptr, ASize) {
      this.FMemory = Ptr;
      this.FSize = ASize;
      this.FDataView = null;
      this.FDataArray = null;
    };
    this.MemoryToBytes = function (Mem) {
      var Result = [];
      Result = this.MemoryToBytes$1(new Uint8Array(Mem));
      return Result;
    };
    this.MemoryToBytes$1 = function (Mem) {
      var Result = [];
      var I = 0;
      for (var $l = 0, $end = Mem.length - 1; $l <= $end; $l++) {
        I = $l;
        Result[I] = Mem[I];
      };
      return Result;
    };
    this.BytesToMemory = function (aBytes) {
      var Result = null;
      var a = null;
      Result = new ArrayBuffer(rtl.length(aBytes));
      a = new Uint8Array(Result);
      a.set(aBytes);
      return Result;
    };
    this.Read$1 = function (Buffer, Offset, Count) {
      var Result = 0;
      var I = 0;
      var Src = 0;
      var Dest = 0;
      Result = 0;
      if ((this.FSize > 0) && (this.FPosition < this.FSize) && (this.FPosition >= 0)) {
        Result = Count;
        if (Result > (this.FSize - this.FPosition)) Result = this.FSize - this.FPosition;
        Src = this.FPosition;
        Dest = Offset;
        I = 0;
        while (I < Result) {
          Buffer[Dest] = this.GetDataView().getUint8(Src);
          Src += 1;
          Dest += 1;
          I += 1;
        };
        this.FPosition = this.FPosition + Result;
      };
      return Result;
    };
    this.Seek = function (Offset, Origin) {
      var Result = 0;
      var $tmp = Origin;
      if ($tmp === $mod.TSeekOrigin.soBeginning) {
        this.FPosition = Offset}
       else if ($tmp === $mod.TSeekOrigin.soEnd) {
        this.FPosition = this.FSize + Offset}
       else if ($tmp === $mod.TSeekOrigin.soCurrent) this.FPosition = this.FPosition + Offset;
      if (this.FSizeBoundsSeek && (this.FPosition > this.FSize)) this.FPosition = this.FSize;
      Result = this.FPosition;
      if (Result < 0) throw pas.SysUtils.Exception.$create("Create$1",["TCustomMemoryStream"]);
      return Result;
    };
    this.SaveToStream = function (Stream) {
      if (this.FSize > 0) Stream.WriteBuffer($mod.TMemoryStream.MemoryToBytes(this.FMemory),this.FSize);
    };
    this.LoadFromURL = function (aURL, Async, OnLoaded, OnError) {
      var $Self = this;
      function DoLoaded(abytes) {
        $Self.SetPointer(abytes,abytes.byteLength);
        if (OnLoaded != null) OnLoaded($Self);
      };
      function DoError(AError) {
        if (OnError != null) {
          OnError($Self,AError)}
         else throw pas.SysUtils.EInOutError.$create("Create$1",["Failed to load from URL:" + AError]);
      };
      $impl.CheckLoadHelper();
      $impl.GlobalLoadHelper.LoadBytes(aURL,Async,DoLoaded,DoError);
    };
    this.LoadFromFile = function (aFileName, OnLoaded, AError) {
      var $Self = this;
      this.LoadFromURL(aFileName,false,function (Sender) {
        if (OnLoaded != null) OnLoaded();
      },function (Sender, ErrorMsg) {
        if (AError != null) AError(ErrorMsg);
      });
    };
  });
  rtl.createClass(this,"TMemoryStream",this.TCustomMemoryStream,function () {
    this.$init = function () {
      $mod.TCustomMemoryStream.$init.call(this);
      this.FCapacity = 0;
    };
    this.SetCapacity = function (NewCapacity) {
      this.SetPointer(this.Realloc({get: function () {
          return NewCapacity;
        }, set: function (v) {
          NewCapacity = v;
        }}),this.FSize);
      this.FCapacity = NewCapacity;
    };
    this.Realloc = function (NewCapacity) {
      var Result = null;
      var GC = 0;
      var DestView = null;
      if (NewCapacity.get() < 0) {
        NewCapacity.set(0)}
       else {
        GC = this.FCapacity + rtl.trunc(this.FCapacity / 4);
        if ((NewCapacity.get() > this.FCapacity) && (NewCapacity.get() < GC)) NewCapacity.set(GC);
        NewCapacity.set((NewCapacity.get() + (4096 - 1)) & ~(4096 - 1));
      };
      if (NewCapacity.get() === this.FCapacity) {
        Result = this.FMemory}
       else if (NewCapacity.get() === 0) {
        Result = null}
       else {
        Result = new ArrayBuffer(NewCapacity.get());
        if (Result === null) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SMemoryStreamError")]);
        DestView = new Uint8Array(Result);
        DestView.set(this.GetDataArray());
      };
      return Result;
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      this.FSize = 0;
      this.FPosition = 0;
      this.SetCapacity(0);
    };
    this.LoadFromStream = function (Stream) {
      this.SetPosition(0);
      Stream.SetPosition(0);
      this.SetSize(Stream.GetSize());
      if (this.GetSize() > 0) this.CopyFrom(Stream,0);
    };
    this.SetSize = function (NewSize) {
      this.SetCapacity(NewSize);
      this.FSize = NewSize;
      if (this.FPosition > this.FSize) this.FPosition = this.FSize;
    };
    this.Write$1 = function (Buffer, Offset, Count) {
      var Result = 0;
      var NewPos = 0;
      if ((Count === 0) || (this.FPosition < 0)) return 0;
      NewPos = this.FPosition + Count;
      if (NewPos > this.FSize) {
        if (NewPos > this.FCapacity) this.SetCapacity(NewPos);
        this.FSize = NewPos;
      };
      this.GetDataArray().set(rtl.arrayCopy(0,Buffer,Offset,Count),this.FPosition);
      this.FPosition = NewPos;
      Result = Count;
      return Result;
    };
    this.Write = function (Buffer, Count) {
      var Result = 0;
      Result = this.Write$1(Buffer,0,Count);
      return Result;
    };
  });
  rtl.createClass(this,"TBytesStream",this.TMemoryStream,function () {
    this.GetBytes = function () {
      var Result = [];
      Result = $mod.TMemoryStream.MemoryToBytes(this.FMemory);
      return Result;
    };
    this.Create$1 = function (ABytes) {
      pas.System.TObject.Create.call(this);
      this.SetPointer($mod.TMemoryStream.BytesToMemory(rtl.arrayRef(ABytes)),rtl.length(ABytes));
      this.FCapacity = rtl.length(ABytes);
      return this;
    };
  });
  rtl.createClass(this,"TStringStream",this.TMemoryStream,function () {
    this.$init = function () {
      $mod.TMemoryStream.$init.call(this);
      this.FEncoding = null;
      this.FOwnsEncoding = false;
    };
    this.$final = function () {
      this.FEncoding = undefined;
      $mod.TMemoryStream.$final.call(this);
    };
    var Chunk = 8 * 1024;
    this.GetDataString = function () {
      var Result = "";
      var ua16 = null;
      var ua8 = null;
      var Len = 0;
      var I = 0;
      Result = "";
      if (this.FEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
        ua16 = new Uint16Array(this.FMemory.slice(0,this.GetSize()));
        if (ua16 !== null) {
          Len = rtl.trunc(ua16.length / 8192);
          for (var $l = 0, $end = Len; $l <= $end; $l++) {
            I = $l;
            Result+=String.fromCharCode.apply(null,ua16.slice(I * Chunk, (I + 1) * Chunk));
          };
        };
      } else {
        ua8 = new Uint8Array(this.FMemory.slice(0,this.GetSize()));
        if (ua8 !== null) {
          return ua8.reduce(function (data, byte) {
          return data + String.fromCharCode(byte);
          }, '');
        };
      };
      return Result;
    };
    this.Create$1 = function () {
      this.Create$3("",pas.SysUtils.TEncoding.GetUnicode(),true);
      return this;
    };
    this.Create$2 = function (aString) {
      this.Create$3(aString,pas.SysUtils.TEncoding.GetUnicode(),true);
      return this;
    };
    this.Create$3 = function (AString, AEncoding, AOwnsEncoding) {
      var Len = 0;
      pas.System.TObject.Create.call(this);
      this.FEncoding = AEncoding;
      Len = AString.length;
      if (this.FEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
        this.SetPointer($mod.StringToBuffer$1(AString,Len,this.FEncoding),Len * 2);
        this.FCapacity = Len * 2;
      } else {
        this.SetPointer($mod.StringToBuffer$1(AString,Len,this.FEncoding),Len);
        this.FCapacity = Len;
      };
      return this;
    };
    this.Destroy = function () {
      if (this.FOwnsEncoding) rtl.free(this,"FEncoding");
      $mod.TMemoryStream.Destroy.call(this);
    };
    this.ReadString = function (Count) {
      var Result = "";
      var B = [];
      var Buf = null;
      var BytesLeft = 0;
      BytesLeft = this.GetSize() - this.GetPosition();
      if (this.FEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
        if (BytesLeft < (Count * 2)) Count = BytesLeft;
        B = rtl.arraySetLength(B,0,Count * 2);
        this.ReadBuffer$1({get: function () {
            return B;
          }, set: function (v) {
            B = v;
          }},0,Count * 2);
        Buf = this.$class.BytesToMemory(rtl.arrayRef(B));
        Result = $mod.BufferToString$1(Buf,0,Count * 2,this.FEncoding);
      } else {
        if (BytesLeft < Count) Count = BytesLeft;
        B = rtl.arraySetLength(B,0,Count);
        this.ReadBuffer$1({get: function () {
            return B;
          }, set: function (v) {
            B = v;
          }},0,Count);
        Buf = this.$class.BytesToMemory(rtl.arrayRef(B));
        Result = $mod.BufferToString$1(Buf,0,Count,this.FEncoding);
      };
      return Result;
    };
    this.WriteString = function (AString) {
      var Buf = null;
      var B = [];
      Buf = $mod.StringToBuffer$1(AString,AString.length,this.FEncoding);
      B = this.$class.MemoryToBytes(Buf);
      this.WriteBuffer(B,rtl.length(B));
    };
  });
  rtl.createClass(this,"TResourceStream",this.TCustomMemoryStream,function () {
    this.Initialize = function (aInfo) {
      var Ptr = null;
      var S = "";
      if (aInfo.encoding === "base64") {
        S = atob(aInfo.data)}
       else if (aInfo.encoding === "text") {
        S = aInfo.data}
       else throw pas.SysUtils.ENotSupportedException.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrResourceNotBase64"),pas.System.VarRecs(18,aInfo.name)]);
      Ptr = $mod.StringToBuffer(S,S.length);
      this.SetPointer(Ptr,Ptr.byteLength);
    };
    this.Initialize$1 = function (Instance, Name, ResType) {
      var aInfo = pas.p2jsres.TResourceInfo.$new();
      if (!pas.p2jsres.GetResourceInfo(Name,aInfo)) throw $mod.EResNotFound.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SResNotFound"),pas.System.VarRecs(18,Name)]);
      this.Initialize(pas.p2jsres.TResourceInfo.$clone(aInfo));
    };
    this.Create$1 = function (aInfo) {
      pas.System.TObject.Create.call(this);
      this.Initialize(pas.p2jsres.TResourceInfo.$clone(aInfo));
      return this;
    };
    this.Create$2 = function (Instance, ResName, ResType) {
      pas.System.TObject.Create.call(this);
      this.Initialize$1(Instance,ResName,ResType);
      return this;
    };
    this.CreateFromID = function (Instance, ResID, ResType) {
      pas.System.TObject.Create.call(this);
      this.Initialize$1(Instance,pas.SysUtils.IntToStr(ResID),ResType);
      return this;
    };
    this.Write$1 = function (Buffer, Offset, Count) {
      var Result = 0;
      throw pas.SysUtils.ENotSupportedException.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrResourceStreamNoWrite")]);
      Result = 0;
      return Result;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.TFilerFlag = {"0": "ffInherited", ffInherited: 0, "1": "ffChildPos", ffChildPos: 1, "2": "ffInline", ffInline: 2};
  this.$rtti.$Enum("TFilerFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TFilerFlag});
  this.$rtti.$Set("TFilerFlags",{comptype: this.$rtti["TFilerFlag"]});
  this.$rtti.$MethodVar("TReaderProc",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TWriterProc",{procsig: rtl.newTIProcSig([["Writer",this.$rtti["TWriter"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TStreamProc",{procsig: rtl.newTIProcSig([["Stream",this.$rtti["TStream"]]]), methodkind: 0});
  rtl.createClass(this,"TFiler",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FRoot = null;
      this.FLookupRoot = null;
      this.FAncestor = null;
      this.FIgnoreChildren = false;
    };
    this.$final = function () {
      this.FRoot = undefined;
      this.FLookupRoot = undefined;
      this.FAncestor = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetRoot = function (ARoot) {
      this.FRoot = ARoot;
    };
  });
  this.TValueType = {"0": "vaNull", vaNull: 0, "1": "vaList", vaList: 1, "2": "vaInt8", vaInt8: 2, "3": "vaInt16", vaInt16: 3, "4": "vaInt32", vaInt32: 4, "5": "vaDouble", vaDouble: 5, "6": "vaString", vaString: 6, "7": "vaIdent", vaIdent: 7, "8": "vaFalse", vaFalse: 8, "9": "vaTrue", vaTrue: 9, "10": "vaBinary", vaBinary: 10, "11": "vaSet", vaSet: 11, "12": "vaNil", vaNil: 12, "13": "vaCollection", vaCollection: 13, "14": "vaCurrency", vaCurrency: 14, "15": "vaDate", vaDate: 15, "16": "vaNativeInt", vaNativeInt: 16};
  this.$rtti.$Enum("TValueType",{minvalue: 0, maxvalue: 16, ordtype: 1, enumtype: this.TValueType});
  rtl.createClass(this,"TAbstractObjectReader",pas.System.TObject,function () {
    this.FlushBuffer = function () {
    };
  });
  rtl.createClass(this,"TBinaryObjectReader",this.TAbstractObjectReader,function () {
    this.$init = function () {
      $mod.TAbstractObjectReader.$init.call(this);
      this.FStream = null;
    };
    this.$final = function () {
      this.FStream = undefined;
      $mod.TAbstractObjectReader.$final.call(this);
    };
    this.ReadWord = function () {
      var Result = 0;
      this.FStream.ReadBufferData$10({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadDWord = function () {
      var Result = 0;
      this.FStream.ReadBufferData$14({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.SkipProperty = function () {
      this.ReadStr();
      this.SkipValue();
    };
    this.SkipSetBody = function () {
      while (this.ReadStr().length > 0) ;
    };
    this.Create$1 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalReader")]);
      this.FStream = Stream;
      return this;
    };
    this.NextValue = function () {
      var Result = 0;
      Result = this.ReadValue();
      this.FStream.Seek(-1,$mod.TSeekOrigin.soCurrent);
      return Result;
    };
    this.ReadValue = function () {
      var Result = 0;
      var b = 0;
      this.FStream.ReadBufferData$6({get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      Result = b;
      return Result;
    };
    this.BeginRootComponent = function () {
      this.ReadSignature();
    };
    this.BeginComponent = function (Flags, AChildPos, CompClassName, CompName) {
      var Prefix = 0;
      var ValueType = 0;
      Flags.set({});
      if ((this.NextValue() & 0xf0) === 0xf0) {
        Prefix = this.ReadValue();
        Flags.set({});
        if ((Prefix & 0x1) !== 0) Flags.set(rtl.includeSet(Flags.get(),$mod.TFilerFlag.ffInherited));
        if ((Prefix & 0x2) !== 0) Flags.set(rtl.includeSet(Flags.get(),$mod.TFilerFlag.ffChildPos));
        if ((Prefix & 0x4) !== 0) Flags.set(rtl.includeSet(Flags.get(),$mod.TFilerFlag.ffInline));
        if ($mod.TFilerFlag.ffChildPos in Flags.get()) {
          ValueType = this.ReadValue();
          var $tmp = ValueType;
          if ($tmp === $mod.TValueType.vaInt8) {
            AChildPos.set(this.ReadInt8())}
           else if ($tmp === $mod.TValueType.vaInt16) {
            AChildPos.set(this.ReadInt16())}
           else if ($tmp === $mod.TValueType.vaInt32) {
            AChildPos.set(this.ReadInt32())}
           else if ($tmp === $mod.TValueType.vaNativeInt) {
            AChildPos.set(this.ReadNativeInt())}
           else {
            throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
          };
        };
      };
      CompClassName.set(this.ReadStr());
      CompName.set(this.ReadStr());
    };
    this.BeginProperty = function () {
      var Result = "";
      Result = this.ReadStr();
      return Result;
    };
    this.Read = function (Buffer, Count) {
      this.FStream.Read(Buffer,Count);
    };
    this.ReadBinary = function (DestData) {
      var BinSize = 0;
      BinSize = this.ReadDWord() & 0xFFFFFFFF;
      DestData.SetSize64(BinSize);
      DestData.CopyFrom(this.FStream,BinSize);
    };
    this.ReadFloat = function () {
      var Result = 0.0;
      this.FStream.ReadBufferData$20({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadCurrency = function () {
      var Result = 0;
      Result = rtl.trunc(this.ReadFloat() * 10000);
      return Result;
    };
    this.ReadIdent = function (ValueType) {
      var Result = "";
      var i = 0;
      var c = "\x00";
      var $tmp = ValueType;
      if ($tmp === $mod.TValueType.vaIdent) {
        this.FStream.ReadBufferData$6({get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }});
        Result = rtl.strSetLength(Result,i);
        for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
          i = $l;
          this.FStream.ReadBufferData$2({get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
          Result = rtl.setCharAt(Result,i - 1,c);
        };
      } else if ($tmp === $mod.TValueType.vaNil) {
        Result = "nil"}
       else if ($tmp === $mod.TValueType.vaFalse) {
        Result = "False"}
       else if ($tmp === $mod.TValueType.vaTrue) {
        Result = "True"}
       else if ($tmp === $mod.TValueType.vaNull) Result = "Null";
      return Result;
    };
    this.ReadInt8 = function () {
      var Result = 0;
      this.FStream.ReadBufferData$4({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadInt16 = function () {
      var Result = 0;
      this.FStream.ReadBufferData$8({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadInt32 = function () {
      var Result = 0;
      this.FStream.ReadBufferData$12({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadNativeInt = function () {
      var Result = 0;
      this.FStream.ReadBufferData$16({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadSet = function (EnumType) {
      var Result = 0;
      var Name = "";
      var Value = 0;
      try {
        Result = 0;
        while (true) {
          Name = this.ReadStr();
          if (Name.length === 0) break;
          Value = EnumType.enumtype[Name];
          if (Value === -1) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
          Result = Result | (1 << Value);
        };
      } catch ($e) {
        this.SkipSetBody();
        throw $e;
      };
      return Result;
    };
    this.ReadSignature = function () {
      var Signature = 0;
      this.FStream.ReadBufferData$12({get: function () {
          return Signature;
        }, set: function (v) {
          Signature = v;
        }});
      if (Signature !== 809914452) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
    };
    this.ReadStr = function () {
      var Result = "";
      var l = 0;
      var i = 0;
      var c = "\x00";
      this.FStream.ReadBufferData$6({get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }});
      Result = rtl.strSetLength(Result,l);
      for (var $l = 1, $end = l; $l <= $end; $l++) {
        i = $l;
        this.FStream.ReadBufferData$2({get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,c);
      };
      return Result;
    };
    this.ReadString = function (StringType) {
      var Result = "";
      var i = 0;
      var C = "\x00";
      Result = "";
      if (StringType !== $mod.TValueType.vaString) throw $mod.EFilerError.$create("Create$1",["Invalid string type passed to ReadString"]);
      i = this.ReadDWord();
      Result = rtl.strSetLength(Result,i);
      for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
        i = $l;
        this.FStream.ReadBufferData$2({get: function () {
            return C;
          }, set: function (v) {
            C = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,C);
      };
      return Result;
    };
    this.ReadWideString = function () {
      var Result = "";
      Result = this.ReadString($mod.TValueType.vaString);
      return Result;
    };
    this.ReadUnicodeString = function () {
      var Result = "";
      Result = this.ReadString($mod.TValueType.vaString);
      return Result;
    };
    this.SkipComponent = function (SkipComponentInfos) {
      var Flags = {};
      var Dummy = 0;
      var CompClassName = "";
      var CompName = "";
      if (SkipComponentInfos) this.BeginComponent({get: function () {
          return Flags;
        }, set: function (v) {
          Flags = v;
        }},{get: function () {
          return Dummy;
        }, set: function (v) {
          Dummy = v;
        }},{get: function () {
          return CompClassName;
        }, set: function (v) {
          CompClassName = v;
        }},{get: function () {
          return CompName;
        }, set: function (v) {
          CompName = v;
        }});
      while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipProperty();
      this.ReadValue();
      while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipComponent(true);
      this.ReadValue();
    };
    this.SkipValue = function () {
      var $Self = this;
      function SkipBytes(Count) {
        var Dummy = [];
        var SkipNow = 0;
        while (Count > 0) {
          if (Count > 1024) {
            SkipNow = 1024}
           else SkipNow = Count;
          Dummy = rtl.arraySetLength(Dummy,0,SkipNow);
          $Self.Read({get: function () {
              return Dummy;
            }, set: function (v) {
              Dummy = v;
            }},SkipNow);
          Count -= SkipNow;
        };
      };
      var Count = 0;
      var $tmp = this.ReadValue();
      if (($tmp === $mod.TValueType.vaNull) || ($tmp === $mod.TValueType.vaFalse) || ($tmp === $mod.TValueType.vaTrue) || ($tmp === $mod.TValueType.vaNil)) {}
      else if ($tmp === $mod.TValueType.vaList) {
        while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipValue();
        this.ReadValue();
      } else if ($tmp === $mod.TValueType.vaInt8) {
        SkipBytes(1)}
       else if ($tmp === $mod.TValueType.vaInt16) {
        SkipBytes(2)}
       else if ($tmp === $mod.TValueType.vaInt32) {
        SkipBytes(4)}
       else if (($tmp === $mod.TValueType.vaNativeInt) || ($tmp === $mod.TValueType.vaDouble)) {
        SkipBytes(8)}
       else if ($tmp === $mod.TValueType.vaIdent) {
        this.ReadStr()}
       else if ($tmp === $mod.TValueType.vaString) {
        this.ReadString($mod.TValueType.vaString)}
       else if ($tmp === $mod.TValueType.vaBinary) {
        Count = this.ReadDWord() & 0xFFFFFFFF;
        SkipBytes(Count);
      } else if ($tmp === $mod.TValueType.vaSet) {
        this.SkipSetBody()}
       else if ($tmp === $mod.TValueType.vaCollection) {
        while (this.NextValue() !== $mod.TValueType.vaNull) {
          if (this.NextValue() in rtl.createSet($mod.TValueType.vaInt8,$mod.TValueType.vaInt16,$mod.TValueType.vaInt32)) this.SkipValue();
          SkipBytes(1);
          while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipProperty();
          this.ReadValue();
        };
        this.ReadValue();
      };
    };
  });
  this.$rtti.$MethodVar("TFindMethodEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["MethodName",rtl.string,2],["Address",rtl.pointer,1],["error",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TSetNameEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Component",this.$rtti["TComponent"]],["Name",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TReferenceNameEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Name",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TAncestorNotFoundEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["ComponentName",rtl.string,2],["ComponentClass",this.$rtti["TPersistentClass"]],["Component",this.$rtti["TComponent"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TReadComponentsProc",{procsig: rtl.newTIProcSig([["Component",this.$rtti["TComponent"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TReaderError",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Message",rtl.string,2],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TPropertyNotFoundEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Instance",this.$rtti["TPersistent"]],["PropName",rtl.string,1],["IsPath",rtl.boolean],["Handled",rtl.boolean,1],["Skip",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TFindComponentClassEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["ClassName",rtl.string,2],["ComponentClass",this.$rtti["TComponentClass"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TCreateComponentEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["ComponentClass",this.$rtti["TComponentClass"]],["Component",this.$rtti["TComponent"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TSetMethodPropertyEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Instance",this.$rtti["TPersistent"]],["PropInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["TheMethodName",rtl.string,2],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TReadWriteStringPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Instance",this.$rtti["TPersistent"],2],["PropInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["Content",rtl.string,1]]), methodkind: 0});
  rtl.createClass(this,"TReader",this.TFiler,function () {
    this.$init = function () {
      $mod.TFiler.$init.call(this);
      this.FDriver = null;
      this.FOwner = null;
      this.FParent = null;
      this.FFixups = null;
      this.FLoaded = null;
      this.FOnFindMethod = null;
      this.FOnSetMethodProperty = null;
      this.FOnSetName = null;
      this.FOnReferenceName = null;
      this.FOnAncestorNotFound = null;
      this.FOnError = null;
      this.FOnPropertyNotFound = null;
      this.FOnFindComponentClass = null;
      this.FOnCreateComponent = null;
      this.FPropName = "";
      this.FCanHandleExcepts = false;
      this.FOnReadStringProperty = null;
    };
    this.$final = function () {
      this.FDriver = undefined;
      this.FOwner = undefined;
      this.FParent = undefined;
      this.FFixups = undefined;
      this.FLoaded = undefined;
      this.FOnFindMethod = undefined;
      this.FOnSetMethodProperty = undefined;
      this.FOnSetName = undefined;
      this.FOnReferenceName = undefined;
      this.FOnAncestorNotFound = undefined;
      this.FOnError = undefined;
      this.FOnPropertyNotFound = undefined;
      this.FOnFindComponentClass = undefined;
      this.FOnCreateComponent = undefined;
      this.FOnReadStringProperty = undefined;
      $mod.TFiler.$final.call(this);
    };
    this.DoFixupReferences = function () {
      var R = null;
      var RN = null;
      var G = null;
      var Ref = "";
      var C = null;
      var P = 0;
      var L = null;
      var $ir = rtl.createIntfRefs();
      try {
        if (this.FFixups != null) {
          L = this.FFixups;
          R = L.FRoot;
          while (R !== null) {
            RN = R.Next;
            Ref = R.FRelative;
            if (this.FOnReferenceName != null) this.FOnReferenceName(this,{get: function () {
                return Ref;
              }, set: function (v) {
                Ref = v;
              }});
            C = $mod.FindNestedComponent(R.FRoot,Ref,true);
            if (C != null) {
              if (R.FPropInfo.typeinfo.kind === pas.System.TTypeKind.tkInterface) {
                pas.TypInfo.SetInterfaceProp$1(R.Finstance,R.FPropInfo,$ir.ref(1,rtl.queryIntfT(C,pas.System.IUnknown)))}
               else pas.TypInfo.SetObjectProp$1(R.Finstance,R.FPropInfo,C)}
             else {
              P = pas.System.Pos(".",R.FRelative);
              if (P !== 0) {
                G = $impl.AddtoResolveList(R.Finstance);
                G.AddReference(R.FRoot,R.FPropInfo,pas.System.Copy(R.FRelative,1,P - 1),pas.System.Copy(R.FRelative,P + 1,R.FRelative.length - P));
              };
            };
            L.RemoveItem(R,true);
            R = RN;
          };
          pas.SysUtils.FreeAndNil({p: this, get: function () {
              return this.p.FFixups;
            }, set: function (v) {
              this.p.FFixups = v;
            }});
        };
      } finally {
        $ir.free();
      };
    };
    this.FindComponentClass = function (AClassName) {
      var $Self = this;
      var Result = null;
      var PersistentClass = null;
      function FindClassInFieldTable(Instance) {
        var Result = null;
        var aClass = null;
        var i = 0;
        var ClassTI = null;
        var MemberClassTI = null;
        var MemberTI = null;
        aClass = Instance.$class.ClassType();
        while (aClass !== null) {
          ClassTI = aClass.$rtti;
          for (var $l = 0, $end = ClassTI.fields.length - 1; $l <= $end; $l++) {
            i = $l;
            MemberTI = ClassTI.getField(i).typeinfo;
            if (MemberTI.kind === pas.System.TTypeKind.tkClass) {
              MemberClassTI = MemberTI;
              if (pas.SysUtils.SameText(MemberClassTI.name,AClassName) && rtl.is(MemberClassTI.class,$mod.TComponent)) return MemberClassTI.class;
            };
          };
          aClass = aClass.$ancestor;
        };
        return Result;
      };
      Result = null;
      Result = FindClassInFieldTable(this.FRoot);
      if ((Result === null) && (this.FLookupRoot != null) && (this.FLookupRoot !== this.FRoot)) Result = FindClassInFieldTable(this.FLookupRoot);
      if (Result === null) {
        PersistentClass = $mod.GetClass(AClassName);
        if ((PersistentClass != null) && PersistentClass.InheritsFrom($mod.TComponent)) Result = PersistentClass;
      };
      if ((Result === null) && (this.FOnFindComponentClass != null)) this.FOnFindComponentClass($Self,AClassName,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      if ((Result === null) || !Result.InheritsFrom($mod.TComponent)) throw $mod.EClassNotFound.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SClassNotFound"),pas.System.VarRecs(18,AClassName)]);
      return Result;
    };
    this.Error = function (Message) {
      var Result = false;
      Result = false;
      if (this.FOnError != null) this.FOnError(this,Message,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.FindMethod = function (ARoot, AMethodName) {
      var Result = null;
      var ErrorResult = false;
      Result = null;
      if ((ARoot === null) || (AMethodName === "")) return Result;
      Result = ARoot.$class.MethodAddress(AMethodName);
      ErrorResult = Result === null;
      if (this.FOnFindMethod != null) this.FOnFindMethod(this,AMethodName,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return ErrorResult;
        }, set: function (v) {
          ErrorResult = v;
        }});
      if (ErrorResult) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadProperty = function (AInstance) {
      var $Self = this;
      var Path = "";
      var Instance = null;
      var PropInfo = null;
      var Obj = null;
      var Name = "";
      var Skip = false;
      var Handled = false;
      var OldPropName = "";
      var DotPos = "";
      var NextPos = 0;
      function HandleMissingProperty(IsPath) {
        var Result = false;
        Result = true;
        if ($Self.FOnPropertyNotFound != null) {
          OldPropName = $Self.FPropName;
          Handled = false;
          Skip = false;
          $Self.FOnPropertyNotFound($Self,Instance,{p: $Self, get: function () {
              return this.p.FPropName;
            }, set: function (v) {
              this.p.FPropName = v;
            }},IsPath,{get: function () {
              return Handled;
            }, set: function (v) {
              Handled = v;
            }},{get: function () {
              return Skip;
            }, set: function (v) {
              Skip = v;
            }});
          if (Handled && !Skip && (OldPropName !== $Self.FPropName)) PropInfo = pas.TypInfo.GetPropInfo$4(Instance.$class.ClassType(),$Self.FPropName);
          if (Skip) {
            $Self.FDriver.SkipValue();
            Result = false;
            return Result;
          };
        };
        return Result;
      };
      try {
        Path = this.FDriver.BeginProperty();
        try {
          Instance = AInstance;
          this.FCanHandleExcepts = true;
          DotPos = Path;
          while (true) {
            NextPos = pas.System.Pos(".",DotPos);
            if (NextPos > 0) {
              this.FPropName = pas.System.Copy(DotPos,1,NextPos - 1)}
             else {
              this.FPropName = DotPos;
              break;
            };
            pas.System.Delete({get: function () {
                return DotPos;
              }, set: function (v) {
                DotPos = v;
              }},1,NextPos);
            PropInfo = pas.TypInfo.GetPropInfo$4(Instance.$class.ClassType(),this.FPropName);
            if (!(PropInfo != null)) {
              if (!HandleMissingProperty(true)) return;
              if (!(PropInfo != null)) this.PropertyError();
            };
            if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkClass) {
              Obj = pas.TypInfo.GetObjectProp$2(Instance,PropInfo)}
             else Obj = null;
            if (!$mod.TPersistent.isPrototypeOf(Obj)) {
              this.FDriver.SkipValue();
              throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyPath")]);
            };
            Instance = Obj;
          };
          PropInfo = pas.TypInfo.GetPropInfo$4(Instance.$class.ClassType(),this.FPropName);
          if (PropInfo != null) {
            this.ReadPropValue(Instance,PropInfo)}
           else {
            this.FCanHandleExcepts = false;
            Instance.DefineProperties($Self);
            this.FCanHandleExcepts = true;
            if (this.FPropName.length > 0) {
              if (!HandleMissingProperty(false)) return;
              if (!(PropInfo != null)) this.PropertyError();
            };
          };
        } catch ($e) {
          if (pas.SysUtils.Exception.isPrototypeOf($e)) {
            var e = $e;
            Name = rtl.strSetLength(Name,0);
            if (AInstance.$class.InheritsFrom($mod.TComponent)) Name = AInstance.FName;
            if (Name.length === 0) Name = AInstance.$classname;
            throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SPropertyException"),pas.System.VarRecs(18,Name,9,".",18,Path,18,e.FMessage)]);
          } else throw $e
        };
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var e = $e;
          if (!this.FCanHandleExcepts || !this.Error(e.FMessage)) throw $e;
        } else throw $e
      };
    };
    var NullMethod = pas.System.TMethod.$clone({Code: null, Data: null});
    this.ReadPropValue = function (Instance, PropInfo) {
      var PropType = null;
      var Value = 0;
      var Ident = "";
      var Method = pas.System.TMethod.$new();
      var Handled = false;
      var TmpStr = "";
      if (PropInfo.setter === "") throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SReadOnlyProperty")]);
      PropType = PropInfo.typeinfo;
      var $tmp = PropType.kind;
      if ($tmp === pas.System.TTypeKind.tkInteger) {
        var $tmp1 = this.FDriver.NextValue();
        if ($tmp1 === $mod.TValueType.vaIdent) {
          Ident = this.ReadIdent();
          if ($impl.GlobalIdentToInt(Ident,{get: function () {
              return Value;
            }, set: function (v) {
              Value = v;
            }})) {
            pas.TypInfo.SetOrdProp$1(Instance,PropInfo,Value)}
           else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
        } else if ($tmp1 === $mod.TValueType.vaNativeInt) {
          pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.ReadNativeInt())}
         else if ($tmp1 === $mod.TValueType.vaCurrency) {
          pas.TypInfo.SetFloatProp$1(Instance,PropInfo,this.ReadCurrency() / 10000)}
         else {
          pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.ReadInteger());
        };
      } else if ($tmp === pas.System.TTypeKind.tkBool) {
        pas.TypInfo.SetBoolProp$1(Instance,PropInfo,this.ReadBoolean())}
       else if ($tmp === pas.System.TTypeKind.tkChar) {
        pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.ReadChar().charCodeAt())}
       else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
        Value = pas.TypInfo.GetEnumValue(PropType,this.ReadIdent());
        if (Value === -1) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
        pas.TypInfo.SetOrdProp$1(Instance,PropInfo,Value);
      } else if ($tmp === pas.System.TTypeKind.tkDouble) {
        pas.TypInfo.SetFloatProp$1(Instance,PropInfo,this.ReadFloat())}
       else if ($tmp === pas.System.TTypeKind.tkSet) {
        this.CheckValue($mod.TValueType.vaSet);
        if (PropType.comptype.kind === pas.System.TTypeKind.tkEnumeration) pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.FDriver.ReadSet(PropType.comptype));
      } else if (($tmp === pas.System.TTypeKind.tkMethod) || ($tmp === pas.System.TTypeKind.tkRefToProcVar)) {
        if (this.FDriver.NextValue() === $mod.TValueType.vaNil) {
          this.FDriver.ReadValue();
          pas.TypInfo.SetMethodProp(Instance,PropInfo,NullMethod);
        } else {
          Handled = false;
          Ident = this.ReadIdent();
          if (this.FOnSetMethodProperty != null) this.FOnSetMethodProperty(this,Instance,PropInfo,Ident,{get: function () {
              return Handled;
            }, set: function (v) {
              Handled = v;
            }});
          if (!Handled) {
            Method.Code = this.FindMethod(this.FRoot,Ident);
            Method.Data = this.FRoot;
            if (Method.Code != null) pas.TypInfo.SetMethodProp(Instance,PropInfo,Method);
          };
        }}
       else if ($tmp === pas.System.TTypeKind.tkString) {
        TmpStr = this.ReadString();
        if (this.FOnReadStringProperty != null) this.FOnReadStringProperty(this,Instance,PropInfo,{get: function () {
            return TmpStr;
          }, set: function (v) {
            TmpStr = v;
          }});
        pas.TypInfo.SetStrProp$1(Instance,PropInfo,TmpStr);
      } else if ($tmp === pas.System.TTypeKind.tkJSValue) {
        pas.TypInfo.SetJSValueProp$3(Instance,PropInfo,this.ReadVariant());
      } else if (($tmp === pas.System.TTypeKind.tkClass) || ($tmp === pas.System.TTypeKind.tkInterface)) {
        var $tmp2 = this.FDriver.NextValue();
        if ($tmp2 === $mod.TValueType.vaNil) {
          this.FDriver.ReadValue();
          pas.TypInfo.SetOrdProp$1(Instance,PropInfo,0);
        } else if ($tmp2 === $mod.TValueType.vaCollection) {
          this.FDriver.ReadValue();
          this.ReadCollection(pas.TypInfo.GetObjectProp$2(Instance,PropInfo));
        } else {
          if (!(this.FFixups != null)) this.FFixups = pas.simplelinkedlist.TLinkedList.$create("Create$1",[$impl.TLocalUnResolvedReference]);
          var $with = this.FFixups.Add();
          $with.Finstance = Instance;
          $with.FRoot = this.FRoot;
          $with.FPropInfo = PropInfo;
          $with.FRelative = this.ReadIdent();
        };
      } else {
        throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SUnknownPropertyType"),pas.System.VarRecs(18,pas.System.TTypeKind[PropType.kind])]);
      };
    };
    this.PropertyError = function () {
      this.FDriver.SkipValue();
      throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SUnknownProperty"),pas.System.VarRecs(18,this.FPropName)]);
    };
    this.ReadData = function (Instance) {
      var SavedOwner = null;
      var SavedParent = null;
      while (!this.EndOfList()) this.ReadProperty(Instance);
      this.ReadListEnd();
      SavedOwner = this.FOwner;
      SavedParent = this.FParent;
      try {
        this.FOwner = Instance.GetChildOwner();
        if (!(this.FOwner != null)) this.FOwner = this.FRoot;
        this.FParent = Instance.GetChildParent();
        while (!this.EndOfList()) this.ReadComponent(null);
        this.ReadListEnd();
      } finally {
        this.FOwner = SavedOwner;
        this.FParent = SavedParent;
      };
      if (Instance === this.FRoot) this.DoFixupReferences();
    };
    this.CreateDriver = function (Stream) {
      var Result = null;
      Result = $mod.TBinaryObjectReader.$create("Create$1",[Stream]);
      return Result;
    };
    this.Create$1 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalReader")]);
      this.FDriver = this.CreateDriver(Stream);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FDriver");
      pas.System.TObject.Destroy.call(this);
    };
    this.FlushBuffer = function () {
      this.FDriver.FlushBuffer();
    };
    this.BeginReferences = function () {
      this.FLoaded = $mod.TFPList.$create("Create");
    };
    this.CheckValue = function (Value) {
      if (this.FDriver.NextValue() !== Value) {
        throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")])}
       else this.FDriver.ReadValue();
    };
    this.DefineProperty = function (Name, AReadData, WriteData, HasData) {
      if ((AReadData != null) && pas.SysUtils.SameText(Name,this.FPropName)) {
        AReadData(this);
        this.FPropName = rtl.strSetLength(this.FPropName,0);
      } else if ((WriteData != null) && HasData) ;
    };
    this.DefineBinaryProperty = function (Name, AReadData, WriteData, HasData) {
      var MemBuffer = null;
      if ((AReadData != null) && pas.SysUtils.SameText(Name,this.FPropName)) {
        if (this.FDriver.NextValue() !== $mod.TValueType.vaBinary) {
          this.FDriver.SkipValue();
          this.FCanHandleExcepts = true;
          throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
        } else this.FDriver.ReadValue();
        MemBuffer = $mod.TMemoryStream.$create("Create");
        try {
          this.FDriver.ReadBinary(MemBuffer);
          this.FCanHandleExcepts = true;
          AReadData(MemBuffer);
        } finally {
          MemBuffer = rtl.freeLoc(MemBuffer);
        };
        this.FPropName = rtl.strSetLength(this.FPropName,0);
      } else if ((WriteData != null) && HasData) ;
    };
    this.EndOfList = function () {
      var Result = false;
      Result = this.FDriver.NextValue() === $mod.TValueType.vaNull;
      return Result;
    };
    this.EndReferences = function () {
      rtl.free(this,"FLoaded");
      this.FLoaded = null;
    };
    this.FixupReferences = function () {
      var i = 0;
      this.DoFixupReferences();
      $impl.GlobalFixupReferences();
      for (var $l = 0, $end = this.FLoaded.FCount - 1; $l <= $end; $l++) {
        i = $l;
        rtl.getObject(this.FLoaded.Get(i)).Loaded();
      };
    };
    this.NextValue = function () {
      var Result = 0;
      Result = this.FDriver.NextValue();
      return Result;
    };
    this.Read = function (Buffer, Count) {
      this.FDriver.Read(Buffer,Count);
    };
    this.ReadBoolean = function () {
      var Result = false;
      var ValueType = 0;
      ValueType = this.FDriver.ReadValue();
      if (ValueType === $mod.TValueType.vaTrue) {
        Result = true}
       else if (ValueType === $mod.TValueType.vaFalse) {
        Result = false}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadChar = function () {
      var Result = "\x00";
      var s = "";
      s = this.ReadString();
      if (s.length === 1) {
        Result = s.charAt(0)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadWideChar = function () {
      var Result = "\x00";
      var W = "";
      W = this.ReadWideString();
      if (W.length === 1) {
        Result = W.charAt(0)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadUnicodeChar = function () {
      var Result = "\x00";
      var U = "";
      U = this.ReadUnicodeString();
      if (U.length === 1) {
        Result = U.charAt(0)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadCollection = function (Collection) {
      var Item = null;
      Collection.BeginUpdate();
      if (!this.EndOfList()) Collection.Clear();
      while (!this.EndOfList()) {
        this.ReadListBegin();
        Item = Collection.Add();
        while (this.NextValue() !== $mod.TValueType.vaNull) this.ReadProperty(Item);
        this.ReadListEnd();
      };
      Collection.EndUpdate();
      this.ReadListEnd();
    };
    this.ReadComponent = function (Component) {
      var $Self = this;
      var Result = null;
      var Flags = {};
      function Recover(E, aComponent) {
        var Result = false;
        Result = false;
        if (!(($mod.TFilerFlag.ffInherited in Flags) || (Component != null))) aComponent.set(rtl.freeLoc(aComponent.get()));
        aComponent.set(null);
        $Self.FDriver.SkipComponent(false);
        Result = $Self.Error(E.FMessage);
        return Result;
      };
      var CompClassName = "";
      var Name = "";
      var n = 0;
      var ChildPos = 0;
      var SavedParent = null;
      var SavedLookupRoot = null;
      var ComponentClass = null;
      var C = null;
      var NewComponent = null;
      var SubComponents = null;
      this.FDriver.BeginComponent({get: function () {
          return Flags;
        }, set: function (v) {
          Flags = v;
        }},{get: function () {
          return ChildPos;
        }, set: function (v) {
          ChildPos = v;
        }},{get: function () {
          return CompClassName;
        }, set: function (v) {
          CompClassName = v;
        }},{get: function () {
          return Name;
        }, set: function (v) {
          Name = v;
        }});
      SavedParent = this.FParent;
      SavedLookupRoot = this.FLookupRoot;
      SubComponents = null;
      try {
        Result = Component;
        if (!(Result != null)) try {
          if ($mod.TFilerFlag.ffInherited in Flags) {
            if (this.FLookupRoot != null) {
              Result = this.FLookupRoot.FindComponent(Name)}
             else Result = null;
            if (!(Result != null)) {
              if (this.FOnAncestorNotFound != null) this.FOnAncestorNotFound($Self,Name,this.FindComponentClass(CompClassName),{get: function () {
                  return Result;
                }, set: function (v) {
                  Result = v;
                }});
              if (!(Result != null)) throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SAncestorNotFound"),pas.System.VarRecs(18,Name)]);
            };
            this.FParent = Result.GetParentComponent();
            if (!(this.FParent != null)) this.FParent = this.FRoot;
          } else {
            Result = null;
            ComponentClass = this.FindComponentClass(CompClassName);
            if (this.FOnCreateComponent != null) this.FOnCreateComponent($Self,ComponentClass,{get: function () {
                return Result;
              }, set: function (v) {
                Result = v;
              }});
            if (!(Result != null)) {
              NewComponent = Object.create(ComponentClass);
              NewComponent.$init();
              if ($mod.TFilerFlag.ffInline in Flags) NewComponent.FComponentState = rtl.unionSet(NewComponent.FComponentState,rtl.createSet($mod.TComponentStateItem.csLoading,$mod.TComponentStateItem.csInline));
              NewComponent.Create$1(this.FOwner);
              NewComponent.AfterConstruction();
              Result = NewComponent;
            };
            Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csLoading);
          };
        } catch ($e) {
          if (pas.SysUtils.Exception.isPrototypeOf($e)) {
            var E = $e;
            if (!Recover(E,{get: function () {
                return Result;
              }, set: function (v) {
                Result = v;
              }})) throw $e;
          } else throw $e
        };
        if (Result != null) try {
          Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csLoading);
          SubComponents = $mod.TList.$create("Create$1");
          for (var $l = 0, $end = Result.GetComponentCount() - 1; $l <= $end; $l++) {
            n = $l;
            C = Result.GetComponent(n);
            if ($mod.TComponentStyleItem.csSubComponent in C.FComponentStyle) {
              SubComponents.Add(C);
              C.FComponentState = rtl.includeSet(C.FComponentState,$mod.TComponentStateItem.csLoading);
            };
          };
          if (!($mod.TFilerFlag.ffInherited in Flags)) try {
            Result.SetParentComponent(this.FParent);
            if (this.FOnSetName != null) this.FOnSetName($Self,Result,{get: function () {
                return Name;
              }, set: function (v) {
                Name = v;
              }});
            Result.SetName(Name);
            if ($mod.FindGlobalComponent(Name) === Result) Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csInline);
          } catch ($e) {
            if (pas.SysUtils.Exception.isPrototypeOf($e)) {
              var E = $e;
              if (!Recover(E,{get: function () {
                  return Result;
                }, set: function (v) {
                  Result = v;
                }})) throw $e;
            } else throw $e
          };
          if (!(Result != null)) return Result;
          if ($mod.TComponentStateItem.csInline in Result.FComponentState) this.FLookupRoot = Result;
          Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csReading);
          for (var $l1 = 0, $end1 = SubComponents.GetCount() - 1; $l1 <= $end1; $l1++) {
            n = $l1;
            rtl.getObject(SubComponents.Get(n)).FComponentState = rtl.includeSet(rtl.getObject(SubComponents.Get(n)).FComponentState,$mod.TComponentStateItem.csReading);
          };
          Result.ReadState($Self);
          Result.FComponentState = rtl.excludeSet(Result.FComponentState,$mod.TComponentStateItem.csReading);
          for (var $l2 = 0, $end2 = SubComponents.GetCount() - 1; $l2 <= $end2; $l2++) {
            n = $l2;
            rtl.getObject(SubComponents.Get(n)).FComponentState = rtl.excludeSet(rtl.getObject(SubComponents.Get(n)).FComponentState,$mod.TComponentStateItem.csReading);
          };
          if ($mod.TFilerFlag.ffChildPos in Flags) this.FParent.SetChildOrder(Result,ChildPos);
          if (!(($mod.TFilerFlag.ffInherited in Flags) || ($mod.TComponentStateItem.csInline in Result.FComponentState)) || (this.FLoaded.IndexOf(Result) < 0)) {
            for (var $l3 = 0, $end3 = SubComponents.GetCount() - 1; $l3 <= $end3; $l3++) {
              n = $l3;
              this.FLoaded.Add(SubComponents.Get(n));
            };
            this.FLoaded.Add(Result);
          };
        } catch ($e) {
          if (($mod.TFilerFlag.ffInherited in Flags) || (Component != null)) Result = rtl.freeLoc(Result);
          throw $e;
        };
      } finally {
        this.FParent = SavedParent;
        this.FLookupRoot = SavedLookupRoot;
        SubComponents = rtl.freeLoc(SubComponents);
      };
      return Result;
    };
    this.ReadComponents = function (AOwner, AParent, Proc) {
      var Component = null;
      this.SetRoot(AOwner);
      this.FOwner = AOwner;
      this.FParent = AParent;
      this.BeginReferences();
      try {
        while (!this.EndOfList()) {
          this.FDriver.BeginRootComponent();
          Component = this.ReadComponent(null);
          if (Proc != null) Proc(Component);
        };
        this.ReadListEnd();
        this.FixupReferences();
      } finally {
        this.EndReferences();
      };
    };
    this.ReadFloat = function () {
      var Result = 0.0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaDouble) {
        this.ReadValue();
        Result = this.FDriver.ReadFloat();
      } else Result = this.ReadNativeInt();
      return Result;
    };
    this.ReadCurrency = function () {
      var Result = 0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaCurrency) {
        this.FDriver.ReadValue();
        Result = this.FDriver.ReadCurrency();
      } else Result = this.ReadInteger() * 10000;
      return Result;
    };
    this.ReadIdent = function () {
      var Result = "";
      var ValueType = 0;
      ValueType = this.FDriver.ReadValue();
      if (ValueType in rtl.createSet($mod.TValueType.vaIdent,$mod.TValueType.vaNil,$mod.TValueType.vaFalse,$mod.TValueType.vaTrue,$mod.TValueType.vaNull)) {
        Result = this.FDriver.ReadIdent(ValueType)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadInteger = function () {
      var Result = 0;
      var $tmp = this.FDriver.ReadValue();
      if ($tmp === $mod.TValueType.vaInt8) {
        Result = this.FDriver.ReadInt8()}
       else if ($tmp === $mod.TValueType.vaInt16) {
        Result = this.FDriver.ReadInt16()}
       else if ($tmp === $mod.TValueType.vaInt32) {
        Result = this.FDriver.ReadInt32()}
       else {
        throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      };
      return Result;
    };
    this.ReadNativeInt = function () {
      var Result = 0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaNativeInt) {
        this.FDriver.ReadValue();
        Result = this.FDriver.ReadNativeInt();
      } else Result = this.ReadInteger();
      return Result;
    };
    this.ReadSet = function (EnumType) {
      var Result = 0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaSet) {
        this.FDriver.ReadValue();
        Result = this.FDriver.ReadSet(EnumType);
      } else Result = this.ReadInteger();
      return Result;
    };
    this.ReadListBegin = function () {
      this.CheckValue($mod.TValueType.vaList);
    };
    this.ReadListEnd = function () {
      this.CheckValue($mod.TValueType.vaNull);
    };
    this.ReadRootComponent = function (ARoot) {
      var Result = null;
      var Dummy = 0;
      var i = 0;
      var Flags = {};
      var CompClassName = "";
      var CompName = "";
      var ResultName = "";
      this.FDriver.BeginRootComponent();
      Result = null;
      try {
        this.FDriver.BeginComponent({get: function () {
            return Flags;
          }, set: function (v) {
            Flags = v;
          }},{get: function () {
            return Dummy;
          }, set: function (v) {
            Dummy = v;
          }},{get: function () {
            return CompClassName;
          }, set: function (v) {
            CompClassName = v;
          }},{get: function () {
            return CompName;
          }, set: function (v) {
            CompName = v;
          }});
        if (!(ARoot != null)) {
          Result = $mod.FindClass(CompClassName).$create("Create$1",[null]);
          Result.SetName(CompName);
        } else {
          Result = ARoot;
          if (!($mod.TComponentStateItem.csDesigning in Result.FComponentState)) {
            Result.FComponentState = rtl.unionSet(Result.FComponentState,rtl.createSet($mod.TComponentStateItem.csLoading,$mod.TComponentStateItem.csReading));
            i = 0;
            ResultName = CompName;
            while ($mod.FindGlobalComponent(ResultName) != null) {
              i += 1;
              ResultName = CompName + "_" + pas.SysUtils.IntToStr(i);
            };
            Result.SetName(ResultName);
          };
        };
        this.FRoot = Result;
        this.FLookupRoot = Result;
        if ($impl.GlobalLoaded != null) {
          this.FLoaded = $impl.GlobalLoaded}
         else this.FLoaded = $mod.TFPList.$create("Create");
        try {
          if (this.FLoaded.IndexOf(this.FRoot) < 0) this.FLoaded.Add(this.FRoot);
          this.FOwner = this.FRoot;
          this.FRoot.FComponentState = rtl.unionSet(this.FRoot.FComponentState,rtl.createSet($mod.TComponentStateItem.csLoading,$mod.TComponentStateItem.csReading));
          this.FRoot.ReadState(this);
          this.FRoot.FComponentState = rtl.excludeSet(this.FRoot.FComponentState,$mod.TComponentStateItem.csReading);
          if (!($impl.GlobalLoaded != null)) for (var $l = 0, $end = this.FLoaded.FCount - 1; $l <= $end; $l++) {
            i = $l;
            rtl.getObject(this.FLoaded.Get(i)).Loaded();
          };
        } finally {
          if (!($impl.GlobalLoaded != null)) rtl.free(this,"FLoaded");
          this.FLoaded = null;
        };
        $impl.GlobalFixupReferences();
      } catch ($e) {
        $mod.RemoveFixupReferences(ARoot,"");
        if (!(ARoot != null)) Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.ReadVariant = function () {
      var Result = undefined;
      var nv = 0;
      nv = this.NextValue();
      var $tmp = nv;
      if ($tmp === $mod.TValueType.vaNil) {
        Result = undefined;
        this.ReadValue();
      } else if ($tmp === $mod.TValueType.vaNull) {
        Result = null;
        this.ReadValue();
      } else if (($tmp === $mod.TValueType.vaInt8) || ($tmp === $mod.TValueType.vaInt16) || ($tmp === $mod.TValueType.vaInt32)) {
        Result = this.ReadInteger();
      } else if ($tmp === $mod.TValueType.vaNativeInt) {
        Result = this.ReadNativeInt();
      } else if (($tmp === $mod.TValueType.vaFalse) || ($tmp === $mod.TValueType.vaTrue)) {
        Result = nv !== $mod.TValueType.vaFalse;
        this.ReadValue();
      } else if ($tmp === $mod.TValueType.vaCurrency) {
        Result = this.ReadCurrency() / 10000;
      } else if ($tmp === $mod.TValueType.vaDouble) {
        Result = this.ReadFloat();
      } else if ($tmp === $mod.TValueType.vaString) {
        Result = this.ReadString();
      } else {
        throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SUnsupportedPropertyVariantType"),pas.System.VarRecs(0,nv)]);
      };
      return Result;
    };
    this.ReadSignature = function () {
      this.FDriver.ReadSignature();
    };
    this.ReadString = function () {
      var Result = "";
      var StringType = 0;
      StringType = this.FDriver.ReadValue();
      if (StringType === $mod.TValueType.vaString) {
        Result = this.FDriver.ReadString(StringType)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadWideString = function () {
      var Result = "";
      Result = this.ReadString();
      return Result;
    };
    this.ReadUnicodeString = function () {
      var Result = "";
      Result = this.ReadString();
      return Result;
    };
    this.ReadValue = function () {
      var Result = 0;
      Result = this.FDriver.ReadValue();
      return Result;
    };
    this.CopyValue = function (Writer) {
      var $tmp = this.FDriver.NextValue();
      if ($tmp === $mod.TValueType.vaNull) {
        Writer.WriteIdent("NULL")}
       else if ($tmp === $mod.TValueType.vaFalse) {
        Writer.WriteIdent("FALSE")}
       else if ($tmp === $mod.TValueType.vaTrue) {
        Writer.WriteIdent("TRUE")}
       else if ($tmp === $mod.TValueType.vaNil) {
        Writer.WriteIdent("NIL")}
       else if (($tmp === $mod.TValueType.vaInt8) || ($tmp === $mod.TValueType.vaInt16) || ($tmp === $mod.TValueType.vaInt32)) {
        Writer.WriteInteger(this.ReadInteger())}
       else if ($tmp === $mod.TValueType.vaDouble) {
        Writer.WriteFloat(this.ReadFloat())}
       else if ($tmp === $mod.TValueType.vaString) {
        Writer.WriteString(this.ReadString())}
       else if ($tmp === $mod.TValueType.vaIdent) {
        Writer.WriteIdent(this.ReadIdent())}
       else if ($tmp === $mod.TValueType.vaNativeInt) Writer.WriteInteger$1(this.ReadNativeInt());
    };
  });
  rtl.createClass(this,"TAbstractObjectWriter",pas.System.TObject,function () {
  });
  rtl.createClass(this,"TBinaryObjectWriter",this.TAbstractObjectWriter,function () {
    this.$init = function () {
      $mod.TAbstractObjectWriter.$init.call(this);
      this.FStream = null;
      this.FBuffer = null;
      this.FBufSize = 0;
      this.FBufPos = 0;
      this.FBufEnd = 0;
    };
    this.$final = function () {
      this.FStream = undefined;
      $mod.TAbstractObjectWriter.$final.call(this);
    };
    this.WriteWord = function (w) {
      this.FStream.WriteBufferData$12(w);
    };
    this.WriteDWord = function (lw) {
      this.FStream.WriteBufferData$14(lw);
    };
    this.WriteValue = function (Value) {
      var b = 0;
      b = Value;
      this.FStream.WriteBufferData$8(b);
    };
    this.Create$1 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EWriteError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalWriter")]);
      this.FStream = Stream;
      return this;
    };
    this.WriteSignature = function () {
      this.FStream.WriteBufferData$14(809914452);
    };
    this.BeginCollection = function () {
      this.WriteValue($mod.TValueType.vaCollection);
    };
    this.BeginComponent = function (Component, Flags, ChildPos) {
      var Prefix = 0;
      if (rtl.neSet(Flags,{})) {
        Prefix = 0;
        if ($mod.TFilerFlag.ffInherited in Flags) Prefix = Prefix | 0x1;
        if ($mod.TFilerFlag.ffChildPos in Flags) Prefix = Prefix | 0x2;
        if ($mod.TFilerFlag.ffInline in Flags) Prefix = Prefix | 0x4;
        Prefix = Prefix | 0xf0;
        this.FStream.WriteBufferData$8(Prefix);
        if ($mod.TFilerFlag.ffChildPos in Flags) this.WriteInteger(ChildPos);
      };
      this.WriteStr(Component.$classname);
      this.WriteStr(Component.FName);
    };
    this.BeginList = function () {
      this.WriteValue($mod.TValueType.vaList);
    };
    this.EndList = function () {
      this.WriteValue($mod.TValueType.vaNull);
    };
    this.BeginProperty = function (PropName) {
      this.WriteStr(PropName);
    };
    this.EndProperty = function () {
    };
    this.FlushBuffer = function () {
    };
    this.Write = function (Buffer, Count) {
      this.FStream.Write(Buffer,Count);
    };
    this.WriteBinary = function (Buffer, Count) {
      this.WriteValue($mod.TValueType.vaBinary);
      this.WriteDWord(Count >>> 0);
      this.FStream.Write(Buffer,Count);
    };
    this.WriteBoolean = function (Value) {
      if (Value) {
        this.WriteValue($mod.TValueType.vaTrue)}
       else this.WriteValue($mod.TValueType.vaFalse);
    };
    this.WriteFloat = function (Value) {
      this.WriteValue($mod.TValueType.vaDouble);
      this.FStream.WriteBufferData$20(Value);
    };
    this.WriteCurrency = function (Value) {
      var F = 0.0;
      this.WriteValue($mod.TValueType.vaCurrency);
      F = Value / 10000;
      this.FStream.WriteBufferData$20(F);
    };
    this.WriteIdent = function (Ident) {
      if (pas.SysUtils.UpperCase(Ident) === "NIL") {
        this.WriteValue($mod.TValueType.vaNil)}
       else if (pas.SysUtils.UpperCase(Ident) === "FALSE") {
        this.WriteValue($mod.TValueType.vaFalse)}
       else if (pas.SysUtils.UpperCase(Ident) === "TRUE") {
        this.WriteValue($mod.TValueType.vaTrue)}
       else if (pas.SysUtils.UpperCase(Ident) === "NULL") {
        this.WriteValue($mod.TValueType.vaNull)}
       else {
        this.WriteValue($mod.TValueType.vaIdent);
        this.WriteStr(Ident);
      };
    };
    this.WriteInteger = function (Value) {
      var s = 0;
      var i = 0;
      var l = 0;
      if ((Value >= -128) && (Value <= 127)) {
        this.WriteValue($mod.TValueType.vaInt8);
        s = Value;
        this.FStream.WriteBufferData$6(s);
      } else if ((Value >= -32768) && (Value <= 32767)) {
        this.WriteValue($mod.TValueType.vaInt16);
        i = Value;
        this.WriteWord(i & 65535);
      } else if ((Value >= -0x80000000) && (Value <= 0x7fffffff)) {
        this.WriteValue($mod.TValueType.vaInt32);
        l = Value;
        this.WriteDWord(l >>> 0);
      } else {
        this.WriteValue($mod.TValueType.vaNativeInt);
        this.FStream.WriteBufferData$16(Value);
      };
    };
    this.WriteNativeInt = function (Value) {
      var s = 0;
      var i = 0;
      var l = 0;
      if (Value <= 127) {
        this.WriteValue($mod.TValueType.vaInt8);
        s = Value;
        this.FStream.WriteBufferData$6(s);
      } else if (Value <= 32767) {
        this.WriteValue($mod.TValueType.vaInt16);
        i = Value;
        this.WriteWord(i & 65535);
      } else if (Value <= 0x7fffffff) {
        this.WriteValue($mod.TValueType.vaInt32);
        l = Value;
        this.WriteDWord(l >>> 0);
      } else {
        this.WriteValue($mod.TValueType.vaNativeInt);
        this.FStream.WriteBufferData$16(Value);
      };
    };
    this.WriteMethodName = function (Name) {
      if (Name.length > 0) {
        this.WriteValue($mod.TValueType.vaIdent);
        this.WriteStr(Name);
      } else this.WriteValue($mod.TValueType.vaNil);
    };
    this.WriteSet = function (Value, SetType) {
      var i = 0;
      var b = 0;
      this.WriteValue($mod.TValueType.vaSet);
      b = 1;
      for (i = 0; i <= 31; i++) {
        if ((Value & b) !== 0) {
          this.WriteStr(pas.TypInfo.GetEnumName(SetType,i));
        };
        b = b << 1;
      };
      this.WriteStr("");
    };
    this.WriteStr = function (Value) {
      var len = 0;
      var i = 0;
      var b = 0;
      len = Value.length;
      if (len > 255) len = 255;
      b = len;
      this.FStream.WriteBufferData$8(b);
      for (var $l = 1, $end = len; $l <= $end; $l++) {
        i = $l;
        this.FStream.WriteBufferData$4(Value.charAt(i - 1));
      };
    };
    this.WriteString = function (Value) {
      var i = 0;
      var len = 0;
      len = Value.length;
      this.WriteValue($mod.TValueType.vaString);
      this.WriteDWord(len);
      for (var $l = 1, $end = len; $l <= $end; $l++) {
        i = $l;
        this.FStream.WriteBufferData$4(Value.charAt(i - 1));
      };
    };
    this.WriteWideString = function (Value) {
      this.WriteString(Value);
    };
    this.WriteUnicodeString = function (Value) {
      this.WriteString(Value);
    };
    this.WriteVariant = function (VarValue) {
      if (pas.JS.isUndefined(VarValue)) {
        this.WriteValue($mod.TValueType.vaNil)}
       else if (pas.JS.isNull(VarValue)) {
        this.WriteValue($mod.TValueType.vaNull)}
       else if (rtl.isNumber(VarValue)) {
        if (pas.System.Frac(rtl.getNumber(VarValue)) === 0) {
          this.WriteInteger(rtl.trunc(VarValue))}
         else this.WriteFloat(rtl.getNumber(VarValue));
      } else if (pas.JS.isBoolean(VarValue)) {
        this.WriteBoolean(!(VarValue == false))}
       else if (rtl.isString(VarValue)) {
        this.WriteString("" + VarValue)}
       else throw $mod.EWriteError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SUnsupportedPropertyVariantType")]);
    };
  });
  this.$rtti.$MethodVar("TFindAncestorEvent",{procsig: rtl.newTIProcSig([["Writer",this.$rtti["TWriter"]],["Component",this.$rtti["TComponent"]],["Name",rtl.string,2],["Ancestor",this.$rtti["TComponent"],1],["RootAncestor",this.$rtti["TComponent"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TWriteMethodPropertyEvent",{procsig: rtl.newTIProcSig([["Writer",this.$rtti["TWriter"]],["Instance",this.$rtti["TPersistent"]],["PropInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["MethodValue",pas.System.$rtti["TMethod"],2],["DefMethodValue",pas.System.$rtti["TMethod"],2],["Handled",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TWriter",this.TFiler,function () {
    this.$init = function () {
      $mod.TFiler.$init.call(this);
      this.FDriver = null;
      this.FDestroyDriver = false;
      this.FRootAncestor = null;
      this.FPropPath = "";
      this.FAncestors = null;
      this.FAncestorPos = 0;
      this.FCurrentPos = 0;
      this.FOnFindAncestor = null;
      this.FOnWriteMethodProperty = null;
      this.FOnWriteStringProperty = null;
    };
    this.$final = function () {
      this.FDriver = undefined;
      this.FRootAncestor = undefined;
      this.FAncestors = undefined;
      this.FOnFindAncestor = undefined;
      this.FOnWriteMethodProperty = undefined;
      this.FOnWriteStringProperty = undefined;
      $mod.TFiler.$final.call(this);
    };
    this.AddToAncestorList = function (Component) {
      this.FAncestors.AddObject(Component.FName,$impl.TPosComponent.$create("Create$1",[this.FAncestors.GetCount(),Component]));
    };
    this.WriteComponentData = function (Instance) {
      var Flags = {};
      Flags = {};
      if ((this.FAncestor != null) && (!($mod.TComponentStateItem.csInline in Instance.FComponentState) || (($mod.TComponentStateItem.csAncestor in Instance.FComponentState) && (this.FAncestors !== null)))) {
        Flags = rtl.createSet($mod.TFilerFlag.ffInherited)}
       else if ($mod.TComponentStateItem.csInline in Instance.FComponentState) Flags = rtl.createSet($mod.TFilerFlag.ffInline);
      if ((this.FAncestors !== null) && ((this.FCurrentPos !== this.FAncestorPos) || (this.FAncestor === null))) Flags = rtl.includeSet(Flags,$mod.TFilerFlag.ffChildPos);
      this.FDriver.BeginComponent(Instance,rtl.refSet(Flags),this.FCurrentPos);
      if (this.FAncestors !== null) this.FCurrentPos += 1;
      this.WriteProperties(Instance);
      this.WriteListEnd();
      if (!this.FIgnoreChildren) this.WriteChildren(Instance);
    };
    this.DetermineAncestor = function (Component) {
      var I = 0;
      if (!(this.FAncestors != null)) return;
      I = this.FAncestors.IndexOf(Component.FName);
      if (I === -1) {
        this.FAncestor = null;
        this.FAncestorPos = -1;
      } else {
        this.FAncestor = this.FAncestors.GetObject(I).FComponent;
        this.FAncestorPos = this.FAncestors.GetObject(I).FPos;
      };
    };
    this.DoFindAncestor = function (Component) {
      var C = null;
      if (this.FOnFindAncestor != null) if ((this.FAncestor === null) || $mod.TComponent.isPrototypeOf(this.FAncestor)) {
        C = this.FAncestor;
        this.FOnFindAncestor(this,Component,Component.FName,{get: function () {
            return C;
          }, set: function (v) {
            C = v;
          }},{p: this, get: function () {
            return this.p.FRootAncestor;
          }, set: function (v) {
            this.p.FRootAncestor = v;
          }});
        this.FAncestor = C;
      };
    };
    this.SetRoot = function (ARoot) {
      $mod.TFiler.SetRoot.call(this,ARoot);
      this.FLookupRoot = ARoot;
    };
    this.WriteBinary = function (AWriteData) {
      var MemBuffer = null;
      MemBuffer = $mod.TBytesStream.$create("Create");
      try {
        AWriteData(MemBuffer);
        this.FDriver.WriteBinary(MemBuffer.GetBytes(),MemBuffer.GetSize());
      } finally {
        MemBuffer = rtl.freeLoc(MemBuffer);
      };
    };
    this.WriteProperty = function (Instance, PropInfo) {
      var HasAncestor = false;
      var PropType = null;
      var N = 0;
      var Value = 0;
      var DefValue = 0;
      var Ident = "";
      var IntToIdentFn = null;
      var FloatValue = 0.0;
      var DefFloatValue = 0.0;
      var MethodValue = pas.System.TMethod.$new();
      var DefMethodValue = pas.System.TMethod.$new();
      var StrValue = "";
      var DefStrValue = "";
      var AncestorObj = null;
      var C = null;
      var Component = null;
      var ObjValue = null;
      var SavedAncestor = null;
      var Key = "";
      var SavedPropPath = "";
      var Name = "";
      var lMethodName = "";
      var VarValue = undefined;
      var DefVarValue = undefined;
      var BoolValue = false;
      var DefBoolValue = false;
      var Handled = false;
      var O = null;
      if (PropInfo.getter === "") return;
      PropType = PropInfo.typeinfo;
      if (PropInfo.setter === "") {
        if (PropType.kind !== pas.System.TTypeKind.tkClass) return;
        ObjValue = pas.TypInfo.GetObjectProp$2(Instance,PropInfo);
        if (!ObjValue.$class.InheritsFrom($mod.TComponent) || !($mod.TComponentStyleItem.csSubComponent in ObjValue.FComponentStyle)) return;
      };
      HasAncestor = (this.FAncestor != null) && ((Instance === this.FRoot) || (Instance.$class.ClassType() === this.FAncestor.$class.ClassType()));
      var $tmp = PropType.kind;
      if (($tmp === pas.System.TTypeKind.tkInteger) || ($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkEnumeration) || ($tmp === pas.System.TTypeKind.tkSet)) {
        Value = pas.TypInfo.GetOrdProp$1(Instance,PropInfo);
        if (HasAncestor) {
          DefValue = pas.TypInfo.GetOrdProp$1(this.FAncestor,PropInfo)}
         else {
          if (PropType.kind !== pas.System.TTypeKind.tkSet) {
            DefValue = rtl.trunc(PropInfo.Default)}
           else {
            O = PropInfo.Default;
            DefValue = 0;
            for (Key in O) {
              N = parseInt(Key,10);
              if (N < 32) DefValue = DefValue + (1 << N);
            };
          };
        };
        if ((Value !== DefValue) || (DefValue === 0x80000000)) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          var $tmp1 = PropType.kind;
          if ($tmp1 === pas.System.TTypeKind.tkInteger) {
            IntToIdentFn = $mod.FindIntToIdent(PropInfo.typeinfo);
            if ((IntToIdentFn != null) && IntToIdentFn(Value,{get: function () {
                return Ident;
              }, set: function (v) {
                Ident = v;
              }})) {
              this.WriteIdent(Ident)}
             else this.WriteInteger(Value);
          } else if ($tmp1 === pas.System.TTypeKind.tkChar) {
            this.WriteChar(String.fromCharCode(Value))}
           else if ($tmp1 === pas.System.TTypeKind.tkSet) {
            this.FDriver.WriteSet(Value,PropType.comptype);
          } else if ($tmp1 === pas.System.TTypeKind.tkEnumeration) this.WriteIdent(pas.TypInfo.GetEnumName(PropType,Value));
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkDouble) {
        FloatValue = pas.TypInfo.GetFloatProp$1(Instance,PropInfo);
        if (HasAncestor) {
          DefFloatValue = pas.TypInfo.GetFloatProp$1(this.FAncestor,PropInfo)}
         else {
          DefFloatValue = rtl.getNumber(PropInfo.Default);
        };
        if ((FloatValue !== DefFloatValue) || (!HasAncestor && (pas.System.Int(DefFloatValue) === 0x80000000))) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          this.WriteFloat(FloatValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkMethod) {
        MethodValue.$assign(pas.TypInfo.GetMethodProp(Instance,PropInfo));
        if (HasAncestor) {
          DefMethodValue.$assign(pas.TypInfo.GetMethodProp(this.FAncestor,PropInfo))}
         else {
          DefMethodValue.Data = null;
          DefMethodValue.Code = null;
        };
        Handled = false;
        if (this.FOnWriteMethodProperty != null) this.FOnWriteMethodProperty(this,Instance,PropInfo,MethodValue,DefMethodValue,{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
        if (rtl.isString(MethodValue.Code)) {
          lMethodName = MethodValue.Code}
         else lMethodName = this.FLookupRoot.$class.MethodName(MethodValue.Code);
        if (!Handled && (MethodValue.Code !== DefMethodValue.Code) && (!(MethodValue.Code != null) || (lMethodName.length > 0))) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          if (MethodValue.Code != null) {
            this.FDriver.WriteMethodName(lMethodName)}
           else this.FDriver.WriteMethodName("");
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkString) {
        StrValue = pas.TypInfo.GetStrProp$1(Instance,PropInfo);
        if (HasAncestor) {
          DefStrValue = pas.TypInfo.GetStrProp$1(this.FAncestor,PropInfo)}
         else {
          DefValue = rtl.trunc(PropInfo.Default);
          DefStrValue = rtl.strSetLength(DefStrValue,0);
        };
        if ((StrValue !== DefStrValue) || (!HasAncestor && (DefValue === 0x80000000))) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          if (this.FOnWriteStringProperty != null) this.FOnWriteStringProperty(this,Instance,PropInfo,{get: function () {
              return StrValue;
            }, set: function (v) {
              StrValue = v;
            }});
          this.WriteString(StrValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkJSValue) {
        VarValue = pas.TypInfo.GetJSValueProp$3(Instance,PropInfo);
        if (HasAncestor) {
          DefVarValue = pas.TypInfo.GetJSValueProp$3(this.FAncestor,PropInfo)}
         else DefVarValue = null;
        if (VarValue != DefVarValue) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          this.WriteVariant(VarValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkClass) {
        ObjValue = pas.TypInfo.GetObjectProp$2(Instance,PropInfo);
        if (HasAncestor) {
          AncestorObj = pas.TypInfo.GetObjectProp$2(this.FAncestor,PropInfo);
          if ($mod.TComponent.isPrototypeOf(AncestorObj) && $mod.TComponent.isPrototypeOf(ObjValue)) {
            if ((AncestorObj !== ObjValue) && (AncestorObj.FOwner === this.FRootAncestor) && (ObjValue.FOwner === this.FRoot) && (pas.SysUtils.UpperCase(AncestorObj.FName) === pas.SysUtils.UpperCase(ObjValue.FName))) {
              AncestorObj = ObjValue;
            };
          };
        } else AncestorObj = null;
        if (!(ObjValue != null)) {
          if (ObjValue !== AncestorObj) {
            this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
            this.FDriver.WriteIdent("NIL");
            this.FDriver.EndProperty();
          };
        } else if (ObjValue.$class.InheritsFrom($mod.TPersistent)) {
          if (ObjValue.$class.InheritsFrom($mod.TComponent) && (!($mod.TComponentStyleItem.csSubComponent in ObjValue.FComponentStyle) || ((ObjValue.FOwner !== Instance) && (ObjValue.FOwner !== null)))) {
            Component = ObjValue;
            if ((ObjValue !== AncestorObj) && !($mod.TComponentStyleItem.csTransient in Component.FComponentStyle)) {
              Name = "";
              C = Component;
              while ((C !== null) && (C.FName !== "")) {
                if (Name !== "") Name = "." + Name;
                if (C.FOwner === this.FLookupRoot) {
                  Name = C.FName + Name;
                  break;
                } else if (C === this.FLookupRoot) {
                  Name = "Owner" + Name;
                  break;
                };
                Name = C.FName + Name;
                C = C.FOwner;
              };
              if ((C === null) && (Component.FOwner === null)) if (Name !== "") Name = Name + ".Owner";
              if (Name.length > 0) {
                this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
                this.WriteIdent(Name);
                this.FDriver.EndProperty();
              };
            };
          } else {
            SavedAncestor = this.FAncestor;
            SavedPropPath = this.FPropPath;
            try {
              this.FPropPath = this.FPropPath + PropInfo.name + ".";
              if (HasAncestor) this.FAncestor = pas.TypInfo.GetObjectProp$2(this.FAncestor,PropInfo);
              this.WriteProperties(ObjValue);
            } finally {
              this.FAncestor = SavedAncestor;
              this.FPropPath = SavedPropPath;
            };
            if (ObjValue.$class.InheritsFrom($mod.TCollection)) {
              if (!HasAncestor || !$mod.CollectionsEqual$1(ObjValue,pas.TypInfo.GetObjectProp$2(this.FAncestor,PropInfo),this.FRoot,this.FRootAncestor)) {
                this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
                SavedPropPath = this.FPropPath;
                try {
                  this.FPropPath = rtl.strSetLength(this.FPropPath,0);
                  this.WriteCollection(ObjValue);
                } finally {
                  this.FPropPath = SavedPropPath;
                  this.FDriver.EndProperty();
                };
              };
            };
          };
        };
      } else if ($tmp === pas.System.TTypeKind.tkBool) {
        BoolValue = pas.TypInfo.GetOrdProp$1(Instance,PropInfo) !== 0;
        if (HasAncestor) {
          DefBoolValue = pas.TypInfo.GetOrdProp$1(this.FAncestor,PropInfo) !== 0}
         else {
          DefBoolValue = PropInfo.Default != 0;
          DefValue = rtl.trunc(PropInfo.Default);
        };
        if ((BoolValue !== DefBoolValue) || (DefValue === 0x80000000)) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          this.WriteBoolean(BoolValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkInterface) ;
    };
    this.WriteProperties = function (Instance) {
      var PropCount = 0;
      var i = 0;
      var PropList = [];
      PropList = pas.TypInfo.GetPropList$3(Instance);
      PropCount = rtl.length(PropList);
      if (PropCount > 0) for (var $l = 0, $end = PropCount - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.TypInfo.IsStoredProp(Instance,PropList[i])) this.WriteProperty(Instance,PropList[i]);
      };
      Instance.DefineProperties(this);
    };
    this.WriteChildren = function (Component) {
      var SRoot = null;
      var SRootA = null;
      var SList = null;
      var SPos = 0;
      var I = 0;
      var SAncestorPos = 0;
      var O = null;
      SRoot = this.FRoot;
      SRootA = this.FRootAncestor;
      SList = this.FAncestors;
      SPos = this.FCurrentPos;
      SAncestorPos = this.FAncestorPos;
      try {
        this.FAncestors = null;
        this.FCurrentPos = 0;
        this.FAncestorPos = -1;
        if ($mod.TComponentStateItem.csInline in Component.FComponentState) this.FRoot = Component;
        if ($mod.TComponent.isPrototypeOf(this.FAncestor)) {
          this.FAncestors = $mod.TStringList.$create("Create$1");
          if ($mod.TComponentStateItem.csInline in this.FAncestor.FComponentState) this.FRootAncestor = this.FAncestor;
          this.FAncestor.GetChildren(rtl.createCallback(this,"AddToAncestorList"),this.FRootAncestor);
          this.FAncestors.SetSorted(true);
        };
        try {
          Component.GetChildren(rtl.createCallback(this,"WriteComponent"),this.FRoot);
        } finally {
          if (this.FAncestors != null) for (var $l = 0, $end = this.FAncestors.GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            O = this.FAncestors.GetObject(I);
            this.FAncestors.PutObject(I,null);
            O = rtl.freeLoc(O);
          };
          pas.SysUtils.FreeAndNil({p: this, get: function () {
              return this.p.FAncestors;
            }, set: function (v) {
              this.p.FAncestors = v;
            }});
        };
      } finally {
        this.FAncestors = SList;
        this.FRoot = SRoot;
        this.FRootAncestor = SRootA;
        this.FCurrentPos = SPos;
        this.FAncestorPos = SAncestorPos;
      };
    };
    this.CreateDriver = function (Stream) {
      var Result = null;
      Result = $mod.TBinaryObjectWriter.$create("Create$1",[Stream]);
      return Result;
    };
    this.Create$1 = function (ADriver) {
      pas.System.TObject.Create.call(this);
      this.FDriver = ADriver;
      return this;
    };
    this.Create$2 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EWriteError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalWriter")]);
      this.FDriver = this.CreateDriver(Stream);
      this.FDestroyDriver = true;
      return this;
    };
    this.Destroy = function () {
      if (this.FDestroyDriver) rtl.free(this,"FDriver");
      pas.System.TObject.Destroy.call(this);
    };
    this.DefineProperty = function (Name, ReadData, AWriteData, HasData) {
      if (HasData && (AWriteData != null)) {
        this.FDriver.BeginProperty(this.FPropPath + Name);
        AWriteData(this);
        this.FDriver.EndProperty();
      } else if (ReadData != null) ;
    };
    this.DefineBinaryProperty = function (Name, ReadData, AWriteData, HasData) {
      if (HasData && (AWriteData != null)) {
        this.FDriver.BeginProperty(this.FPropPath + Name);
        this.WriteBinary(AWriteData);
        this.FDriver.EndProperty();
      } else if (ReadData != null) ;
    };
    this.FlushBuffer = function () {
      this.FDriver.FlushBuffer();
    };
    this.Write = function (Buffer, Count) {
      this.FDriver.Write(Buffer,Count);
    };
    this.WriteBoolean = function (Value) {
      this.FDriver.WriteBoolean(Value);
    };
    this.WriteCollection = function (Value) {
      var i = 0;
      this.FDriver.BeginCollection();
      if (Value != null) for (var $l = 0, $end = Value.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.WriteListBegin();
        this.WriteProperties(Value.GetItem(i));
        this.WriteListEnd();
      };
      this.WriteListEnd();
    };
    this.WriteComponent = function (Component) {
      var SA = null;
      var SR = null;
      var SRA = null;
      SR = this.FRoot;
      SA = this.FAncestor;
      SRA = this.FRootAncestor;
      try {
        Component.FComponentState = rtl.unionSet(Component.FComponentState,rtl.createSet($mod.TComponentStateItem.csWriting));
        try {
          this.DetermineAncestor(Component);
          this.DoFindAncestor(Component);
          Component.WriteState(this);
          this.FDriver.EndList();
        } finally {
          Component.FComponentState = rtl.diffSet(Component.FComponentState,rtl.createSet($mod.TComponentStateItem.csWriting));
        };
      } finally {
        this.FAncestor = SA;
        this.FRoot = SR;
        this.FRootAncestor = SRA;
      };
    };
    this.WriteChar = function (Value) {
      this.WriteString(Value);
    };
    this.WriteWideChar = function (Value) {
      this.WriteWideString(Value);
    };
    this.WriteDescendent = function (ARoot, AAncestor) {
      this.FRoot = ARoot;
      this.FAncestor = AAncestor;
      this.FRootAncestor = AAncestor;
      this.FLookupRoot = ARoot;
      this.WriteSignature();
      this.WriteComponent(ARoot);
    };
    this.WriteFloat = function (Value) {
      this.FDriver.WriteFloat(Value);
    };
    this.WriteCurrency = function (Value) {
      this.FDriver.WriteCurrency(Value);
    };
    this.WriteIdent = function (Ident) {
      this.FDriver.WriteIdent(Ident);
    };
    this.WriteInteger = function (Value) {
      this.FDriver.WriteInteger(Value);
    };
    this.WriteInteger$1 = function (Value) {
      this.FDriver.WriteInteger(Value);
    };
    this.WriteSet = function (Value, SetType) {
      this.FDriver.WriteSet(Value,SetType);
    };
    this.WriteListBegin = function () {
      this.FDriver.BeginList();
    };
    this.WriteListEnd = function () {
      this.FDriver.EndList();
    };
    this.WriteSignature = function () {
      this.FDriver.WriteSignature();
    };
    this.WriteRootComponent = function (ARoot) {
      this.WriteDescendent(ARoot,null);
    };
    this.WriteString = function (Value) {
      this.FDriver.WriteString(Value);
    };
    this.WriteWideString = function (Value) {
      this.FDriver.WriteWideString(Value);
    };
    this.WriteUnicodeString = function (Value) {
      this.FDriver.WriteUnicodeString(Value);
    };
    this.WriteVariant = function (VarValue) {
      this.FDriver.WriteVariant(VarValue);
    };
  });
  this.TParserToken = {"0": "toUnknown", toUnknown: 0, "1": "toEOF", toEOF: 1, "2": "toSymbol", toSymbol: 2, "3": "ToString", ToString: 3, "4": "toInteger", toInteger: 4, "5": "toFloat", toFloat: 5, "6": "toMinus", toMinus: 6, "7": "toSetStart", toSetStart: 7, "8": "toListStart", toListStart: 8, "9": "toCollectionStart", toCollectionStart: 9, "10": "toBinaryStart", toBinaryStart: 10, "11": "toSetEnd", toSetEnd: 11, "12": "toListEnd", toListEnd: 12, "13": "toCollectionEnd", toCollectionEnd: 13, "14": "toBinaryEnd", toBinaryEnd: 14, "15": "toComma", toComma: 15, "16": "toDot", toDot: 16, "17": "toEqual", toEqual: 17, "18": "toColon", toColon: 18, "19": "toPlus", toPlus: 19};
  this.$rtti.$Enum("TParserToken",{minvalue: 0, maxvalue: 19, ordtype: 1, enumtype: this.TParserToken});
  rtl.createClass(this,"TParser",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.fStream = null;
      this.fBuf = [];
      this.FBufLen = 0;
      this.fPos = 0;
      this.fDeltaPos = 0;
      this.fFloatType = "\x00";
      this.fSourceLine = 0;
      this.fToken = 0;
      this.fEofReached = false;
      this.fLastTokenStr = "";
    };
    this.$final = function () {
      this.fStream = undefined;
      this.fBuf = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetTokenName = function (aTok) {
      var Result = "";
      Result = $impl.TokNames[aTok];
      return Result;
    };
    this.LoadBuffer = function () {
      var CharsRead = 0;
      var i = 0;
      CharsRead = 0;
      for (i = 0; i <= 4095; i++) {
        if (this.fStream.ReadData$3({a: i, p: this.fBuf, get: function () {
            return this.p[this.a];
          }, set: function (v) {
            this.p[this.a] = v;
          }}) !== 2) break;
        CharsRead += 1;
      };
      this.fDeltaPos += CharsRead;
      this.fPos = 0;
      this.FBufLen = CharsRead;
      this.fEofReached = CharsRead === 0;
    };
    this.CheckLoadBuffer = function () {
      if (this.fPos >= this.FBufLen) this.LoadBuffer();
    };
    this.ProcessChar = function () {
      this.fLastTokenStr = this.fLastTokenStr + this.fBuf[this.fPos];
      this.GotoToNextChar();
    };
    this.IsNumber = function () {
      var Result = false;
      Result = this.fBuf[this.fPos].charCodeAt() in rtl.createSet(null,48,57);
      return Result;
    };
    this.IsHexNum = function () {
      var Result = false;
      Result = this.fBuf[this.fPos].charCodeAt() in rtl.createSet(null,48,57,null,65,70,null,97,102);
      return Result;
    };
    this.IsAlpha = function () {
      var Result = false;
      Result = this.fBuf[this.fPos].charCodeAt() in rtl.createSet(95,null,65,90,null,97,122);
      return Result;
    };
    this.IsAlphaNum = function () {
      var Result = false;
      Result = this.IsAlpha() || this.IsNumber();
      return Result;
    };
    this.GetHexValue = function (c) {
      var Result = 0;
      var $tmp = c;
      if (($tmp >= "0") && ($tmp <= "9")) {
        Result = c.charCodeAt() - 0x30}
       else if (($tmp >= "A") && ($tmp <= "F")) {
        Result = c.charCodeAt() - 0x37}
       else if (($tmp >= "a") && ($tmp <= "f")) Result = c.charCodeAt() - 0x57;
      return Result;
    };
    this.GetAlphaNum = function () {
      var Result = "";
      if (!this.IsAlpha()) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserExpected"),pas.System.VarRecs(18,this.GetTokenName($mod.TParserToken.toSymbol)));
      Result = "";
      while (!this.fEofReached && this.IsAlphaNum()) {
        Result = Result + this.fBuf[this.fPos];
        this.GotoToNextChar();
      };
      return Result;
    };
    this.HandleNewLine = function () {
      if (this.fBuf[this.fPos] === "\r") this.GotoToNextChar();
      if (!this.fEofReached && (this.fBuf[this.fPos] === "\n")) this.GotoToNextChar();
      this.fSourceLine += 1;
      this.fDeltaPos = -(this.fPos - 1);
    };
    this.SkipBOM = function () {
    };
    this.SkipSpaces = function () {
      while (!this.fEofReached && (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(32,9))) this.GotoToNextChar();
    };
    this.SkipWhitespace = function () {
      while (!this.fEofReached) {
        var $tmp = this.fBuf[this.fPos];
        if (($tmp === " ") || ($tmp === "\t")) {
          this.SkipSpaces()}
         else if (($tmp === "\n") || ($tmp === "\r")) {
          this.HandleNewLine()}
         else {
          break;
        };
      };
    };
    this.HandleEof = function () {
      this.fToken = $mod.TParserToken.toEOF;
      this.fLastTokenStr = "";
    };
    this.HandleAlphaNum = function () {
      this.fLastTokenStr = this.GetAlphaNum();
      this.fToken = $mod.TParserToken.toSymbol;
    };
    var floatPunct = {"0": "fpDot", fpDot: 0, "1": "fpE", fpE: 1};
    this.HandleNumber = function () {
      var allowed = {};
      this.fLastTokenStr = "";
      while (this.IsNumber()) this.ProcessChar();
      this.fToken = $mod.TParserToken.toInteger;
      if (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(46,101,69)) {
        this.fToken = $mod.TParserToken.toFloat;
        allowed = rtl.createSet(floatPunct.fpDot,floatPunct.fpE);
        while (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(46,101,69,null,48,57)) {
          var $tmp = this.fBuf[this.fPos];
          if ($tmp === ".") {
            if (floatPunct.fpDot in allowed) {
              allowed = rtl.excludeSet(allowed,floatPunct.fpDot)}
             else break}
           else if (($tmp === "E") || ($tmp === "e")) if (floatPunct.fpE in allowed) {
            allowed = {};
            this.ProcessChar();
            if (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(43,45)) this.ProcessChar();
            if (!(this.fBuf[this.fPos].charCodeAt() in rtl.createSet(null,48,57))) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserInvalidFloat"),pas.System.VarRecs(18,this.fLastTokenStr + this.fBuf[this.fPos]));
          } else break;
          this.ProcessChar();
        };
      };
      if (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(115,83,100,68,99,67)) {
        this.fFloatType = this.fBuf[this.fPos];
        this.GotoToNextChar();
        this.fToken = $mod.TParserToken.toFloat;
      } else this.fFloatType = "\x00";
    };
    this.HandleHexNumber = function () {
      var valid = false;
      this.fLastTokenStr = "$";
      this.GotoToNextChar();
      valid = false;
      while (this.IsHexNum()) {
        valid = true;
        this.ProcessChar();
      };
      if (!valid) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserInvalidInteger"),pas.System.VarRecs(18,this.fLastTokenStr));
      this.fToken = $mod.TParserToken.toInteger;
    };
    this.HandleQuotedString = function () {
      var Result = "";
      Result = "";
      this.GotoToNextChar();
      while (true) {
        var $tmp = this.fBuf[this.fPos];
        if ($tmp === "\x00") {
          this.ErrorStr(rtl.getResStr(pas.RTLConsts,"SParserUnterminatedString"))}
         else if (($tmp === "\r") || ($tmp === "\n")) {
          this.ErrorStr(rtl.getResStr(pas.RTLConsts,"SParserUnterminatedString"))}
         else if ($tmp === "'") {
          this.GotoToNextChar();
          if (this.fBuf[this.fPos] !== "'") return Result;
        };
        Result = Result + this.fBuf[this.fPos];
        this.GotoToNextChar();
      };
      return Result;
    };
    this.HandleDecimalCharacter = function () {
      var Result = "\x00";
      var i = 0;
      this.GotoToNextChar();
      i = 0;
      while (this.IsNumber() && (i < 65535)) {
        i = ((i * 10) + this.fBuf[this.fPos].charCodeAt()) - 48;
        this.GotoToNextChar();
      };
      if (i > 65535) i = 0;
      Result = String.fromCharCode(i);
      return Result;
    };
    this.HandleString = function () {
      var s = "";
      this.fLastTokenStr = "";
      while (true) {
        var $tmp = this.fBuf[this.fPos];
        if ($tmp === "'") {
          s = this.HandleQuotedString();
          this.fLastTokenStr = this.fLastTokenStr + s;
        } else if ($tmp === "#") {
          this.fLastTokenStr = this.fLastTokenStr + this.HandleDecimalCharacter();
        } else {
          break;
        };
      };
      this.fToken = $mod.TParserToken.ToString;
    };
    this.HandleMinus = function () {
      this.GotoToNextChar();
      if (this.IsNumber()) {
        this.HandleNumber();
        this.fLastTokenStr = "-" + this.fLastTokenStr;
      } else {
        this.fToken = $mod.TParserToken.toMinus;
        this.fLastTokenStr = "-";
      };
    };
    this.HandleUnknown = function () {
      this.fToken = $mod.TParserToken.toUnknown;
      this.fLastTokenStr = this.fBuf[this.fPos];
      this.GotoToNextChar();
    };
    this.GotoToNextChar = function () {
      this.fPos += 1;
      this.CheckLoadBuffer();
    };
    this.Create$1 = function (Stream) {
      this.fStream = Stream;
      this.fBuf = rtl.arraySetLength(this.fBuf,"\x00",4096);
      this.FBufLen = 0;
      this.fPos = 0;
      this.fDeltaPos = 1;
      this.fSourceLine = 1;
      this.fEofReached = false;
      this.fLastTokenStr = "";
      this.fFloatType = "\x00";
      this.fToken = $mod.TParserToken.toEOF;
      this.LoadBuffer();
      this.SkipBOM();
      this.NextToken();
      return this;
    };
    this.Destroy = function () {
      var aCount = 0;
      aCount = this.fLastTokenStr.length * 2;
      this.fStream.SetPosition(this.SourcePos() - aCount);
    };
    this.CheckToken = function (T) {
      if (this.fToken !== T) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserWrongTokenType"),pas.System.VarRecs(18,this.GetTokenName(T),18,this.GetTokenName(this.fToken)));
    };
    this.CheckTokenSymbol = function (S) {
      this.CheckToken($mod.TParserToken.toSymbol);
      if (pas.SysUtils.CompareText(this.fLastTokenStr,S) !== 0) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserWrongTokenSymbol"),pas.System.VarRecs(18,S,18,this.fLastTokenStr));
    };
    this.Error = function (Ident) {
      this.ErrorStr(Ident);
    };
    this.ErrorFmt = function (Ident, Args) {
      this.ErrorStr(pas.SysUtils.Format(Ident,Args));
    };
    this.ErrorStr = function (Message) {
      throw $mod.EParserError.$create("CreateFmt",[Message + rtl.getResStr(pas.RTLConsts,"SParserLocInfo"),pas.System.VarRecs(0,this.fSourceLine,0,this.fPos + this.fDeltaPos,0,this.SourcePos())]);
    };
    this.HexToBinary = function (Stream) {
      var outbuf = [];
      var b = 0;
      var i = 0;
      outbuf = rtl.arraySetLength(outbuf,0,4096);
      i = 0;
      this.SkipWhitespace();
      while (this.IsHexNum()) {
        b = this.GetHexValue(this.fBuf[this.fPos]) << 4;
        this.GotoToNextChar();
        if (!this.IsHexNum()) this.Error(rtl.getResStr(pas.RTLConsts,"SParserUnterminatedBinValue"));
        b = b | this.GetHexValue(this.fBuf[this.fPos]);
        this.GotoToNextChar();
        outbuf[i] = b;
        i += 1;
        if (i >= 4096) {
          Stream.WriteBuffer(outbuf,i);
          i = 0;
        };
        this.SkipWhitespace();
      };
      if (i > 0) Stream.WriteBuffer(outbuf,i);
      this.NextToken();
    };
    this.NextToken = function () {
      var $Self = this;
      var Result = 0;
      function SetToken(aToken) {
        $Self.fToken = aToken;
        $Self.GotoToNextChar();
      };
      this.SkipWhitespace();
      if (this.fEofReached) {
        this.HandleEof()}
       else {
        var $tmp = this.fBuf[this.fPos];
        if (($tmp === "_") || (($tmp >= "A") && ($tmp <= "Z")) || (($tmp >= "a") && ($tmp <= "z"))) {
          this.HandleAlphaNum()}
         else if ($tmp === "$") {
          this.HandleHexNumber()}
         else if ($tmp === "-") {
          this.HandleMinus()}
         else if (($tmp >= "0") && ($tmp <= "9")) {
          this.HandleNumber()}
         else if (($tmp === "'") || ($tmp === "#")) {
          this.HandleString()}
         else if ($tmp === "[") {
          SetToken($mod.TParserToken.toSetStart)}
         else if ($tmp === "(") {
          SetToken($mod.TParserToken.toListStart)}
         else if ($tmp === "<") {
          SetToken($mod.TParserToken.toCollectionStart)}
         else if ($tmp === "{") {
          SetToken($mod.TParserToken.toBinaryStart)}
         else if ($tmp === "]") {
          SetToken($mod.TParserToken.toSetEnd)}
         else if ($tmp === ")") {
          SetToken($mod.TParserToken.toListEnd)}
         else if ($tmp === ">") {
          SetToken($mod.TParserToken.toCollectionEnd)}
         else if ($tmp === "}") {
          SetToken($mod.TParserToken.toBinaryEnd)}
         else if ($tmp === ",") {
          SetToken($mod.TParserToken.toComma)}
         else if ($tmp === ".") {
          SetToken($mod.TParserToken.toDot)}
         else if ($tmp === "=") {
          SetToken($mod.TParserToken.toEqual)}
         else if ($tmp === ":") {
          SetToken($mod.TParserToken.toColon)}
         else if ($tmp === "+") {
          SetToken($mod.TParserToken.toPlus)}
         else {
          this.HandleUnknown();
        };
      };
      Result = this.fToken;
      return Result;
    };
    this.SourcePos = function () {
      var Result = 0;
      Result = (this.fStream.GetPosition() - this.FBufLen) + this.fPos;
      return Result;
    };
    this.TokenComponentIdent = function () {
      var Result = "";
      if (this.fToken !== $mod.TParserToken.toSymbol) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserExpected"),pas.System.VarRecs(18,this.GetTokenName($mod.TParserToken.toSymbol)));
      this.CheckLoadBuffer();
      while (this.fBuf[this.fPos] === ".") {
        this.ProcessChar();
        this.fLastTokenStr = this.fLastTokenStr + this.GetAlphaNum();
      };
      Result = this.fLastTokenStr;
      return Result;
    };
    this.TokenFloat = function () {
      var Result = 0.0;
      var errcode = 0;
      pas.System.val$8(this.fLastTokenStr,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return errcode;
        }, set: function (v) {
          errcode = v;
        }});
      if (errcode !== 0) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserInvalidFloat"),pas.System.VarRecs(18,this.fLastTokenStr));
      return Result;
    };
    this.TokenInt = function () {
      var Result = 0;
      if (!pas.SysUtils.TryStrToInt64(this.fLastTokenStr,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = pas.SysUtils.StrToQWord(this.fLastTokenStr);
      return Result;
    };
    this.TokenString = function () {
      var Result = "";
      var $tmp = this.fToken;
      if ($tmp === $mod.TParserToken.toFloat) {
        if (this.fFloatType !== "\x00") {
          Result = this.fLastTokenStr + this.fFloatType}
         else Result = this.fLastTokenStr}
       else {
        Result = this.fLastTokenStr;
      };
      return Result;
    };
    this.TokenSymbolIs = function (S) {
      var Result = false;
      Result = (this.fToken === $mod.TParserToken.toSymbol) && (pas.SysUtils.CompareText(this.fLastTokenStr,S) === 0);
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TParser.fBuf$a",{eltype: rtl.char});
  });
  this.TObjectTextEncoding = {"0": "oteDFM", oteDFM: 0, "1": "oteLFM", oteLFM: 1};
  this.$rtti.$Enum("TObjectTextEncoding",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TObjectTextEncoding});
  rtl.createClass(this,"TObjectStreamConverter",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FIndent = "";
      this.FInput = null;
      this.FOutput = null;
      this.FEncoding = 0;
      this.FPlainStrings = false;
    };
    this.$final = function () {
      this.FInput = undefined;
      this.FOutput = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Outchars = function (S) {
      var res = "";
      var NewStr = "";
      var i = 0;
      var len = 0;
      var w = 0;
      var InString = false;
      var NewInString = false;
      if (S === "") {
        res = "''"}
       else {
        res = "";
        InString = false;
        len = S.length;
        i = 0;
        while (i < len) {
          NewInString = InString;
          w = S.charCodeAt(i);
          if (w === 39) {
            if (!InString) NewInString = true;
            NewStr = "''";
          } else if ((w >= 32) && (w < 127)) {
            if (!InString) NewInString = true;
            NewStr = String.fromCharCode(w);
          } else {
            if (InString) NewInString = false;
            NewStr = "#" + pas.SysUtils.IntToStr(w);
          };
          if (NewInString !== InString) {
            NewStr = "'" + NewStr;
            InString = NewInString;
          };
          res = res + NewStr;
          i += 1;
        };
        if (InString) res = res + "'";
      };
      this.OutStr(res);
    };
    this.OutLn = function (s) {
      this.OutStr(s + pas.System.LineEnding);
    };
    this.OutStr = function (s) {
      var I = 0;
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        I = $l;
        this.FOutput.WriteBufferData$4(s.charAt(I - 1));
      };
    };
    this.OutString = function (s) {
      this.Outchars(s);
    };
    this.ReadWord = function () {
      var Result = 0;
      this.FInput.ReadBufferData$10({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadDWord = function () {
      var Result = 0;
      this.FInput.ReadBufferData$14({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadDouble = function () {
      var Result = 0.0;
      this.FInput.ReadBufferData$20({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadInt = function (ValueType) {
      var Result = 0;
      var $tmp = ValueType;
      if ($tmp === $mod.TValueType.vaInt8) {
        Result = ((this.FInput.ReadByte() & 255) << 24) >> 24}
       else if ($tmp === $mod.TValueType.vaInt16) {
        Result = ((this.ReadWord() & 65535) << 16) >> 16}
       else if ($tmp === $mod.TValueType.vaInt32) {
        Result = this.ReadDWord() & 0xFFFFFFFF}
       else if ($tmp === $mod.TValueType.vaNativeInt) Result = this.ReadNativeInt();
      return Result;
    };
    this.ReadInt$1 = function () {
      var Result = 0;
      Result = this.ReadInt(this.FInput.ReadByte());
      return Result;
    };
    this.ReadNativeInt = function () {
      var Result = 0;
      this.FInput.ReadBufferData$16({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadStr = function () {
      var Result = "";
      var l = 0;
      var i = 0;
      var c = "\x00";
      this.FInput.ReadBufferData$6({get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }});
      Result = rtl.strSetLength(Result,l);
      for (var $l = 1, $end = l; $l <= $end; $l++) {
        i = $l;
        this.FInput.ReadBufferData$2({get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,c);
      };
      return Result;
    };
    this.ReadString = function (StringType) {
      var Result = "";
      var i = 0;
      var C = "\x00";
      Result = "";
      if (StringType !== $mod.TValueType.vaString) throw $mod.EFilerError.$create("Create$1",["Invalid string type passed to ReadString"]);
      i = this.ReadDWord();
      Result = rtl.strSetLength(Result,i);
      for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
        i = $l;
        this.FInput.ReadBufferData$2({get: function () {
            return C;
          }, set: function (v) {
            C = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,C);
      };
      return Result;
    };
    this.ProcessBinary = function () {
      var ToDo = 0;
      var DoNow = 0;
      var i = 0;
      var lbuf = [];
      var s = "";
      ToDo = this.ReadDWord();
      lbuf = rtl.arraySetLength(lbuf,0,32);
      this.OutLn("{");
      while (ToDo > 0) {
        DoNow = ToDo;
        if (DoNow > 32) DoNow = 32;
        ToDo -= DoNow;
        s = this.FIndent + "  ";
        this.FInput.ReadBuffer({get: function () {
            return lbuf;
          }, set: function (v) {
            lbuf = v;
          }},DoNow);
        for (var $l = 0, $end = DoNow - 1; $l <= $end; $l++) {
          i = $l;
          s = s + pas.SysUtils.IntToHex(lbuf[i],2);
        };
        this.OutLn(s);
      };
      this.OutLn(this.FIndent + "}");
    };
    this.ProcessValue = function (ValueType, Indent) {
      var s = "";
      var IsFirst = false;
      var ext = 0.0;
      var $tmp = ValueType;
      if ($tmp === $mod.TValueType.vaList) {
        this.OutStr("(");
        IsFirst = true;
        while (true) {
          ValueType = this.FInput.ReadByte();
          if (ValueType === $mod.TValueType.vaNull) break;
          if (IsFirst) {
            this.OutLn("");
            IsFirst = false;
          };
          this.OutStr(Indent + "  ");
          this.ProcessValue(ValueType,Indent + "  ");
        };
        this.OutLn(Indent + ")");
      } else if ($tmp === $mod.TValueType.vaInt8) {
        this.OutLn(pas.SysUtils.IntToStr(((this.FInput.ReadByte() & 255) << 24) >> 24))}
       else if ($tmp === $mod.TValueType.vaInt16) {
        this.OutLn(pas.SysUtils.IntToStr(((this.ReadWord() & 65535) << 16) >> 16))}
       else if ($tmp === $mod.TValueType.vaInt32) {
        this.OutLn(pas.SysUtils.IntToStr(this.ReadDWord() & 0xFFFFFFFF))}
       else if ($tmp === $mod.TValueType.vaNativeInt) {
        this.OutLn(pas.SysUtils.IntToStr(this.ReadNativeInt()))}
       else if ($tmp === $mod.TValueType.vaDouble) {
        ext = this.ReadDouble();
        s = rtl.floatToStr(ext);
        this.OutLn(s);
      } else if ($tmp === $mod.TValueType.vaString) {
        if (this.FPlainStrings) {
          this.OutStr("'" + pas.SysUtils.StringReplace(this.ReadString($mod.TValueType.vaString),"'","''",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)) + "'")}
         else this.OutString(this.ReadString($mod.TValueType.vaString));
        this.OutLn("");
      } else if ($tmp === $mod.TValueType.vaIdent) {
        this.OutLn(this.ReadStr())}
       else if ($tmp === $mod.TValueType.vaFalse) {
        this.OutLn("False")}
       else if ($tmp === $mod.TValueType.vaTrue) {
        this.OutLn("True")}
       else if ($tmp === $mod.TValueType.vaBinary) {
        this.ProcessBinary()}
       else if ($tmp === $mod.TValueType.vaSet) {
        this.OutStr("[");
        IsFirst = true;
        while (true) {
          s = this.ReadStr();
          if (s.length === 0) break;
          if (!IsFirst) this.OutStr(", ");
          IsFirst = false;
          this.OutStr(s);
        };
        this.OutLn("]");
      } else if ($tmp === $mod.TValueType.vaNil) {
        this.OutLn("nil")}
       else if ($tmp === $mod.TValueType.vaCollection) {
        this.OutStr("<");
        while (this.FInput.ReadByte() !== 0) {
          this.OutLn(Indent);
          this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
          this.OutStr(Indent + "  item");
          ValueType = this.FInput.ReadByte();
          if (ValueType !== $mod.TValueType.vaList) this.OutStr("[" + pas.SysUtils.IntToStr(this.ReadInt(ValueType)) + "]");
          this.OutLn("");
          this.ReadPropList(Indent + "    ");
          this.OutStr(Indent + "  end");
        };
        this.OutLn(">");
      } else {
        throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidPropertyType"),pas.System.VarRecs(0,ValueType)]);
      };
    };
    this.ReadObject = function (indent) {
      var b = 0;
      var ObjClassName = "";
      var ObjName = "";
      var ChildPos = 0;
      b = this.FInput.ReadByte();
      if ((b & 0xf0) === 0xf0) {
        if ((b & 2) !== 0) ChildPos = this.ReadInt$1();
      } else {
        b = 0;
        this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
      };
      ObjClassName = this.ReadStr();
      ObjName = this.ReadStr();
      this.OutStr(indent);
      if ((b & 1) !== 0) {
        this.OutStr("inherited")}
       else if ((b & 4) !== 0) {
        this.OutStr("inline")}
       else this.OutStr("object");
      this.OutStr(" ");
      if (ObjName !== "") this.OutStr(ObjName + ": ");
      this.OutStr(ObjClassName);
      if ((b & 2) !== 0) this.OutStr("[" + pas.SysUtils.IntToStr(ChildPos) + "]");
      this.OutLn("");
      this.ReadPropList(indent + "  ");
      while (this.FInput.ReadByte() !== 0) {
        this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
        this.ReadObject(indent + "  ");
      };
      this.OutLn(indent + "end");
    };
    this.ReadPropList = function (indent) {
      while (this.FInput.ReadByte() !== 0) {
        this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
        this.OutStr(indent + this.ReadStr() + " = ");
        this.ProcessValue(this.FInput.ReadByte(),indent);
      };
    };
    this.ObjectBinaryToText = function (aInput, aOutput) {
      this.ObjectBinaryToText$1(aInput,aOutput,$mod.TObjectTextEncoding.oteDFM);
    };
    this.ObjectBinaryToText$1 = function (aInput, aOutput, aEncoding) {
      this.FInput = aInput;
      this.FOutput = aOutput;
      this.FEncoding = aEncoding;
      this.Execute();
    };
    this.Execute = function () {
      var Signature = 0;
      if (this.FIndent === "") this.FIndent = "  ";
      if (!(this.FInput != null)) throw $mod.EReadError.$create("Create$1",["Missing input stream"]);
      if (!(this.FOutput != null)) throw $mod.EReadError.$create("Create$1",["Missing output stream"]);
      this.FInput.ReadBufferData$12({get: function () {
          return Signature;
        }, set: function (v) {
          Signature = v;
        }});
      if (Signature !== 809914452) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
      this.ReadObject("");
    };
  });
  rtl.createClass(this,"TObjectTextConverter",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FParser = null;
      this.FInput = null;
      this.Foutput = null;
    };
    this.$final = function () {
      this.FParser = undefined;
      this.FInput = undefined;
      this.Foutput = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.WriteDouble = function (e) {
      this.Foutput.WriteBufferData$20(e);
    };
    this.WriteDWord = function (lw) {
      this.Foutput.WriteBufferData$14(lw);
    };
    this.WriteInteger = function (value) {
      if ((value >= -128) && (value <= 127)) {
        this.Foutput.WriteByte($mod.TValueType.vaInt8);
        this.Foutput.WriteByte(value & 255);
      } else if ((value >= -32768) && (value <= 32767)) {
        this.Foutput.WriteByte($mod.TValueType.vaInt16);
        this.WriteWord(value & 65535);
      } else if ((value >= -2147483648) && (value <= 2147483647)) {
        this.Foutput.WriteByte($mod.TValueType.vaInt32);
        this.WriteDWord(value >>> 0);
      } else {
        this.Foutput.WriteByte($mod.TValueType.vaNativeInt);
        this.WriteQWord(value);
      };
    };
    this.WriteQWord = function (q) {
      this.Foutput.WriteBufferData$16(q);
    };
    this.WriteString = function (s) {
      var i = 0;
      var size = 0;
      if (s.length > 255) {
        size = 255}
       else size = s.length;
      this.Foutput.WriteByte(size);
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        this.Foutput.WriteBufferData$4(s.charAt(i - 1));
      };
    };
    this.WriteWord = function (w) {
      this.Foutput.WriteBufferData$12(w);
    };
    this.WriteWString = function (s) {
      var i = 0;
      this.WriteDWord(s.length);
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        this.Foutput.WriteBufferData$4(s.charAt(i - 1));
      };
    };
    this.ProcessObject = function () {
      var Flags = 0;
      var ObjectName = "";
      var ObjectType = "";
      var ChildPos = 0;
      if (this.FParser.TokenSymbolIs("OBJECT")) {
        Flags = 0}
       else {
        if (this.FParser.TokenSymbolIs("INHERITED")) {
          Flags = 1}
         else {
          this.FParser.CheckTokenSymbol("INLINE");
          Flags = 4;
        };
      };
      this.FParser.NextToken();
      this.FParser.CheckToken($mod.TParserToken.toSymbol);
      ObjectName = "";
      ObjectType = this.FParser.TokenString();
      this.FParser.NextToken();
      if (this.FParser.fToken === $mod.TParserToken.toColon) {
        this.FParser.NextToken();
        this.FParser.CheckToken($mod.TParserToken.toSymbol);
        ObjectName = ObjectType;
        ObjectType = this.FParser.TokenString();
        this.FParser.NextToken();
        if (this.FParser.fToken === $mod.TParserToken.toSetStart) {
          this.FParser.NextToken();
          ChildPos = this.FParser.TokenInt();
          this.FParser.NextToken();
          this.FParser.CheckToken($mod.TParserToken.toSetEnd);
          this.FParser.NextToken();
          Flags = Flags | 2;
        };
      };
      if (Flags !== 0) {
        this.Foutput.WriteByte(0xf0 | Flags);
        if ((Flags & 2) !== 0) this.WriteInteger(ChildPos);
      };
      this.WriteString(ObjectType);
      this.WriteString(ObjectName);
      while (!(this.FParser.TokenSymbolIs("END") || this.FParser.TokenSymbolIs("OBJECT") || this.FParser.TokenSymbolIs("INHERITED") || this.FParser.TokenSymbolIs("INLINE"))) this.ProcessProperty();
      this.Foutput.WriteByte(0);
      while (!this.FParser.TokenSymbolIs("END")) this.ProcessObject();
      this.FParser.NextToken();
      this.Foutput.WriteByte(0);
    };
    this.ProcessProperty = function () {
      var name = "";
      this.FParser.CheckToken($mod.TParserToken.toSymbol);
      name = this.FParser.TokenString();
      while (true) {
        this.FParser.NextToken();
        if (this.FParser.fToken !== $mod.TParserToken.toDot) break;
        this.FParser.NextToken();
        this.FParser.CheckToken($mod.TParserToken.toSymbol);
        name = name + "." + this.FParser.TokenString();
      };
      this.WriteString(name);
      this.FParser.CheckToken($mod.TParserToken.toEqual);
      this.FParser.NextToken();
      this.ProcessValue();
    };
    this.ProcessValue = function () {
      var flt = 0.0;
      var stream = null;
      var $tmp = this.FParser.fToken;
      if ($tmp === $mod.TParserToken.toInteger) {
        this.WriteInteger(this.FParser.TokenInt());
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toFloat) {
        this.Foutput.WriteByte($mod.TValueType.vaDouble);
        flt = this.FParser.TokenFloat();
        this.WriteDouble(flt);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.ToString) {
        this.ProcessWideString("")}
       else if ($tmp === $mod.TParserToken.toSymbol) {
        if (pas.SysUtils.CompareText(this.FParser.TokenString(),"True") === 0) {
          this.Foutput.WriteByte($mod.TValueType.vaTrue)}
         else if (pas.SysUtils.CompareText(this.FParser.TokenString(),"False") === 0) {
          this.Foutput.WriteByte($mod.TValueType.vaFalse)}
         else if (pas.SysUtils.CompareText(this.FParser.TokenString(),"nil") === 0) {
          this.Foutput.WriteByte($mod.TValueType.vaNil)}
         else {
          this.Foutput.WriteByte($mod.TValueType.vaIdent);
          this.WriteString(this.FParser.TokenComponentIdent());
        };
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toSetStart) {
        this.FParser.NextToken();
        this.Foutput.WriteByte($mod.TValueType.vaSet);
        if (this.FParser.fToken !== $mod.TParserToken.toSetEnd) while (true) {
          this.FParser.CheckToken($mod.TParserToken.toSymbol);
          this.WriteString(this.FParser.TokenString());
          this.FParser.NextToken();
          if (this.FParser.fToken === $mod.TParserToken.toSetEnd) break;
          this.FParser.CheckToken($mod.TParserToken.toComma);
          this.FParser.NextToken();
        };
        this.Foutput.WriteByte(0);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toListStart) {
        this.FParser.NextToken();
        this.Foutput.WriteByte($mod.TValueType.vaList);
        while (this.FParser.fToken !== $mod.TParserToken.toListEnd) this.ProcessValue();
        this.Foutput.WriteByte(0);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toCollectionStart) {
        this.FParser.NextToken();
        this.Foutput.WriteByte($mod.TValueType.vaCollection);
        while (this.FParser.fToken !== $mod.TParserToken.toCollectionEnd) {
          this.FParser.CheckTokenSymbol("item");
          this.FParser.NextToken();
          this.Foutput.WriteByte($mod.TValueType.vaList);
          while (!this.FParser.TokenSymbolIs("end")) this.ProcessProperty();
          this.FParser.NextToken();
          this.Foutput.WriteByte(0);
        };
        this.Foutput.WriteByte(0);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toBinaryStart) {
        this.Foutput.WriteByte($mod.TValueType.vaBinary);
        stream = $mod.TBytesStream.$create("Create");
        try {
          this.FParser.HexToBinary(stream);
          this.WriteDWord(stream.GetSize());
          this.Foutput.WriteBuffer(stream.GetBytes(),stream.GetSize());
        } finally {
          stream = rtl.freeLoc(stream);
        };
        this.FParser.NextToken();
      } else {
        this.FParser.Error(rtl.getResStr(pas.RTLConsts,"SParserInvalidProperty"));
      };
    };
    this.ProcessWideString = function (left) {
      var ws = "";
      ws = left + this.FParser.TokenString();
      while (this.FParser.NextToken() === $mod.TParserToken.toPlus) {
        this.FParser.NextToken();
        if (!(this.FParser.fToken === $mod.TParserToken.ToString)) this.FParser.CheckToken($mod.TParserToken.ToString);
        ws = ws + this.FParser.TokenString();
      };
      this.Foutput.WriteByte($mod.TValueType.vaString);
      this.WriteWString(ws);
    };
    this.ObjectTextToBinary = function (aInput, aOutput) {
      this.FInput = aInput;
      this.Foutput = aOutput;
      this.Execute();
    };
    this.Execute = function () {
      if (!(this.FInput != null)) throw $mod.EReadError.$create("Create$1",["Missing input stream"]);
      if (!(this.Foutput != null)) throw $mod.EReadError.$create("Create$1",["Missing output stream"]);
      this.FParser = $mod.TParser.$create("Create$1",[this.FInput]);
      try {
        this.Foutput.WriteBufferData$14(809914452);
        this.ProcessObject();
      } finally {
        rtl.free(this,"FParser");
      };
    };
  });
  rtl.createClass(this,"TLoadHelper",pas.System.TObject,function () {
    $mod.$rtti.$RefToProcVar("TLoadHelper.TTextLoadedCallBack",{procsig: rtl.newTIProcSig([["aText",rtl.string,2]])});
    $mod.$rtti.$RefToProcVar("TLoadHelper.TBytesLoadedCallBack",{procsig: rtl.newTIProcSig([["aBuffer",pas.JS.$rtti["TJSArrayBuffer"],2]])});
    $mod.$rtti.$RefToProcVar("TLoadHelper.TErrorCallBack",{procsig: rtl.newTIProcSig([["aError",rtl.string,2]])});
  });
  this.$rtti.$ClassRef("TLoadHelperClass",{instancetype: this.$rtti["TLoadHelper"]});
  rtl.createClass(this,"TDataModule",this.TComponent,function () {
    this.$init = function () {
      $mod.TComponent.$init.call(this);
      this.FDPos = pas.Types.TPoint.$new();
      this.FDSize = pas.Types.TPoint.$new();
      this.FDPPI = 0;
      this.FOnCreate = null;
      this.FOnDestroy = null;
      this.FOldOrder = false;
    };
    this.$final = function () {
      this.FDPos = undefined;
      this.FDSize = undefined;
      this.FOnCreate = undefined;
      this.FOnDestroy = undefined;
      $mod.TComponent.$final.call(this);
    };
    this.ReadP = function (Reader) {
      this.FDPPI = Reader.ReadInteger();
    };
    this.WriteP = function (Writer) {
      Writer.WriteInteger(this.FDPPI);
    };
    this.ReadT = function (Reader) {
      this.FDPos.y = Reader.ReadInteger();
    };
    this.WriteT = function (Writer) {
      Writer.WriteInteger(this.FDPos.y);
    };
    this.ReadL = function (Reader) {
      this.FDPos.x = Reader.ReadInteger();
    };
    this.WriteL = function (Writer) {
      Writer.WriteInteger(this.FDPos.x);
    };
    this.ReadW = function (Reader) {
      this.FDSize.x = Reader.ReadInteger();
    };
    this.WriteW = function (Writer) {
      Writer.WriteInteger(this.FDSize.x);
    };
    this.ReadH = function (Reader) {
      this.FDSize.y = Reader.ReadInteger();
    };
    this.WriteH = function (Writer) {
      Writer.WriteInteger(this.FDSize.y);
    };
    this.DoCreate = function () {
      if (this.FOnCreate != null) try {
        this.FOnCreate(this);
      } catch ($e) {
        if (!this.HandleCreateException()) throw $e;
      };
    };
    this.DoDestroy = function () {
      if (this.FOnDestroy != null) try {
        this.FOnDestroy(this);
      } catch ($e) {
        if ($mod.ApplicationHandleException != null) $mod.ApplicationHandleException(this);
      };
    };
    this.DefineProperties = function (Filer) {
      var Ancestor = null;
      var HaveData = false;
      var HavePPIData = false;
      $mod.TComponent.DefineProperties.call(this,Filer);
      Ancestor = Filer.FAncestor;
      HaveData = (Ancestor === null) || (this.FDSize.x !== Ancestor.FDSize.x) || (this.FDSize.y !== Ancestor.FDSize.y) || (this.FDPos.y !== Ancestor.FDPos.y) || (this.FDPos.x !== Ancestor.FDPos.x);
      HavePPIData = ((Ancestor != null) && (this.FDPPI !== Ancestor.FDPPI)) || (!(Ancestor != null) && (this.FDPPI !== 96));
      Filer.DefineProperty("Height",rtl.createCallback(this,"ReadH"),rtl.createCallback(this,"WriteH"),HaveData);
      Filer.DefineProperty("HorizontalOffset",rtl.createCallback(this,"ReadL"),rtl.createCallback(this,"WriteL"),HaveData);
      Filer.DefineProperty("VerticalOffset",rtl.createCallback(this,"ReadT"),rtl.createCallback(this,"WriteT"),HaveData);
      Filer.DefineProperty("Width",rtl.createCallback(this,"ReadW"),rtl.createCallback(this,"WriteW"),HaveData);
      Filer.DefineProperty("PPI",rtl.createCallback(this,"ReadP"),rtl.createCallback(this,"WriteP"),HavePPIData);
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      $mod.TComponent.GetChildren.call(this,Proc,Root);
      if (Root === this) for (var $l = 0, $end = this.GetComponentCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (!this.GetComponent(I).HasParent()) Proc(this.GetComponent(I));
      };
    };
    this.HandleCreateException = function () {
      var Result = false;
      Result = $mod.ApplicationHandleException != null;
      if (Result) $mod.ApplicationHandleException(this);
      return Result;
    };
    this.ReadState = function (Reader) {
      this.FOldOrder = false;
      $mod.TComponent.ReadState.call(this,Reader);
    };
    this.Create$1 = function (AOwner) {
      this.CreateNew(AOwner);
      if ((this.$class.ClassType() !== $mod.TDataModule) && !($mod.TComponentStateItem.csDesigning in this.FComponentState)) {
        if (!$mod.InitInheritedComponent(this,$mod.TDataModule)) throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrNoStreaming"),pas.System.VarRecs(18,this.$classname)]);
        if (this.FOldOrder) this.DoCreate();
      };
      return this;
    };
    this.CreateNew = function (AOwner) {
      this.CreateNew$1(AOwner,0);
      return this;
    };
    this.CreateNew$1 = function (AOwner, CreateMode) {
      $mod.TComponent.Create$1.call(this,AOwner);
      this.FDPPI = 96;
      if (($mod.AddDataModule != null) && (CreateMode >= 0)) $mod.AddDataModule(this);
      return this;
    };
    this.Destroy = function () {
      if (this.FOldOrder) this.DoDestroy();
      if ($mod.RemoveDataModule != null) $mod.RemoveDataModule(this);
      $mod.TComponent.Destroy.call(this);
    };
    this.AfterConstruction = function () {
      if (!this.FOldOrder) this.DoCreate();
    };
    this.BeforeDestruction = function () {
      this.Destroying();
      $mod.RemoveFixupReferences(this,"");
      if (!this.FOldOrder) this.DoDestroy();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnCreate",0,$mod.$rtti["TNotifyEvent"],"FOnCreate","FOnCreate");
    $r.addProperty("OnDestroy",0,$mod.$rtti["TNotifyEvent"],"FOnDestroy","FOnDestroy");
    $r.addProperty("OldCreateOrder",0,rtl.boolean,"FOldOrder","FOldOrder");
  });
  this.$rtti.$ClassRef("TDataModuleClass",{instancetype: this.$rtti["TDataModule"]});
  rtl.recNewT(this,"TIdentMapEntry",function () {
    this.Value = 0;
    this.Name = "";
    this.$eq = function (b) {
      return (this.Value === b.Value) && (this.Name === b.Name);
    };
    this.$assign = function (s) {
      this.Value = s.Value;
      this.Name = s.Name;
      return this;
    };
    var $r = $mod.$rtti.$Record("TIdentMapEntry",{},this);
    $r.addField("Value",rtl.longint);
    $r.addField("Name",rtl.string);
  });
  this.$rtti.$ProcVar("TIdentToInt",{procsig: rtl.newTIProcSig([["Ident",rtl.string,2],["Int",rtl.longint,1]],rtl.boolean)});
  this.$rtti.$ProcVar("TIntToIdent",{procsig: rtl.newTIProcSig([["Int",rtl.longint],["Ident",rtl.string,1]],rtl.boolean)});
  this.$rtti.$ProcVar("TFindGlobalComponent",{procsig: rtl.newTIProcSig([["Name",rtl.string,2]],this.$rtti["TComponent"])});
  this.$rtti.$ProcVar("TInitComponentHandler",{procsig: rtl.newTIProcSig([["Instance",this.$rtti["TComponent"]],["RootAncestor",pas.System.$rtti["TClass"]]],rtl.boolean)});
  rtl.createHelper(this,"TStringsHelper",null,function () {
    this.LoadFromStream = function (Stream) {
      $mod.TStringsHelper.LoadFromStream$1.call(this,Stream,pas.SysUtils.TEncoding.GetUTF8());
    };
    this.LoadFromStream$1 = function (Stream, Encoding) {
      var arr = null;
      var s = "";
      var buf = [];
      Stream.Read({get: function () {
          return buf;
        }, set: function (v) {
          buf = v;
        }},Stream.GetSize());
      arr = $mod.TMemoryStream.BytesToMemory(rtl.arrayRef(buf));
      if ((Encoding != null) && (Encoding !== Encoding.$class.GetUTF8())) {
        s = Encoding.GetEncoding();
        var enc = new TextDecoder(s);
        s = enc.decode(arr);
      } else {
        s =  String.fromCharCode.apply(null, new Uint16Array(arr));
      };
      this.SetTextStr(s);
    };
    this.SaveToStream = function (Stream) {
      $mod.TStringsHelper.SaveToStream$1.call(this,Stream,pas.SysUtils.TEncoding.GetUTF8());
    };
    this.SaveToStream$1 = function (Stream, Encoding) {
      var s = "";
      var txt = "";
      var arr = null;
      var b = [];
      var l = 0;
      s = "utf-8";
      if (Encoding != null) {
        s = Encoding.GetEncoding();
      };
      txt = this.GetTextStr();
      var enc = new TextEncoder(s);
      arr = enc.encode(txt);
      b = $mod.TMemoryStream.MemoryToBytes(arr);
      l = arr.byteLength;
      Stream.Write(b,l);
      Stream.SetPosition(0);
    };
    this.IndexOfValue = function (Value) {
      var Result = 0;
      var len = 0;
      var S = "";
      this.CheckSpecialChars();
      Result = 0;
      while (Result < this.GetCount()) {
        S = this.Get(Result);
        len = pas.System.Pos(this.FNameValueSeparator,S) + 1;
        if ((len >= 0) && (this.DoCompareText(Value,pas.System.Copy(S,len,S.length)) === 0)) return Result;
        Result += 1;
      };
      Result = -1;
      return Result;
    };
  });
  this.TMSPlatformsWeb = 1;
  rtl.createClass(this,"ComponentPlatformsAttribute",pas.System.TCustomAttribute,function () {
    this.$init = function () {
      pas.System.TCustomAttribute.$init.call(this);
      this.FPlatforms = 0;
    };
    this.Create$1 = function (Platforms) {
      this.FPlatforms = Platforms;
      return this;
    };
  });
  this.TShiftState$a = {"0": "ssShift", ssShift: 0, "1": "ssAlt", ssAlt: 1, "2": "ssCtrl", ssCtrl: 2, "3": "ssLeft", ssLeft: 3, "4": "ssRight", ssRight: 4, "5": "ssMIDdle", ssMIDdle: 5, "6": "ssDouble", ssDouble: 6, "7": "ssTouch", ssTouch: 7, "8": "ssPen", ssPen: 8, "9": "ssCommand", ssCommand: 9};
  this.$rtti.$Enum("TShiftState$a",{minvalue: 0, maxvalue: 9, ordtype: 1, enumtype: this.TShiftState$a});
  this.$rtti.$Set("TShiftState",{comptype: this.$rtti["TShiftState$a"]});
  this.RegisterInitComponentHandler = function (ComponentClass, Handler) {
    var I = 0;
    var H = null;
    if ($impl.InitHandlerList === null) $impl.InitHandlerList = $mod.TList.$create("Create$1");
    H = $impl.TInitHandler.$create("Create");
    H.AClass = ComponentClass;
    H.AHandler = Handler;
    try {
      var $with = $impl.InitHandlerList;
      I = 0;
      while ((I < $with.GetCount()) && !H.AClass.InheritsFrom(rtl.getObject($with.Get(I)).AClass)) I += 1;
      if ((I < $with.GetCount()) && (rtl.getObject($with.Get(I)).AClass === H.AClass)) {
        rtl.getObject($with.Get(I)).AHandler = Handler;
        H = rtl.freeLoc(H);
      } else $impl.InitHandlerList.Insert(I,H);
    } catch ($e) {
      H = rtl.freeLoc(H);
      throw $e;
    };
  };
  this.RegisterClass = function (AClass) {
    $impl.ClassList[AClass.$classname] = AClass;
  };
  this.RegisterClasses = function (AClasses) {
    var AClass = null;
    for (var $in = AClasses, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
      AClass = $in[$l];
      $mod.RegisterClass(AClass);
    };
  };
  this.GetClass = function (AClassName) {
    var Result = null;
    Result = null;
    if (AClassName === "") return Result;
    if (!$impl.ClassList.hasOwnProperty(AClassName)) return Result;
    Result = rtl.getObject($impl.ClassList[AClassName]);
    return Result;
  };
  this.RegisterFindGlobalComponentProc = function (AFindGlobalComponent) {
    if (!($impl.FindGlobalComponentList != null)) $impl.FindGlobalComponentList = $mod.TFPList.$create("Create");
    if ($impl.FindGlobalComponentList.IndexOf(AFindGlobalComponent) < 0) $impl.FindGlobalComponentList.Add(AFindGlobalComponent);
  };
  this.UnregisterFindGlobalComponentProc = function (AFindGlobalComponent) {
    if ($impl.FindGlobalComponentList != null) $impl.FindGlobalComponentList.Remove(AFindGlobalComponent);
  };
  this.FindGlobalComponent = function (Name) {
    var Result = null;
    var i = 0;
    Result = null;
    if ($impl.FindGlobalComponentList != null) {
      for (var $l = $impl.FindGlobalComponentList.FCount - 1; $l >= 0; $l--) {
        i = $l;
        Result = $impl.FindGlobalComponentList.Get(i)(Name);
        if (Result != null) break;
      };
    };
    return Result;
  };
  this.FindNestedComponent = function (Root, APath, CStyle) {
    var Result = null;
    function GetNextName() {
      var Result = "";
      var P = 0;
      var CM = false;
      P = pas.System.Pos(".",APath);
      CM = false;
      if (P === 0) {
        if (CStyle) {
          P = pas.System.Pos("->",APath);
          CM = P !== 0;
        };
        if (P === 0) P = APath.length + 1;
      };
      Result = pas.System.Copy(APath,1,P - 1);
      pas.System.Delete({get: function () {
          return APath;
        }, set: function (v) {
          APath = v;
        }},1,P + (CM + 0));
      return Result;
    };
    var C = null;
    var S = "";
    if (APath === "") {
      Result = null}
     else {
      Result = Root;
      while ((APath !== "") && (Result !== null)) {
        C = Result;
        S = pas.SysUtils.UpperCase(GetNextName());
        Result = C.FindComponent(S);
        if ((Result === null) && (S === "OWNER")) Result = C;
      };
    };
    return Result;
  };
  this.InitInheritedComponent = function (Instance, RootAncestor) {
    var Result = false;
    var I = 0;
    I = 0;
    if (!($impl.InitHandlerList != null)) {
      Result = true;
      return Result;
    };
    Result = false;
    var $with = $impl.InitHandlerList;
    I = 0;
    while (!Result && (I < $with.GetCount())) {
      if (Instance.$class.InheritsFrom(rtl.getObject($with.Get(I)).AClass)) Result = rtl.getObject($with.Get(I)).AHandler(Instance,RootAncestor);
      I += 1;
    };
    return Result;
  };
  this.RedirectFixupReferences = function (Root, OldRootName, NewRootName) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TRedirectReferenceVisitor.$create("Create$1",[Root,OldRootName,NewRootName]));
  };
  this.RemoveFixupReferences = function (Root, RootName) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TRemoveReferenceVisitor.$create("Create$1",[Root,RootName]));
  };
  this.RegisterIntegerConsts = function (IntegerType, IdentToIntFn, IntToIdentFn) {
    if (!($impl.IntConstList != null)) $impl.IntConstList = $mod.TFPList.$create("Create");
    $impl.IntConstList.Add($impl.TIntConst.$create("Create$1",[IntegerType,IdentToIntFn,IntToIdentFn]));
  };
  this.ExtractStrings = function (Separators, WhiteSpace, Content, Strings, AddEmptyStrings) {
    var Result = 0;
    var b = 0;
    var c = 0;
    function SkipWhitespace() {
      while (Content.charCodeAt(c - 1) in WhiteSpace) c += 1;
    };
    function AddString() {
      var l = 0;
      l = c - b;
      if ((l > 0) || AddEmptyStrings) {
        if (Strings != null) {
          if (l > 0) {
            Strings.Add(pas.System.Copy(Content,b,l))}
           else Strings.Add("");
        };
        Result += 1;
      };
    };
    var cc = "\x00";
    var quoted = "\x00";
    var aLen = 0;
    Result = 0;
    c = 1;
    quoted = "\x00";
    Separators = rtl.diffSet(rtl.unionSet(Separators,rtl.createSet(13,10)),rtl.createSet(39,34));
    SkipWhitespace();
    b = c;
    aLen = Content.length;
    while (c <= aLen) {
      cc = Content.charAt(c - 1);
      if (cc === quoted) {
        if ((c < aLen) && (Content.charAt((c + 1) - 1) === quoted)) {
          c += 1}
         else quoted = "\x00";
      } else if ((quoted === "\x00") && (cc.charCodeAt() in rtl.createSet(39,34))) quoted = cc;
      if ((quoted === "\x00") && (cc.charCodeAt() in Separators)) {
        AddString();
        c += 1;
        SkipWhitespace();
        b = c;
      } else c += 1;
    };
    if (c !== b) AddString();
    return Result;
  };
  this.IdentToInt = function (Ident, Int, map) {
    var Result = false;
    var i = 0;
    for (var $l = 0, $end = rtl.length(map) - 1; $l <= $end; $l++) {
      i = $l;
      if (pas.SysUtils.CompareText(map[i].Name,Ident) === 0) {
        Int.set(map[i].Value);
        return true;
      };
    };
    Result = false;
    return Result;
  };
  this.IntToIdent = function (Int, Ident, map) {
    var Result = false;
    var i = 0;
    for (var $l = 0, $end = rtl.length(map) - 1; $l <= $end; $l++) {
      i = $l;
      if (map[i].Value === Int) {
        Ident.set(map[i].Name);
        return true;
      };
    };
    Result = false;
    return Result;
  };
  this.FindIntToIdent = function (AIntegerType) {
    var Result = null;
    var i = 0;
    Result = null;
    if (!($impl.IntConstList != null)) return Result;
    var $with = $impl.IntConstList;
    for (var $l = 0, $end = $with.FCount - 1; $l <= $end; $l++) {
      i = $l;
      if (rtl.getObject($with.Get(i)).IntegerType === AIntegerType) return rtl.getObject($with.Get(i)).IntToIdentFn;
    };
    return Result;
  };
  this.FindIdentToInt = function (AIntegerType) {
    var Result = null;
    var i = 0;
    Result = null;
    if (!($impl.IntConstList != null)) return Result;
    var $with = $impl.IntConstList;
    for (var $l = 0, $end = $with.FCount - 1; $l <= $end; $l++) {
      i = $l;
      var $with1 = rtl.getObject($with.Get(i));
      if (rtl.getObject($with.Get(i)).IntegerType === AIntegerType) return $with1.IdentToIntFn;
    };
    return Result;
  };
  this.FindClass = function (AClassName) {
    var Result = null;
    Result = $mod.GetClass(AClassName);
    if (!(Result != null)) throw $mod.EClassNotFound.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SClassNotFound"),pas.System.VarRecs(18,AClassName)]);
    return Result;
  };
  this.CollectionsEqual = function (C1, C2) {
    var Result = false;
    var Comp1 = null;
    var Comp2 = null;
    Comp2 = null;
    Comp1 = $mod.TComponent.$create("Create");
    try {
      Result = $mod.CollectionsEqual$1(C1,C2,Comp1,Comp2);
    } finally {
      Comp1 = rtl.freeLoc(Comp1);
      Comp2 = rtl.freeLoc(Comp2);
    };
    return Result;
  };
  this.CollectionsEqual$1 = function (C1, C2, Owner1, Owner2) {
    var Result = false;
    function stream_collection(s, c, o) {
      var w = null;
      w = $mod.TWriter.$create("Create$2",[s]);
      try {
        w.SetRoot(o);
        w.FLookupRoot = o;
        w.WriteCollection(c);
      } finally {
        w = rtl.freeLoc(w);
      };
    };
    var s1 = null;
    var s2 = null;
    var b1 = [];
    var b2 = [];
    var I = 0;
    var Len = 0;
    Result = false;
    if ((C1.$class.ClassType() !== C2.$class.ClassType()) || (C1.GetCount() !== C2.GetCount())) return Result;
    if (C1.GetCount() === 0) {
      Result = true;
      return Result;
    };
    s2 = null;
    s1 = $mod.TBytesStream.$create("Create");
    try {
      s2 = $mod.TBytesStream.$create("Create");
      stream_collection(s1,C1,Owner1);
      stream_collection(s2,C2,Owner2);
      Result = s1.GetSize() === s2.GetSize();
      if (Result) {
        b1 = s1.GetBytes();
        b2 = s2.GetBytes();
        I = 0;
        Len = s1.GetSize();
        while (Result && (I < Len)) {
          Result = b1[I] === b2[I];
          I += 1;
        };
      };
    } finally {
      s2 = rtl.freeLoc(s2);
      s1 = rtl.freeLoc(s1);
    };
    return Result;
  };
  this.GetFixupReferenceNames = function (Root, Names) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TReferenceNamesVisitor.$create("Create$1",[Root,Names]));
  };
  this.GetFixupInstanceNames = function (Root, ReferenceRootName, Names) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TReferenceInstancesVisitor.$create("Create$1",[Root,ReferenceRootName,Names]));
  };
  this.ObjectBinaryToText = function (aInput, aOutput) {
    $mod.ObjectBinaryToText$1(aInput,aOutput,$mod.TObjectTextEncoding.oteLFM);
  };
  this.ObjectBinaryToText$1 = function (aInput, aOutput, aEncoding) {
    var Conv = null;
    Conv = $mod.TObjectStreamConverter.$create("Create");
    try {
      Conv.ObjectBinaryToText$1(aInput,aOutput,aEncoding);
    } finally {
      Conv = rtl.freeLoc(Conv);
    };
  };
  this.ObjectTextToBinary = function (aInput, aOutput) {
    var Conv = null;
    Conv = $mod.TObjectTextConverter.$create("Create");
    try {
      Conv.ObjectTextToBinary(aInput,aOutput);
    } finally {
      Conv = rtl.freeLoc(Conv);
    };
  };
  this.SetLoadHelperClass = function (aClass) {
    var Result = null;
    Result = $impl.GlobalLoadHelper;
    $impl.GlobalLoadHelper = aClass;
    return Result;
  };
  this.StringToBuffer = function (aString, aLen) {
    var Result = null;
    Result = $mod.StringToBuffer$1(aString,aLen,pas.SysUtils.TEncoding.GetUTF8());
    return Result;
  };
  this.StringToBuffer$1 = function (aString, aLen, AEncoding) {
    var Result = null;
    var I = 0;
    if (AEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
      Result = new ArrayBuffer(aLen * 2);
      var $with = new Uint16Array(Result);
      for (var $l = 0, $end = aLen - 1; $l <= $end; $l++) {
        I = $l;
        $with[I] = aString.charCodeAt(I);
      };
    } else {
      Result = new ArrayBuffer(aLen);
      var $with1 = new Uint8Array(Result);
      for (var $l1 = 0, $end1 = aLen - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        $with1[I] = aString.charCodeAt(I);
      };
    };
    return Result;
  };
  this.BufferToString = function (aBuffer, aPos, aLen) {
    var Result = "";
    Result = $mod.BufferToString$1(aBuffer,aPos,aLen,pas.SysUtils.TEncoding.GetUTF8());
    return Result;
  };
  this.BufferToString$1 = function (aBuffer, aPos, aLen, AEncoding) {
    var Result = "";
    var ua16 = null;
    var ua8 = null;
    Result = "";
    if (AEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
      ua16 = new Uint16Array(aBuffer.slice(aPos,aLen));
      if (ua16 !== null) Result = "" + String.fromCharCode.apply(null,ua16);
    } else {
      ua8 = new Uint8Array(aBuffer.slice(aPos,aLen));
      if (ua8 !== null) Result = "" + String.fromCharCode.apply(null,ua8);
    };
    return Result;
  };
  this.BeginGlobalLoading = function () {
    $impl.GlobalLoaded = $mod.TFPList.$create("Create");
  };
  this.NotifyGlobalLoading = function () {
    var I = 0;
    var G = null;
    G = $impl.GlobalLoaded;
    for (var $l = 0, $end = G.FCount - 1; $l <= $end; $l++) {
      I = $l;
      rtl.getObject(G.Get(I)).Loaded();
    };
  };
  this.EndGlobalLoading = function () {
    rtl.free($impl,"GlobalLoaded");
  };
  this.$rtti.$MethodVar("TDataModuleNotifyEvent",{procsig: rtl.newTIProcSig([["DataModule",this.$rtti["TDataModule"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TExceptionNotifyEvent",{procsig: rtl.newTIProcSig([["E",pas.SysUtils.$rtti["Exception"]]]), methodkind: 0});
  this.AddDataModule = null;
  this.RemoveDataModule = null;
  this.ApplicationHandleException = null;
  this.ApplicationShowException = null;
  this.FormResourceIsText = true;
  this.vaSingle = this.TValueType.vaDouble;
  this.vaExtended = this.TValueType.vaDouble;
  this.vaLString = this.TValueType.vaString;
  this.vaUTF8String = this.TValueType.vaString;
  this.vaUString = this.TValueType.vaString;
  this.vaWString = this.TValueType.vaString;
  this.vaQWord = this.TValueType.vaNativeInt;
  this.vaInt64 = this.TValueType.vaNativeInt;
  this.toWString = this.TParserToken.ToString;
  $mod.$implcode = function () {
    $mod.$rtti.$RefToProcVar("TReqLoadProc",{procsig: rtl.newTIProcSig([["AResponse",rtl.string]])});
    $mod.$rtti.$RefToProcVar("TReqErrorProc",{procsig: rtl.newTIProcSig([])});
    $impl.GlobalLoaded = null;
    $impl.IntConstList = null;
    $impl.GlobalLoadHelper = null;
    $impl.CheckLoadHelper = function () {
      if ($impl.GlobalLoadHelper === null) throw pas.SysUtils.EInOutError.$create("Create$1",["No support for loading URLS. Include Rtl.BrowserLoadHelper in your project uses clause"]);
    };
    $impl.CreateComponentfromRes = function (res, Inst, Component) {
      var Result = false;
      var ResStream = null;
      var Src = null;
      var aInfo = pas.p2jsres.TResourceInfo.$new();
      if (Inst === 0) ;
      Result = pas.p2jsres.GetResourceInfo(res,aInfo);
      if (Result) {
        ResStream = $mod.TResourceStream.$create("Create$1",[pas.p2jsres.TResourceInfo.$clone(aInfo)]);
        try {
          if (!$mod.FormResourceIsText) {
            Src = ResStream}
           else {
            Src = $mod.TMemoryStream.$create("Create");
            $mod.ObjectTextToBinary(ResStream,Src);
            Src.SetPosition(0);
          };
          Component.set(Src.ReadComponent(Component.get()));
        } finally {
          if (Src !== ResStream) Src = rtl.freeLoc(Src);
          ResStream = rtl.freeLoc(ResStream);
        };
      };
      return Result;
    };
    $impl.DefaultInitHandler = function (Instance, RootAncestor) {
      var Result = false;
      function doinit(_class) {
        var Result = false;
        Result = false;
        if ((_class.ClassType() === $mod.TComponent) || (_class.ClassType() === RootAncestor)) return Result;
        Result = doinit(_class.$ancestor);
        Result = $impl.CreateComponentfromRes(_class.$module.$name,0,{get: function () {
            return Instance;
          }, set: function (v) {
            Instance = v;
          }}) || Result;
        return Result;
      };
      Result = doinit(Instance.$class.ClassType());
      return Result;
    };
    rtl.createClass($impl,"TIntConst",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.IntegerType = null;
        this.IdentToIntFn = null;
        this.IntToIdentFn = null;
      };
      this.$final = function () {
        this.IdentToIntFn = undefined;
        this.IntToIdentFn = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function (AIntegerType, AIdentToInt, AIntToIdent) {
        this.IntegerType = AIntegerType;
        this.IdentToIntFn = AIdentToInt;
        this.IntToIdentFn = AIntToIdent;
        return this;
      };
    });
    $impl.GlobalIdentToInt = function (Ident, Int) {
      var Result = false;
      var i = 0;
      Result = false;
      if (!($impl.IntConstList != null)) return Result;
      var $with = $impl.IntConstList;
      for (var $l = 0, $end = $with.FCount - 1; $l <= $end; $l++) {
        i = $l;
        if (rtl.getObject($with.Get(i)).IdentToIntFn(Ident,Int)) return true;
      };
      return Result;
    };
    $impl.QuickSort = function (aList, L, R, Compare) {
      var I = 0;
      var J = 0;
      var PivotIdx = 0;
      var P = undefined;
      var Q = undefined;
      do {
        I = L;
        J = R;
        PivotIdx = L + ((R - L) >>> 1);
        P = aList[PivotIdx];
        do {
          while ((I < PivotIdx) && (Compare(P,aList[I]) > 0)) I += 1;
          while ((J > PivotIdx) && (Compare(P,aList[J]) < 0)) J -= 1;
          if (I < J) {
            Q = aList[I];
            aList[I] = aList[J];
            aList[J] = Q;
            if (PivotIdx === I) {
              PivotIdx = J;
              I += 1;
            } else if (PivotIdx === J) {
              PivotIdx = I;
              J -= 1;
            } else {
              I += 1;
              J -= 1;
            };
          };
        } while (!(I >= J));
        if ((PivotIdx - L) < (R - PivotIdx)) {
          if ((L + 1) < PivotIdx) $impl.QuickSort(rtl.arrayRef(aList),L,PivotIdx - 1,Compare);
          L = PivotIdx + 1;
        } else {
          if ((PivotIdx + 1) < R) $impl.QuickSort(rtl.arrayRef(aList),PivotIdx + 1,R,Compare);
          if ((L + 1) < PivotIdx) {
            R = PivotIdx - 1}
           else return;
        };
      } while (!(L >= R));
    };
    $impl.URLToArrayOfString = function (URL) {
      var Result = [];
      var a = [];
      var cors_api_url = "";
      cors_api_url = "";
      var xhr = new XMLHttpRequest();
          xhr.open("GET", cors_api_url + URL, false);
          xhr.send();
      
          if (xhr.status==200)
          {
            var obj = xhr.responseText.split(/\r\n|\n/);
            for (var i = 0; i < obj.length; i++) {
              a.push(obj[i]);
            }
          };
      Result = rtl.arrayRef(a);
      return Result;
    };
    $impl.ReqAsync = function (AURL, LoadProc, ErrorProc) {
      var req = null;
      function HandleResponse(Event) {
        var Result = false;
        var s = "";
        var status = 0;
        status = Event.target.status;
        s = Event.target.responseText;
        if (rtl.trunc(status / 100) === 2) {
          LoadProc(s)}
         else ErrorProc();
        Result = true;
        return Result;
      };
      function HandleError(Event) {
        var Result = false;
        ErrorProc();
        Result = true;
        return Result;
      };
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(null,HandleResponse));
      req.addEventListener("abort",rtl.createSafeCallback(null,HandleError));
      req.addEventListener("timeout",rtl.createSafeCallback(null,HandleError));
      req.addEventListener("error",rtl.createSafeCallback(null,HandleError));
      req.open("GET",AURL);
      req.send();
    };
    $impl.StringListAnsiCompare = function (List, Index1, Index) {
      var Result = 0;
      Result = List.DoCompareText(List.FList[Index1].FString,List.FList[Index].FString);
      return Result;
    };
    $impl.TMSGrow = 4096;
    $impl.FilerSignatureInt = 809914452;
    rtl.createClass($impl,"TUnresolvedReference",pas.simplelinkedlist.TLinkedListItem,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListItem.$init.call(this);
        this.FRoot = null;
        this.FPropInfo = null;
        this.FGlobal = "";
        this.FRelative = "";
      };
      this.$final = function () {
        this.FRoot = undefined;
        this.FPropInfo = undefined;
        pas.simplelinkedlist.TLinkedListItem.$final.call(this);
      };
      this.Resolve = function (Instance) {
        var Result = false;
        var C = null;
        C = $mod.FindGlobalComponent(this.FGlobal);
        Result = C !== null;
        if (Result) {
          C = $mod.FindNestedComponent(C,this.FRelative,true);
          Result = C !== null;
          if (Result) pas.TypInfo.SetObjectProp$1(Instance,this.FPropInfo,C);
        };
        return Result;
      };
      this.RootMatches = function (ARoot) {
        var Result = false;
        Result = (ARoot === null) || (ARoot === this.FRoot);
        return Result;
      };
      this.NextRef = function () {
        var Result = null;
        Result = this.Next;
        return Result;
      };
    });
    rtl.createClass($impl,"TLocalUnResolvedReference",$impl.TUnresolvedReference,function () {
      this.$init = function () {
        $impl.TUnresolvedReference.$init.call(this);
        this.Finstance = null;
      };
      this.$final = function () {
        this.Finstance = undefined;
        $impl.TUnresolvedReference.$final.call(this);
      };
      var $r = this.$rtti;
      $r.addField("Finstance",$mod.$rtti["TPersistent"],4);
    });
    rtl.createClass($impl,"TUnResolvedInstance",pas.simplelinkedlist.TLinkedListItem,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListItem.$init.call(this);
        this.Instance = null;
        this.FUnresolved = null;
      };
      this.$final = function () {
        this.Instance = undefined;
        this.FUnresolved = undefined;
        pas.simplelinkedlist.TLinkedListItem.$final.call(this);
      };
      this.Destroy = function () {
        rtl.free(this,"FUnresolved");
        pas.System.TObject.Destroy.call(this);
      };
      this.AddReference = function (ARoot, APropInfo, AGlobal, ARelative) {
        var Result = null;
        if (this.FUnresolved === null) this.FUnresolved = pas.simplelinkedlist.TLinkedList.$create("Create$1",[$impl.TUnresolvedReference]);
        Result = rtl.as(this.FUnresolved.Add(),$impl.TUnresolvedReference);
        Result.FGlobal = AGlobal;
        Result.FRelative = ARelative;
        Result.FPropInfo = APropInfo;
        Result.FRoot = ARoot;
        return Result;
      };
      this.RootUnresolved = function () {
        var Result = null;
        Result = null;
        if (this.FUnresolved != null) Result = this.FUnresolved.FRoot;
        return Result;
      };
      this.ResolveReferences = function () {
        var Result = false;
        var R = null;
        var RN = null;
        R = this.RootUnresolved();
        while (R !== null) {
          RN = R.NextRef();
          if (R.Resolve(this.Instance)) this.FUnresolved.RemoveItem(R,true);
          R = RN;
        };
        Result = this.RootUnresolved() === null;
        return Result;
      };
    });
    rtl.createClass($impl,"TBuildListVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.List = null;
      };
      this.$final = function () {
        this.List = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Add = function (Item) {
        if (this.List === null) this.List = $mod.TFPList.$create("Create");
        this.List.Add(Item);
      };
      this.Destroy = function () {
        var I = 0;
        if (this.List != null) for (var $l = 0, $end = this.List.FCount - 1; $l <= $end; $l++) {
          I = $l;
          $impl.NeedResolving.RemoveItem(rtl.getObject(this.List.Get(I)),true);
        };
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.List;
          }, set: function (v) {
            this.p.List = v;
          }});
        pas.System.TObject.Destroy.call(this);
      };
    });
    rtl.createClass($impl,"TResolveReferenceVisitor",$impl.TBuildListVisitor,function () {
      this.Visit = function (Item) {
        var Result = false;
        if (Item.ResolveReferences()) this.Add(Item);
        Result = true;
        return Result;
      };
      var $r = this.$rtti;
      $r.addMethod("Visit",1,[["Item",pas.simplelinkedlist.$rtti["TLinkedListItem"]]],4,rtl.boolean);
    });
    rtl.createClass($impl,"TRemoveReferenceVisitor",$impl.TBuildListVisitor,function () {
      this.$init = function () {
        $impl.TBuildListVisitor.$init.call(this);
        this.FRef = "";
        this.FRoot = null;
      };
      this.$final = function () {
        this.FRoot = undefined;
        $impl.TBuildListVisitor.$final.call(this);
      };
      this.Create$1 = function (ARoot, ARef) {
        this.FRoot = ARoot;
        this.FRef = pas.SysUtils.UpperCase(ARef);
        return this;
      };
      this.Visit = function (Item) {
        var Result = false;
        var I = 0;
        var UI = null;
        var R = null;
        var L = null;
        UI = Item;
        R = UI.RootUnresolved();
        L = null;
        try {
          while (R !== null) {
            if (R.RootMatches(this.FRoot) && ((this.FRef === "") || (this.FRef === pas.SysUtils.UpperCase(R.FGlobal)))) {
              if (!(L != null)) L = $mod.TFPList.$create("Create");
              L.Add(R);
            };
            R = R.NextRef();
          };
          if (L != null) {
            for (var $l = 0, $end = L.FCount - 1; $l <= $end; $l++) {
              I = $l;
              UI.FUnresolved.RemoveItem(rtl.getObject(L.Get(I)),true);
            };
          };
          if (UI.FUnresolved.FRoot === null) {
            if (this.List === null) this.List = $mod.TFPList.$create("Create");
            this.List.Add(UI);
          };
        } finally {
          L = rtl.freeLoc(L);
        };
        Result = true;
        return Result;
      };
    });
    rtl.createClass($impl,"TReferenceNamesVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.FList = null;
        this.FRoot = null;
      };
      this.$final = function () {
        this.FList = undefined;
        this.FRoot = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Visit = function (Item) {
        var Result = false;
        var R = null;
        R = Item.RootUnresolved();
        while (R !== null) {
          if (R.RootMatches(this.FRoot)) if (this.FList.IndexOf(R.FGlobal) === -1) this.FList.Add(R.FGlobal);
          R = R.NextRef();
        };
        Result = true;
        return Result;
      };
      this.Create$1 = function (ARoot, AList) {
        this.FRoot = ARoot;
        this.FList = AList;
        return this;
      };
    });
    rtl.createClass($impl,"TReferenceInstancesVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.FList = null;
        this.FRef = "";
        this.FRoot = null;
      };
      this.$final = function () {
        this.FList = undefined;
        this.FRoot = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Visit = function (Item) {
        var Result = false;
        var R = null;
        R = Item.RootUnresolved();
        while (R !== null) {
          if ((this.FRoot === R.FRoot) && (this.FRef === pas.SysUtils.UpperCase(R.FGlobal))) if (this.FList.IndexOf(R.FRelative) === -1) this.FList.Add(R.FRelative);
          R = R.NextRef();
        };
        Result = true;
        return Result;
      };
      this.Create$1 = function (ARoot, ARef, AList) {
        this.FRoot = ARoot;
        this.FRef = pas.SysUtils.UpperCase(ARef);
        this.FList = AList;
        return this;
      };
    });
    rtl.createClass($impl,"TRedirectReferenceVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.FOld = "";
        this.FNew = "";
        this.FRoot = null;
      };
      this.$final = function () {
        this.FRoot = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Visit = function (Item) {
        var Result = false;
        var R = null;
        R = Item.RootUnresolved();
        while (R !== null) {
          if (R.RootMatches(this.FRoot) && (this.FOld === pas.SysUtils.UpperCase(R.FGlobal))) R.FGlobal = this.FNew;
          R = R.NextRef();
        };
        Result = true;
        return Result;
      };
      this.Create$1 = function (ARoot, AOld, ANew) {
        this.FRoot = ARoot;
        this.FOld = pas.SysUtils.UpperCase(AOld);
        this.FNew = ANew;
        return this;
      };
    });
    $impl.NeedResolving = null;
    $impl.FindUnresolvedInstance = function (AInstance) {
      var Result = null;
      Result = null;
      if ($impl.NeedResolving != null) {
        Result = $impl.NeedResolving.FRoot;
        while ((Result !== null) && (Result.Instance !== AInstance)) Result = Result.Next;
      };
      return Result;
    };
    $impl.AddtoResolveList = function (AInstance) {
      var Result = null;
      Result = $impl.FindUnresolvedInstance(AInstance);
      if (Result === null) {
        if (!($impl.NeedResolving != null)) $impl.NeedResolving = pas.simplelinkedlist.TLinkedList.$create("Create$1",[$impl.TUnResolvedInstance]);
        Result = rtl.as($impl.NeedResolving.Add(),$impl.TUnResolvedInstance);
        Result.Instance = AInstance;
      };
      return Result;
    };
    $impl.VisitResolveList = function (V) {
      try {
        $impl.NeedResolving.ForEach(V);
      } finally {
        pas.SysUtils.FreeAndNil({get: function () {
            return V;
          }, set: function (v) {
            V = v;
          }});
      };
    };
    $impl.GlobalFixupReferences = function () {
      if ($impl.NeedResolving === null) return;
      $impl.VisitResolveList($impl.TResolveReferenceVisitor.$create("Create"));
    };
    rtl.createClass($impl,"TPosComponent",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FPos = 0;
        this.FComponent = null;
      };
      this.$final = function () {
        this.FComponent = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function (APos, AComponent) {
        this.FPos = APos;
        this.FComponent = AComponent;
        return this;
      };
    });
    rtl.createClass($impl,"TInitHandler",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.AHandler = null;
        this.AClass = null;
      };
      this.$final = function () {
        this.AHandler = undefined;
        this.AClass = undefined;
        pas.System.TObject.$final.call(this);
      };
      var $r = this.$rtti;
      $r.addField("AHandler",$mod.$rtti["TInitComponentHandler"],4);
      $r.addField("AClass",$mod.$rtti["TComponentClass"],4);
    });
    $impl.ClassList = null;
    $impl.InitHandlerList = null;
    $impl.FindGlobalComponentList = null;
    $impl.ParseBufSize = 4096;
    $mod.$rtti.$StaticArray("TokNames$a",{dims: [20], eltype: rtl.string});
    $impl.TokNames = ["?","EOF","Symbol","String","Integer","Float","-","[","(","<","{","]",")",">","}",",",".","=",":","+"];
    $mod.$resourcestrings = {SStreamInvalidSeek: {org: "Seek is not implemented for class %s"}, SStreamNoReading: {org: "Stream reading is not implemented for class %s"}, SStreamNoWriting: {org: "Stream writing is not implemented for class %s"}, SReadError: {org: "Could not read data from stream"}, SWriteError: {org: "Could not write data to stream"}, SMemoryStreamError: {org: "Could not allocate memory"}, SerrInvalidStreamSize: {org: "Invalid Stream size"}};
  };
  $mod.$init = function () {
    (function () {
      $mod.RegisterInitComponentHandler($mod.TDataModule,$impl.DefaultInitHandler);
    })();
    $impl.ClassList = new Object();
  };
},["Web","simplelinkedlist"]);
rtl.module("UITypes",["System"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$inherited("TFontName",rtl.string,{});
});
rtl.module("WEBLib.Consts",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$resourcestrings = {SWarning: {org: "Warning"}, SError: {org: "Error"}, SInformation: {org: "Information"}, SConfirm: {org: "Confirm"}, SOK: {org: "OK"}, SCancel: {org: "Cancel"}, SYes: {org: "Yes"}, SNo: {org: "No"}, SAbort: {org: "Abort"}, SRetry: {org: "Retry"}, SIgnore: {org: "Ignore"}, SHelp: {org: "Help"}, SClose: {org: "Close"}, SAll: {org: "All"}, SYesToAll: {org: "Yes to all"}, SNoToAll: {org: "No to all"}, SReadError: {org: "Stream read error"}, SWriteError: {org: "Stream write error"}, SCannotGetFile: {org: "Cannot get the file from the URL %s because of the error %d!"}, SErrorLoadFromFile: {org: "There was an error during the download of the file %s!"}, SLoadFromFileAborted: {org: "The download of the file %s was aborted!"}, SWarningFR: {org: "Avertissement"}, SErrorFR: {org: "Erreur"}, SInformationFR: {org: "Information"}, SConfirmFR: {org: "Confirmer"}, SOKFR: {org: "OK"}, SCancelFR: {org: "Annuler"}, SYesFR: {org: "Oui"}, SNoFR: {org: "Non"}, SAbortFR: {org: "Interrompre"}, SRetryFR: {org: "Réessayer"}, SIgnoreFR: {org: "Ignorer"}, SHelpFR: {org: "Aide"}, SCloseFR: {org: "Fermer"}, SAllFR: {org: "Tout"}, SYesToAllFR: {org: "Oui à tout"}, SNoToAllFR: {org: "Non à tout"}, SWarningDE: {org: "Warnung"}, SErrorDE: {org: "Fehler"}, SInformationDE: {org: "Information"}, SConfirmDE: {org: "Bestätigen"}, SOKDE: {org: "OK"}, SCancelDE: {org: "Abbrechen"}, SYesDE: {org: "Ja"}, SNoDE: {org: "Nein"}, SAbortDE: {org: "Abbrechen"}, SRetryDE: {org: "Wiederholen"}, SIgnoreDE: {org: "Ignorieren"}, SHelpDE: {org: "Hilfe"}, SCloseDE: {org: "Schließen"}, SAllDE: {org: "Alles"}, SYesToAllDE: {org: "Ja auf Alles"}, SNoToAllDE: {org: "Nein auf Alles"}, SWarningES: {org: "Advertencia"}, SErrorES: {org: "Error"}, SInformationES: {org: "Información"}, SConfirmES: {org: "Confirmado"}, SOKES: {org: "OK"}, SCancelES: {org: "Cancelar"}, SYesES: {org: "Sí"}, SNoES: {org: "No"}, SAbortES: {org: "Abortar"}, SRetryES: {org: "Rever"}, SIgnoreES: {org: "Ignorar"}, SHelpES: {org: "Ayudar"}, SCloseES: {org: "Cerrar"}, SAllES: {org: "Todos"}, SYesToAllES: {org: "Sí a todo"}, SNoToAllES: {org: "No a todo"}, SWarningNL: {org: "Waarschuwing"}, SErrorNL: {org: "Fout"}, SInformationNL: {org: "Informatie"}, SConfirmNL: {org: "Bevestiging"}, SOKNL: {org: "OK"}, SCancelNL: {org: "Afbreken"}, SYesNL: {org: "Ja"}, SNoNL: {org: "Nee"}, SAbortNL: {org: "Afbreken"}, SRetryNL: {org: "Opnieuw"}, SIgnoreNL: {org: "Negeren"}, SHelpNL: {org: "Hulp"}, SCloseNL: {org: "Sluiten"}, SAllNL: {org: "Alles"}, SYesToAllNL: {org: "Ja op alles"}, SNoToAllNL: {org: "Nee op alles"}};
});
rtl.module("WEBLib.Dialogs",["System","Classes","WEBLib.Controls","Web","JS","SysUtils","WEBLib.Graphics"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TMsgDlgType = {"0": "mtWarning", mtWarning: 0, "1": "mtError", mtError: 1, "2": "mtInformation", mtInformation: 2, "3": "mtConfirmation", mtConfirmation: 3, "4": "mtCustom", mtCustom: 4};
  this.$rtti.$Enum("TMsgDlgType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMsgDlgType});
  this.TMsgDlgBtn = {"0": "mbYes", mbYes: 0, "1": "mbNo", mbNo: 1, "2": "mbOK", mbOK: 2, "3": "mbCancel", mbCancel: 3, "4": "mbAbort", mbAbort: 4, "5": "mbRetry", mbRetry: 5, "6": "mbIgnore", mbIgnore: 6, "7": "mbAll", mbAll: 7, "8": "mbNoToAll", mbNoToAll: 8, "9": "mbYesToAll", mbYesToAll: 9, "10": "mbHelp", mbHelp: 10, "11": "mbClose", mbClose: 11};
  this.$rtti.$Enum("TMsgDlgBtn",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TMsgDlgBtn});
  this.$rtti.$Set("TMsgDlgButtons",{comptype: this.$rtti["TMsgDlgBtn"]});
  this.$rtti.$RefToProcVar("TDialogResultProc",{procsig: rtl.newTIProcSig([["AValue",rtl.longint]])});
  rtl.createClass(this,"TCustomDialogButton",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCaption = "";
      this.FTag = 0;
      this.FElementClassName = "";
    };
    var $r = this.$rtti;
    $r.addProperty("Caption",0,rtl.string,"FCaption","FCaption");
    $r.addProperty("ElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","FElementClassName");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag",4,{Default: 0});
  });
  rtl.createClass(this,"TCustomDialogButtons",pas.Classes.TOwnedCollection,function () {
    this.GetItem$1 = function (AIndex) {
      var Result = null;
      Result = this.GetItem(AIndex);
      return Result;
    };
    this.SetItem$1 = function (AIndex, Value) {
      this.SetItem(AIndex,Value);
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (AIndex) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,AIndex);
      return Result;
    };
  });
  rtl.createClass(this,"TMessageDlg",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FOpacity = 0.0;
      this.FLayer$1 = null;
      this.FDlg = null;
      this.FCancel = null;
      this.FMessage = "";
      this.FTitle = "";
      this.FMsgDlgType = 0;
      this.FOnButtonClick = null;
      this.FOnClose = null;
      this.FButtons = {};
      this.FDialogProc = null;
      this.FDialogResult = 0;
      this.FMdx = 0;
      this.FMdy = 0;
      this.FDlgX = 0;
      this.FDlgY = 0;
      this.FCaptured$1 = false;
      this.FDown = false;
      this.FElementTitleClassName = "";
      this.FElementButtonClassName = "";
      this.FElementContentClassName = "";
      this.FDialogText = null;
      this.FCustomButtons = null;
      this.FElementDialogClassName = "";
      this.FAutoLanguage = false;
      this.FUseMaterial = false;
    };
    this.$final = function () {
      this.FLayer$1 = undefined;
      this.FDlg = undefined;
      this.FCancel = undefined;
      this.FOnButtonClick = undefined;
      this.FOnClose = undefined;
      this.FButtons = undefined;
      this.FDialogProc = undefined;
      this.FDialogText = undefined;
      this.FCustomButtons = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetDialogText = function (Value) {
      this.FDialogText.Assign(Value);
    };
    this.SetCustomButtons = function (Value) {
      this.FCustomButtons.Assign(Value);
    };
    this.CreateElement = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = null}
       else pas["WEBLib.Controls"].TCustomControl.CreateElement.call(this);
      return Result;
    };
    var TLang = {"0": "lEN", lEN: 0, "1": "lFR", lFR: 1, "2": "lDE", lDE: 2, "3": "lES", lES: 3, "4": "lNL", lNL: 4};
    this.GetDialogText = function (Index) {
      var Result = "";
      var locl = "";
      var l = 0;
      Result = "Undefined";
      if (Index < this.FDialogText.GetCount()) Result = this.FDialogText.Get(Index);
      if (this.FAutoLanguage) {
        locl = pas["WEBLib.WebTools"].GetBrowserLocale();
        l = TLang.lEN;
        if (pas.System.Pos("es",locl) === 1) l = TLang.lES;
        if (pas.System.Pos("fr",locl) === 1) l = TLang.lFR;
        if (pas.System.Pos("de",locl) === 1) l = TLang.lDE;
        if (pas.System.Pos("nl",locl) === 1) l = TLang.lNL;
        var $tmp = l;
        if ($tmp === TLang.lES) {
          var $tmp1 = Index;
          if ($tmp1 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningES")}
           else if ($tmp1 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorES")}
           else if ($tmp1 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationES")}
           else if ($tmp1 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmES")}
           else if ($tmp1 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKES")}
           else if ($tmp1 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelES")}
           else if ($tmp1 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesES")}
           else if ($tmp1 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoES")}
           else if ($tmp1 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortES")}
           else if ($tmp1 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryES")}
           else if ($tmp1 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreES")}
           else if ($tmp1 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllES")}
           else if ($tmp1 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllES")}
           else if ($tmp1 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllES")}
           else if ($tmp1 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpES")}
           else if ($tmp1 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseES");
        } else if ($tmp === TLang.lFR) {
          var $tmp2 = Index;
          if ($tmp2 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningFR")}
           else if ($tmp2 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorFR")}
           else if ($tmp2 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationFR")}
           else if ($tmp2 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmFR")}
           else if ($tmp2 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKFR")}
           else if ($tmp2 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelFR")}
           else if ($tmp2 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesFR")}
           else if ($tmp2 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoFR")}
           else if ($tmp2 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortFR")}
           else if ($tmp2 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryFR")}
           else if ($tmp2 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreFR")}
           else if ($tmp2 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllFR")}
           else if ($tmp2 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllFR")}
           else if ($tmp2 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllFR")}
           else if ($tmp2 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpFR")}
           else if ($tmp2 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseFR");
        } else if ($tmp === TLang.lDE) {
          var $tmp3 = Index;
          if ($tmp3 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningDE")}
           else if ($tmp3 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorDE")}
           else if ($tmp3 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationDE")}
           else if ($tmp3 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmDE")}
           else if ($tmp3 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKDE")}
           else if ($tmp3 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelDE")}
           else if ($tmp3 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesDE")}
           else if ($tmp3 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoDE")}
           else if ($tmp3 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortDE")}
           else if ($tmp3 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryDE")}
           else if ($tmp3 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreDE")}
           else if ($tmp3 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllDE")}
           else if ($tmp3 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllDE")}
           else if ($tmp3 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllDE")}
           else if ($tmp3 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpDE")}
           else if ($tmp3 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseDE");
        } else if ($tmp === TLang.lNL) {
          var $tmp4 = Index;
          if ($tmp4 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningNL")}
           else if ($tmp4 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorNL")}
           else if ($tmp4 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationNL")}
           else if ($tmp4 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmNL")}
           else if ($tmp4 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKNL")}
           else if ($tmp4 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelNL")}
           else if ($tmp4 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesNL")}
           else if ($tmp4 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoNL")}
           else if ($tmp4 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortNL")}
           else if ($tmp4 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryNL")}
           else if ($tmp4 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreNL")}
           else if ($tmp4 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllNL")}
           else if ($tmp4 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllNL")}
           else if ($tmp4 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllNL")}
           else if ($tmp4 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpNL")}
           else if ($tmp4 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseNL");
        };
      };
      return Result;
    };
    this.BindEvents = function () {
    };
    this.SetDialogResult = function (Value) {
      this.FDialogResult = Value;
      if (this.FDialogResult !== 0) this.Close();
    };
    this.CreateButton = function (Caption, DoFocus, AClass) {
      var Result = null;
      var BtnClass = "";
      Result = document.createElement("BUTTON");
      Result.innerHTML = Caption;
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        Result.setAttribute("type","BUTTON");
        Result.setAttribute("class","btn " + AClass);
        Result.setAttribute("data-dismiss","modal-dialog");
      } else {
        BtnClass = AClass;
        if (BtnClass !== "") BtnClass = " " + BtnClass;
        Result.style.setProperty("width","100px");
        Result.style.setProperty("margin-left","5px");
        if (this.FElementButtonClassName !== "") {
          Result.setAttribute("class",this.FElementButtonClassName + BtnClass)}
         else if (pas["WEBLib.Forms"].Application.FThemeButtonClassName !== "") Result.setAttribute("class",pas["WEBLib.Forms"].Application.FThemeButtonClassName + BtnClass);
      };
      Result.id = Caption;
      Result.addEventListener("click",rtl.createSafeCallback(this,"HandleButtonClick"));
      Result.addEventListener("keydown",rtl.createSafeCallback(this,"HandleKeyDown"));
      if (DoFocus.get()) {
        setTimeout(function() {Result.focus();}, 1);
        DoFocus.set(false);
      };
      return Result;
    };
    this.HandleDocMouseMove = function (Event) {
      var Result = false;
      var deltax = 0.0;
      var deltay = 0.0;
      var el = null;
      var AEvent = null;
      AEvent = Event;
      if (this.FDown) {
        deltax = AEvent.screenX - this.FMdx;
        deltay = AEvent.screenY - this.FMdy;
        el = this.FDlg;
        el.style.setProperty("transform","");
        el.style.setProperty("position","absolute");
        el.style.setProperty("left",pas.SysUtils.IntToStr(Math.round(this.FDlgX + deltax)) + "px");
        el.style.setProperty("top",pas.SysUtils.IntToStr(Math.round(this.FDlgY + deltay)) + "px");
        el = this.FCancel;
        el.style.setProperty("position","absolute");
        el.style.setProperty("top","0");
        el.style.setProperty("right","0");
      };
      Result = true;
      return Result;
    };
    this.HandleDocMouseUp = function (Event) {
      var Result = false;
      this.FDown = false;
      document.body.removeEventListener("mousemove",rtl.createSafeCallback(this,"HandleDocMouseMove"));
      document.body.removeEventListener("mouseup",rtl.createSafeCallback(this,"HandleDocMouseUp"));
      Result = true;
      return Result;
    };
    this.HandleMouseDown = function (Event) {
      var Result = false;
      var r = null;
      var AEvent = null;
      AEvent = Event;
      this.FMdx = Math.round(AEvent.screenX);
      this.FMdy = Math.round(AEvent.screenY);
      r = this.FDlg.getBoundingClientRect();
      this.FDlgX = Math.round(pas.System.Int(r.left));
      this.FDlgY = Math.round(pas.System.Int(r.top));
      this.FDown = true;
      if (!this.FCaptured$1) {
        this.FCaptured$1 = true;
        document.body.addEventListener("mousemove",rtl.createSafeCallback(this,"HandleDocMouseMove"));
        document.body.addEventListener("mouseup",rtl.createSafeCallback(this,"HandleDocMouseUp"));
      };
      Result = true;
      return Result;
    };
    this.HandleButtonClick = function (Event) {
      var Result = false;
      var id = "";
      var i = 0;
      this.SetDialogResult(0);
      id = Event.target.getAttribute("id");
      if (id === this.GetDialogText(7)) {
        this.SetDialogResult(6)}
       else if (id === this.GetDialogText(8)) {
        this.SetDialogResult(7)}
       else if (id === this.GetDialogText(5)) {
        this.SetDialogResult(1)}
       else if (id === this.GetDialogText(6)) {
        this.SetDialogResult(2)}
       else if (id === this.GetDialogText(9)) {
        this.SetDialogResult(3)}
       else if (id === this.GetDialogText(10)) {
        this.SetDialogResult(4)}
       else if (id === this.GetDialogText(11)) {
        this.SetDialogResult(5)}
       else if (id === this.GetDialogText(12)) {
        this.SetDialogResult(12)}
       else if (id === this.GetDialogText(13)) {
        this.SetDialogResult(13)}
       else if (id === this.GetDialogText(14)) {
        this.SetDialogResult(14)}
       else if (id === this.GetDialogText(15)) {
        this.SetDialogResult(9)}
       else if (id === this.GetDialogText(16)) this.SetDialogResult(8);
      if ((this.FDialogResult === 0) && (this.FCustomButtons.GetCount() > 0)) {
        for (var $l = 0, $end = this.FCustomButtons.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (id === this.FCustomButtons.GetItem$1(i).FCaption) {
            this.SetDialogResult(100 + i);
            break;
          };
        };
      };
      if (this.FOnButtonClick != null) this.FOnButtonClick(this);
      Result = true;
      return Result;
    };
    this.HandleKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      var AEvent = null;
      AEvent = Event;
      k = this.GetKeyCode(AEvent.key,true);
      if (!pas.System.Assigned(k)) return Result;
      if (k === 27) this.SetDialogResult(2);
      Result = true;
      return Result;
    };
    this.InitBootstrapStyle = function () {
      this.FElementButtonClassName = "btn";
      this.FElementContentClassName = "text-body";
      this.FElementTitleClassName = "text-body";
      this.FElementDialogClassName = "shadow-lg p-3 mb-5 bg-body text-body rounded";
    };
    this.InsertInputElement = function (AElement, DoFocus) {
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FOpacity = 0.2;
      this.FMessage = "";
      this.FAutoLanguage = true;
      this.FMsgDlgType = $mod.TMsgDlgType.mtInformation;
      this.FDialogText = pas.Classes.TStringList.$create("Create$1");
      this.FDialogText.SetSkipLastLineBreak(true);
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SWarning"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SError"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SInformation"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SConfirm"));
      this.FDialogText.Add("Custom");
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SOK"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SCancel"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SYes"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SNo"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SAbort"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SRetry"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SIgnore"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SAll"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SYesToAll"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SNoToAll"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SHelp"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SClose"));
      this.FMsgDlgType = $mod.TMsgDlgType.mtCustom;
      this.FUseMaterial = true;
      this.FCustomButtons = $mod.TCustomDialogButtons.$create("Create$2",[this,$mod.TCustomDialogButton]);
      this.FCustomButtons.FPropName = "CustomButtons";
    };
    this.Destroy = function () {
      rtl.free(this,"FDialogText");
      rtl.free(this,"FCustomButtons");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Close = function () {
      pas["WEBLib.Forms"].Application.UnLockForm(pas["WEBLib.Forms"].Application.FMainForm);
      document.body.removeChild(this.FLayer$1);
      document.body.removeChild(this.FDlg);
      this.FDown = false;
      this.FCaptured$1 = false;
      if (this.FOnClose != null) this.FOnClose(this);
      if (this.FDialogProc != null) this.FDialogProc(this.FDialogResult);
    };
    this.Show$1 = function () {
      var title = null;
      var msg = null;
      var icon = null;
      var content = null;
      var contentdiv = null;
      var bar = null;
      var edlg = null;
      var eh = null;
      var cancel = null;
      var adiv = null;
      var ldiv = null;
      var cdiv = null;
      var MsgSymbol = "";
      var MsgColor = "";
      var MsgTitle = "";
      var BorderColor = "";
      var BarBGColor = "";
      var BarHeight = "";
      var Padding = "";
      var btnFocus = false;
      var i = 0;
      if ((pas["WEBLib.Forms"].Application === null) || (pas["WEBLib.Forms"].Application.FMainForm === null)) return;
      if (this.FUseMaterial && !pas["WEBLib.Forms"].Application.HasCSS($impl.lMaterial)) this.AddControlLink("material",$impl.lMaterial);
      pas["WEBLib.Forms"].Application.LockForm(pas["WEBLib.Forms"].Application.FMainForm);
      this.FLayer$1 = document.createElement("SPAN");
      document.body.appendChild(this.FLayer$1);
      this.FLayer$1.setAttribute("tabindex","0");
      this.FLayer$1.addEventListener("keydown",rtl.createSafeCallback(this,"HandleKeyDown"));
      btnFocus = true;
      this.FMessage = $impl.StringToHTML(this.FMessage);
      var $tmp = this.FMsgDlgType;
      if ($tmp === $mod.TMsgDlgType.mtWarning) {
        MsgSymbol = "warning";
        MsgColor = "orange";
        MsgTitle = this.GetDialogText(0);
      } else if ($tmp === $mod.TMsgDlgType.mtError) {
        MsgSymbol = "cancel";
        MsgColor = "red";
        MsgTitle = this.GetDialogText(1);
      } else if ($tmp === $mod.TMsgDlgType.mtInformation) {
        MsgSymbol = "info";
        MsgColor = "blue";
        MsgTitle = this.GetDialogText(2);
      } else if ($tmp === $mod.TMsgDlgType.mtConfirmation) {
        MsgSymbol = "help";
        MsgColor = "blue";
        MsgTitle = this.GetDialogText(3);
      } else if ($tmp === $mod.TMsgDlgType.mtCustom) {
        MsgSymbol = "";
        MsgColor = "";
        MsgTitle = this.GetDialogText(4);
      };
      if (this.FTitle !== "") MsgTitle = this.FTitle;
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.FDlg = document.createElement("DIV");
        this.FDlg.setAttribute("class","modal-dialog");
        this.FDlg.setAttribute("role","document");
        this.FDlg.style.setProperty("z-index","1999998");
        eh = document.createElement("DIV");
        eh.style.setProperty("top","0");
        eh.style.setProperty("left","0");
        eh.style.setProperty("right","0");
        eh.style.setProperty("bottom","0");
        eh.style.setProperty("z-index","1999997");
        eh.style.setProperty("display","block");
        eh.setAttribute("class","modal show fade");
        document.body.appendChild(eh);
        eh.appendChild(this.FDlg);
        ldiv = this.FDlg;
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-content " + this.FElementDialogClassName);
        ldiv.appendChild(adiv);
        cdiv = adiv;
        ldiv = adiv;
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-header");
        cdiv.appendChild(adiv);
        ldiv = adiv;
        adiv = document.createElement("H5");
        adiv.setAttribute("class","modal-title");
        adiv.innerHTML = MsgTitle;
        ldiv.appendChild(adiv);
        if ($mod.TMsgDlgBtn.mbCancel in this.FButtons) {
          adiv = document.createElement("BUTTON");
          adiv.setAttribute("type","button");
          adiv.setAttribute("class","close btn btn-danger");
          adiv.setAttribute("data-dismiss","modal-dialog");
          adiv.setAttribute("aria-label","Close");
          adiv.setAttribute("id",this.GetDialogText(6));
          adiv.addEventListener("click",rtl.createSafeCallback(this,"HandleButtonClick"));
          ldiv.appendChild(adiv);
          ldiv = adiv;
          adiv = document.createElement("SPAN");
          adiv.setAttribute("aria-hidden","true");
          adiv.setAttribute("id",this.GetDialogText(6));
          adiv.innerHTML = "&times;";
          ldiv.appendChild(adiv);
        };
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-body");
        cdiv.appendChild(adiv);
        ldiv = adiv;
        if (this.FMsgDlgType !== $mod.TMsgDlgType.mtCustom) {
          icon = document.createElement("SPAN");
          icon.innerHTML = '<i class="material-icons" style="color:' + MsgColor + '!important;font-size:48px!important">' + MsgSymbol + "</i>";
          icon.style.setProperty("display","inline-block");
          icon.style.setProperty("float","left");
          icon.style.setProperty("padding-right","15px");
          ldiv.appendChild(icon);
        };
        adiv = document.createElement("H6");
        adiv.innerHTML = this.FMessage;
        ldiv.appendChild(adiv);
        this.InsertInputElement(ldiv,{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }});
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-footer");
        cdiv.appendChild(adiv);
        ldiv = adiv;
        bar = ldiv;
        this.FDlg = eh;
      } else {
        Padding = "5";
        BarHeight = "26";
        BarBGColor = "#f1f1f1";
        BorderColor = "#ababab";
        this.FDlg = document.createElement("DIV");
        document.body.appendChild(this.FDlg);
        edlg = this.FDlg;
        if (this.FElementDialogClassName !== "") {
          edlg.setAttribute("class",this.FElementDialogClassName)}
         else {
          edlg.style.setProperty("background-color","white");
          edlg.style.setProperty("border","1px solid " + BorderColor);
          edlg.style.setProperty("font-family","Arial");
          edlg.style.setProperty("font-size","10pt");
        };
        edlg.style.setProperty("cursor","default");
        edlg.style.setProperty("position","fixed");
        edlg.style.setProperty("min-width","300px");
        edlg.style.setProperty("min-height","125px");
        edlg.style.setProperty("max-width","100%");
        edlg.style.setProperty("max-height","100%");
        edlg.style.setProperty("top","50%");
        edlg.style.setProperty("left","50%");
        edlg.style.setProperty("transform","translate(-50%, -50%)");
        edlg.style.setProperty("z-index","1999998");
        edlg.style.setProperty("box-shadow","5px 5px 5px gray");
        cancel = document.createElement("DIV");
        this.FCancel = cancel;
        cancel.innerHTML = '<i id="Cancel" class="material-icons" style="font-size:16px!important">clear</i>';
        cancel.id = "Cancel";
        cancel.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(pas["WEBLib.Forms"].Application.FThemeTextColor));
        cancel.style.setProperty("position","fixed");
        cancel.style.setProperty("top","0");
        cancel.style.setProperty("right","0");
        cancel.style.setProperty("padding",Padding + "px");
        cancel.style.setProperty("height",BarHeight + "px");
        cancel.style.setProperty("line-height",BarHeight + "px");
        cancel.addEventListener("click",rtl.createSafeCallback(this,"HandleButtonClick"));
        edlg.appendChild(cancel);
        title = document.createElement("DIV");
        title.innerHTML = MsgTitle;
        if (this.FElementTitleClassName !== "") {
          title.setAttribute("class",this.FElementTitleClassName);
        } else {
          title.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(pas["WEBLib.Forms"].Application.FThemeColor));
          title.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(pas["WEBLib.Forms"].Application.FThemeTextColor));
        };
        title.style.setProperty("cursor","move");
        title.style.setProperty("padding-left",Padding + "px");
        title.style.setProperty("height",BarHeight + "px");
        title.style.setProperty("vertical-align","middle");
        title.style.setProperty("line-height",BarHeight + "px");
        title.style.setProperty("border-bottom","1px solid " + BorderColor);
        title.style.setProperty("-moz-user-select","none");
        title.style.setProperty("-webkit-user-select","none");
        title.style.setProperty("-ms-user-select","none");
        title.style.setProperty("user-select","none");
        title.style.setProperty("-o-user-select","none");
        title.addEventListener("mousedown",rtl.createSafeCallback(this,"HandleMouseDown"));
        edlg.appendChild(title);
        msg = document.createElement("DIV");
        msg.style.setProperty("padding",Padding + "px");
        msg.style.setProperty("height","auto");
        msg.style.setProperty("min-height","50px");
        msg.style.setProperty("border-bottom","1px solid " + BorderColor);
        if (this.FMsgDlgType !== $mod.TMsgDlgType.mtCustom) {
          icon = document.createElement("DIV");
          icon.innerHTML = '<i class="material-icons" style="color:' + MsgColor + '!important;font-size:48px!important">' + MsgSymbol + "</i>";
          icon.style.setProperty("display","inline-block");
          icon.style.setProperty("float","left");
          icon.style.setProperty("padding-right","15px");
          msg.appendChild(icon);
        };
        this.FMessage = pas.SysUtils.StringReplace(this.FMessage,pas.System.sLineBreak,"<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        contentdiv = document.createElement("DIV");
        contentdiv.innerHTML = this.FMessage;
        contentdiv.style.setProperty("height","auto");
        contentdiv.style.setProperty("min-height","50px");
        contentdiv.style.setProperty("white-space","pre-wrap");
        content = document.createElement("LABEL");
        content.innerHTML = this.FMessage;
        if (this.FElementTitleClassName !== "") {
          content.setAttribute("class",this.FElementContentClassName);
        };
        contentdiv.appendChild(content);
        msg.appendChild(content);
        this.InsertInputElement(msg,{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }});
        edlg.appendChild(msg);
        bar = document.createElement("DIV");
        bar.style.setProperty("background-color",BarBGColor);
        bar.style.setProperty("padding",Padding + "px");
        bar.style.setProperty("min-height",BarHeight + "px");
        bar.style.setProperty("height","auto");
        bar.style.setProperty("line-height",BarHeight + "px");
        bar.style.setProperty("text-align","right");
        edlg.appendChild(bar);
      };
      if (rtl.eqSet(this.FButtons,{}) && (this.FCustomButtons.GetCount() === 0)) {
        bar.appendChild(this.CreateButton(this.GetDialogText(5),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""))}
       else {
        if ($mod.TMsgDlgBtn.mbYes in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(7),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbNo in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(8),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbOK in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(5),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbCancel in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(6),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbAbort in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(9),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbRetry in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(10),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbIgnore in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(11),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbAll in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(12),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbYesToAll in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(13),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbNoToAll in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(14),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbHelp in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(15),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbClose in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(16),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
      };
      for (var $l = 0, $end = this.FCustomButtons.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        bar.appendChild(this.CreateButton(this.FCustomButtons.GetItem$1(i).FCaption,{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},this.FCustomButtons.GetItem$1(i).FElementClassName));
      };
      eh = this.FLayer$1;
      eh.style.setProperty("background-color","black");
      eh.style.setProperty("opacity",pas["WEBLib.WebTools"].DoubleToHTML(this.FOpacity));
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("z-index",pas["WEBLib.Forms"].Application.MaxZIndexStr());
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","fixed");
    };
    this.ShowDialog = function () {
      var Result = 0;
      Result = 0;
      this.Show$1();
      return Result;
    };
    this.ShowDialog$1 = function (Msg, DlgType, Buttons, AProc) {
      var Result = 0;
      Result = 0;
      this.FButtons = rtl.refSet(Buttons);
      this.FMessage = Msg;
      this.FMsgDlgType = DlgType;
      this.FDialogProc = AProc;
      this.SetDialogResult(0);
      this.Show$1();
      return Result;
    };
    this.ShowDialog$2 = function (Msg, DlgType, Buttons) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowDialog$1(Msg,DlgType,rtl.refSet(Buttons),function (AResult) {
          ASuccess(AResult);
        });
      });
      return Result;
    };
    this.ShowAsync = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowDialog$1($Self.FMessage,$Self.FMsgDlgType,rtl.refSet($Self.FButtons),function (AResult) {
          ASuccess(AResult);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AutoLanguage",0,rtl.boolean,"FAutoLanguage","FAutoLanguage",4,{Default: true});
    $r.addProperty("Buttons",0,$mod.$rtti["TMsgDlgButtons"],"FButtons","FButtons",4,{Default: {}});
    $r.addProperty("CustomButtons",2,$mod.$rtti["TCustomDialogButtons"],"FCustomButtons","SetCustomButtons");
    $r.addProperty("DialogText",2,pas.Classes.$rtti["TStringList"],"FDialogText","SetDialogText");
    $r.addProperty("DialogType",0,$mod.$rtti["TMsgDlgType"],"FMsgDlgType","FMsgDlgType",4,{Default: $mod.TMsgDlgType.mtCustom});
    $r.addProperty("Message",0,rtl.string,"FMessage","FMessage");
    $r.addProperty("Opacity",0,rtl.double,"FOpacity","FOpacity");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementDialogClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementDialogClassName","FElementDialogClassName");
    $r.addProperty("ElementTitleClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTitleClassName","FElementTitleClassName");
    $r.addProperty("ElementContentClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementContentClassName","FElementContentClassName");
    $r.addProperty("Title",0,rtl.string,"FTitle","FTitle");
    $r.addProperty("UseMaterial",0,rtl.boolean,"FUseMaterial","FUseMaterial",4,{Default: true});
    $r.addProperty("OnButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnButtonClick","FOnButtonClick");
    $r.addProperty("OnClose",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClose","FOnClose");
  });
  rtl.createClass(this,"TWebMessageDlg",this.TMessageDlg,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TInputMessageDlg",this.TMessageDlg,function () {
    this.$init = function () {
      $mod.TMessageDlg.$init.call(this);
      this.FInputElement = null;
      this.FInputValue = "";
      this.FKeydownHandler = null;
      this.FKeypressHandler = null;
      this.FInputType = 0;
    };
    this.$final = function () {
      this.FInputElement = undefined;
      $mod.TMessageDlg.$final.call(this);
    };
    this.ShowAsync = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowDialog$1($Self.FMessage,$Self.FMsgDlgType,rtl.refSet($Self.FButtons),function (AResult) {
          $Self.FInputValue = $Self.GetInputElementValue();
          ASuccess(AResult);
        });
      });
      return Result;
    };
    this.HandleInputKeydown = function (Event) {
      var Result = false;
      Result = true;
      if (Event.key === "Enter") {
        Event.preventDefault();
        Event.stopPropagation();
        this.SetDialogResult(1);
        Result = false;
      };
      if (Event.key === "Escape") {
        Event.preventDefault();
        Event.stopPropagation();
        this.SetDialogResult(2);
        Result = false;
      };
      return Result;
    };
    this.HandleInputKeypress = function (Event) {
      var Result = false;
      Result = true;
      Event.stopPropagation();
      return Result;
    };
    this.InsertInputElement = function (AElement, DoFocus) {
      var divel = null;
      var inputel = null;
      $mod.TMessageDlg.InsertInputElement.apply(this,arguments);
      if (this.FKeydownHandler === null) this.FKeydownHandler = rtl.createCallback(this,"HandleInputKeydown");
      if (this.FKeypressHandler === null) this.FKeypressHandler = rtl.createCallback(this,"HandleInputKeypress");
      divel = document.createElement("DIV");
      inputel = document.createElement("INPUT");
      inputel.addEventListener("keydown",this.FKeydownHandler);
      inputel.addEventListener("keypress",this.FKeypressHandler);
      divel.appendChild(inputel);
      AElement.appendChild(divel);
      this.FInputElement = inputel;
      this.FInputElement.setAttribute("type",pas["WEBLib.Controls"].InputTypeString(this.FInputType));
      divel.style.setProperty("margin-top","10px");
      this.FInputElement.style.setProperty("padding","4px");
      this.SetInputElementValue(this.FInputValue);
      this.FInputElement.style.setProperty("width","calc(100% - 80px)");
      if (DoFocus.get()) {
        setTimeout(function() {inputel.focus(); inputel.select()}, 1);
        DoFocus.set(false);
      };
    };
    this.GetInputElementValue = function () {
      var Result = "";
      Result = "";
      if (this.FInputElement != null) {
        this.FInputValue = this.FInputElement.value;
        Result = this.FInputValue;
      };
      return Result;
    };
    this.SetInputElementValue = function (AValue) {
      this.FInputElement.value = AValue;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addField("FInputElement",pas.Web.$rtti["TJSHTMLElement"],4);
    $r.addField("FInputValue",rtl.string,4);
    $r.addField("FKeydownHandler",rtl.pointer,4);
    $r.addField("FKeypressHandler",rtl.pointer,4);
    $r.addProperty("InputValue",1,rtl.string,"GetInputElementValue","FInputValue");
    $r.addProperty("InputType",0,pas["WEBLib.Controls"].$rtti["TInputType"],"FInputType","FInputType",4,{Default: pas["WEBLib.Controls"].TInputType.itText});
  });
  rtl.createClass(this,"TWebInputMessageDlg",this.TInputMessageDlg,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWaitMessage",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FLayer$1 = null;
      this.FPicture = null;
      this.FOpacity = 0.0;
      this.FOnShow = null;
      this.FOnHide = null;
      this.FIsWaiting = false;
      this.FPictureURL = "";
      this.FTimeOut = 0;
      this.FShowID = 0;
      this.FHideID = 0;
    };
    this.$final = function () {
      this.FLayer$1 = undefined;
      this.FPicture = undefined;
      this.FOnShow = undefined;
      this.FOnHide = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetPicture = function (Value) {
      this.FPicture.Assign(Value);
    };
    this.SetPictureURL = function (Value) {
      this.FPictureURL = Value;
    };
    this.WaitDisplayed = function () {
      if (this.FOnShow != null) this.FOnShow(this);
    };
    this.WaitHide = function () {
      if (this.FOnHide != null) this.FOnHide(this);
      this.Hide$1();
    };
    this.CreateElement = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = null}
       else pas["WEBLib.Controls"].TCustomControl.CreateElement.call(this);
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FOpacity = 0.2;
      this.FPicture = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FIsWaiting = false;
      this.FPicture.SetData($impl.lWaitCursor);
      this.FShowID = 0;
      this.FHideID = 0;
    };
    this.Destroy = function () {
      rtl.free(this,"FPicture");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Show$1 = function () {
      var eh = null;
      var img = null;
      var dv = null;
      var el = null;
      this.FLayer$1 = document.createElement("SPAN");
      eh = this.FLayer$1;
      eh.style.setProperty("background-color","black");
      eh.style.setProperty("opacity",pas["WEBLib.WebTools"].DoubleToHTML(this.FOpacity));
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("z-index","9999999");
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","fixed");
      document.body.appendChild(this.FLayer$1);
      this.FLayer$1.setAttribute("tabindex","0");
      el = document.createElement("DIV");
      this.FContainer = el;
      this.FControlCreated = true;
      dv = el;
      this.FLayer$1.appendChild(el);
      dv.style.setProperty("position","relative");
      dv.style.setProperty("width","100%");
      dv.style.setProperty("height","100%");
      el = document.createElement("IMG");
      img = el;
      dv.appendChild(img);
      if (this.FPictureURL !== "") {
        img.setAttribute("src",this.FPictureURL)}
       else img.setAttribute("src",this.FPicture.FFilename);
      img.style.setProperty("position","absolute");
      img.style.setProperty("top","0");
      img.style.setProperty("left","0");
      img.style.setProperty("right","0");
      img.style.setProperty("bottom","0");
      img.style.setProperty("margin","auto");
      this.FIsWaiting = true;
      if (this.FOnShow != null) {
        this.FShowID = window.setTimeout(rtl.createSafeCallback(this,"WaitDisplayed"),100);
      };
      if (this.FTimeOut > 0) {
        this.FHideID = window.setTimeout(rtl.createSafeCallback(this,"WaitHide"),this.FTimeOut);
      };
    };
    this.Hide$1 = function () {
      if (this.FIsWaiting) document.body.removeChild(this.FLayer$1);
      this.FIsWaiting = false;
      if (this.FShowID > 0) window.clearTimeout(this.FShowID);
      if (this.FHideID > 0) window.clearTimeout(this.FHideID);
      this.FControlCreated = false;
      this.FContainer = null;
      this.FShowID = 0;
      this.FHideID = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Opacity",0,rtl.double,"FOpacity","FOpacity");
    $r.addProperty("Picture",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPicture","SetPicture");
    $r.addProperty("PictureURL",2,rtl.string,"FPictureURL","SetPictureURL");
    $r.addProperty("TimeOut",0,rtl.longint,"FTimeOut","FTimeOut");
    $r.addProperty("OnHide",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHide","FOnHide");
    $r.addProperty("OnShow",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnShow","FOnShow");
  });
  rtl.createClass(this,"TWebWaitMessage",this.TWaitMessage,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TFilesDroppedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileList",pas.Classes.$rtti["TStringList"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsBase64Event",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["ABase64",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsDataURLEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AURL",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsArrayBufferEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["ABuffer",pas["WEBLib.Controls"].$rtti["TJSArrayBufferRecord"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsStreamEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AStream",pas.Classes.$rtti["TStream"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadResponseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["ARequest",pas["WEBLib.Controls"].$rtti["TJSXMLHttpRequestRecord"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AError",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadProgressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["APosition",rtl.longint],["ATotalSize",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsBase64",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABase64",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsText",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsURL",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AURL",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsArrayBuffer",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABuffer",pas["WEBLib.Controls"].$rtti["TJSArrayBufferRecord"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsStream",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AStream",pas.Classes.$rtti["TStream"]]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TGetAsStringProc",{procsig: rtl.newTIProcSig([["AValue",rtl.string]])});
  this.$rtti.$RefToProcVar("TGetAsArrayBufferProc",{procsig: rtl.newTIProcSig([["AValue",pas.JS.$rtti["TJSArrayBuffer"]]])});
  this.$rtti.$RefToProcVar("TGetAsStreamProc",{procsig: rtl.newTIProcSig([["AStream",pas.Classes.$rtti["TStream"]]])});
  rtl.createClass(this,"TFile",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FReq = null;
      this.FModified = 0.0;
      this.FName = "";
      this.FMimeType = "";
      this.FSize = 0;
      this.FFileObject = null;
      this.FTag = 0;
      this.FObject = null;
      this.FOnGetFileAsBase64 = null;
      this.FOnGetFileAsArrayBuffer = null;
      this.FOnGetFileAsText = null;
      this.FOnGetFileAsURL = null;
      this.FOnGetFileAsStream = null;
      this.FGetAsString = null;
      this.FGetAsStream = null;
      this.FGetAsArrayBuffer = null;
    };
    this.$final = function () {
      this.FReq = undefined;
      this.FFileObject = undefined;
      this.FObject = undefined;
      this.FOnGetFileAsBase64 = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnGetFileAsText = undefined;
      this.FOnGetFileAsURL = undefined;
      this.FOnGetFileAsStream = undefined;
      this.FGetAsString = undefined;
      this.FGetAsStream = undefined;
      this.FGetAsArrayBuffer = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.HandleFileLoadAsText = function (Event) {
      var Result = false;
      var s = "";
      var ctrl = null;
      Result = true;
      s = Event.target.result;
      if (this.FGetAsString != null) this.FGetAsString(s);
      this.FGetAsString = null;
      if (this.FOnGetFileAsText != null) this.FOnGetFileAsText(this,s);
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnFileAsText != null)) rtl.as(ctrl,$mod.TFilePicker).FOnFileAsText(ctrl,this.GetIndex(),s);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnFileAsText != null)) rtl.as(ctrl,$mod.TFileUpload).FOnFileAsText(ctrl,this.GetIndex(),s);
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsText != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsText(ctrl,this.GetIndex(),s);
      };
      return Result;
    };
    this.HandleFileLoadAsBase64 = function (Event) {
      var Result = false;
      var s = "";
      var ctrl = null;
      Result = true;
      function _arrayBufferToBase64( buffer ) {
      var binary = '';
      var bytes = new Uint8Array( buffer );
      var len = bytes.byteLength;
      for (var i = 0; i < len; i++) {
          binary += String.fromCharCode( bytes[ i ] );
      }
      return window.btoa( binary );
      }
      s = _arrayBufferToBase64(Event.target.result);
      if (this.FGetAsString != null) this.FGetAsString(s);
      this.FGetAsString = null;
      if (this.FOnGetFileAsBase64 != null) this.FOnGetFileAsBase64(this,s);
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnFileAsBase64 != null)) rtl.as(ctrl,$mod.TFilePicker).FOnFileAsBase64(ctrl,this.GetIndex(),s);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnFileAsBase64 != null)) rtl.as(ctrl,$mod.TFileUpload).FOnFileAsBase64(ctrl,this.GetIndex(),s);
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsBase64 != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsBase64(ctrl,this.GetIndex(),s);
      };
      return Result;
    };
    this.HandleFileLoadAsArrayBuffer = function (Event) {
      var Result = false;
      var ja = null;
      var LJARec = pas["WEBLib.Controls"].TJSArrayBufferRecord.$new();
      var ctrl = null;
      Result = true;
      ja = Event.target.result;
      if (this.FGetAsArrayBuffer != null) {
        this.FGetAsArrayBuffer(ja);
      };
      this.FGetAsArrayBuffer = null;
      if (this.FOnGetFileAsArrayBuffer != null) {
        LJARec.jsarraybuffer = ja;
        this.FOnGetFileAsArrayBuffer(this,pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
      };
      ctrl = this.GetControl();
      if (ctrl != null) {
        LJARec.jsarraybuffer = ja;
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsArrayBuffer != null)) rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsArrayBuffer(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsArrayBuffer != null)) rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsArrayBuffer(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsArrayBuffer != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsArrayBuffer(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
      };
      return Result;
    };
    this.HandleFileLoadAsDataURL = function (Event) {
      var Result = false;
      var s = "";
      var ctrl = null;
      Result = true;
      s = Event.target.result;
      if (this.FGetAsString != null) this.FGetAsString(s);
      this.FGetAsString = null;
      if (this.FOnGetFileAsURL != null) this.FOnGetFileAsURL(this,s);
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnFileAsDataURL != null)) rtl.as(ctrl,$mod.TFilePicker).FOnFileAsDataURL(ctrl,this.GetIndex(),s);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnFileAsDataURL != null)) rtl.as(ctrl,$mod.TFileUpload).FOnFileAsDataURL(ctrl,this.GetIndex(),s);
        if ($mod.TWebOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TWebOpenDialog).FOnFileAsDataURL != null)) rtl.as(ctrl,$mod.TWebOpenDialog).FOnFileAsDataURL(ctrl,this.GetIndex(),s);
      };
      return Result;
    };
    this.HandleFileLoadAsStream = function (Event) {
      var Result = false;
      var ctrl = null;
      var b = [];
      var l = 0;
      var ms = null;
      var ja = null;
      Result = true;
      ja = Event.target.result;
      b = pas.Classes.TMemoryStream.MemoryToBytes(ja);
      l = ja.byteLength;
      ms = pas.Classes.TMemoryStream.$create("Create");
      ms.Write$1(b,0,l);
      ms.SetPosition(0);
      if (this.FGetAsStream != null) {
        this.FGetAsStream(ms);
      };
      this.FGetAsStream = null;
      if (this.FOnGetFileAsStream != null) {
        this.FOnGetFileAsStream(this,ms);
      };
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsStream != null)) rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsStream(ctrl,this.GetIndex(),ms);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsStream != null)) rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsStream(ctrl,this.GetIndex(),ms);
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsStream != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsStream(ctrl,this.GetIndex(),ms);
      };
      ms = rtl.freeLoc(ms);
      return Result;
    };
    this.HandleFileUploadProgress = function (Event) {
      var Result = false;
      var Lloaded = 0;
      var Ltotal = 0;
      var ctrl = null;
      Lloaded = 0;
      Ltotal = 0;
      if (Event.lengthComputable) {
         Lloaded = Event.loaded;
         Ltotal = Event.total;
         //console.log(Event.loaded + " bytes of " + Event.total); } else { console.log('no calc');
      };
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(this.GetControl(),$mod.TFilePicker).FOnUploadFileProgress != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileProgress(ctrl,this.GetIndex(),Lloaded,Ltotal);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(this.GetControl(),$mod.TFileUpload).FOnUploadFileProgress != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileProgress(ctrl,this.GetIndex(),Lloaded,Ltotal);
      };
      Result = true;
      return Result;
    };
    this.HandleFileUploadComplete = function (Event) {
      var Result = false;
      var ctrl = null;
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      var AResponse = "";
      Result = true;
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileComplete != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileComplete(ctrl,this.GetIndex());
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileResponseComplete != null)) {
          LRequestRec.req = Event.target;
          AResponse = Event.target.responseText;
          rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileResponseComplete(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),AResponse);
        };
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileComplete != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileComplete(ctrl,this.GetIndex());
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileResponseComplete != null)) {
          LRequestRec.req = Event.target;
          AResponse = Event.target.responseText;
          rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileResponseComplete(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),AResponse);
        };
      };
      this.FReq = null;
      return Result;
    };
    this.HandleFileUploadError = function (Event) {
      var Result = false;
      var err = "";
      var ctrl = null;
      err = Event.target.status;
      Result = true;
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileError != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileError(ctrl,this.GetIndex(),err);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileError != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileError(ctrl,this.GetIndex(),err);
      };
      return Result;
    };
    this.HandleFileUploadAbort = function (Event) {
      var Result = false;
      var ctrl = null;
      Result = true;
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileAbort != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileAbort(ctrl,this.GetIndex());
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileAbort != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileAbort(ctrl,this.GetIndex());
      };
      return Result;
    };
    this.GetControl = function () {
      var Result = null;
      Result = null;
      if ((this.FCollection != null) && (rtl.as(this.FCollection,$mod.TFiles).Owner$1() != null)) {
        if (pas.Classes.TComponent.isPrototypeOf(rtl.as(this.FCollection,$mod.TFiles).Owner$1())) Result = rtl.as(rtl.as(this.FCollection,$mod.TFiles).Owner$1(),pas.Classes.TComponent);
      };
      return Result;
    };
    this.FileAsText = function () {
      var Result = null;
      Result = this.FileAsText$1("utf-8");
      return Result;
    };
    this.FileAsText$1 = function (AEncoding) {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          ASuccess($impl.EventResult(Event));
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsText($Self.FFileObject,AEncoding);
      });
      return Result;
    };
    this.FileAsBase64 = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var s = "";
          function _arrayBufferToBase64( buffer ) {
          var binary = '';
          var bytes = new Uint8Array( buffer );
          var len = bytes.byteLength;
          for (var i = 0; i < len; i++) {
              binary += String.fromCharCode( bytes[ i ] );
          }
          return window.btoa( binary );
          }
          s = _arrayBufferToBase64(Event.target.result);
          ASuccess(s);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsArrayBuffer($Self.FFileObject);
      });
      return Result;
    };
    this.FileAsStream = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var ms = null;
          var ja = null;
          var b = [];
          var l = 0;
          ja = Event.target.result;
          b = pas.Classes.TMemoryStream.MemoryToBytes(ja);
          l = ja.byteLength;
          ms = pas.Classes.TMemoryStream.$create("Create");
          ms.Write$1(b,0,l);
          ms.SetPosition(0);
          ASuccess(ms);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsArrayBuffer($Self.FFileObject);
      });
      return Result;
    };
    this.FileAsDataURL = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var s = "";
          s = Event.target.result;
          ASuccess(s);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsDataURL($Self.FFileObject);
      });
      return Result;
    };
    this.FileAsArrayBuffer = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var arr = null;
          arr = Event.target.result;
          ASuccess(arr);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsArrayBuffer($Self.FFileObject);
      });
      return Result;
    };
    this.GetFileAsText = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsText");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsText(f);
    };
    this.GetFileAsText$1 = function (GetAsString) {
      this.FGetAsString = GetAsString;
      this.GetFileAsText();
    };
    this.GetFileAsText$2 = function (AEncoding) {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsText");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsText(f, AEncoding);
    };
    this.GetFileAsBase64 = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsBase64");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsArrayBuffer(f);
    };
    this.GetFileAsBase64$1 = function (GetAsString) {
      this.FGetAsString = GetAsString;
      this.GetFileAsBase64();
    };
    this.GetFileAsArrayBuffer = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsArrayBuffer");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsArrayBuffer(f);
    };
    this.GetFileAsArrayBuffer$1 = function (GetAsArrayBuffer) {
      this.FGetAsArrayBuffer = GetAsArrayBuffer;
      this.GetFileAsArrayBuffer();
    };
    this.GetFileAsStream = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsStream");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsArrayBuffer(f);
    };
    this.GetFileAsStream$1 = function (GetAsStream) {
      this.FGetAsStream = GetAsStream;
      this.GetFileAsStream();
    };
    this.GetFileAsDataURL = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsDataURL");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsDataURL(f);
    };
    this.GetFileAsDataURL$1 = function (GetAsString) {
      this.FGetAsString = GetAsString;
      this.GetFileAsDataURL();
    };
    this.Upload = function (AAction) {
      var f = null;
      var fd = null;
      var ptrProgress = null;
      var ptrComplete = null;
      var ptrError = null;
      var ptrAbort = null;
      f = this.FFileObject;
      fd = new FormData();
      fd.append("file1",f);
      this.FReq = new XMLHttpRequest();
      ptrProgress = rtl.createCallback(this,"HandleFileUploadProgress");
      ptrComplete = rtl.createCallback(this,"HandleFileUploadComplete");
      ptrError = rtl.createCallback(this,"HandleFileUploadError");
      ptrAbort = rtl.createCallback(this,"HandleFileUploadAbort");
      this.FReq.addEventListener("load",ptrComplete);
      this.FReq.addEventListener("error",ptrError);
      this.FReq.addEventListener("abort",ptrAbort);
      this.FReq.upload.addEventListener("progress",ptrProgress);
      this.FReq.open("POST",AAction,true);
      this.FReq.send(fd);
    };
    this.AbortUpload = function () {
      var Result = false;
      Result = false;
      if (this.FReq != null) {
        this.FReq.abort();
        Result = true;
      };
      return Result;
    };
  });
  this.$rtti.$Class("TFilePicker");
  rtl.createClass(this,"TFiles",pas.Classes.TCollection,function () {
    this.$init = function () {
      pas.Classes.TCollection.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$2 = function (AOwner) {
      pas.Classes.TCollection.Create$1.call(this,$mod.TFile);
      this.FOwner = AOwner;
      return this;
    };
    this.Owner$1 = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.Clear$1 = function () {
      var fc = 0;
      fc = this.GetCount();
      pas.Classes.TCollection.Clear.call(this);
      if (fc > 0) {
        if ($mod.TFilePicker.isPrototypeOf(this.FOwner)) rtl.as(this.FOwner,$mod.TFilePicker).Clear();
        if ($mod.TFileUpload.isPrototypeOf(this.FOwner)) rtl.as(this.FOwner,$mod.TFileUpload).Clear();
      };
    };
  });
  rtl.createClass(this,"TFileUpload",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FAccept = "";
      this.FCreateRef = "";
      this.FEventInit = false;
      this.FFiles = null;
      this.FFileList = null;
      this.FOnDroppedFiles = null;
      this.FMultiFile = false;
      this.FShowFiles = false;
      this.FDragCaption = "";
      this.FOnGetFileAsArrayBuffer = null;
      this.FOnFileAsText = null;
      this.FOnFileAsBase64 = null;
      this.FOnFileAsDataURL = null;
      this.FOnUploadFileAbort = null;
      this.FOnUploadFileComplete = null;
      this.FOnUploadFileProgress = null;
      this.FOnUploadFileError = null;
      this.FOnUploadFileResponseComplete = null;
      this.FOnGetFileAsStream = null;
      this.FFontHoverColor = 0;
      this.FShowPicture = false;
      this.FDragColor = 0;
    };
    this.$final = function () {
      this.FFiles = undefined;
      this.FFileList = undefined;
      this.FOnDroppedFiles = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnFileAsText = undefined;
      this.FOnFileAsBase64 = undefined;
      this.FOnFileAsDataURL = undefined;
      this.FOnUploadFileAbort = undefined;
      this.FOnUploadFileComplete = undefined;
      this.FOnUploadFileProgress = undefined;
      this.FOnUploadFileError = undefined;
      this.FOnUploadFileResponseComplete = undefined;
      this.FOnGetFileAsStream = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetDragCaption = function (Value) {
      this.FDragCaption = Value;
      this.UpdateElement();
    };
    this.SetAccept = function (Value) {
      if (this.FAccept !== Value) {
        this.FAccept = Value;
        this.UpdateElement();
      };
    };
    this.SetShowPicture = function (Value) {
      if (this.FShowPicture !== Value) {
        this.FShowPicture = Value;
        this.UpdateElement();
      };
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElement();
      };
    };
    this.HandleFiles = function (files) {
      var Result = "";
      var i = 0;
      var sz = 0;
      var afile = null;
      var szFiles = "";
      var m = "";
      var d = null;
      szFiles = "";
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
      while (this.FFileList.GetCount() > 0) this.FFileList.Delete(0);
      for (var $l = 0, $end = files.length - 1; $l <= $end; $l++) {
        i = $l;
        afile = files.item(i);
        d = new Date(afile.lastModified);
        m = afile.type;
        sz = afile.size;
        var $with = this.FFiles.Add$1();
        $with.FFileObject = afile;
        $with.FName = afile.name;
        $with.FMimeType = m;
        $with.FSize = sz;
        $with.FModified = pas.SysUtils.EncodeDate(d.getYear() + 1900,d.getMonth() + 1,d.getDate()) + pas.SysUtils.EncodeTime(d.getHours(),d.getMinutes(),d.getSeconds(),d.getMilliseconds());
        if (this.FFileList != null) this.FFileList.Add(afile.name);
        if (this.FShowFiles) {
          if (i > 0) szFiles = szFiles + "<br>";
          szFiles = szFiles + afile.name;
        };
        if (!this.FMultiFile) break;
      };
      Result = szFiles;
      if (this.FOnDroppedFiles != null) this.FOnDroppedFiles(this,this.FFileList);
      return Result;
    };
    this.DoHandleChange = function (e) {
      var Result = false;
      var el = null;
      var span = null;
      var curfiles = null;
      var szfiles = "";
      Result = true;
      if (this.GetElementHandle() != null) {
        el = e.target;
        if (el != null) {
          curfiles = el.files;
          szfiles = this.HandleFiles(curfiles);
          if (this.FShowFiles) {
            span = document.getElementById(this.GetID() + "fileslist");
            span.innerHTML = szfiles;
          };
        };
      };
      return Result;
    };
    this.HandleDroppedFiles = function (Event) {
      var Result = false;
      var droppedfiles = null;
      var span = null;
      var szFiles = "";
      var AEvent = null;
      Result = true;
      AEvent = Event;
      AEvent.preventDefault();
      AEvent.stopPropagation();
      droppedfiles = AEvent.dataTransfer.files;
      szFiles = this.HandleFiles(droppedfiles);
      if (this.FShowFiles) {
        span = document.getElementById(this.GetID() + "fileslist");
        span.innerHTML = szFiles;
      };
      this.GetContainer().setAttribute("class","box has-advanced-upload");
      return Result;
    };
    this.HandleDragOver = function (Event) {
      var Result = false;
      Result = true;
      Event.preventDefault();
      Event.stopPropagation();
      if (this.GetContainer() != null) this.GetContainer().setAttribute("class","box has-advanced-upload is-dragover");
      if ((this.GetElementHandle() != null) && (this.FDragColor !== -1)) this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FDragColor));
      return Result;
    };
    this.HandleDragEnd = function (Event) {
      var Result = false;
      Result = true;
      Event.preventDefault();
      Event.stopPropagation();
      if (this.GetContainer() != null) this.GetContainer().setAttribute("class","box has-advanced-upload");
      if (this.GetElementHandle() != null) {
        if ((this.FColor !== -1) && (this.FDragColor !== -1)) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.GetElementHandle().style.removeProperty("background-color");
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      this.CreateCSS();
      this.FCreateRef = this.FName;
      Result = document.createElement("FORM");
      Result.setAttribute("method","post");
      Result.setAttribute("class","box");
      Result.setAttribute("enctype","multipart/form-data");
      Result.style.setProperty("display","flex");
      Result.style.setProperty("justify-content","center");
      Result.style.setProperty("align-items","center");
      Result.innerHTML = '<div class="box__input" style="text-align: center">' + '<svg class="box__icon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43">' + '<path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z"/></svg>' + '<input class="box__file" type="file" name="files[]" id="FP' + this.FName + '" data-multiple-caption="{count} files selected" multiple/>' + '<label for="FP' + this.FName + '" style="outline:none"><strong id="' + this.FName + 'lbl">' + this.FCaption + '</strong>&nbsp;<span class="box__dragndrop" id="' + this.FName + 'drag">' + this.FDragCaption + "</span>.</label>" + '<button class="box__button" type="submit">Upload</button>' + '<br><span style="display:inline-block;" id="' + this.FName + 'fileslist"></span>' + '</div><div class="box__uploading">Uploading&hellip;</div>';
      Result.addEventListener("drop",rtl.createSafeCallback(this,"HandleDroppedFiles"));
      Result.addEventListener("dragenter",rtl.createSafeCallback(this,"HandleDragOver"));
      Result.addEventListener("dragover",rtl.createSafeCallback(this,"HandleDragOver"));
      Result.addEventListener("dragend",rtl.createSafeCallback(this,"HandleDragEnd"));
      Result.addEventListener("dragleave",rtl.createSafeCallback(this,"HandleDragEnd"));
      if ($impl.isAdvancedUpload()) Result.classList.add("has-advanced-upload");
      return Result;
    };
    this.UpdateElement = function () {
      var el = null;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      this.CreateCSS();
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("display","flex");
        el = this.GetElementHandle().children.item(0);
        el = el.children.item(0);
        if (!this.FShowPicture) {
          el.style.setProperty("display","none")}
         else el.style.removeProperty("display");
        if (this.FElementFont !== pas["WEBLib.Controls"].TElementFont.efCSS) {
          el.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor))}
         else el.style.removeProperty("color");
        el = document.getElementById("FP" + this.FCreateRef);
        if (el != null) {
          if (!this.FEventInit) {
            this.FEventInit = true;
            el.addEventListener("change",rtl.createSafeCallback(this,"DoHandleChange"));
          };
          if (this.FMultiFile) {
            el.setAttribute("multiple","")}
           else el.removeAttribute("multiple");
          if (this.FAccept !== "") {
            el.setAttribute("accept",this.FAccept)}
           else el.removeAttribute("accept");
        };
        el = document.getElementById(this.FCreateRef + "lbl");
        if (el != null) {
          el.innerHTML = this.FCaption;
        };
        el = document.getElementById(this.FCreateRef + "drag");
        if (el != null) {
          el.innerHTML = this.FDragCaption;
        };
      };
    };
    this.ColorChanging = function () {
      pas["WEBLib.Controls"].TControl.ColorChanging.call(this);
      this.UpdateElement();
    };
    this.CreateCSS = function () {
      this.AddControlStyle("  \t.box" + "\t\t\t{" + " \t\t\tposition: relative;" + "\t    \tpadding: 2px 2px;" + "\t\t}" + "\t\t.box.has-advanced-upload" + "\t\t{" + "\t\t\toutline: 2px dashed #92b0b3;" + "\t\t\toutline-offset: -10px;" + "\t\t\t-webkit-transition: outline-offset .15s ease-in-out, background-color .15s linear;" + "\t\t\ttransition: outline-offset .15s ease-in-out, background-color .15s linear;" + "\t\t}" + "\t\t.box.is-dragover" + "\t\t{" + "\t\t\toutline-offset: -20px;" + "\t\t\toutline-color: #c8dadf;" + "\t\t\tbackground-color: #fff;" + "\t\t}" + "\t\t\t.box__dragndrop," + "\t\t\t.box__icon" + "\t\t\t{" + "\t\t\t\tdisplay: none;" + "\t\t\t}" + "\t\t\t.box.has-advanced-upload .box__dragndrop" + "\t\t\t{" + "\t\t\t\tdisplay: inline;" + "\t\t\t}" + "\t\t\t.box.has-advanced-upload .box__icon" + "\t\t\t{" + "\t\t\t\twidth: 100%;" + "\t\t\t\theight: 80px;" + "\t\t\t\tfill: #92b0b3;" + "\t\t\t\tdisplay: block;" + "\t\t\t\tmargin-bottom: 40px;" + "\t\t\t}" + "\t\t\t.box.is-uploading .box__input," + "\t\t\t.box.is-success .box__input," + "\t\t\t.box.is-error .box__input" + "\t\t\t{" + "\t\t\t\tvisibility: hidden;" + "\t\t\t}" + "\t\t\t.box__uploading," + "\t\t\t.box__success," + "\t\t\t.box__error" + "\t\t\t{" + "\t\t\tdisplay: none;" + "\t\t\t}" + "\t\t\t.box.is-uploading .box__uploading," + "\t\t\t.box.is-success .box__success," + "\t\t\t.box.is-error .box__error" + "\t\t\t{" + "\t\t\t\tdisplay: block;" + "\t\t\t\tposition: absolute;" + "\t\t\t\ttop: 50%;" + "       right: 0;" + "\t\t\t\tleft: 0;" + "\t   \t\t-webkit-transform: translateY( -50% );" + "\t\t\t\t\ttransform: translateY( -50% );" + "\t\t\t\t}" + "\t\t\t\t.box__uploading" + "\t\t\t\t{" + "\t\t\t\t\tfont-style: italic;" + "\t\t\t\t}" + "\t\t\t\t.box__success" + "\t\t\t\t{" + "\t\t\t\t\t-webkit-animation: appear-from-inside .25s ease-in-out;" + "\t\t\t\t\tanimation: appear-from-inside .25s ease-in-out;" + "\t\t\t\t}" + "\t\t\t\t\t@-webkit-keyframes appear-from-inside" + "\t\t\t\t\t{" + "\t\t\t\t\t\tfrom\t{ -webkit-transform: translateY( -50% ) scale( 0 ); }" + "\t\t\t\t\t\t75%\t\t{ -webkit-transform: translateY( -50% ) scale( 1.1 ); }" + "\t\t\t\t\t\tto\t\t{ -webkit-transform: translateY( -50% ) scale( 1 ); }" + "\t\t\t\t\t}" + "\t\t\t\t\t@keyframes appear-from-inside" + "\t\t\t\t\t{" + "\t\t\t\t\t\tfrom\t{ transform: translateY( -50% ) scale( 0 ); }" + "\t\t\t\t\t\t75%\t\t{ transform: translateY( -50% ) scale( 1.1 ); }" + "\t\t\t\t\t\tto\t\t{ transform: translateY( -50% ) scale( 1 ); }" + "\t\t\t\t\t}" + "\t\t\t\t.box__restart" + "\t\t\t\t{" + "\t\t\t\t\tfont-weight: 700;" + "\t\t\t\t}" + "\t\t\t\t.box__restart:focus," + "\t\t\t\t.box__restart:hover" + "\t\t\t\t{" + "\t\t\t\t\tcolor: " + pas["WEBLib.Graphics"].ColorToHTML(this.FFontHoverColor) + ";" + "\t\t\t\t}" + "\t\t\t\t.box__file" + "\t\t\t\t{" + "\t\t\t\t\twidth: 0.1px;" + "\t\t\t\t\theight: 0.1px;" + "\t\t\t\t\topacity: 0;" + "\t\t\t\t\toverflow: hidden;" + "\t\t\t\t\tposition: absolute;" + "\t\t\t\t\tz-index: -1;" + "\t\t\t\t}" + "\t\t\t\t.box__file + label" + "\t\t\t\t{" + "\t\t\t\t\ttext-overflow: ellipsis;" + "\t\t\t\t\twhite-space: nowrap;" + "\t\t\t\t\tcursor: pointer;" + "\t\t\t\t\tdisplay: inline-block;" + "\t\t\t\t\toverflow: hidden;" + "\t\t\t\t}" + "\t\t\t\t.box__file + label:hover strong," + "\t\t\t\t.box__file:focus + label strong," + "\t\t\t\t.box__file.has-focus + label strong" + "\t\t\t\t{" + "\t\t\t\t\tcolor: " + pas["WEBLib.Graphics"].ColorToHTML(this.FFontHoverColor) + ";" + "\t\t\t\t}" + "\t\t\t\t.box__file:focus + label," + "\t\t\t\t.box__file.has-focus + label" + "\t\t\t\t{" + " \t\t\t\toutline: 1px dotted #000;" + "\t\t\t\t\toutline: -webkit-focus-ring-color auto 5px;" + "\t\t\t\t}" + "\t\t\t\t.box__button" + "\t\t\t\t{" + "\t\t\t\t\tfont-weight: 700;" + "\t\t\t\t\tcolor: #e5edf1;" + "\t\t\t\t\tbackground-color: #39bfd3;" + "\t\t\t\t\tdisplay: none;" + "\t\t\t\t\tpadding: 8px 16px;" + "\t\t\t\t\tmargin: 10px auto 0;" + "\t\t\t\t}" + "\t\t\t\t\t.box__button:hover," + "\t\t\t\t\t.box__button:focus" + "\t\t\t\t\t{" + "\t\t\t\t\t\tbackground-color: #0f3c4b;" + "\t\t\t\t\t}");
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.SetColor(0xDFDAC8);
      this.FFontHoverColor = 0xd3bf39;
      this.SetCaption("Choose a file");
      this.FDragCaption = "or drag it here";
      this.FDragColor = -1;
      this.FShowPicture = true;
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      this.FFileList = pas.Classes.TStringList.$create("Create$1");
      this.FFileList.SetSkipLastLineBreak(true);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFiles");
      rtl.free(this,"FFileList");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FMultiFile = false;
      this.FShowFiles = false;
      this.FEventInit = false;
      this.SetWidth(170);
      this.SetHeight(190);
    };
    this.Clear = function () {
      var el = null;
      el = document.getElementById("FP" + this.GetID());
      if (el != null) {
        el.setAttribute("type","");
        el.setAttribute("type","file");
      };
      el = document.getElementById(this.GetID() + "fileslist");
      if (el != null) {
        el.innerHTML = "";
      };
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Accept",2,rtl.string,"FAccept","SetAccept");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 14670536});
    $r.addProperty("DragCaption",2,rtl.string,"FDragCaption","SetDragCaption");
    $r.addProperty("DragColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FDragColor","FDragColor",4,{Default: -1});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("FontHoverColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FFontHoverColor","FFontHoverColor",4,{Default: 13877049});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Multifile",0,rtl.boolean,"FMultiFile","FMultiFile",4,{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ShowFiles",0,rtl.boolean,"FShowFiles","FShowFiles",4,{Default: false});
    $r.addProperty("ShowPicture",2,rtl.boolean,"FShowPicture","SetShowPicture",4,{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDroppedFiles",0,$mod.$rtti["TFilesDroppedEvent"],"FOnDroppedFiles","FOnDroppedFiles");
    $r.addProperty("OnGetFileAsText",0,$mod.$rtti["TFileAsTextEvent"],"FOnFileAsText","FOnFileAsText");
    $r.addProperty("OnGetFileAsArrayBuffer",0,$mod.$rtti["TFileAsArrayBufferEvent"],"FOnGetFileAsArrayBuffer","FOnGetFileAsArrayBuffer");
    $r.addProperty("OnGetFileAsStream",0,$mod.$rtti["TFileAsStreamEvent"],"FOnGetFileAsStream","FOnGetFileAsStream");
    $r.addProperty("OnGetFileAsBase64",0,$mod.$rtti["TFileAsBase64Event"],"FOnFileAsBase64","FOnFileAsBase64");
    $r.addProperty("OnGetFileAsDataURL",0,$mod.$rtti["TFileAsDataURLEvent"],"FOnFileAsDataURL","FOnFileAsDataURL");
    $r.addProperty("OnUploadFileComplete",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileComplete","FOnUploadFileComplete");
    $r.addProperty("OnUploadFileResponseComplete",0,$mod.$rtti["TFileUploadResponseEvent"],"FOnUploadFileResponseComplete","FOnUploadFileResponseComplete");
    $r.addProperty("OnUploadFileAbort",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileAbort","FOnUploadFileAbort");
    $r.addProperty("OnUploadFileError",0,$mod.$rtti["TFileUploadErrorEvent"],"FOnUploadFileError","FOnUploadFileError");
    $r.addProperty("OnUploadFileProgress",0,$mod.$rtti["TFileUploadProgressEvent"],"FOnUploadFileProgress","FOnUploadFileProgress");
  });
  rtl.createClass(this,"TWebFileUpload",this.TFileUpload,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TFilePicker",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FOnChange = null;
      this.FMultiFile = false;
      this.FFiles = null;
      this.FOnFileAsText = null;
      this.FOnGetFileAsArrayBuffer = null;
      this.FAccept = "";
      this.FOnFileAsBase64 = null;
      this.FChangePtr = null;
      this.FOnFileAsDataURL = null;
      this.FOnUploadFileAbort = null;
      this.FOnUploadFileComplete = null;
      this.FOnUploadFileProgress = null;
      this.FOnUploadFileError = null;
      this.FOnUploadFileResponseComplete = null;
      this.FOnGetFileAsStream = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FFiles = undefined;
      this.FOnFileAsText = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnFileAsBase64 = undefined;
      this.FOnFileAsDataURL = undefined;
      this.FOnUploadFileAbort = undefined;
      this.FOnUploadFileComplete = undefined;
      this.FOnUploadFileProgress = undefined;
      this.FOnUploadFileError = undefined;
      this.FOnUploadFileResponseComplete = undefined;
      this.FOnGetFileAsStream = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetMultiFile = function (Value) {
      if (this.FMultiFile !== Value) {
        this.FMultiFile = Value;
        this.UpdateElement();
      };
    };
    this.DoHandleChange = function (e) {
      var Result = false;
      var i = 0;
      var l = 0;
      var sz = 0;
      var eh = null;
      var s = "";
      var m = "";
      var f = null;
      var d = null;
      var jsfile = null;
      Result = true;
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
      eh = this.GetElementHandle();
      var curFiles = eh.files;
      l = curFiles.length;
      for (var $l = 0, $end = l - 1; $l <= $end; $l++) {
        i = $l;
        f = this.FFiles.Add$1();
        jsfile = curFiles[i];
        s = curFiles[i].name;
        m = curFiles[i].type;
        sz = curFiles[i].size;
        d = new Date(curFiles[i].lastModified);
        f.FFileObject = jsfile;
        f.FName = s;
        f.FMimeType = m;
        f.FSize = sz;
        f.FModified = pas.SysUtils.EncodeDate(d.getFullYear(),d.getMonth() + 1,d.getDate()) + pas.SysUtils.EncodeTime(d.getHours(),d.getMinutes(),d.getSeconds(),d.getMilliseconds());
      };
      if (this.FOnChange != null) this.FOnChange(this);
      return Result;
    };
    this.SetAccept = function (Value) {
      if (this.FAccept !== Value) {
        this.FAccept = Value;
        this.UpdateElement();
      };
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        if (this.FMultiFile) {
          this.GetElementHandle().setAttribute("multiple","")}
         else this.GetElementHandle().removeAttribute("multiple");
        if (this.FAccept !== "") {
          this.GetElementHandle().setAttribute("accept",this.FAccept)}
         else this.GetElementHandle().removeAttribute("accept");
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("INPUT");
      Result.setAttribute("type","file");
      return Result;
    };
    this.GetMethodPointers = function () {
      if (this.FChangePtr === null) {
        this.FChangePtr = rtl.createCallback(this,"DoHandleChange");
        pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      };
    };
    this.BindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.addEventListener("change",rtl.createSafeCallback(this,"DoHandleChange"));
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      this.SetWidth(160);
      this.SetHeight(40);
    };
    this.Destroy = function () {
      rtl.free(this,"FFiles");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.GetElementHandle().setAttribute("type","");
      this.GetElementHandle().setAttribute("type","file");
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Accept",2,rtl.string,"FAccept","SetAccept");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Multifile",2,rtl.boolean,"FMultiFile","SetMultiFile");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnGetFileAsText",0,$mod.$rtti["TFileAsTextEvent"],"FOnFileAsText","FOnFileAsText");
    $r.addProperty("OnGetFileAsArrayBuffer",0,$mod.$rtti["TFileAsArrayBufferEvent"],"FOnGetFileAsArrayBuffer","FOnGetFileAsArrayBuffer");
    $r.addProperty("OnGetFileAsBase64",0,$mod.$rtti["TFileAsBase64Event"],"FOnFileAsBase64","FOnFileAsBase64");
    $r.addProperty("OnGetFileAsDataURL",0,$mod.$rtti["TFileAsDataURLEvent"],"FOnFileAsDataURL","FOnFileAsDataURL");
    $r.addProperty("OnGetFileAsStream",0,$mod.$rtti["TFileAsStreamEvent"],"FOnGetFileAsStream","FOnGetFileAsStream");
    $r.addProperty("OnUploadFileComplete",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileComplete","FOnUploadFileComplete");
    $r.addProperty("OnUploadFileResponseComplete",0,$mod.$rtti["TFileUploadResponseEvent"],"FOnUploadFileResponseComplete","FOnUploadFileResponseComplete");
    $r.addProperty("OnUploadFileAbort",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileAbort","FOnUploadFileAbort");
    $r.addProperty("OnUploadFileError",0,$mod.$rtti["TFileUploadErrorEvent"],"FOnUploadFileError","FOnUploadFileError");
    $r.addProperty("OnUploadFileProgress",0,$mod.$rtti["TFileUploadProgressEvent"],"FOnUploadFileProgress","FOnUploadFileProgress");
  });
  rtl.createClass(this,"TWebFilePicker",this.TFilePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$RefToProcVar("TOpenDialogProc",{procsig: rtl.newTIProcSig([["AFileName",rtl.string]])});
  this.TOpenOption = {"0": "ofReadOnly", ofReadOnly: 0, "1": "ofOverwritePrompt", ofOverwritePrompt: 1, "2": "ofHideReadOnly", ofHideReadOnly: 2, "3": "ofNoChangeDir", ofNoChangeDir: 3, "4": "ofShowHelp", ofShowHelp: 4, "5": "ofNoValidate", ofNoValidate: 5, "6": "ofAllowMultiSelect", ofAllowMultiSelect: 6, "7": "ofExtensionDifferent", ofExtensionDifferent: 7, "8": "ofPathMustExist", ofPathMustExist: 8, "9": "ofFileMustExist", ofFileMustExist: 9, "10": "ofCreatePrompt", ofCreatePrompt: 10, "11": "ofShareAware", ofShareAware: 11, "12": "ofNoReadOnlyReturn", ofNoReadOnlyReturn: 12, "13": "ofNoTestFileCreate", ofNoTestFileCreate: 13, "14": "ofNoNetworkButton", ofNoNetworkButton: 14, "15": "ofNoLongNames", ofNoLongNames: 15, "16": "ofOldStyleDialog", ofOldStyleDialog: 16, "17": "ofNoDereferenceLinks", ofNoDereferenceLinks: 17, "18": "ofEnableIncludeNotify", ofEnableIncludeNotify: 18, "19": "ofEnableSizing", ofEnableSizing: 19, "20": "ofDontAddToRecent", ofDontAddToRecent: 20, "21": "ofForceShowHidden", ofForceShowHidden: 21};
  this.$rtti.$Enum("TOpenOption",{minvalue: 0, maxvalue: 21, ordtype: 1, enumtype: this.TOpenOption});
  this.$rtti.$Set("TOpenOptions",{comptype: this.$rtti["TOpenOption"]});
  rtl.createClass(this,"TOpenDialog",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FFiles = null;
      this.FOnChange = null;
      this.FFileName = "";
      this.FMultiFile = false;
      this.FFilter = "";
      this.FAccept = "";
      this.FOpenDialogProc = null;
      this.FOptions = {};
      this.FFilterIndex = 0;
      this.FOnFileAsBase64 = null;
      this.FOnGetFileAsArrayBuffer = null;
      this.FOnFileAsDataURL = null;
      this.FOnFileAsText = null;
      this.FOnGetFileAsStream = null;
    };
    this.$final = function () {
      this.FFiles = undefined;
      this.FOnChange = undefined;
      this.FOpenDialogProc = undefined;
      this.FOptions = undefined;
      this.FOnFileAsBase64 = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnFileAsDataURL = undefined;
      this.FOnFileAsText = undefined;
      this.FOnGetFileAsStream = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.HandleInputChange = function (Event) {
      var i = 0;
      var l = 0;
      var sz = 0;
      var s = "";
      var m = "";
      var f = null;
      var d = null;
      var jsfile = null;
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
      var curFiles = Event.target.files;
      l = curFiles.length;
      for (var $l = 0, $end = l - 1; $l <= $end; $l++) {
        i = $l;
        f = this.FFiles.Add$1();
        jsfile = curFiles[i];
        s = curFiles[i].name;
        m = curFiles[i].type;
        sz = curFiles[i].size;
        d = new Date(curFiles[i].lastModified);
        if (i === 0) this.FFileName = s;
        f.FFileObject = jsfile;
        f.FName = s;
        f.FMimeType = m;
        f.FSize = sz;
        f.FModified = pas.SysUtils.EncodeDate(d.getFullYear(),d.getMonth() + 1,d.getDate()) + pas.SysUtils.EncodeTime(d.getHours(),d.getMinutes(),d.getSeconds(),d.getMilliseconds());
      };
      if (this.FOpenDialogProc != null) this.FOpenDialogProc(this.FFileName);
      this.FOpenDialogProc = null;
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      return this;
    };
    this.Create$3 = function () {
      pas.System.TObject.Create.call(this);
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFiles");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Execute = function () {
      var ic = null;
      var fp = null;
      ic = rtl.createCallback(this,"HandleInputChange");
      fp = document.createElement("input");
      fp.setAttribute("type","file");
      if (this.FMultiFile || ($mod.TOpenOption.ofAllowMultiSelect in this.FOptions)) fp.setAttribute("multiple","");
      if (this.FAccept !== "") fp.setAttribute("accept",this.FAccept);
      fp.addEventListener("change",ic);
      fp.click();
    };
    this.Execute$1 = function (AProc) {
      this.FOpenDialogProc = AProc;
      this.Execute();
    };
    this.Perform = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.Execute$1(function (AFileName) {
          ASuccess(AFileName);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Accept",0,rtl.string,"FAccept","FAccept");
    $r.addProperty("MultiFile",0,rtl.boolean,"FMultiFile","FMultiFile",4,{Default: false});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnGetFileAsText",0,$mod.$rtti["TFileAsTextEvent"],"FOnFileAsText","FOnFileAsText");
    $r.addProperty("OnGetFileAsArrayBuffer",0,$mod.$rtti["TFileAsArrayBufferEvent"],"FOnGetFileAsArrayBuffer","FOnGetFileAsArrayBuffer");
    $r.addProperty("OnGetFileAsStream",0,$mod.$rtti["TFileAsStreamEvent"],"FOnGetFileAsStream","FOnGetFileAsStream");
    $r.addProperty("OnGetFileAsBase64",0,$mod.$rtti["TFileAsBase64Event"],"FOnFileAsBase64","FOnFileAsBase64");
    $r.addProperty("OnGetFileAsDataURL",0,$mod.$rtti["TFileAsDataURLEvent"],"FOnFileAsDataURL","FOnFileAsDataURL");
  });
  rtl.createClass(this,"TWebOpenDialog",this.TOpenDialog,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.MessageDlg = function (Msg, DlgType, Buttons, AResultProc) {
    if (!($impl.WebLibDlg != null)) {
      $impl.WebLibDlg = $mod.TMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibDlg.InitBootstrapStyle();
      };
    };
    $impl.WebLibDlg.ShowDialog$1(Msg,DlgType,rtl.refSet(Buttons),AResultProc);
  };
  this.ShowMessage = function (AMsg) {
    if ((pas["WEBLib.Forms"].Application !== null) && (pas["WEBLib.Forms"].Application.FMainForm !== null) && (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap)) {
      $mod.MessageDlg(AMsg,$mod.TMsgDlgType.mtInformation,rtl.createSet($mod.TMsgDlgBtn.mbOK),null);
    } else {
      alert(AMsg);
    };
  };
  this.MessageDlgAsync = async function (Msg, DlgType, Buttons) {
    var Result = 0;
    if (!($impl.WebLibDlg != null)) {
      $impl.WebLibDlg = $mod.TMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibDlg.InitBootstrapStyle();
      };
    };
    Result = await $impl.WebLibDlg.ShowDialog$2(Msg,DlgType,rtl.refSet(Buttons));
    return Result;
  };
  this.InputBox = function (ACaption, APrompt, ADefault) {
    var Result = "";
    var retvalue = "";
    retvalue = prompt(APrompt, ADefault);
    if (retvalue == null) {
      retvalue = "";
    };
    Result = retvalue;
    return Result;
  };
  this.InputQuery = function (ACaption, APrompt, Value) {
    var Result = false;
    var retvalue = false;
    var s = "";
    retvalue = true;
    s = Value.get();
    var text = s;
    s = prompt(APrompt, text);
    if (s == null) {
      retvalue = false;
    };
    if (retvalue) Value.set(s);
    Result = retvalue;
    return Result;
  };
  this.Confirm = function (Value) {
    var Result = false;
    var res = false;
    res = confirm(Value);
    Result = res;
    return Result;
  };
  this.InputMessageDlg = function (Msg, DlgType, Buttons, AResult, AInputType, AResultProc) {
    function ResultHandler(AModalResult) {
      if (AModalResult !== 2) AResult.set($impl.WebLibInputDlg.GetInputElementValue());
      if (AResultProc != null) AResultProc(AModalResult);
    };
    if (!($impl.WebLibInputDlg != null)) {
      $impl.WebLibInputDlg = $mod.TInputMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibInputDlg.InitBootstrapStyle();
      };
    };
    $impl.WebLibInputDlg.FInputValue = AResult.get();
    $impl.WebLibInputDlg.FInputType = AInputType;
    $impl.WebLibInputDlg.ShowDialog$1(Msg,DlgType,rtl.refSet(Buttons),ResultHandler);
  };
  this.InputMessageDlgAsync = async function (Msg, DlgType, Buttons, AResult, AInputType) {
    var Result = 0;
    if (!($impl.WebLibInputDlg != null)) {
      $impl.WebLibInputDlg = $mod.TInputMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibInputDlg.InitBootstrapStyle();
      };
    };
    $impl.WebLibInputDlg.FInputValue = AResult.get();
    $impl.WebLibInputDlg.FInputType = AInputType;
    Result = await $impl.WebLibInputDlg.ShowDialog$2(Msg,DlgType,rtl.refSet(Buttons));
    AResult.set($impl.WebLibInputDlg.GetInputElementValue());
    return Result;
  };
  $mod.$implcode = function () {
    $impl.lMaterial = "https://fonts.googleapis.com/icon?family=Material+Icons";
    $impl.lWaitCursor = "0954474946496D61676547494638396190012C01A20000FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF21FF0B4E45545343415045322E30030100000021F90405050004002C0000000090012C0182FFFFFFDDDDD" + "DBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF48BADCFE30CA49ABBD38EBCDBBFF60288E64699E68AAAE6CEBBE702CCF746DDF78AEEF7CEFFFC0A070482C1A8FC8A472C96C3A9FD0A8744AAD5AAFD8AC76CBED7ABFE0B078" + "4C2E9BCFE8B47ACD6EBBDFF0B87C4EAFDBEFF8BC7ECFEFFBFF808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC" + "0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF00030A1C48B0A0C18308132A5CC8B0A1C3871023861A407180C4" + "44152B5E349431FFE346421D357E141492E24892254F062A6951E51F962EC978F400D383809B02621E09493365079C387512A9B981A806A040850A319A812906A441950261D95283530B50A34AF541B52A86AB14B26ADDDA836" + "A519F19C4E6243B15AC04B711D4B20D62B629DA0B72E7B6BD5B01EE83BC7A7F74FDCA7782DAB58105FB6DB09801E0C45CEBF62D1CF731E4B28D15642660F93266CA0F3277F6CC43F204D162492F6DDC78B4EA1D834F8376ECFA" + "B50ED31016D7B69D237604BF8779AF9EBD80A7E1D4C24BCCFC803BB44809BB2F04981E20B9F19EC48F22F7409D3AEFE676AF87D8CEA1BB79DB5DBD86EF48827C06F3F0D1A7577F41BC08A8E5E1C77F3DDFE459FFFF2624B5817" + "EFA7DD71F7D4E1058A0700702D884820B26474083081601E17E1216D7A012179E97A103141AD161771FBEB56110237A57A26C070291E2742B5A70220F2FC6B81E78378C682307E9F970E18ED865370384408220240D111669E4" + "733F90A8E493504629E594545669E5955866A9A54014FA960400608629E698648EB955973D7E59E69A6C86A9149AF321D1E69C6C0A05679A46D0A9A7993ADDE925117B060A809D7E6E9683A07BBE59287B6A225AA7548B3229A" + "7A3656E69E9A59866AAE9A69C76EAE9A7A086AAC5728A39E8E99133A06AE59FBDE198259EB0B18A657F91C1BA6A8B9FC5596588A5D22A25AF7BF9AA24B04310BBA2B145206BDD8CFF4928CB1FB34C387B19B44F503BADB0EBA1" + "402A61BAAA862DB79286605F7DDD92662BB8DB32A72A88B226E6AA8CEB5260A873F1129AAE55F3B2382EBEF77AD6EF8DFF6A682ABDFBF25BE1AC8B15CCC0BBA2FEC6B05FED36ECB09009E71B6AC402336AA2C59F32ACD9911E4" + "B3C61662473CC69C8232BCC98C99AA29CB2C6F2B27C29C62BAB5C73BD2D1BAAB3CC5AD27C73C0ECF28C70BCF3BA9C73BDF91A8DA9D22F034D30CC0D33DD74B893E13C34CE16FBBC34C75C0B1DA5C9605B7DABCD1B438D2ED5A7" + "9A7DF6C0678BFC31DB6B1F0C2FDC6E77E075DDCA898D770A77EF2D42DF7E2F4976E02F004E7890741F9E2ADA8A37EEF8E390472EF9E494576EF9E5649867AEF9E69C77EEF9E7A0872EFAE8A4976EFAE9A8A7AEFAEAACB7EEFAE" + "BB0C72EFBECB4D76EFBEDB8E7AEFBEEBCF7EEFBEFC0072FFCF0C4176FFCF1C827AFFCF2CC37EFFCF3D0472FFDF4D4576FFDF5D867AFFDF6DC77EFFDF7E0872FFEF8E497DF7D020021F90405050007002CD60060003000570082" + "FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03EC78BABCF3A3C9492B85D0EA7D71E6E0E67D61298DA4A9A2A95AB291BBB2B20BD7E68D8770BC73BA9F2828B4108B1D1472A85C568E4E462F9A1C5127D36B037AE" + "5AA04608191B60B879FCD9A795DC5A8D7ECB6CF04AF8F1FB2BA9DAADF3BFB7E4880707C83665186877F8960858C8E865A895A0A83940B80970C819A95679DA0A1A2A3A4A5A6A7A8A9AA2A01ADAEAFB0B1B035B2B5B6AF2EB7BA" + "B6ACBBBEB826BFC201BDC3BBB9C6B7B4C9B2ABCECFD0D1D2D3D4D53200D800A5D9DCA2DCDFDA9DE0DFE2E3E494E6E3E8E9E05AECEDEEEFDDF1F2D8F4F5EBF5E157FAFBFCF8F9D8954B178AA0B773A3E65148000021F90405050" + "007002CD60075003000570082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03E978BADCFE6EC801ABBD6D4ECCFBD1A0274660388E657A8AA9BA62ADFB56B13C93B576D3B9BEE33DCA2F13940C81BD2331A844B6" + "9A8F1C14529BF24CD6AB30CBED7ABFE0B0784C2E9BCF5C817ACD6EBBDBB3B77CCE5ED1EFF3137E0F1FF1FF027A807B76837471866F688B8C8D8E8F909192930A01960166979A639A9D98609E9DA0A1A25DA4A1A6A79E5CAAABA" + "CAD9BAFB096B2B3A9B39F59B8B91000BE002FB815BFBFC1B0BDC4C5C6A7C8C9C037CC0FCECAD0A5D2D3CF3BB1C3D862D8BEDEDD61DFD95FDF63E7E3E2EAD3E1EBE6EF5EE4EECEE8F15DE9ECF5FAFB60F9FEEDE81123D3CF1EB8" + "2909000021F90405050007002CC40092004200420082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03F978BADCFE508D49ABBD36EA1DB1FF15277260F98DE863AE59EA4A6CFCBEB13CBBB579CFF9B9FFC0A0704" + "82C1A8FC8A472C96C3A9FD0A8747A105805D4D7759B1D6DBFD8AE06FC1547C860B3034D5633D86D77155E96CFE957FB1D1F76F3F3767F567A8246018701377F4488888A78438D8D3B74919287406C96978999751100A1001C9C" + "98415C1AA2A2A4A54FAAAA1BA5A64CAFABB1AD4DB5A1ACB84BBAA3BC97B9BA23B2B4C422C6BEC8C9BD48BF28B29DCFCCCD9C4AD0D1CA47D9DAD7D4B52FDB45DDDEC2DCD5E692E8E1E2E342E529EF41F1F2DF44F5EA8EE4E92EE" + "7FCED764C62F74A8F837C7610CA51E886A11A870F0B1A7C006B6283040021F90405050007002CA700A4005700300082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADCFE30CA37EA9838EBCD8FFD5D28" + "8ECD675E64AA4AA7B9BEB0D7BA711DCEADAD6B78BEFF90DE0948740869C5E411942C2E2D4DE51315054E35802CE027E80A464F8C56ABF37AC1C7C9785C339B4942F53ADB76775538C99C1CB39FF148107B7413018601187E772" + "B4C11835B858786898A518F90119292138A8B458F189A87947E4997A1A2889C9D9F8319A9AAABA540A0AFA91AAC3FB5A8A2B8953BBBBC9A1BB935A71AB0C4C530C1C29BCAB3CCCD91BDD0D12BD3D4C31CCB29D9DACFDCBF2ADF" + "12C91DDD22E5E6B721E91CC71DE7E8EF58AE22F3F4D71DF7F8ED22E342F40B914F9F1B6F6B521434E889041B85FF46BCA9E26C14C5280B2FFEC8A8511307C78E353E82842172E48B6A2689844BA920010021F90405050007002" + "C9200A4005700300082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADC0E10B849ABBD38B7C8B5FFE0C78D52689E2139A26C4BA9A42BB7B03ADF606DE33CA6C7BDE0E4B7121A17C4CE71998C2C8F4DC8" + "13DA9C5289A78036201C7807996476ABED7DBF3E1D8A4CC69DCF975A8BBD75BFBD69258B5EBFDDD1714E2E7C6517028702187F785607845C8688878A8B568F90159292178B8C4B8F189A88947F4F97A1A2899C9D9F8419A9AAA" + "BA546A0AFA91AAC42B5A8A2B89541BBBC9A1EB938A71AB0C4C533C1C29BCAB3CCCD91BDD0D183AE1FC91FCB7BD9DAB720DD637C21DBDCBFDEE5E6E1E2E926C720E7E8EF20D3C8EDEED7F6EB26F3FA6FD6F46357CD443D7E6D50" + "FC03E849602185F90C026A446D18452B0B2F0AC9A8B11207C78E383E829C2172A48C82268D3CE391000021F90405050007002C8A0092004200420082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03F57807DCF" + "EF0A949ABBD98C6CD5DFEE0D58D5C6882642A9DACA5BE402B4FB03ADFF578EFF9B6FFC0A070482C1A8FC8A472C96C3A9FD0A8744A3D05AE81AA0CCBD59AB8E0AC3713068F2FE5F099922EAF0F6DF73AAE3ED3CDF63BF6ADDFE7" + "FB7C8081773B028602467A85878645743F8C8C446D4191878E784096979857439B8D2003A30352A088A2A4A350A7A819AAAA4FA721B0A44EADB4B5A54DB3B9B5BCA027BABB4BBDBEB04CC6C7B14AB8C2BAC5C12CC3CDCACBB64" + "9D6D7AB48DADBC446DEA9BF47E2E3C8E1E61FD4E99B3BEC45D237F044F233F4F59140F8F9A13FFC6F26000C78606040836F10AE5178866143740431304B000021F90405050007002C8A0075003000570082FFFFFFDDDDDDBBBB" + "BB999999FFFFFFFFFFFFFFFFFFFFFFFF03E778BA0C0E2CCA496B7BCEEA4DB1E7E0E68D61298DA8A9A2A95AB2ADCBC1B1ACD1A47DE3982EF20FDF0E0811768845E304A9AC009B161C340A9B0E7BD65F26CBED7ABFE0B0784C2E9" + "BCFA1807ACD6EBBDBB6B77CCE76D1EF73157E0F37F1FF017A807B76837471866F688B8C8D8E8F909192936802960266979A639A9D98609E9D5FA19E5DA4A159A7A856AAA553ADA2AFB097A9B396ACB69FB2B35CB63203C00316" + "BC2EC1C115AD36C6C614A73ECBC7CDB13AD0D1D2B742D5C062DAC261DDDE60DDDCE3DFDAE4D563E5E2E7E6EDECE9EEF1F0D0E8F5F6CBF8CCF2F7F4F9FADBD4CDD377669F86040021F90405050007002C8A0060003000570082F" + "FFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03EB78BADCFE0B4800ABBD6D4ECCBBD29A2756E0369E4C69A2A7BAB2A24BC1AD4B8FF28DDB7A27CF3D4C2E281C122DC62389A784249B8E2734229D1EAAD39F35CA84" + "04BE811EF60006EBB0E5F4ADCB48BB61EC857BCE2A55E67454C882CF4FFB7E50806F7F83655B8687568966858C888F90835B7280949578976D849A9B5F9DA0A1A2A3A4A5A6A7A8A93A02ACADAEAFB0AF30B1B4B5AE28B6B9B52" + "7BABDB223BEC102BCC2BDB8C5B6B3C8B1AACDCECFD0D1D2D3D4CF03D703A3D8DBA0DBDED997DFDE94E2DF56E5E250E8E94DEBE64AEEE3F0F1D8EAF4D7EDF7E0F3F453F75BFD00AED3842ED43B51DCAC24000021F90405050007" + "002C8A0058004200420082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FD78BADCFE30CA062A9838EB69EDFE20D77961698EA4A96E68B5BE597BC13424D738D5E64BE007AF1BEFF75B097144A2EA584B164FB" + "B9CF31962D2A6D48FF58A2D6DB9D36A74D8057DC14EF3985CD69CD149ED9A1D76CFE9713B8AE7C0026377784A807B7C0D7E842386878822858B3D6D116F528D93818696971D13029E027083129C129F9F309A2BA6AB2F92AAAB" + "AC26AE2AB0B5B27934B5B625A235BABB9020BFC0C11BC3B0C51FC7B1C91ACBA6CDC6CF9ED119D3D4D518D7D9D6CBDCCEC3DFE0BAE2D2CCE5E3A0E8EBECEDEEEFF0F1F2F3F4F5F68603F9FAFBFCFDFCD5FE020ADCD76CA04181C" + "90E2AFC576CA1C301091F2A2C287120C08AFEA225000021F90405050007002C920058005700300082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADCFE30BE4083BC38EB3D2BE560284A9E379E285756" + "69EB76EB2BBFEB37DF676DE13CA8F723815090FAA10048406B38441947C9248AC9CCD54ED1E889DA1C3D435969902BF45E4561B188DCF59D4169F59A2DFA6EE2CA149BE88EC1E32E7B217619782F822A6F1A8687881A8412787" + "98D64897E8B80337B7C19901092388E189E0F8CA1749D8A91993CA224AA11A6ADA817A40CB2B3B411B60AA0400AAE302518B83D9BB5B00DBEBFC0BA1097B1AC1003D40381CEC2C4D20FD5D54BD847DB0DDDE47A9532E2E3E4E5" + "635C33E90CEBF2ED6DE85918F2F373653C5A19F9FA9809041850E02F82EB0C3243C84E211086DD1C1E84484D620F8A152DF2C0A8F11322C38E0F09820C996FE4C48626495A4BA921010021F90401050007002CA700580057003" + "00082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADCFE4B4801ABBD38EB36E7FE60A8759D689E22E9A16C5BA9922BCF074CD1F869E77CB8F7A28170C0FA9D02C8406B38441945C9248AC9D4C18E51A9" + "89DA343D41596D902BF45EA161E489DC057D3569F1989C3A83E34BB6CFBE892BF3746E7C70782E6C441F6F177E33878823838B8C8D7A1B8A1593949519970F7E7F34879691988539A29CA49EA6A79B179D0D993CA8AFAAB1ACB" + "3B42FB60B9F400BBA10B00AB2408EB52A92B8C6AEC22418C5BF07C10F25CA612E00DA0018D428D121DBDBDD8132CB20E2E917CD2CE71AE9F0E45538D822F0F719F3395126F7F8D2D2FCFD03D843E04082380CC643C843A13A86" + "091D8E834843E2448A332C6AC358D11422C7880A3FE6082972A4C0920517A24CB9D14402003B";
    $impl.WebLibDlg = null;
    $impl.WebLibInputDlg = null;
    $impl.EventResult = function (Event) {
      var Result = "";
      Result = Event.target.result;
      return Result;
    };
    $impl.StringToHTML = function (AValue) {
      var Result = "";
      Result = pas.SysUtils.StringReplace(AValue,"\r","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      Result = pas.SysUtils.StringReplace(Result,"\n","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      return Result;
    };
    $impl.isAdvancedUpload = function () {
      var div = document.createElement('div');
      return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
    };
  };
  $mod.$init = function () {
    $impl.WebLibDlg = null;
  };
},["WEBLib.Forms","WEBLib.Consts","WEBLib.WebTools"]);
rtl.module("Math",["System"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MinInteger = -0xfffffffffffff - 1;
  this.MaxInteger = 0xfffffffffffff;
  this.MinDouble = 5.0e-324;
  this.MaxDouble = 1.7e+308;
  this.InRange = function (AValue, AMin, AMax) {
    return (AValue >= AMin) && (AValue <= AMax);
  };
  this.InRange$1 = function (AValue, AMin, AMax) {
    return (AValue >= AMin) && (AValue <= AMax);
  };
  this.EnsureRange = function (AValue, AMin, AMax) {
    if (AValue<AMin){ return AMin;
    } else if (AValue>AMax){ return AMax;
    } else return AValue;
  };
  this.EnsureRange$1 = function (AValue, AMin, AMax) {
    if (AValue<AMin){ return AMin;
    } else if (AValue>AMax){ return AMax;
    } else return AValue;
  };
  this.$rtti.$Int("TRoundToRange",{minvalue: -37, maxvalue: 37, ordtype: 0});
  this.RoundTo = function (AValue, Digits) {
    var Result = 0.0;
    var RV = 0.0;
    RV = $mod.IntPower(10,Digits);
    Result = Math.round(AValue / RV) * RV;
    return Result;
  };
  this.SimpleRoundTo = function (AValue, Digits) {
    var Result = 0.0;
    var RV = 0.0;
    RV = $mod.IntPower(10,-Digits);
    if (AValue < 0) {
      Result = pas.System.Int((AValue * RV) - 0.5) / RV}
     else Result = pas.System.Int((AValue * RV) + 0.5) / RV;
    return Result;
  };
  this.randg = function (mean, stddev) {
    var Result = 0.0;
    var U1 = 0.0;
    var S2 = 0.0;
    do {
      U1 = (2 * Math.random()) - 1;
      S2 = pas.System.Sqr$1(U1) + pas.System.Sqr$1((2 * Math.random()) - 1);
    } while (!(S2 < 1));
    Result = (Math.sqrt((-2 * Math.log(S2)) / S2) * U1 * stddev) + mean;
    return Result;
  };
  this.RandomRange = function (aFrom, aTo) {
    var Result = 0;
    Result = pas.System.Random(Math.abs(aFrom - aTo)) + Math.min(aTo,aFrom);
    return Result;
  };
  this.RandomRange$1 = function (aFrom, aTo) {
    var Result = 0;
    var m = 0;
    if (aFrom < aTo) {
      m = aFrom}
     else m = aTo;
    Result = pas.System.Random(Math.abs(aFrom - aTo)) + m;
    return Result;
  };
  this.$rtti.$Int("TValueSign",{minvalue: -1, maxvalue: 1, ordtype: 0});
  this.NegativeValue = -1;
  this.ZeroValue = 0;
  this.PositiveValue = 1;
  this.IsZero = function (d, Epsilon) {
    var Result = false;
    if (Epsilon === 0) Epsilon = 1E-12;
    Result = Math.abs(d) <= Epsilon;
    return Result;
  };
  this.IsZero$1 = function (d) {
    var Result = false;
    Result = Math.abs(d) <= 1E-12;
    return Result;
  };
  this.IsInfinite = function (d) {
    return (d==Infinity) || (d==-Infinity);
  };
  this.SameValue = function (A, B, Epsilon) {
    var Result = false;
    if (Epsilon === 0.0) Epsilon = Math.max(Math.min(Math.abs(A),Math.abs(B)) * 1E-12,1E-12);
    if (A > B) {
      Result = (A - B) <= Epsilon}
     else Result = (B - A) <= Epsilon;
    return Result;
  };
  this.SinCos = function (A, B, C) {
    B.set(Math.sin(A));
    C.set(Math.cos(A));
  };
  this.LogN = function (Base, A) {
    var Result = 0.0;
    Result = Math.log(A) / Math.log(Base);
    return Result;
  };
  this.Ceil = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.ceil(A));
    return Result;
  };
  this.Floor = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.floor(A));
    return Result;
  };
  this.Ceil64 = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.ceil(A));
    return Result;
  };
  this.Floor64 = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.ceil(A));
    return Result;
  };
  this.ldexp = function (x, p) {
    var Result = 0.0;
    Result = x * $mod.IntPower(2.0,p);
    return Result;
  };
  this.Frexp = function (X, Mantissa, Exponent) {
    Exponent.set(0);
    if (X !== 0) if (Math.abs(X) < 0.5) {
      do {
        X = X * 2;
        Exponent.set(Exponent.get() - 1);
      } while (!(Math.abs(X) >= 0.5))}
     else while (Math.abs(X) >= 1) {
      X = X / 2;
      Exponent.set(Exponent.get() + 1);
    };
    Mantissa.set(X);
  };
  this.lnxp1 = function (x) {
    var Result = 0.0;
    var y = 0.0;
    if (x >= 4.0) {
      Result = Math.log(1.0 + x)}
     else {
      y = 1.0 + x;
      if (y === 1.0) {
        Result = x}
       else {
        Result = Math.log(y);
        if (y > 0.0) Result = Result + ((x - (y - 1.0)) / y);
      };
    };
    return Result;
  };
  this.IntPower = function (base, exponent) {
    var Result = 0.0;
    var i = 0;
    if ((base === 0.0) && (exponent === 0)) {
      Result = 1}
     else {
      i = Math.abs(exponent);
      Result = 1.0;
      while (i > 0) {
        while ((i & 1) === 0) {
          i = i >>> 1;
          base = pas.System.Sqr$1(base);
        };
        i = i - 1;
        Result = Result * base;
      };
      if (exponent < 0) Result = 1.0 / Result;
    };
    return Result;
  };
  this.DivMod = function (Dividend, Divisor, Result, Remainder) {
    if (Dividend < 0) {
      Dividend = -Dividend;
      Result.set(-rtl.trunc(Dividend / Divisor));
      Remainder.set(-(Dividend + (Result.get() * Divisor)));
    } else {
      Result.set(rtl.trunc(Dividend / Divisor));
      Remainder.set(Dividend - (Result.get() * Divisor));
    };
  };
  this.DivMod$1 = function (Dividend, Divisor, Result, Remainder) {
    if (Dividend < 0) {
      Dividend = -Dividend;
      Result.set(-rtl.trunc(Dividend / Divisor));
      Remainder.set(-(Dividend + (Result.get() * Divisor)));
    } else {
      Result.set(rtl.trunc(Dividend / Divisor));
      Remainder.set(Dividend - (Result.get() * Divisor));
    };
  };
  this.DivMod$2 = function (Dividend, Divisor, Result, Remainder) {
    Result.set(rtl.trunc(Dividend / Divisor));
    Remainder.set(Dividend - (Result.get() * Divisor));
  };
  this.DivMod$3 = function (Dividend, Divisor, Result, Remainder) {
    if (Dividend < 0) {
      Dividend = -Dividend;
      Result.set(-rtl.trunc(Dividend / Divisor));
      Remainder.set(-(Dividend + (Result.get() * Divisor)));
    } else {
      Result.set(rtl.trunc(Dividend / Divisor));
      Remainder.set(Dividend - (Result.get() * Divisor));
    };
  };
  this.DegToRad = function (deg) {
    var Result = 0.0;
    Result = deg * (Math.PI / 180.0);
    return Result;
  };
  this.RadToDeg = function (rad) {
    var Result = 0.0;
    Result = rad * (180.0 / Math.PI);
    return Result;
  };
  this.GradToRad = function (grad) {
    var Result = 0.0;
    Result = grad * (Math.PI / 200.0);
    return Result;
  };
  this.RadToGrad = function (rad) {
    var Result = 0.0;
    Result = rad * (200.0 / Math.PI);
    return Result;
  };
  this.DegToGrad = function (deg) {
    var Result = 0.0;
    Result = deg * (200.0 / 180.0);
    return Result;
  };
  this.GradToDeg = function (grad) {
    var Result = 0.0;
    Result = grad * (180.0 / 200.0);
    return Result;
  };
  this.CycleToRad = function (cycle) {
    var Result = 0.0;
    Result = 2 * Math.PI * cycle;
    return Result;
  };
  this.RadToCycle = function (rad) {
    var Result = 0.0;
    Result = rad * (1 / (2 * Math.PI));
    return Result;
  };
  this.DegNormalize = function (deg) {
    var Result = 0.0;
    Result = deg - (pas.System.Int(deg / 360) * 360);
    if (Result < 0) Result = Result + 360;
    return Result;
  };
  this.Norm = function (data) {
    var Result = 0.0;
    Result = Math.sqrt($impl.sumofsquares(data));
    return Result;
  };
  this.Mean = function (data) {
    var Result = 0.0;
    var N = 0;
    N = rtl.length(data);
    if (N === 0) {
      Result = 0}
     else Result = $mod.Sum(data) / N;
    return Result;
  };
  this.Sum = function (data) {
    var Result = 0.0;
    var i = 0;
    var N = 0;
    N = rtl.length(data);
    Result = 0.0;
    for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
      i = $l;
      Result = Result + data[i];
    };
    return Result;
  };
  this.SumsAndSquares = function (data, Sum, SumOfSquares) {
    var i = 0;
    var n = 0;
    var t = 0.0;
    var s = 0.0;
    var ss = 0.0;
    n = rtl.length(data);
    ss = 0.0;
    s = 0.0;
    for (var $l = 0, $end = n - 1; $l <= $end; $l++) {
      i = $l;
      t = data[i];
      ss = ss + pas.System.Sqr$1(t);
      s = s + t;
    };
    Sum.set(s);
    SumOfSquares.set(ss);
  };
  this.StdDev = function (data) {
    var Result = 0.0;
    Result = Math.sqrt($mod.Variance(data));
    return Result;
  };
  this.MeanAndStdDev = function (data, Mean, StdDev) {
    var I = 0;
    var N = 0;
    var M = 0.0;
    var S = 0.0;
    N = rtl.length(data);
    M = 0;
    S = 0;
    for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
      I = $l;
      M = M + data[I];
      S = S + pas.System.Sqr$1(data[I]);
    };
    M = M / N;
    S = S - (N * pas.System.Sqr$1(M));
    if (N > 1) {
      S = Math.sqrt(S / (N - 1))}
     else S = 0;
    Mean.set(M);
    StdDev.set(S);
  };
  this.Variance = function (data) {
    var Result = 0.0;
    var n = 0;
    n = rtl.length(data);
    if (n === 1) {
      Result = 0}
     else Result = $mod.TotalVariance(data) / (n - 1);
    return Result;
  };
  this.TotalVariance = function (data) {
    var Result = 0.0;
    var S = 0.0;
    var SS = 0.0;
    var N = 0;
    N = rtl.length(data);
    if (rtl.length(data) === 1) {
      Result = 0}
     else {
      $mod.SumsAndSquares(data,{get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},{get: function () {
          return SS;
        }, set: function (v) {
          SS = v;
        }});
      Result = SS - (pas.System.Sqr$1(S) / N);
    };
    return Result;
  };
  this.PopNStdDev = function (data) {
    var Result = 0.0;
    Result = Math.sqrt($mod.PopNVariance(data));
    return Result;
  };
  this.PopNVariance = function (data) {
    var Result = 0.0;
    var N = 0;
    N = rtl.length(data);
    if (N === 0) {
      Result = 0}
     else Result = $mod.TotalVariance(data) / N;
    return Result;
  };
  this.MomentSkewKurtosis = function (data, m1, m2, m3, m4, skew, kurtosis) {
    var i = 0;
    var N = 0;
    var deviation = 0.0;
    var deviation2 = 0.0;
    var reciprocalN = 0.0;
    var lm1 = 0.0;
    var lm2 = 0.0;
    var lm3 = 0.0;
    var lm4 = 0.0;
    var lskew = 0.0;
    var lkurtosis = 0.0;
    N = rtl.length(data);
    lm1 = 0;
    reciprocalN = 1 / N;
    for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
      i = $l;
      lm1 = lm1 + data[i];
    };
    lm1 = reciprocalN * lm1;
    lm2 = 0;
    lm3 = 0;
    lm4 = 0;
    for (var $l1 = 0, $end1 = N - 1; $l1 <= $end1; $l1++) {
      i = $l1;
      deviation = data[i] - lm1;
      deviation2 = deviation * deviation;
      lm2 = lm2 + deviation2;
      lm3 = lm3 + (deviation2 * deviation);
      lm4 = lm4 + (deviation2 * deviation2);
    };
    lm2 = reciprocalN * lm2;
    lm3 = reciprocalN * lm3;
    lm4 = reciprocalN * lm4;
    lskew = lm3 / (Math.sqrt(lm2) * lm2);
    lkurtosis = lm4 / (lm2 * lm2);
    m1.set(lm1);
    m2.set(lm2);
    m3.set(lm3);
    m4.set(lm4);
    skew.set(lskew);
    kurtosis.set(lkurtosis);
  };
  this.TPaymentTime = {"0": "ptEndOfPeriod", ptEndOfPeriod: 0, "1": "ptStartOfPeriod", ptStartOfPeriod: 1};
  this.$rtti.$Enum("TPaymentTime",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TPaymentTime});
  this.FutureValue = function (ARate, NPeriods, APayment, APresentValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var qn = 0.0;
    var factor = 0.0;
    if (ARate === 0) {
      Result = -APresentValue - (APayment * NPeriods)}
     else {
      q = 1.0 + ARate;
      qn = Math.pow(q,NPeriods);
      factor = (qn - 1) / (q - 1);
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) factor = factor * q;
      Result = -((APresentValue * qn) + (APayment * factor));
    };
    return Result;
  };
  var DELTA = 0.001;
  var EPS = 1E-9;
  var MAXIT = 20;
  this.InterestRate = function (NPeriods, APayment, APresentValue, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var r1 = 0.0;
    var r2 = 0.0;
    var dr = 0.0;
    var fv1 = 0.0;
    var fv2 = 0.0;
    var iteration = 0;
    iteration = 0;
    r1 = 0.05;
    do {
      r2 = r1 + 1E-3;
      fv1 = $mod.FutureValue(r1,NPeriods,APayment,APresentValue,APaymentTime);
      fv2 = $mod.FutureValue(r2,NPeriods,APayment,APresentValue,APaymentTime);
      dr = ((AFutureValue - fv1) / (fv2 - fv1)) * 1E-3;
      r1 = r1 + dr;
      iteration += 1;
    } while (!((Math.abs(dr) < 1E-9) || (iteration >= 20)));
    Result = r1;
    return Result;
  };
  this.NumberOfPeriods = function (ARate, APayment, APresentValue, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var x1 = 0.0;
    var x2 = 0.0;
    if (ARate === 0) {
      Result = -(APresentValue + AFutureValue) / APayment}
     else {
      q = 1.0 + ARate;
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) APayment = APayment * q;
      x1 = APayment - (AFutureValue * ARate);
      x2 = APayment + (APresentValue * ARate);
      if ((x2 === 0) || ((Math.sign(x1) * Math.sign(x2)) < 0)) {
        Result = Infinity}
       else {
        Result = Math.log(x1 / x2) / Math.log(q);
      };
    };
    return Result;
  };
  this.Payment = function (ARate, NPeriods, APresentValue, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var qn = 0.0;
    var factor = 0.0;
    if (ARate === 0) {
      Result = -(AFutureValue + APresentValue) / NPeriods}
     else {
      q = 1.0 + ARate;
      qn = Math.pow(q,NPeriods);
      factor = (qn - 1) / (q - 1);
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) factor = factor * q;
      Result = -(AFutureValue + (APresentValue * qn)) / factor;
    };
    return Result;
  };
  this.PresentValue = function (ARate, NPeriods, APayment, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var qn = 0.0;
    var factor = 0.0;
    if (ARate === 0.0) {
      Result = -AFutureValue - (APayment * NPeriods)}
     else {
      q = 1.0 + ARate;
      qn = Math.pow(q,NPeriods);
      factor = (qn - 1) / (q - 1);
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) factor = factor * q;
      Result = -(AFutureValue + (APayment * factor)) / qn;
    };
    return Result;
  };
  this.IfThen = function (val, ifTrue, ifFalse) {
    var Result = 0;
    if (val) {
      Result = ifTrue}
     else Result = ifFalse;
    return Result;
  };
  this.IfThen$1 = function (val, ifTrue, ifFalse) {
    var Result = 0.0;
    if (val) {
      Result = ifTrue}
     else Result = ifFalse;
    return Result;
  };
  this.$rtti.$Int("TValueRelationship",{minvalue: -1, maxvalue: 1, ordtype: 0});
  this.EqualsValue = 0;
  this.LessThanValue = -1;
  this.GreaterThanValue = 1;
  this.CompareValue = function (A, B) {
    var Result = 0;
    Result = 1;
    if (A === B) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.CompareValue$1 = function (A, B) {
    var Result = 0;
    Result = 1;
    if (A === B) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.CompareValue$2 = function (A, B) {
    var Result = 0;
    Result = 1;
    if (A === B) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.CompareValue$3 = function (A, B, delta) {
    var Result = 0;
    Result = 1;
    if (Math.abs(A - B) <= delta) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.MinValue = function (Data) {
    var Result = 0.0;
    var I = 0;
    Result = Data[0];
    for (var $l = 1, $end = rtl.length(Data) - 1; $l <= $end; $l++) {
      I = $l;
      if (Result > Data[I]) Result = Data[I];
    };
    return Result;
  };
  this.MaxValue = function (Data) {
    var Result = 0.0;
    var I = 0;
    Result = Data[0];
    for (var $l = 1, $end = rtl.length(Data) - 1; $l <= $end; $l++) {
      I = $l;
      if (Result < Data[I]) Result = Data[I];
    };
    return Result;
  };
  this.MaxIntValue = function (AData) {
    var Result = 0;
    var lCount = 0;
    Result = AData[0];
    for (var $l = 1, $end = rtl.length(AData) - 1; $l <= $end; $l++) {
      lCount = $l;
      if (Result < AData[lCount]) Result = AData[lCount];
    };
    return Result;
  };
  $mod.$implcode = function () {
    $impl.DZeroResolution = 1E-12;
    $impl.sumofsquares = function (data) {
      var Result = 0.0;
      var i = 0;
      var N = 0;
      N = rtl.length(data);
      Result = 0.0;
      for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
        i = $l;
        Result = Result + pas.System.Sqr$1(data[i]);
      };
      return Result;
    };
  };
},[]);
rtl.module("RTTI",["System","JS","RTLConsts","Types","SysUtils","TypInfo"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.recNewT(this,"TValue",function () {
    this.FTypeInfo = null;
    this.FData = undefined;
    this.FReferenceVariableData = false;
    this.$eq = function (b) {
      return (this.FTypeInfo === b.FTypeInfo) && (this.FData === b.FData) && (this.FReferenceVariableData === b.FReferenceVariableData);
    };
    this.$assign = function (s) {
      this.FTypeInfo = s.FTypeInfo;
      this.FData = s.FData;
      this.FReferenceVariableData = s.FReferenceVariableData;
      return this;
    };
    this.GetData = function () {
      var Result = undefined;
      if (this.FReferenceVariableData) {
        Result = this.FData.get()}
       else Result = this.FData;
      return Result;
    };
    this.GetIsEmpty = function () {
      var Result = false;
      if ((this.FTypeInfo === null) || (this.GetData() == undefined) || (this.GetData() == null)) return true;
      var $tmp = this.FTypeInfo.kind;
      if ($tmp === pas.System.TTypeKind.tkDynArray) {
        Result = this.GetArrayLength() === 0}
       else {
        Result = false;
      };
      return Result;
    };
    this.GetTypeKind = function () {
      var Result = 0;
      if (this.FTypeInfo === null) {
        Result = pas.System.TTypeKind.tkUnknown}
       else Result = this.FTypeInfo.kind;
      return Result;
    };
    this.SetData = function (Value) {
      if (this.FReferenceVariableData) {
        this.FData.set(Value)}
       else this.FData = Value;
    };
    this.Empty = function () {
      var Result = $mod.TValue.$new();
      Result.SetData(null);
      Result.FTypeInfo = null;
      return Result;
    };
    this.FromArray = function (TypeInfo, Values) {
      var Result = $mod.TValue.$new();
      var A = 0;
      var NewArray = null;
      var ElementType = null;
      if (TypeInfo.kind !== pas.System.TTypeKind.tkDynArray) throw pas.SysUtils.EInvalidCast.$create("Create$1",["Type not an array in FromArray!"]);
      ElementType = TypeInfo.eltype;
      NewArray = new Array();
      NewArray.length = rtl.length(Values);
      for (var $l = 0, $end = rtl.length(Values) - 1; $l <= $end; $l++) {
        A = $l;
        NewArray[A] = Values[A].Cast(ElementType,true).AsJSValue();
      };
      Result.SetData(NewArray);
      Result.FTypeInfo = TypeInfo;
      return Result;
    };
    this.FromJSValue = function (v) {
      var Result = $mod.TValue.$new();
      var i = 0;
      var TypeOfValue = null;
      var $tmp = typeof(v);
      if ($tmp === "number") {
        if (pas.JS.isInteger(v)) {
          i = rtl.trunc(v);
          if ((i >= -2147483648) && (i <= 2147483647)) {
            TypeOfValue = rtl.longint}
           else TypeOfValue = rtl.nativeint;
        } else TypeOfValue = rtl.double}
       else if ($tmp === "string") {
        TypeOfValue = rtl.string}
       else if ($tmp === "boolean") {
        TypeOfValue = rtl.boolean}
       else if ($tmp === "object") {
        if (v == null) {
          return $mod.TValue.Empty()}
         else if (pas.JS.isClass(v) && rtl.isExt(v,pas.System.TObject)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else if (rtl.isObject(v) && rtl.isExt(v,pas.System.TObject)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else if (pas.JS.isRecord(v)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else if (Array.isArray(v)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else throw pas.SysUtils.EInvalidCast.$create("Create$1",["Type not recognized in FromJSValue!"])}
       else {
        TypeOfValue = rtl.jsvalue;
      };
      $mod.TValue.Make(v,TypeOfValue,Result);
      return Result;
    };
    this.FromOrdinal = function (ATypeInfo, AValue) {
      var Result = $mod.TValue.$new();
      if ((ATypeInfo === null) || !(ATypeInfo.kind in rtl.createSet(pas.System.TTypeKind.tkBool,pas.System.TTypeKind.tkEnumeration,pas.System.TTypeKind.tkInteger))) throw pas.SysUtils.EInvalidCast.$create("Create$1",["Invalid type in FromOrdinal"]);
      if (ATypeInfo.kind === pas.System.TTypeKind.tkBool) {
        $mod.TValue.Make(AValue == true,ATypeInfo,Result)}
       else $mod.TValue.Make(rtl.trunc(AValue),ATypeInfo,Result);
      return Result;
    };
    this.Make = function (ABuffer, ATypeInfo, Result) {
      Result.FData = ABuffer;
      Result.FTypeInfo = ATypeInfo;
    };
    this.AsBoolean = function () {
      var Result = false;
      if (this.GetTypeKind() === pas.System.TTypeKind.tkBool) {
        Result = !(this.GetData() == false)}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsClass = function () {
      var Result = null;
      if (this.IsClass()) {
        Result = rtl.getObject(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsExtended = function () {
      var Result = 0.0;
      if (rtl.isNumber(this.GetData())) {
        Result = rtl.getNumber(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsInteger = function () {
      var Result = 0;
      if (pas.JS.isInteger(this.GetData())) {
        Result = rtl.trunc(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsInterface = function () {
      var Result = null;
      var k = 0;
      var $ok = false;
      try {
        k = this.GetTypeKind();
        if (k === pas.System.TTypeKind.tkInterface) {
          Result = rtl.setIntfL(Result,rtl.getObject(this.GetData()))}
         else if ((k in rtl.createSet(pas.System.TTypeKind.tkClass,pas.System.TTypeKind.tkClassRef,pas.System.TTypeKind.tkUnknown)) && !rtl.isObject(this.GetData())) {
          Result = rtl.setIntfL(Result,null)}
         else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.AsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      return Result;
    };
    this.AsNativeInt = function () {
      var Result = 0;
      if (pas.JS.isInteger(this.GetData())) {
        Result = rtl.trunc(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsObject = function () {
      var Result = null;
      if (this.IsObject() || (this.IsClass() && !rtl.isObject(this.GetData()))) {
        Result = rtl.getObject(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsOrdinal = function () {
      var Result = 0;
      if (this.IsOrdinal()) {
        Result = rtl.trunc(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      if (rtl.isString(this.GetData())) {
        Result = "" + this.GetData()}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsUnicodeString = function () {
      var Result = "";
      Result = this.AsString();
      return Result;
    };
    this.Cast = function (ATypeInfo, EmptyAsAnyType) {
      var Result = $mod.TValue.$new();
      if (!this.TryCast(ATypeInfo,Result,EmptyAsAnyType)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      return Result;
    };
    this.IsType = function (ATypeInfo, EmptyAsAnyType) {
      var Result = false;
      var AnyValue = $mod.TValue.$new();
      Result = this.TryCast(ATypeInfo,AnyValue,EmptyAsAnyType);
      return Result;
    };
    this.GetArrayElement = function (aIndex) {
      var Result = $mod.TValue.$new();
      if (this.IsArray()) {
        var $tmp = this.GetTypeKind();
        if ($tmp === pas.System.TTypeKind.tkArray) {
          Result.FTypeInfo = this.FTypeInfo.eltype}
         else if ($tmp === pas.System.TTypeKind.tkDynArray) Result.FTypeInfo = this.FTypeInfo.eltype;
        Result.SetData(this.GetData()[aIndex]);
      } else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.GetArrayLength = function () {
      var Result = 0;
      if (this.IsArray()) return rtl.length(this.GetData());
      throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.IsArray = function () {
      var Result = false;
      var $tmp = this.GetTypeKind();
      if ($tmp === pas.System.TTypeKind.tkDynArray) {
        return true}
       else if ($tmp === pas.System.TTypeKind.tkArray) {
        return rtl.length(this.FTypeInfo.dims) === 1}
       else {
        Result = false;
      };
      return Result;
    };
    this.IsClass = function () {
      var Result = false;
      var k = 0;
      k = this.GetTypeKind();
      Result = (k === pas.System.TTypeKind.tkClassRef) || ((k in rtl.createSet(pas.System.TTypeKind.tkClass,pas.System.TTypeKind.tkUnknown)) && !rtl.isObject(this.GetData()));
      return Result;
    };
    this.IsObject = function () {
      var Result = false;
      Result = this.GetIsEmpty() || (this.FTypeInfo.kind === pas.System.TTypeKind.tkClass);
      return Result;
    };
    this.IsObjectInstance = function () {
      var Result = false;
      Result = (this.FTypeInfo !== null) && (this.FTypeInfo.kind === pas.System.TTypeKind.tkClass);
      return Result;
    };
    this.IsOrdinal = function () {
      var Result = false;
      Result = this.GetIsEmpty() || (this.GetTypeKind() in rtl.createSet(pas.System.TTypeKind.tkBool,pas.System.TTypeKind.tkInteger,pas.System.TTypeKind.tkChar,pas.System.TTypeKind.tkEnumeration));
      return Result;
    };
    this.IsType$2 = function (ATypeInfo) {
      var Result = false;
      Result = ATypeInfo === this.FTypeInfo;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      var $tmp = this.GetTypeKind();
      if ($tmp === pas.System.TTypeKind.tkString) {
        Result = this.AsString()}
       else if ($tmp === pas.System.TTypeKind.tkInteger) {
        Result = pas.SysUtils.IntToStr(this.AsNativeInt())}
       else if ($tmp === pas.System.TTypeKind.tkBool) {
        Result = pas.SysUtils.BoolToStr(this.AsBoolean(),true)}
       else if ($tmp === pas.System.TTypeKind.tkDouble) {
        Result = pas.SysUtils.FloatToStr(this.AsExtended())}
       else {
        Result = "";
      };
      return Result;
    };
    this.TryCast = function (ATypeInfo, AResult, EmptyAsAnyType) {
      var $Self = this;
      var Result = false;
      function ConversionAccepted() {
        var Result = {};
        var $tmp = ATypeInfo.kind;
        if ($tmp === pas.System.TTypeKind.tkString) {
          return rtl.createSet(pas.System.TTypeKind.tkChar,pas.System.TTypeKind.tkString)}
         else if ($tmp === pas.System.TTypeKind.tkDouble) {
          return rtl.createSet(pas.System.TTypeKind.tkInteger,pas.System.TTypeKind.tkDouble)}
         else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
          return rtl.createSet(pas.System.TTypeKind.tkInteger,pas.System.TTypeKind.tkEnumeration)}
         else {
          return rtl.createSet(ATypeInfo.kind);
        };
        return Result;
      };
      if (EmptyAsAnyType && this.GetIsEmpty()) {
        AResult.$assign(this.Empty());
        if (ATypeInfo !== null) {
          AResult.FTypeInfo = ATypeInfo;
          var $tmp = ATypeInfo.kind;
          if ($tmp === pas.System.TTypeKind.tkBool) {
            AResult.SetData(false)}
           else if ($tmp === pas.System.TTypeKind.tkChar) {
            AResult.SetData("\x00")}
           else if ($tmp === pas.System.TTypeKind.tkString) {
            AResult.SetData(pas.SysUtils.EmptyStr)}
           else if (($tmp === pas.System.TTypeKind.tkDouble) || ($tmp === pas.System.TTypeKind.tkEnumeration) || ($tmp === pas.System.TTypeKind.tkInteger)) AResult.SetData(0);
          return true;
        };
      };
      if (!EmptyAsAnyType && (this.FTypeInfo === null)) return false;
      if (this.FTypeInfo === ATypeInfo) {
        AResult.$assign($Self);
        return true;
      };
      if (ATypeInfo === null) return false;
      if (ATypeInfo === $mod.$rtti["TValue"]) {
        this.Make($Self,$mod.$rtti["TValue"],AResult);
        return true;
      };
      Result = this.FTypeInfo.kind in ConversionAccepted();
      if (Result) {
        AResult.SetData(this.FData);
        AResult.FTypeInfo = ATypeInfo;
      };
      return Result;
    };
    this.SetArrayElement = function (aIndex, AValue) {
      if (this.IsArray()) {
        this.GetData()[aIndex] = AValue.AsJSValue()}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
    };
    this.SetArrayLength = function (Size) {
      var NewArray = [];
      NewArray = this.GetData();
      NewArray = rtl.arraySetLength(NewArray,undefined,Size);
      this.SetData(NewArray);
    };
    this.From$$$G$$rtti$$Longint = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.longint,Result);
      return Result;
    };
    this.From$$$G$$rtti$$Double = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.double,Result);
      return Result;
    };
    this.From$$$G$$rtti$$String = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.string,Result);
      return Result;
    };
    this.From$$$G$$rtti$$Boolean = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.boolean,Result);
      return Result;
    };
    var $r = $mod.$rtti.$Record("TValue",{},this);
    $r.addMethod("Empty",5,[],2,$r,1);
    $r.addMethod("FromArray",5,[["TypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["Values",pas.System.$rtti["TArray<RTTI.TValue>"],2]],2,$r,1);
    $r.addMethod("FromJSValue",5,[["v",rtl.jsvalue]],2,$r,1);
    $r.addMethod("FromOrdinal",5,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["AValue",rtl.jsvalue]],2,$r,1);
    $r.addMethod("Make",4,[["ABuffer",rtl.jsvalue,2],["ATypeInfo",rtl.pointer,2],["Result",$r,1]],2,null,1);
    $r.addMethod("AsBoolean",1,[],2,rtl.boolean);
    $r.addMethod("AsClass",1,[],2,pas.System.$rtti["TClass"]);
    $r.addMethod("AsExtended",1,[],2,pas.System.$rtti["Extended"]);
    $r.addMethod("AsInteger",1,[],2,rtl.longint);
    $r.addMethod("AsInterface",1,[],2,pas.System.$rtti["IUnknown"]);
    $r.addMethod("AsJSValue",1,[],2,rtl.jsvalue);
    $r.addMethod("AsNativeInt",1,[],2,rtl.nativeint);
    $r.addMethod("AsObject",1,[],2,pas.System.$rtti["TObject"]);
    $r.addMethod("AsOrdinal",1,[],2,rtl.nativeint);
    $r.addMethod("AsString",1,[],2,rtl.string);
    $r.addMethod("AsUnicodeString",1,[],2,rtl.string);
    $r.addMethod("Cast",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["EmptyAsAnyType",rtl.boolean,2]],2,$r);
    $r.addMethod("IsType",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["EmptyAsAnyType",rtl.boolean,2]],2,rtl.boolean);
    $r.addMethod("GetArrayElement",1,[["aIndex",rtl.nativeint]],2,$r);
    $r.addMethod("GetArrayLength",1,[],2,rtl.nativeint);
    $r.addMethod("IsArray",1,[],2,rtl.boolean);
    $r.addMethod("IsClass",1,[],2,rtl.boolean);
    $r.addMethod("IsObject",1,[],2,rtl.boolean);
    $r.addMethod("IsObjectInstance",1,[],2,rtl.boolean);
    $r.addMethod("IsOrdinal",1,[],2,rtl.boolean);
    $r.addMethod("IsType$2",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]]],2,rtl.boolean);
    $r.addMethod("ToString",1,[],2,rtl.string);
    $r.addMethod("TryCast",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["AResult",$r,4],["EmptyAsAnyType",rtl.boolean,2]],2,rtl.boolean);
    $r.addMethod("SetArrayElement",0,[["aIndex",rtl.nativeint],["AValue",$r,2]]);
    $r.addMethod("SetArrayLength",0,[["Size",rtl.nativeint,2]]);
    $r.addProperty("IsEmpty",1,rtl.boolean,"GetIsEmpty","",2);
    $r.addProperty("Kind",1,pas.System.$rtti["TTypeKind"],"GetTypeKind","",2);
    $r.addProperty("TypeInfo",0,pas.TypInfo.$rtti["TTypeInfo"],"FTypeInfo","",2);
  });
  this.$rtti.$Class("TRttiType");
  this.$rtti.$Class("TRttiInstanceType");
  this.$rtti.$Class("TRttiInstanceExternalType");
  rtl.recNewT(this,"TRTTIContext",function () {
    this.$eq = function (b) {
      return true;
    };
    this.$assign = function (s) {
      return this;
    };
    this.Create = function () {
      var Result = $mod.TRTTIContext.$new();
      $impl.TRttiPoolTypes.AcquireContext();
      return Result;
    };
    this.Free = function () {
      $impl.TRttiPoolTypes.ReleaseContext();
    };
    this.FindType = function (AQualifiedName) {
      var Result = null;
      Result = $impl.Pool.FindType(AQualifiedName);
      return Result;
    };
    this.GetType = function (aTypeInfo) {
      var Result = null;
      Result = $impl.Pool.GetType(aTypeInfo);
      return Result;
    };
    this.GetType$1 = function (aClass) {
      var Result = null;
      Result = $impl.Pool.GetType$1(aClass);
      return Result;
    };
    this.GetTypes = function () {
      var Result = [];
      var ModuleName = "";
      var ClassName = "";
      var ModuleTypes = null;
      for (var $in = Object.keys(pas), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        ModuleName = $in[$l];
        ModuleTypes = pas[ModuleName].$rtti;
        for (ClassName in ModuleTypes) if (ModuleTypes[ClassName].hasOwnProperty("name") && (ClassName.charAt(0) !== "$")) this.GetType(ModuleTypes[ClassName]);
      };
      Result = Object.values($impl.Pool.FTypes);
      return Result;
    };
    this.KeepContext = function () {
      $impl.TRttiPoolTypes.AcquireContext();
    };
    this.DropContext = function () {
      $impl.TRttiPoolTypes.ReleaseContext();
    };
    var $r = $mod.$rtti.$Record("TRTTIContext",{},this);
    $r.addMethod("Create",5,[],2,$r,1);
    $r.addMethod("Free",0,[]);
    $r.addMethod("FindType",1,[["AQualifiedName",rtl.string,2]],2,$mod.$rtti["TRttiType"]);
    $r.addMethod("GetType",1,[["aTypeInfo",rtl.pointer]],2,$mod.$rtti["TRttiType"]);
    $r.addMethod("GetType$1",1,[["aClass",pas.System.$rtti["TClass"]]],2,$mod.$rtti["TRttiType"]);
    $r.addMethod("GetTypes",1,[],2,pas.System.$rtti["TArray<RTTI.TRttiType>"]);
    $r.addMethod("KeepContext",4,[],2,null,1);
    $r.addMethod("DropContext",4,[],2,null,1);
  });
  rtl.createClass(this,"TRttiObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FAttributesLoaded = false;
      this.FAttributes = [];
      this.FParent = null;
      this.FHandle = null;
    };
    this.$final = function () {
      this.FAttributes = undefined;
      this.FParent = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.LoadCustomAttributes = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.Create$1 = function (AParent, AHandle) {
      this.FParent = AParent;
      this.FHandle = AHandle;
      return this;
    };
    this.Destroy = function () {
      var Attribute = null;
      for (var $in = this.FAttributes, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Attribute = $in[$l];
        Attribute = rtl.freeLoc(Attribute);
      };
      this.FAttributes = [];
      pas.System.TObject.Destroy.call(this);
    };
    this.GetAttributes = function () {
      var Result = [];
      if (!this.FAttributesLoaded) {
        this.FAttributes = this.LoadCustomAttributes();
        this.FAttributesLoaded = true;
      };
      Result = rtl.arrayRef(this.FAttributes);
      return Result;
    };
    this.GetAttribute$1 = function (Attribute) {
      var Result = null;
      var CustomAttribute = null;
      Result = null;
      for (var $in = this.GetAttributes(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        CustomAttribute = $in[$l];
        if (Attribute.isPrototypeOf(CustomAttribute)) return CustomAttribute;
      };
      return Result;
    };
    this.HasAttribute$1 = function (Attribute) {
      var Result = false;
      Result = this.GetAttribute$1(Attribute) !== null;
      return Result;
    };
  });
  rtl.createClass(this,"TRttiNamedObject",this.TRttiObject,function () {
    this.GetName = function () {
      var Result = "";
      Result = "";
      return Result;
    };
  });
  this.TMemberVisibility = {"0": "mvPrivate", mvPrivate: 0, "1": "mvProtected", mvProtected: 1, "2": "mvPublic", mvPublic: 2, "3": "mvPublished", mvPublished: 3};
  this.$rtti.$Enum("TMemberVisibility",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TMemberVisibility});
  rtl.createClass(this,"TRttiMember",this.TRttiNamedObject,function () {
    this.GetMemberTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.GetName = function () {
      var Result = "";
      Result = this.GetMemberTypeInfo().name;
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = this.FParent;
      return Result;
    };
    this.GetVisibility = function () {
      var Result = 0;
      Result = $mod.TMemberVisibility.mvPublished;
      return Result;
    };
    this.LoadCustomAttributes = function () {
      var Result = [];
      Result = pas.TypInfo.GetRTTIAttributes(this.GetMemberTypeInfo().attr);
      return Result;
    };
    this.Create$2 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeMember)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.call(this,AParent,ATypeInfo);
      return this;
    };
  });
  rtl.createClass(this,"TRttiField",this.TRttiMember,function () {
    this.GetFieldType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetFieldTypeInfo().typeinfo);
      return Result;
    };
    this.GetFieldTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.Create$3 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeMemberField)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiMember.Create$2.apply(this,arguments);
      return this;
    };
    this.GetValue = function (Instance) {
      var Result = $mod.TValue.$new();
      Result.$assign($mod.TValue.FromJSValue(Instance[this.GetName()]));
      return Result;
    };
    this.SetValue = function (Instance, AValue) {
      Instance[this.GetName()] = AValue.Cast(this.GetFieldType().GetHandle(),true).AsJSValue();
    };
  });
  rtl.createClass(this,"TRttiParameter",this.TRttiNamedObject,function () {
    this.$init = function () {
      $mod.TRttiNamedObject.$init.call(this);
      this.FParamType = null;
      this.FFlags = {};
      this.FName = "";
    };
    this.$final = function () {
      this.FParamType = undefined;
      this.FFlags = undefined;
      $mod.TRttiNamedObject.$final.call(this);
    };
    this.GetName = function () {
      var Result = "";
      Result = this.FName;
      return Result;
    };
  });
  rtl.createClass(this,"TRttiMethod",this.TRttiMember,function () {
    this.$init = function () {
      $mod.TRttiMember.$init.call(this);
      this.FParameters = [];
      this.FParametersLoaded = false;
    };
    this.$final = function () {
      this.FParameters = undefined;
      $mod.TRttiMember.$final.call(this);
    };
    this.GetIsAsyncCall = function () {
      var Result = false;
      Result = (pas.TypInfo.TProcedureFlag.pfAsync in this.GetProcedureFlags()) || ((this.GetReturnType() != null) && this.GetReturnType().GetIsInstanceExternal() && (this.GetReturnType().GetAsInstanceExternal().GetExternalName() === "Promise"));
      return Result;
    };
    this.GetIsClassMethod = function () {
      var Result = false;
      Result = this.GetMethodTypeInfo().methodkind in rtl.createSet(pas.TypInfo.TMethodKind.mkClassFunction,pas.TypInfo.TMethodKind.mkClassProcedure);
      return Result;
    };
    this.GetIsConstructor = function () {
      var Result = false;
      Result = this.GetMethodTypeInfo().methodkind === pas.TypInfo.TMethodKind.mkConstructor;
      return Result;
    };
    this.GetIsDestructor = function () {
      var Result = false;
      Result = this.GetMethodTypeInfo().methodkind === pas.TypInfo.TMethodKind.mkDestructor;
      return Result;
    };
    this.GetIsExternal = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfExternal in this.GetProcedureFlags();
      return Result;
    };
    this.GetIsSafeCall = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfSafeCall in this.GetProcedureFlags();
      return Result;
    };
    this.GetIsStatic = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfStatic in this.GetProcedureFlags();
      return Result;
    };
    this.GetMethodKind = function () {
      var Result = 0;
      Result = this.GetMethodTypeInfo().methodkind;
      return Result;
    };
    this.GetMethodTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    var PROCEDURE_FLAGS = [1,2,4,8,16];
    this.GetProcedureFlags = function () {
      var Result = {};
      var Flag = 0;
      var ProcedureFlags = 0;
      ProcedureFlags = this.GetMethodTypeInfo().procsig.flags;
      Result = {};
      for (Flag = 0; Flag <= 4; Flag++) if (rtl.and(PROCEDURE_FLAGS[Flag],ProcedureFlags) > 0) Result = rtl.unionSet(Result,rtl.createSet(Flag));
      return Result;
    };
    this.GetReturnType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetMethodTypeInfo().procsig.resulttype);
      return Result;
    };
    var FLAGS_CONVERSION = [1,2,4,8,16,32];
    this.LoadParameters = function () {
      var A = 0;
      var Flag = 0;
      var Param = null;
      var RttiParam = null;
      var MethodParams = [];
      this.FParametersLoaded = true;
      MethodParams = this.GetMethodTypeInfo().procsig.params;
      this.FParameters = rtl.arraySetLength(this.FParameters,null,rtl.length(MethodParams));
      for (var $l = 0, $end = rtl.length(this.FParameters) - 1; $l <= $end; $l++) {
        A = $l;
        Param = MethodParams[A];
        RttiParam = $mod.TRttiParameter.$create("Create$1",[this,Param]);
        RttiParam.FName = Param.name;
        RttiParam.FParamType = $impl.Pool.GetType(Param.typeinfo);
        for (Flag = 0; Flag <= 5; Flag++) if (rtl.and(FLAGS_CONVERSION[Flag],Param.flags) > 0) RttiParam.FFlags = rtl.unionSet(RttiParam.FFlags,rtl.createSet(Flag));
        this.FParameters[A] = RttiParam;
      };
    };
    this.GetIsVarArgs = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfVarargs in this.GetProcedureFlags();
      return Result;
    };
    this.GetParameters = function () {
      var Result = [];
      if (!this.FParametersLoaded) this.LoadParameters();
      Result = rtl.arrayRef(this.FParameters);
      return Result;
    };
    this.Invoke = function (Instance, Args) {
      var Result = $mod.TValue.$new();
      var A = 0;
      var AArgs = [];
      if (this.GetReturnType() != null) Result.FTypeInfo = this.GetReturnType().GetHandle();
      AArgs = rtl.arraySetLength(AArgs,undefined,rtl.length(Args));
      for (var $l = 0, $end = rtl.length(Args) - 1; $l <= $end; $l++) {
        A = $l;
        AArgs[A] = Args[A].AsJSValue();
      };
      Result.SetData(Instance.AsJSValue()[this.GetName()].apply(Instance.AsJSValue(),AArgs));
      return Result;
    };
    this.Invoke$1 = function (Instance, Args) {
      var Result = $mod.TValue.$new();
      var v = $mod.TValue.$new();
      $mod.TValue.Make(Instance,Instance.$class.ClassInfo(),v);
      Result.$assign(this.Invoke(v,Args));
      return Result;
    };
    this.Invoke$2 = function (aClass, Args) {
      var Result = $mod.TValue.$new();
      var v = $mod.TValue.$new();
      $mod.TValue.Make(aClass,aClass.ClassInfo(),v);
      Result.$assign(this.Invoke(v,Args));
      return Result;
    };
  });
  rtl.createClass(this,"TRttiProperty",this.TRttiMember,function () {
    this.GetPropertyTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.GetPropertyType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetPropertyTypeInfo().typeinfo);
      return Result;
    };
    this.GetIsWritable = function () {
      var Result = false;
      Result = this.GetPropertyTypeInfo().setter !== "";
      return Result;
    };
    this.GetIsReadable = function () {
      var Result = false;
      Result = this.GetPropertyTypeInfo().getter !== "";
      return Result;
    };
    this.GetVisibility = function () {
      var Result = 0;
      Result = $mod.TMemberVisibility.mvPublished;
      return Result;
    };
    this.Create$3 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeMemberProperty)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiMember.Create$2.apply(this,arguments);
      return this;
    };
    this.GetValue = function (Instance) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(pas.TypInfo.GetJSValueProp$1(Instance,this.GetPropertyTypeInfo()),this.GetPropertyType().GetHandle(),Result);
      return Result;
    };
    this.SetValue = function (Instance, AValue) {
      pas.TypInfo.SetJSValueProp$1(Instance,this.GetPropertyTypeInfo(),AValue.Cast(this.GetPropertyType().GetHandle(),true).AsJSValue());
    };
  });
  rtl.createClass(this,"TRttiInstanceProperty",this.TRttiProperty,function () {
  });
  rtl.createClass(this,"TRttiType",this.TRttiNamedObject,function () {
    this.GetAsInstance = function () {
      var Result = null;
      Result = rtl.as(this,$mod.TRttiInstanceType);
      return Result;
    };
    this.GetAsInstanceExternal = function () {
      var Result = null;
      Result = rtl.as(this,$mod.TRttiInstanceExternalType);
      return Result;
    };
    this.GetHandle = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.GetQualifiedName = function () {
      var Result = "";
      Result = pas.SysUtils.Format("%s.%s",pas.System.VarRecs(18,this.GetHandle().$module.$name,18,this.GetName()));
      return Result;
    };
    this.GetName = function () {
      var Result = "";
      Result = this.GetHandle().name;
      return Result;
    };
    this.GetIsInstance = function () {
      var Result = false;
      Result = $mod.TRttiInstanceType.isPrototypeOf(this);
      return Result;
    };
    this.GetIsInstanceExternal = function () {
      var Result = false;
      Result = $mod.TRttiInstanceExternalType.isPrototypeOf(this);
      return Result;
    };
    this.GetIsOrdinal = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetIsRecord = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetIsSet = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetTypeKind = function () {
      var Result = 0;
      Result = this.GetHandle().kind;
      return Result;
    };
    this.GetBaseType = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.LoadCustomAttributes = function () {
      var Result = [];
      Result = pas.TypInfo.GetRTTIAttributes(this.GetHandle().attr);
      return Result;
    };
    this.GetField = function (AName) {
      var Result = null;
      var AField = null;
      Result = null;
      for (var $in = this.GetFields(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        AField = $in[$l];
        if (AField.GetName() === AName) return AField;
      };
      return Result;
    };
    this.GetFields = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetMethods = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetMethods$1 = function (aName) {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetMethod = function (aName) {
      var Result = null;
      Result = null;
      if (aName === "") ;
      return Result;
    };
    this.GetProperty = function (AName) {
      var Result = null;
      Result = null;
      if (AName === "") ;
      return Result;
    };
    this.GetProperties = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetDeclaredProperties = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetDeclaredMethods = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetDeclaredFields = function () {
      var Result = [];
      Result = [];
      return Result;
    };
  });
  this.$rtti.$ClassRef("TRttiTypeClass",{instancetype: this.$rtti["TRttiType"]});
  rtl.createClass(this,"TRttiStructuredType",this.TRttiType,function () {
    this.$init = function () {
      $mod.TRttiType.$init.call(this);
      this.FFields = [];
      this.FMethods = [];
      this.FProperties = [];
    };
    this.$final = function () {
      this.FFields = undefined;
      this.FMethods = undefined;
      this.FProperties = undefined;
      $mod.TRttiType.$final.call(this);
    };
    this.GetAncestor = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetStructTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoStruct)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
    this.Destroy = function () {
      var Method = null;
      var Prop = null;
      for (var $in = this.FMethods, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        Method = rtl.freeLoc(Method);
      };
      for (var $in1 = this.FProperties, $l1 = 0, $end1 = rtl.length($in1) - 1; $l1 <= $end1; $l1++) {
        Prop = $in1[$l1];
        Prop = rtl.freeLoc(Prop);
      };
      $mod.TRttiObject.Destroy.call(this);
    };
    this.GetDeclaredFields = function () {
      var Result = [];
      var A = 0;
      var FieldCount = 0;
      if (!(rtl.length(this.FFields) > 0)) {
        FieldCount = this.GetStructTypeInfo().fields.length;
        this.FFields = rtl.arraySetLength(this.FFields,null,FieldCount);
        for (var $l = 0, $end = FieldCount - 1; $l <= $end; $l++) {
          A = $l;
          this.FFields[A] = $mod.TRttiField.$create("Create$3",[this,this.GetStructTypeInfo().getField(A)]);
        };
      };
      Result = rtl.arrayRef(this.FFields);
      return Result;
    };
    this.GetDeclaredMethods = function () {
      var Result = [];
      var A = 0;
      var MethodCount = 0;
      if (!(rtl.length(this.FMethods) > 0)) {
        MethodCount = this.GetStructTypeInfo().methods.length;
        this.FMethods = rtl.arraySetLength(this.FMethods,null,MethodCount);
        for (var $l = 0, $end = MethodCount - 1; $l <= $end; $l++) {
          A = $l;
          this.FMethods[A] = $mod.TRttiMethod.$create("Create$2",[this,this.GetStructTypeInfo().getMethod(A)]);
        };
      };
      Result = rtl.arrayRef(this.FMethods);
      return Result;
    };
    this.GetDeclaredProperties = function () {
      var Result = [];
      var A = 0;
      var PropCount = 0;
      if (!(rtl.length(this.FProperties) > 0)) {
        PropCount = this.GetStructTypeInfo().properties.length;
        this.FProperties = rtl.arraySetLength(this.FProperties,null,PropCount);
        for (var $l = 0, $end = PropCount - 1; $l <= $end; $l++) {
          A = $l;
          this.FProperties[A] = $mod.TRttiProperty.$create("Create$3",[this,this.GetStructTypeInfo().getProperty(A)]);
        };
      };
      Result = rtl.arrayRef(this.FProperties);
      return Result;
    };
    this.GetFields = function () {
      var Result = [];
      var A = 0;
      var Start = 0;
      var BaseClass = null;
      var Declared = [];
      BaseClass = this;
      Result = [];
      while (BaseClass != null) {
        Declared = BaseClass.GetDeclaredFields();
        Start = rtl.length(Result);
        Result = rtl.arraySetLength(Result,null,Start + rtl.length(Declared));
        for (var $l = 0, $end = rtl.length(Declared) - 1; $l <= $end; $l++) {
          A = $l;
          Result[Start + A] = Declared[A];
        };
        BaseClass = BaseClass.GetAncestor();
      };
      return Result;
    };
    this.GetMethod = function (aName) {
      var Result = null;
      var Method = null;
      for (var $in = this.GetMethods(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        if (aName === Method.GetName()) return Method;
      };
      return Result;
    };
    this.GetMethods = function () {
      var Result = [];
      var A = 0;
      var Start = 0;
      var BaseClass = null;
      var Declared = [];
      BaseClass = this;
      Result = [];
      while (BaseClass != null) {
        Declared = BaseClass.GetDeclaredMethods();
        Start = rtl.length(Result);
        Result = rtl.arraySetLength(Result,null,Start + rtl.length(Declared));
        for (var $l = 0, $end = rtl.length(Declared) - 1; $l <= $end; $l++) {
          A = $l;
          Result[Start + A] = Declared[A];
        };
        BaseClass = BaseClass.GetAncestor();
      };
      return Result;
    };
    this.GetMethods$1 = function (aName) {
      var Result = [];
      var Method = null;
      var MethodCount = 0;
      MethodCount = 0;
      for (var $in = this.GetMethods(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        if (aName === Method.GetName()) MethodCount += 1;
      };
      Result = rtl.arraySetLength(Result,null,MethodCount);
      for (var $in1 = this.GetMethods(), $l1 = 0, $end1 = rtl.length($in1) - 1; $l1 <= $end1; $l1++) {
        Method = $in1[$l1];
        if (aName === Method.GetName()) {
          MethodCount -= 1;
          Result[MethodCount] = Method;
        };
      };
      return Result;
    };
    this.GetProperties = function () {
      var Result = [];
      var A = 0;
      var Start = 0;
      var BaseClass = null;
      var Declared = [];
      BaseClass = this;
      Result = [];
      while (BaseClass != null) {
        Declared = BaseClass.GetDeclaredProperties();
        Start = rtl.length(Result);
        Result = rtl.arraySetLength(Result,null,Start + rtl.length(Declared));
        for (var $l = 0, $end = rtl.length(Declared) - 1; $l <= $end; $l++) {
          A = $l;
          Result[Start + A] = Declared[A];
        };
        BaseClass = BaseClass.GetAncestor();
      };
      return Result;
    };
    this.GetProperty = function (AName) {
      var Result = null;
      var Prop = null;
      var lName = "";
      lName = pas.SysUtils.LowerCase(AName);
      for (var $in = this.GetProperties(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Prop = $in[$l];
        if (pas.SysUtils.LowerCase(Prop.GetName()) === lName) return Prop;
      };
      Result = null;
      return Result;
    };
  });
  rtl.createClass(this,"TRttiInstanceType",this.TRttiStructuredType,function () {
    this.GetAncestorType = function () {
      var Result = null;
      Result = rtl.as(this.FParent,$mod.TRttiInstanceType);
      return Result;
    };
    this.GetClassTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetMetaClassType = function () {
      var Result = null;
      Result = this.GetClassTypeInfo().class;
      return Result;
    };
    this.GetAncestor = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.GetBaseType = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoClass)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiStructuredType.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiInterfaceType",this.TRttiStructuredType,function () {
    this.GetAncestorType = function () {
      var Result = null;
      Result = rtl.as($impl.Pool.GetType(this.GetInterfaceTypeInfo().ancestor),$mod.TRttiInterfaceType);
      return Result;
    };
    this.GetGUID = function () {
      var Result = pas.System.TGuid.$new();
      var GUID = "";
      GUID = this.GetInterfaceTypeInfo().interface.$guid;
      pas.SysUtils.TryStringToGUID(GUID,Result);
      return Result;
    };
    this.GetInterfaceTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetAncestor = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.GetBaseType = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoInterface)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiStructuredType.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiRecordType",this.TRttiStructuredType,function () {
    this.GetRecordTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetIsRecord = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoRecord)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiStructuredType.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiClassRefType",this.TRttiType,function () {
    this.GetClassRefTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetInstanceType = function () {
      var Result = null;
      Result = rtl.as($impl.Pool.GetType(this.GetClassRefTypeInfo().instancetype),$mod.TRttiInstanceType);
      return Result;
    };
    this.GetMetaclassType = function () {
      var Result = null;
      Result = this.GetInstanceType().GetMetaClassType();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoClassRef)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiInstanceExternalType",this.TRttiType,function () {
    this.GetAncestor = function () {
      var Result = null;
      Result = rtl.as($impl.Pool.GetType(this.GetExternalClassTypeInfo().ancestor),$mod.TRttiInstanceExternalType);
      return Result;
    };
    this.GetExternalName = function () {
      var Result = "";
      Result = this.GetExternalClassTypeInfo().jsclass;
      return Result;
    };
    this.GetExternalClassTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoExtClass)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiOrdinalType",this.TRttiType,function () {
    this.GetMaxValue = function () {
      var Result = 0;
      Result = this.GetOrdinalTypeInfo().maxvalue;
      return Result;
    };
    this.GetMinValue = function () {
      var Result = 0;
      Result = this.GetOrdinalTypeInfo().minvalue;
      return Result;
    };
    this.GetOrdType = function () {
      var Result = 0;
      Result = this.GetOrdinalTypeInfo().ordtype;
      return Result;
    };
    this.GetOrdinalTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoInteger)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiEnumerationType",this.TRttiOrdinalType,function () {
    this.GetEnumerationTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoEnum)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiOrdinalType.Create$1.apply(this,arguments);
      return this;
    };
    this.GetNames = function () {
      var Result = [];
      var A = 0;
      var NamesSize = 0;
      NamesSize = pas.TypInfo.GetEnumNameCount(this.GetEnumerationTypeInfo());
      Result = rtl.arraySetLength(Result,"",NamesSize);
      for (var $l = 0, $end = NamesSize - 1; $l <= $end; $l++) {
        A = $l;
        Result[A] = this.GetEnumerationTypeInfo().enumtype[A + this.GetMinValue()];
      };
      return Result;
    };
  });
  rtl.createClass(this,"TRttiDynamicArrayType",this.TRttiType,function () {
    this.GetDynArrayTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetElementType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetDynArrayTypeInfo().eltype);
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoDynArray)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  this.$rtti.$RefToProcVar("TVirtualInterfaceInvokeEvent",{procsig: rtl.newTIProcSig([["Method",this.$rtti["TRttiMethod"]],["Args",pas.System.$rtti["TArray<RTTI.TValue>"],2],["Result",this.$rtti["TValue"],4]])});
  this.$rtti.$RefToProcVar("TVirtualInterfaceInvokeEventJS",{procsig: rtl.newTIProcSig([["aMethodName",rtl.string,2],["Args",pas.Types.$rtti["TJSValueDynArray"],2]],rtl.jsvalue)});
  rtl.createClass(this,"TVirtualInterface",pas.System.TInterfacedObject,function () {
    this.$init = function () {
      pas.System.TInterfacedObject.$init.call(this);
      this.FContext = $mod.TRTTIContext.$new();
      this.FInterfaceType = null;
      this.FOnInvoke = null;
      this.FOnInvokeJS = null;
    };
    this.$final = function () {
      this.FContext = undefined;
      this.FInterfaceType = undefined;
      this.FOnInvoke = undefined;
      this.FOnInvokeJS = undefined;
      pas.System.TInterfacedObject.$final.call(this);
    };
    this.Invoke = function (MethodName, Args) {
      var $Self = this;
      var Result = undefined;
      var Method = null;
      var Return = $mod.TValue.$new();
      function GenerateParams() {
        var Result = [];
        var A = 0;
        var Param = null;
        var Parameters = [];
        Parameters = Method.GetParameters();
        Result = rtl.arraySetLength(Result,$mod.TValue,rtl.length(Parameters));
        for (var $l = 0, $end = rtl.length(Parameters) - 1; $l <= $end; $l++) {
          A = $l;
          Param = Parameters[A];
          $mod.TValue.Make(Args[A],Param.FParamType.GetHandle(),Result[A]);
          Result[A].FReferenceVariableData = (pas.TypInfo.TParamFlag.pfVar in Param.FFlags) || (pas.TypInfo.TParamFlag.pfOut in Param.FFlags);
        };
        return Result;
      };
      if (this.FOnInvokeJS != null) {
        Result = this.FOnInvokeJS(MethodName,Args)}
       else {
        Method = this.FInterfaceType.GetMethod(MethodName);
        this.FOnInvoke(Method,GenerateParams(),Return);
        Result = Return.AsJSValue();
      };
      return Result;
    };
    this.Create$1 = function (InterfaceTypeInfo) {
      var $Self = this;
      var SelfInterfaceObject = null;
      var InterfaceObject = null;
      var Method = null;
      var MethodName = "";
      this.FContext.$assign($mod.TRTTIContext.Create());
      this.FInterfaceType = rtl.as(this.FContext.GetType(InterfaceTypeInfo),$mod.TRttiInterfaceType);
      if (this.FInterfaceType.GetInterfaceTypeInfo().interface.$kind !== "com") throw pas.SysUtils.EInvalidCast.$create("Create");
      InterfaceObject = Object.create(this.FInterfaceType.GetInterfaceTypeInfo().interface);
      InterfaceObject.$o = $Self;
      for (var $in = this.FInterfaceType.GetMethods(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        let MethodName = Method.GetName();
        InterfaceObject[MethodName] = function () {
          var Result = undefined;
          Result = this.$o.Invoke(MethodName,arguments);
          return Result;
        };
      };
      InterfaceObject["_AddRef"] = rtl.createCallback($Self,"_AddRef");
      InterfaceObject["_Release"] = rtl.createCallback($Self,"_Release");
      InterfaceObject["QueryInterface"] = rtl.createCallback($Self,"QueryInterface");
      SelfInterfaceObject = $Self;
      SelfInterfaceObject.$intfmaps = new Object();
      SelfInterfaceObject.$intfmaps[pas.SysUtils.GUIDToString(rtl.getIntfGUIDR(pas.System.IUnknown))] = InterfaceObject;
      SelfInterfaceObject.$intfmaps[pas.SysUtils.TGuidHelper.ToString.call(this.FInterfaceType.GetGUID(),false)] = new Object();
      SelfInterfaceObject.$interfaces = new Object();
      SelfInterfaceObject.$interfaces[pas.SysUtils.TGuidHelper.ToString.call(this.FInterfaceType.GetGUID(),false)] = InterfaceObject;
      return this;
    };
    this.Create$2 = function (InterfaceTypeInfo, InvokeEvent) {
      this.Create$1(InterfaceTypeInfo);
      this.FOnInvoke = InvokeEvent;
      return this;
    };
    this.Create$3 = function (InterfaceTypeInfo, InvokeEvent) {
      this.Create$1(InterfaceTypeInfo);
      this.FOnInvokeJS = InvokeEvent;
      return this;
    };
    this.Destroy = function () {
      this.FContext.Free();
      pas.System.TObject.Destroy.call(this);
    };
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      Result = pas.System.TInterfacedObject.QueryInterface.call(this,iid,obj);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.CreateVirtualCorbaInterface = function (InterfaceTypeInfo, MethodImplementation, IntfVar) {
    var IntfType = InterfaceTypeInfo.interface;
    var i = Object.create(IntfType);
    var o = { $name: "virtual", $fullname: "virtual" };
    i.$o = o;
    do {
      var names = IntfType.$names;
      if (!names) break;
      for (var j=0; j<names.length; j++){
        let fnname = names[j];
        i[fnname] = function(){ return MethodImplementation(fnname,arguments); };
      }
      IntfType = Object.getPrototypeOf(IntfType);
    } while(IntfType!=null);
    IntfVar.set(i);
  };
  this.Invoke = function (ACodeAddress, AArgs, ACallConv, AResultType, AIsStatic, AIsConstructor) {
    var Result = $mod.TValue.$new();
    if (ACallConv === pas.TypInfo.TCallConv.ccReg) ;
    if (AIsStatic) ;
    if (AIsConstructor) throw pas.JS.EJS.$create("Create$1",["not supported"]);
    if (rtl.isFunction(ACodeAddress)) {
      Result.FData = ACodeAddress.apply(null,AArgs);
      if (AResultType !== null) {
        Result.FTypeInfo = AResultType}
       else Result.FTypeInfo = rtl.jsvalue;
    } else throw pas.JS.EJS.$create("Create$1",[rtl.getResStr($mod,"SErrInvokeInvalidCodeAddr")]);
    return Result;
  };
  $mod.$resourcestrings = {SErrInvokeInvalidCodeAddr: {org: "CodeAddress is not a function"}, SErrTypeIsNotEnumerated: {org: "Type %s is not an enumerated type"}};
  $mod.$implcode = function () {
    rtl.createClass($impl,"TRttiPoolTypes",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FReferenceCount = 0;
        this.FTypes = null;
      };
      this.$final = function () {
        this.FTypes = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function () {
        pas.System.TObject.Create.call(this);
        this.FTypes = new Object();
        return this;
      };
      this.Destroy = function () {
        var Key = "";
        var RttiObject = null;
        for (Key in this.FTypes) if (this.FTypes.hasOwnProperty(Key)) {
          RttiObject = rtl.getObject(this.FTypes[Key]);
          RttiObject = rtl.freeLoc(RttiObject);
        };
      };
      this.FindType = function (AQualifiedName) {
        var Result = null;
        var ModuleName = "";
        var TypeName = "";
        var Module = null;
        var TypeFound = null;
        if (this.FTypes.hasOwnProperty(AQualifiedName)) {
          Result = rtl.getObject(this.FTypes[AQualifiedName])}
         else {
          Result = null;
          for (var $in = Object.keys(pas), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
            ModuleName = $in[$l];
            if (pas.SysUtils.TStringHelper.StartsWith.call({get: function () {
                return AQualifiedName;
              }, set: function (v) {
                rtl.raiseE("EPropReadOnly");
              }},ModuleName + ".")) {
              Module = pas[ModuleName];
              TypeName = pas.System.Copy(AQualifiedName,ModuleName.length + 2,AQualifiedName.length);
              if (Module.$rtti.hasOwnProperty(TypeName)) {
                TypeFound = Module.$rtti[TypeName];
                return this.GetType(TypeFound);
              };
            };
          };
        };
        return Result;
      };
      this.GetType = function (ATypeInfo) {
        var Result = null;
        var RttiTypeClass = [null,$mod.TRttiOrdinalType,$mod.TRttiOrdinalType,$mod.TRttiType,$mod.TRttiEnumerationType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiDynamicArrayType,$mod.TRttiRecordType,$mod.TRttiInstanceType,$mod.TRttiClassRefType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiInterfaceType,$mod.TRttiType,$mod.TRttiInstanceExternalType];
        var Name = "";
        var Parent = null;
        if (pas.JS.isNull(ATypeInfo) || pas.JS.isUndefined(ATypeInfo)) return null;
        Name = ATypeInfo.name;
        if (rtl.isModule(ATypeInfo.$module)) Name = ATypeInfo.$module.$name + "." + Name;
        if (this.FTypes.hasOwnProperty(Name)) {
          Result = rtl.getObject(this.FTypes[Name])}
         else {
          if ((ATypeInfo.kind in rtl.createSet(pas.System.TTypeKind.tkClass,pas.System.TTypeKind.tkInterface,pas.System.TTypeKind.tkHelper,pas.System.TTypeKind.tkExtClass)) && ATypeInfo.hasOwnProperty("ancestor")) {
            Parent = this.GetType(ATypeInfo["ancestor"])}
           else Parent = null;
          Result = RttiTypeClass[ATypeInfo.kind].$create("Create$1",[Parent,ATypeInfo]);
          this.FTypes[Name] = Result;
        };
        return Result;
      };
      this.GetType$1 = function (AClass) {
        var Result = null;
        if (AClass === null) return null;
        Result = this.GetType(AClass.$rtti);
        return Result;
      };
      this.AcquireContext = function () {
        var Result = null;
        if (!($impl.Pool != null)) $impl.Pool = $impl.TRttiPoolTypes.$create("Create$1");
        Result = $impl.Pool.FTypes;
        $impl.Pool.FReferenceCount += 1;
        return Result;
      };
      this.ReleaseContext = function () {
        $impl.Pool.FReferenceCount -= 1;
        if ($impl.Pool.FReferenceCount === 0) pas.SysUtils.FreeAndNil({p: $impl, get: function () {
            return this.p.Pool;
          }, set: function (v) {
            this.p.Pool = v;
          }});
      };
    });
    $impl.Pool = null;
  };
},[]);
rtl.module("WEBLib.JSON",["System","Classes","Web","JS","SysUtils","RTTI"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TJSONObject");
  this.$rtti.$Class("TJSONString");
  rtl.createClass(this,"TJSONAncestor",pas.System.TObject,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.SetStrValue = function (Value) {
    };
  });
  rtl.createClass(this,"TJSONValue",this.TJSONAncestor,function () {
    this.$init = function () {
      $mod.TJSONAncestor.$init.call(this);
      this.fjv = undefined;
      this.fjo = undefined;
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = "" + this.fjv;
      return Result;
    };
    this.JSONValueFromJS = function (AJSValue) {
      var Result = null;
      var d = 0.0;
      Result = null;
      if (rtl.isArray(AJSValue)) {
        Result = $mod.TJSONArray.$create("Create");
        rtl.as(Result,$mod.TJSONArray).fja = AJSValue;
      } else if (rtl.isObject(AJSValue)) {
        Result = $mod.TJSONObject.$create("Create$2");
        rtl.as(Result,$mod.TJSONObject).fjo$1 = AJSValue;
      } else if (rtl.isString(AJSValue)) {
        Result = $mod.TJSONString.$create("Create");
        rtl.as(Result,$mod.TJSONString).SetStrValue("" + AJSValue);
      } else if (rtl.isNumber(AJSValue)) {
        Result = $mod.TJSONNumber.$create("Create");
        rtl.as(Result,$mod.TJSONNumber).SetStrValue("" + AJSValue);
        d = rtl.getNumber(AJSValue);
        rtl.as(Result,$mod.TJSONNumber).FDouble = d;
        if (pas.System.Frac(d) === 0) rtl.as(Result,$mod.TJSONNumber).FInt = rtl.trunc(AJSValue);
      } else if (pas.JS.isNull(AJSValue)) {
        Result = $mod.TJSONNull.$create("Create")}
       else if (pas.JS.isBoolean(AJSValue)) {
        if (pas.JS.toBoolean(AJSValue)) {
          Result = $mod.TJSONTrue.$create("Create$3")}
         else Result = $mod.TJSONFalse.$create("Create$3");
      };
      if (!(Result != null)) Result = $mod.TJSONNull.$create("Create");
      Result.fjv = AJSValue;
      return Result;
    };
    this.Create$1 = function (AJSValue) {
      pas.System.TObject.Create.call(this);
      this.fjv = AJSValue;
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = JSON.stringify(this.fjv);
      return Result;
    };
    this.GetJSValue = function () {
      var Result = undefined;
      Result = this.fjv;
      return Result;
    };
  });
  rtl.createClass(this,"TJSONPair",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.fjo = undefined;
      this.fjv = null;
      this.fjs = null;
    };
    this.$final = function () {
      this.fjv = undefined;
      this.fjs = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.fjs = $mod.TJSONString.$create("Create");
      return this;
    };
    this.Create$2 = function (Str, Value) {
      pas.System.TObject.Create.call(this);
      this.fjs = $mod.TJSONString.$create("Create$2",[Str]);
      this.fjv = Value;
      return this;
    };
    this.Create$3 = function (Str, Value) {
      pas.System.TObject.Create.call(this);
      this.fjs = $mod.TJSONString.$create("Create$2",[Str]);
      this.fjv = $mod.TJSONString.$create("Create$2",[Value]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"fjs");
      pas.System.TObject.Destroy.call(this);
    };
    this.ToString = function () {
      var Result = "";
      if ($mod.TJSONObject.isPrototypeOf(this.fjv)) {
        Result = '"' + this.fjs.GetStrValue() + '":' + rtl.as(this.fjv,$mod.TJSONObject).ToJSON()}
       else {
        if ((this.fjs !== null) && (this.fjv !== null)) {
          Result = '"' + this.fjs.GetStrValue() + '":' + this.fjv.ToString()}
         else Result = "";
      };
      return Result;
    };
  });
  rtl.createClass(this,"TJSONPairList",pas.Classes.TList,function () {
  });
  rtl.createClass(this,"TJSONObject",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.fjo$1 = null;
      this.FMembers = null;
    };
    this.$final = function () {
      this.fjo$1 = undefined;
      this.FMembers = undefined;
      $mod.TJSONValue.$final.call(this);
    };
    this.GetPair = function (I) {
      var Result = null;
      var v = null;
      var l = 0;
      var s = "";
      var jv = undefined;
      if ((this.FMembers.GetCount() === 0) && (this.fjo$1 != null) && (rtl.length(Object.keys(this.fjo$1)) > 0)) {
        l = rtl.length(Object.keys(this.fjo$1));
        if (I < l) {
          jv = this.fjo$1[Object.keys(this.fjo$1)[I]];
          v = this.$class.JSONValueFromJS(jv);
          s = Object.keys(this.fjo$1)[I];
          Result = $mod.TJSONPair.$create("Create$2",[s,v]);
          return Result;
        };
      };
      if ((I >= 0) && (I < this.FMembers.GetCount())) {
        Result = rtl.getObject(this.FMembers.Get(I))}
       else Result = null;
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      if (this.fjo$1 != null) {
        Result = rtl.length(Object.keys(this.fjo$1))}
       else if (this.FMembers != null) {
        Result = this.FMembers.GetCount()}
       else Result = 0;
      return Result;
    };
    this.GetItem = function (Index) {
      var Result = null;
      var jv = undefined;
      jv = this.fjo$1[Object.keys(this.fjo$1)[Index]];
      Result = this.$class.JSONValueFromJS(jv);
      return Result;
    };
    this.SetValues = function (Name, Value) {
      var O = null;
      O = this.fjo$1;
      O[Name] = Value;
    };
    this.AddDescendant = function (Descendent) {
      this.FMembers.Add(Descendent);
    };
    this.Create$2 = function () {
      pas.System.TObject.Create.call(this);
      this.FMembers = $mod.TJSONPairList.$create("Create$1");
      this.fjo$1 = null;
      return this;
    };
    this.Create$3 = function (AObject) {
      pas.System.TObject.Create.call(this);
      this.FMembers = $mod.TJSONPairList.$create("Create$1");
      this.fjo$1 = AObject;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FMembers");
      pas.System.TObject.Destroy.call(this);
    };
    this.ParseJSONValue = function (data) {
      var Result = null;
      var O = null;
      O = JSON.parse(data);
      Result = this.JSONValueFromJS(O);
      return Result;
    };
    this.GetJSONValue = function (Name) {
      var Result = "";
      var jv = undefined;
      jv = this.fjo$1[Name];
      Result = $impl.JSONObjectToString(jv);
      return Result;
    };
    this.Get = function (Name) {
      var Result = null;
      var jv = undefined;
      var jsv = null;
      var i = 0;
      var p = null;
      Result = null;
      if (this.fjo$1 != null) {
        jv = this.fjo$1[Name];
        if ((jv != undefined) || (jv === null)) {
          Result = $mod.TJSONPair.$create("Create$1");
          jsv = this.$class.JSONValueFromJS(jv);
          Result.fjo = this.fjo$1;
          Result.fjs.SetStrValue(Name);
          Result.fjv = jsv;
        };
      } else {
        for (var $l = 0, $end = this.FMembers.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          p = rtl.getObject(this.FMembers.Get(i));
          if (p.fjs.ToString() === ('"' + Name + '"')) Result = p;
        };
      };
      return Result;
    };
    this.Get$1 = function (Index) {
      var Result = null;
      Result = this.Get(Object.keys(this.fjo$1)[Index]);
      return Result;
    };
    this.GetValue$1 = function (Name) {
      var Result = null;
      var jp = null;
      Result = null;
      jp = this.Get(Name);
      if (jp != null) {
        Result = jp.fjv;
        Result.fjo = jp.fjo;
      };
      return Result;
    };
    this.GetObjectValue = function (APath) {
      var Result = null;
      Result = this.GetValue$1(APath);
      return Result;
    };
    this.SetValue = function (Name, AValue) {
      var O = null;
      O = this.fjo$1;
      O[Name] = AValue;
    };
    this.SetValue$1 = function (Name, AValue) {
      var O = null;
      O = this.fjo$1;
      O[Name] = AValue;
    };
    this.SetValue$2 = function (Name, AValue) {
      var O = null;
      O = this.fjo$1;
      O[Name] = AValue;
    };
    this.AddPair = function (Pair) {
      var Result = null;
      var o = null;
      if (Pair != null) {
        this.AddDescendant(Pair);
        if (this.fjo$1 != null) {
          o = this.fjo$1;
          if ($mod.TJSONArray.isPrototypeOf(Pair.fjv)) {
            o[Pair.fjs.FValue] = Pair.fjv.fja;
          } else {
            o[Pair.fjs.FValue] = Pair.fjv.fjv;
          };
        };
      };
      Result = this;
      return Result;
    };
    this.AddPair$1 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,Val]));
      Result = this;
      return Result;
    };
    this.AddPair$2 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$3",[Str,Val]));
      Result = this;
      return Result;
    };
    this.AddPair$3 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONNumber.$create("Create$3",[Val])]));
      Result = this;
      return Result;
    };
    this.AddPair$4 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONNumber.$create("Create$4",[Val])]));
      Result = this;
      return Result;
    };
    this.AddPair$5 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONNumber.$create("Create$5",[Val])]));
      Result = this;
      return Result;
    };
    this.AddPair$6 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONBool.$create("Create$2",[Val])]));
      Result = this;
      return Result;
    };
    this.RemovePair = function (PairName) {
      var Result = null;
      var o = null;
      var p = null;
      var i = 0;
      Result = null;
      if (this.fjo$1 != null) {
        o = this.fjo$1;
        delete o[PairName];
      } else {
        for (var $l = 0, $end = this.FMembers.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          p = rtl.getObject(this.FMembers.Get(i));
          if (p.fjs.ToString() === ('"' + PairName + '"')) {
            Result = p;
            this.FMembers.Delete(i);
            break;
          };
        };
      };
      return Result;
    };
    this.ToJSON = function () {
      var Result = "";
      var s = "";
      var Size = 0;
      var I = 0;
      var jp = null;
      if (this.fjo$1 != null) {
        Size = this.GetCount()}
       else Size = this.FMembers.GetCount();
      s = "{";
      if (Size > 0) {
        if (this.fjo$1 != null) {
          jp = this.Get$1(0);
          if (jp != null) {
            s = s + jp.ToString()}
           else s = s + '"' + Object.keys(this.fjo$1)[0] + '":null';
        } else s = s + rtl.getObject(this.FMembers.Get(0)).ToString();
      };
      for (var $l = 1, $end = Size - 1; $l <= $end; $l++) {
        I = $l;
        if (this.fjo$1 != null) {
          jp = this.Get$1(I);
          if (jp != null) {
            s = s + "," + jp.ToString()}
           else s = s + "," + '"' + Object.keys(this.fjo$1)[I] + '":null';
        } else s = s + "," + rtl.getObject(this.FMembers.Get(I)).ToString();
      };
      s = s + "}";
      Result = s;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.ToJSON();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONString",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.FValue = "";
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = this.FValue;
      return Result;
    };
    this.SetStrValue = function (Value) {
      this.FValue = Value;
      this.fjv = Value;
      if (pas.System.Assigned(this.fjo)) {
        var s = Object.keys(this.fjo)[0];
        this.fjo[s] = Value;
      };
    };
    this.Create$2 = function (AString) {
      pas.System.TObject.Create.call(this);
      this.fjv = AString;
      this.FValue = AString;
      return this;
    };
  });
  rtl.createClass(this,"TJSONNumber",this.TJSONString,function () {
    this.$init = function () {
      $mod.TJSONString.$init.call(this);
      this.FInt = 0;
      this.FInt64 = 0;
      this.FDouble = 0.0;
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = pas.SysUtils.FloatToStr$1(this.FDouble,pas.SysUtils.TFormatSettings.Invariant());
      return Result;
    };
    this.SetStrValue = function (Value) {
      this.FDouble = pas.SysUtils.StrToFloat$1(Value,pas.SysUtils.TFormatSettings.Invariant());
      if (pas.System.Frac(this.FDouble) === 0) {
        if (!pas.SysUtils.TryStrToInt64$1(Value,{p: this, get: function () {
            return this.p.FInt64;
          }, set: function (v) {
            this.p.FInt64 = v;
          }},pas.SysUtils.TFormatSettings.Invariant())) this.FInt64 = 0;
        this.FInt = this.FInt64;
        this.fjv = this.FInt64;
      } else this.fjv = this.FDouble;
    };
    this.Create$3 = function (ANumber) {
      pas.System.TObject.Create.call(this);
      this.fjv = ANumber;
      this.FInt = ANumber;
      this.FInt64 = ANumber;
      this.FDouble = ANumber;
      return this;
    };
    this.Create$4 = function (ANumber) {
      pas.System.TObject.Create.call(this);
      this.fjv = ANumber;
      this.FInt = ANumber & 0xFFFFFFFF;
      this.FInt64 = ANumber;
      this.FDouble = ANumber;
      return this;
    };
    this.Create$5 = function (ANumber) {
      pas.System.TObject.Create.call(this);
      this.fjv = ANumber;
      this.FInt = pas.System.Trunc(ANumber);
      this.FInt64 = pas.System.Trunc(ANumber);
      this.FDouble = ANumber;
      return this;
    };
  });
  rtl.createClass(this,"TJSONBool",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.FBool = false;
    };
    this.SetStrValue = function (Value) {
      var s = "";
      s = pas.SysUtils.UpperCase(Value);
      this.FBool = s === "TRUE";
    };
    this.Create$2 = function (AValue) {
      $mod.TJSONValue.Create$1.call(this,AValue);
      this.FBool = AValue;
      return this;
    };
  });
  rtl.createClass(this,"TJSONTrue",this.TJSONBool,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "true";
      return Result;
    };
    this.Create$3 = function () {
      $mod.TJSONBool.Create$2.call(this,true);
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONFalse",this.TJSONBool,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "false";
      return Result;
    };
    this.Create$3 = function () {
      $mod.TJSONBool.Create$2.call(this,false);
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONNull",this.TJSONValue,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "null";
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
  });
  this.$rtti.$Class("TJSONArray");
  rtl.createClass(this,"TJSONArrayEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FJSONArray = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FJSONArray = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AJSONArray) {
      pas.System.TObject.Create.call(this);
      this.FJSONArray = AJSONArray;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FJSONArray.GetItem(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FJSONArray.GetCount();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONArray",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.fja = null;
    };
    this.$final = function () {
      this.fja = undefined;
      $mod.TJSONValue.$final.call(this);
    };
    this.GetItem = function (index) {
      var Result = null;
      var jv = undefined;
      jv = this.GetJA()[index];
      if (rtl.isExt(jv,$mod.TJSONObject,1) || rtl.isExt(jv,$mod.TJSONArray,1)) {
        Result = rtl.getObject(jv)}
       else Result = this.$class.JSONValueFromJS(jv);
      return Result;
    };
    this.SetItem = function (index, Value) {
      if ($mod.TJSONObject.isPrototypeOf(Value)) this.GetJA()[index] = Value.fjo$1;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.GetJA().length;
      return Result;
    };
    this.GetJA = function () {
      var Result = null;
      if (!(this.fja != null)) this.fja = new Array();
      Result = this.fja;
      return Result;
    };
    this.Create$2 = function (AArray) {
      pas.System.TObject.Create.call(this);
      this.fja = AArray;
      return this;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TJSONArrayEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Add = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$1 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$2 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$3 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$4 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$5 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$6 = function (Element) {
      this.GetJA().push(Element);
    };
    this.AddElement = function (Element) {
      this.GetJA().push(Element);
    };
    this.ToJSON = function () {
      var Result = "";
      Result = this.ToString();
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      var i = 0;
      var jv = null;
      var comma = "";
      Result = "[";
      comma = "";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        jv = this.GetItem(i);
        if (jv != null) {
          if ($mod.TJSONObject.isPrototypeOf(jv)) {
            Result = Result + comma + rtl.as(jv,$mod.TJSONObject).ToString();
          } else Result = Result + comma + jv.ToString();
          comma = ",";
        };
      };
      Result = Result + "]";
      return Result;
    };
  });
  rtl.createClass(this,"TJSON",pas.System.TObject,function () {
    this.Parse = function (s) {
      var Result = null;
      var O = null;
      O = JSON.parse(s);
      if (rtl.isArray(O)) {
        Result = $mod.TJSONArray.$create("Create$2",[O]);
      } else {
        Result = $mod.TJSONObject.$create("Create$3",[O]);
      };
      return Result;
    };
  });
  $mod.$implcode = function () {
    $impl.JSONObjectToString = function (v) {
      return v+"";
    };
  };
},["TypInfo"]);
rtl.module("WEBLib.Storage",["System","Web","Classes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$MethodVar("TStorageChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AKey",rtl.string],["AOldValue",rtl.string],["ANewValue",rtl.string],["AURL",rtl.string]]), methodkind: 0});
  rtl.createClass(this,"TLocalStorage",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FChangePtr = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetValues = function (AKey, AValue) {
      window.localStorage.setItem(AKey,AValue);
    };
    this.GetValues = function (AKey) {
      var Result = "";
      var s = "";
      s = window.localStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.GetKey = function (AIndex) {
      var Result = "";
      Result = window.localStorage.key(AIndex);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = window.localStorage.length;
      return Result;
    };
    this.StorageChanged = function (AEvent) {
      var s = "";
      s = AEvent.storageArea + " ";
      if ((this.FOnChange != null) && (pas.System.Pos("OBJECT",pas.SysUtils.UpperCase(s)) > 0)) this.FOnChange(this,AEvent.key,AEvent.oldValue,AEvent.newValue,AEvent.url);
    };
    this.Create$1 = function (AOwner) {
      this.FChangePtr = rtl.createCallback(this,"StorageChanged");
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      window.addEventListener("storage",this.FChangePtr);
      return this;
    };
    this.Destroy = function () {
      window.removeEventListener("storage",this.FChangePtr);
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Clear = function () {
      window.localStorage.clear();
    };
    this.SetValue = function (AKey, AValue) {
      window.localStorage.setItem(AKey,AValue);
    };
    this.GetValue = function (AKey) {
      var Result = "";
      var s = "";
      s = window.localStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.RemoveKey = function (AKey) {
      window.localStorage.removeItem(AKey);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnChange",0,$mod.$rtti["TStorageChangeEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TWebLocalStorage",this.TLocalStorage,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSessionStorage",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FChangePtr = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetValues = function (AKey, AValue) {
      window.sessionStorage.setItem(AKey,AValue);
    };
    this.GetValues = function (AKey) {
      var Result = "";
      var s = "";
      s = window.sessionStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.GetKey = function (AIndex) {
      var Result = "";
      Result = window.sessionStorage.key(AIndex);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = window.sessionStorage.length;
      return Result;
    };
    this.StorageChanged = function (AEvent) {
      var s = "";
      s = AEvent.storageArea + " ";
      if ((this.FOnChange != null) && (pas.System.Pos("OBJECT",pas.SysUtils.UpperCase(s)) === 0)) this.FOnChange(this,AEvent.key,AEvent.oldValue,AEvent.newValue,AEvent.url);
    };
    this.Create$1 = function (AOwner) {
      this.FChangePtr = rtl.createCallback(this,"StorageChanged");
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      window.addEventListener("storage",this.FChangePtr);
      return this;
    };
    this.Destroy = function () {
      window.removeEventListener("storage",this.FChangePtr);
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Clear = function () {
      window.sessionStorage.clear();
    };
    this.SetValue = function (AKey, AValue) {
      window.sessionStorage.setItem(AKey,AValue);
    };
    this.GetValue = function (AKey) {
      var Result = "";
      var s = "";
      s = window.sessionStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.RemoveKey = function (AKey) {
      window.sessionStorage.removeItem(AKey);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnChange",0,$mod.$rtti["TStorageChangeEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TWebSessionStorage",this.TSessionStorage,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
},["SysUtils"]);
rtl.module("WEBLib.REST",["System","Classes","Web","JS","SysUtils","WEBLib.Controls","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.ContentTypeJSON = "application/json;charset=UTF-8";
  this.ContentTypeForm = "application/x-www-form-urlencoded";
  this.THTTPCommand = {"0": "httpGET", httpGET: 0, "1": "httpPOST", httpPOST: 1, "2": "httpPUT", httpPUT: 2, "3": "httpDELETE", httpDELETE: 3, "4": "httpHEAD", httpHEAD: 4, "5": "httpPATCH", httpPATCH: 5, "6": "httpCUSTOM", httpCUSTOM: 6};
  this.$rtti.$Enum("THTTPCommand",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.THTTPCommand});
  this.THTTPRequestResponseType = {"0": "rtDefault", rtDefault: 0, "1": "rtText", rtText: 1, "2": "rtBlob", rtBlob: 2, "3": "rtJSON", rtJSON: 3, "4": "rtDocument", rtDocument: 4, "5": "rtArrayBuffer", rtArrayBuffer: 5};
  this.$rtti.$Enum("THTTPRequestResponseType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.THTTPRequestResponseType});
  this.$rtti.$RefToProcVar("THTTPResponseProc",{procsig: rtl.newTIProcSig([["AResponse",rtl.string],["ARequest",pas.Web.$rtti["TJSXMLHttpRequest"]]])});
  this.$rtti.$RefToProcVar("THTTPErrorProc",{procsig: rtl.newTIProcSig([["ARequest",pas.Web.$rtti["TJSXMLHttpRequest"]]])});
  this.$rtti.$RefToProcVar("THTTPRequestHandler",{procsig: rtl.newTIProcSig([["Event",pas.Web.$rtti["TJSEvent"]]])});
  this.$rtti.$MethodVar("THTTPProgressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Position",rtl.nativeint],["Total",rtl.nativeint]]), methodkind: 0});
  rtl.createClass(this,"THttpRequest",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FURL = "";
      this.FOnResponse = null;
      this.FOnAbort = null;
      this.FHeaders = null;
      this.FCommand = 0;
      this.FCustomCommand = "";
      this.FWithCredentials = false;
      this.FPostData = "";
      this.FOnRequestResponse = null;
      this.FPassword = "";
      this.FUser = "";
      this.FTimeout = 0;
      this.FOnTimeout = null;
      this.FOnError = null;
      this.FResponse = null;
      this.FErrorProc = null;
      this.FTimeOutProc = null;
      this.FResponseType = 0;
      this.FOnProgress = null;
    };
    this.$final = function () {
      this.FOnResponse = undefined;
      this.FOnAbort = undefined;
      this.FHeaders = undefined;
      this.FOnRequestResponse = undefined;
      this.FOnTimeout = undefined;
      this.FOnError = undefined;
      this.FResponse = undefined;
      this.FErrorProc = undefined;
      this.FTimeOutProc = undefined;
      this.FOnProgress = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.HandleResponse = function (Event) {
      var Result = false;
      var s = "";
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      LRequestRec.req = Event.target;
      s = "";
      if (this.FResponseType in rtl.createSet($mod.THTTPRequestResponseType.rtText,$mod.THTTPRequestResponseType.rtDefault)) {
        s = Event.target.responseText;
      };
      if (this.FOnRequestResponse != null) {
        this.FOnRequestResponse(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),s);
      };
      if (this.FOnResponse != null) this.FOnResponse(this,s);
      if (this.FResponse != null) {
        this.FResponse(s,LRequestRec.req);
      };
      Result = true;
      return Result;
    };
    this.HandleAbort = function (Event) {
      var Result = false;
      if (this.FOnAbort != null) this.FOnAbort(this);
      Result = true;
      return Result;
    };
    this.HandleTimeout = function (Event) {
      var Result = false;
      if (this.FOnTimeout != null) this.FOnTimeout(this);
      if (this.FTimeOutProc != null) this.FTimeOutProc(Event.target);
      Result = true;
      return Result;
    };
    this.HandleError = function (Event) {
      var Result = false;
      var Handled = false;
      var LEventRec = pas["WEBLib.Controls"].TJSEventRecord.$new();
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      Result = true;
      Handled = false;
      if (this.FOnError != null) {
        LEventRec.event = Event;
        LRequestRec.req = Event.target;
        this.FOnError(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),pas["WEBLib.Controls"].TJSEventRecord.$clone(LEventRec),{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
      };
      if (this.FErrorProc != null) this.FErrorProc(LRequestRec.req);
      if (!Handled) throw pas.SysUtils.Exception.$create("Create$1",["HTTP request error @" + this.FURL]);
      return Result;
    };
    this.HandleProgress = function (Event) {
      var Result = false;
      var position = 0;
      var total = 0;
      Result = true;
      position = Event.loaded;
      total = Event.total;
      if (this.FOnProgress != null) this.FOnProgress(this,position,total);
      return Result;
    };
    this.HandleReadyStateChange = function (Event) {
      var Result = false;
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      var sz = "";
      Result = true;
      LRequestRec.req = Event.target;
      if (LRequestRec.req.readyState === 4) {
        if ((LRequestRec.req.status >= 200) && (LRequestRec.req.status < 300)) {
          sz = LRequestRec.req.getResponseHeader("Content-Length");
          if (this.FResponse != null) {
            this.FResponse(sz,LRequestRec.req);
          };
        } else if (this.FErrorProc != null) this.FErrorProc(LRequestRec.req);
      };
      return Result;
    };
    this.SetHeaders = function (AValue) {
      this.FHeaders.Assign(AValue);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FHeaders = pas.Classes.TStringList.$create("Create$1");
      this.FResponseType = $mod.THTTPRequestResponseType.rtDefault;
      this.FCommand = $mod.THTTPCommand.httpGET;
      this.FTimeout = 0;
      this.FResponse = null;
      this.FWithCredentials = false;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHeaders");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Loaded = function () {
      var i = 0;
      var j = 0;
      var s = "";
      var flg = false;
      pas.Classes.TComponent.Loaded.call(this);
      for (var $l = 0, $end = this.FHeaders.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        s = this.FHeaders.Get(i);
        flg = false;
        for (var $l1 = 1, $end1 = s.length; $l1 <= $end1; $l1++) {
          j = $l1;
          if ((s.charAt(j - 1) === ":") && !flg) {
            s = rtl.setCharAt(s,j - 1,"=");
            flg = true;
          } else if ((s.charAt(j - 1) === "=") && flg) {
            s = rtl.setCharAt(s,j - 1,":");
          };
        };
        this.FHeaders.Put(i,s);
      };
    };
    this.GetResponseType = function (AResponseType) {
      var Result = "";
      Result = "";
      var $tmp = AResponseType;
      if ($tmp === $mod.THTTPRequestResponseType.rtText) {
        Result = "text"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtBlob) {
        Result = "blob"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtDocument) {
        Result = "document"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtJSON) {
        Result = "json"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtArrayBuffer) Result = "arraybuffer";
      return Result;
    };
    this.ExecuteSizeRequest = function (AResponse, AError, ATimeOut) {
      var i = 0;
      var req = null;
      var headname = "";
      var headvalue = "";
      this.FResponse = AResponse;
      this.FErrorProc = AError;
      this.FTimeOutProc = ATimeOut;
      req = new XMLHttpRequest();
      req.addEventListener("readystatechange",rtl.createSafeCallback(this,"HandleReadyStateChange"));
      req.addEventListener("timeout",rtl.createSafeCallback(this,"HandleTimeout"));
      req.addEventListener("error",rtl.createSafeCallback(this,"HandleError"));
      req.withCredentials = this.FWithCredentials;
      if (this.FTimeout !== 0) req.timeout = this.FTimeout;
      if (this.FUser !== "") {
        req.open("HEAD",this.FURL,true,this.FUser,this.FPassword);
        req.setRequestHeader("X-Requested-With","XMLHttpRequest");
      } else req.open("HEAD",this.FURL);
      for (var $l = 0, $end = this.FHeaders.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FHeaders.GetNameValue(i,{get: function () {
            return headname;
          }, set: function (v) {
            headname = v;
          }},{get: function () {
            return headvalue;
          }, set: function (v) {
            headvalue = v;
          }});
        req.setRequestHeader(headname,headvalue);
      };
      if (this.FUser !== "") req.setRequestHeader("Authorization","Basic " + window.btoa(this.FUser + ":" + this.FPassword));
      req.send();
    };
    this.Execute = function (AResponse) {
      this.Execute$2(AResponse,null,null);
    };
    this.Execute$1 = function (AResponse, AError) {
      this.Execute$2(AResponse,AError,null);
    };
    this.Execute$2 = function (AResponse, AError, ATimeOut) {
      var i = 0;
      var cmd = "";
      var req = null;
      var headname = "";
      var headvalue = "";
      this.FResponse = AResponse;
      this.FErrorProc = AError;
      this.FTimeOutProc = ATimeOut;
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(this,"HandleResponse"));
      req.addEventListener("abort",rtl.createSafeCallback(this,"HandleAbort"));
      req.addEventListener("timeout",rtl.createSafeCallback(this,"HandleTimeout"));
      req.addEventListener("error",rtl.createSafeCallback(this,"HandleError"));
      req.addEventListener("progress",rtl.createSafeCallback(this,"HandleProgress"));
      req.responseType = $mod.THttpRequest.GetResponseType(this.FResponseType);
      req.withCredentials = this.FWithCredentials;
      cmd = $mod.HTTPCommand(this.FCommand,this.FCustomCommand);
      if (this.FTimeout !== 0) req.timeout = this.FTimeout;
      if (this.FUser !== "") {
        req.open(cmd,this.FURL,true);
        req.setRequestHeader("X-Requested-With","XMLHttpRequest");
      } else req.open(cmd,this.FURL);
      for (var $l = 0, $end = this.FHeaders.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FHeaders.GetNameValue(i,{get: function () {
            return headname;
          }, set: function (v) {
            headname = v;
          }},{get: function () {
            return headvalue;
          }, set: function (v) {
            headvalue = v;
          }});
        req.setRequestHeader(headname,headvalue);
      };
      if (this.FUser !== "") req.setRequestHeader("Authorization","Basic " + window.btoa(this.FUser + ":" + this.FPassword));
      if (this.FPostData !== "") {
        req.send(this.FPostData)}
       else req.send();
    };
    this.GetSize = function () {
      var $Self = this;
      var Result = null;
      var sz = 0;
      var e = 0;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ExecuteSizeRequest(function (AResponse, ARequest) {
          pas.System.val(AResponse,{get: function () {
              return sz;
            }, set: function (v) {
              sz = v;
            }},{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          ASuccess(sz);
        },function (ARequest) {
          AFailed(0);
        },function (ARequest) {
          AFailed(ARequest);
        });
      });
      return Result;
    };
    this.Perform = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.Execute$2(function (AResponse, ARequest) {
          ASuccess(ARequest);
        },function (ARequest) {
          AFailed(ARequest);
        },function (ARequest) {
          AFailed(ARequest);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Command",0,$mod.$rtti["THTTPCommand"],"FCommand","FCommand");
    $r.addProperty("CustomCommand",0,rtl.string,"FCustomCommand","FCustomCommand");
    $r.addProperty("Headers",2,pas.Classes.$rtti["TStringList"],"FHeaders","SetHeaders");
    $r.addProperty("Password",0,rtl.string,"FPassword","FPassword");
    $r.addProperty("PostData",0,rtl.string,"FPostData","FPostData");
    $r.addProperty("ResponseType",0,$mod.$rtti["THTTPRequestResponseType"],"FResponseType","FResponseType",4,{Default: $mod.THTTPRequestResponseType.rtDefault});
    $r.addProperty("Timeout",0,rtl.longint,"FTimeout","FTimeout",4,{Default: 0});
    $r.addProperty("URL",0,rtl.string,"FURL","FURL");
    $r.addProperty("User",0,rtl.string,"FUser","FUser");
    $r.addProperty("WithCredentials",0,rtl.boolean,"FWithCredentials","FWithCredentials",4,{Default: false});
    $r.addProperty("OnError",0,pas["WEBLib.Controls"].$rtti["THTTPErrorEvent"],"FOnError","FOnError");
    $r.addProperty("OnAbort",0,pas["WEBLib.Controls"].$rtti["THTTPAbortEvent"],"FOnAbort","FOnAbort");
    $r.addProperty("OnProgress",0,$mod.$rtti["THTTPProgressEvent"],"FOnProgress","FOnProgress");
    $r.addProperty("OnRequestResponse",0,pas["WEBLib.Controls"].$rtti["THTTPRequestResponseEvent"],"FOnRequestResponse","FOnRequestResponse");
    $r.addProperty("OnResponse",0,pas["WEBLib.Controls"].$rtti["THTTPResponseEvent"],"FOnResponse","FOnResponse");
    $r.addProperty("OnTimeout",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnTimeout","FOnTimeout");
  });
  rtl.createClass(this,"TWebHTTPRequest",this.THttpRequest,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("THttpResponse",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TInternalHttpResponse",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AResponse",rtl.string],["Handled",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TPersistTokens",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FKey = "";
      this.FEnabled = false;
    };
    this.Create$1 = function () {
      this.FEnabled = false;
      this.FKey = "";
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TPersistTokens.isPrototypeOf(Source)) {
        this.FKey = rtl.as(Source,$mod.TPersistTokens).FKey;
        this.FEnabled = rtl.as(Source,$mod.TPersistTokens).FEnabled;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Key",0,rtl.string,"FKey","FKey");
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",4,{Default: false});
  });
  rtl.createClass(this,"TRESTApp",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FKey = "";
      this.FCallbackURL = "";
      this.FSecret = "";
      this.FAuthURL = "";
      this.FClientID = "";
    };
    this.GetKey = function () {
      var Result = "";
      if ((this.FKey !== "") && (this.FClientID === "")) {
        Result = this.FKey}
       else Result = this.FClientID;
      return Result;
    };
    this.Assign = function (Source) {
      if ($mod.TRESTApp.isPrototypeOf(Source)) {
        this.FKey = rtl.as(Source,$mod.TRESTApp).FKey;
        this.FClientID = rtl.as(Source,$mod.TRESTApp).FClientID;
        this.FCallbackURL = rtl.as(Source,$mod.TRESTApp).FCallbackURL;
        this.FSecret = rtl.as(Source,$mod.TRESTApp).FSecret;
        this.FAuthURL = rtl.as(Source,$mod.TRESTApp).FAuthURL;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("AuthURL",0,rtl.string,"FAuthURL","FAuthURL");
    $r.addProperty("ClientID",0,rtl.string,"FClientID","FClientID");
    $r.addProperty("Key",0,rtl.string,"FKey","FKey");
    $r.addProperty("CallbackURL",0,rtl.string,"FCallbackURL","FCallbackURL");
    $r.addProperty("Secret",0,rtl.string,"FSecret","FSecret");
  });
  this.TAuthLocale = {"0": "lcDefault", lcDefault: 0, "1": "lcEnglish", lcEnglish: 1, "2": "lcDutch", lcDutch: 2, "3": "lcGerman", lcGerman: 3, "4": "lcFrench", lcFrench: 4, "5": "lcSpanish", lcSpanish: 5, "6": "lcItalian", lcItalian: 6, "7": "lcPortuguese", lcPortuguese: 7, "8": "lcGreek", lcGreek: 8, "9": "lcDanish", lcDanish: 9, "10": "lcRussian", lcRussian: 10, "11": "lcRomanian", lcRomanian: 11, "12": "lcSwedish", lcSwedish: 12, "13": "lcFinnish", lcFinnish: 13, "14": "lcTurkish", lcTurkish: 14, "15": "lcJapanese", lcJapanese: 15};
  this.$rtti.$Enum("TAuthLocale",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TAuthLocale});
  rtl.recNewT(this,"TCoreCloudHeader",function () {
    this.header = "";
    this.value = "";
    this.$eq = function (b) {
      return (this.header === b.header) && (this.value === b.value);
    };
    this.$assign = function (s) {
      this.header = s.header;
      this.value = s.value;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCoreCloudHeader",{},this);
    $r.addField("header",rtl.string);
    $r.addField("value",rtl.string);
  });
  this.$rtti.$DynArray("TCoreCloudHeaders",{eltype: this.$rtti["TCoreCloudHeader"]});
  rtl.createClass(this,"TRESTClient",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FAPIBase = "";
      this.FAccessToken = "";
      this.FRefreshToken = "";
      this.FAccessExpiry = 0.0;
      this.FRefreshExpiry = 0.0;
      this.FOnAccessToken = null;
      this.FOnAuthFailed = null;
      this.FEventRegistered = false;
      this.FOnResponse = null;
      this.FPersistTokens = null;
      this.FOnHttpResponse = null;
      this.FApp = null;
      this.FScopes = null;
      this.FLocale = 0;
      this.FOnRequestResponse = null;
      this.FOnError = null;
      this.FResponseType = 0;
      this.FLoginWidth = 0;
      this.FLoginHeight = 0;
      this.FHandleAccessTokenPtr = null;
      this.FHandleAuthClosePtr = null;
      this.FOpenResolver = null;
      this.FWithCredentials = false;
    };
    this.$final = function () {
      this.FOnAccessToken = undefined;
      this.FOnAuthFailed = undefined;
      this.FOnResponse = undefined;
      this.FPersistTokens = undefined;
      this.FOnHttpResponse = undefined;
      this.FApp = undefined;
      this.FScopes = undefined;
      this.FOnRequestResponse = undefined;
      this.FOnError = undefined;
      this.FOpenResolver = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetPersistTokens = function (Value) {
      this.FPersistTokens.Assign(Value);
    };
    this.SetApp = function (Value) {
      this.FApp.Assign(Value);
    };
    this.SetScopes = function (Value) {
      this.FScopes.Assign(Value);
    };
    this.AuthWinClosed = function () {
      if (this.FEventRegistered) this.DoAuthFailed();
    };
    this.InstallCallback = function () {
      var Result = false;
      var scriptsrc = "";
      scriptsrc = " function processAuthData(access_token) {" + 'var event = new CustomEvent("oauthcallback", {\r' + "            detail: {\r" + "                 message: access_token\r" + "            },\r" + "  bubbles: true,\r" + "  cancelable: true});\r" + "  document.dispatchEvent(event);" + "}";
      var script = document.createElement("script");
          script.innerHTML = scriptsrc;
          document.head.appendChild(script);
      
          var scr = document.createElement('script');
          scr.async = true;
          scr.defer = true;
          scr.type = 'text/javascript';
          document.body.appendChild(scr);
      Result = true;
      return Result;
    };
    this.RemoveOAuthHandler = function () {
      document.removeEventListener("oauthcallback",this.FHandleAccessTokenPtr);
      this.FEventRegistered = false;
    };
    this.DoAuthFailed = function () {
      if (this.FOnAuthFailed != null) this.FOnAuthFailed(this);
      if (this.FOpenResolver != null) {
        this.FOpenResolver(false);
        this.FOpenResolver = null;
      };
    };
    this.DoAuthSuccess = function () {
      if (this.FOpenResolver != null) {
        this.FOpenResolver(true);
        this.FOpenResolver = null;
      };
    };
    this.HandleAccessToken = function (s) {
      var Result = false;
      var token = "";
      this.RemoveOAuthHandler();
      token = s.detail.message;
      this.FAccessToken = token;
      this.WriteTokens();
      if (this.FOnAccessToken != null) this.FOnAccessToken(this);
      if (this.FOpenResolver != null) {
        this.FOpenResolver(true);
        this.FOpenResolver = null;
      };
      Result = true;
      return Result;
    };
    this.HandleResponse = function (Event) {
      var Result = false;
      var Response = "";
      var Handled = false;
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      LRequestRec.req = Event.target;
      Response = "";
      if (this.FResponseType in rtl.createSet($mod.THTTPRequestResponseType.rtText,$mod.THTTPRequestResponseType.rtDefault)) {
        Response = Event.target.responseText;
      };
      Handled = false;
      if (this.FOnHttpResponse != null) this.FOnHttpResponse(this,Response,{get: function () {
          return Handled;
        }, set: function (v) {
          Handled = v;
        }});
      if ((this.FOnRequestResponse != null) && !Handled) this.FOnRequestResponse(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),Response);
      if ((this.FOnResponse != null) && !Handled) this.FOnResponse(this,Response);
      Result = true;
      return Result;
    };
    this.GetAuthURL = function () {
      var Result = "";
      Result = this.FApp.FAuthURL;
      return Result;
    };
    this.ScopeParamText = function (Delimiter, Encode) {
      var Result = "";
      var i = 0;
      var scopestr = "";
      Result = "";
      for (var $l = 0, $end = this.FScopes.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (Encode) {
          scopestr = encodeURIComponent(this.FScopes.Get(i))}
         else scopestr = this.FScopes.Get(i);
        if (Result === "") {
          Result = scopestr}
         else Result = Result + Delimiter + scopestr;
      };
      return Result;
    };
    this.GetLocaleParam = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetJSONValue = function (o, ID) {
      var Result = null;
      var js = undefined;
      var res = false;
      var jvb = false;
      Result = null;
      js = o.fjo$1[ID];
      res = false;
      res = (js != undefined);
      if (res) {
        if (pas.JS.isBoolean(js)) {
          jvb = js;
          if (jvb) {
            Result = pas["WEBLib.JSON"].TJSONTrue.$create("Create$3")}
           else Result = pas["WEBLib.JSON"].TJSONFalse.$create("Create$3");
        };
        Result = pas["WEBLib.JSON"].TJSONValue.$create("Create$1",[js]);
      };
      return Result;
    };
    this.GetJSONObject = function (o, ID) {
      var Result = null;
      var ro = null;
      var jv = undefined;
      jv = o.fjo$1[ID];
      ro = jv;
      if (rtl.isArray(ro)) {
        Result = pas["WEBLib.JSON"].TJSONArray.$create("Create$2",[ro]);
      } else {
        Result = pas["WEBLib.JSON"].TJSONObject.$create("Create$3",[ro]);
      };
      return Result;
    };
    this.TMSUTF8Encode = function (s) {
      var Result = "";
      Result = s;
      return Result;
    };
    this.HttpRequestEvent = function (Command, URL, Data, ContentType, headers, AResponse, AError, ATimeOut) {
      var i = 0;
      var req = null;
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(null,AResponse));
      req.addEventListener("error",rtl.createSafeCallback(null,AError));
      req.addEventListener("timeout",rtl.createSafeCallback(null,ATimeOut));
      req.withCredentials = this.FWithCredentials;
      req.responseType = $mod.THttpRequest.GetResponseType(this.FResponseType);
      req.open(Command,URL,true);
      if (ContentType !== "") req.setRequestHeader("Content-Type",ContentType);
      if (this.FAccessToken !== "") req.setRequestHeader("Authorization","Bearer " + this.FAccessToken);
      if (rtl.length(headers) > 0) {
        for (var $l = 0, $end = rtl.length(headers) - 1; $l <= $end; $l++) {
          i = $l;
          req.setRequestHeader(headers[i].header,headers[i].value);
        };
      };
      if (Data === "") {
        req.send(null)}
       else req.send(Data);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FPersistTokens = $mod.TPersistTokens.$create("Create$1");
      this.FApp = $mod.TRESTApp.$create("Create");
      this.FScopes = pas.Classes.TStringList.$create("Create$1");
      this.FLocale = $mod.TAuthLocale.lcDefault;
      this.FResponseType = $mod.THTTPRequestResponseType.rtDefault;
      this.FWithCredentials = false;
      this.FLoginWidth = 800;
      this.FLoginHeight = 600;
      this.FHandleAccessTokenPtr = rtl.createCallback(this,"HandleAccessToken");
      return this;
    };
    this.Destroy = function () {
      if (this.FHandleAuthClosePtr != null) this.FHandleAuthClosePtr = null;
      rtl.free(this,"FApp");
      rtl.free(this,"FScopes");
      rtl.free(this,"FPersistTokens");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.HttpsCommand = function (Command, URL, Data, ContentType, headers) {
      var $Self = this;
      var i = 0;
      var req = null;
      var FRequestResponse = null;
      var FResponse = null;
      var FHttpResponse = null;
      function ResponseHandler(Event) {
        var Result = false;
        var Response = "";
        var Handled = false;
        var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
        LRequestRec.req = Event.target;
        Response = Event.target.responseText;
        Handled = false;
        if (FHttpResponse != null) FHttpResponse($Self,Response,{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
        if ((FRequestResponse != null) && !Handled) {
          FRequestResponse($Self,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),Response);
        };
        if ((FResponse != null) && !Handled) {
          FResponse($Self,Response);
        };
        Result = true;
        return Result;
      };
      function ErrorHandler(Event) {
        var Result = false;
        var Handled = false;
        var LEventRec = pas["WEBLib.Controls"].TJSEventRecord.$new();
        var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
        Handled = false;
        if ($Self.FOnError != null) {
          LRequestRec.req = Event.target;
          LEventRec.event = Event;
          $Self.FOnError($Self,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),pas["WEBLib.Controls"].TJSEventRecord.$clone(LEventRec),{get: function () {
              return Handled;
            }, set: function (v) {
              Handled = v;
            }});
        };
        if (!Handled) throw pas.SysUtils.Exception.$create("Create$1",["HTTP request error @" + URL]);
        Result = true;
        return Result;
      };
      FRequestResponse = this.FOnRequestResponse;
      FResponse = this.FOnResponse;
      FHttpResponse = this.FOnHttpResponse;
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(null,ResponseHandler));
      req.addEventListener("error",rtl.createSafeCallback(null,ErrorHandler));
      req.responseType = $mod.THttpRequest.GetResponseType(this.FResponseType);
      req.open(Command,URL,true);
      if (ContentType !== "") req.setRequestHeader("Content-Type",ContentType);
      if (this.FAccessToken !== "") req.setRequestHeader("Authorization","Bearer " + this.FAccessToken);
      if (rtl.length(headers) > 0) {
        for (var $l = 0, $end = rtl.length(headers) - 1; $l <= $end; $l++) {
          i = $l;
          req.setRequestHeader(headers[i].header,headers[i].value);
        };
      };
      if (Data === "") {
        req.send(null)}
       else req.send(Data);
    };
    this.HttpsDelete = function (URL) {
      this.HttpsCommand("DELETE",URL,"","",[]);
    };
    this.HttpsDelete$1 = function (URL, headers) {
      this.HttpsCommand("DELETE",URL,"","",rtl.arrayRef(headers));
    };
    this.HttpsGet = function (URL) {
      this.HttpsCommand("GET",URL,"","",[]);
    };
    this.HttpsGet$1 = function (URL, headers) {
      this.HttpsCommand("GET",URL,"","",rtl.arrayRef(headers));
    };
    this.HttpsPost = function (URL, Data) {
      this.HttpsPost$1(URL,"",Data);
    };
    this.HttpsPost$1 = function (URL, ContentType, Data) {
      this.HttpsCommand("POST",URL,Data,ContentType,[]);
    };
    this.HttpsPost$2 = function (URL, ContentType, Data, headers) {
      this.HttpsCommand("POST",URL,Data,ContentType,rtl.arrayRef(headers));
    };
    this.HttpsPost$3 = function (URL, headers, Data) {
      this.HttpsCommand("POST",URL,Data,"",rtl.arrayRef(headers));
    };
    this.HttpsUpdate = function (URL, headers, Data) {
      this.HttpsCommand("PUT",URL,Data,"",rtl.arrayRef(headers));
    };
    this.HttpsPut = function (URL, ContentType, Data) {
      this.HttpsCommand("PUT",URL,Data,ContentType,[]);
    };
    this.HttpRequest = function (Command, URL, Data, ContentType, headers) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        var i = 0;
        var req = null;
        var FRequestResponse = null;
        var FResponse = null;
        var FHttpResponse = null;
        function ResponseHandler(Event) {
          var Result = false;
          ASuccess(Event.target);
          return Result;
        };
        function ErrorHandler(Event) {
          var Result = false;
          AFailed(Event.target);
          return Result;
        };
        req = new XMLHttpRequest();
        req.addEventListener("load",rtl.createSafeCallback(null,ResponseHandler));
        req.addEventListener("error",rtl.createSafeCallback(null,ErrorHandler));
        req.withCredentials = $Self.FWithCredentials;
        req.responseType = $mod.THttpRequest.GetResponseType($Self.FResponseType);
        req.open(Command,URL,true);
        if (ContentType !== "") req.setRequestHeader("Content-Type",ContentType);
        if ($Self.FAccessToken !== "") req.setRequestHeader("Authorization","Bearer " + $Self.FAccessToken);
        if (rtl.length(headers) > 0) {
          for (var $l = 0, $end = rtl.length(headers) - 1; $l <= $end; $l++) {
            i = $l;
            req.setRequestHeader(headers[i].header,headers[i].value);
          };
        };
        if (Data === "") {
          req.send(null)}
         else req.send(Data);
      });
      return Result;
    };
    this.URLEncode = function (URI) {
      var Result = "";
      Result = encodeURIComponent(URI);
      return Result;
    };
    this.JSONEscape = function (s) {
      var Result = "";
      Result = encodeURIComponent(s);
      return Result;
    };
    this.IsoToDateTime = function (s) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var err = 0;
      ms = 0;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if ((s.length >= 20) && (s.charAt(19) === ".")) {
        pas.System.val$5(pas.System.Copy(s,21,3),{get: function () {
            return ms;
          }, set: function (v) {
            ms = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
      };
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,ms);
      return Result;
    };
    this.IsoToDateTime$1 = function (s, IsUTC) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var HourOffset = 0;
      var MinuteOffset = 0;
      var err = 0;
      var delta = 0;
      var sign = "";
      HourOffset = 0;
      MinuteOffset = 0;
      ms = 0;
      delta = 0;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if ((s.length >= 20) && (s.charAt(19) === ".")) {
        pas.System.val$5(pas.System.Copy(s,21,3),{get: function () {
            return ms;
          }, set: function (v) {
            ms = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        delta = 4;
      };
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      if (s.length > (20 + delta)) {
        sign = pas.System.Copy(s,20 + delta,1);
        pas.System.val$6(pas.System.Copy(s,22 + delta,2),{get: function () {
            return HourOffset;
          }, set: function (v) {
            HourOffset = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        pas.System.val$6(pas.System.Copy(s,25 + delta,2),{get: function () {
            return MinuteOffset;
          }, set: function (v) {
            MinuteOffset = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (sign === "-") {
          HourOffset = HourOffset * -1;
          MinuteOffset = MinuteOffset * -1;
        };
      };
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,ms);
      return Result;
    };
    this.IsoToDate = function (s) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var err = 0;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(0,0,0,0);
      return Result;
    };
    this.IsoToTime = function (s) {
      var Result = 0.0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var err = 0;
      ms = 0;
      pas.System.val$5(pas.System.Copy(s,1,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,4,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,7,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (s.length > 10) pas.System.val$5(pas.System.Copy(s,10,4),{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if ((ho < 0) || (ho > 23)) ho = 0;
      if ((mi < 0) || (mi > 59)) mi = 0;
      if ((se < 0) || (se > 59)) se = 0;
      if (ms < 0) ms = 0;
      Result = pas.SysUtils.EncodeTime(ho,mi,se,ms);
      return Result;
    };
    this.IsIsoDateTime = function (s) {
      var Result = false;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var err = 0;
      Result = true;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err !== 0) return false;
      if (!(pas.System.Copy(s,5,1) === "-")) return false;
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err !== 0) return false;
      if (!(pas.System.Copy(s,8,1) === "-")) return false;
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err !== 0) return false;
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err === 0) {
        if (!(pas.System.Copy(s,14,1) === ":")) return false;
        pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
            return mi;
          }, set: function (v) {
            mi = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return false;
        if (!(pas.System.Copy(s,17,1) === ":")) return false;
        pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
            return se;
          }, set: function (v) {
            se = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return false;
      };
      return Result;
    };
    this.GetUTCDateTime = function () {
      var Result = 0.0;
      var s = "";
      const nowt = new Date();
      s = nowt.toISOString();
      Result = this.IsoToDateTime(s);
      return Result;
    };
    this.DateTimeToWL = function (dt) {
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      pas.SysUtils.DecodeDate(dt,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      pas.SysUtils.DecodeTime(dt,{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = pas.SysUtils.IntToStr(ye) + "-" + $impl.IntToZStr(mo,2) + "-" + $impl.IntToZStr(da,2) + "T" + $impl.IntToZStr(ho,2) + ":" + $impl.IntToZStr(mi,2) + ":" + $impl.IntToZStr(se,2);
      Result = Result + "+00:00";
      return Result;
    };
    this.DateToWL = function (dt) {
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      pas.SysUtils.DecodeDate(dt,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      Result = pas.SysUtils.IntToStr(ye) + "-" + $impl.IntToZStr(mo,2) + "-" + $impl.IntToZStr(da,2);
      return Result;
    };
    this.TimeToWL = function (dt) {
      var Result = "";
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(dt,{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = $impl.IntToZStr(ho,2) + ":" + $impl.IntToZStr(mi,2) + ":" + $impl.IntToZStr(se,2) + "." + pas.SysUtils.IntToStr(ms);
      return Result;
    };
    this.DateTimeToDaylightSavings = function (dt) {
      var Result = 0.0;
      Result = dt;
      return Result;
    };
    this.GetJSONProp = function (O, ID) {
      var Result = "";
      Result = O.GetJSONValue(ID);
      return Result;
    };
    this.GetJSONInt = function (O, ID) {
      var Result = 0;
      var jv = undefined;
      jv = O.fjo$1[ID];
      if (rtl.isNumber(jv)) Result = rtl.trunc(jv);
      return Result;
    };
    this.DoAuth = function () {
      var URL = "";
      var param = "";
      if (!this.FEventRegistered) {
        document.addEventListener("oauthcallback",this.FHandleAccessTokenPtr);
        this.FEventRegistered = true;
      };
      URL = this.GetAuthURL();
      param = "width=" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this, get: function () {
          return this.p.FLoginWidth;
        }, set: function (v) {
          this.p.FLoginWidth = v;
        }}) + ",height=" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this, get: function () {
          return this.p.FLoginHeight;
        }, set: function (v) {
          this.p.FLoginHeight = v;
        }}) + ",location=no,toolbar=no,menubar=no";
      this.FHandleAuthClosePtr = rtl.createCallback(this,"AuthWinClosed");
      var authwinfunc = this.FHandleAuthClosePtr;
          var newwindow = window.open(URL, 'oauth', param);
          var timeoutid = 0;
      
          function onWindowClosed() {
            clearTimeout(timeoutid);
            authwinfunc();
          }
      
          function checkWindowClosed() {
           if (newwindow.closed) {
              onWindowClosed();
          } else {
              timeoutid = setTimeout(checkWindowClosed, 1000); // Check every second
          }
          }
      
          checkWindowClosed();
    };
    this.Connect = function () {
      if (this.FPersistTokens.FEnabled) {
        this.ReadTokens();
      };
      if (this.FAccessToken !== "") {
        this.TestTokens();
      } else {
        this.DoAuth();
      };
    };
    this.Open = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.FOpenResolver = ASuccess;
        $Self.Connect();
      });
      return Result;
    };
    this.Authenticate = async function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        var ptr = null;
        function HandleOAuthCallBack(s) {
          var Result = false;
          var token = "";
          document.removeEventListener("oauthcallback",ptr);
          token = s.detail.message;
          $Self.FAccessToken = token;
          $Self.WriteTokens();
          ASuccess($Self.FAccessToken);
          return Result;
        };
        ptr = HandleOAuthCallBack;
        document.addEventListener("oauthcallback",ptr);
        $Self.DoAuth();
      });
      return Result;
    };
    this.ReadTokens = function () {
      var ls = null;
      if (this.FPersistTokens.FEnabled && (this.FPersistTokens.FKey !== "")) {
        ls = pas["WEBLib.Storage"].TLocalStorage.$create("Create");
        this.FAccessToken = ls.GetValues(this.FPersistTokens.FKey);
        this.FRefreshToken = ls.GetValues(this.FPersistTokens.FKey + "refresh");
        this.FAccessExpiry = this.$class.IsoToDateTime(ls.GetValues(this.FPersistTokens.FKey + "accessexpiry"));
        this.FRefreshExpiry = this.$class.IsoToDateTime(ls.GetValues(this.FPersistTokens.FKey + "refreshexpiry"));
        ls = rtl.freeLoc(ls);
      };
    };
    this.WriteTokens = function () {
      var ls = null;
      if (this.FPersistTokens.FEnabled && (this.FPersistTokens.FKey !== "")) {
        ls = pas["WEBLib.Storage"].TLocalStorage.$create("Create");
        ls.SetValues(this.FPersistTokens.FKey,this.FAccessToken);
        ls.SetValues(this.FPersistTokens.FKey + "refresh",this.FRefreshToken);
        ls.SetValues(this.FPersistTokens.FKey + "accessexpiry",pas["WEBLib.Utils"].TDateTimeHelper.ToIsoString.call({p: this, get: function () {
            return this.p.FAccessExpiry;
          }, set: function (v) {
            this.p.FAccessExpiry = v;
          }},true,false));
        ls.SetValues(this.FPersistTokens.FKey + "refreshexpiry",pas["WEBLib.Utils"].TDateTimeHelper.ToIsoString.call({p: this, get: function () {
            return this.p.FRefreshExpiry;
          }, set: function (v) {
            this.p.FRefreshExpiry = v;
          }},true,false));
        ls = rtl.freeLoc(ls);
      };
    };
    this.TestTokens = async function () {
      if (this.FOnAccessToken != null) this.FOnAccessToken(this);
    };
    this.ClearTokens = function () {
      this.FAccessToken = "";
      this.WriteTokens();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("App",2,$mod.$rtti["TRESTApp"],"FApp","SetApp");
    $r.addProperty("LoginHeight",0,rtl.longint,"FLoginHeight","FLoginHeight",4,{Default: 600});
    $r.addProperty("LoginWidth",0,rtl.longint,"FLoginWidth","FLoginWidth",4,{Default: 800});
    $r.addProperty("PersistTokens",2,$mod.$rtti["TPersistTokens"],"FPersistTokens","SetPersistTokens");
    $r.addProperty("ResponseType",0,$mod.$rtti["THTTPRequestResponseType"],"FResponseType","FResponseType",4,{Default: $mod.THTTPRequestResponseType.rtDefault});
    $r.addProperty("Scopes",2,pas.Classes.$rtti["TStrings"],"FScopes","SetScopes");
    $r.addProperty("WithCredentials",0,rtl.boolean,"FWithCredentials","FWithCredentials",4,{Default: false});
    $r.addProperty("OnAccessToken",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnAccessToken","FOnAccessToken");
    $r.addProperty("OnAuthFailed",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnAuthFailed","FOnAuthFailed");
    $r.addProperty("OnRequestResponse",0,pas["WEBLib.Controls"].$rtti["THTTPRequestResponseEvent"],"FOnRequestResponse","FOnRequestResponse");
    $r.addProperty("OnResponse",0,$mod.$rtti["THttpResponse"],"FOnResponse","FOnResponse");
    $r.addProperty("OnError",0,pas["WEBLib.Controls"].$rtti["THTTPErrorEvent"],"FOnError","FOnError");
  });
  rtl.createClass(this,"TWebRESTClient",this.TRESTClient,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.AddHeader = function (AHeaders, Header, Value) {
    AHeaders.set(rtl.arraySetLength(AHeaders.get(),$mod.TCoreCloudHeader,rtl.length(AHeaders.get()) + 1));
    AHeaders.get()[rtl.length(AHeaders.get()) - 1].header = Header;
    AHeaders.get()[rtl.length(AHeaders.get()) - 1].value = Value;
  };
  this.GetArraySize = function (ja) {
    var Result = 0;
    Result = ja.GetCount();
    return Result;
  };
  this.GetArrayItem = function (ja, Index) {
    var Result = null;
    Result = ja.GetItem(Index);
    return Result;
  };
  this.HTTPCommand = function (ACommand, ACustomCommand) {
    var Result = "";
    var cmd = "";
    var $tmp = ACommand;
    if ($tmp === $mod.THTTPCommand.httpGET) {
      cmd = "GET"}
     else if ($tmp === $mod.THTTPCommand.httpPOST) {
      cmd = "POST"}
     else if ($tmp === $mod.THTTPCommand.httpPUT) {
      cmd = "PUT"}
     else if ($tmp === $mod.THTTPCommand.httpDELETE) {
      cmd = "DELETE"}
     else if ($tmp === $mod.THTTPCommand.httpHEAD) {
      cmd = "HEAD"}
     else if ($tmp === $mod.THTTPCommand.httpPATCH) {
      cmd = "PATCH"}
     else if ($tmp === $mod.THTTPCommand.httpCUSTOM) cmd = ACustomCommand;
    Result = cmd;
    return Result;
  };
  $mod.$implcode = function () {
    $impl.IntToZStr = function (i, l) {
      var Result = "";
      var Res = "";
      Res = pas.SysUtils.IntToStr(i);
      while (Res.length < l) Res = "0" + Res;
      Result = Res;
      return Result;
    };
  };
  $mod.$init = function () {
    $mod.TRESTClient.InstallCallback();
  };
},["WEBLib.Storage","WEBLib.Utils"]);
rtl.module("WEBLib.Utils",["System","Types","Web","SysUtils","Math","Classes","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.DayMonday = 1;
  this.DayTuesday = 2;
  this.DayWednesday = 3;
  this.DayThursday = 4;
  this.DayFriday = 5;
  this.DaySaturday = 6;
  this.DaySunday = 7;
  this.MonthJanuary = 1;
  this.MonthFebruary = 2;
  this.MonthMarch = 3;
  this.MonthApril = 4;
  this.MonthMay = 5;
  this.MonthJune = 6;
  this.MonthJuly = 7;
  this.MonthAugust = 8;
  this.MonthSeptember = 9;
  this.MonthOctober = 10;
  this.MonthNovember = 11;
  this.MonthDecember = 12;
  this.$rtti.$Class("TInterfaceList");
  rtl.createClass(this,"EEncodingError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EStringStreamError",pas.Classes.EStreamError,function () {
  });
  rtl.createHelper(this,"TBytesHelper",null,function () {
    this.get_Length = function () {
      var Result = 0;
      Result = rtl.length(this.get());
      return Result;
    };
    this.set_Length = function (AValue) {
      this.set(rtl.arraySetLength(this.get(),0,AValue));
    };
    this.Compare = function (ARight) {
      var Result = 0;
      var lCount = 0;
      if ($mod.TBytesHelper.get_Length.call(this) > $mod.TBytesHelper.get_Length.call({get: function () {
          return ARight;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) return 1;
      if ($mod.TBytesHelper.get_Length.call(this) < $mod.TBytesHelper.get_Length.call({get: function () {
          return ARight;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) return -1;
      Result = 0;
      for (var $l = $mod.TBytesHelper.Low.call(this), $end = $mod.TBytesHelper.High.call(this); $l <= $end; $l++) {
        lCount = $l;
        if (this.get()[lCount] > ARight[lCount]) return 1;
        if (this.get()[lCount] < ARight[lCount]) return -1;
      };
      return Result;
    };
    this.High = function () {
      var Result = 0;
      Result = rtl.length(this.get()) - 1;
      return Result;
    };
    this.Low = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.SubBytes = function (AStartIndex) {
      var Result = [];
      Result = rtl.arrayCopy(0,this.get(),AStartIndex,$mod.TBytesHelper.get_Length.call(this));
      return Result;
    };
    this.SubBytes$1 = function (AStartIndex, ALength) {
      var Result = [];
      Result = rtl.arrayCopy(0,this.get(),AStartIndex,ALength);
      return Result;
    };
  });
  this.$rtti.$DynArray("TWords",{eltype: rtl.word});
  rtl.createHelper(this,"TWordsHelper",null,function () {
    this.get_Length = function () {
      var Result = 0;
      Result = rtl.length(this.get());
      return Result;
    };
    this.set_Length = function (AValue) {
      this.set(rtl.arraySetLength(this.get(),0,AValue));
    };
    var cBytesPerWord = 2;
    this.FromBytes = function (ABytes) {
      var Result = [];
      var lCount = 0;
      var lLow = 0;
      var lHigh = 0;
      lCount = $mod.TBytesHelper.get_Length.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      if (pas.System.Odd(lCount)) lCount += 1;
      $mod.TWordsHelper.set_Length.call({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},rtl.trunc(lCount / 2));
      lCount = $mod.TBytesHelper.Low.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      while (lCount <= $mod.TBytesHelper.High.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) {
        lLow = ABytes[lCount];
        if ((lCount + 1) <= $mod.TBytesHelper.High.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }})) {
          lHigh = ABytes[lCount + 1]}
         else lHigh = 0;
        Result[rtl.trunc(lCount / 2)] = pas.SysUtils.TWordHelper.FromBytes(lLow,lHigh);
        lCount += 2;
      };
      return Result;
    };
    this.High = function () {
      var Result = 0;
      Result = rtl.length(this.get()) - 1;
      return Result;
    };
    this.Low = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    var cBytesPerWord$1 = 2;
    this.ToBytes = function () {
      var Result = [];
      var lLow = 0;
      var lHigh = 0;
      var lCount = 0;
      var lNewIndex = 0;
      $mod.TBytesHelper.set_Length.call({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},$mod.TWordsHelper.get_Length.call(this) * 2);
      for (var $l = $mod.TWordsHelper.Low.call(this), $end = $mod.TWordsHelper.High.call(this); $l <= $end; $l++) {
        lCount = $l;
        pas.SysUtils.TWordHelper.ToBytes.call({a: lCount, p: this.get(), get: function () {
            return this.p[this.a];
          }, set: function (v) {
            this.p[this.a] = v;
          }},{get: function () {
            return lLow;
          }, set: function (v) {
            lLow = v;
          }},{get: function () {
            return lHigh;
          }, set: function (v) {
            lHigh = v;
          }});
        lNewIndex = lCount * 2;
        Result[lNewIndex] = lLow;
        Result[lNewIndex + 1] = lHigh;
      };
      return Result;
    };
  });
  rtl.createHelper(this,"TCharHelper",null,function () {
    this.Length = 1;
    this.Size = 2;
    var cNumChars = rtl.createSet(48,49,50,51,52,53,54,55,56,57);
    this.IsDigit = function () {
      var Result = false;
      Result = this.get().charCodeAt() in cNumChars;
      return Result;
    };
    this.ToOrd = function () {
      var Result = 0;
      Result = this.get().charCodeAt();
      return Result;
    };
    this.ToUpper = function () {
      var Result = "\x00";
      Result = $mod.TCharHelper.ToUpper$1(this.get());
      return Result;
    };
    this.ToUpper$1 = function (AValue) {
      return AValue.toUpperCase();
    };
  });
  rtl.createHelper(this,"TLongIntHelper",null,function () {
    this.Equals = function (AValue) {
      var Result = false;
      Result = this.get() === AValue;
      return Result;
    };
    this.NotEquals = function (AValue) {
      var Result = false;
      Result = !$mod.TLongIntHelper.Equals.call(this,AValue);
      return Result;
    };
    this.Parse = function (AValue) {
      var Result = 0;
      Result = pas.SysUtils.StrToInt(AValue);
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = $mod.TLongIntHelper.ToString$1(this.get());
      return Result;
    };
    this.ToString$1 = function (AValue) {
      return AValue.toString();
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      Result = pas.SysUtils.TryStrToInt(AString,AValue);
      return Result;
    };
  });
  rtl.createHelper(this,"TDateTimeHelper",null,function () {
    this.Equals = function (AValue) {
      var Result = false;
      Result = pas.Math.SameValue(this.get(),AValue,0.0);
      return Result;
    };
    this.NotEquals = function (AValue) {
      var Result = false;
      Result = !pas.Math.SameValue(this.get(),AValue,0.0);
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = pas.SysUtils.DateTimeToStr$1(this.get(),pas.SysUtils.FormatSettings,false);
      return Result;
    };
    this.ToIsoString = function (AAddDelimiters, AAddMilliSeconds) {
      var $Self = this;
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var dd = "";
      var td = "";
      var msec = "";
      function IntToZStr(i, l) {
        var Result = "";
        var Res = "";
        Res = pas.SysUtils.IntToStr(i);
        while (Res.length < l) Res = "0" + Res;
        Result = Res;
        return Result;
      };
      if (AAddDelimiters) {
        dd = "-";
        td = ":";
      };
      pas.SysUtils.DecodeDate($Self.get(),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      pas.SysUtils.DecodeTime($Self.get(),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      if (AAddMilliSeconds) msec = "." + IntToZStr(ms,3) + "Z";
      Result = IntToZStr(ye,4) + dd + IntToZStr(mo,2) + dd + IntToZStr(da,2) + "T" + IntToZStr(ho,2) + td + IntToZStr(mi,2) + td + IntToZStr(se,2) + msec;
      return Result;
    };
  });
  rtl.createHelper(this,"TStreamHelper",null,function () {
    var MaxBufSize = 0xF000;
    this.CopyFrom = function (ASource, ACount) {
      var Result = 0;
      var lBufSize = 0;
      var lCount = 0;
      var lBuffer = [];
      if (ACount <= 0) {
        ASource.SetPosition(0);
        ACount = ASource.GetSize();
      };
      Result = ACount;
      if (ACount > 61440) {
        lBufSize = 61440}
       else lBufSize = ACount;
      $mod.TBytesHelper.set_Length.call({get: function () {
          return lBuffer;
        }, set: function (v) {
          lBuffer = v;
        }},lBufSize);
      try {
        while (ACount !== 0) {
          if (ACount > lBufSize) {
            lCount = lBufSize}
           else lCount = ACount;
          ASource.ReadBuffer({get: function () {
              return lBuffer;
            }, set: function (v) {
              lBuffer = v;
            }},lCount);
          this.WriteBuffer(lBuffer,lCount);
          ACount -= lCount;
        };
      } finally {
        $mod.TBytesHelper.set_Length.call({get: function () {
            return lBuffer;
          }, set: function (v) {
            lBuffer = v;
          }},0);
      };
      return Result;
    };
  });
  rtl.createClass(this,"TTMSStringStream",pas.Classes.TBytesStream,function () {
    this.$init = function () {
      pas.Classes.TBytesStream.$init.call(this);
      this.FEncoding = null;
      this.FFileName = "";
      this.FOwnsEncoding = false;
      this.FError = null;
      this.FLoaded = null;
      this.FRequest = null;
    };
    this.$final = function () {
      this.FEncoding = undefined;
      this.FError = undefined;
      this.FLoaded = undefined;
      this.FRequest = undefined;
      pas.Classes.TBytesStream.$final.call(this);
    };
    this.GetDataString = function () {
      var Result = "";
      Result = this.FEncoding.GetString(rtl.arrayCopy(0,this.GetBytes(),0,this.GetSize()));
      return Result;
    };
    this.InternalLoadFromFileP = function (AFileName) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (AResolve, AReject) {
        $Self.LoadFromFile$3(AFileName,function () {
          AResolve(true);
        },function (AError) {
          AReject(AError);
        });
      });
      return Result;
    };
    this.OnAbort = function (AEvent) {
      var Result = false;
      Result = true;
      if (this.FError != null) this.FError(pas.SysUtils.Format(rtl.getResStr(pas["WEBLib.Consts"],"SLoadFromFileAborted"),pas.System.VarRecs(18,this.FFileName)));
      return Result;
    };
    this.OnError = function (AEvent) {
      var Result = false;
      Result = true;
      if (this.FError != null) this.FError(pas.SysUtils.Format(rtl.getResStr(pas["WEBLib.Consts"],"SErrorLoadFromFile"),pas.System.VarRecs(18,this.FFileName)));
      return Result;
    };
    var cStatusOK$1 = 200;
    var cStatusLastOK = 208;
    this.OnLoad = function (AEvent) {
      var Result = false;
      var lReq = null;
      lReq = AEvent.target;
      if ((lReq.status < 200) || (lReq.status > 208)) {
        if (this.FError != null) {
          this.FError(pas.SysUtils.Format(rtl.getResStr(pas["WEBLib.Consts"],"SCannotGetFile"),pas.System.VarRecs(18,this.FFileName,0,this.FRequest.status)));
          return Result;
        } else throw $mod.EStringStreamError.$create("CreateFmt",[rtl.getResStr(pas["WEBLib.Consts"],"SCannotGetFile"),pas.System.VarRecs(18,this.FFileName,0,lReq.status)]);
      };
      this.WriteString(lReq.responseText);
      Result = true;
      if (this.FLoaded != null) this.FLoaded();
      return Result;
    };
    this.Create$2 = function () {
      this.Create$4(pas.SysUtils.TStringHelper.Empty,pas.SysUtils.TEncoding.GetDefault(),false);
      return this;
    };
    this.Create$3 = function (AString) {
      this.Create$4(AString,pas.SysUtils.TEncoding.GetDefault(),false);
      return this;
    };
    this.Create$4 = function (AString, AEncoding, AOwnsEncoding) {
      var lBytes = [];
      pas.System.TObject.Create.call(this);
      this.FEncoding = AEncoding;
      this.FOwnsEncoding = AOwnsEncoding && !pas.SysUtils.TEncoding.IsStandardEncoding(AEncoding);
      lBytes = this.FEncoding.GetBytes(AString);
      this.SetPointer(this.$class.BytesToMemory(rtl.arrayRef(lBytes)),$mod.TBytesHelper.get_Length.call({get: function () {
          return lBytes;
        }, set: function (v) {
          lBytes = v;
        }}));
      return this;
    };
    this.Destroy = function () {
      if (this.FOwnsEncoding) rtl.free(this,"FEncoding");
      pas.Classes.TMemoryStream.Destroy.call(this);
    };
    var cStatusOK = 200;
    this.LoadFromFile$1 = function (AFileName) {
      var lStatus = 0;
      var lResponse = "";
      lResponse = pas.SysUtils.TStringHelper.Empty;
      lStatus = 200;
      var lRequest = new XMLHttpRequest();
          lRequest.open("GET", AFileName, false);
          lRequest.send();
      
          if (lRequest.status == cStatusOK)
            lResponse = lRequest.responseText
          else
            lStatus = lRequest.status;
      if (lStatus !== 200) throw $mod.EStringStreamError.$create("CreateFmt",[rtl.getResStr(pas["WEBLib.Consts"],"SCannotGetFile"),pas.System.VarRecs(18,AFileName,0,lStatus)]);
      this.WriteString(lResponse);
    };
    this.LoadFromFile$2 = function (AFileName, ALoaded) {
      this.LoadFromFile$3(AFileName,ALoaded,null);
    };
    var cAbortMethod = "abort";
    var cErrorMethod = "error";
    var cGetMethod = "GET";
    var cLoadMethod = "load";
    this.LoadFromFile$3 = function (AFileName, ALoaded, AError) {
      this.FLoaded = ALoaded;
      this.FError = AError;
      this.FFileName = AFileName;
      this.FRequest = new XMLHttpRequest();
      this.FRequest.addEventListener(cAbortMethod,rtl.createSafeCallback(this,"OnAbort"));
      this.FRequest.addEventListener(cErrorMethod,rtl.createSafeCallback(this,"OnError"));
      this.FRequest.addEventListener(cLoadMethod,rtl.createSafeCallback(this,"OnLoad"));
      try {
        this.FRequest.open(cGetMethod,AFileName,true);
        this.FRequest.send();
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
          if (AError != null) {
            AError(E.FMessage)}
           else throw $e;
        } else throw $e
      };
    };
    this.LoadFromFileP = async function (AFileName) {
      var Result = false;
      Result = await this.InternalLoadFromFileP(AFileName);
      return Result;
    };
    this.ReadString = function (ACount) {
      var Result = "";
      var lBytes = [];
      var lDest = [];
      var lCount = 0;
      if (ACount > (this.GetSize() - this.GetPosition())) ACount = this.GetSize() - this.GetPosition();
      $mod.TBytesHelper.set_Length.call({get: function () {
          return lDest;
        }, set: function (v) {
          lDest = v;
        }},ACount);
      lBytes = rtl.arrayRef(this.GetBytes());
      for (var $l = this.GetPosition(), $end = (ACount + this.GetPosition()) - 1; $l <= $end; $l++) {
        lCount = $l;
        lDest[lCount - this.GetPosition()] = lBytes[lCount];
      };
      Result = this.FEncoding.GetString(lDest);
      this.SetPosition(this.GetPosition() + ACount);
      return Result;
    };
    this.WriteString = function (AString) {
      var lBytes = [];
      var lData = "";
      lBytes = this.FEncoding.GetBytes(AString);
      this.Write$1(lBytes,0,$mod.TBytesHelper.get_Length.call({get: function () {
          return lBytes;
        }, set: function (v) {
          lBytes = v;
        }}));
      lData = this.GetDataString();
      if (lData !== AString) this.WriteString("");
    };
  });
  rtl.createInterface(this,"IInterfaceList","{285DEA8A-B865-11D1-AAA7-00C04FB17A72}",["Add","Clear","Delete","Exchange","Expand","First","get_Capacity","get_Count","get_Items","IndexOf","IndexOfItem","Insert","Last","Lock","Remove","RemoveItem","set_Capacity","set_Count","set_Items","Unlock"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Add",1,[["AItem",pas.System.$rtti["IUnknown"],2]],2,rtl.longint);
    $r.addMethod("Clear",0,[]);
    $r.addMethod("Delete",0,[["AIndex",rtl.longint,2]]);
    $r.addMethod("Exchange",0,[["AIndex1",rtl.longint,2],["AIndex2",rtl.longint,2]]);
    $r.addMethod("Expand",1,[],2,$mod.$rtti["TInterfaceList"]);
    $r.addMethod("First",1,[],2,pas.System.$rtti["IUnknown"]);
    $r.addMethod("get_Capacity",1,[],2,rtl.longint);
    $r.addMethod("get_Count",1,[],2,rtl.longint);
    $r.addMethod("get_Items",1,[["AIndex",rtl.longint,2]],2,pas.System.$rtti["IUnknown"]);
    $r.addMethod("IndexOf",1,[["AItem",pas.System.$rtti["IUnknown"],2]],2,rtl.longint);
    $r.addMethod("IndexOfItem",1,[["AItem",pas.System.$rtti["IUnknown"],2],["ADirection",pas.Types.$rtti["TDirection"],2]],2,rtl.longint);
    $r.addMethod("Insert",0,[["AIndex",rtl.longint,2],["AItem",pas.System.$rtti["IUnknown"],2]]);
    $r.addMethod("Last",1,[],2,pas.System.$rtti["IUnknown"]);
    $r.addMethod("Lock",0,[]);
    $r.addMethod("Remove",1,[["AItem",pas.System.$rtti["IUnknown"],2]],2,rtl.longint);
    $r.addMethod("RemoveItem",1,[["AItem",pas.System.$rtti["IUnknown"],2],["ADirection",pas.Types.$rtti["TDirection"],2]],2,rtl.longint);
    $r.addMethod("set_Capacity",0,[["AValue",rtl.longint,2]]);
    $r.addMethod("set_Count",0,[["AValue",rtl.longint,2]]);
    $r.addMethod("set_Items",0,[["AIndex",rtl.longint,2],["AItem",pas.System.$rtti["IUnknown"],2]]);
    $r.addMethod("Unlock",0,[]);
    $r.addProperty("Count",3,rtl.longint,"get_Count","set_Count",2);
    $r.addProperty("Items",3,pas.System.$rtti["IUnknown"],"get_Items","set_Items",2);
  });
  rtl.createClass(this,"TInterfaceListEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FIndex = 0;
      this.FInterfaceList = null;
    };
    this.$final = function () {
      this.FInterfaceList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.get_Current = function () {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,this.FInterfaceList.get_Items(this.FIndex),true);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.Create$1 = function (AInterfaceList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FInterfaceList = AInterfaceList;
      return this;
    };
    this.MoveNext = function () {
      var Result = false;
      Result = this.FIndex < (this.FInterfaceList.get_Count() - 1);
      if (Result) this.FIndex += 1;
      return Result;
    };
  });
  rtl.createInterface(this,"IInterfaceListEx","{FDB39D70-65B9-4995-9436-6084ACA05DB3}",["GetEnumerator"],this.IInterfaceList,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["TInterfaceListEnumerator"]);
  });
  this.$rtti.$RefToProcVar("TCompareItems",{procsig: rtl.newTIProcSig([["ALeft",pas.System.$rtti["IUnknown"],2],["ARight",pas.System.$rtti["IUnknown"],2]],pas.Math.$rtti["TValueRelationship"])});
  rtl.createInterface(this,"IInterfaceListEx2","{4FE71218-0F8F-4027-B050-5E84E2202604}",["Sort"],this.IInterfaceList,function () {
    var $r = this.$rtti;
    $r.addMethod("Sort",0,[["ACompare",$mod.$rtti["TCompareItems"],2]]);
  });
  rtl.createClass(this,"TInterfaceList",pas.System.TInterfacedObject,function () {
    this.$init = function () {
      pas.System.TInterfacedObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TInterfacedObject.$final.call(this);
    };
    this.Add = function (AItem) {
      var Result = 0;
      Result = this.FList.Add(null);
      this.set_Items(Result,AItem);
      return Result;
    };
    this.Clear = function () {
      var lCount = 0;
      for (var $l = 0, $end = this.FList.FCount - 1; $l <= $end; $l++) {
        lCount = $l;
        this.set_Items(lCount,null);
      };
      this.FList.Clear();
    };
    this.Delete = function (AIndex) {
      this.set_Items(AIndex,null);
      this.FList.Delete(AIndex);
    };
    this.Exchange = function (AIndex1, AIndex2) {
      this.FList.Exchange(AIndex1,AIndex2);
    };
    this.Expand = function () {
      var Result = null;
      this.FList.Expand();
      Result = this;
      return Result;
    };
    this.First = function () {
      var Result = null;
      var $ok = false;
      try {
        if (this.get_Count() > 0) {
          Result = rtl.setIntfL(Result,this.get_Items(0),true)}
         else Result = rtl.setIntfL(Result,null);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TInterfaceListEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.get_Capacity = function () {
      var Result = 0;
      Result = this.FList.FCapacity;
      return Result;
    };
    this.get_Count = function () {
      var Result = 0;
      Result = this.FList.FCount;
      return Result;
    };
    this.get_Items = function (AIndex) {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,rtl.getObject(this.FList.Get(AIndex)));
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.IndexOf = function (AItem) {
      var Result = 0;
      Result = this.IndexOfItem(AItem,pas.Types.TDirection.FromBeginning);
      return Result;
    };
    this.IndexOfItem = function (AItem, ADirection) {
      var Result = 0;
      Result = this.FList.IndexOfItem(AItem,ADirection);
      return Result;
    };
    this.Insert = function (AIndex, AItem) {
      this.FList.Insert(AIndex,null);
      this.set_Items(AIndex,AItem);
    };
    this.Last = function () {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,this.get_Items(this.get_Count() - 1),true);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.Lock = function () {
    };
    this.Remove = function (AItem) {
      var Result = 0;
      Result = this.RemoveItem(AItem,pas.Types.TDirection.FromBeginning);
      return Result;
    };
    this.RemoveItem = function (AItem, ADirection) {
      var Result = 0;
      Result = this.FList.IndexOfItem(AItem,ADirection);
      if (Result > -1) this.Delete(Result);
      return Result;
    };
    this.set_Capacity = function (AValue) {
      this.FList.SetCapacity(AValue);
    };
    this.set_Count = function (AValue) {
      this.FList.SetCount(AValue);
    };
    this.set_Items = function (AIndex, AItem) {
      if (this.FList.Get(AIndex) != null) rtl.getObject(this.FList.Get(AIndex))._Release();
      this.FList.Put(AIndex,AItem);
      if (AItem !== null) AItem._AddRef();
    };
    this.Sort = function (ACompare) {
      $impl.FCompare = ACompare;
      try {
        this.FList.Sort($impl.InternalCompare);
      } finally {
        $impl.FCompare = null;
      };
    };
    this.Unlock = function () {
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FList = pas.Classes.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      this.Clear();
      rtl.free(this,"FList");
      pas.System.TObject.Destroy.call(this);
    };
    rtl.addIntf(this,$mod.IInterfaceList);
    rtl.addIntf(this,$mod.IInterfaceListEx);
    rtl.addIntf(this,$mod.IInterfaceListEx2);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TStringBuilder",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FData = "";
    };
    this.get_Length = function () {
      var Result = 0;
      Result = pas.SysUtils.TStringHelper.GetLength.call({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }});
      return Result;
    };
    this.set_Length = function (AValue) {
      pas.SysUtils.TStringHelper.Set_Length.call({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},AValue);
    };
    this.Create$1 = function (AValue) {
      pas.System.TObject.Create.call(this);
      this.FData = AValue;
      return this;
    };
    this.Append = function (AValue) {
      var Result = null;
      Result = this.Append$1($mod.TLongIntHelper.ToString.call({get: function () {
          return AValue;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.Append$1 = function (AValue) {
      var Result = null;
      this.FData = this.FData + AValue;
      Result = this;
      return Result;
    };
    this.Insert = function (AIndex, AValue) {
      var Result = null;
      Result = this.Insert$1(AIndex,$mod.TLongIntHelper.ToString.call({get: function () {
          return AValue;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.Insert$1 = function (AIndex, AValue) {
      var Result = null;
      pas.SysUtils.TStringHelper.Insert.call({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},AIndex,AValue);
      Result = this;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.FData;
      return Result;
    };
  });
  rtl.recNewT(this,"TSysInfo",function () {
    this.screenSize = "";
    this.browser = "";
    this.browserversion = "";
    this.browsermajorVersion = "";
    this.mobile = false;
    this.os = "";
    this.osVersion = "";
    this.cookieEnabled = false;
    this.flashVersion = "";
    this.$eq = function (b) {
      return (this.screenSize === b.screenSize) && (this.browser === b.browser) && (this.browserversion === b.browserversion) && (this.browsermajorVersion === b.browsermajorVersion) && (this.mobile === b.mobile) && (this.os === b.os) && (this.osVersion === b.osVersion) && (this.cookieEnabled === b.cookieEnabled) && (this.flashVersion === b.flashVersion);
    };
    this.$assign = function (s) {
      this.screenSize = s.screenSize;
      this.browser = s.browser;
      this.browserversion = s.browserversion;
      this.browsermajorVersion = s.browsermajorVersion;
      this.mobile = s.mobile;
      this.os = s.os;
      this.osVersion = s.osVersion;
      this.cookieEnabled = s.cookieEnabled;
      this.flashVersion = s.flashVersion;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSysInfo",{},this);
    $r.addField("screenSize",rtl.string);
    $r.addField("browser",rtl.string);
    $r.addField("browserversion",rtl.string);
    $r.addField("browsermajorVersion",rtl.string);
    $r.addField("mobile",rtl.boolean);
    $r.addField("os",rtl.string);
    $r.addField("osVersion",rtl.string);
    $r.addField("cookieEnabled",rtl.boolean);
    $r.addField("flashVersion",rtl.string);
  });
  rtl.createHelper(this,"TJsonToObjectHelper",null,function () {
    this.FromJSON = function (JSONValue) {
      var $Self = this;
      var Context = pas.RTTI.TRTTIContext.$new();
      var TypeInfo = null;
      var v = pas.RTTI.TValue.$new();
      function ListProperties(AObject, jsv) {
        for (var key in jsv) {
          if (jsv.hasOwnProperty(key)) {
            //console.log(key + " / " + jsv[key]);
            SetProperty(AObject, key, jsv[key]);
          }
        };
      };
      function SetProperty(AObject, Name, AValue) {
        var pn = "";
        var Prop = null;
        var PropTypeInfo = null;
        if (Name === "") return;
        TypeInfo = Context.GetType$1(AObject.$class.ClassType());
        Prop = TypeInfo.GetProperty(Name);
        if (Prop != null) {
          pn = Prop.GetPropertyType().GetName();
          PropTypeInfo = Prop.GetPropertyType();
          if ((PropTypeInfo.GetTypeKind() === pas.System.TTypeKind.tkClass) && Prop.GetValue(AObject).IsObject()) {
            ListProperties(Prop.GetValue(AObject).AsObject(),AValue);
          };
          if (pn === "string") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$String("" + AValue));
            Prop.SetValue(AObject,v);
          };
          if (pn === "longint") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$Longint(rtl.trunc(AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "boolean") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$Boolean(("" + AValue) === "true"));
            Prop.SetValue(AObject,v);
          };
          if (pn === "double") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$Double(rtl.getNumber(AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TDateTime") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$Double(pas["WEBLib.REST"].TRESTClient.IsoToDateTime$1("" + AValue,true)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TDate") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$Double(pas["WEBLib.REST"].TRESTClient.IsoToDate("" + AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TTime") {
            v.$assign(pas.RTTI.TValue.From$$$G$$rtti$$Double(pas["WEBLib.REST"].TRESTClient.IsoToTime("" + AValue)));
            Prop.SetValue(AObject,v);
          };
        };
      };
      Context.$assign(pas.RTTI.TRTTIContext.Create());
      SetProperty($Self,"",null);
      ListProperties($Self,JSONValue);
      Context.Free();
    };
    this.FromJSON$1 = function (JSONValue) {
      var jsv = undefined;
      jsv = null;
      jsv = JSON.parse(JSONValue);
      $mod.TJsonToObjectHelper.FromJSON.call(this,jsv);
    };
    this.ToJSON = function () {
      var $Self = this;
      var Result = undefined;
      var Context = pas.RTTI.TRTTIContext.$new();
      var TypeInfo = null;
      var Prop = null;
      var jsonstr = "";
      var pn = "";
      var res = undefined;
      var PropTypeInfo = null;
      function ListProperties(AObject, ATypeInfo, js) {
        var sub = "";
        var sep = "";
        var subn = "";
        for (var $in = ATypeInfo.GetProperties(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
          Prop = $in[$l];
          PropTypeInfo = Prop.GetPropertyType();
          sep = "";
          if (js.get().length > 1) sep = ",";
          subn = Prop.GetName();
          pn = Prop.GetPropertyType().GetName();
          if ((PropTypeInfo.GetTypeKind() === pas.System.TTypeKind.tkClass) && Prop.GetValue(AObject).IsObject()) {
            sub = "{";
            ListProperties(Prop.GetValue(AObject).AsObject(),Prop.GetPropertyType(),{get: function () {
                return sub;
              }, set: function (v) {
                sub = v;
              }});
            sub = sub + "}";
            js.set(js.get() + sep + '"' + subn + '":' + sub);
            continue;
          };
          if (pn === "string") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + Prop.GetValue(AObject).ToString() + '"');
          };
          if (pn === "longint") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + pas.SysUtils.IntToStr(Prop.GetValue(AObject).AsInteger()));
          };
          if (pn === "boolean") {
            if (Prop.GetValue(AObject).AsBoolean()) {
              js.set(js.get() + sep + '"' + Prop.GetName() + '":' + "true")}
             else js.set(js.get() + sep + '"' + Prop.GetName() + '":' + "false");
          };
          if (pn === "double") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + pas.SysUtils.FloatToStr(Prop.GetValue(AObject).AsExtended()));
          };
          if (pn === "TDateTime") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + pas["WEBLib.REST"].TRESTClient.DateTimeToWL(Prop.GetValue(AObject).AsExtended()) + '"');
          };
          if (pn === "TDate") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + pas["WEBLib.REST"].TRESTClient.DateToWL(Prop.GetValue(AObject).AsExtended()) + '"');
          };
          if (pn === "TTime") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + pas["WEBLib.REST"].TRESTClient.TimeToWL(Prop.GetValue(AObject).AsExtended()) + '"');
          };
        };
      };
      Context.$assign(pas.RTTI.TRTTIContext.Create());
      TypeInfo = Context.GetType$1($Self.$class.ClassType());
      jsonstr = "{";
      ListProperties($Self,TypeInfo,{get: function () {
          return jsonstr;
        }, set: function (v) {
          jsonstr = v;
        }});
      jsonstr = jsonstr + "}";
      res = JSON.parse(jsonstr);
      Result = res;
      Context.Free();
      return Result;
    };
  });
  this.UseVariable = function (AValue) {
  };
  this.UseVariable$1 = function (AValue) {
  };
  this.UseVariable$2 = function (AValue) {
  };
  this.ArrayBufferToBase64 = function (Buffer) {
    var Result = "";
    function _arrayBufferToBase64(buf) {
    var binary = '';
    var bytes = new Uint8Array(buf);
    var len = bytes.byteLength;
    for (var i = 0; i < len; i++) {
        binary += String.fromCharCode( bytes[i] );
    }
    return window.btoa(binary);
    }
    Result = _arrayBufferToBase64(Buffer);
    return Result;
  };
  this.Base64ToArrayBuffer = function (Base64) {
    var Result = null;
    function _base64ToArrayBuffer(data) {
            var binary_string = window.atob(data);
            var len = binary_string.length;
            var bytes = new Uint8Array(len);
            for (var i = 0; i < len; i++) {
                bytes[i] = binary_string.charCodeAt(i);
            }
            return bytes.buffer;
        }
    
        Result = _base64ToArrayBuffer(Base64);
    return Result;
  };
  this.StringToBase64 = function (AValue) {
    var Result = "";
    var res = "";
    res = window.btoa(AValue);
    Result = res;
    return Result;
  };
  this.Base64ToString = function (AValue) {
    var Result = "";
    var res = "";
    res = window.atob(AValue);
    Result = res;
    return Result;
  };
  var cSizeOfDouble = 8;
  this.SizeOf = function (AValue) {
    var Result = 0;
    Result = 8;
    return Result;
  };
  var cSizeOfInteger = 4;
  this.SizeOf$1 = function (AValue) {
    var Result = 0;
    Result = 4;
    return Result;
  };
  this.InsertAfter = function (newNode, referenceNode) {
    referenceNode.parentNode.insertBefore(newNode,referenceNode.nextSibling);
  };
  this.MatchStrEx = function (AValue1, AValue2, ACaseSensitive) {
    var Result = false;
    var ch = "\x00";
    var lastop = "\x00";
    var sep = 0;
    var cp = 0;
    var res = false;
    var newres = false;
    var CharArray = [];
    AValue1 = pas.SysUtils.Trim(AValue1);
    AValue1 = $impl.StripLogicSpaces(AValue1);
    sep = -1;
    if ($impl.VarPos("=",AValue1,{get: function () {
        return sep;
      }, set: function (v) {
        sep = v;
      }}) === 1) pas.System.Delete({get: function () {
        return AValue1;
      }, set: function (v) {
        AValue1 = v;
      }},sep,1);
    lastop = "\x00";
    res = true;
    CharArray = rtl.arraySetLength(CharArray,"\x00",5);
    CharArray[0] = "(";
    CharArray[1] = ";";
    CharArray[2] = "^";
    CharArray[3] = "&";
    CharArray[4] = "|";
    if (AValue1 === "") {
      Result = AValue2 === "";
      return Result;
    };
    if ((AValue1 !== "*") && (AValue2 === "")) {
      Result = false;
      return Result;
    };
    do {
      ch = $impl.FirstChar(CharArray,AValue1,{get: function () {
          return sep;
        }, set: function (v) {
          sep = v;
        }});
      if (ch !== "\x00") {
        if ((AValue1.length > 0) && (AValue1.charAt(0) === "(") && (pas.System.Pos("(",AValue1) > 0)) {
          cp = $impl.ClosingParenthesis(AValue1);
          newres = $mod.MatchStrEx(pas.System.Copy(AValue1,2,cp - 2),AValue2,ACaseSensitive);
          pas.System.Delete({get: function () {
              return AValue1;
            }, set: function (v) {
              AValue1 = v;
            }},1,cp);
        } else {
          newres = $mod.MatchStr(pas.System.Copy(AValue1,1,sep - 1),AValue2,ACaseSensitive);
          pas.System.Delete({get: function () {
              return AValue1;
            }, set: function (v) {
              AValue1 = v;
            }},1,sep);
        };
        if (lastop === "\x00") {
          res = newres}
         else {
          var $tmp = lastop;
          if (($tmp === ";") || ($tmp === "^") || ($tmp === "|")) {
            res = res || newres}
           else if ($tmp === "&") res = res && newres;
        };
        lastop = ch;
      };
    } while (!(ch === "\x00"));
    newres = $mod.MatchStr(AValue1,AValue2,ACaseSensitive);
    if (lastop === "\x00") {
      res = newres}
     else {
      var $tmp1 = lastop;
      if (($tmp1 === ";") || ($tmp1 === "^") || ($tmp1 === "|")) {
        res = res || newres}
       else if ($tmp1 === "&") res = res && newres;
    };
    Result = res;
    return Result;
  };
  this.MatchStr = function (AValue1, AValue2, ACaseSensitive) {
    var Result = false;
    if (ACaseSensitive) {
      Result = $impl.Matches(AValue1,AValue2)}
     else Result = $impl.Matches(pas.SysUtils.UpperCase(AValue1),pas.SysUtils.UpperCase(AValue2));
    return Result;
  };
  this.SelectElementContents = function (AElement) {
    if (window.getSelection && document.createRange) {
        var sel = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(AElement);
        sel.removeAllRanges();
        sel.addRange(range);
    } else if (document.selection && document.body.createTextRange) {
        var textRange = document.body.createTextRange();
        textRange.moveToElementText(AElement);
        textRange.select();
    };
  };
  this.FormatProp = function (AFmt, AArgs) {
    var Result = "";
    Result = pas.SysUtils.Format$1(AFmt,AArgs,pas.SysUtils.TFormatSettings.Invariant());
    return Result;
  };
  this.StringIsFloat = function (N) {
    var Result = false;
    var f = 0.0;
    Result = pas.SysUtils.TryStrToFloat$2(N,{get: function () {
        return f;
      }, set: function (v) {
        f = v;
      }});
    return Result;
  };
  this.StringIsInteger = function (N) {
    var Result = false;
    var I = 0;
    Result = true;
    if (pas.SysUtils.Trim(N) === "") return false;
    if ((pas.SysUtils.Trim(N).length > 1) && (pas.SysUtils.Trim(N).charAt(0) === "0")) return false;
    if (!(N.charCodeAt(I - 1) in rtl.createSet(null,48,57,45))) return false;
    for (var $l = 2, $end = N.length; $l <= $end; $l++) {
      I = $l;
      if (!(N.charCodeAt(I - 1) in rtl.createSet(null,48,57))) {
        Result = false;
        break;
      };
    };
    return Result;
  };
  this.MD5Hash = function (N) {
    var Result = "";
    var h = "";
    function md5(inputString) {
      var hc="0123456789abcdef";
      function rh(n) {var j,s="";for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;}
      function ad(x,y) {var l=(x&0xFFFF)+(y&0xFFFF);var m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);}
      function rl(n,c)            {return (n<<c)|(n>>>(32-c));}
      function cm(q,a,b,x,s,t)    {return ad(rl(ad(ad(a,q),ad(x,t)),s),b);}
      function ff(a,b,c,d,x,s,t)  {return cm((b&c)|((~b)&d),a,b,x,s,t);}
      function gg(a,b,c,d,x,s,t)  {return cm((b&d)|(c&(~d)),a,b,x,s,t);}
      function hh(a,b,c,d,x,s,t)  {return cm(b^c^d,a,b,x,s,t);}
      function ii(a,b,c,d,x,s,t)  {return cm(c^(b|(~d)),a,b,x,s,t);}
      function sb(x) {
          var i;var nblk=((x.length+8)>>6)+1;var blks=new Array(nblk*16);for(i=0;i<nblk*16;i++) blks[i]=0;
          for(i=0;i<x.length;i++) blks[i>>2]|=x.charCodeAt(i)<<((i%4)*8);
          blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks;
      }
      var i,x=sb(inputString),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd;
      for(i=0;i<x.length;i+=16) {olda=a;oldb=b;oldc=c;oldd=d;
          a=ff(a,b,c,d,x[i+ 0], 7, -680876936);d=ff(d,a,b,c,x[i+ 1],12, -389564586);c=ff(c,d,a,b,x[i+ 2],17,  606105819);
          b=ff(b,c,d,a,x[i+ 3],22,-1044525330);a=ff(a,b,c,d,x[i+ 4], 7, -176418897);d=ff(d,a,b,c,x[i+ 5],12, 1200080426);
          c=ff(c,d,a,b,x[i+ 6],17,-1473231341);b=ff(b,c,d,a,x[i+ 7],22,  -45705983);a=ff(a,b,c,d,x[i+ 8], 7, 1770035416);
          d=ff(d,a,b,c,x[i+ 9],12,-1958414417);c=ff(c,d,a,b,x[i+10],17,     -42063);b=ff(b,c,d,a,x[i+11],22,-1990404162);
          a=ff(a,b,c,d,x[i+12], 7, 1804603682);d=ff(d,a,b,c,x[i+13],12,  -40341101);c=ff(c,d,a,b,x[i+14],17,-1502002290);
          b=ff(b,c,d,a,x[i+15],22, 1236535329);a=gg(a,b,c,d,x[i+ 1], 5, -165796510);d=gg(d,a,b,c,x[i+ 6], 9,-1069501632);
          c=gg(c,d,a,b,x[i+11],14,  643717713);b=gg(b,c,d,a,x[i+ 0],20, -373897302);a=gg(a,b,c,d,x[i+ 5], 5, -701558691);
          d=gg(d,a,b,c,x[i+10], 9,   38016083);c=gg(c,d,a,b,x[i+15],14, -660478335);b=gg(b,c,d,a,x[i+ 4],20, -405537848);
          a=gg(a,b,c,d,x[i+ 9], 5,  568446438);d=gg(d,a,b,c,x[i+14], 9,-1019803690);c=gg(c,d,a,b,x[i+ 3],14, -187363961);
          b=gg(b,c,d,a,x[i+ 8],20, 1163531501);a=gg(a,b,c,d,x[i+13], 5,-1444681467);d=gg(d,a,b,c,x[i+ 2], 9,  -51403784);
          c=gg(c,d,a,b,x[i+ 7],14, 1735328473);b=gg(b,c,d,a,x[i+12],20,-1926607734);a=hh(a,b,c,d,x[i+ 5], 4,    -378558);
          d=hh(d,a,b,c,x[i+ 8],11,-2022574463);c=hh(c,d,a,b,x[i+11],16, 1839030562);b=hh(b,c,d,a,x[i+14],23,  -35309556);
          a=hh(a,b,c,d,x[i+ 1], 4,-1530992060);d=hh(d,a,b,c,x[i+ 4],11, 1272893353);c=hh(c,d,a,b,x[i+ 7],16, -155497632);
          b=hh(b,c,d,a,x[i+10],23,-1094730640);a=hh(a,b,c,d,x[i+13], 4,  681279174);d=hh(d,a,b,c,x[i+ 0],11, -358537222);
          c=hh(c,d,a,b,x[i+ 3],16, -722521979);b=hh(b,c,d,a,x[i+ 6],23,   76029189);a=hh(a,b,c,d,x[i+ 9], 4, -640364487);
          d=hh(d,a,b,c,x[i+12],11, -421815835);c=hh(c,d,a,b,x[i+15],16,  530742520);b=hh(b,c,d,a,x[i+ 2],23, -995338651);
          a=ii(a,b,c,d,x[i+ 0], 6, -198630844);d=ii(d,a,b,c,x[i+ 7],10, 1126891415);c=ii(c,d,a,b,x[i+14],15,-1416354905);
          b=ii(b,c,d,a,x[i+ 5],21,  -57434055);a=ii(a,b,c,d,x[i+12], 6, 1700485571);d=ii(d,a,b,c,x[i+ 3],10,-1894986606);
          c=ii(c,d,a,b,x[i+10],15,   -1051523);b=ii(b,c,d,a,x[i+ 1],21,-2054922799);a=ii(a,b,c,d,x[i+ 8], 6, 1873313359);
          d=ii(d,a,b,c,x[i+15],10,  -30611744);c=ii(c,d,a,b,x[i+ 6],15,-1560198380);b=ii(b,c,d,a,x[i+13],21, 1309151649);
          a=ii(a,b,c,d,x[i+ 4], 6, -145523070);d=ii(d,a,b,c,x[i+11],10,-1120210379);c=ii(c,d,a,b,x[i+ 2],15,  718787259);
          b=ii(b,c,d,a,x[i+ 9],21, -343485551);a=ad(a,olda);b=ad(b,oldb);c=ad(c,oldc);d=ad(d,oldd);
      }
      return rh(a)+rh(b)+rh(c)+rh(d);
    }
    h = md5(N);
    Result = h;
    return Result;
  };
  this.GetSysInfo = function () {
    var Result = $mod.TSysInfo.$new();
    function GetInfo(window)
        {
            var unknown = '-';
    
            // screen
            var screenSize = '';
            if (screen.width) {
                var width = (screen.width) ? screen.width : '';
                var height = (screen.height) ? screen.height : '';
                screenSize += '' + width + " x " + height;
            }
    
            // browser
            var nVer = navigator.appVersion;
            var nAgt = navigator.userAgent;
            var browser = navigator.appName;
            var version = '' + parseFloat(navigator.appVersion);
            var majorVersion = parseInt(navigator.appVersion, 10);
            var nameOffset, verOffset, ix;
    
            // Opera
            if ((verOffset = nAgt.indexOf('Opera')) != -1) {
                browser = 'Opera';
                version = nAgt.substring(verOffset + 6);
                if ((verOffset = nAgt.indexOf('Version')) != -1) {
                    version = nAgt.substring(verOffset + 8);
                }
            }
            // Opera Next
            if ((verOffset = nAgt.indexOf('OPR')) != -1) {
                browser = 'Opera';
                version = nAgt.substring(verOffset + 4);
            }
            // Legacy Edge
            else if ((verOffset = nAgt.indexOf('Edge')) != -1) {
                browser = 'Microsoft Legacy Edge';
                version = nAgt.substring(verOffset + 5);
            }
            // Edge (Chromium)
            else if ((verOffset = nAgt.indexOf('Edg')) != -1) {
                browser = 'Microsoft Edge';
                version = nAgt.substring(verOffset + 4);
            }
            // MSIE
            else if ((verOffset = nAgt.indexOf('MSIE')) != -1) {
                browser = 'Microsoft Internet Explorer';
                version = nAgt.substring(verOffset + 5);
            }
            // Chrome
            else if ((verOffset = nAgt.indexOf('Chrome')) != -1) {
                browser = 'Chrome';
                version = nAgt.substring(verOffset + 7);
            }
            // Safari
            else if ((verOffset = nAgt.indexOf('Safari')) != -1) {
                browser = 'Safari';
                version = nAgt.substring(verOffset + 7);
                if ((verOffset = nAgt.indexOf('Version')) != -1) {
                    version = nAgt.substring(verOffset + 8);
                }
            }
            // Firefox
            else if ((verOffset = nAgt.indexOf('Firefox')) != -1) {
                browser = 'Firefox';
                version = nAgt.substring(verOffset + 8);
            }
            // MSIE 11+
            else if (nAgt.indexOf('Trident/') != -1) {
                browser = 'Microsoft Internet Explorer';
                version = nAgt.substring(nAgt.indexOf('rv:') + 3);
            }
            // Other browsers
            else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) < (verOffset = nAgt.lastIndexOf('/'))) {
                browser = nAgt.substring(nameOffset, verOffset);
                version = nAgt.substring(verOffset + 1);
                if (browser.toLowerCase() == browser.toUpperCase()) {
                    browser = navigator.appName;
                }
            }
            // trim the version string
            if ((ix = version.indexOf(';')) != -1) version = version.substring(0, ix);
            if ((ix = version.indexOf(' ')) != -1) version = version.substring(0, ix);
            if ((ix = version.indexOf(')')) != -1) version = version.substring(0, ix);
    
            majorVersion = parseInt('' + version, 10);
            if (isNaN(majorVersion)) {
                version = '' + parseFloat(navigator.appVersion);
                majorVersion = parseInt(navigator.appVersion, 10);
            }
    
            // mobile version
            var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer);
    
            // cookie
            var cookieEnabled = (navigator.cookieEnabled) ? true : false;
    
            if (typeof navigator.cookieEnabled == 'undefined' && !cookieEnabled) {
                document.cookie = 'testcookie';
                cookieEnabled = (document.cookie.indexOf('testcookie') != -1) ? true : false;
            }
    
            // system
            var os = unknown;
            var clientStrings = [
                {s:'Windows 10', r:/(Windows 10.0|Windows NT 10.0)/},
                {s:'Windows 8.1', r:/(Windows 8.1|Windows NT 6.3)/},
                {s:'Windows 8', r:/(Windows 8|Windows NT 6.2)/},
                {s:'Windows 7', r:/(Windows 7|Windows NT 6.1)/},
                {s:'Windows Vista', r:/Windows NT 6.0/},
                {s:'Windows Server 2003', r:/Windows NT 5.2/},
                {s:'Windows XP', r:/(Windows NT 5.1|Windows XP)/},
                {s:'Windows 2000', r:/(Windows NT 5.0|Windows 2000)/},
                {s:'Windows ME', r:/(Win 9x 4.90|Windows ME)/},
                {s:'Windows 98', r:/(Windows 98|Win98)/},
                {s:'Windows 95', r:/(Windows 95|Win95|Windows_95)/},
                {s:'Windows NT 4.0', r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},
                {s:'Windows CE', r:/Windows CE/},
                {s:'Windows 3.11', r:/Win16/},
                {s:'Android', r:/Android/},
                {s:'Open BSD', r:/OpenBSD/},
                {s:'Sun OS', r:/SunOS/},
                {s:'Chrome OS', r:/CrOS/},
                {s:'Linux', r:/(Linux|X11(?!.*CrOS))/},
                {s:'iOS', r:/(iPhone|iPad|iPod)/},
                {s:'Mac OS X', r:/Mac OS X/},
                {s:'Mac OS', r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},
                {s:'QNX', r:/QNX/},
                {s:'UNIX', r:/UNIX/},
                {s:'BeOS', r:/BeOS/},
                {s:'OS/2', r:/OS\/2/},
                {s:'Search Bot', r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}
            ];
            for (var id in clientStrings) {
                var cs = clientStrings[id];
                if (cs.r.test(nAgt)) {
                    os = cs.s;
                    break;
                }
            }
    
            var osVersion = unknown;
    
            if (/Windows/.test(os)) {
                osVersion = /Windows (.*)/.exec(os)[1];
                os = 'Windows';
            }
    
            switch (os) {
                case 'Mac OS':
                case 'Mac OS X':
                case 'Android':
                    osVersion = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\.\_\d]+)/.exec(nAgt)[1];
                    break;
    
                case 'iOS':
                    osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
                    osVersion = osVersion[1] + '.' + osVersion[2] + '.' + (osVersion[3] | 0);
                    break;
            }
    
            // flash (you'll need to include swfobject)
            /* script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" */
            var flashVersion = 'no check';
            if (typeof swfobject != 'undefined') {
                var fv = swfobject.getFlashPlayerVersion();
                if (fv.major > 0) {
                    flashVersion = fv.major + '.' + fv.minor + ' r' + fv.release;
                }
                else  {
                    flashVersion = unknown;
                }
            }
           Result.screenSize = screenSize;
           Result.browser = browser;
           Result.browserversion = version;
           Result.browsermajorVersion = majorVersion;
           Result.mobile = mobile;
           Result.os = os;
           Result.osVersion = osVersion;
           Result.cookieEnabled = cookieEnabled;
          }
          GetInfo(window);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.FCompare = null;
    $impl.InternalCompare = function (AItem1, AItem2) {
      var Result = 0;
      Result = $impl.FCompare(rtl.getObject(AItem1),rtl.getObject(AItem2));
      return Result;
    };
    $impl.StripThousandSep = function (ps) {
      var Result = "";
      while (pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,ps) > 0) pas.System.Delete({get: function () {
          return ps;
        }, set: function (v) {
          ps = v;
        }},pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,ps),1);
      Result = ps;
      return Result;
    };
    $impl.VarPos = function (ASubValue, AValue, AResult) {
      var Result = 0;
      AResult.set(pas.System.Pos(ASubValue,AValue));
      Result = AResult.get();
      return Result;
    };
    $impl.IsDate = function (AValue, ADate) {
      var Result = false;
      var su = "";
      var ts = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var err = 0;
      var dp = 0;
      var mp = 0;
      var yp = 0;
      var vp = 0;
      Result = false;
      ts = "";
      su = pas.SysUtils.UpperCase(pas.SysUtils.FormatSettings.ShortDateFormat);
      dp = pas.System.Pos("D",su);
      mp = pas.System.Pos("M",su);
      yp = pas.System.Pos("Y",su);
      da = 0;
      mo = 0;
      ye = 0;
      ho = 0;
      mi = 0;
      se = 0;
      vp = -1;
      if ($impl.VarPos(pas.SysUtils.FormatSettings.DateSeparator,AValue,{get: function () {
          return vp;
        }, set: function (v) {
          vp = v;
        }}) > 0) {
        su = pas.System.Copy(AValue,1,vp - 1);
        if ((dp < mp) && (dp < yp)) {
          pas.System.val$5(su,{get: function () {
              return da;
            }, set: function (v) {
              da = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }})}
         else if ((mp < dp) && (mp < yp)) {
          pas.System.val$5(su,{get: function () {
              return mo;
            }, set: function (v) {
              mo = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }})}
         else if ((yp < mp) && (yp < dp)) pas.System.val$5(su,{get: function () {
            return ye;
          }, set: function (v) {
            ye = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return Result;
        pas.System.Delete({get: function () {
            return AValue;
          }, set: function (v) {
            AValue = v;
          }},1,vp);
        if ($impl.VarPos(pas.SysUtils.FormatSettings.DateSeparator,AValue,{get: function () {
            return vp;
          }, set: function (v) {
            vp = v;
          }}) > 0) {
          su = pas.System.Copy(AValue,1,vp - 1);
          if (((dp > mp) && (dp < yp)) || ((dp > yp) && (dp < mp))) {
            pas.System.val$5(su,{get: function () {
                return da;
              }, set: function (v) {
                da = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if (((mp > dp) && (mp < yp)) || ((mp > yp) && (mp < dp))) {
            pas.System.val$5(su,{get: function () {
                return mo;
              }, set: function (v) {
                mo = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if (((yp > mp) && (yp < dp)) || ((yp > dp) && (yp < mp))) pas.System.val$5(su,{get: function () {
              return ye;
            }, set: function (v) {
              ye = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err !== 0) return Result;
          pas.System.Delete({get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }},1,vp);
          AValue = pas.SysUtils.Trim(AValue);
          if ($impl.VarPos(" ",AValue,{get: function () {
              return vp;
            }, set: function (v) {
              vp = v;
            }}) > 0) {
            ts = pas.System.Copy(AValue,vp,AValue.length);
            AValue = pas.System.Copy(AValue,1,vp - 1);
          };
          if ((dp > mp) && (dp > yp)) {
            pas.System.val$5(AValue,{get: function () {
                return da;
              }, set: function (v) {
                da = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if ((mp > dp) && (mp > yp)) {
            pas.System.val$5(AValue,{get: function () {
                return mo;
              }, set: function (v) {
                mo = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if ((yp > mp) && (yp > dp)) pas.System.val$5(AValue,{get: function () {
              return ye;
            }, set: function (v) {
              ye = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err !== 0) return Result;
          if (da > 31) return Result;
          if (mo > 12) return Result;
          if (ts !== "") {
            if ($impl.VarPos(pas.SysUtils.FormatSettings.TimeSeparator,ts,{get: function () {
                return vp;
              }, set: function (v) {
                vp = v;
              }}) > 0) {
              su = pas.System.Copy(ts,1,vp - 1);
              pas.System.val$5(su,{get: function () {
                  return ho;
                }, set: function (v) {
                  ho = v;
                }},{get: function () {
                  return err;
                }, set: function (v) {
                  err = v;
                }});
              if (err !== 0) return Result;
              if (ho > 23) return Result;
              pas.System.Delete({get: function () {
                  return ts;
                }, set: function (v) {
                  ts = v;
                }},1,vp);
              if ($impl.VarPos(pas.SysUtils.FormatSettings.TimeSeparator,ts,{get: function () {
                  return vp;
                }, set: function (v) {
                  vp = v;
                }}) > 0) {
                su = pas.System.Copy(ts,1,vp - 1);
                pas.System.val$5(su,{get: function () {
                    return mi;
                  }, set: function (v) {
                    mi = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
                pas.System.Delete({get: function () {
                    return ts;
                  }, set: function (v) {
                    ts = v;
                  }},1,vp);
                pas.System.val$5(ts,{get: function () {
                    return se;
                  }, set: function (v) {
                    se = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
                if (se > 60) return Result;
              } else {
                pas.System.val$5(su,{get: function () {
                    return mi;
                  }, set: function (v) {
                    mi = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
              };
              if (mi > 59) return Result;
              Result = true;
            };
          } else Result = true;
          try {
            ADate.set(pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,0));
          } catch ($e) {
            Result = false;
          };
        };
      };
      return Result;
    };
    var larger = ">";
    var smaller = "<";
    var logand = "&";
    var logor = "^";
    var asterix = "*";
    var qmark = "?";
    var negation = "!";
    $impl.Matches = function (s0a, s1a) {
      var Result = false;
      var matching = false;
      var done = false;
      var len = 0;
      var lastchar = "\x00";
      var s0 = 0;
      var s1 = 0;
      var s2 = 0;
      var s3 = 0;
      var oksmaller = false;
      var oklarger = false;
      var negflag = false;
      var compstr = "";
      var flag1 = false;
      var flag2 = false;
      var flag3 = false;
      var equal = false;
      var n1 = 0.0;
      var n2 = 0.0;
      var code1 = 0;
      var code2 = 0;
      var dt1 = 0.0;
      var dt2 = 0.0;
      var q = 0;
      var i = 0;
      i = 0;
      oksmaller = true;
      oklarger = true;
      flag1 = false;
      flag2 = false;
      flag3 = false;
      negflag = false;
      equal = false;
      s2 = pas.System.Pos(larger,s0a);
      if (s2 !== 0) {
        s2 += 1;
        if (s0a.charAt(s2 - i - 1) === "=") {
          equal = true;
          s2 += 1;
        };
        while (s0a.charAt(s2 - i - 1) === " ") s2 += 1;
        s3 = s2;
        len = 0;
        lastchar = "\x00";
        q = 0;
        while (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((s0a.charAt(s2 - i - 1) !== "&") && (s0a.charAt(s2 - i - 1) !== "|")))) {
          if (s0a.charAt(s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (s0a.charAt(s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = s0a.charAt(s2 - i - 1);
          s2 += 1;
          if (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) === " ") && pas.System.Odd(q)) {
            lastchar = s0a.charAt(s2 - i - 1);
            s2 += 1;
          };
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        pas.System.val$8($impl.StripThousandSep(s1a),{get: function () {
            return n1;
          }, set: function (v) {
            n1 = v;
          }},{get: function () {
            return code1;
          }, set: function (v) {
            code1 = v;
          }});
        pas.System.val$8($impl.StripThousandSep(compstr),{get: function () {
            return n2;
          }, set: function (v) {
            n2 = v;
          }},{get: function () {
            return code2;
          }, set: function (v) {
            code2 = v;
          }});
        dt2 = 0;
        if ($impl.IsDate(compstr,{get: function () {
            return dt2;
          }, set: function (v) {
            dt2 = v;
          }})) code2 = 1;
        dt1 = 0;
        if ($impl.IsDate(s1a,{get: function () {
            return dt1;
          }, set: function (v) {
            dt1 = v;
          }})) code1 = 1;
        if ((code1 === 0) && (code2 === 0)) {
          if (equal) {
            oklarger = n1 >= n2}
           else oklarger = n1 > n2;
        } else {
          if ($impl.IsDate(compstr,{get: function () {
              return dt2;
            }, set: function (v) {
              dt2 = v;
            }}) && $impl.IsDate(s1a,{get: function () {
              return dt1;
            }, set: function (v) {
              dt1 = v;
            }})) {
            if (equal) {
              oklarger = dt1 >= dt2}
             else oklarger = dt1 > dt2;
          } else {
            if (equal) {
              oklarger = pas.SysUtils.CompareStr(compstr,s1a) <= 0}
             else oklarger = pas.SysUtils.CompareStr(compstr,s1a) < 0;
          };
        };
        flag1 = true;
      };
      equal = false;
      s2 = pas.System.Pos(smaller,s0a);
      if (s2 !== 0) {
        s2 += 1;
        if (s0a.charAt(s2 - i - 1) === "=") {
          equal = true;
          s2 += 1;
        };
        lastchar = "\x00";
        while (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) === " ")) s2 += 1;
        s3 = s2;
        len = 0;
        q = 0;
        while (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((s0a.charAt(s2 - i - 1) !== "&") && (s0a.charAt(s2 - i - 1) !== "|")))) {
          if (s0a.charAt(s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (s0a.charAt(s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = s0a.charAt(s2 - i - 1);
          s2 += 1;
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        pas.System.val$8($impl.StripThousandSep(s1a),{get: function () {
            return n1;
          }, set: function (v) {
            n1 = v;
          }},{get: function () {
            return code1;
          }, set: function (v) {
            code1 = v;
          }});
        pas.System.val$8($impl.StripThousandSep(compstr),{get: function () {
            return n2;
          }, set: function (v) {
            n2 = v;
          }},{get: function () {
            return code2;
          }, set: function (v) {
            code2 = v;
          }});
        if ($impl.IsDate(compstr,{get: function () {
            return dt2;
          }, set: function (v) {
            dt2 = v;
          }})) code2 = 1;
        if ($impl.IsDate(s1a,{get: function () {
            return dt1;
          }, set: function (v) {
            dt1 = v;
          }})) code1 = 1;
        if ((code1 === 0) && (code2 === 0)) {
          if (equal) {
            oksmaller = n1 <= n2}
           else oksmaller = n1 < n2;
        } else {
          if ($impl.IsDate(compstr,{get: function () {
              return dt2;
            }, set: function (v) {
              dt2 = v;
            }}) && $impl.IsDate(s1a,{get: function () {
              return dt1;
            }, set: function (v) {
              dt1 = v;
            }})) {
            if (equal) {
              oksmaller = dt1 <= dt2}
             else oksmaller = dt1 < dt2;
          } else {
            if (equal) {
              oksmaller = pas.SysUtils.CompareStr(compstr,s1a) >= 0}
             else oksmaller = pas.SysUtils.CompareStr(compstr,s1a) > 0;
          };
        };
        flag2 = true;
      };
      s2 = pas.System.Pos(negation,s0a);
      if (s2 !== 0) {
        s2 += 1;
        while (s0a.charAt(s2 - i - 1) === " ") s2 += 1;
        s3 = s2;
        len = 0;
        lastchar = "\x00";
        q = 0;
        while ((s0a.charAt(s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((s0a.charAt(s2 - i - 1) !== "&") && (s0a.charAt(s2 - i - 1) !== "|")))) {
          if (s0a.charAt(s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (s0a.charAt(s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = s0a.charAt(s2 - i - 1);
          s2 += 1;
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        flag3 = true;
      };
      if (flag3) {
        if (pas.System.Pos(larger,s0a) === 0) flag1 = flag3;
        if (pas.System.Pos(smaller,s0a) === 0) flag2 = flag3;
      };
      if (pas.System.Pos(logor,s0a) !== 0) if (flag1 || flag2) {
        Result = oksmaller || oklarger;
        return Result;
      };
      if (pas.System.Pos(logand,s0a) !== 0) if (flag1 && flag2) {
        Result = oksmaller && oklarger;
        return Result;
      };
      if (((pas.System.Pos(larger,s0a) !== 0) && oklarger) || ((pas.System.Pos(smaller,s0a) !== 0) && oksmaller)) {
        Result = true;
        return Result;
      };
      s0 = 1;
      s1 = 1;
      done = (s0a === "") || (s1a === "");
      matching = true;
      while (!done && matching) {
        var $tmp = s0a.charAt(s0 - i - 1);
        if ($tmp === qmark) {
          matching = s1 <= s1a.length;
          if (matching) {
            s0 += 1;
            s1 += 1;
          };
        } else if ($tmp === negation) {
          negflag = true;
          s0 += 1;
        } else if ($tmp === '"') {
          s0 += 1;
        } else if ($tmp === asterix) {
          do {
            s0 += 1;
          } while (!(((s0 - i) > s0a.length) || (s0a.charAt(s0 - i - 1) !== asterix)));
          len = s1a.length - s1;
          s1 += len;
          matching = $impl.Matches(pas.System.Copy(s0a,s0,s0a.length),pas.System.Copy(s1a,s1,s1a.length));
          while ((len >= 0) && !matching) {
            s1 -= 1;
            len -= 1;
            matching = $impl.Matches(pas.System.Copy(s0a,s0,s0a.length),pas.System.Copy(s1a,s1,s1a.length));
          };
          if (matching) {
            s0 = s0a.length + 1;
            s1 = s1a.length + 1;
          };
        } else {
          if ((s0 <= s0a.length) && (s1 <= s1a.length)) {
            matching = s0a.charAt(s0 - i - 1) === s1a.charAt(s1 - i - 1)}
           else matching = false;
          if (matching) {
            s0 += 1;
            s1 += 1;
          };
        };
        done = (s0 > s0a.length) && (s1 > s1a.length);
      };
      if (negflag) {
        Result = !matching}
       else Result = matching;
      return Result;
    };
    $impl.StripLogicSpaces = function (AValue) {
      var Result = "";
      var i = 0;
      var k = 0;
      var q = 0;
      q = 0;
      i = 1;
      k = AValue.length;
      Result = "";
      while (i <= k) {
        if (AValue.charAt(i - 1) === '"') q += 1;
        if (AValue.charAt(i - 1) === " ") {
          if (pas.System.Odd(q)) Result = Result + AValue.charAt(i - 1);
        } else Result = Result + AValue.charAt(i - 1);
        i += 1;
      };
      return Result;
    };
    $impl.FirstChar = function (ACharset, AValue, spos) {
      var Result = "\x00";
      var i = 0;
      var q = 0;
      var j = 0;
      j = 1;
      i = 1;
      q = 0;
      spos.set(-1);
      Result = "\x00";
      while (i <= AValue.length) {
        if (AValue.charAt(i - j - 1) === '"') q += 1;
        if (pas.SysUtils.CharInSet(AValue.charAt(i - j - 1),ACharset) && !pas.System.Odd(q)) {
          spos.set(i);
          Result = AValue.charAt(i - j - 1);
          break;
        };
        i += 1;
      };
      return Result;
    };
    $impl.ClosingParenthesis = function (s1) {
      var Result = 0;
      var i = 0;
      var j = 0;
      var k = 0;
      var r = 0;
      r = 0;
      j = 0;
      k = 0;
      i = 1;
      while (i <= s1.length) {
        if (s1.charAt(i - 1) === ")") k += 1;
        if (s1.charAt(i - 1) === "(") j += 1;
        if ((s1.charAt(i - 1) === ")") && (j === k)) {
          r = i;
          break;
        };
        i += 1;
      };
      Result = r;
      return Result;
    };
  };
},["RTLConsts","WEBLib.Consts","RTTI","WEBLib.REST"]);
rtl.module("WEBLib.Controls",["System","Classes","WEBLib.Graphics","Types","SysUtils","Web","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.VK_CANCEL = 3;
  this.VK_BACK = 8;
  this.VK_TAB = 9;
  this.VK_RETURN = 13;
  this.VK_SHIFT = 16;
  this.VK_CONTROL = 17;
  this.VK_MENU = 18;
  this.VK_PAUSE = 19;
  this.VK_CAPITAL = 20;
  this.VK_ESCAPE = 27;
  this.VK_SPACE = 32;
  this.VK_PRIOR = 33;
  this.VK_NEXT = 34;
  this.VK_END = 35;
  this.VK_HOME = 36;
  this.VK_LEFT = 37;
  this.VK_UP = 38;
  this.VK_RIGHT = 39;
  this.VK_DOWN = 40;
  this.VK_PRINT = 42;
  this.VK_SNAPSHOT = 44;
  this.VK_INSERT = 45;
  this.VK_DELETE = 46;
  this.VK_HELP = 47;
  this.VK_LWIN = 91;
  this.VK_RWIN = 92;
  this.VK_NUMPAD0 = 96;
  this.VK_NUMPAD1 = 97;
  this.VK_NUMPAD2 = 98;
  this.VK_NUMPAD3 = 99;
  this.VK_NUMPAD4 = 100;
  this.VK_NUMPAD5 = 101;
  this.VK_NUMPAD6 = 102;
  this.VK_NUMPAD7 = 103;
  this.VK_NUMPAD8 = 104;
  this.VK_NUMPAD9 = 105;
  this.VK_MULTIPLY = 106;
  this.VK_ADD = 107;
  this.VK_SEPARATOR = 108;
  this.VK_SUBTRACT = 109;
  this.VK_DECIMAL = 110;
  this.VK_DIVIDE = 111;
  this.VK_F1 = 112;
  this.VK_F2 = 113;
  this.VK_F3 = 114;
  this.VK_F4 = 115;
  this.VK_F5 = 116;
  this.VK_F6 = 117;
  this.VK_F7 = 118;
  this.VK_F8 = 119;
  this.VK_F9 = 120;
  this.VK_F10 = 121;
  this.VK_F11 = 122;
  this.VK_F12 = 123;
  this.VK_F13 = 124;
  this.VK_F14 = 125;
  this.VK_F15 = 126;
  this.VK_F16 = 127;
  this.VK_F17 = 128;
  this.VK_F18 = 129;
  this.VK_F19 = 130;
  this.VK_F20 = 131;
  this.VK_F21 = 132;
  this.VK_F22 = 133;
  this.VK_F23 = 134;
  this.VK_F24 = 135;
  this.VK_NUMLOCK = 144;
  this.WHEEL_DELTA = 120;
  this.RELEASETIMEOUT = 150;
  this.$rtti.$inherited("TCursor",rtl.longint,{});
  this.crDefault = 0;
  this.crNone = 1;
  this.crArrow = 2;
  this.crCross = 3;
  this.crIBeam = 4;
  this.crSize = 5;
  this.crSizeNESW = 6;
  this.crSizeNS = 7;
  this.crSizeNWSE = 8;
  this.crSizeWE = 9;
  this.crUpArrow = 10;
  this.crHourGlass = 11;
  this.crDrag = 12;
  this.crNoDrop = 13;
  this.crHSplit = 14;
  this.crVSplit = 15;
  this.crMultIDrag = 16;
  this.crSQLWait = 17;
  this.crNo = 18;
  this.crAppStart = 19;
  this.crHelp = 20;
  this.crHandPoint = 21;
  this.crSizeAll = 22;
  this.CSSBackground = "background-color";
  this.CSSZIndex = "z-index";
  this.$rtti.$Class("TCSSCodeManager");
  this.TCSSLibrary = {"0": "cssNone", cssNone: 0, "1": "cssBootstrap", cssBootstrap: 1};
  this.$rtti.$Enum("TCSSLibrary",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TCSSLibrary});
  this.TDragState = {"0": "dsDragEnter", dsDragEnter: 0, "1": "dsDragLeave", dsDragLeave: 1, "2": "dsDragMove", dsDragMove: 2};
  this.$rtti.$Enum("TDragState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TDragState});
  this.TDragMode = {"0": "dmManual", dmManual: 0, "1": "dmAutomatic", dmAutomatic: 1};
  this.$rtti.$Enum("TDragMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDragMode});
  this.TDragKind = {"0": "dkDrag", dkDrag: 0, "1": "dkDock", dkDock: 1};
  this.$rtti.$Enum("TDragKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDragKind});
  rtl.createClass(this,"TDragObject",pas.System.TObject,function () {
  });
  this.TAlign = {"0": "alNone", alNone: 0, "1": "alTop", alTop: 1, "2": "alBottom", alBottom: 2, "3": "alLeft", alLeft: 3, "4": "alRight", alRight: 4, "5": "alClient", alClient: 5, "6": "alCustom", alCustom: 6};
  this.$rtti.$Enum("TAlign",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TAlign});
  this.TMouseButton = {"0": "mbLeft", mbLeft: 0, "1": "mbRight", mbRight: 1, "2": "mbMiddle", mbMiddle: 2};
  this.$rtti.$Enum("TMouseButton",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMouseButton});
  this.TBorderStyle = {"0": "bsNone", bsNone: 0, "1": "bsSingle", bsSingle: 1};
  this.$rtti.$Enum("TBorderStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TBorderStyle});
  this.TSizeStyle = {"0": "ssPercent", ssPercent: 0, "1": "ssAbsolute", ssAbsolute: 1, "2": "ssAuto", ssAuto: 2};
  this.$rtti.$Enum("TSizeStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TSizeStyle});
  this.TScrollStyle = {"0": "ssNone", ssNone: 0, "1": "ssHorizontal", ssHorizontal: 1, "2": "ssVertical", ssVertical: 2, "3": "ssBoth", ssBoth: 3};
  this.$rtti.$Enum("TScrollStyle",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TScrollStyle});
  this.TStyleElements$a = {"0": "seFont", seFont: 0, "1": "seClient", seClient: 1, "2": "seBorder", seBorder: 2};
  this.$rtti.$Enum("TStyleElements$a",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TStyleElements$a});
  this.$rtti.$Set("TStyleElements",{comptype: this.$rtti["TStyleElements$a"]});
  this.TAnchorKind = {"0": "akLeft", akLeft: 0, "1": "akTop", akTop: 1, "2": "akRight", akRight: 2, "3": "akBottom", akBottom: 3};
  this.$rtti.$Enum("TAnchorKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TAnchorKind});
  this.$rtti.$Set("TAnchors",{comptype: this.$rtti["TAnchorKind"]});
  this.$rtti.$inherited("TElementClassName",rtl.string,{});
  this.$rtti.$inherited("TElementID",rtl.string,{});
  this.TElementFont = {"0": "efProperty", efProperty: 0, "1": "efCSS", efCSS: 1};
  this.$rtti.$Enum("TElementFont",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TElementFont});
  this.TElementPosition = {"0": "epAbsolute", epAbsolute: 0, "1": "epRelative", epRelative: 1, "2": "epIgnore", epIgnore: 2};
  this.$rtti.$Enum("TElementPosition",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TElementPosition});
  this.TElementEvent = {"0": "eeClick", eeClick: 0, "1": "eeMouseDown", eeMouseDown: 1, "2": "eeMouseUp", eeMouseUp: 2, "3": "eeMouseMove", eeMouseMove: 3, "4": "eeDblClick", eeDblClick: 4, "5": "eeKeyPress", eeKeyPress: 5, "6": "eeKeyDown", eeKeyDown: 6, "7": "eeKeyUp", eeKeyUp: 7, "8": "eeTouchStart", eeTouchStart: 8, "9": "eeTouchMove", eeTouchMove: 9, "10": "eeTouchEnd", eeTouchEnd: 10};
  this.$rtti.$Enum("TElementEvent",{minvalue: 0, maxvalue: 10, ordtype: 1, enumtype: this.TElementEvent});
  this.$rtti.$Set("TEventPropagation",{comptype: this.$rtti["TElementEvent"]});
  this.TTextDirection = {"0": "tdDefault", tdDefault: 0, "1": "tdLeftToRight", tdLeftToRight: 1, "2": "tdRightToLeft", tdRightToLeft: 2, "3": "tdInherit", tdInherit: 3};
  this.$rtti.$Enum("TTextDirection",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTextDirection});
  this.TBevelCut = {"0": "bvNone", bvNone: 0, "1": "bvLowered", bvLowered: 1, "2": "bvRaised", bvRaised: 2, "3": "bvSpace", bvSpace: 3};
  this.$rtti.$Enum("TBevelCut",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBevelCut});
  this.TBevelEdge = {"0": "beLeft", beLeft: 0, "1": "beTop", beTop: 1, "2": "beRight", beRight: 2, "3": "beBottom", beBottom: 3};
  this.$rtti.$Enum("TBevelEdge",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBevelEdge});
  this.$rtti.$Set("TBevelEdges",{comptype: this.$rtti["TBevelEdge"]});
  this.TBevelKind = {"0": "bkNone", bkNone: 0, "1": "bkTile", bkTile: 1, "2": "bkSoft", bkSoft: 2, "3": "bkFlat", bkFlat: 3};
  this.$rtti.$Enum("TBevelKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBevelKind});
  this.TInputType = {"0": "itText", itText: 0, "1": "itEmail", itEmail: 1, "2": "itDate", itDate: 2, "3": "itDateTime", itDateTime: 3, "4": "itFile", itFile: 4, "5": "itMonth", itMonth: 5, "6": "itNumber", itNumber: 6, "7": "itPassword", itPassword: 7, "8": "itSearch", itSearch: 8, "9": "itTime", itTime: 9, "10": "itURL", itURL: 10, "11": "itWeek", itWeek: 11};
  this.$rtti.$Enum("TInputType",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TInputType});
  this.TMaterialGlyphType = {"0": "mgNormal", mgNormal: 0, "1": "mgOutlined", mgOutlined: 1, "2": "mgTwoTone", mgTwoTone: 2, "3": "mgRound", mgRound: 3, "4": "mgSharp", mgSharp: 4};
  this.$rtti.$Enum("TMaterialGlyphType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMaterialGlyphType});
  rtl.recNewT(this,"TJSXMLHttpRequestRecord",function () {
    this.req = null;
    this.$eq = function (b) {
      return this.req === b.req;
    };
    this.$assign = function (s) {
      this.req = s.req;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSXMLHttpRequestRecord",{},this);
    $r.addField("req",pas.Web.$rtti["TJSXMLHttpRequest"]);
  });
  rtl.recNewT(this,"TJSEventRecord",function () {
    this.event = null;
    this.$eq = function (b) {
      return this.event === b.event;
    };
    this.$assign = function (s) {
      this.event = s.event;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSEventRecord",{},this);
    $r.addField("event",pas.Web.$rtti["TJSEvent"]);
  });
  this.$rtti.$MethodVar("THTTPResponseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("THTTPRequestResponseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARequest",this.$rtti["TJSXMLHttpRequestRecord"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("THTTPAbortEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("THTTPErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARequest",this.$rtti["TJSXMLHttpRequestRecord"]],["Event",this.$rtti["TJSEventRecord"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  rtl.recNewT(this,"TJSHTMLElementRecord",function () {
    this.element = null;
    this.$eq = function (b) {
      return this.element === b.element;
    };
    this.$assign = function (s) {
      this.element = s.element;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSHTMLElementRecord",{},this);
    $r.addField("element",pas.Web.$rtti["TJSHTMLElement"]);
  });
  rtl.recNewT(this,"TJSObjectRecord",function () {
    this.jsobject = null;
    this.$eq = function (b) {
      return this.jsobject === b.jsobject;
    };
    this.$assign = function (s) {
      this.jsobject = s.jsobject;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSObjectRecord",{},this);
    $r.addField("jsobject",pas.JS.$rtti["TJSObject"]);
  });
  rtl.recNewT(this,"TJSArrayRecord",function () {
    this.jsarray = null;
    this.$eq = function (b) {
      return this.jsarray === b.jsarray;
    };
    this.$assign = function (s) {
      this.jsarray = s.jsarray;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSArrayRecord",{},this);
    $r.addField("jsarray",pas.JS.$rtti["TJSArray"]);
  });
  rtl.recNewT(this,"TJSArrayBufferRecord",function () {
    this.jsarraybuffer = null;
    this.$eq = function (b) {
      return this.jsarraybuffer === b.jsarraybuffer;
    };
    this.$assign = function (s) {
      this.jsarraybuffer = s.jsarraybuffer;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSArrayBufferRecord",{},this);
    $r.addField("jsarraybuffer",pas.JS.$rtti["TJSArrayBuffer"]);
  });
  rtl.createClass(this,"TDragSourceObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FJSEvent = null;
      this.FObject = null;
    };
    this.$final = function () {
      this.FJSEvent = undefined;
      this.FObject = undefined;
      pas.System.TObject.$final.call(this);
    };
  });
  this.$rtti.$MethodVar("TNotifyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Button",this.$rtti["TMouseButton"]],["Shift",pas.Classes.$rtti["TShiftState"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseWheelEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["WheelDelta",rtl.longint],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseWheelUpDownEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseMoveEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TKeyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AKey",rtl.word,1],["Shift",pas.Classes.$rtti["TShiftState"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TKeyPressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AChar",rtl.char,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTouchEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.TBiDiMode = {"0": "bdLeftToRight", bdLeftToRight: 0, "1": "bdRightToLeft", bdRightToLeft: 1, "2": "bdRightToLeftNoAlign", bdRightToLeftNoAlign: 2, "3": "bdRightToLeftReadingOnly", bdRightToLeftReadingOnly: 3};
  this.$rtti.$Enum("TBiDiMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBiDiMode});
  this.$rtti.$MethodVar("TDragOverEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint],["State",this.$rtti["TDragState"]],["Accept",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TDragDropEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TStartDragEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DragObject",this.$rtti["TDragObject"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TEndDragEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Target",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TScreenshotEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABitmap",pas["WEBLib.Graphics"].$rtti["TBitmap"]]]), methodkind: 0});
  this.TControlStyleValue = {"0": "csAcceptsControls", csAcceptsControls: 0, "1": "csSetCaption", csSetCaption: 1};
  this.$rtti.$Enum("TControlStyleValue",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TControlStyleValue});
  this.$rtti.$Set("TControlStyle",{comptype: this.$rtti["TControlStyleValue"]});
  rtl.createClass(this,"TMargins",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FLeft = 0;
      this.FTop = 0;
      this.FRight = 0;
      this.FBottom = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetLeft = function (Value) {
      if (Value !== this.FLeft) {
        this.FLeft = Value;
        this.DoChange();
      };
    };
    this.SetTop = function (Value) {
      if (Value !== this.FTop) {
        this.FTop = Value;
        this.DoChange();
      };
    };
    this.SetRight = function (Value) {
      if (Value !== this.FRight) {
        this.FRight = Value;
        this.DoChange();
      };
    };
    this.SetBottom = function (Value) {
      if (Value !== this.FBottom) {
        this.FBottom = Value;
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      this.FLeft = 3;
      this.FTop = 3;
      this.FBottom = 3;
      this.FRight = 3;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TMargins.isPrototypeOf(Source)) {
        this.FLeft = rtl.as(Source,$mod.TMargins).FLeft;
        this.FTop = rtl.as(Source,$mod.TMargins).FTop;
        this.FBottom = rtl.as(Source,$mod.TMargins).FBottom;
        this.FRight = rtl.as(Source,$mod.TMargins).FRight;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Left",2,rtl.longint,"FLeft","SetLeft",4,{Default: 3});
    $r.addProperty("Top",2,rtl.longint,"FTop","SetTop",4,{Default: 3});
    $r.addProperty("Right",2,rtl.longint,"FRight","SetRight",4,{Default: 3});
    $r.addProperty("Bottom",2,rtl.longint,"FBottom","SetBottom",4,{Default: 3});
  });
  rtl.createClass(this,"TCenter",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FHorizontal = false;
      this.FVertical = false;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHorizontal = function (Value) {
      if (this.FHorizontal !== Value) {
        this.FHorizontal = Value;
        this.DoChange();
      };
    };
    this.SetVertical = function (Value) {
      if (this.FVertical !== Value) {
        this.FVertical = Value;
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Assign = function (Source) {
      if ($mod.TCenter.isPrototypeOf(Source)) {
        this.FHorizontal = rtl.as(Source,$mod.TCenter).FHorizontal;
        this.FVertical = rtl.as(Source,$mod.TCenter).FVertical;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Horizontal",2,rtl.boolean,"FHorizontal","SetHorizontal",4,{Default: false});
    $r.addProperty("Vertical",2,rtl.boolean,"FVertical","SetVertical",4,{Default: false});
  });
  rtl.createClass(this,"TPadding",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FLeft = 0;
      this.FTop = 0;
      this.FRight = 0;
      this.FBottom = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetLeft = function (Value) {
      if (this.FLeft !== Value) {
        this.FLeft = Value;
        this.DoChange();
      };
    };
    this.SetTop = function (Value) {
      if (this.FTop !== Value) {
        this.FTop = Value;
        this.DoChange();
      };
    };
    this.SetRight = function (Value) {
      if (this.FRight !== Value) {
        this.FRight = Value;
        this.DoChange();
      };
    };
    this.SetBottom = function (Value) {
      if (this.FBottom !== Value) {
        this.FBottom = Value;
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FLeft = 0;
      this.FTop = 0;
      this.FRight = 0;
      this.FBottom = 0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TPadding.isPrototypeOf(Source)) {
        this.FLeft = rtl.as(Source,$mod.TPadding).FLeft;
        this.FRight = rtl.as(Source,$mod.TPadding).FRight;
        this.FTop = rtl.as(Source,$mod.TPadding).FTop;
        this.FBottom = rtl.as(Source,$mod.TPadding).FBottom;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Left",2,rtl.longint,"FLeft","SetLeft",4,{Default: 0});
    $r.addProperty("Top",2,rtl.longint,"FTop","SetTop",4,{Default: 0});
    $r.addProperty("Right",2,rtl.longint,"FRight","SetRight",4,{Default: 0});
    $r.addProperty("Bottom",2,rtl.longint,"FBottom","SetBottom",4,{Default: 0});
  });
  rtl.createInterface(this,"IControl","{6325F220-F2E4-384C-B7C4-A6C697D13DCF}",["EnterChildren","ExitChildren"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("EnterChildren",1,[["AObject",$r]],2,rtl.boolean);
    $r.addMethod("ExitChildren",1,[["AObject",$r]],2,rtl.boolean);
  });
  rtl.createClass(this,"TControl",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FGotFocus = false;
      this.FAcceptDrag = false;
      this.FCaptureDown = false;
      this.FMouseInsideLayer = false;
      this.FLayer = null;
      this.FCaptured = false;
      this.FControlCreated = false;
      this.FUpdateCount = 0;
      this.FBlockUpdateElement = false;
      this.FElement = null;
      this.FID = "";
      this.FNew = false;
      this.FContainer = null;
      this.FElementEvent = null;
      this.FLastElementEvent = null;
      this.FElementClassName = "";
      this.FFont = null;
      this.FParent = null;
      this.FPrevParent = null;
      this.FControls = [];
      this.FOnDragOver = null;
      this.FOnDragDrop = null;
      this.FOnStartDrag = null;
      this.FonEndDrag = null;
      this.FOnClick = null;
      this.FOnDblClick = null;
      this.FOnMouseDown = null;
      this.FOnMouseUp = null;
      this.FOnMouseMove = null;
      this.FOnKeyDown = null;
      this.FOnKeyUp = null;
      this.FOnKeyPress = null;
      this.FOnEnter = null;
      this.FOnExit = null;
      this.FEnabled = false;
      this.FHint = "";
      this.FRole = "";
      this.FShowHint = false;
      this.FTabOrder = 0;
      this.FTabStop = false;
      this.FVisible = false;
      this.FWidth = 0;
      this.FHeight = 0;
      this.FTag$1 = 0;
      this.FAlign = 0;
      this.FAnchors = {};
      this.FAlignWithMargins = false;
      this.FIsAligning = false;
      this.FOnMouseEnter = null;
      this.FOnMouseLeave = null;
      this.FCursor = 0;
      this.FDoubleBuffered = false;
      this.FControlStyle = {};
      this.FMargins = null;
      this.FCenter = null;
      this.FOnMouseWheel = null;
      this.FParentDoubleBuffered = false;
      this.FParentColor = false;
      this.FParentFont = false;
      this.FParentBiDiMode = false;
      this.FOnTouchMove = null;
      this.FOnTouchStart = null;
      this.FOnTouchEnd = null;
      this.FOnTouchCancel = null;
      this.FLinkTouchEvents = false;
      this.FWidthStyle = 0;
      this.FHeightStyle = 0;
      this.FWidthPercent = 0.0;
      this.FHeightPercent = 0.0;
      this.FOrigRect = pas.Types.TRect.$new();
      this.FOrigParentRect = pas.Types.TRect.$new();
      this.FIsResizing = false;
      this.FShowFocus = false;
      this.FBorderWidth = 0;
      this.FOrigTop = 0;
      this.FOrigLeft = 0;
      this.FUpdateTopLeft = false;
      this.FEnablePropagation = false;
      this.FParentShowHint = false;
      this.FScriptLoaded = false;
      this.FControlScriptCount = 0;
      this.FControlScriptCountLoaded = 0;
      this.FRequiredScripts = null;
      this.FElementFont = 0;
      this.FElementPosition = 0;
      this.FParentElement = null;
      this.FTagObject = null;
      this.FClipChildren = false;
      this.FTextDirection = 0;
      this.FEventStopPropagation = {};
      this.FParentElementID = "";
      this.FOnResize = null;
      this.FMouseMovePtr = null;
      this.FMouseDownPtr = null;
      this.FMouseUpPtr = null;
      this.FMouseEnterPtr = null;
      this.FMouseLeavePtr = null;
      this.FClickPtr = null;
      this.FDblClickPtr = null;
      this.FKeyDownPtr = null;
      this.FKeyUpPtr = null;
      this.FKeyPressPtr = null;
      this.FInputPtr = null;
      this.FTouchStartPtr = null;
      this.FTouchEndPtr = null;
      this.FTouchMovePtr = null;
      this.FTouchCancelPtr = null;
      this.FContextMenuPtr = null;
      this.FExitPtr = null;
      this.FEnterPtr = null;
      this.FWheelPtr = null;
      this.FLayerMouseEnterPtr = null;
      this.FLayerMouseLeavePtr = null;
      this.FScriptLoadedPtr = null;
      this.FDragStartPtr = null;
      this.FDragOverPtr = null;
      this.FDragEnterPtr = null;
      this.FDragLeavePtr = null;
      this.FDragEndPtr = null;
      this.FDragDropPtr = null;
      this.FChildOrder = 0;
      this.FAllowTouch = false;
      this.FCtl3D = false;
      this.FParentCtl3D = false;
      this.FWheelAccumulator = 0;
      this.FWheelMousePos = pas.Types.TPoint.$new();
      this.FBiDiMode = 0;
      this.FOnMouseWheelDown = null;
      this.FOnMouseWheelUp = null;
      this.FNoUserSelect = false;
      this.FEventsBound = false;
      this.FDragMode = 0;
      this.FToolTip = undefined;
      this.FDesignTime = false;
      this.FColor = 0;
    };
    this.$final = function () {
      this.FLayer = undefined;
      this.FElement = undefined;
      this.FContainer = undefined;
      this.FElementEvent = undefined;
      this.FLastElementEvent = undefined;
      this.FFont = undefined;
      this.FParent = undefined;
      this.FPrevParent = undefined;
      this.FControls = undefined;
      this.FOnDragOver = undefined;
      this.FOnDragDrop = undefined;
      this.FOnStartDrag = undefined;
      this.FonEndDrag = undefined;
      this.FOnClick = undefined;
      this.FOnDblClick = undefined;
      this.FOnMouseDown = undefined;
      this.FOnMouseUp = undefined;
      this.FOnMouseMove = undefined;
      this.FOnKeyDown = undefined;
      this.FOnKeyUp = undefined;
      this.FOnKeyPress = undefined;
      this.FOnEnter = undefined;
      this.FOnExit = undefined;
      this.FAnchors = undefined;
      this.FOnMouseEnter = undefined;
      this.FOnMouseLeave = undefined;
      this.FControlStyle = undefined;
      this.FMargins = undefined;
      this.FCenter = undefined;
      this.FOnMouseWheel = undefined;
      this.FOnTouchMove = undefined;
      this.FOnTouchStart = undefined;
      this.FOnTouchEnd = undefined;
      this.FOnTouchCancel = undefined;
      this.FOrigRect = undefined;
      this.FOrigParentRect = undefined;
      this.FRequiredScripts = undefined;
      this.FParentElement = undefined;
      this.FTagObject = undefined;
      this.FEventStopPropagation = undefined;
      this.FOnResize = undefined;
      this.FWheelMousePos = undefined;
      this.FOnMouseWheelDown = undefined;
      this.FOnMouseWheelUp = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.GetControlsCount = function () {
      var Result = 0;
      Result = rtl.length(this.FControls);
      return Result;
    };
    this.GetControls = function (Index) {
      var Result = null;
      Result = this.FControls[Index];
      return Result;
    };
    this.SetVisible = function (AValue) {
      if (this.FVisible !== AValue) {
        this.VisibleChanging();
        this.FVisible = AValue;
        this.UpdateElement();
        this.DoRealign();
        this.AlignControl(this);
        this.VisibleChanged();
      };
    };
    this.SetHint = function (AValue) {
      if (this.FHint !== AValue) {
        this.FHint = AValue;
        this.UpdateElement();
      };
    };
    this.SetShowHint = function (AValue) {
      if (this.FShowHint !== AValue) {
        this.FShowHint = AValue;
        this.UpdateElement();
      };
    };
    this.SetTabOrder = function (AValue) {
      if (this.FTabOrder !== AValue) {
        this.FTabOrder = AValue;
        this.UpdateElement();
      };
    };
    this.SetTabStop = function (AValue) {
      if (this.FTabStop !== AValue) {
        this.FTabStop = AValue;
        this.UpdateElement();
      };
    };
    this.SetAlign = function (Value) {
      if (this.FAlign !== Value) {
        this.FAlign = Value;
        this.DoRealign();
      };
    };
    this.SetAlignWithMargins = function (Value) {
      if (this.FAlignWithMargins !== Value) {
        this.FAlignWithMargins = Value;
        this.DoRealign();
      };
    };
    this.GetBoundsRect = function () {
      var Result = pas.Types.TRect.$new();
      Result.Left = this.GetLeft();
      Result.Top = this.GetTop();
      Result.Right = this.GetLeft() + this.GetWidth();
      Result.Bottom = this.GetTop() + this.GetHeight();
      return Result;
    };
    this.SetBoundsRect = function (Value) {
      this.SetBoundsInt(Value.Left,Value.Top,Value.Right - Value.Left,Value.Bottom - Value.Top);
    };
    this.SetID = function (Value) {
      var eh = null;
      var el = null;
      var tmp = null;
      var frm = null;
      var p = null;
      var l = 0;
      var t = 0;
      var w = 0;
      var h = 0;
      if (this.FNew && (this.FID !== Value)) {
        eh = document.getElementById(Value);
        if (eh != null) {
          l = this.FLeft;
          t = this.FTop;
          w = this.FWidth;
          h = this.FHeight;
          tmp = null;
          this.UnbindEvents();
          if (this.FContainer != null) {
            this.FParentElement = this.FContainer.parentElement;
            tmp = document.createElement("SPAN");
            this.$class.MoveElements(this.FContainer,tmp);
          };
          p = this.FParent;
          this.SetParent(null);
          this.CreateWithID(Value);
          this.SetParentComponent(p);
          this.FID = Value;
          this.FWidth = w;
          this.FHeight = h;
          this.UpdateElement();
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
            this.FLeft = l;
            this.FTop = t;
          };
          if (tmp != null) {
            this.GetElementHandle().textContent = "";
            this.MoveElementsAndFree(tmp,this.GetElementHandle());
          };
          return;
        };
      };
      if (!this.FNew && (this.FID !== Value)) {
        w = this.FWidth;
        h = this.FHeight;
        eh = document.getElementById(this.FID);
        if (eh != null) {
          tmp = document.createElement("SPAN");
          this.$class.MoveElements(eh,tmp);
          this.UnbindEvents();
        };
        if (Value !== "") {
          eh = document.getElementById(Value);
          if (eh != null) {
            this.CreateWithID(Value);
            this.FID = Value;
            this.FWidth = w;
            this.FHeight = h;
            this.UpdateElement();
            this.MoveElementsAndFree(tmp,this.FContainer);
            return;
          };
        };
        this.FNew = true;
        this.FElement = null;
        this.CreateControl();
        if (Value === "") {
          this.CreateInitialize();
          this.FWidth = w;
          this.FHeight = h;
        };
        if (this.FParentElement != null) {
          this.FParentElement.appendChild(this.GetContainer());
        } else document.body.appendChild(this.GetContainer());
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if (frm != null) {
          this.SetParent(frm);
          this.SetElementPosition($mod.TElementPosition.epAbsolute);
          this.SetLeft(0);
          this.SetTop(0);
        };
        if (tmp != null) this.MoveElementsAndFree(tmp,this.FContainer);
        this.UpdateElement();
        this.UpdateElementSize();
      };
      this.FID = Value;
      if (this.FContainer != null) this.FContainer.setAttribute("id",Value);
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
    };
    this.SetAnchors = function (Value) {
      if (rtl.neSet(this.FAnchors,Value)) {
        this.FAnchors = rtl.refSet(Value);
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
          this.UpdateAnchoring();
        };
      };
    };
    this.GetElementEvent = function () {
      var Result = null;
      Result = this.FElementEvent;
      return Result;
    };
    this.GetClientOrigin = function () {
      var Result = pas.Types.TPoint.$new();
      var r = null;
      Result.$assign(pas.Types.Point(0,0));
      if (this.GetElementHandle() != null) {
        r = this.GetElementHandle().getBoundingClientRect();
        Result.$assign(pas.Types.Point(Math.round(r.left),Math.round(r.top)));
      };
      return Result;
    };
    this.SetBorderWidth = function (Value) {
      if (this.FBorderWidth !== Value) {
        this.FBorderWidth = Value;
        this.UpdateElement();
      };
    };
    this.GetIsLinked = function () {
      var Result = false;
      Result = !this.FNew;
      return Result;
    };
    this.SetScriptLoaded = function (Value) {
      this.FScriptLoaded = Value;
    };
    this.SetRequiredScripts = function (Value) {
      this.FRequiredScripts.Assign(Value);
    };
    this.SetElementFont = function (Value) {
      if (this.FElementFont !== Value) {
        this.FElementFont = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetElementPosition = function (Value) {
      if (this.FElementPosition !== Value) {
        this.FElementPosition = Value;
        if (this.GetElementHandle() != null) {
          this.UpdateElementSize();
          this.RecreateCanvas();
          this.InternalResize();
        };
      };
    };
    this.SetParentElement = function (Value) {
      if (this.FNew) {
        this.FElementPosition = $mod.TElementPosition.epRelative;
        this.CreateControl();
        this.FParentElement = Value;
        if (this.FParentElement != null) {
          this.FParentElement.appendChild(this.GetContainer());
        };
      } else {
        if (this.FParentElement != null) this.FParentElement.removeChild(this.GetContainer());
        this.FParentElement = Value;
        if (this.FParentElement != null) this.FParentElement.appendChild(this.GetContainer());
        this.UpdateElement();
      };
      this.InitScript();
      this.Invalidate();
    };
    this.SetClipChildren = function (Value) {
      this.FClipChildren = Value;
      this.UpdateElement();
    };
    this.SetParentElementID = function (Value) {
      var el = null;
      this.FParentElementID = Value;
      el = document.getElementById(this.FParentElementID);
      if (el != null) this.SetParentElement(el);
    };
    this.SetChildOrderEx = function (Value) {
      this.FChildOrder = Value;
    };
    this.GetRole = function () {
      var Result = "";
      Result = this.FRole;
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().getAttribute("role");
      return Result;
    };
    this.SetRole = function (Value) {
      this.FRole = Value;
      if (this.GetElementHandle() != null) {
        if (Value === "") {
          this.GetElementHandle().removeAttribute("role")}
         else this.GetElementHandle().setAttribute("role",Value);
      };
    };
    this.GetContainer = function () {
      var Result = null;
      Result = this.FContainer;
      return Result;
    };
    this.GetChildContainer = function () {
      var Result = null;
      Result = this.FContainer;
      return Result;
    };
    this.SetParentFont = function (Value) {
      if ((Value !== this.FParentFont) && Value && (this.FParent != null)) {
        this.BeginUpdate();
        this.FFont.Assign(this.FParent.FFont);
        this.EndUpdate();
        this.UpdateElement();
      };
      this.FParentFont = Value;
    };
    this.SetParentColor = function (Value) {
      if ((this.FParentColor !== Value) && Value && (this.FParent != null)) {
        this.SetColor(this.FParent.FColor);
      };
      this.FParentColor = Value;
    };
    this.SetDragMode = function (Value) {
      this.FDragMode = Value;
      if (Value === $mod.TDragMode.dmAutomatic) {
        this.BeginDrag()}
       else this.DisableDrag();
    };
    this.GetClientHeight = function () {
      var Result = 0;
      Result = this.GetHeight();
      return Result;
    };
    this.GetClientWidth = function () {
      var Result = 0;
      Result = this.GetWidth();
      return Result;
    };
    this.SetClientHeight = function (Value) {
      this.SetHeight(Value);
    };
    this.SetClientWidth = function (Value) {
      this.SetWidth(Value);
    };
    this.SetHeightStyle = function (Value) {
      if (this.FHeightStyle !== Value) {
        this.FHeightStyle = Value;
        if ((this.FHeightStyle === $mod.TSizeStyle.ssAuto) && (this.GetElementHandle() != null) && !this.GetIsLinked()) this.GetElementStyle().removeProperty("height");
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetWidthStyle = function (Value) {
      if (this.FWidthStyle !== Value) {
        this.FWidthStyle = Value;
        if ((this.FWidthStyle === $mod.TSizeStyle.ssAuto) && (this.GetElementHandle() != null) && !this.GetIsLinked()) this.GetElementStyle().removeProperty("width");
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetHeightPercent = function (Value) {
      if (this.FHeightPercent !== Value) {
        this.FHeightPercent = Value;
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetWidthPercent = function (Value) {
      if (this.FWidthPercent !== Value) {
        this.FWidthPercent = Value;
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetShowFocus = function (Value) {
      if (this.FShowFocus !== Value) {
        this.FShowFocus = Value;
        this.UpdateElement();
      };
    };
    this.SetWidth = function (AValue) {
      if (this.FWidth !== AValue) {
        this.FWidth = AValue;
        this.ResetAnchoring();
        this.DoBoundsChange();
        if (this.GetIsLinked() && (this.FWidthStyle === $mod.TSizeStyle.ssAbsolute) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !this.IsUpdating() && (this.GetElementHandle() != null)) {
          if (AValue >= 0) {
            this.GetElementStyle().setProperty("width",pas.SysUtils.IntToStr(AValue) + "px")}
           else this.GetElementStyle().removeProperty("width");
        };
      };
    };
    this.SetHeight = function (AValue) {
      var dr = null;
      if (this.FHeight !== AValue) {
        if ((this.FAlign in rtl.createSet($mod.TAlign.alLeft,$mod.TAlign.alRight,$mod.TAlign.alClient)) && (this.GetElementHandle() != null)) {
          dr = this.GetElementHandle().getBoundingClientRect();
          if ((dr.top + AValue) >= pas["WEBLib.Forms"].WinHeight()) {
            AValue = Math.round(pas["WEBLib.Forms"].WinHeight() - dr.top);
          };
        };
        this.FHeight = AValue;
        this.ResetAnchoring();
        this.DoBoundsChange();
        if (this.GetIsLinked() && (this.FHeightStyle === $mod.TSizeStyle.ssAbsolute) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !this.IsUpdating() && (this.GetElementHandle() != null)) {
          if (AValue >= 0) {
            this.GetElementStyle().setProperty("height",pas.SysUtils.IntToStr(AValue) + "px")}
           else this.GetElementStyle().removeProperty("height");
        };
      };
    };
    this.SetWidthInt = function (AValue) {
      this.FWidth = AValue;
    };
    this.SetHeightInt = function (AValue) {
      this.FHeight = AValue;
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.UpdateElementData();
      };
    };
    this.RecreateCanvas = function () {
    };
    this.VisibleChanging = function () {
    };
    this.VisibleChanged = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).VisibleChanged();
      };
    };
    this.ColorChanging = function () {
    };
    this.IncUpdateCount = function () {
      this.FUpdateCount += 1;
    };
    this.DecUpdateCount = function () {
      this.FUpdateCount -= 1;
    };
    this.FocusedControlEntered = function () {
      var p = null;
      var c = null;
      var $ir = rtl.createIntfRefs();
      try {
        p = this.FParent;
        while (p !== null) if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(p,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.IControl),{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }}) && c.EnterChildren($ir.ref(2,rtl.queryIntfT(this,$mod.IControl)))) {
          break}
         else p = p.FParent;
      } finally {
        $ir.free();
        rtl._Release(c);
      };
    };
    this.FocusedControlExited = function () {
      var p = null;
      var c = null;
      var undef = false;
      var $ir = rtl.createIntfRefs();
      try {
        p = this.FParent;
        undef = false;
        undef = (p == undefined);
        while (!undef && (p !== null)) if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(p,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.IControl),{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }}) && c.ExitChildren($ir.ref(2,rtl.queryIntfT(this,$mod.IControl)))) {
          break}
         else p = p.FParent;
      } finally {
        $ir.free();
        rtl._Release(c);
      };
    };
    this.EnterChildren = function (AObject) {
      var Result = false;
      rtl._AddRef(AObject);
      try {
        Result = false;
      } finally {
        rtl._Release(AObject);
      };
      return Result;
    };
    this.ExitChildren = function (AObject) {
      var Result = false;
      rtl._AddRef(AObject);
      try {
        Result = false;
      } finally {
        rtl._Release(AObject);
      };
      return Result;
    };
    this.GetWidth = function () {
      var Result = 0;
      var cr = null;
      Result = this.FWidth;
      if ((this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if (Result === -1) {
          Result = Math.round(pas.System.Int(this.GetElementHandle().offsetWidth));
        };
        if (this.FWidthStyle !== $mod.TSizeStyle.ssAbsolute) {
          cr = this.GetElementHandle().getBoundingClientRect();
          Result = Math.round(pas.System.Int(cr.right - cr.left));
        };
      };
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      var cr = null;
      Result = this.FHeight;
      if ((this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if (Result === -1) {
          Result = Math.round(pas.System.Int(this.GetElementHandle().offsetHeight));
        };
        if (this.FHeightStyle !== $mod.TSizeStyle.ssAbsolute) {
          cr = this.GetElementHandle().getBoundingClientRect();
          Result = Math.round(pas.System.Int(cr.bottom - cr.top));
        };
      };
      return Result;
    };
    this.GetOuterWidth = function () {
      var Result = 0;
      Result = this.FWidth - this.FBorderWidth;
      return Result;
    };
    this.GetOuterHeight = function () {
      var Result = 0;
      Result = this.FHeight - this.FBorderWidth;
      return Result;
    };
    this.GetDesignWidth = function () {
      var Result = 0;
      Result = this.FWidth;
      return Result;
    };
    this.GetDesignHeight = function () {
      var Result = 0;
      Result = this.FHeight;
      return Result;
    };
    this.GetDesignLeft = function () {
      var Result = 0;
      Result = this.FLeft;
      return Result;
    };
    this.GetDesignTop = function () {
      var Result = 0;
      Result = this.FTop;
      return Result;
    };
    this.GetLeft = function () {
      var Result = 0;
      Result = this.FLeft;
      if ((Result === -1) && (this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) Result = Math.round(this.GetElementHandle().offsetLeft);
      return Result;
    };
    this.GetTop = function () {
      var Result = 0;
      Result = this.FTop;
      if ((Result === -1) && (this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) Result = Math.round(this.GetElementHandle().offsetTop);
      return Result;
    };
    this.HandleAllocated = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.CreateChildElements = function (AContainer) {
    };
    this.ContainerElement = function () {
      var Result = null;
      Result = document.body;
      return Result;
    };
    this.IsStructuralElement = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.IsEnabled = function () {
      var Result = false;
      Result = this.FEnabled;
      return Result;
    };
    this.GetNewName = function () {
      var Result = "";
      var s = "";
      var lPrefix = "";
      var frm = null;
      s = this.$classname;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      lPrefix = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) lPrefix = frm.$classname;
      Result = lPrefix + "_" + $mod.FindUniqueName(s);
      return Result;
    };
    this.IsInputControl = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.UseCSSFont = function () {
      var Result = false;
      Result = !((this.FElementClassName === "") && (this.FElementFont === $mod.TElementFont.efProperty) && !this.GetIsLinked());
      return Result;
    };
    this.UseCSSFontColor = function () {
      var Result = false;
      Result = !(pas["WEBLib.Forms"].Application.FThemed && (pas["WEBLib.Graphics"].ColorToRGB(this.FFont.FColor) === pas["WEBLib.Graphics"].RGB(0,0,0)));
      return Result;
    };
    this.RecreateElement = function () {
      if (this.GetContainer() != null) {
        this.UnbindEvents();
        this.GetContainer().parentNode.removeChild(this.GetContainer());
        this.FElement = null;
        this.CreateControl();
        if ((this.FParent != null) && (this.FParent.GetContainer() != null)) this.FParent.GetChildContainer().appendChild(this.GetContainer());
      };
    };
    this.BindElement = function () {
    };
    this.CreateInitialize = function () {
      var frm = null;
      this.FDesignTime = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FRequiredScripts = pas.Classes.TStringList.$create("Create$1");
      this.FOrigRect.$assign(pas.Types.Rect(-1,-1,-1,-1));
      this.FClipChildren = true;
      if (this.FDesignTime) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if ((frm != null) && pas["WEBLib.Forms"].TForm.isPrototypeOf(frm) && (rtl.as(frm,pas["WEBLib.Forms"].TForm).FCSSLibrary !== $mod.TCSSLibrary.cssNone)) {
          this.InitCSSLibrary(rtl.as(frm,pas["WEBLib.Forms"].TForm).FCSSLibrary);
        };
      };
    };
    this.DestroyControls = function () {
      var i = 0;
      var ctrl = null;
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        i = $l;
        ctrl = this.GetControls(i);
        ctrl = rtl.freeLoc(ctrl);
      };
    };
    this.ClearControls = function () {
      this.FControls = rtl.arraySetLength(this.FControls,null,0);
    };
    this.GetElementStyle = function () {
      var Result = null;
      Result = this.GetElementHandle().style;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
    };
    this.SetControlCursor = function (Value) {
      this.FCursor = Value;
      if ((this.FElementClassName === "") && (this.GetElementHandle() != null)) {
        this.SetElementPointer(this.GetElementHandle(),Value);
      };
    };
    this.SetBiDiMode = function (Value) {
      if (this.GetElementHandle() != null) {
        if (Value === $mod.TBiDiMode.bdLeftToRight) {
          this.GetElementHandle().removeAttribute("dir")}
         else this.GetElementHandle().setAttribute("dir","rtl");
      };
    };
    this.GetMouseEventButton = function (Event) {
      var Result = 0;
      Result = $mod.TMouseButton.mbLeft;
      var $tmp = Event.button;
      if ($tmp === 0) {
        Result = $mod.TMouseButton.mbLeft}
       else if ($tmp === 1) {
        Result = $mod.TMouseButton.mbMiddle}
       else if ($tmp === 2) Result = $mod.TMouseButton.mbRight;
      return Result;
    };
    this.GetMouseEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      if ((Event.buttons & 1) === 1) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssLeft));
      if ((Event.buttons & 2) === 2) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssRight));
      if ((Event.buttons & 4) === 4) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssMIDdle));
      return Result;
    };
    this.GetKeyBoardEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      return Result;
    };
    this.GetMouseWheelEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      return Result;
    };
    this.GetTouchEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      if ($mod.TElementEvent.eeClick in this.FEventStopPropagation) this.StopPropagation();
      if (this.FEnabled) this.Click();
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoWheel = function (Event) {
      var Result = false;
      var ss = {};
      var h = false;
      var l = 0.0;
      var t = 0.0;
      this.FElementEvent = Event;
      this.StopPropagation();
      this.XYToClient(Event.clientX,Event.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      this.FWheelMousePos.x = Math.round(l);
      this.FWheelMousePos.y = Math.round(t);
      ss = rtl.refSet(this.GetMouseWheelEventShiftState(Event));
      h = false;
      this.MouseWheel(rtl.refSet(ss),pas.System.Trunc(-Event.deltaY),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }});
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDblClick = function (Event) {
      var Result = false;
      this.FCaptureDown = false;
      this.FElementEvent = Event;
      if ($mod.TElementEvent.eeDblClick in this.FEventStopPropagation) this.StopPropagation();
      if (this.FEnabled) this.DblClick();
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseDown = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var mb = 0;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeMouseDown in this.FEventStopPropagation) this.StopPropagation();
      if (!this.CanFocus()) this.PreventDefault();
      $impl.FMouseX = Math.round(AEvent.clientX);
      $impl.FMouseY = Math.round(AEvent.clientY);
      this.XYToClient(AEvent.clientX,AEvent.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      if (this.HasVertScrollBar() && (l > (this.GetWidth() - $mod.GetScrollBarWidth()))) return Result;
      if (this.HasHorzScrollBar() && (t > (this.GetHeight() - $mod.GetScrollBarHeight()))) return Result;
      ss = rtl.refSet(this.GetMouseEventShiftState(AEvent));
      mb = this.GetMouseEventButton(AEvent);
      this.MouseDown(mb,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseUp = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var mb = 0;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeMouseUp in this.FEventStopPropagation) this.StopPropagation();
      this.XYToClient(AEvent.clientX,AEvent.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      if (this.HasVertScrollBar() && (l > (this.GetWidth() - $mod.GetScrollBarWidth()))) {
        this.FElementEvent = null;
        return Result;
      };
      if (this.HasHorzScrollBar() && (t > (this.GetHeight() - $mod.GetScrollBarHeight()))) {
        this.FElementEvent = null;
        return Result;
      };
      ss = rtl.refSet(this.GetMouseEventShiftState(AEvent));
      mb = this.GetMouseEventButton(AEvent);
      if (this.FDragMode === $mod.TDragMode.dmManual) this.DisableDrag();
      this.MouseUp(mb,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseMove = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      $impl.FCursorX = Math.round(AEvent.clientX);
      $impl.FCursorY = Math.round(AEvent.clientY);
      if ($mod.TElementEvent.eeMouseMove in this.FEventStopPropagation) this.StopPropagation();
      this.XYToClient(AEvent.clientX,AEvent.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      ss = rtl.refSet(this.GetMouseEventShiftState(AEvent));
      this.MouseMove(rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseLeave = function (Event) {
      var Result = false;
      if (this.Captured()) return Result;
      Event.stopPropagation();
      this.DoMouseLeave();
      Result = true;
      return Result;
    };
    this.HandleDoContextMenu = function (Event) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.LayerHandleDoMouseEnter = function (Event) {
      var Result = false;
      if ((Event.buttons === 0) && this.Captured() && !this.FMouseInsideLayer) {
        this.ReleaseCapture();
        this.HandleDoMouseUp(Event);
        this.HandleDoMouseLeave(Event);
      };
      this.FMouseInsideLayer = true;
      Result = true;
      return Result;
    };
    this.LayerHandleDoMouseLeave = function (Event) {
      var Result = false;
      this.FMouseInsideLayer = false;
      Result = true;
      return Result;
    };
    this.HandleDoMouseEnter = function (Event) {
      var Result = false;
      if (this.Captured()) return Result;
      Event.stopPropagation();
      this.DoMouseEnter();
      Result = true;
      return Result;
    };
    this.HandleDoKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      var ss = {};
      var undef = false;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeKeyDown in this.FEventStopPropagation) this.StopPropagation();
      undef = (AEvent.key == undefined);
      if (!undef) {
        k = this.GetKeyCode(AEvent.key,true);
        ss = rtl.refSet(this.GetKeyBoardEventShiftState(AEvent));
        this.KeyDown({get: function () {
            return k;
          }, set: function (v) {
            k = v;
          }},rtl.refSet(ss));
        if (k in rtl.createSet(13,27,9)) {
          this.KeyPreview({get: function () {
              return k;
            }, set: function (v) {
              k = v;
            }},rtl.refSet(ss));
        };
      };
      Result = true;
      if (k === 0) this.PreventDefault();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoKeyUp = function (Event) {
      var Result = false;
      var k = 0;
      var ss = {};
      var c = "\x00";
      var undef = false;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeKeyUp in this.FEventStopPropagation) this.StopPropagation();
      undef = (AEvent.key == undefined);
      if (!undef) {
        k = this.GetKeyCode(AEvent.key,true);
        ss = rtl.refSet(this.GetKeyBoardEventShiftState(AEvent));
        if (k === 27) {
          c = "\x1B";
          this.KeyPress({get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
        };
        this.KeyUp({get: function () {
            return k;
          }, set: function (v) {
            k = v;
          }},rtl.refSet(ss));
      };
      Result = true;
      if (k === 0) this.PreventDefault();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoKeyPress = function (Event) {
      var Result = false;
      var c = "\x00";
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeKeyPress in this.FEventStopPropagation) this.StopPropagation();
      if (this.IsKeyCharacter(AEvent.key)) {
        c = this.GetKeyChar(AEvent.key);
        this.KeyPress({get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
      };
      Result = true;
      if (c === "\x00") this.PreventDefault();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoInput = function (Event) {
      var Result = false;
      var c = "\x00";
      var stemp = "";
      if ($mod.IsAndroid()) {
        this.FElementEvent = Event;
        if ($mod.TElementEvent.eeKeyPress in this.FEventStopPropagation) this.StopPropagation();
        c = "\x00";
        if (Event.data !== "") {
          stemp = Event.data;
          if (pas.System.Assigned(stemp)) {
            c = stemp.charAt(stemp.length - 1)}
           else c = "\b";
          this.KeyPress({get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
        };
        Result = true;
        if (c === "\x00") this.PreventDefault();
        this.FElementEvent = null;
      };
      return Result;
    };
    this.HandleDoExit = function (Event) {
      var Result = false;
      this.DoExit();
      Result = true;
      this.FocusedControlExited();
      return Result;
    };
    this.HandleDoEnter = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      this.StopPropagation();
      this.DoEnter();
      Result = true;
      this.FElementEvent = null;
      this.FGotFocus = true;
      this.FocusedControlEntered();
      return Result;
    };
    this.HandleDoTouchStart = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      this.FLastElementEvent = Event;
      if ($mod.TElementEvent.eeTouchStart in this.FEventStopPropagation) this.StopPropagation();
      if (!this.FAllowTouch) this.PreventDefault();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) {
          this.MouseDown($mod.TMouseButton.mbLeft,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
        };
        this.TouchStart(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoTouchMove = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      this.FLastElementEvent = Event;
      if ($mod.TElementEvent.eeTouchMove in this.FEventStopPropagation) this.StopPropagation();
      if (!this.FAllowTouch) this.PreventDefault();
      if (this.Captured()) this.PreventDefault();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) this.MouseMove(rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
        this.TouchMove(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      this.FElementEvent = null;
      Result = true;
      return Result;
    };
    this.HandleDoTouchEnd = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      if (!this.FAllowTouch) this.PreventDefault();
      this.ReleaseCapture();
      if ($mod.TElementEvent.eeTouchEnd in this.FEventStopPropagation) this.StopPropagation();
      if ((this.FLastElementEvent != null) && (this.FLastElementEvent.touches.length > 0)) {
        touch = this.FLastElementEvent.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) {
          this.MouseUp($mod.TMouseButton.mbLeft,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
          if (this.FEnabled && !this.FAllowTouch) this.Click();
        };
        this.TouchEnd(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      this.FElementEvent = null;
      Result = true;
      return Result;
    };
    this.HandleDoTouchCancel = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      this.ReleaseCapture();
      this.StopPropagation();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) {
          this.MouseUp($mod.TMouseButton.mbLeft,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
        };
        this.TouchCancel(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      this.FElementEvent = null;
      Result = true;
      return Result;
    };
    this.HandleDoDragStart = function (Event) {
      var Result = false;
      var obj = null;
      this.FElementEvent = Event;
      Event.stopPropagation();
      obj = null;
      this.DoStartDrag({get: function () {
          return obj;
        }, set: function (v) {
          obj = v;
        }});
      if (obj != null) {
        $impl.DragObject = obj}
       else $impl.DragObject = this;
      Result = true;
      return Result;
    };
    this.HandleDoDragOver = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.DragOver($impl.DragObject,Event.clientX,Event.clientY,$mod.TDragState.dsDragMove,{p: this, get: function () {
          return this.p.FAcceptDrag;
        }, set: function (v) {
          this.p.FAcceptDrag = v;
        }});
      if (this.FAcceptDrag && (!this.IsInputControl() || (Event.dataTransfer.items.length === 0))) Event.preventDefault();
      Result = !this.FAcceptDrag;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDragEnter = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.FAcceptDrag = this.IsInputControl();
      this.DragOver($impl.DragObject,Event.clientX,Event.clientY,$mod.TDragState.dsDragEnter,{p: this, get: function () {
          return this.p.FAcceptDrag;
        }, set: function (v) {
          this.p.FAcceptDrag = v;
        }});
      if (this.FAcceptDrag) Event.preventDefault();
      Result = !this.FAcceptDrag;
      this.FElementEvent = null;
      return Result;
    };
    this.HandledoDragLeave = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.DragOver($impl.DragObject,Event.clientX,Event.clientY,$mod.TDragState.dsDragLeave,{p: this, get: function () {
          return this.p.FAcceptDrag;
        }, set: function (v) {
          this.p.FAcceptDrag = v;
        }});
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDragEnd = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.DoEndDrag($impl.DragObject,Event.clientX,Event.clientY);
      Result = true;
      if (this.FDragMode === $mod.TDragMode.dmManual) this.DisableDrag();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDragDrop = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      if (!this.FAcceptDrag) {
        Event.preventDefault()}
       else {
        if (!this.IsInputControl()) Event.preventDefault();
        this.DragDrop($impl.DragObject,Event.clientX,Event.clientY);
      };
      Result = this.FAcceptDrag;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleKeyPreview = function (Key) {
    };
    this.HandleFontChanged = function (Sender) {
      if (this.FUpdateCount === 0) {
        this.SetParentFont(false);
        this.ParentFontChanged();
      };
      this.FontChanged();
    };
    this.ParentFontChanged = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetControls(i).FParentFont) {
          this.GetControls(i).FFont.Assign(this.FFont);
          this.GetControls(i).FontChanged();
          this.GetControls(i).FParentFont = true;
          this.GetControls(i).ParentFontChanged();
        };
      };
    };
    this.DoExit = function () {
      if (this.FOnExit != null) this.FOnExit(this);
    };
    this.DoEnter = function () {
      if (this.FOnEnter != null) this.FOnEnter(this);
    };
    this.Click = function () {
      if ((this.FOnClick != null) && this.IsEnabled()) this.FOnClick(this);
    };
    this.UpdateElement = function () {
      if (this.FBlockUpdateElement || (this.FUpdateCount > 0)) return;
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement()) && !this.IsUpdating()) {
        this.UpdateElementData();
        if (!this.GetIsLinked()) {
          this.UpdateElementVisual();
        };
      };
    };
    this.UpdateElementSize = function () {
      var es = null;
      var offsLeft = 0;
      var offsTop = 0;
      var ow = 0;
      var ctrl = null;
      var cr = null;
      if (this.FBlockUpdateElement || (this.FUpdateCount > 0)) return;
      if (this.GetIsLinked()) return;
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement())) {
        es = this.GetElementStyle();
        offsLeft = 0;
        offsTop = 0;
        ctrl = this.FParent;
        while ((ctrl != null) && (this.FElementPosition === $mod.TElementPosition.epAbsolute) && (ctrl.FElementPosition !== $mod.TElementPosition.epAbsolute) && !pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(ctrl)) {
          if (ctrl.GetIsLinked() && (ctrl.GetElementHandle() != null) && (ctrl.GetElementHandle().style.getPropertyValue("position") !== "absolute")) {
            cr = ctrl.GetElementHandle().getBoundingClientRect();
            offsLeft = Math.round(cr.left);
            offsTop = Math.round(cr.top);
            if ((ctrl.FParent != null) && (ctrl.FParent.GetElementHandle() != null) && (ctrl.FParent.GetElementHandle().style.getPropertyValue("position") === "absolute")) {
              cr = ctrl.FParent.GetElementHandle().getBoundingClientRect();
              offsLeft = offsLeft - Math.round(cr.left);
              offsTop = offsTop - Math.round(cr.top);
            };
            break;
          };
          ctrl = ctrl.FParent;
        };
        if ((this.FParent != null) && this.FParent.IsStructuralElement()) {
          offsLeft = this.FParent.GetLeft();
          offsTop = this.FParent.GetTop();
        };
        if (this.FElementPosition === $mod.TElementPosition.epAbsolute) {
          if (this.FTop !== -1) {
            es.setProperty("top",pas.SysUtils.IntToStr(this.FTop + offsTop) + "px")}
           else es.setProperty("top","");
          if (this.FLeft !== -1) {
            es.setProperty("left",pas.SysUtils.IntToStr(this.FLeft + offsLeft) + "px")}
           else es.setProperty("left","");
        } else {
          es.removeProperty("top");
          es.removeProperty("left");
        };
        if (this.FWidthStyle === $mod.TSizeStyle.ssAbsolute) {
          ow = this.GetOuterWidth();
          if (this.FWidth !== -1) {
            es.setProperty("width",pas.SysUtils.IntToStr(ow) + "px")}
           else es.removeProperty("width");
        };
        if (this.FWidthStyle === $mod.TSizeStyle.ssAuto) {
          es.removeProperty("width");
        };
        if (this.FHeightStyle === $mod.TSizeStyle.ssAbsolute) {
          if (this.FHeight !== -1) {
            es.setProperty("height",pas.SysUtils.IntToStr(this.GetOuterHeight()) + "px")}
           else es.removeProperty("height");
        };
        if (this.FHeightStyle === $mod.TSizeStyle.ssAuto) {
          es.removeProperty("height");
        };
        if (this.FWidthStyle === $mod.TSizeStyle.ssPercent) {
          if (this.FWidth !== -1) {
            es.setProperty("width",pas["WEBLib.Utils"].FormatProp("%.2f%%",pas.System.VarRecs(3,this.FWidthPercent)))}
           else es.removeProperty("width");
        };
        if (this.FHeightStyle === $mod.TSizeStyle.ssPercent) {
          if (this.FHeight !== -1) {
            es.setProperty("height",pas["WEBLib.Utils"].FormatProp("%.2f%%",pas.System.VarRecs(3,this.FHeightPercent)))}
           else es.removeProperty("height");
        };
        if (this.FElementPosition === $mod.TElementPosition.epAbsolute) {
          es.setProperty("position","absolute")}
         else if (this.FElementPosition === $mod.TElementPosition.epRelative) {
          es.setProperty("position","relative")}
         else es.removeProperty("position");
        es.setProperty("box-sizing","border-box");
      };
    };
    this.UpdateElementVisual = function () {
      var eh = null;
      var es = null;
      var useCSS = false;
      var LinkedForm = false;
      eh = this.GetElementHandle();
      if (!(eh != null)) return;
      if (this.IsUpdating()) return;
      es = this.GetElementStyle();
      if (this.FParentFont && (this.FParent != null)) {
        this.FFont.FOnChange = null;
        this.FFont.Assign(this.FParent.FFont);
        this.FFont.FOnChange = rtl.createCallback(this,"HandleFontChanged");
      };
      if (this.FElementClassName === "") {
        LinkedForm = pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this) && (rtl.as(this,pas["WEBLib.Forms"].TCustomForm).FFormContainer !== "");
        if (!this.GetIsLinked() && !LinkedForm) {
          if (this.FClipChildren && (pas.SysUtils.LowerCase(eh.tagName) !== pas["WEBLib.WebTools"].cBodyTag)) {
            es.setProperty("overflow","hidden")}
           else es.setProperty("overflow","");
        };
        this.SetElementPointer(eh,this.FCursor);
      };
      if (this.Captured()) this.FLayer.style.setProperty("cursor",es.getPropertyValue("cursor"));
      if ((this.FElementClassName !== "") || this.CanShowFocus()) {
        es.setProperty("outline","")}
       else es.setProperty("outline","none");
      this.UpdateElementSize();
      var $tmp = this.FTextDirection;
      if ($tmp === $mod.TTextDirection.tdDefault) {
        es.removeProperty("direction")}
       else if ($tmp === $mod.TTextDirection.tdRightToLeft) {
        es.setProperty("direction","rtl")}
       else if ($tmp === $mod.TTextDirection.tdLeftToRight) {
        es.setProperty("direction","ltr")}
       else if ($tmp === $mod.TTextDirection.tdInherit) es.setProperty("direction","inherit");
      if ((this.FElementClassName === "") && this.FNoUserSelect) {
        es.setProperty("webkit-user-select","none");
        es.setProperty("moz-user-select","none");
        es.setProperty("khtml-user-select","none");
        es.setProperty("ms-user-select","none");
        es.setProperty("user-select","none");
        es.setProperty("-webkit-tap-highlight-color","transparent");
      };
      this.SetElementColor(eh,this.FColor);
      useCSS = this.UseCSSFont();
      if (!this.GetIsLinked()) $mod.SetHTMLElementFont(eh,this.FFont,useCSS);
      if (!useCSS) {
        if (this.IsEnabled() && this.UseCSSFontColor()) es.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
      } else {
        es.removeProperty("color");
      };
    };
    this.UpdateElementData = function () {
      var frm = null;
      var el = null;
      var AToolTip = "";
      var ToolTipClass = "";
      var ToolTipPos = "";
      var ToolTipPause = 0;
      var ToolTipHidePause = 0;
      var tt = undefined;
      var isBootstrap = false;
      if (this.GetElementHandle() != null) {
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          if (this.FVisible) {
            this.GetElementStyle().setProperty("display","")}
           else this.GetElementStyle().setProperty("display","none");
        };
        this.EnableTab();
        if (this.FContainer != null) {
          if (this.IsEnabled()) {
            this.FContainer.removeAttribute("disabled");
            this.FContainer.style.removeProperty("pointer-events");
          } else {
            this.FContainer.setAttribute("disabled","");
            this.FContainer.style.setProperty("pointer-events","none");
          };
        };
        if (this.GetIsLinked() && (this.FHint === "")) return;
        if ((this.FContainer != null) && (this.GetRole() !== "")) this.FContainer.setAttribute("role",this.FRole);
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        isBootstrap = (frm != null) && (frm.FCSSLibrary === $mod.TCSSLibrary.cssBootstrap);
        if (isBootstrap && this.FShowHint && (this.FHint !== "")) {
          el = this.GetElementHandle();
          AToolTip = this.FHint;
          var $tmp = pas["WEBLib.Forms"].Application.FHintPosition;
          if ($tmp === pas["WEBLib.Forms"].THintPosition.hpLeft) {
            ToolTipPos = "left"}
           else if ($tmp === pas["WEBLib.Forms"].THintPosition.hpRight) {
            ToolTipPos = "right"}
           else if ($tmp === pas["WEBLib.Forms"].THintPosition.hpTop) {
            ToolTipPos = "top"}
           else if ($tmp === pas["WEBLib.Forms"].THintPosition.hpBottom) ToolTipPos = "bottom";
          ToolTipClass = pas["WEBLib.Forms"].Application.FHintClassName;
          ToolTipPause = pas["WEBLib.Forms"].Application.FHintPause;
          ToolTipHidePause = pas["WEBLib.Forms"].Application.FHintHidePause;
          tt = this.FToolTip;
          if (tt) { tt.dispose(); }
          el.setAttribute('title',AToolTip);
          tt = new bootstrap.Tooltip(el, {
          title: AToolTip,
          trigger: 'hover',
          placement: ToolTipPos,
          customClass: ToolTipClass,
          delay: { "show": ToolTipPause, "hide": ToolTipHidePause }
          });
          this.FToolTip = tt;
        } else {
          if (this.FContainer != null) {
            if (this.FShowHint && (this.FHint !== "")) {
              if (isBootstrap) {
                this.FContainer.setAttribute("data-title",this.FHint)}
               else this.FContainer.setAttribute("title",this.FHint);
            } else {
              if (isBootstrap) {
                this.FContainer.removeAttribute("data-title")}
               else this.FContainer.removeAttribute("title");
            };
          };
        };
        if (!this.IsEnabled() || (this.FElementFont === $mod.TElementFont.efCSS)) {
          this.GetElementStyle().removeProperty("color")}
         else if (this.UseCSSFontColor()) this.GetElementStyle().setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
      };
    };
    this.UpdateParent = function () {
      this.InternalUpdateParent();
      if (this.FAlign !== $mod.TAlign.alNone) {
        this.UpdateChildren(this.FPrevParent);
        this.UpdateChildren(this.FParent);
      };
    };
    this.UpdateControlSize = function (AWidth, AHeight) {
      this.FWidth = AWidth;
      this.FHeight = AHeight;
    };
    this.InternalUpdateParent = function () {
      var p = null;
      p = this.FPrevParent;
      if (this.FNew) {
        this.CreateControl();
        if (this.GetContainer() != null) {
          if ((this.FParent != null) && !(this.FParent.GetContainer() != null)) this.FParent.CreateControl();
          if ((this.FParent !== p) && (p != null) && (p.GetContainer() != null)) {
            if (this.GetContainer().parentNode === p.GetChildContainer()) p.GetChildContainer().removeChild(this.GetContainer());
          };
          if ((this.FParent != null) && (this.FParent.GetContainer() != null)) {
            this.FParent.GetChildContainer().appendChild(this.GetContainer());
          };
        };
      };
    };
    this.UpdateChildren = function (AControl) {
      var I = 0;
      var c = null;
      if ((AControl != null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (AControl.FAlign !== $mod.TAlign.alNone) AControl.DoRealign();
        if ($mod.TCustomControl.isPrototypeOf(AControl)) {
          rtl.as(AControl,$mod.TCustomControl).RecreateCanvas();
          rtl.as(AControl,$mod.TCustomControl).Invalidate();
        };
        for (var $l = 0, $end = AControl.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          c = AControl.GetControls(I);
          this.UpdateChildren(c);
        };
      };
    };
    this.PersistinHTML = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).PersistinHTML();
      };
    };
    this.LoadFromHTML = function (HTML) {
      if (this.GetElementHandle() != null) this.GetElementHandle().outerHTML = HTML;
    };
    this.InitFromHTML = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).InitFromHTML();
      };
    };
    this.SaveState = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.LoadState = function (AState) {
    };
    this.DisableTab = function () {
      var i = 0;
      if (!(this.FTabStop && this.CanFocus())) {
        if (this.GetContainer() != null) this.GetContainer().setAttribute("tabindex","-1");
      };
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).DisableTab();
      };
    };
    this.EnableTab = function () {
      var i = 0;
      if ((this.FContainer != null) && !this.GetIsLinked()) {
        if (this.FTabStop && this.CanFocus()) {
          this.FContainer.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder + 1));
        } else {
          this.FContainer.setAttribute("tabindex","-1");
        };
      };
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).EnableTab();
      };
    };
    this.SetElementClassName = function (AValue) {
      if (this.FElementClassName !== AValue) {
        this.FElementClassName = AValue;
        if (this.FContainer != null) this.FContainer.setAttribute("class",AValue);
        this.UpdateElement();
      };
    };
    this.SetColor = function (AValue) {
      this.FColor = AValue;
      this.UpdateElementVisual();
      this.ColorChanging();
    };
    this.SetFont = function (AValue) {
      this.FFont.SetName(AValue.FName);
      this.FFont.SetSize(AValue.FSize);
      this.FFont.SetStyle(rtl.refSet(AValue.FStyle));
      this.FFont.SetColor(AValue.FColor);
    };
    this.SetParent = function (AValue) {
      var isNew = false;
      if (AValue != null) AValue = AValue.CanAcceptChild(this);
      isNew = this.FNew;
      if (this.FParent !== AValue) {
        if (this.FParent != null) this.FParent.UnRegisterParent(this);
        this.FPrevParent = this.FParent;
        this.FParent = AValue;
        this.FGotFocus = false;
        this.UpdateParent();
        if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
          if (!isNew) this.UpdateElement();
          this.InitScript();
        };
        if (this.FParent != null) this.FParent.RegisterParent(this);
        if ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FParent != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FParent.FComponentState)) this.Loaded();
        if ((AValue != null) && (this.FParent != null) && !this.FParent.IsUpdating()) {
          if (this.FAlign !== $mod.TAlign.alNone) {
            this.DoRealign()}
           else this.Realign();
        };
        if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.Invalidate();
      };
    };
    this.RegisterParent = function (AValue) {
      this.FControls = rtl.arraySetLength(this.FControls,null,rtl.length(this.FControls) + 1);
      this.FControls[rtl.length(this.FControls) - 1] = AValue;
    };
    this.UnRegisterParent = function (AValue) {
      var i = 0;
      var flg = false;
      flg = false;
      for (var $l = 0, $end = rtl.length(this.FControls) - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControls[i] === AValue) {
          flg = true;
        };
        if (flg && (i < (rtl.length(this.FControls) - 1))) this.FControls[i] = this.FControls[i + 1];
      };
      if (flg) this.FControls = rtl.arraySetLength(this.FControls,null,rtl.length(this.FControls) - 1);
    };
    this.CanAcceptChild = function (AValue) {
      var Result = null;
      Result = this;
      return Result;
    };
    this.SetLeft = function (AValue) {
      if (this.FLeft !== AValue) {
        this.FLeft = AValue;
        this.ResetAnchoring();
        if (!this.FUpdateTopLeft) this.FOrigLeft = AValue;
        this.UpdateElementSize();
        this.RecreateCanvas();
        this.InternalResize();
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FAlign !== $mod.TAlign.alNone) && (this.FParent != null)) {
          this.DoRealign();
        };
      };
    };
    this.SetTop = function (AValue) {
      if (this.FTop !== AValue) {
        this.FTop = AValue;
        this.ResetAnchoring();
        if (!this.FUpdateTopLeft) this.FOrigTop = AValue;
        this.UpdateElementSize();
        this.RecreateCanvas();
        this.InternalResize();
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FAlign !== $mod.TAlign.alNone) && (this.FParent != null)) {
          this.DoRealign();
        };
      };
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      if (!this.FEnabled) return;
      if (this.FOnMouseUp != null) this.FOnMouseUp(this,Button,rtl.refSet(Shift),X,Y);
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      if (!this.FEnabled) return;
      if (this.FOnMouseDown != null) this.FOnMouseDown(this,Button,rtl.refSet(Shift),X,Y);
    };
    this.MouseMove = function (Shift, X, Y) {
      if (!this.FEnabled) return;
      if (this.FOnMouseMove != null) this.FOnMouseMove(this,rtl.refSet(Shift),X,Y);
    };
    this.TouchStart = function (X, Y) {
      if (this.FOnTouchStart != null) this.FOnTouchStart(this,X,Y);
    };
    this.TouchMove = function (X, Y) {
      if (this.FOnTouchMove != null) this.FOnTouchMove(this,X,Y);
    };
    this.TouchEnd = function (X, Y) {
      if (this.FOnTouchEnd != null) this.FOnTouchEnd(this,X,Y);
    };
    this.TouchCancel = function (X, Y) {
      if (this.FOnTouchCancel != null) this.FOnTouchCancel(this,X,Y);
    };
    this.DoMouseEnter = function () {
      if (this.FOnMouseEnter != null) this.FOnMouseEnter(this);
    };
    this.DoMouseLeave = function () {
      if (this.FOnMouseLeave != null) this.FOnMouseLeave(this);
    };
    this.MouseWheel = function (Shift, WheelDelta, Handled) {
      var IsNeg = false;
      if (this.FOnMouseWheel != null) this.FOnMouseWheel(this,rtl.refSet(Shift),WheelDelta,pas.Types.TPoint.$clone(pas.Types.Point(0,0)),Handled);
      this.FWheelAccumulator += WheelDelta;
      while (Math.abs(this.FWheelAccumulator) >= 120) {
        IsNeg = this.FWheelAccumulator < 0;
        this.FWheelAccumulator = Math.abs(this.FWheelAccumulator) - 120;
        if (IsNeg) {
          if (this.FWheelAccumulator !== 0) this.FWheelAccumulator = -this.FWheelAccumulator;
          this.DoMouseWheelDown(rtl.refSet(Shift),pas.Types.TPoint.$clone(this.FWheelMousePos));
        } else this.DoMouseWheelUp(rtl.refSet(Shift),pas.Types.TPoint.$clone(this.FWheelMousePos));
      };
    };
    this.DoMouseWheelDown = function (Shift, MousePos) {
      var Result = false;
      Result = false;
      if (this.FOnMouseWheelDown != null) this.FOnMouseWheelDown(this,rtl.refSet(Shift),pas.Types.TPoint.$clone(MousePos),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DoMouseWheelUp = function (Shift, MousePos) {
      var Result = false;
      Result = false;
      if (this.FOnMouseWheelUp != null) this.FOnMouseWheelUp(this,rtl.refSet(Shift),pas.Types.TPoint.$clone(MousePos),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DblClick = function () {
      if (this.FOnDblClick != null) this.FOnDblClick(this);
    };
    this.KeyDown = function (Key, Shift) {
      if (this.FOnKeyDown != null) this.FOnKeyDown(this,Key,rtl.refSet(Shift));
    };
    this.KeyPreview = function (Key, Shift) {
      if ((this.FOwner != null) && $mod.TControl.isPrototypeOf(this.FOwner)) {
        rtl.as(this.FOwner,$mod.TControl).KeyPreview(Key,rtl.refSet(Shift));
      };
    };
    this.KeyPress = function (Key) {
      if (this.FOnKeyPress != null) this.FOnKeyPress(this,Key);
    };
    this.KeyUp = function (Key, Shift) {
      if (this.FOnKeyUp != null) this.FOnKeyUp(this,Key,rtl.refSet(Shift));
    };
    this.SetFocus = function () {
      var e = null;
      if (!this.CanFocus()) return;
      if (this.GetElementHandle() != null) {
        e = this.GetElementHandle();
        if (this.FGotFocus) {
          e.focus();
        } else {
          setTimeout(function() {e.focus();}, 1);
        };
      };
    };
    this.DoMarginsChanged = function (Sender) {
      this.DoRealign();
    };
    this.DoCenterChanged = function (Sender) {
      this.DoRealign();
    };
    this.DoRealign = function () {
      if ((this.FParent != null) && !this.FParent.IsUpdating()) {
        this.FParent.AlignControl(this.FParent);
      };
    };
    this.DoBoundsChange = function () {
      var b = false;
      var frm = null;
      this.UpdateElementSize();
      this.RecreateCanvas();
      if (this.FIsResizing) return;
      this.FIsResizing = true;
      this.InternalResize();
      this.DoRealign();
      b = false;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        b = frm.FIsResizing$1;
        b = b || (frm.FUpdateCount > 0);
      };
      b = b || (this.FUpdateCount > 0);
      b = b || this.FIsAligning;
      if (!b) {
        this.UpdateChildAnchoring();
      };
      this.FIsResizing = false;
    };
    this.DoEndDrag = function (Target, X, Y) {
      if (this.FonEndDrag != null) this.FonEndDrag(this,Target,X,Y);
    };
    this.DoStartDrag = function (DragObject) {
      if (this.FOnStartDrag != null) this.FOnStartDrag(this,DragObject);
    };
    this.DragOver = function (Source, X, Y, State, Accept) {
      if (this.FOnDragOver != null) this.FOnDragOver(this,Source,X,Y,State,Accept);
    };
    this.IsFocused = function () {
      var Result = false;
      Result = this.FContainer === document.activeElement;
      return Result;
    };
    this.Focused = function () {
      var Result = false;
      Result = this.FContainer === document.activeElement;
      return Result;
    };
    this.GetID = function () {
      var Result = "";
      Result = this.FID;
      return Result;
    };
    this.GetElementHandle = function () {
      var Result = null;
      Result = null;
      if ((this.FContainer != null) && this.FControlCreated) Result = this.FContainer;
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.GetElementHandle();
      return Result;
    };
    this.GetElement = function () {
      var Result = null;
      Result = document.getElementById(this.GetID());
      return Result;
    };
    this.GetKeyCode = function (AValue, IgnoreCase) {
      var Result = 0;
      var i = 0;
      i = -1;
      var $tmp = AValue;
      if ($tmp === "Up") {
        i = 38}
       else if ($tmp === "Down") {
        i = 40}
       else if ($tmp === "Left") {
        i = 37}
       else if ($tmp === "Right") {
        i = 39}
       else if ($tmp === "!") {
        i = 56}
       else if ($tmp === '"') {
        i = 51}
       else if ($tmp === "#") {
        i = 51}
       else if ($tmp === "$") {
        i = 186}
       else if ($tmp === "%") {
        i = 192}
       else if ($tmp === "'") {
        i = 52}
       else if ($tmp === "(") {
        i = 53}
       else if ($tmp === ")") {
        i = 219}
       else if ($tmp === "*") {
        i = 106}
       else if ($tmp === "+") {
        i = 107}
       else if ($tmp === "-") {
        i = 109}
       else if ($tmp === ",") {
        i = 44}
       else if ($tmp === ".") {
        i = 46}
       else if ($tmp === "/") {
        i = 111}
       else if ($tmp === "\\") {
        i = 226}
       else if ($tmp === "=") {
        i = 187}
       else if ($tmp === "<") {
        i = 226}
       else if ($tmp === ">") {
        i = 226}
       else if ($tmp === pas.Web.TJSKeyNames.BackSpace) {
        i = 8}
       else if ($tmp === pas.Web.TJSKeyNames.Tab) {
        i = 9}
       else if ($tmp === pas.Web.TJSKeyNames.Enter) {
        i = 13}
       else if ($tmp === pas.Web.TJSKeyNames.Shift) {
        i = 16}
       else if ($tmp === pas.Web.TJSKeyNames.Control) {
        i = 17}
       else if ($tmp === pas.Web.TJSKeyNames.Alt) {
        i = 18}
       else if ($tmp === pas.Web.TJSKeyNames.Pause) {
        i = 19}
       else if ($tmp === pas.Web.TJSKeyNames.CapsLock) {
        i = 20}
       else if ($tmp === pas.Web.TJSKeyNames.Escape) {
        i = 27}
       else if ($tmp === pas.Web.TJSKeyNames.PageUp) {
        i = 33}
       else if ($tmp === pas.Web.TJSKeyNames.PageDown) {
        i = 34}
       else if ($tmp === pas.Web.TJSKeyNames._End) {
        i = 35}
       else if ($tmp === pas.Web.TJSKeyNames.Home) {
        i = 36}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowLeft) {
        i = 37}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowUp) {
        i = 38}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowRight) {
        i = 39}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowDown) {
        i = 40}
       else if ($tmp === pas.Web.TJSKeyNames.Insert) {
        i = 45}
       else if ($tmp === pas.Web.TJSKeyNames.Delete) {
        i = 46}
       else if ($tmp === pas.Web.TJSKeyNames.F1) {
        i = 112}
       else if ($tmp === pas.Web.TJSKeyNames.F2) {
        i = 113}
       else if ($tmp === pas.Web.TJSKeyNames.F3) {
        i = 114}
       else if ($tmp === pas.Web.TJSKeyNames.F4) {
        i = 115}
       else if ($tmp === pas.Web.TJSKeyNames.F5) {
        i = 116}
       else if ($tmp === pas.Web.TJSKeyNames.F6) {
        i = 117}
       else if ($tmp === pas.Web.TJSKeyNames.F7) {
        i = 118}
       else if ($tmp === pas.Web.TJSKeyNames.F8) {
        i = 119}
       else if ($tmp === pas.Web.TJSKeyNames.F9) {
        i = 120}
       else if ($tmp === pas.Web.TJSKeyNames.F10) {
        i = 121}
       else if ($tmp === pas.Web.TJSKeyNames.F11) {
        i = 122}
       else if ($tmp === pas.Web.TJSKeyNames.F12) {
        i = 123}
       else if ($tmp === pas.Web.TJSKeyNames.F13) {
        i = 124}
       else if ($tmp === pas.Web.TJSKeyNames.F14) {
        i = 125}
       else if ($tmp === pas.Web.TJSKeyNames.F15) {
        i = 126}
       else if ($tmp === pas.Web.TJSKeyNames.F16) {
        i = 127}
       else if ($tmp === pas.Web.TJSKeyNames.F17) {
        i = 128}
       else if ($tmp === pas.Web.TJSKeyNames.F18) {
        i = 129}
       else if ($tmp === pas.Web.TJSKeyNames.F19) {
        i = 130}
       else if ($tmp === pas.Web.TJSKeyNames.F20) {
        i = 131}
       else {
        if (pas.System.Assigned(AValue) && (AValue.length > 0)) {
          i = AValue.charCodeAt(1 - 1);
          if (IgnoreCase && (i >= 97) && (i <= 122)) {
            i = i & 0xDF}
           else if ((i >= 65) && (i <= 90)) {
            i = i | 0x40}
           else if (i > 122) i = i | 0x80;
        };
      };
      Result = i;
      return Result;
    };
    this.GetKeyChar = function (AValue) {
      var Result = "\x00";
      var i = 0;
      i = -1;
      Result = "\x00";
      var $tmp = AValue;
      if ($tmp === pas.Web.TJSKeyNames.BackSpace) {
        i = 8}
       else if ($tmp === pas.Web.TJSKeyNames.Tab) {
        i = 9}
       else if ($tmp === pas.Web.TJSKeyNames.Enter) {
        i = 13}
       else if ($tmp === pas.Web.TJSKeyNames.Shift) {
        i = 16}
       else if ($tmp === pas.Web.TJSKeyNames.Control) {
        i = 17}
       else if ($tmp === pas.Web.TJSKeyNames.Alt) {
        i = 18}
       else if ($tmp === pas.Web.TJSKeyNames.Pause) {
        i = 19}
       else if ($tmp === pas.Web.TJSKeyNames.CapsLock) {
        i = 20}
       else if ($tmp === pas.Web.TJSKeyNames.Escape) {
        i = 27}
       else if ($tmp === pas.Web.TJSKeyNames.PageUp) {
        i = 33}
       else if ($tmp === pas.Web.TJSKeyNames.PageDown) {
        i = 34}
       else if ($tmp === pas.Web.TJSKeyNames._End) {
        i = 35}
       else if ($tmp === pas.Web.TJSKeyNames.Home) {
        i = 36}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowLeft) {
        i = 37}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowUp) {
        i = 38}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowRight) {
        i = 39}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowDown) {
        i = 40}
       else if ($tmp === pas.Web.TJSKeyNames.Insert) {
        i = 45}
       else if ($tmp === pas.Web.TJSKeyNames.Delete) {
        i = 46}
       else if ($tmp === pas.Web.TJSKeyNames.F1) {
        i = 112}
       else if ($tmp === pas.Web.TJSKeyNames.F2) {
        i = 113}
       else if ($tmp === pas.Web.TJSKeyNames.F3) {
        i = 114}
       else if ($tmp === pas.Web.TJSKeyNames.F4) {
        i = 115}
       else if ($tmp === pas.Web.TJSKeyNames.F5) {
        i = 116}
       else if ($tmp === pas.Web.TJSKeyNames.F6) {
        i = 117}
       else if ($tmp === pas.Web.TJSKeyNames.F7) {
        i = 118}
       else if ($tmp === pas.Web.TJSKeyNames.F8) {
        i = 119}
       else if ($tmp === pas.Web.TJSKeyNames.F9) {
        i = 120}
       else if ($tmp === pas.Web.TJSKeyNames.F10) {
        i = 121}
       else if ($tmp === pas.Web.TJSKeyNames.F11) {
        i = 122}
       else if ($tmp === pas.Web.TJSKeyNames.F12) {
        i = 123}
       else if ($tmp === pas.Web.TJSKeyNames.F13) {
        i = 124}
       else if ($tmp === pas.Web.TJSKeyNames.F14) {
        i = 125}
       else if ($tmp === pas.Web.TJSKeyNames.F15) {
        i = 126}
       else if ($tmp === pas.Web.TJSKeyNames.F16) {
        i = 127}
       else if ($tmp === pas.Web.TJSKeyNames.F17) {
        i = 128}
       else if ($tmp === pas.Web.TJSKeyNames.F18) {
        i = 129}
       else if ($tmp === pas.Web.TJSKeyNames.F19) {
        i = 130}
       else if ($tmp === pas.Web.TJSKeyNames.F20) {
        i = 131}
       else {
        Result = AValue.charAt(0);
      };
      if (i !== -1) Result = String.fromCharCode(i);
      return Result;
    };
    this.IsKeyCharacter = function (AValue) {
      var Result = false;
      var $tmp = AValue;
      if (($tmp === "Up") || ($tmp === "Down") || ($tmp === "Left") || ($tmp === "Right") || ($tmp === pas.Web.TJSKeyNames.Shift) || ($tmp === pas.Web.TJSKeyNames.Control) || ($tmp === pas.Web.TJSKeyNames.Alt) || ($tmp === pas.Web.TJSKeyNames.Pause) || ($tmp === pas.Web.TJSKeyNames.CapsLock) || ($tmp === pas.Web.TJSKeyNames.PageUp) || ($tmp === pas.Web.TJSKeyNames.PageDown) || ($tmp === pas.Web.TJSKeyNames._End) || ($tmp === pas.Web.TJSKeyNames.Home) || ($tmp === pas.Web.TJSKeyNames.ArrowLeft) || ($tmp === pas.Web.TJSKeyNames.ArrowUp) || ($tmp === pas.Web.TJSKeyNames.ArrowRight) || ($tmp === pas.Web.TJSKeyNames.ArrowDown) || ($tmp === pas.Web.TJSKeyNames.Insert) || ($tmp === pas.Web.TJSKeyNames.Delete) || ($tmp === pas.Web.TJSKeyNames.F1) || ($tmp === pas.Web.TJSKeyNames.F2) || ($tmp === pas.Web.TJSKeyNames.F3) || ($tmp === pas.Web.TJSKeyNames.F4) || ($tmp === pas.Web.TJSKeyNames.F5) || ($tmp === pas.Web.TJSKeyNames.F6) || ($tmp === pas.Web.TJSKeyNames.F7) || ($tmp === pas.Web.TJSKeyNames.F8) || ($tmp === pas.Web.TJSKeyNames.F9) || ($tmp === pas.Web.TJSKeyNames.F10) || ($tmp === pas.Web.TJSKeyNames.F11) || ($tmp === pas.Web.TJSKeyNames.F12) || ($tmp === pas.Web.TJSKeyNames.F13) || ($tmp === pas.Web.TJSKeyNames.F14) || ($tmp === pas.Web.TJSKeyNames.F15) || ($tmp === pas.Web.TJSKeyNames.F16) || ($tmp === pas.Web.TJSKeyNames.F17) || ($tmp === pas.Web.TJSKeyNames.F18) || ($tmp === pas.Web.TJSKeyNames.F19) || ($tmp === pas.Web.TJSKeyNames.F20)) {
        Result = false}
       else {
        Result = true;
      };
      return Result;
    };
    this.GetClientRect = function () {
      var Result = pas.Types.TRect.$new();
      var css = "";
      var p = 0;
      var brdr = 0;
      css = pas.SysUtils.UpperCase(this.GetStyle("border-width"));
      brdr = 0;
      p = pas.System.Pos("PX",css);
      if (p > 0) {
        pas.System.Delete({get: function () {
            return css;
          }, set: function (v) {
            css = v;
          }},p,2);
        pas.System.val$6(css,{get: function () {
            return brdr;
          }, set: function (v) {
            brdr = v;
          }},{get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }});
      };
      Result.$assign(pas.Types.Rect(0,0,this.GetWidth() - (2 * brdr),this.GetHeight() - (2 * brdr)));
      return Result;
    };
    this.CreateControl = function () {
      if (!(this.FElement != null)) {
        this.FElement = this.CreateElement();
        if (this.FElement != null) {
          this.FControlCreated = true;
          this.FContainer = this.FElement;
          if (!(this.GetID() === "body")) this.GetContainer().setAttribute("id",this.GetID());
          this.GetContainer().setAttribute("zindex","0");
          if (this.FElementClassName !== "") this.GetContainer().setAttribute("class",this.FElementClassName);
          this.CreateChildElements(this.FElement);
          this.BindEvents();
          this.UpdateElement();
        };
      };
    };
    this.ClearMethodPointers = function () {
      this.FWheelPtr = null;
      this.FClickPtr = null;
      this.FDblClickPtr = null;
      this.FMouseDownPtr = null;
      this.FMouseUpPtr = null;
      this.FMouseMovePtr = null;
      this.FMouseLeavePtr = null;
      this.FMouseEnterPtr = null;
      this.FKeyDownPtr = null;
      this.FKeyUpPtr = null;
      this.FKeyPressPtr = null;
      this.FInputPtr = null;
      this.FEnterPtr = null;
      this.FExitPtr = null;
      this.FTouchStartPtr = null;
      this.FTouchEndPtr = null;
      this.FTouchMovePtr = null;
      this.FTouchCancelPtr = null;
      this.FLayerMouseLeavePtr = null;
      this.FLayerMouseEnterPtr = null;
      this.FScriptLoadedPtr = null;
      this.FContextMenuPtr = null;
    };
    this.GetMethodPointers = function () {
      if (this.FWheelPtr === null) {
        this.FWheelPtr = rtl.createCallback(this,"HandleDoWheel");
        this.FClickPtr = rtl.createCallback(this,"HandleDoClick");
        this.FDblClickPtr = rtl.createCallback(this,"HandleDoDblClick");
        this.FMouseDownPtr = rtl.createCallback(this,"HandleDoMouseDown");
        this.FMouseUpPtr = rtl.createCallback(this,"HandleDoMouseUp");
        this.FMouseMovePtr = rtl.createCallback(this,"HandleDoMouseMove");
        this.FMouseLeavePtr = rtl.createCallback(this,"HandleDoMouseLeave");
        this.FMouseEnterPtr = rtl.createCallback(this,"HandleDoMouseEnter");
        this.FKeyDownPtr = rtl.createCallback(this,"HandleDoKeyDown");
        this.FKeyUpPtr = rtl.createCallback(this,"HandleDoKeyUp");
        this.FKeyPressPtr = rtl.createCallback(this,"HandleDoKeyPress");
        this.FInputPtr = rtl.createCallback(this,"HandleDoInput");
        this.FEnterPtr = rtl.createCallback(this,"HandleDoEnter");
        this.FExitPtr = rtl.createCallback(this,"HandleDoExit");
        this.FTouchStartPtr = rtl.createCallback(this,"HandleDoTouchStart");
        this.FTouchEndPtr = rtl.createCallback(this,"HandleDoTouchEnd");
        this.FTouchMovePtr = rtl.createCallback(this,"HandleDoTouchMove");
        this.FTouchCancelPtr = rtl.createCallback(this,"HandleDoTouchCancel");
        this.FLayerMouseLeavePtr = rtl.createCallback(this,"LayerHandleDoMouseLeave");
        this.FLayerMouseEnterPtr = rtl.createCallback(this,"LayerHandleDoMouseEnter");
        this.FScriptLoadedPtr = rtl.createCallback(this,"RequiredScriptLoaded");
        this.FDragStartPtr = rtl.createCallback(this,"HandleDoDragStart");
        this.FDragOverPtr = rtl.createCallback(this,"HandleDoDragOver");
        this.FDragEnterPtr = rtl.createCallback(this,"HandleDoDragEnter");
        this.FDragLeavePtr = rtl.createCallback(this,"HandledoDragLeave");
        this.FDragEndPtr = rtl.createCallback(this,"HandleDoDragEnd");
        this.FDragDropPtr = rtl.createCallback(this,"HandleDoDragDrop");
        this.FContextMenuPtr = rtl.createCallback(this,"HandleDoContextMenu");
      };
    };
    this.EventsBound = function () {
      var Result = false;
      Result = this.FEventsBound;
      return Result;
    };
    this.BindEvents = function () {
      var eh = null;
      var wp = null;
      if (this.GetElementBindHandle() != null) {
        this.GetMethodPointers();
        this.FEventsBound = true;
        eh = this.GetElementBindHandle();
        wp = this.FWheelPtr;
        eh.addEventListener('wheel', wp, { passive:true});
        eh.addEventListener("click",this.FClickPtr);
        eh.addEventListener("dblclick",this.FDblClickPtr);
        eh.addEventListener("mousedown",this.FMouseDownPtr);
        eh.addEventListener("mouseup",this.FMouseUpPtr);
        eh.addEventListener("mousemove",this.FMouseMovePtr);
        eh.addEventListener("mouseleave",this.FMouseLeavePtr);
        eh.addEventListener("mouseenter",this.FMouseEnterPtr);
        eh.addEventListener("keydown",this.FKeyDownPtr);
        eh.addEventListener("keyup",this.FKeyUpPtr);
        eh.addEventListener("keypress",this.FKeyPressPtr);
        eh.addEventListener("input",this.FInputPtr);
        eh.addEventListener("focus",this.FEnterPtr);
        eh.addEventListener("blur",this.FExitPtr);
        wp = this.FTouchStartPtr;
        eh.addEventListener('touchstart', wp, {passive: true});
        wp = this.FTouchMovePtr;
        eh.addEventListener('touchmove', wp, {passive:true});
        eh.addEventListener("touchend",this.FTouchEndPtr);
        eh.addEventListener("touchcancel",this.FTouchCancelPtr);
        eh.addEventListener("contextmenu",this.FContextMenuPtr);
        eh.addEventListener("dragstart",this.FDragStartPtr);
        eh.addEventListener("dragover",this.FDragOverPtr);
        eh.addEventListener("dragenter",this.FDragEnterPtr);
        eh.addEventListener("dragleave",this.FDragLeavePtr);
        eh.addEventListener("dragend",this.FDragEndPtr);
        eh.addEventListener("drop",this.FDragDropPtr);
      };
    };
    this.UnbindEvents = function () {
      var eh = null;
      this.ReleaseCapture();
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.removeEventListener("wheel",this.FWheelPtr);
        eh.removeEventListener("click",this.FClickPtr);
        eh.removeEventListener("dblclick",this.FDblClickPtr);
        eh.removeEventListener("mousedown",this.FMouseDownPtr);
        eh.removeEventListener("mouseup",this.FMouseUpPtr);
        eh.removeEventListener("mousemove",this.FMouseMovePtr);
        eh.removeEventListener("mouseleave",this.FMouseLeavePtr);
        eh.removeEventListener("mouseenter",this.FMouseEnterPtr);
        eh.removeEventListener("keydown",this.FKeyDownPtr);
        eh.removeEventListener("keyup",this.FKeyUpPtr);
        eh.removeEventListener("keypress",this.FKeyPressPtr);
        eh.removeEventListener("focus",this.FEnterPtr);
        eh.removeEventListener("blur",this.FExitPtr);
        eh.removeEventListener("input",this.FInputPtr);
        eh.removeEventListener("touchstart",this.FTouchStartPtr);
        eh.removeEventListener("touchmove",this.FTouchMovePtr);
        eh.removeEventListener("touchend",this.FTouchEndPtr);
        eh.removeEventListener("touchcancel",this.FTouchEndPtr);
        eh.removeEventListener("contextmenu",this.FContextMenuPtr);
      };
    };
    this.UpdatePadding = function (ARect) {
    };
    this.AlignControls = function (AControl, ARect) {
      var $Self = this;
      var j = 0;
      function DoPosition(Control, AAlign) {
        var dl = 0;
        var dt = 0;
        var dr = 0;
        var db = 0;
        if (!Control.AnchoringInitialized()) $Self.InitAnchoring();
        Control.FUpdateTopLeft = true;
        if (Control.FAlignWithMargins) {
          dl = Control.FMargins.FLeft;
          dt = Control.FMargins.FTop;
          db = Control.FMargins.FBottom;
          dr = Control.FMargins.FRight;
        } else {
          dl = 0;
          dt = 0;
          db = 0;
          dr = 0;
        };
        var $tmp = AAlign;
        if ($tmp === $mod.TAlign.alTop) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Top + dt,ARect.Right - ARect.Left - dl - dr,Control.GetHeight());
          ARect.Top = ARect.Top + Control.GetHeight() + dt + db;
        } else if ($tmp === $mod.TAlign.alBottom) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Bottom - Control.GetHeight() - db - 1,ARect.Right - ARect.Left - dl - dr - 1,Control.GetHeight());
          ARect.Bottom = ARect.Bottom - Control.GetHeight() - dt - db;
        } else if ($tmp === $mod.TAlign.alLeft) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Top + dt,Control.GetWidth(),ARect.Bottom - ARect.Top - dt - db);
          ARect.Left = ARect.Left + Control.GetWidth() + dl + dr;
        } else if ($tmp === $mod.TAlign.alRight) {
          Control.SetBoundsInt(ARect.Right - Control.GetWidth() - dr,ARect.Top + dt,Control.GetWidth(),ARect.Bottom - ARect.Top - db - dt);
          ARect.Right = ARect.Right - Control.GetWidth() - dr - dl;
        } else if ($tmp === $mod.TAlign.alClient) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Top + dt,ARect.Right - ARect.Left - dl - dr,ARect.Bottom - ARect.Top - db - dt);
        } else if ($tmp === $mod.TAlign.alCustom) {
          dl = Control.GetLeft();
          dt = Control.GetTop();
          dr = 0;
          db = 0;
          if (Control.FCenter.FVertical || Control.FCenter.FHorizontal) {
            if (Control.FCenter.FHorizontal) {
              dl = ARect.Left;
              dr = rtl.trunc((ARect.Right - ARect.Left - Control.GetWidth()) / 2);
            };
            if (Control.FCenter.FVertical) {
              dt = ARect.Top;
              db = rtl.trunc((ARect.Bottom - ARect.Top - Control.GetHeight()) / 2);
            };
            Control.SetBoundsInt(dl + dr,dt + db,Control.GetWidth(),Control.GetHeight());
          };
        };
        Control.FUpdateTopLeft = false;
      };
      function DoAlign(AAlign) {
        var i = 0;
        var j = 0;
        var ins = 0;
        var il = null;
        var b = false;
        il = pas.Classes.TList.$create("Create$1");
        for (var $l = 0, $end = $Self.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          b = ($Self.GetControls(i).FCenter.FVertical || $Self.GetControls(i).FCenter.FHorizontal) && (AAlign === $mod.TAlign.alCustom);
          if (b || (($Self.GetControls(i).FAlign === AAlign) && ($Self.GetControls(i).FVisible || (pas.Classes.TComponentStateItem.csDesigning in $Self.FComponentState)))) {
            ins = il.GetCount();
            for (var $l1 = il.GetCount() - 1; $l1 >= 0; $l1--) {
              j = $l1;
              var $tmp = AAlign;
              if ($tmp === $mod.TAlign.alTop) {
                if ($Self.GetControls(i).FOrigTop < rtl.getObject(il.Get(j)).FOrigTop) ins = j}
               else if ($tmp === $mod.TAlign.alLeft) {
                if ($Self.GetControls(i).FOrigLeft < rtl.getObject(il.Get(j)).FOrigLeft) ins = j}
               else if ($tmp === $mod.TAlign.alRight) {
                if (($Self.GetControls(i).FOrigLeft + $Self.GetControls(i).GetWidth()) > (rtl.getObject(il.Get(j)).FOrigLeft + rtl.getObject(il.Get(j)).GetWidth())) ins = j}
               else if ($tmp === $mod.TAlign.alBottom) if (($Self.GetControls(i).FOrigTop + $Self.GetControls(i).GetHeight()) > (rtl.getObject(il.Get(j)).FOrigTop + rtl.getObject(il.Get(j)).GetHeight())) ins = j;
            };
            il.Insert(ins,$Self.GetControls(i));
          };
        };
        for (var $l2 = 0, $end1 = il.GetCount() - 1; $l2 <= $end1; $l2++) {
          i = $l2;
          DoPosition(rtl.getObject(il.Get(i)),AAlign);
        };
        il = rtl.freeLoc(il);
      };
      this.UpdatePadding(ARect);
      DoAlign($mod.TAlign.alTop);
      DoAlign($mod.TAlign.alBottom);
      DoAlign($mod.TAlign.alLeft);
      DoAlign($mod.TAlign.alRight);
      DoAlign($mod.TAlign.alClient);
      DoAlign($mod.TAlign.alCustom);
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        j = $l;
        this.GetControls(j).AlignControl(this.GetControls(j));
      };
    };
    this.AlignControl = function (AControl) {
      var r = pas.Types.TRect.$new();
      var cr = null;
      var ovf = "";
      var ovfx = "";
      var ovfy = "";
      var eh = null;
      var el = null;
      var frm = null;
      var ctop = 0;
      var vscrl = 0;
      var sbw = 0;
      if (this.FIsAligning) return;
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if ((this.FParent != null) && !this.FParent.FVisible) return;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if ((frm != null) && frm.IsUpdating()) return;
      ctop = 0;
      if ((frm != null) && (frm.FFormContainer !== "") && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AControl)) {
        el = document.getElementById(frm.FFormContainer);
        if (el != null) {
          cr = el.getBoundingClientRect();
          ctop = Math.round(cr.top + 1);
        };
      };
      this.FIsAligning = true;
      if (!(AControl != null)) return;
      eh = AControl.GetElementHandle();
      if (eh != null) {
        ovf = AControl.GetElementStyle().getPropertyValue("overflow");
        ovfx = AControl.GetElementStyle().getPropertyValue("overflow-x");
        ovfy = AControl.GetElementStyle().getPropertyValue("overflow-y");
        if (this.FClipChildren && (pas.SysUtils.LowerCase(eh.tagName) !== pas["WEBLib.WebTools"].cBodyTag)) {
          AControl.GetElementStyle().setProperty("overflow","hidden")}
         else AControl.GetElementStyle().setProperty("overflow","");
      };
      r.$assign(this.GetClientRect());
      r.Bottom = r.Bottom - ctop;
      if (this.GetIsLinked()) {
        cr = this.GetElementHandle().getBoundingClientRect();
        r.$assign(pas.Types.Rect(0,0,Math.round(cr.right - cr.left),Math.round(cr.bottom - cr.top)));
      };
      if (((r.Bottom + ctop) > pas["WEBLib.Forms"].WinHeight()) && (this.FHeightStyle !== $mod.TSizeStyle.ssAbsolute) && !(this.FElementPosition === $mod.TElementPosition.epAbsolute) && !this.GetIsLinked() && !(pas["WEBLib.Forms"].VSIDE != null)) {
        if (((this.FParent != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this.FParent)) || pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this)) {
          r.Bottom = pas["WEBLib.Forms"].WinHeight() - ctop;
        };
      };
      if ((eh != null) && (eh.tagName === "BODY")) {
        vscrl = 0;
        if ((document.body.scrollHeight > document.body.clientHeight) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) vscrl = 16;
        if (frm.FFormContainer !== "") {
          r.Bottom = Math.round(Math.min(r.Bottom,pas["WEBLib.Forms"].WinHeight()));
          r.Right = Math.round(Math.min(r.Right - vscrl,pas["WEBLib.Forms"].WinWidth()));
        } else {
          r.Bottom = frm.GetHeight();
          r.Right = frm.GetWidth();
        };
      };
      if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AControl) && !(pas["WEBLib.Forms"].VSIDE != null)) {
        if (r.Bottom > pas["WEBLib.Forms"].WinHeight()) r.Bottom = pas["WEBLib.Forms"].WinHeight();
        if (r.Right > pas["WEBLib.Forms"].WinWidth()) r.Right = pas["WEBLib.Forms"].WinWidth();
      };
      if (AControl.IsStructuralElement()) {
        r.$assign(this.FParent.GetClientRect());
      };
      if ((pas["WEBLib.Forms"].Application.CalcScrollBarWidth() < 16) && !pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AControl)) {
        if ((AControl.FParent != null) && (AControl.GetElementHandle() != null)) {
          if (AControl.GetElementHandle().scrollHeight > AControl.GetElementHandle().clientHeight) {
            sbw = pas["WEBLib.Forms"].Application.CalcScrollBarWidth();
            if (sbw === 0) sbw = 16;
            r.Right = r.Right + (17 - sbw);
          };
        };
      };
      this.AlignControls(AControl,r);
      if (eh != null) {
        AControl.GetElementStyle().setProperty("overflow",ovf);
        AControl.GetElementStyle().setProperty("overflow-x",ovfx);
        AControl.GetElementStyle().setProperty("overflow-y",ovfy);
      };
      this.FIsAligning = false;
    };
    this.InitAnchoring = function () {
      var $Self = this;
      var i = 0;
      var dx = 0;
      var dy = 0;
      function SizeBorderOffset(AObject, ax, ay) {
        var prop = null;
        ax.set(0);
        ay.set(0);
        prop = pas.TypInfo.GetPropInfo(AObject.$class.ClassInfo(),"BorderStyle");
        if (prop != null) {
          i = pas.TypInfo.GetOrdProp$1(AObject,prop);
          if (i in rtl.createSet(1,4,5)) {
            ax.set(4);
            ay.set(4);
          };
          if (i in rtl.createSet(2,3)) {
            ax.set(16);
            ay.set(16);
          };
        };
      };
      if (this.AnchoringInitialized()) return;
      dx = 0;
      dy = 0;
      if (pas["WEBLib.Forms"].TForm.isPrototypeOf($Self)) {
        if (rtl.as($Self,pas["WEBLib.Forms"].TForm).IsMiletus()) SizeBorderOffset($Self,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FOrigRect.$assign(pas.Types.Rect(0,0,this.GetDesignWidth() - dx,this.GetDesignHeight() - dy));
      } else {
        this.FOrigRect.$assign(pas.Types.Rect(this.GetDesignLeft(),this.GetDesignTop(),this.GetDesignLeft() + this.GetDesignWidth(),this.GetDesignTop() + this.GetDesignHeight()));
      };
      if (this.FParent != null) {
        if (pas["WEBLib.Forms"].TForm.isPrototypeOf(this.FParent)) {
          if (rtl.as(this.FParent,pas["WEBLib.Forms"].TForm).IsMiletus()) {
            SizeBorderOffset(this.FParent,{get: function () {
                return dx;
              }, set: function (v) {
                dx = v;
              }},{get: function () {
                return dy;
              }, set: function (v) {
                dy = v;
              }});
          };
          this.FOrigParentRect.$assign(pas.Types.Rect(0,0,this.FParent.GetDesignWidth() - dx,this.FParent.GetDesignHeight() - dy));
        } else {
          if (!this.FParent.AnchoringInitialized()) this.FParent.InitAnchoring();
          this.FOrigParentRect.$assign(pas.Types.Rect(this.FParent.GetDesignLeft(),this.FParent.GetDesignTop(),this.FParent.GetDesignLeft() + this.FParent.GetDesignWidth(),this.FParent.GetDesignTop() + this.FParent.GetDesignHeight()));
        };
      };
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).InitAnchoring();
      };
    };
    this.AnchoringInitialized = function () {
      var Result = false;
      Result = (this.FOrigRect.Left !== -1) || (this.FOrigRect.Top !== -1);
      return Result;
    };
    this.InitScript = function () {
    };
    this.Realign = function () {
      this.AlignControl(this);
    };
    this.Loaded = function () {
      var i = 0;
      var NodeList = null;
      var NodeLen = 0;
      var CurIdx = 0;
      var TargetIdx = 0;
      var RefNode = null;
      var TargetNode = null;
      var C = null;
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      pas.Classes.TComponent.Loaded.call(this);
      if (this.GetChildContainer() != null) {
        NodeList = this.GetChildContainer().childNodes;
        NodeLen = NodeList.length;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          C = this.GetControls(i);
          if (!((C.FElementPosition in rtl.createSet($mod.TElementPosition.epRelative,$mod.TElementPosition.epIgnore)) && !C.GetIsLinked() && (C.FChildOrder >= 0))) {
            C.Loaded();
            continue;
          };
          TargetIdx = C.FChildOrder;
          TargetNode = C.GetContainer();
          if (TargetIdx >= NodeLen) {
            this.GetChildContainer().appendChild(TargetNode);
            C.Loaded();
            continue;
          };
          // Find current index of TargetNode inside NodeList
          CurIdx = Array.prototype.indexOf.call(NodeList, TargetNode);
          // If it moves forward, compensate for the removal
          if (CurIdx !== -1 && TargetIdx > CurIdx) { TargetIdx++; };
          if (CurIdx === -1) ;
          if (TargetIdx < NodeLen) {
            RefNode = NodeList.item(TargetIdx)}
           else RefNode = null;
          if (RefNode != null) {
            this.GetChildContainer().insertBefore(TargetNode,RefNode)}
           else this.GetChildContainer().appendChild(TargetNode);
          C.Loaded();
        };
      } else {
        for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.GetControls(i).Loaded();
        };
      };
      for (var $l2 = 0, $end2 = this.GetComponentCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if (pas.Classes.TComponentStateItem.csLoading in this.GetComponent(i).FComponentState) this.GetComponent(i).Loaded();
      };
      var $tmp = this.FAlign;
      if ($tmp === $mod.TAlign.alClient) {
        if (this.FParent != null) this.SetBoundsInt(0,0,this.FParent.FWidth,this.FParent.FHeight);
      };
      this.Resize();
      this.UpdateElement();
    };
    this.InternalResize = function () {
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      this.Resize();
    };
    this.FontChanged = function () {
      this.UpdateElementVisual();
    };
    this.DisposeOf = function () {
      var t = null;
      t = this;
      t = rtl.freeLoc(t);
    };
    this.ClearChildElements = function () {
      var el = null;
      if (!(this.GetElementHandle() != null)) return;
      while (this.GetElementHandle().childElementCount > 0) {
        el = this.GetElementHandle().firstChild;
        this.GetElementHandle().removeChild(el);
      };
    };
    this.HookElement = function () {
      var el = null;
      var i = 0;
      el = document.getElementById(this.FID);
      this.FContainer = el;
      this.BindElement();
      this.BindEvents();
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).HookElement();
      };
    };
    this.SetElementColor = function (AElement, AColor) {
      var noCSS = false;
      noCSS = !pas["WEBLib.Forms"].Application.FThemed && !(this.FElementClassName !== "");
      if (!this.GetIsLinked()) $mod.SetHTMLElementColor(AElement,AColor,!noCSS);
    };
    this.MoveElements = function (FromElement, ToElement) {
      if (FromElement && ToElement) {
        while (FromElement.childNodes.length) { ToElement.appendChild(FromElement.firstChild); }
      };
    };
    this.MoveElementsAndFree = function (FromElement, ToElement) {
      if (FromElement && ToElement){
        while (FromElement.childNodes.length) { ToElement.appendChild(FromElement.firstChild); }
        FromElement.remove();
      };
    };
    this.CreateWithID = function (AID) {
      var el = null;
      this.ClearMethodPointers();
      this.FUpdateCount = 0;
      this.FControlCreated = false;
      this.FLinkTouchEvents = true;
      this.FIsResizing = false;
      if (((this.FOwner != null) && (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState)) || !(this.FOwner != null)) {
        if (!((this.FOwner != null) && (pas.Classes.TComponentStateItem.csDesigning in this.FOwner.FComponentState))) this.Loading();
      };
      this.FElementPosition = $mod.TElementPosition.epAbsolute;
      this.FWidthStyle = $mod.TSizeStyle.ssAbsolute;
      this.FHeightStyle = $mod.TSizeStyle.ssAbsolute;
      el = document.getElementById(AID);
      this.FNew = !(el != null);
      this.FFont = pas["WEBLib.Graphics"].TFont.$create("Create$1");
      this.FFont.FOnChange = rtl.createCallback(this,"HandleFontChanged");
      if (this.FNew) {
        this.FContainer = null;
      } else {
        this.FContainer = el;
        this.FControlCreated = true;
        this.FElementPosition = $mod.TElementPosition.epRelative;
        this.CreateChildElements(el);
        this.BindElement();
        this.BindEvents();
      };
      this.FID = AID;
      this.FEnabled = true;
      this.FVisible = true;
      this.FLeft = 0;
      this.FTop = 0;
      this.FAlign = $mod.TAlign.alNone;
      this.FAlignWithMargins = false;
      this.FIsAligning = false;
      this.FParentFont = true;
      this.FParentBiDiMode = true;
      this.FParentColor = false;
      this.FAnchors = rtl.createSet($mod.TAnchorKind.akLeft,$mod.TAnchorKind.akTop);
      this.FShowFocus = false;
      this.FBorderWidth = 0;
      this.FEnablePropagation = false;
      this.FToolTip = null;
      this.FColor = 16711422;
      this.FMargins = $mod.TMargins.$create("Create$1");
      this.FMargins.FOnChange = rtl.createCallback(this,"DoMarginsChanged");
      this.FCenter = $mod.TCenter.$create("Create");
      this.FCenter.FOnChange = rtl.createCallback(this,"DoCenterChanged");
      this.FParent = null;
      this.FPrevParent = null;
      if (!($mod.TControlStyleValue.csAcceptsControls in this.FControlStyle)) this.ClearControls();
      this.CreateInitialize();
    };
    this.AddInstanceStyle = function (css) {
      var cssname = "";
      cssname = this.FName + "_style";
      this.$class.AddInstanceStyle$1(cssname,css);
    };
    this.AddInstanceStyle$1 = function (id, css) {
      function writeStylesOnce(styleName, cssText) {
          var styleElement = document.getElementById(styleName);
          if (styleElement) {
            styleElement.innerHTML = cssText;
            return;
            }
          styleElement = document.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          document.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      writeStylesOnce(id,css);
    };
    this.AddControlStyle = function (css) {
      var cssname = "";
      cssname = this.$classname;
      function writeStylesOnce(styleName, cssText) {
          var styleElement = document.getElementById(styleName);
          if (styleElement) {
               styleElement.innerHTML = cssText;
            return;
            }
          styleElement = document.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          document.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      writeStylesOnce(cssname,css);
    };
    this.AddControlLink = function (linkid, link) {
      function writeLinkOnce(linkName, linkText) {
          var linkElement = document.getElementById(linkName);
          if (linkElement)
            return;
          linkElement = document.createElement('link');
          linkElement.id = linkName;
          linkElement.setAttribute('rel', 'stylesheet');
          linkElement.setAttribute('type', 'text/css');
          linkElement.setAttribute('href', linkText);
          document.getElementsByTagName('head')[0].appendChild(linkElement);
      }
      writeLinkOnce(linkid,link);
    };
    this.AddControlScriptLink = function (link) {
      var id = "";
      var script = null;
      id = this.$classname;
      if (!(document.getElementById(id) != null)) {
        script = document.createElement("script");
        script.id = id;
        script.src = link;
        script.type = "text/javascript";
        document.head.appendChild(script);
      };
    };
    this.AddControlScriptSource = function (source) {
      var id = "";
      var script = null;
      id = this.$classname + "SRC";
      if (!(document.getElementById(id) != null)) {
        script = document.createElement("script");
        script.id = id;
        script.innerHTML = source;
        script.type = "text/javascript";
        document.head.appendChild(script);
      };
    };
    this.AddRequiredScripts = function () {
      var Result = false;
      var i = 0;
      var j = 0;
      var el = null;
      var scr = null;
      var found = false;
      var loading = false;
      this.FControlScriptCount = 0;
      for (var $l = 0, $end = this.FRequiredScripts.GetCount() - 1; $l <= $end; $l++) {
        j = $l;
        found = false;
        loading = false;
        for (var $l1 = 0, $end1 = document.head.children.length - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          el = document.head.children.item(i);
          if (el.tagName === "SCRIPT") {
            scr = el;
            if (pas.System.Pos(this.FRequiredScripts.Get(j),scr.src) > 0) {
              found = true;
              if (scr.title === "tmswebloading") {
                loading = true;
                if (!(this.FScriptLoadedPtr != null)) this.FScriptLoadedPtr = rtl.createCallback(this,"RequiredScriptLoaded");
                scr.addEventListener("load",this.FScriptLoadedPtr);
              };
              break;
            };
          };
        };
        if (!found) {
          this.FControlScriptCount += 1;
          this.AddRequiredScript(this.RequiredBaseURL() + this.FRequiredScripts.Get(j));
        };
        if (found && loading) this.FControlScriptCount += 1;
      };
      Result = this.FControlScriptCount > 0;
      return Result;
    };
    this.AddRequiredScript = function (link) {
      var id = "";
      var script = null;
      script = document.createElement("script");
      script.src = link;
      script.type = "text/javascript";
      script.title = "tmswebloading";
      if (!(this.FScriptLoadedPtr != null)) this.FScriptLoadedPtr = rtl.createCallback(this,"RequiredScriptLoaded");
      script.addEventListener("load",this.FScriptLoadedPtr);
      document.head.appendChild(script);
    };
    this.ResetAnchoring = function () {
      this.FOrigRect.$assign(pas.Types.Rect(-1,-1,-1,-1));
      this.InitAnchoring();
    };
    this.UpdateSize = function () {
      var i = 0;
      this.UpdateElementSize();
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).UpdateSize();
      };
    };
    this.UpdateAnchoring = function () {
      var dxr = 0;
      var dyr = 0;
      var dxo = 0;
      var dyo = 0;
      var dxw = 0;
      var dyw = 0;
      var br = pas.Types.TRect.$new();
      var r = pas.Types.TRect.$new();
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if (!this.FControlCreated) return;
      if ((this.FOrigRect.Left === -1) && (this.FOrigRect.Top === -1)) this.InitAnchoring();
      if ((this.FParent != null) && !this.FParent.AnchoringInitialized()) return;
      if (this.FAlign !== $mod.TAlign.alClient) {
        if ((this.FParent != null) && !pas["WEBLib.Forms"].TForm.isPrototypeOf(this)) {
          r.$assign(this.FParent.GetBoundsRect());
          dxr = r.Right - r.Left - (this.FOrigParentRect.Right - this.FOrigParentRect.Left);
          dyr = r.Bottom - r.Top - (this.FOrigParentRect.Bottom - this.FOrigParentRect.Top);
          br.$assign(this.FOrigRect);
          dxo = 0;
          dyo = 0;
          dxw = 0;
          dyw = 0;
          if ($mod.TAnchorKind.akRight in this.FAnchors) {
            if ($mod.TAnchorKind.akLeft in this.FAnchors) {
              dxw = dxr}
             else dxo = dxr;
          };
          if ($mod.TAnchorKind.akBottom in this.FAnchors) {
            if ($mod.TAnchorKind.akTop in this.FAnchors) {
              dyw = dyr}
             else dyo = dyr;
          };
          if (($mod.TAnchorKind.akBottom in this.FAnchors) || ($mod.TAnchorKind.akRight in this.FAnchors)) {
            this.SetBoundsInt(br.Left + dxo,br.Top + dyo,(br.Right - br.Left) + dxw,(br.Bottom - br.Top) + dyw);
          };
        };
      };
      this.UpdateChildAnchoring();
    };
    this.UpdateChildAnchoring = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).UpdateAnchoring();
      };
    };
    this.SetElementPointer = function (AElement, ACursor) {
      if (ACursor !== 0) {
        AElement.style.setProperty("cursor",$mod.GetHTMLCursorName(ACursor))}
       else AElement.style.removeProperty("cursor");
    };
    this.GetWebClassName = function () {
      var Result = "";
      Result = this.$classname;
      pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      Result = "TWeb" + Result;
      return Result;
    };
    this.GetCSSManager = function () {
      var Result = null;
      var frm = null;
      var i = 0;
      Result = null;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        for (var $l = 0, $end = frm.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ($mod.TCSSCodeManager.isPrototypeOf(frm.GetComponent(i))) {
            Result = rtl.as(frm.GetComponent(i),$mod.TCSSCodeManager);
          };
        };
      };
      return Result;
    };
    this.IsUpdating = function () {
      var Result = false;
      Result = this.FUpdateCount > 0;
      return Result;
    };
    this.CanShowFocus = function () {
      var Result = false;
      Result = this.FShowFocus;
      return Result;
    };
    this.RequiredScriptLoaded = function (Event) {
      rtl.asExt(Event.target,HTMLScriptElement).title = "tmswebloaded";
      this.FControlScriptCountLoaded += 1;
    };
    this.InjectCSS = function () {
      var cssname = "";
      var css = "";
      var cssmgr = null;
      cssname = this.GetWebClassName();
      css = "";
      cssmgr = this.GetCSSManager();
      if (cssmgr != null) css = cssmgr.GetClassCSS(cssname);
      if (css !== "") this.AddControlStyle(css);
    };
    this.StartCapture = function () {
      var eh = null;
      if (!this.FCaptureDown) return;
      if (this.Captured()) this.ReleaseCapture();
      this.FMouseInsideLayer = true;
      this.FLayer = document.createElement("SPAN");
      document.body.appendChild(this.FLayer);
      eh = this.FLayer;
      eh.addEventListener("mouseenter",this.FLayerMouseEnterPtr);
      eh.addEventListener("mouseleave",this.FLayerMouseLeavePtr);
      eh.addEventListener("mousedown",this.FMouseDownPtr);
      eh.addEventListener("mouseup",this.FMouseUpPtr);
      eh.addEventListener("mousemove",this.FMouseMovePtr);
      eh.addEventListener("touchstart",this.FTouchStartPtr);
      eh.addEventListener("touchmove",this.FTouchMovePtr);
      eh.addEventListener("touchend",this.FTouchEndPtr);
      eh.addEventListener("touchcancel",this.FTouchCancelPtr);
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","absolute");
      eh.style.setProperty($mod.CSSZIndex,"999999");
      this.FCaptured = true;
      this.UpdateElement();
    };
    this.RequiredBaseURL = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetStyle = function (css) {
      var Result = "";
      var res = "";
      var el = null;
      el = this.GetElementHandle();
      res = "";
      if (!(el != null)) return Result;
      if (window.getComputedStyle) res = getComputedStyle(el, '')[css];
      if(el.currentStyle) res = el.currentStyle[css];
      Result = res;
      return Result;
    };
    this.SetBoundsInt = function (X, Y, AWidth, AHeight) {
      if ((X !== this.GetLeft()) || (Y !== this.GetTop()) || ((AWidth !== this.GetWidth()) && (this.FWidthStyle === $mod.TSizeStyle.ssAbsolute)) || ((AHeight !== this.GetHeight()) && (this.FHeightStyle === $mod.TSizeStyle.ssAbsolute)) || ((this.FParent != null) && this.FParent.GetIsLinked())) {
        this.FBlockUpdateElement = true;
        this.FLeft = X;
        this.FTop = Y;
        this.FWidth = AWidth;
        this.FHeight = AHeight;
        this.FBlockUpdateElement = false;
        this.UpdateElementSize();
        if (this.FAlign !== $mod.TAlign.alNone) {
          this.DoRealign()}
         else this.Realign();
        this.RecreateCanvas();
        this.DoBoundsChange();
        this.Invalidate();
        this.UpdateChildAnchoring();
      };
    };
    this.MoveFirst = function (AControl) {
      var i = 0;
      var fnd = false;
      fnd = false;
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.FControls[i] === AControl) fnd = true;
        if (fnd) {
          if (i > 0) {
            this.FControls[i] = this.FControls[i - 1]}
           else this.FControls[i] = AControl;
        };
      };
    };
    this.MoveLast = function (AControl) {
      var i = 0;
      var fnd = false;
      fnd = false;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControls[i] === AControl) fnd = true;
        if (fnd) {
          if (i < (this.GetControlsCount() - 1)) {
            this.FControls[i] = this.FControls[i + 1]}
           else this.FControls[i] = AControl;
        };
      };
    };
    this.EnableDrag = function () {
      if (this.GetContainer() != null) this.GetContainer().setAttribute("draggable","true");
    };
    this.DisableDrag = function () {
      if ((this.GetContainer() != null) && (this.GetContainer().getAttribute("draggable") === "true")) this.GetContainer().setAttribute("draggable","false");
    };
    this.Create$2 = function (ID) {
      this.FGotFocus = false;
      this.FTabStop = true;
      this.FAllowTouch = true;
      this.CreateWithID(ID);
      return this;
    };
    this.Create$1 = function (AOwner) {
      var lName = "";
      var frm = null;
      var lDesign = false;
      this.FGotFocus = false;
      this.FEventsBound = false;
      this.FTabStop = true;
      this.FAllowTouch = true;
      this.FNoUserSelect = true;
      this.ClearMethodPointers();
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FEventStopPropagation = rtl.createSet($mod.TElementEvent.eeClick,$mod.TElementEvent.eeDblClick,$mod.TElementEvent.eeMouseUp,$mod.TElementEvent.eeMouseMove,$mod.TElementEvent.eeMouseDown,$mod.TElementEvent.eeKeyPress,$mod.TElementEvent.eeKeyDown,$mod.TElementEvent.eeKeyUp,$mod.TElementEvent.eeTouchMove,$mod.TElementEvent.eeTouchStart,$mod.TElementEvent.eeTouchEnd);
      this.FScriptLoaded = false;
      this.FElementFont = $mod.TElementFont.efProperty;
      this.FElementPosition = $mod.TElementPosition.epAbsolute;
      this.FParentElement = null;
      this.FTextDirection = $mod.TTextDirection.tdDefault;
      lDesign = false;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        lDesign = pas.Classes.TComponentStateItem.csDesigning in frm.FComponentState;
      };
      lName = this.GetNewName();
      if (lDesign) {
        this.CreateWithID("")}
       else this.CreateWithID(lName);
      if ((AOwner != null) && !(pas.Classes.TComponentStateItem.csDesigning in AOwner.FComponentState)) this.SetName(lName);
      return this;
    };
    this.Destroy = function () {
      this.UnbindEvents();
      this.DestroyControls();
      if ((this.GetContainer() != null) && (this.FParent != null) && (this.FParent.GetChildContainer() != null)) {
        if (this.FParent.GetChildContainer() === this.GetContainer().parentNode) {
          this.FParent.GetChildContainer().removeChild(this.GetContainer());
        };
        this.FContainer = null;
        this.SetParent(null);
        this.FControlCreated = false;
      };
      rtl.free(this,"FRequiredScripts");
      rtl.free(this,"FMargins");
      rtl.free(this,"FCenter");
      rtl.free(this,"FFont");
      if (pas.System.Assigned(this.FToolTip)) {
        this.FToolTip.dispose();
        this.FToolTip = null;
      };
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Release = function () {
      var $Self = this;
      function Free$1() {
        $Self.$destroy("Destroy");
      };
      window.setTimeout(rtl.createSafeCallback(null,Free$1),150);
    };
    this.Assign = function (Source) {
    };
    this.DragDrop = function (Source, X, Y) {
      if (this.FOnDragDrop != null) this.FOnDragDrop(this,Source,X,Y);
    };
    this.Resize = function () {
      if (this.FOnResize != null) this.FOnResize(this);
    };
    this.Capture = function () {
      this.FCaptureDown = true;
      window.setTimeout(rtl.createSafeCallback(this,"StartCapture"),100);
    };
    this.ApplyName = function () {
      var s = "";
      var prefix = "";
      var frm = null;
      s = this.$classname;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      prefix = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) prefix = frm.$classname;
      this.SetID(prefix + "_" + $mod.FindUniqueName(s));
    };
    this.ReleaseCapture = function () {
      var eh = null;
      this.FCaptureDown = false;
      if (this.FCaptured && (this.FLayer != null)) {
        eh = this.FLayer;
        eh.removeEventListener("mouseenter",this.FLayerMouseEnterPtr);
        eh.removeEventListener("mouseleave",this.FLayerMouseLeavePtr);
        eh.removeEventListener("mousedown",this.FMouseDownPtr);
        eh.removeEventListener("mouseup",this.FMouseUpPtr);
        eh.removeEventListener("mousemove",this.FMouseMovePtr);
        eh.removeEventListener("touchstart",this.FTouchStartPtr);
        eh.removeEventListener("touchmove",this.FTouchMovePtr);
        eh.removeEventListener("touchend",this.FTouchEndPtr);
        eh.removeEventListener("touchcancel",this.FTouchEndPtr);
        document.body.removeChild(eh);
        this.FCaptured = false;
        this.FLayer = null;
        this.UpdateElement();
      };
    };
    this.BringToFront = function () {
      if ((this.GetElementHandle() != null) && (this.GetElementHandle().parentElement != null)) {
        try {
          this.GetElementHandle().parentElement.appendChild(this.GetElementHandle());
          if (this.FParent != null) this.FParent.MoveLast(this);
        } catch ($e) {
        };
      };
    };
    this.SendToBack = function () {
      if ((this.GetElementHandle() != null) && (this.GetElementHandle().parentElement != null)) {
        this.GetElementHandle().parentElement.insertBefore(this.GetElementHandle(),this.GetElementHandle().parentElement.firstElementChild);
        if (this.FParent != null) this.FParent.MoveFirst(this);
      };
    };
    this.Show = function () {
      this.SetVisible(true);
    };
    this.Hide = function () {
      this.SetVisible(false);
    };
    this.PreventDefault = function () {
      if (this.GetElementEvent() != null) this.GetElementEvent().preventDefault();
    };
    this.StopPropagation = function () {
      if ((this.GetElementEvent() != null) && !this.FEnablePropagation) this.GetElementEvent().stopPropagation();
    };
    this.BeginDrag = function () {
      this.EnableDrag();
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      if (this.FUpdateCount > 0) {
        this.FUpdateCount -= 1;
        if (this.FUpdateCount === 0) this.UpdateElement();
      };
    };
    this.Invalidate = function () {
    };
    this.SetParentComponent = function (Value) {
      if ((this.FParent !== Value) && $mod.TControl.isPrototypeOf(Value)) this.SetParent(Value);
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      this.SetBoundsInt(X,Y,AWidth,AHeight);
      this.FWidth = AWidth;
      this.FHeight = AHeight;
      if (!this.FUpdateTopLeft) {
        this.FOrigTop = Y;
        this.FOrigLeft = X;
      };
      this.ResetAnchoring();
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FAlign !== $mod.TAlign.alNone) && (this.FParent != null)) {
        this.DoRealign();
      };
    };
    this.XYToClient = function (X, Y, AClientX, AClientY) {
      var p = null;
      var cr = null;
      var el = null;
      var OrigX = 0.0;
      var OrigY = 0.0;
      var norel = false;
      var formcont = false;
      var r = pas.Types.TRect.$new();
      var cs = null;
      var csx = 0;
      var csy = 0;
      var scrollx = 0;
      var scrolly = 0;
      norel = true;
      formcont = false;
      scrollx = 0;
      scrolly = 0;
      if (this.FElementPosition === $mod.TElementPosition.epAbsolute) {
        scrollx = document.body.scrollLeft + document.documentElement.scrollLeft;
        scrolly = document.body.scrollTop + document.documentElement.scrollTop;
        OrigX = X - this.GetLeft();
        OrigY = Y - this.GetTop();
      } else {
        norel = false;
        cr = this.GetElementHandle().getBoundingClientRect();
        OrigX = X - cr.left;
        OrigY = Y - cr.top;
        AClientX.set(OrigX);
        AClientY.set(OrigY);
        return;
      };
      AClientX.set(OrigX);
      AClientY.set(OrigY);
      p = this.FParent;
      if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this) && !(p != null) && (this.GetContainer() != null)) {
        cr = this.GetContainer().getBoundingClientRect();
        AClientX.set(AClientX.get() - cr.left);
        AClientY.set(AClientY.get() - cr.top);
      };
      while (p != null) {
        if (p.GetIsLinked()) {
          if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
            cr = p.GetContainer().getBoundingClientRect();
          } else {
            cr = p.GetElementHandle().getBoundingClientRect();
          };
          AClientX.set(AClientX.get() - cr.left);
          AClientY.set(AClientY.get() - cr.top);
          AClientX.set(AClientX.get() + p.GetElementHandle().scrollLeft);
          AClientY.set(AClientY.get() + p.GetElementHandle().scrollTop);
          scrollx = 0;
          scrolly = 0;
          break;
        } else if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
          if (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer !== "") {
            el = document.getElementById(rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer);
            if (el != null) {
              formcont = true;
              cr = el.getBoundingClientRect();
              AClientX.set(AClientX.get() - cr.left);
              AClientY.set(AClientY.get() - cr.top);
            };
          };
          if ((rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer() != null) && (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer === "") && rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FPopup) {
            cr = rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer().getBoundingClientRect();
            AClientX.set(AClientX.get() - cr.left);
            AClientY.set(AClientY.get() - cr.top);
            r.$assign(rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetClientRect());
            AClientY.set(AClientY.get() + r.Top);
            scrollx = 0;
            scrolly = 0;
          };
        } else if (p.FElementPosition in rtl.createSet($mod.TElementPosition.epRelative,$mod.TElementPosition.epIgnore)) {
          if (p.GetElementHandle() != null) {
            cr = p.GetElementHandle().getBoundingClientRect();
            AClientX.set(OrigX - cr.left);
            AClientY.set(OrigY - cr.top);
            scrollx = 0;
            scrolly = 0;
            if (norel) {
              cs = window.getComputedStyle(document.documentElement);
              csx = parseInt(cs.marginLeft,10);
              csy = parseInt(cs.marginTop,10);
              AClientX.set(AClientX.get() + csx);
              AClientY.set(AClientY.get() + csy);
            };
            norel = false;
            break;
          };
        } else if ((p.FElementPosition === $mod.TElementPosition.epAbsolute) && norel) {
          AClientX.set(AClientX.get() - p.GetLeft());
          AClientY.set(AClientY.get() - p.GetTop());
          if (p.GetElementHandle() != null) {
            AClientX.set(AClientX.get() + p.GetElementHandle().scrollLeft);
            AClientY.set(AClientY.get() + p.GetElementHandle().scrollTop);
          };
          OrigX = AClientX.get();
          OrigY = AClientY.get();
        };
        p = p.FParent;
      };
      if ((this.FElementPosition === $mod.TElementPosition.epAbsolute) && !formcont) {
        AClientX.set(AClientX.get() + scrollx);
        AClientY.set(AClientY.get() + scrolly);
      };
    };
    this.ClientToXY = function (AClientX, AClientY, X, Y) {
      var p = null;
      var cr = null;
      X.set((AClientX + this.GetLeft()) - document.body.scrollLeft - document.documentElement.scrollLeft);
      Y.set((AClientY + this.GetTop()) - document.body.scrollTop - document.documentElement.scrollTop);
      p = this.FParent;
      while (p != null) {
        if (p.GetIsLinked()) {
          if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
            cr = p.GetContainer().getBoundingClientRect()}
           else cr = p.GetElementHandle().getBoundingClientRect();
          X.set(X.get() + cr.left);
          Y.set(Y.get() + cr.top);
        };
        if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
          if ((rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer() != null) && (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer === "") && (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormFileName !== "") && rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FPopup) {
            cr = rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer().getBoundingClientRect();
            X.set(X.get() + cr.left);
            Y.set(Y.get() + cr.top);
          };
        };
        if (p.FElementPosition === $mod.TElementPosition.epAbsolute) {
          X.set(X.get() + p.GetLeft());
          Y.set(Y.get() + p.GetTop());
        };
        p = p.FParent;
      };
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      var Control = null;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        Control = this.GetControls(I);
        if ((Control.FOwner === Root) || (Root === null)) Proc(Control);
      };
    };
    this.Captured = function () {
      var Result = false;
      Result = this.FCaptured && (this.FLayer != null);
      return Result;
    };
    this.MakeScreenshot = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.ClientToScreen = function (Point) {
      var Result = pas.Types.TPoint.$new();
      var Origin = pas.Types.TPoint.$new();
      Origin.$assign(this.GetClientOrigin());
      Result.x = Point.x + Origin.x;
      Result.y = Point.y + Origin.y;
      return Result;
    };
    this.ScreenToClient = function (Point) {
      var Result = pas.Types.TPoint.$new();
      var Origin = pas.Types.TPoint.$new();
      Origin.$assign(this.GetClientOrigin());
      Result.x = Point.x - Origin.x;
      Result.y = Point.y - Origin.y;
      return Result;
    };
    this.CanFocus = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.HasHorzScrollBar = function () {
      var Result = false;
      Result = false;
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().clientWidth < this.GetElementHandle().scrollWidth;
      return Result;
    };
    this.HasVertScrollBar = function () {
      var Result = false;
      Result = false;
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().clientHeight < this.GetElementHandle().scrollHeight;
      return Result;
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TControl.FControls$a",{eltype: $r});
  });
  this.TScrollBarKind = {"0": "sbHorizontal", sbHorizontal: 0, "1": "sbVertical", sbVertical: 1};
  this.$rtti.$Enum("TScrollBarKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TScrollBarKind});
  rtl.createClass(this,"TControlScrollBar",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FKind = 0;
      this.FControl = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function (AControl, AKind) {
      this.FControl = AControl;
      this.FKind = AKind;
      return this;
    };
    this.IsScrollBarVisible = function () {
      var Result = false;
      Result = false;
      if (this.FControl.GetElementHandle() != null) {
        if (this.FKind === $mod.TScrollBarKind.sbVertical) {
          Result = this.FControl.GetElementHandle().scrollHeight > this.FControl.GetElementHandle().clientHeight}
         else Result = this.FControl.GetElementHandle().scrollWidth > this.FControl.GetElementHandle().clientWidth;
      };
      return Result;
    };
    this.ScrollPos = function () {
      var Result = 0;
      Result = 0;
      if (this.FControl.GetElementHandle() != null) {
        if (this.FKind === $mod.TScrollBarKind.sbVertical) {
          Result = this.FControl.GetElementHandle().scrollTop}
         else Result = this.FControl.GetElementHandle().scrollLeft;
      };
      return Result;
    };
    this.Range = function () {
      var Result = 0;
      Result = 0;
      if (this.FControl.GetElementHandle() != null) {
        if (this.FKind === $mod.TScrollBarKind.sbVertical) {
          Result = this.FControl.GetElementHandle().scrollHeight}
         else Result = this.FControl.GetElementHandle().scrollWidth;
      };
      return Result;
    };
  });
  this.$rtti.$Class("TWinControl");
  this.$rtti.$ClassRef("TWinControlClass",{instancetype: this.$rtti["TWinControl"]});
  rtl.createClass(this,"TWinControl",this.TControl,function () {
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Cursor",2,$mod.$rtti["TCursor"],"FCursor","SetControlCursor",4,{Default: 0});
    $r.addProperty("ElementClassName",2,$mod.$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("Tag",0,rtl.longint,"FTag$1","FTag$1",4,{Default: 0});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("OnMouseDown",0,$mod.$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,$mod.$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,$mod.$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseEnter",0,$mod.$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseLeave",0,$mod.$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnKeyUp",0,$mod.$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnKeyDown",0,$mod.$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,$mod.$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnEnter",0,$mod.$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,$mod.$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  this.$rtti.$Class("TCustomControl");
  this.$rtti.$ClassRef("TCustomControlClass",{instancetype: this.$rtti["TCustomControl"]});
  rtl.createClass(this,"TCustomControl",this.TWinControl,function () {
    this.$init = function () {
      $mod.TWinControl.$init.call(this);
      this.FCaption = "";
      this.FPixelRatio = 0.0;
      this.FPainting = false;
      this.FCanvas = null;
      this.FElementCanvas = null;
      this.FBorderStyle = 0;
      this.FBorderColor = 0;
      this.FCustomBorder = false;
      this.FOnScreenShot = null;
      this.FBevelOuter = 0;
      this.FBevelWidth = 0;
      this.FBevelCut = 0;
      this.FBevelEdges = {};
      this.FBevelKind = 0;
    };
    this.$final = function () {
      this.FCanvas = undefined;
      this.FElementCanvas = undefined;
      this.FOnScreenShot = undefined;
      this.FBevelEdges = undefined;
      $mod.TWinControl.$final.call(this);
    };
    this.GetCanvas = function () {
      var Result = null;
      if (!(this.FCanvas != null)) {
        if (!this.GetIsLinked()) {
          this.CreateControl()}
         else {
          if (!(this.FElementCanvas != null)) this.FElementCanvas = document.getElementById(this.GetID());
          this.RecreateCanvas();
        };
      };
      Result = this.FCanvas;
      return Result;
    };
    this.RenderDesigning = function (ACaption, AElement, AControl, ADisplay, AImage) {
      var LContainer = null;
      var LLabel = null;
      var LDiv = null;
      var LHasLabel = false;
      LContainer = AElement;
      LLabel = LContainer.firstChild;
      LHasLabel = (LLabel != null) && (LLabel.tagName === "DIV") && (LLabel.getAttribute("data-design") === "1");
      if ((pas.Classes.TComponentStateItem.csDesigning in AControl.FComponentState) && ADisplay && (this.FElementClassName === "")) {
        LContainer.style.setProperty("border","1px solid gray");
        if (AImage === "") {
          LContainer.style.setProperty("background-color","#F0F0F0")}
         else LContainer.style.setProperty("background-color","white");
        if (LHasLabel) return;
        LContainer.innerHTML = "";
        if (AImage !== "") {
          LDiv = document.createElement("DIV");
          LDiv.style.setProperty("background-color","white");
          LDiv.style.setProperty("background-repeat","no-repeat");
          LDiv.style.setProperty("background-position-y","center");
          LDiv.style.setProperty("background-image","url(" + AImage + ")");
          LDiv.style.setProperty("background-position-x","center");
          LDiv.style.setProperty("background-size","128px");
          LDiv.style.setProperty("top","50%");
          LDiv.style.setProperty("left","50%");
          LDiv.style.setProperty("height","70%");
          LContainer.appendChild(LDiv);
        };
        LLabel = document.createElement("DIV");
        LLabel.setAttribute("data-design","1");
        LLabel.innerHTML = ACaption;
        LLabel.style.setProperty("position","relative");
        LLabel.style.setProperty("top","50%");
        LLabel.style.setProperty("left","50%");
        LLabel.style.setProperty("display","inline-block");
        LLabel.style.setProperty("transform","translateX(-50%)");
        this.FCustomBorder = true;
        LContainer.appendChild(LLabel);
      } else {
        if (LHasLabel) {
          while (LContainer.firstChild != null) LContainer.removeChild(LContainer.firstChild);
          LContainer.style.removeProperty("border");
          LContainer.style.removeProperty("background-color");
        };
      };
    };
    this.GetPixelRatio = function () {
      var Result = 0.0;
      var res = 0.0;
      var ctx = document.createElement("canvas").getContext("2d"),
          dpr = window.devicePixelRatio || 1,
          bsr = ctx.webkitBackingStorePixelRatio ||
                ctx.mozBackingStorePixelRatio ||
                ctx.msBackingStorePixelRatio ||
                ctx.oBackingStorePixelRatio ||
                ctx.backingStorePixelRatio || 1;
      res = dpr / bsr;
      Result = res;
      return Result;
    };
    this.GetContext = function () {
      var Result = null;
      var ctx = null;
      ctx = this.FElementCanvas.getContext("2d");
      Result = ctx;
      return Result;
    };
    this.RecreateCanvas = function () {
      var px = 0.0;
      var el = null;
      var h = 0;
      var w = 0;
      if (this.FElementCanvas != null) {
        if (!this.FPainting) {
          if (this.GetIsLinked()) {
            el = this.GetElementHandle();
          } else el = document.getElementById(this.GetID() + "_Canvas");
          if (el != null) {
            this.FElementCanvas = el;
            rtl.free(this,"FCanvas");
            this.FCanvas = null;
          };
          px = this.GetPixelRatio();
          h = Math.min(16383,this.GetHeight() - this.GetCanvasHeightOffset());
          w = Math.min(16383,this.GetWidth() - this.GetCanvasWidthOffset());
          if (this.FElementPosition === $mod.TElementPosition.epRelative) {
            this.FElementCanvas.style.setProperty("position","relative")}
           else this.FElementCanvas.style.setProperty("position","absolute");
          this.FElementCanvas.style.setProperty("height",pas.SysUtils.IntToStr(h) + "px");
          this.FElementCanvas.style.setProperty("width",pas.SysUtils.IntToStr(w) + "px");
          this.FElementCanvas.height = Math.round(h * px);
          this.FElementCanvas.width = Math.round(w * px);
        };
        if (!(this.FCanvas != null)) {
          this.FCanvas = pas["WEBLib.Graphics"].TCanvas.$create("Create$1",[this.FElementCanvas]);
        };
        this.FCanvas.FApplyPixelRatio = true;
        this.FCanvas.SetTransform(1,0,0,1,0,0);
      };
    };
    this.SetBorderStyle = function (AValue) {
      if (this.FBorderStyle !== AValue) {
        this.FBorderStyle = AValue;
        this.UpdateElement();
      };
    };
    this.SetBorderColor = function (AValue) {
      if (this.FBorderColor !== AValue) {
        this.FBorderColor = AValue;
        this.UpdateElement();
      };
    };
    this.SetName = function (NewName) {
      var cs = {};
      var ownername = "";
      ownername = "";
      if (!((pas["WEBLib.Forms"].VSIDE != null) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState))) {
        if (pas["WEBLib.Forms"].TFrame.isPrototypeOf(this)) {
          ownername = "F" + $mod.FindUniqueName(this.FName) + "_";
        };
      };
      pas.Classes.TComponent.SetName.call(this,ownername + NewName);
      if (($mod.TControlStyleValue.csSetCaption in this.FControlStyle) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if ((this.FOwner != null) && (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState)) return;
        cs = rtl.refSet(this.FControlStyle);
        this.SetCaption(NewName);
        this.FControlStyle = rtl.refSet(cs);
      };
    };
    this.SetCaption = function (AValue) {
      this.FCaption = AValue;
      this.FControlStyle = rtl.diffSet(this.FControlStyle,rtl.createSet($mod.TControlStyleValue.csSetCaption));
    };
    this.CreateControl = function () {
      $mod.TControl.CreateControl.call(this);
      this.RecreateCanvas();
    };
    this.Loaded = function () {
      $mod.TControl.Loaded.call(this);
      this.Invalidate();
    };
    this.UpdateElementVisual = function () {
      $mod.TControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (!this.GetIsLinked() && (this.FElementClassName === "")) {
          if (this.FBorderStyle === $mod.TBorderStyle.bsSingle) {
            if (this.FCustomBorder) {
              this.GetElementStyle().setProperty("border-style","solid");
              this.GetElementStyle().setProperty("border-width","1px");
              this.GetElementStyle().setProperty("border-color",pas["WEBLib.Graphics"].ColorToHTML(this.FBorderColor));
            } else this.GetElementStyle().setProperty("border-style","");
          } else {
            this.GetElementStyle().setProperty("border-style","none");
          };
        };
        if (this.FElementClassName !== "") {
          this.GetElementStyle().removeProperty("border-style");
          this.GetElementStyle().removeProperty("border-width");
          this.GetElementStyle().removeProperty("border-color");
        };
      };
    };
    this.CreateElement = function () {
      var Result = null;
      this.FElementCanvas = document.createElement("CANVAS");
      if ($mod.TControlStyleValue.csAcceptsControls in this.FControlStyle) {
        Result = document.createElement("SPAN");
        Result.appendChild(this.FElementCanvas);
        if (this.GetID() !== "") this.FElementCanvas.setAttribute("id",this.GetID() + "_Canvas");
        this.FElementCanvas.setAttribute("zindex","-1");
      } else Result = this.FElementCanvas;
      return Result;
    };
    this.GetCanvasHeightOffset = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetCanvasWidthOffset = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.BindElement = function () {
      if ((this.GetContainer().tagName !== "CANVAS") && !this.FControlCreated) {
        this.FElementCanvas = document.createElement("CANVAS");
        this.GetContainer().appendChild(this.FElementCanvas);
      };
    };
    this.BindEvents = function () {
      $mod.TControl.BindEvents.call(this);
    };
    this.HandleScreenShot = function (Sender) {
      if (this.FOnScreenShot != null) this.FOnScreenShot(this,Sender);
    };
    this.Paint = function () {
    };
    this.CreateInitialize = function () {
      $mod.TControl.CreateInitialize.call(this);
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet($mod.TControlStyleValue.csSetCaption));
      this.FBorderStyle = $mod.TBorderStyle.bsSingle;
      this.FBorderColor = 12632256;
      this.FPainting = false;
      this.FWidth = 100;
      this.FHeight = 25;
      this.FWidthPercent = 100;
      this.FHeightPercent = 100;
      this.FCustomBorder = false;
    };
    this.Destroy = function () {
      if (this.FCanvas != null) rtl.free(this,"FCanvas");
      $mod.TControl.Destroy.call(this);
    };
    this.MakeScreenshot = function () {
      var Result = null;
      Result = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      Result.FOnChange = rtl.createCallback(this,"HandleScreenShot");
      Result.LoadFromCanvas(this.GetCanvas());
      return Result;
    };
    this.Resize = function () {
      $mod.TControl.Resize.call(this);
      this.Invalidate();
    };
    this.Invalidate = function () {
      var px = 0.0;
      var frm = null;
      $mod.TControl.Invalidate.call(this);
      if ((this.FParent === null) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if (!this.FVisible) return;
      if (this.FUpdateCount > 0) return;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) if (frm.IsUpdating()) return;
      px = this.GetPixelRatio();
      if (px !== this.FPixelRatio) this.RecreateCanvas();
      this.FPixelRatio = this.GetPixelRatio();
      this.FPainting = true;
      if (this.FCanvas != null) this.FCanvas.Clear();
      this.Paint();
      this.FPainting = false;
    };
    this.SetFocus = function () {
      $mod.TControl.SetFocus.call(this);
    };
    this.Focused = function () {
      var Result = false;
      Result = $mod.TControl.Focused.call(this);
      return Result;
    };
    this.EndUpdate = function () {
      $mod.TControl.EndUpdate.call(this);
      if (this.FUpdateCount === 0) this.Invalidate();
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TjQueryCustomControl",this.TWinControl,function () {
    this.$init = function () {
      $mod.TWinControl.$init.call(this);
      this.FIsInitialized = false;
    };
    this.InitJQueryOnce = function () {
      if (this.IsUpdating()) return;
      if (this.FIsInitialized) return;
      this.FIsInitialized = true;
      this.InitJQuery();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.Loaded = function () {
      $mod.TControl.Loaded.call(this);
      this.InitJQueryOnce();
    };
    this.SetParent = function (AValue) {
      $mod.TControl.SetParent.apply(this,arguments);
      this.InitJQueryOnce();
    };
    this.GetJQID = function () {
      var Result = "";
      Result = "#" + this.GetID();
      return Result;
    };
    this.InitJQuery = function () {
    };
    this.CreateInitialize = function () {
      $mod.TControl.CreateInitialize.call(this);
      this.FIsInitialized = false;
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("ElementPosition",2,$mod.$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: $mod.TElementPosition.epAbsolute});
  });
  rtl.createClass(this,"TGraphicControl",this.TCustomControl,function () {
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollingGraphicControl",this.TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      $mod.TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) this.GetElementHandle().style.setProperty("overflow","auto");
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomHTMLDiv",this.TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TControlManager",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FInstanceCount = 0;
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FInstanceCount = 0;
      return this;
    };
    this.GetInstanceNumber = function () {
      var Result = 0;
      this.FInstanceCount += 1;
      Result = this.FInstanceCount;
      return Result;
    };
    this.Reset = function () {
      this.FInstanceCount = 0;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCSSCodeFragment",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FControlClassname = "";
      this.FCSS = null;
    };
    this.$final = function () {
      this.FCSS = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetCSS = function (Value) {
      this.FCSS.Assign(Value);
    };
    this.Create$1 = function (Collection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FCSS = pas.Classes.TStringList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCSS");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("ControlClassname",0,rtl.string,"FControlClassname","FControlClassname");
    $r.addProperty("CSS",2,pas.Classes.$rtti["TStringList"],"FCSS","SetCSS");
  });
  rtl.createClass(this,"TCSSCodeFragments",pas.Classes.TOwnedCollection,function () {
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TCSSCodeFragment);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  rtl.createClass(this,"TCSSCodeManager",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FCSSFragments = null;
    };
    this.$final = function () {
      this.FCSSFragments = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetCSSFragments = function (Value) {
      this.FCSSFragments.Assign(Value);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FCSSFragments = $mod.TCSSCodeFragments.$create("Create$3",[this]);
      this.FCSSFragments.FPropName = "CSSFragments";
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCSSFragments");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.GetClassFragment = function (AClassname) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.FCSSFragments.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FCSSFragments.GetItemEx(i).FControlClassname === AClassname) Result = this.FCSSFragments.GetItemEx(i);
      };
      return Result;
    };
    this.GetClassCSS = function (AClassname) {
      var Result = "";
      var CSSCodeFragment = null;
      Result = "";
      CSSCodeFragment = this.GetClassFragment(AClassname);
      if (CSSCodeFragment != null) Result = CSSCodeFragment.FCSS.GetTextStr();
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("CSSFragments",2,$mod.$rtti["TCSSCodeFragments"],"FCSSFragments","SetCSSFragments");
  });
  rtl.createInterface(this,"ITMSFNCDataBinderBase","{778B63C9-34E3-4B65-A6B8-85E3EB1D17C3}",["DataBeginUpdate","DataEndUpdate"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("DataBeginUpdate",0,[]);
    $r.addMethod("DataEndUpdate",0,[]);
  });
  rtl.createInterface(this,"ITMSFNCDataBinderGrid","{D23BDEAA-49B1-451A-9401-0D0D11A9957A}",["SetDataColumnCount","SetDataRowCount","ClearData","GetDataRowCount","SetDataValue","SetDataHeader","DataInsertRow"],this.ITMSFNCDataBinderBase,function () {
    var $r = this.$rtti;
    $r.addMethod("SetDataColumnCount",0,[["AValue",rtl.longint]]);
    $r.addMethod("SetDataRowCount",0,[["AValue",rtl.longint]]);
    $r.addMethod("ClearData",0,[]);
    $r.addMethod("GetDataRowCount",1,[],2,rtl.longint);
    $r.addMethod("SetDataValue",0,[["AColumn",rtl.longint],["ARow",rtl.longint],["AValue",rtl.string]]);
    $r.addMethod("SetDataHeader",0,[["AColumn",rtl.longint],["AValue",rtl.string]]);
    $r.addMethod("DataInsertRow",0,[["AInsertPosition",rtl.longint]]);
  });
  rtl.createHelper(this,"TStringListHelper",null,function () {
    this.LoadFromJSONArray = function (ja) {
      var jsa = null;
      var i = 0;
      jsa = JSON.parse(ja);
      for (var $l = 0, $end = jsa.length - 1; $l <= $end; $l++) {
        i = $l;
        this.Add("" + jsa[i]);
      };
    };
    this.LoadFromJSONArrayURL = function (URL) {
      var $Self = this;
      var Result = null;
      var req = null;
      function ResultHandler(response) {
        var jsa = null;
        var i = 0;
        jsa = JSON.parse(response);
        for (var $l = 0, $end = jsa.length - 1; $l <= $end; $l++) {
          i = $l;
          $Self.Add("" + jsa[i]);
        };
      };
      Result = new Promise(function (ASuccess, AFailed) {
        req = new XMLHttpRequest();
        req.open("GET",URL);
        req.onload = function() {
                  if (req.status != 200) {
                    AFailed(false); }
                  else {
        
                    ResultHandler(req.response);
                    ASuccess(true);
                  }
                };
        req.send();
      });
      return Result;
    };
  });
  this.FindGlobalComponent = function (Name) {
    var Result = null;
    Result = null;
    return Result;
  };
  this.GetMousePos = function () {
    var Result = pas.Types.TPoint.$new();
    Result.$assign(pas.Types.Point($impl.FMouseX,$impl.FMouseY));
    return Result;
  };
  this.GetCursorPos = function (pt) {
    pt.x = $impl.FCursorX;
    pt.y = $impl.FCursorY;
  };
  this.FindUniqueName = function (Name) {
    var Result = "";
    Result = Name + pas.SysUtils.IntToStr($impl.ControlManager.GetInstanceNumber());
    return Result;
  };
  this.GetScrollBarHeight = function () {
    var Result = 0;
    var res = 0;
    res = $impl.ScrollBH;
    if (res === 0) {
      var outer = document.createElement("div");
            outer.style.visibility = "hidden";
            outer.style.height = "100px";
            outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
      
            document.body.appendChild(outer);
      
            var HeightNoScroll = outer.offsetHeight;
            // force scrollbars
            outer.style.overflow = "scroll";
      
            // add innerdiv
            var inner = document.createElement("div");
            inner.style.height = "100%";
            outer.appendChild(inner);
      
            var HeightWithScroll = inner.offsetHeight;
      
            // remove divs
            outer.parentNode.removeChild(outer);
      
            res = HeightNoScroll - HeightWithScroll;
      
            //res = 0;
      $impl.ScrollBH = res;
    };
    Result = res;
    return Result;
  };
  this.GetScrollBarWidth = function () {
    var Result = 0;
    var res = 0;
    res = $impl.ScrollBW;
    if (res === 0) {
      var outer = document.createElement("div");
            outer.style.visibility = "hidden";
            outer.style.width = "100px";
            outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
      
            document.body.appendChild(outer);
      
            var widthNoScroll = outer.offsetWidth;
            // force scrollbars
            outer.style.overflow = "scroll";
      
            // add innerdiv
            var inner = document.createElement("div");
            inner.style.width = "100%";
            outer.appendChild(inner);
      
            var widthWithScroll = inner.offsetWidth;
      
            // remove divs
            outer.parentNode.removeChild(outer);
      
            res = widthNoScroll - widthWithScroll;
      $impl.ScrollBW = res;
    };
    Result = res;
    return Result;
  };
  this.SetHTMLElementFont = function (AElement, AFont, UseCSS) {
    var s = "";
    if (UseCSS) {
      AElement.style.removeProperty("font-family");
      AElement.style.removeProperty("font-style");
      AElement.style.removeProperty("font-weight");
      AElement.style.removeProperty("font-size");
      AElement.style.removeProperty("text-decoration");
    } else {
      AElement.style.setProperty("font-family",AFont.FName);
      AElement.style.setProperty("font-style","normal");
      if (pas["WEBLib.Graphics"].TFontStyle.fsBold in AFont.FStyle) {
        AElement.style.setProperty("font-weight","bold")}
       else AElement.style.setProperty("font-weight","");
      if (pas["WEBLib.Graphics"].TFontStyle.fsItalic in AFont.FStyle) AElement.style.setProperty("font-style","italic");
      s = "";
      if (pas["WEBLib.Graphics"].TFontStyle.fsUnderline in AFont.FStyle) s = "underline";
      if (pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in AFont.FStyle) {
        if (s !== "") s = s + " ";
        s = s + "line-through";
      };
      if (s !== "") {
        AElement.style.setProperty("text-decoration",s)}
       else AElement.style.removeProperty("text-decoration");
      if (AFont.FSize !== 0) AElement.style.setProperty("font-size",pas.SysUtils.IntToStr(AFont.FSize) + "pt");
    };
  };
  this.SetHTMLElementColor = function (AElement, AColor, UseCSS) {
    if (UseCSS || (AColor === -1) || (AColor === 16711422)) {
      AElement.style.removeProperty($impl.cStyleBkgColor)}
     else AElement.style.setProperty($impl.cStyleBkgColor,pas["WEBLib.Graphics"].ColorToHTML(AColor));
  };
  this.GetHTMLCursorName = function (ACursor) {
    var Result = "";
    Result = "default";
    var $tmp = ACursor;
    if ($tmp === 0) {
      Result = "default"}
     else if ($tmp === 2) {
      Result = "auto"}
     else if ($tmp === 1) {
      Result = "none"}
     else if ($tmp === 3) {
      Result = "crosshair"}
     else if ($tmp === 4) {
      Result = "text"}
     else if ($tmp === 6) {
      Result = "nesw-resize"}
     else if ($tmp === 7) {
      Result = "ns-resize"}
     else if ($tmp === 8) {
      Result = "nwse-resize"}
     else if ($tmp === 9) {
      Result = "ew-resize"}
     else if ($tmp === 10) {
      Result = "n-resize"}
     else if ($tmp === 11) {
      Result = "wait"}
     else if ($tmp === 12) {
      Result = "copy"}
     else if ($tmp === 13) {
      Result = "no-drop"}
     else if ($tmp === 14) {
      Result = "col-resize"}
     else if ($tmp === 15) {
      Result = "row-resize"}
     else if ($tmp === 16) {
      Result = "copy"}
     else if ($tmp === 17) {
      Result = "progress"}
     else if ($tmp === 18) {
      Result = "not-allowed"}
     else if ($tmp === 19) {
      Result = "progress"}
     else if ($tmp === 20) {
      Result = "help"}
     else if ($tmp === 21) {
      Result = "pointer"}
     else if (($tmp === 22) || ($tmp === 5)) Result = "move";
    return Result;
  };
  this.GetHTMLElementAbsoluteRect = function (AElement) {
    var Result = pas.Types.TRect.$new();
    var s = "";
    function GetInt(AValue) {
      var Result = 0;
      var e = 0;
      AValue = pas.SysUtils.StringReplace(AValue,"px","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      pas.System.val$6(AValue,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      return Result;
    };
    s = AElement.style.getPropertyValue("left");
    Result.Left = GetInt(s);
    s = AElement.style.getPropertyValue("top");
    Result.Top = GetInt(s);
    s = AElement.style.getPropertyValue("width");
    Result.Right = Result.Left + GetInt(s);
    s = AElement.style.getPropertyValue("height");
    Result.Bottom = Result.Top + GetInt(s);
    return Result;
  };
  this.CursorToString = function (ACursor) {
    var Result = "";
    Result = "crDefault";
    var $tmp = ACursor;
    if ($tmp === 0) {
      Result = "crDefault"}
     else if ($tmp === 2) {
      Result = "crArrow"}
     else if ($tmp === 1) {
      Result = "crNone"}
     else if ($tmp === 3) {
      Result = "crCross"}
     else if ($tmp === 5) {
      Result = "ctSize"}
     else if ($tmp === 4) {
      Result = "crIBeam"}
     else if ($tmp === 6) {
      Result = "crSizeNESW"}
     else if ($tmp === 7) {
      Result = "crSizeNS"}
     else if ($tmp === 8) {
      Result = "crSizeNWSE"}
     else if ($tmp === 9) {
      Result = "crSizeWE"}
     else if ($tmp === 10) {
      Result = "crUpArrow"}
     else if ($tmp === 11) {
      Result = "crHourGlass"}
     else if ($tmp === 12) {
      Result = "crDrag"}
     else if ($tmp === 13) {
      Result = "crNoDrop"}
     else if ($tmp === 14) {
      Result = "crHSplit"}
     else if ($tmp === 15) {
      Result = "crVSplit"}
     else if ($tmp === 16) {
      Result = "crMultiDrag"}
     else if ($tmp === 17) {
      Result = "crSQLWait"}
     else if ($tmp === 18) {
      Result = "crNo"}
     else if ($tmp === 19) {
      Result = "crAppStart"}
     else if ($tmp === 20) {
      Result = "crHelp"}
     else if ($tmp === 21) {
      Result = "crHandpoint"}
     else if ($tmp === 22) Result = "crSizeAll";
    return Result;
  };
  this.StringToCursor = function (S) {
    var Result = 0;
    var us = "";
    Result = 0;
    us = pas.SysUtils.UpperCase(S);
    if (us === "CRDEFAULT") {
      Result = 0}
     else if (us === "CRARROW") {
      Result = 2}
     else if (us === "CRNONE") {
      Result = 1}
     else if (us === "CRCROSS") {
      Result = 3}
     else if (us === "CRSIZE") {
      Result = 5}
     else if (us === "CRIBEAM") {
      Result = 4}
     else if (us === "CRSIZENESW") {
      Result = 6}
     else if (us === "CRSIZENS") {
      Result = 7}
     else if (us === "CRSIZENWSE") {
      Result = 8}
     else if (us === "CRSIZEWE") {
      Result = 9}
     else if (us === "CRUPARROW") {
      Result = 10}
     else if (us === "CRHOURGLASS") {
      Result = 11}
     else if (us === "CRDRAG") {
      Result = 12}
     else if (us === "CRNODROP") {
      Result = 13}
     else if (us === "CRHSPLIT") {
      Result = 14}
     else if (us === "CRVSPLIT") {
      Result = 15}
     else if (us === "CRMULTIDRAG") {
      Result = 16}
     else if (us === "CRSQLWAIT") {
      Result = 17}
     else if (us === "CRNO") {
      Result = 18}
     else if (us === "CRAPPSTART") {
      Result = 19}
     else if (us === "CRHELP") {
      Result = 20}
     else if (us === "CRHANDPOINT") {
      Result = 21}
     else if (us === "CRSIZEALL") Result = 22;
    return Result;
  };
  this.IsAndroid = function () {
    var Result = false;
    var sagent = "";
    sagent = navigator.userAgent;
    Result = pas.System.Pos("Android",sagent) > 0;
    return Result;
  };
  this.GetMaterialClass = function (mg) {
    var Result = "";
    Result = "material-icons";
    var $tmp = mg;
    if ($tmp === $mod.TMaterialGlyphType.mgOutlined) {
      Result = "material-icons-outlined"}
     else if ($tmp === $mod.TMaterialGlyphType.mgTwoTone) {
      Result = "material-icons-two-tone"}
     else if ($tmp === $mod.TMaterialGlyphType.mgRound) {
      Result = "material-icons-round"}
     else if ($tmp === $mod.TMaterialGlyphType.mgSharp) Result = "material-icons-sharp";
    return Result;
  };
  this.InputTypeString = function (AInputType) {
    var Result = "";
    var $tmp = AInputType;
    if ($tmp === $mod.TInputType.itText) {
      Result = "text"}
     else if ($tmp === $mod.TInputType.itEmail) {
      Result = "email"}
     else if ($tmp === $mod.TInputType.itDate) {
      Result = "date"}
     else if ($tmp === $mod.TInputType.itDateTime) {
      Result = "datetime-local"}
     else if ($tmp === $mod.TInputType.itFile) {
      Result = "file"}
     else if ($tmp === $mod.TInputType.itMonth) {
      Result = "month"}
     else if ($tmp === $mod.TInputType.itNumber) {
      Result = "number"}
     else if ($tmp === $mod.TInputType.itPassword) {
      Result = "password"}
     else if ($tmp === $mod.TInputType.itSearch) {
      Result = "search"}
     else if ($tmp === $mod.TInputType.itTime) {
      Result = "time"}
     else if ($tmp === $mod.TInputType.itURL) {
      Result = "url"}
     else if ($tmp === $mod.TInputType.itWeek) Result = "week";
    return Result;
  };
  $mod.$implcode = function () {
    $impl.ControlManager = null;
    $impl.FMouseX = 0;
    $impl.FMouseY = 0;
    $impl.FCursorX = 0;
    $impl.FCursorY = 0;
    $impl.ScrollBW = 0;
    $impl.ScrollBH = 0;
    $impl.DragObject = null;
    $impl.cStyleBkgColor = "background-color";
  };
  $mod.$init = function () {
    $impl.ScrollBW = 0;
    $impl.ScrollBH = 0;
    $impl.DragObject = null;
    $impl.ControlManager = $mod.TControlManager.$create("Create$1",[null]);
  };
},["WEBLib.Dialogs","WEBLib.Forms","Math","TypInfo","WEBLib.WebTools","WEBLib.Utils"]);
rtl.module("WEBLib.WebTools",["System","Classes","Web","JS","WEBLib.Controls","WEBLib.Graphics"],function () {
  "use strict";
  var $mod = this;
  this.CRLF = "\r\n";
  this.LNBR = "<BR>";
  this.cBodyTag = "body";
  this.cHTMLExt = ".html";
  this.TOperatingSystem = {"0": "osUnknown", osUnknown: 0, "1": "osWindows", osWindows: 1, "2": "osmacOS", osmacOS: 2, "3": "osLinux", osLinux: 3, "4": "osAndroid", osAndroid: 4, "5": "osiOS", osiOS: 5};
  this.$rtti.$Enum("TOperatingSystem",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TOperatingSystem});
  this.DoubleToHTML = function (d) {
    var Result = "";
    Result = pas.SysUtils.Format$1("%g",pas.System.VarRecs(3,d),pas.SysUtils.TFormatSettings.Invariant());
    return Result;
  };
  this.MessageBeep = function (AType) {
    var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeI"+
        "IIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVK"+
    "OhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1f"+
    "hzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACi"+
    "DgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhE"+
    "BcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4doscwD6neZjuZR4AgAABY"+
    "AAAABy1xcdQtxYBYYZdifkUDgzzXaXn98Z0oi9ILU5mBjFANmRwlVJ3/6jYDAmxaiDG3/6xjQQCCKkRb/6kg/wW+kSJ5//rLobkLSiKmqP/0ikJuDaSaSf/6JiLYLEYnW/+kXg1WRVJL/9EmQ1YZIsv/6Qzw"+
    "y5qk7/+tEU0nkls3/zIUMPKNX/6yZLf+kFgAfgGyLFAUwY//uQZAUABcd5UiNPVXAAAApAAAAAE0VZQKw9ISAAACgAAAAAVQIygIElVrFkBS+Jhi+EAuu+lKAkYUEIsmEAEoMeDmCETMvfSHTGkF5RWH7kz/"+
    "ESHWPAq/kcCRhqBtMdokPdM7vil7RG98A2sc7zO6ZvTdM7pmOUAZTnJW+NXxqmd41dqJ6mLTXxrPpnV8avaIf5SvL7pndPvPpndJR9Kuu8fePvuiuhorgWjp7Mf/PRjxcFCPDkW31srioCExivv9lcwKEaHs"+
    "f/7ow2Fl1T/9RkXgEhYElAoCLFtMArxwivDJJ+bR1HTKJdlEoTELCIqgEwVGSQ+hIm0NbK8WXcTEI0UPoa2NbG4y2K00JEWbZavJXkYaqo9CRHS55FcZTjKEk3NKoCYUnSQ0rWxrZbFKbKIhOKPZe1cJKzZS"+
    "aQrIyULHDZmV5K4xySsDRKWOruanGtjLJXFEmwaIbDLX0hIPBUQPVFVkQkDoUNfSoDgQGKPekoxeGzA4DUvnn4bxzcZrtJyipKfPNy5w+9lnXwgqsiyHNeSVpemw4bWb9psYeq//uQZBoABQt4yMVxYAIAAA"+
    "kQoAAAHvYpL5m6AAgAACXDAAAAD59jblTirQe9upFsmZbpMudy7Lz1X1DYsxOOSWpfPqNX2WqktK0DMvuGwlbNj44TleLPQ+Gsfb+GOWOKJoIrWb3cIMeeON6lz2umTqMXV8Mj30yWPpjoSa9ujK8SyeJP5y5"+
    "mOW1D6hvLepeveEAEDo0mgCRClOEgANv3B9a6fikgUSu/DmAMATrGx7nng5p5iimPNZsfQLYB2sDLIkzRKZOHGAaUyDcpFBSLG9MCQALgAIgQs2YunOszLSAyQYPVC2YdGGeHD2dTdJk1pAHGAWDjnkcLKFym"+
    "S3RQZTInzySoBwMG0QueC3gMsCEYxUqlrcxK6k1LQQcsmyYeQPdC2YfuGPASCBkcVMQQqpVJshui1tkXQJQV0OXGAZMXSOEEBRirXbVRQW7ugq7IM7rPWSZyDlM3IuNEkxzCOJ0ny2ThNkyRai1b6ev//3dzN"+
    "GzNb//4uAvHT5sURcZCFcuKLhOFs8mLAAEAt4UWAAIABAAAAAB4qbHo0tIjVkUU//uQZAwABfSFz3ZqQAAAAAngwAAAE1HjMp2qAAAAACZDgAAAD5UkTE1UgZEUExqYynN1qZvqIOREEFmBcJQkwdxiFtw0q"+
    "EOkGYfRDifBui9MQg4QAHAqWtAWHoCxu1Yf4VfWLPIM2mHDFsbQEVGwyqQoQcwnfHeIkNt9YnkiaS1oizycqJrx4KOQjahZxWbcZgztj2c49nKmkId44S71j0c8eV9yDK6uPRzx5X18eDvjvQ6yKo9ZSS6l/"+
    "/8elePK/Lf//IInrOF/FvDoADYAGBMGb7FtErm5MXMlmPAJQVgWta7Zx2go+8xJ0UiCb8LHHdftWyLJE0QIAIsI+UbXu67dZMjmgDGCGl1H+vpF4NSDckSIkk7Vd+sxEhBQMRU8j/12UIRhzSaUdQ+rQU5kG"+
    "eFxm+hb1oh6pWWmv3uvmReDl0UnvtapVaIzo1jZbf/pD6ElLqSX+rUmOQNpJFa/r+sa4e/pBlAABoAAAAA3CUgShLdGIxsY7AUABPRrgCABdDuQ5GC7DqPQCgbbJUAoRSUj+NIEig0YfyWUho1VBBBA//uQZ"+
    "B4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZ"+
    "TGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRP"+
    "gUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCk"+
    "QjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk"+
    "4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb////////////////////////////////////////////////////////////////////////////////////////////"+
    "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"+
    "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"+
    "/////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");
    snd.play();
  };
  this.OutputDebugString = function (s) {
    console.log(s);
  };
  this.GetTickCount = function () {
    var Result = 0;
    var n = 0;
    var d = new Date();
    n = d.getTime();
    Result = n;
    return Result;
  };
  this.GetQueryParam = function (AName) {
    var Result = "";
    var res = "";
    $mod.HasQueryParam(AName,{get: function () {
        return res;
      }, set: function (v) {
        res = v;
      }},true);
    Result = res;
    return Result;
  };
  this.HasQueryParam = function (AName, AValue, CaseSensitive) {
    var Result = false;
    var found = false;
    var s = "";
    s = "";
    if (!CaseSensitive) AName = pas.SysUtils.UpperCase(AName);
    var query = window.location.search.substring(1);
        var res = "";
        var key = "";
        found = false;
        var vars = query.split('&');
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split('=');
    
          key = decodeURIComponent(pair[0]);
          if (CaseSensitive == false)
          {
            key = key.toUpperCase();
          }
    
          if (key == AName) {
              res = decodeURIComponent(pair[1]);
              found = true;
           }
        }
        s = res;
    AValue.set(s);
    Result = found;
    return Result;
  };
  this.EscapeHTML = function (AValue) {
    var Result = "";
    var s = "";
    s = AValue;
    function escapeHTML(AString) {
      return AString.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
    }
    s = escapeHTML(s);
    Result = s;
    return Result;
  };
  this.GetLocaleShortDateFormat = function (ALocale) {
    var Result = "";
    Result = pas.SysUtils.TFormatSettings.Create$1(ALocale).ShortDateFormat;
    return Result;
  };
  this.GetLocaleLongDayName = function (DayOfWeek, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, 0, 1); // Sunday
        baseDate.setDate(baseDate.getDate() + DayOfWeek - 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { weekday: 'long' });
    Result = res;
    return Result;
  };
  this.GetLocaleShortDayName = function (DayOfWeek, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, 0, 1); // Sunday
        baseDate.setDate(baseDate.getDate() + DayOfWeek - 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { weekday: 'short' });
    Result = res;
    return Result;
  };
  this.GetLocaleLongMonthName = function (Month, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, Month - 1, 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { month: 'long' });
    Result = res;
    return Result;
  };
  this.GetLocaleShortMonthName = function (Month, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, Month - 1, 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { month: 'short' });
    Result = res;
    return Result;
  };
  this.GetLocaleDecimalSeparator = function (ALocale) {
    var Result = "";
    var res = "";
    var n = 1.1;
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        n = n.toLocaleString(loc).substring(1, 2);
        res = n;
    Result = res;
    return Result;
  };
  this.GetLocaleThousandSeparator = function (ALocale) {
    var Result = "";
    var res = "";
    var n = 1000.1;
    var loc = "";
    if (ALocale == '') { loc = navigator.language; }
    else { loc = ALocale; }
    n = n.toLocaleString(loc).substring(1, 2);
    res = n;
    Result = res;
    return Result;
  };
  this.LocaleFormatCurrency = function (Value, ACurrency, ALocale) {
    var Result = "";
    var res = "";
    var loc = "";
    if (ALocale == '') { loc = navigator.language; }
    else { loc = ALocale; }
    var number = Value;
    res = number.toLocaleString(loc, { style: 'currency', currency: ACurrency });
    Result = res;
    return Result;
  };
  this.GetLocaleCurrency = function (ALocale) {
    var Result = "";
    var res = "";
    var curr =
          {"BD": "BDT", "BE": "EUR", "BF": "XOF", "BG": "BGN", "BA": "BAM", "BB": "BBD", "WF": "XPF",
           "BL": "EUR", "BM": "BMD", "BN": "BND", "BO": "BOB", "BH": "BHD", "BI": "BIF", "BJ": "XOF",
           "BT": "BTN", "JM": "JMD", "BV": "NOK", "BW": "BWP", "WS": "WST", "BQ": "USD", "BR": "BRL",
           "BS": "BSD", "JE": "GBP", "BY": "BYR", "BZ": "BZD", "RU": "RUB", "RW": "RWF", "RS": "RSD",
           "TL": "USD", "RE": "EUR", "TM": "TMT", "TJ": "TJS", "RO": "RON", "TK": "NZD", "GW": "XOF",
           "GU": "USD", "GT": "GTQ", "GS": "GBP", "GR": "EUR", "GQ": "XAF", "GP": "EUR", "JP": "JPY",
           "GY": "GYD", "GG": "GBP", "GF": "EUR", "GE": "GEL", "GD": "XCD", "GB": "GBP", "GA": "XAF",
           "SV": "USD", "GN": "GNF", "GM": "GMD", "GL": "DKK", "GI": "GIP", "GH": "GHS", "OM": "OMR",
           "TN": "TND", "JO": "JOD", "HR": "HRK", "HT": "HTG", "HU": "HUF", "HK": "HKD", "HN": "HNL",
           "HM": "AUD", "VE": "VEF", "PR": "USD", "PS": "ILS", "PW": "USD", "PT": "EUR", "SJ": "NOK",
           "PY": "PYG", "IQ": "IQD", "PA": "PAB", "PF": "XPF", "PG": "PGK", "PE": "PEN", "PK": "PKR",
           "PH": "PHP", "PN": "NZD", "PL": "PLN", "PM": "EUR", "ZM": "ZMK", "EH": "MAD", "EE": "EUR",
           "EG": "EGP", "ZA": "ZAR", "EC": "USD", "IT": "EUR", "VN": "VND", "SB": "SBD", "ET": "ETB",
           "SO": "SOS", "ZW": "ZWL", "SA": "SAR", "ES": "EUR", "ER": "ERN", "ME": "EUR", "MD": "MDL",
           "MG": "MGA", "MF": "EUR", "MA": "MAD", "MC": "EUR", "UZ": "UZS", "MM": "MMK", "ML": "XOF",
           "MO": "MOP", "MN": "MNT", "MH": "USD", "MK": "MKD", "MU": "MUR", "MT": "EUR", "MW": "MWK",
           "MV": "MVR", "MQ": "EUR", "MP": "USD", "MS": "XCD", "MR": "MRO", "IM": "GBP", "UG": "UGX",
           "TZ": "TZS", "MY": "MYR", "MX": "MXN", "IL": "ILS", "FR": "EUR", "IO": "USD", "SH": "SHP",
           "FI": "EUR", "FJ": "FJD", "FK": "FKP", "FM": "USD", "FO": "DKK", "NI": "NIO", "NL": "EUR",
           "NO": "NOK", "NA": "NAD", "VU": "VUV", "NC": "XPF", "NE": "XOF", "NF": "AUD", "NG": "NGN",
           "NZ": "NZD", "NP": "NPR", "NR": "AUD", "NU": "NZD", "CK": "NZD", "XK": "EUR", "CI": "XOF",
           "CH": "CHF", "CO": "COP", "CN": "CNY", "CM": "XAF", "CL": "CLP", "CC": "AUD", "CA": "CAD",
           "CG": "XAF", "CF": "XAF", "CD": "CDF", "CZ": "CZK", "CY": "EUR", "CX": "AUD", "CR": "CRC",
           "CW": "ANG", "CV": "CVE", "CU": "CUP", "SZ": "SZL", "SY": "SYP", "SX": "ANG", "KG": "KGS",
           "KE": "KES", "SS": "SSP", "SR": "SRD", "KI": "AUD", "KH": "KHR", "KN": "XCD", "KM": "KMF",
           "ST": "STD", "SK": "EUR", "KR": "KRW", "SI": "EUR", "KP": "KPW", "KW": "KWD", "SN": "XOF",
           "SM": "EUR", "SL": "SLL", "SC": "SCR", "KZ": "KZT", "KY": "KYD", "SG": "SGD", "SE": "SEK",
           "SD": "SDG", "DO": "DOP", "DM": "XCD", "DJ": "DJF", "DK": "DKK", "VG": "USD", "DE": "EUR",
           "YE": "YER", "DZ": "DZD", "US": "USD", "UY": "UYU", "YT": "EUR", "UM": "USD", "LB": "LBP",
           "LC": "XCD", "LA": "LAK", "TV": "AUD", "TW": "TWD", "TT": "TTD", "TR": "TRY", "LK": "LKR",
           "LI": "CHF", "LV": "EUR", "TO": "TOP", "LT": "LTL", "LU": "EUR", "LR": "LRD", "LS": "LSL",
           "TH": "THB", "TF": "EUR", "TG": "XOF", "TD": "XAF", "TC": "USD", "LY": "LYD", "VA": "EUR",
           "VC": "XCD", "AE": "AED", "AD": "EUR", "AG": "XCD", "AF": "AFN", "AI": "XCD", "VI": "USD",
           "IS": "ISK", "IR": "IRR", "AM": "AMD", "AL": "ALL", "AO": "AOA", "AQ": "", "AS": "USD",
           "AR": "ARS", "AU": "AUD", "AT": "EUR", "AW": "AWG", "IN": "INR", "AX": "EUR", "AZ": "AZN",
           "IE": "EUR", "ID": "IDR", "UA": "UAH", "QA": "QAR", "MZ": "MZN"}
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
        loc = loc.substring(3,5);
        loc = loc.toUpperCase();
        res = curr[loc] || '';
    Result = res;
    return Result;
  };
  this.GetBrowserLocale = function () {
    var Result = "";
    var res = "";
    res = navigator.language;
    Result = res;
    return Result;
  };
  this.GetOperatingSystem = function () {
    var Result = 0;
    var ag = "";
    var res = false;
    Result = $mod.TOperatingSystem.osUnknown;
    ag = navigator.userAgent;
    if (pas.System.Pos("Win",ag) > 0) Result = $mod.TOperatingSystem.osWindows;
    if (pas.System.Pos("Mac",ag) > 0) Result = $mod.TOperatingSystem.osmacOS;
    if (pas.System.Pos("Linux",ag) > 0) Result = $mod.TOperatingSystem.osLinux;
    if (pas.System.Pos("Android",ag) > 0) Result = $mod.TOperatingSystem.osAndroid;
    if (pas.System.Pos("Linux",ag) > 0) Result = $mod.TOperatingSystem.osLinux;
    res = ag.match(/(iPod|iPhone|iPad)/) &&
    ag.match(/AppleWebKit/);
    if (res) Result = $mod.TOperatingSystem.osiOS;
    return Result;
  };
  this.ProcessAccelerator = function (AValue, Accelerator) {
    var Result = "";
    var i = 0;
    var l = 0;
    var res = "";
    l = AValue.length;
    Accelerator.set("");
    res = "";
    i = 1;
    while (i <= l) {
      if (AValue.charAt(i - 1) === "&") {
        if (((i + 1) <= l) && (AValue.charAt((i + 1) - 1) !== "&")) {
          res = res + "<u>" + AValue.charAt((i + 1) - 1) + "</u>";
          Accelerator.set(AValue.charAt((i + 1) - 1));
        } else if (((i + 1) <= l) && (AValue.charAt((i + 1) - 1) === "&")) res = res + "&";
        i += 2;
      } else {
        res = res + AValue.charAt(i - 1);
        i += 1;
      };
    };
    Result = res;
    return Result;
  };
  this.GetBase64Image = function (AImage, AWidth, AHeight) {
    var Result = "";
    var s = "";
    var m = null;
    s = "";
    m = AImage;
    function getBase64Image(img) {
      var canvas = document.createElement("canvas");
      if (AWidth == 0) {
        canvas.width = img.width; }
        else {
        canvas.width = AWidth; }
      if (AHeight == 0) {
      canvas.height = img.height; }
      else {
        canvas.height = AHeight; }
      var ctx = canvas.getContext("2d");
      if ((AWidth == 0) || (AHeight == 0)) {
         ctx.drawImage(img, 0, 0); }
      else {
         ctx.drawImage(img, 0, 0, AWidth, AHeight); }
      var dataURL = canvas.toDataURL("image/png");
      return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
    }
    s = getBase64Image(m);
    Result = s;
    return Result;
  };
  this.DebugBreak = function () {
    debugger;
  };
  this.HexImageDecode = function (s) {
    var Result = null;
    var i = 0;
    var j = 0;
    var l = 0;
    var res = null;
    var c1 = 0;
    var c2 = 0;
    var hdr = 0;
    l = rtl.trunc(s.length / 2);
    j = 0;
    c1 = s.charCodeAt(1 - 1) - 48;
    if (c1 >= 10) c1 = c1 - 7;
    c2 = s.charCodeAt(2 - 1) - 48;
    if (c2 >= 10) c2 = c2 - 7;
    hdr = 1 + (c2 + (c1 << 4));
    i = pas.System.Pos("4A5045474",s);
    if ((i > 1) && (i < 10)) hdr += 4;
    i = pas.System.Pos("4269746D6",s);
    if ((i > 1) && (i < 10)) hdr += 4;
    res = new Uint8Array(l - hdr);
    for (var $l = hdr + 1, $end = l; $l <= $end; $l++) {
      i = $l;
      c1 = s.charCodeAt((i * 2) - 1 - 1) - 48;
      if (c1 >= 10) c1 = c1 - 7;
      c2 = s.charCodeAt((i * 2) - 1) - 48;
      if (c2 >= 10) c2 = c2 - 7;
      c2 = c2 + (c1 << 4);
      res[j] = c2;
      j += 1;
    };
    Result = res;
    return Result;
  };
  this.HexImageEncodeFromBase64 = function (s) {
    var Result = "";
    var ja = null;
    s = s.replace(/^data:image\/\S+;base64,/, "");
    //ja = Uint8Array.from(atob(s), c => c.charCodeAt(0))
    ja = Uint8Array.from(atob(s), function(c) { return c.charCodeAt(0);} );
    Result = $mod.HexImageEncode(ja);
    return Result;
  };
  this.HexImageEncode = function (a) {
    var Result = "";
    var i = 0;
    var l = 0;
    var b = 0;
    var s = "";
    var ls = "";
    Result = "";
    l = a.length;
    if (l === 0) return Result;
    l = ((l & 0xFF) << 24) + ((l & 0xFF00) << 8) + ((l & 0xFF0000) >>> 8) + ((l & 0xFF000000) >>> 24);
    ls = "";
    if ((a[0] === 137) && (a[1] === 80)) {
      s = "TPngImage";
      b = s.length;
    };
    if ((a[0] === 0xFF) && (a[1] === 0xD8)) {
      s = "TJPEGImage";
      b = s.length;
      ls = pas.SysUtils.IntToHex(l,8);
    };
    if ((a[0] === 66) && (a[1] === 77)) {
      s = "TBitmap";
      b = s.length;
      ls = pas.SysUtils.IntToHex(l,8);
    };
    if ((a[0] === 71) && (a[1] === 73)) {
      s = "TGIFImage";
      b = s.length;
    };
    Result = pas.SysUtils.IntToHex(b,2);
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      b = s.charCodeAt(i - 1);
      Result = Result + pas.SysUtils.IntToHex(b,2);
    };
    Result = Result + ls;
    for (var $l1 = 0, $end1 = a.length - 1; $l1 <= $end1; $l1++) {
      i = $l1;
      b = a[i];
      Result = Result + pas.SysUtils.IntToHex(b,2);
    };
    return Result;
  };
  this.HexImageDecodeAsBase64 = function (s) {
    var Result = "";
    var ja = null;
    ja = $mod.HexImageDecode(s);
    s = btoa(new Uint8Array(ja).reduce(function (data, byte) {
    return data + String.fromCharCode(byte);
    }, ''));
    Result = s;
    return Result;
  };
  this.EmptyImage = function () {
    var Result = "";
    Result = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
    return Result;
  };
  this.NumAttribute = function (s) {
    var Result = "";
    var res = "";
    res = pas.SysUtils.TDoubleHelper.ToString$3.call({get: function () {
        return s;
      }, set: function (v) {
        s = v;
      }});
    Result = pas.SysUtils.StringReplace(res,",",".",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.DataURLToFile = function (AURL, FileName) {
    var Result = null;
    var afile = null;
    var arr = AURL.split(','),
    mime = arr[0].match(/:(.*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n);
    while(n--){
      u8arr[n] = bstr.charCodeAt(n);
    }
    afile = new File([u8arr], FileName, {type:mime});
    Result = afile;
    return Result;
  };
  this.DownloadFile = function (AFile) {
    var a = null;
    a = document.createElement("a");
    a.href = window.URL.createObjectURL(AFile);
    a.download = AFile.name;
    a.click();
  };
  this.PickerDateToDate = function (s) {
    var Result = 0.0;
    var ye = "";
    var mo = "";
    var da = "";
    var yei = 0;
    var moi = 0;
    var dai = 0;
    var e = 0;
    Result = 0;
    ye = pas.System.Copy(s,1,4);
    mo = pas.System.Copy(s,6,2);
    da = pas.System.Copy(s,9,2);
    pas.System.val$5(ye,{get: function () {
        return yei;
      }, set: function (v) {
        yei = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(mo,{get: function () {
        return moi;
      }, set: function (v) {
        moi = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(da,{get: function () {
        return dai;
      }, set: function (v) {
        dai = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    if ((yei !== 0) && (moi !== 0) && (dai !== 0)) Result = pas.SysUtils.EncodeDate(yei,moi,dai);
    return Result;
  };
  this.PickerTimeToTime = function (s) {
    var Result = 0.0;
    var ho = "";
    var mi = "";
    var se = "";
    var hoi = 0;
    var mii = 0;
    var sei = 0;
    var e = 0;
    Result = 0;
    ho = pas.System.Copy(s,1,2);
    mi = pas.System.Copy(s,4,2);
    se = pas.System.Copy(s,7,2);
    pas.System.val$5(ho,{get: function () {
        return hoi;
      }, set: function (v) {
        hoi = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(mi,{get: function () {
        return mii;
      }, set: function (v) {
        mii = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(se,{get: function () {
        return sei;
      }, set: function (v) {
        sei = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    if ((hoi >= 0) && (mii >= 0) && (sei >= 0)) Result = pas.SysUtils.EncodeTime(hoi,mii,sei,0);
    return Result;
  };
  this.URLString = function (s) {
    var Result = "";
    var res = "";
    function linkify(inputText) {
        var replacedText, replacePattern1, replacePattern2, replacePattern3;
    
        //URLs starting with http://, https://, or ftp://
        replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
        replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1</a>');
    
        //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
        replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
        replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');
    
        //Change email addresses to mailto:: links.
        replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
        replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
    
        return replacedText;
        }
        res = linkify(s);
    Result = res;
    return Result;
  };
  this.IsURl = function (s) {
    var Result = false;
    var res = false;
    function CheckIsUrl(inputText) {
    if(new RegExp("([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?").test(inputText)) {
        return true;
    }
    return false;
    }
    res = CheckIsUrl(s);
    Result = res;
    return Result;
  };
  this.EmojiString = function (s) {
    var Result = "";
    var ls = null;
    var i = 0;
    var v = "";
    var k = "";
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) === "|") s = rtl.setCharAt(s,i - 1,"¦");
    };
    ls = pas.Classes.TStringList.$create("Create$1");
    ls.AddPair(":)","&#x1F600;");
    ls.AddPair(":D","&#x1F601;");
    ls.AddPair(";)","&#x1F609;");
    ls.AddPair(":O","&#x1F62E;");
    ls.AddPair(":*","&#x1F617;");
    ls.AddPair(":P","&#x1F61C;");
    ls.AddPair(":(","&#x1F641;");
    ls.AddPair(":¦","&#x1F610;");
    ls.AddPair(":X","&#x1F910;");
    ls.AddPair("¦;)","&#x1F60E;");
    ls.AddPair(":<","&#x1F621;");
    for (var $l1 = 0, $end1 = ls.GetCount() - 1; $l1 <= $end1; $l1++) {
      i = $l1;
      v = ls.GetName(i);
      k = ls.GetValue(v);
      s = pas.SysUtils.StringReplace(s,v,k,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    };
    ls = rtl.freeLoc(ls);
    Result = s;
    return Result;
  };
  this.HTMLToString = function (s) {
    var Result = "";
    s = pas.SysUtils.StringReplace(s,"<","&lt;",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    Result = pas.SysUtils.StringReplace(s,">","&gt;",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.FileSizeFmt = function (Size) {
    var Result = "";
    if (Size < 1000) Result = pas.SysUtils.IntToStr(Size) + " bytes";
    if ((Size >= 1000) && (Size < 1000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000)) + " Kb";
    if ((Size >= 1000000) && (Size < 1000000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000)) + " Mb";
    if (Size >= 1000000000) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000000)) + " Gb";
    return Result;
  };
  this.FileSizeFmtSpeed = function (Size) {
    var Result = "";
    if (Size < 1000) Result = pas.SysUtils.IntToStr(Size) + " bytes/sec";
    if ((Size >= 1000) && (Size < 1000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000)) + " Kb/sec";
    if ((Size >= 1000000) && (Size < 1000000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000)) + " Mb/sec";
    if (Size >= 1000000000) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000000)) + " Gb/sec";
    return Result;
  };
  this.ElementVisible = function (el) {
    var Result = false;
    var p = null;
    Result = false;
    p = el;
    while (p != null) {
      if (pas.SysUtils.LowerCase(p.tagName) === $mod.cBodyTag) Result = true;
      p = p.parentElement;
    };
    if (!Result) return Result;
    while (el != null) {
      if (el.style.getPropertyValue("display") === "none") {
        Result = false;
        return Result;
      };
      p = el.parentElement;
      if (!rtl.isExt(p,HTMLElement)) return Result;
      el = p;
    };
    return Result;
  };
  this.GetMaterialGlyph = function (AGlyph, ASize, AColor, AType) {
    var Result = "";
    var s = "";
    var matclr = "";
    var matsize = "";
    s = "<i";
    s = s + ' class="' + pas["WEBLib.Controls"].GetMaterialClass(AType) + '"';
    matclr = "";
    if (AColor !== -1) matclr = "color:" + pas["WEBLib.Graphics"].ColorToHTML(AColor) + ";";
    matsize = "";
    if (ASize !== 0) matsize = "font-size:" + pas.SysUtils.IntToStr(ASize) + "px;";
    s = s + ' style="pointer-events:none;' + matclr + matsize + '"';
    Result = s + ">" + AGlyph + "</i>";
    return Result;
  };
},["SysUtils","WEBLib.Utils"]);
rtl.module("contnrs",["System","SysUtils","Classes"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$RefToProcVar("TObjectListCallback",{procsig: rtl.newTIProcSig([["data",pas.System.$rtti["TObject"]],["arg",rtl.jsvalue]])});
  rtl.createClass(this,"TFPObjectList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FFreeObjects = false;
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FList.FCount;
      return Result;
    };
    this.SetCount = function (AValue) {
      if (this.FList.FCount !== AValue) this.FList.SetCount(AValue);
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.FList.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, AObject) {
      var O = null;
      if (this.FFreeObjects) {
        O = rtl.getObject(this.FList.Get(Index));
        this.FList.Put(Index,AObject);
        O = rtl.freeLoc(O);
      } else this.FList.Put(Index,AObject);
    };
    this.SetCapacity = function (NewCapacity) {
      this.FList.SetCapacity(NewCapacity);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.FList.FCapacity;
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FList = pas.Classes.TFPList.$create("Create");
      this.FFreeObjects = true;
      return this;
    };
    this.Create$2 = function (FreeObjects) {
      this.Create$1();
      this.FFreeObjects = FreeObjects;
      return this;
    };
    this.Destroy = function () {
      if (this.FList !== null) {
        this.Clear();
        this.FList.$destroy("Destroy");
      };
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      var i = 0;
      var O = null;
      if (this.FFreeObjects) for (var $l = this.FList.FCount - 1; $l >= 0; $l--) {
        i = $l;
        O = rtl.getObject(this.FList.Get(i));
        this.FList.Put(i,null);
        O = rtl.freeLoc(O);
      };
      this.FList.Clear();
    };
    this.Add = function (AObject) {
      var Result = 0;
      Result = this.FList.Add(AObject);
      return Result;
    };
    this.Delete = function (Index) {
      var O = null;
      if (this.FFreeObjects) {
        O = rtl.getObject(this.FList.Get(Index));
        this.FList.Put(Index,null);
        O = rtl.freeLoc(O);
      };
      this.FList.Delete(Index);
    };
    this.Exchange = function (Index1, Index2) {
      this.FList.Exchange(Index1,Index2);
    };
    this.Expand = function () {
      var Result = null;
      this.FList.Expand();
      Result = this;
      return Result;
    };
    this.Extract = function (Item) {
      var Result = null;
      Result = rtl.getObject(this.FList.Extract(Item));
      return Result;
    };
    this.Remove = function (AObject) {
      var Result = 0;
      var O = null;
      Result = this.IndexOf(AObject);
      if (Result !== -1) {
        if (this.FFreeObjects) {
          O = rtl.getObject(this.FList.Get(Result));
          this.FList.Put(Result,null);
          O = rtl.freeLoc(O);
        };
        this.FList.Delete(Result);
      };
      return Result;
    };
    this.IndexOf = function (AObject) {
      var Result = 0;
      Result = this.FList.IndexOf(AObject);
      return Result;
    };
    this.FindInstanceOf = function (AClass, AExact, AStartAt) {
      var Result = 0;
      var I = 0;
      I = AStartAt;
      Result = -1;
      if (AExact) {
        while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.ClassType() === AClass) {
          Result = I}
         else I += 1}
       else while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.InheritsFrom(AClass)) {
        Result = I}
       else I += 1;
      return Result;
    };
    this.Insert = function (Index, AObject) {
      this.FList.Insert(Index,AObject);
    };
    this.First = function () {
      var Result = null;
      Result = rtl.getObject(this.FList.First());
      return Result;
    };
    this.Last = function () {
      var Result = null;
      Result = rtl.getObject(this.FList.Last());
      return Result;
    };
    this.Move = function (CurIndex, NewIndex) {
      this.FList.Move(CurIndex,NewIndex);
    };
    this.Assign = function (Obj) {
      var i = 0;
      this.Clear();
      for (var $l = 0, $end = Obj.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.Add(Obj.GetItem(i));
      };
    };
    this.Pack = function () {
      this.FList.Pack();
    };
    this.Sort = function (Compare) {
      this.FList.Sort(Compare);
    };
    this.ForEachCall = function (proc2call, arg) {
      this.FList.ForEachCall(proc2call,arg);
    };
  });
  rtl.createClass(this,"TObjectList",pas.Classes.TList,function () {
    this.$init = function () {
      pas.Classes.TList.$init.call(this);
      this.FFreeObjects = false;
    };
    this.Notify = function (Ptr, Action) {
      var O = null;
      if (this.FFreeObjects) if (Action === pas.Classes.TListNotification.lnDeleted) {
        O = rtl.getObject(Ptr);
        O = rtl.freeLoc(O);
      };
      pas.Classes.TList.Notify.call(this,Ptr,Action);
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Get.call(this,Index));
      return Result;
    };
    this.SetItem = function (Index, AObject) {
      this.Put(Index,AObject);
    };
    this.Create$2 = function () {
      pas.Classes.TList.Create$1.call(this);
      this.FFreeObjects = true;
      return this;
    };
    this.Create$3 = function (FreeObjects) {
      pas.Classes.TList.Create$1.call(this);
      this.FFreeObjects = FreeObjects;
      return this;
    };
    this.Add$1 = function (AObject) {
      var Result = 0;
      Result = pas.Classes.TList.Add.call(this,AObject);
      return Result;
    };
    this.Extract$1 = function (Item) {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Extract.call(this,Item));
      return Result;
    };
    this.Remove$1 = function (AObject) {
      var Result = 0;
      Result = pas.Classes.TList.Remove.call(this,AObject);
      return Result;
    };
    this.IndexOf$1 = function (AObject) {
      var Result = 0;
      Result = pas.Classes.TList.IndexOf.call(this,AObject);
      return Result;
    };
    this.FindInstanceOf = function (AClass, AExact, AStartAt) {
      var Result = 0;
      var I = 0;
      I = AStartAt;
      Result = -1;
      if (AExact) {
        while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.ClassType() === AClass) {
          Result = I}
         else I += 1}
       else while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.InheritsFrom(AClass)) {
        Result = I}
       else I += 1;
      return Result;
    };
    this.Insert$1 = function (Index, AObject) {
      pas.Classes.TList.Insert.call(this,Index,AObject);
    };
    this.First$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.First.call(this));
      return Result;
    };
    this.Last$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Last.call(this));
      return Result;
    };
  });
  rtl.createClass(this,"TComponentList",this.TObjectList,function () {
    this.$init = function () {
      $mod.TObjectList.$init.call(this);
      this.FNotifier = null;
    };
    this.$final = function () {
      this.FNotifier = undefined;
      $mod.TObjectList.$final.call(this);
    };
    this.Notify = function (Ptr, Action) {
      if (this.FNotifier === null) {
        this.FNotifier = $impl.TlistComponent.$create("Create$1",[null]);
        this.FNotifier.Flist = this;
      };
      if (pas.System.Assigned(Ptr)) {
        var $with = rtl.getObject(Ptr);
        var $tmp = Action;
        if ($tmp === pas.Classes.TListNotification.lnAdded) {
          $with.FreeNotification(this.FNotifier)}
         else if (($tmp === pas.Classes.TListNotification.lnExtracted) || ($tmp === pas.Classes.TListNotification.lnDeleted)) $with.RemoveFreeNotification(this.FNotifier);
      };
      $mod.TObjectList.Notify.call(this,Ptr,Action);
    };
    this.GetItems = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItems = function (Index, AComponent) {
      this.Put(Index,AComponent);
    };
    this.HandleFreeNotify = function (Sender, AComponent) {
      this.Extract$2(AComponent);
      if (Sender === null) ;
    };
    this.Destroy = function () {
      pas.Classes.TList.Destroy.call(this);
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FNotifier;
        }, set: function (v) {
          this.p.FNotifier = v;
        }});
    };
    this.Add$2 = function (AComponent) {
      var Result = 0;
      Result = $mod.TObjectList.Add$1.call(this,AComponent);
      return Result;
    };
    this.Extract$2 = function (Item) {
      var Result = null;
      Result = $mod.TObjectList.Extract$1.call(this,Item);
      return Result;
    };
    this.Remove$2 = function (AComponent) {
      var Result = 0;
      Result = $mod.TObjectList.Remove$1.call(this,AComponent);
      return Result;
    };
    this.IndexOf$2 = function (AComponent) {
      var Result = 0;
      Result = $mod.TObjectList.IndexOf$1.call(this,AComponent);
      return Result;
    };
    this.First$2 = function () {
      var Result = null;
      Result = $mod.TObjectList.First$1.call(this);
      return Result;
    };
    this.Last$2 = function () {
      var Result = null;
      Result = $mod.TObjectList.Last$1.call(this);
      return Result;
    };
    this.Insert$2 = function (Index, AComponent) {
      $mod.TObjectList.Insert$1.call(this,Index,AComponent);
    };
  });
  rtl.createClass(this,"TClassList",pas.Classes.TList,function () {
    this.GetItems = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItems = function (Index, AClass) {
      this.Put(Index,AClass);
    };
    this.Add$1 = function (AClass) {
      var Result = 0;
      Result = pas.Classes.TList.Add.call(this,AClass);
      return Result;
    };
    this.Extract$1 = function (Item) {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Extract.call(this,Item));
      return Result;
    };
    this.Remove$1 = function (AClass) {
      var Result = 0;
      Result = pas.Classes.TList.Remove.call(this,AClass);
      return Result;
    };
    this.IndexOf$1 = function (AClass) {
      var Result = 0;
      Result = pas.Classes.TList.IndexOf.call(this,AClass);
      return Result;
    };
    this.First$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.First.call(this));
      return Result;
    };
    this.Last$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Last.call(this));
      return Result;
    };
    this.Insert$1 = function (Index, AClass) {
      pas.Classes.TList.Insert.call(this,Index,AClass);
    };
  });
  rtl.createClass(this,"TOrderedList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.PopItem = function () {
      var Result = undefined;
      var $with = this.FList;
      if ($with.GetCount() > 0) {
        Result = $with.Get($with.GetCount() - 1);
        $with.Delete($with.GetCount() - 1);
      } else Result = null;
      return Result;
    };
    this.PeekItem = function () {
      var Result = undefined;
      var $with = this.FList;
      Result = $with.Get($with.GetCount() - 1);
      return Result;
    };
    this.Create$1 = function () {
      this.FList = pas.Classes.TList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FList");
    };
    this.Count = function () {
      var Result = 0;
      Result = this.FList.GetCount();
      return Result;
    };
    this.AtLeast = function (ACount) {
      var Result = false;
      Result = this.FList.GetCount() >= ACount;
      return Result;
    };
    this.Push = function (AItem) {
      var Result = undefined;
      this.PushItem(AItem);
      Result = AItem;
      return Result;
    };
    this.Pop = function () {
      var Result = undefined;
      if (this.AtLeast(1)) {
        Result = this.PopItem()}
       else Result = null;
      return Result;
    };
    this.Peek = function () {
      var Result = undefined;
      if (this.AtLeast(1)) {
        Result = this.PeekItem()}
       else Result = null;
      return Result;
    };
  });
  rtl.createClass(this,"TStack",this.TOrderedList,function () {
    this.PushItem = function (AItem) {
      this.FList.Add(AItem);
    };
  });
  rtl.createClass(this,"TObjectStack",this.TStack,function () {
    this.Push$1 = function (AObject) {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Push.call(this,AObject));
      return Result;
    };
    this.Pop$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Pop.call(this));
      return Result;
    };
    this.Peek$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Peek.call(this));
      return Result;
    };
  });
  rtl.createClass(this,"TQueue",this.TOrderedList,function () {
    this.PushItem = function (AItem) {
      var $with = this.FList;
      $with.Insert(0,AItem);
    };
  });
  rtl.createClass(this,"TObjectQueue",this.TQueue,function () {
    this.Push$1 = function (AObject) {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Push.call(this,AObject));
      return Result;
    };
    this.Pop$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Pop.call(this));
      return Result;
    };
    this.Peek$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Peek.call(this));
      return Result;
    };
  });
  this.$rtti.$ProcVar("THashFunction",{procsig: rtl.newTIProcSig([["S",rtl.string,2],["TableSize",rtl.longword,2]],rtl.longword)});
  rtl.createClass(this,"THTCustomNode",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FKey = "";
    };
    this.CreateWith = function (AString) {
      pas.System.TObject.Create.call(this);
      this.FKey = AString;
      return this;
    };
    this.HasKey = function (AKey) {
      var Result = false;
      Result = AKey === this.FKey;
      return Result;
    };
  });
  this.$rtti.$ClassRef("THTCustomNodeClass",{instancetype: this.$rtti["THTCustomNode"]});
  rtl.createClass(this,"TFPCustomHashTable",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FHashTable = null;
      this.FHashFunction = null;
      this.FCount = 0;
      this.FHashTableSize = 0;
    };
    this.$final = function () {
      this.FHashTable = undefined;
      this.FHashFunction = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetDensity = function () {
      var Result = 0;
      Result = this.FHashTableSize - this.GetVoidSlots();
      return Result;
    };
    this.GetNumberOfCollisions = function () {
      var Result = 0;
      Result = this.FCount - (this.FHashTableSize - this.GetVoidSlots());
      return Result;
    };
    this.SetHashTableSize = function (Value) {
      var i = 0;
      var newSize = 0;
      if (Value !== this.FHashTableSize) {
        i = 0;
        while (($impl.PRIMELIST[i] < Value) && (i < 27)) i += 1;
        newSize = $impl.PRIMELIST[i];
        if (this.FCount === 0) {
          this.FHashTableSize = newSize;
          this.InitializeHashTable();
        } else this.ChangeTableSize(newSize);
      };
    };
    this.InitializeHashTable = function () {
      var i = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        this.FHashTable.Add(null);
      };
      this.FCount = 0;
    };
    this.GetVoidSlots = function () {
      var Result = 0;
      var i = 0;
      var num = 0;
      num = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (!(this.Chain(i) != null)) num += 1;
      };
      Result = num;
      return Result;
    };
    this.GetLoadFactor = function () {
      var Result = 0.0;
      Result = this.FCount / this.FHashTableSize;
      return Result;
    };
    this.GetAVGChainLen = function () {
      var Result = 0.0;
      Result = this.FCount / (this.FHashTableSize - this.GetVoidSlots());
      return Result;
    };
    this.GetMaxChainLength = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.ChainLength(i) > Result) Result = this.ChainLength(i);
      };
      return Result;
    };
    this.Chain = function (index) {
      var Result = null;
      Result = this.FHashTable.GetItem(index);
      return Result;
    };
    this.ChainLength = function (ChainIndex) {
      var Result = 0;
      if (this.Chain(ChainIndex) != null) {
        Result = this.Chain(ChainIndex).GetCount()}
       else Result = 0;
      return Result;
    };
    this.FindOrCreateNew = function (aKey) {
      var Result = null;
      var hashCode = 0;
      var chn = null;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      chn = this.Chain(hashCode);
      if (chn != null) {
        if (chn.GetCount() > 0) for (var $l = 0, $end = chn.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (chn.GetItem(i).FKey === aKey) return chn.GetItem(i);
        };
      } else {
        this.FHashTable.SetItem(hashCode,$mod.TFPObjectList.$create("Create$2",[true]));
        chn = this.Chain(hashCode);
      };
      this.FCount += 1;
      Result = this.CreateNewNode(aKey);
      chn.Add(Result);
      return Result;
    };
    this.SetHashFunction = function (AHashFunction) {
      if (this.IsEmpty()) {
        this.FHashFunction = AHashFunction}
       else throw pas.SysUtils.Exception.$create("Create$1",[rtl.getResStr($mod,"NotEmptyMsg")]);
    };
    this.FindChainForAdd = function (aKey) {
      var Result = null;
      var hashCode = 0;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      Result = this.Chain(hashCode);
      if (Result != null) {
        if (Result.GetCount() > 0) for (var $l = 0, $end = Result.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (Result.GetItem(i).FKey === aKey) throw $mod.EDuplicate.$create("CreateFmt",[rtl.getResStr($mod,"DuplicateMsg"),pas.System.VarRecs(18,aKey)]);
        };
      } else {
        this.FHashTable.SetItem(hashCode,$mod.TFPObjectList.$create("Create$2",[true]));
        Result = this.Chain(hashCode);
      };
      this.FCount += 1;
      return Result;
    };
    this.Create$1 = function () {
      this.CreateWith(196613,$mod.RSHash);
      return this;
    };
    this.CreateWith = function (AHashTableSize, aHashFunc) {
      pas.System.TObject.Create.call(this);
      this.FHashTable = $mod.TFPObjectList.$create("Create$2",[true]);
      this.SetHashTableSize(AHashTableSize);
      this.FHashFunction = aHashFunc;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHashTable");
      pas.System.TObject.Destroy.call(this);
    };
    this.ChangeTableSize = function (ANewSize) {
      var SavedTable = null;
      var List = null;
      var SavedTableSize = 0;
      var i = 0;
      var j = 0;
      var temp = null;
      SavedTable = this.FHashTable;
      SavedTableSize = this.FHashTableSize;
      this.FHashTableSize = ANewSize;
      this.FHashTable = $mod.TFPObjectList.$create("Create$2",[true]);
      this.InitializeHashTable();
      if (SavedTableSize > 0) for (var $l = 0, $end = SavedTableSize - 1; $l <= $end; $l++) {
        i = $l;
        List = SavedTable.GetItem(i);
        if (List != null) for (var $l1 = 0, $end1 = List.GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          temp = List.GetItem(j);
          this.AddNode(temp);
        };
      };
      SavedTable = rtl.freeLoc(SavedTable);
    };
    this.Clear = function () {
      var i = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) this.Chain(i).Clear();
      };
      this.FCount = 0;
    };
    this.Delete = function (aKey) {
      var hashCode = 0;
      var chn = null;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      chn = this.Chain(hashCode);
      if (chn != null) if (chn.GetCount() > 0) for (var $l = 0, $end = chn.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (chn.GetItem(i).FKey === aKey) {
          chn.Delete(i);
          this.FCount -= 1;
          return;
        };
      };
    };
    this.Find = function (aKey) {
      var Result = null;
      var hashCode = 0;
      var chn = null;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      chn = this.Chain(hashCode);
      if (chn != null) if (chn.GetCount() > 0) for (var $l = 0, $end = chn.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (chn.GetItem(i).FKey === aKey) return chn.GetItem(i);
      };
      Result = null;
      return Result;
    };
    this.IsEmpty = function () {
      var Result = false;
      Result = this.FCount === 0;
      return Result;
    };
  });
  rtl.createClass(this,"THTDataNode",this.THTCustomNode,function () {
    this.$init = function () {
      $mod.THTCustomNode.$init.call(this);
      this.FData = undefined;
    };
  });
  this.$rtti.$MethodVar("TDataIteratorMethod",{procsig: rtl.newTIProcSig([["Item",rtl.jsvalue],["Key",rtl.string,2],["Continue",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ProcVar("TDataIteratorCallBack",{procsig: rtl.newTIProcSig([["Item",rtl.jsvalue],["Key",rtl.string,2],["Continue",rtl.boolean,1]])});
  rtl.createClass(this,"TFPDataHashTable",this.TFPCustomHashTable,function () {
    this.$init = function () {
      $mod.TFPCustomHashTable.$init.call(this);
      this.FIteratorCallBack = null;
    };
    this.$final = function () {
      this.FIteratorCallBack = undefined;
      $mod.TFPCustomHashTable.$final.call(this);
    };
    this.CallbackIterator = function (Item, Key, Continue) {
      this.FIteratorCallBack(Item,Key,Continue);
    };
    this.CreateNewNode = function (aKey) {
      var Result = null;
      Result = $mod.THTDataNode.$create("CreateWith",[aKey]);
      return Result;
    };
    this.AddNode = function (ANode) {
      this.Add(ANode.FKey,ANode.FData);
    };
    this.SetData = function (index, AValue) {
      this.FindOrCreateNew(index).FData = AValue;
    };
    this.GetData = function (index) {
      var Result = undefined;
      var node = null;
      node = this.Find(index);
      if (node != null) {
        Result = node.FData}
       else Result = null;
      return Result;
    };
    this.ForEachCall = function (aMethod) {
      var Result = null;
      var i = 0;
      var j = 0;
      var continue_ = false;
      Result = null;
      continue_ = true;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) if (this.Chain(i).GetCount() > 0) for (var $l1 = 0, $end1 = this.Chain(i).GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          aMethod(this.Chain(i).GetItem(j).FData,this.Chain(i).GetItem(j).FKey,{get: function () {
              return continue_;
            }, set: function (v) {
              continue_ = v;
            }});
          if (!continue_) {
            Result = this.Chain(i).GetItem(j);
            return Result;
          };
        };
      };
      return Result;
    };
    this.Iterate = function (aMethod) {
      var Result = undefined;
      var N = null;
      N = this.ForEachCall(aMethod);
      if (N != null) {
        Result = N.FData}
       else Result = null;
      return Result;
    };
    this.Iterate$1 = function (aMethod) {
      var Result = undefined;
      this.FIteratorCallBack = aMethod;
      Result = this.Iterate(rtl.createCallback(this,"CallbackIterator"));
      return Result;
    };
    this.Add = function (aKey, AItem) {
      var chn = null;
      var NewNode = null;
      chn = this.FindChainForAdd(aKey);
      NewNode = this.CreateNewNode(aKey);
      NewNode.FData = AItem;
      chn.Add(NewNode);
    };
  });
  rtl.createClass(this,"THTStringNode",this.THTCustomNode,function () {
    this.$init = function () {
      $mod.THTCustomNode.$init.call(this);
      this.FData = "";
    };
  });
  this.$rtti.$MethodVar("TStringIteratorMethod",{procsig: rtl.newTIProcSig([["Item",rtl.string],["Key",rtl.string,2],["Continue",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ProcVar("TStringIteratorCallback",{procsig: rtl.newTIProcSig([["Item",rtl.string],["Key",rtl.string,2],["Continue",rtl.boolean,1]])});
  rtl.createClass(this,"TFPStringHashTable",this.TFPCustomHashTable,function () {
    this.$init = function () {
      $mod.TFPCustomHashTable.$init.call(this);
      this.FIteratorCallBack = null;
    };
    this.$final = function () {
      this.FIteratorCallBack = undefined;
      $mod.TFPCustomHashTable.$final.call(this);
    };
    this.CallbackIterator = function (Item, Key, Continue) {
      this.FIteratorCallBack(Item,Key,Continue);
    };
    this.CreateNewNode = function (aKey) {
      var Result = null;
      Result = $mod.THTStringNode.$create("CreateWith",[aKey]);
      return Result;
    };
    this.AddNode = function (ANode) {
      this.Add(ANode.FKey,ANode.FData);
    };
    this.SetData = function (Index, AValue) {
      this.FindOrCreateNew(Index).FData = AValue;
    };
    this.GetData = function (index) {
      var Result = "";
      var node = null;
      node = this.Find(index);
      if (node != null) {
        Result = node.FData}
       else Result = "";
      return Result;
    };
    this.ForEachCall = function (aMethod) {
      var Result = null;
      var i = 0;
      var j = 0;
      var continue_ = false;
      Result = null;
      continue_ = true;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) if (this.Chain(i).GetCount() > 0) for (var $l1 = 0, $end1 = this.Chain(i).GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          aMethod(this.Chain(i).GetItem(j).FData,this.Chain(i).GetItem(j).FKey,{get: function () {
              return continue_;
            }, set: function (v) {
              continue_ = v;
            }});
          if (!continue_) {
            Result = this.Chain(i).GetItem(j);
            return Result;
          };
        };
      };
      return Result;
    };
    this.Iterate = function (aMethod) {
      var Result = "";
      var N = null;
      N = this.ForEachCall(aMethod);
      if (N != null) {
        Result = N.FData}
       else Result = "";
      return Result;
    };
    this.Iterate$1 = function (aMethod) {
      var Result = "";
      this.FIteratorCallBack = aMethod;
      Result = this.Iterate(rtl.createCallback(this,"CallbackIterator"));
      return Result;
    };
    this.Add = function (aKey, aItem) {
      var chn = null;
      var NewNode = null;
      chn = this.FindChainForAdd(aKey);
      NewNode = this.CreateNewNode(aKey);
      NewNode.FData = aItem;
      chn.Add(NewNode);
    };
  });
  rtl.createClass(this,"THTObjectNode",this.THTCustomNode,function () {
    this.$init = function () {
      $mod.THTCustomNode.$init.call(this);
      this.FData = null;
    };
    this.$final = function () {
      this.FData = undefined;
      $mod.THTCustomNode.$final.call(this);
    };
  });
  rtl.createClass(this,"THTOwnedObjectNode",this.THTObjectNode,function () {
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.$rtti.$MethodVar("TObjectIteratorMethod",{procsig: rtl.newTIProcSig([["Item",pas.System.$rtti["TObject"]],["Key",rtl.string,2],["Continue",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ProcVar("TObjectIteratorCallback",{procsig: rtl.newTIProcSig([["Item",pas.System.$rtti["TObject"]],["Key",rtl.string,2],["Continue",rtl.boolean,1]])});
  rtl.createClass(this,"TFPObjectHashTable",this.TFPCustomHashTable,function () {
    this.$init = function () {
      $mod.TFPCustomHashTable.$init.call(this);
      this.FOwnsObjects = false;
      this.FIteratorCallBack = null;
    };
    this.$final = function () {
      this.FIteratorCallBack = undefined;
      $mod.TFPCustomHashTable.$final.call(this);
    };
    this.CallbackIterator = function (Item, Key, Continue) {
      this.FIteratorCallBack(Item,Key,Continue);
    };
    this.CreateNewNode = function (aKey) {
      var Result = null;
      if (this.FOwnsObjects) {
        Result = $mod.THTOwnedObjectNode.$create("CreateWith",[aKey])}
       else Result = $mod.THTObjectNode.$create("CreateWith",[aKey]);
      return Result;
    };
    this.AddNode = function (ANode) {
      this.Add(ANode.FKey,ANode.FData);
    };
    this.SetData = function (Index, AObject) {
      this.FindOrCreateNew(Index).FData = AObject;
    };
    this.GetData = function (index) {
      var Result = null;
      var node = null;
      node = this.Find(index);
      if (node != null) {
        Result = node.FData}
       else Result = null;
      return Result;
    };
    this.ForEachCall = function (aMethod) {
      var Result = null;
      var i = 0;
      var j = 0;
      var continue_ = false;
      Result = null;
      continue_ = true;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) if (this.Chain(i).GetCount() > 0) for (var $l1 = 0, $end1 = this.Chain(i).GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          aMethod(this.Chain(i).GetItem(j).FData,this.Chain(i).GetItem(j).FKey,{get: function () {
              return continue_;
            }, set: function (v) {
              continue_ = v;
            }});
          if (!continue_) {
            Result = this.Chain(i).GetItem(j);
            return Result;
          };
        };
      };
      return Result;
    };
    this.Create$2 = function (AOwnsObjects) {
      $mod.TFPCustomHashTable.Create$1.call(this);
      this.FOwnsObjects = AOwnsObjects;
      return this;
    };
    this.CreateWith$1 = function (AHashTableSize, aHashFunc, AOwnsObjects) {
      $mod.TFPCustomHashTable.CreateWith.call(this,AHashTableSize,aHashFunc);
      this.FOwnsObjects = AOwnsObjects;
      return this;
    };
    this.Iterate = function (aMethod) {
      var Result = null;
      var N = null;
      N = this.ForEachCall(aMethod);
      if (N != null) {
        Result = N.FData}
       else Result = null;
      return Result;
    };
    this.Iterate$1 = function (aMethod) {
      var Result = null;
      this.FIteratorCallBack = aMethod;
      Result = this.Iterate(rtl.createCallback(this,"CallbackIterator"));
      return Result;
    };
    this.Add = function (aKey, AItem) {
      var chn = null;
      var NewNode = null;
      chn = this.FindChainForAdd(aKey);
      NewNode = this.CreateNewNode(aKey);
      NewNode.FData = AItem;
      chn.Add(NewNode);
    };
  });
  rtl.createClass(this,"EDuplicate",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EKeyNotFound",pas.SysUtils.Exception,function () {
  });
  var b = 378551;
  this.RSHash = function (S, TableSize) {
    var Result = 0;
    var a = 0;
    var i = 0;
    a = 63689;
    Result = 0;
    if (S.length > 0) for (var $l = 1, $end = S.length; $l <= $end; $l++) {
      i = $l;
      Result = (Result * a) + S.charCodeAt(i - 1);
      a = a * 378551;
    };
    Result = rtl.lw(Result & 0x7FFFFFFF) % TableSize;
    return Result;
  };
  rtl.recNewT(this,"TBucketItem",function () {
    this.Item = undefined;
    this.Data = undefined;
    this.$eq = function (b) {
      return (this.Item === b.Item) && (this.Data === b.Data);
    };
    this.$assign = function (s) {
      this.Item = s.Item;
      this.Data = s.Data;
      return this;
    };
    var $r = $mod.$rtti.$Record("TBucketItem",{},this);
    $r.addField("Item",rtl.jsvalue);
    $r.addField("Data",rtl.jsvalue);
  });
  this.$rtti.$DynArray("TBucketItemArray",{eltype: this.$rtti["TBucketItem"]});
  rtl.recNewT(this,"TBucket",function () {
    this.Count = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Items = [];
      return r;
    };
    this.$eq = function (b) {
      return (this.Count === b.Count) && (this.Items === b.Items);
    };
    this.$assign = function (s) {
      this.Count = s.Count;
      this.Items = rtl.arrayRef(s.Items);
      return this;
    };
    var $r = $mod.$rtti.$Record("TBucket",{},this);
    $r.addField("Count",rtl.longint);
    $r.addField("Items",$mod.$rtti["TBucketItemArray"]);
  });
  this.$rtti.$DynArray("TBucketArray",{eltype: this.$rtti["TBucket"]});
  this.$rtti.$RefToProcVar("TBucketProc",{procsig: rtl.newTIProcSig([["AInfo",rtl.jsvalue],["AItem",rtl.jsvalue],["AData",rtl.jsvalue],["AContinue",rtl.boolean,4]])});
  rtl.createClass(this,"TCustomBucketList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBuckets = [];
    };
    this.$final = function () {
      this.FBuckets = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetBucketCount = function () {
      var Result = 0;
      Result = rtl.length(this.FBuckets);
      return Result;
    };
    this.GetData = function (AItem) {
      var Result = undefined;
      var B = 0;
      var I = 0;
      this.GetBucketItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      Result = this.FBuckets[B].Items[I].Data;
      return Result;
    };
    this.SetData = function (AItem, AData) {
      var B = 0;
      var I = 0;
      this.GetBucketItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      this.FBuckets[B].Items[I].Data = AData;
    };
    this.SetBucketCount = function (Value) {
      if (Value !== this.GetBucketCount()) this.FBuckets = rtl.arraySetLength(this.FBuckets,$mod.TBucket,Value);
    };
    this.GetBucketItem = function (AItem, ABucket, AIndex) {
      if (!this.FindItem(AItem,ABucket,AIndex)) this.Error(rtl.getResStr($mod,"SErrNoSuchItem"),pas.System.VarRecs(20,AItem));
    };
    this.AddItem = function (ABucket, AItem, AData) {
      var Result = undefined;
      var L = 0;
      L = rtl.length(this.FBuckets[ABucket].Items);
      if (this.FBuckets[ABucket].Count === L) {
        if (L < 8) {
          L = 8}
         else L = L + rtl.trunc(L / 2);
        this.FBuckets[ABucket].Items = rtl.arraySetLength(this.FBuckets[ABucket].Items,$mod.TBucketItem,L);
      };
      var $with = this.FBuckets[ABucket];
      $with.Items[$with.Count].Item = AItem;
      $with.Items[$with.Count].Data = AData;
      Result = AData;
      $with.Count += 1;
      return Result;
    };
    this.DeleteItem = function (ABucket, AIndex) {
      var Result = undefined;
      var I = 0;
      var L = 0;
      Result = this.FBuckets[ABucket].Items[AIndex].Data;
      if (this.FBuckets[ABucket].Count === 1) {
        this.FBuckets[ABucket].Items = rtl.arraySetLength(this.FBuckets[ABucket].Items,$mod.TBucketItem,0)}
       else {
        L = this.FBuckets[ABucket].Count - AIndex - 1;
        for (var $l = 0, $end = L - 1; $l <= $end; $l++) {
          I = $l;
          this.FBuckets[ABucket].Items[AIndex + I].$assign(this.FBuckets[ABucket].Items[AIndex + I + 1]);
        };
      };
      this.FBuckets[ABucket].Count -= 1;
      return Result;
    };
    this.Error = function (Msg, Args) {
      throw pas.Classes.EListError.$create("CreateFmt",[Msg,Args]);
    };
    this.FindItem = function (AItem, ABucket, AIndex) {
      var Result = false;
      var I = 0;
      var B = $mod.TBucket.$new();
      ABucket.set(this.BucketFor(AItem));
      B.$assign(this.FBuckets[ABucket.get()]);
      I = B.Count - 1;
      while ((I >= 0) && (B.Items[I].Item != AItem)) I -= 1;
      Result = I >= 0;
      if (Result) AIndex.set(I);
      return Result;
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      var B = $mod.TBucket.$new();
      var I = 0;
      var J = 0;
      for (var $l = 0, $end = rtl.length(this.FBuckets) - 1; $l <= $end; $l++) {
        I = $l;
        B.$assign(this.FBuckets[I]);
        for (var $l1 = B.Count - 1; $l1 >= 0; $l1--) {
          J = $l1;
          this.DeleteItem(I,J);
        };
      };
      this.FBuckets = rtl.arraySetLength(this.FBuckets,$mod.TBucket,0);
    };
    this.Add = function (AItem, AData) {
      var Result = undefined;
      var B = 0;
      var I = 0;
      if (this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }})) this.Error(rtl.getResStr($mod,"SDuplicateItem"),pas.System.VarRecs(20,AItem));
      Result = this.AddItem(B,AItem,AData);
      return Result;
    };
    this.Assign = function (AList) {
      var I = 0;
      var J = 0;
      this.Clear();
      this.FBuckets = rtl.arraySetLength(this.FBuckets,$mod.TBucket,rtl.length(AList.FBuckets));
      for (var $l = 0, $end = this.GetBucketCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FBuckets[I].Items = rtl.arraySetLength(this.FBuckets[I].Items,$mod.TBucketItem,rtl.length(AList.FBuckets[I].Items));
        for (var $l1 = 0, $end1 = AList.FBuckets[I].Count - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          var $with = AList.FBuckets[I].Items[J];
          this.AddItem(I,$with.Item,$with.Data);
        };
      };
    };
    this.Exists = function (AItem) {
      var Result = false;
      var B = 0;
      var I = 0;
      Result = this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      return Result;
    };
    this.Find = function (AItem, AData) {
      var Result = false;
      var B = 0;
      var I = 0;
      Result = this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      if (Result) AData.set(this.FBuckets[B].Items[I].Data);
      return Result;
    };
    this.ForEach = function (AProc, AInfo) {
      var Result = false;
      var I = 0;
      var J = 0;
      var S = 0;
      var Bu = $mod.TBucket.$new();
      I = 0;
      Result = true;
      S = this.GetBucketCount();
      while (Result && (I < S)) {
        J = 0;
        Bu.$assign(this.FBuckets[I]);
        while (Result && (J < Bu.Count)) {
          var $with = Bu.Items[J];
          AProc(AInfo,$with.Item,$with.Data,{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }});
          J += 1;
        };
        I += 1;
      };
      return Result;
    };
    this.ForEach$1 = function (AProc) {
      var Result = false;
      Result = this.ForEach(AProc,null);
      return Result;
    };
    this.Remove = function (AItem) {
      var Result = undefined;
      var B = 0;
      var I = 0;
      if (this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }})) {
        Result = this.FBuckets[B].Items[I].Data;
        this.DeleteItem(B,I);
      } else Result = null;
      return Result;
    };
  });
  this.TBucketListSizes = {"0": "bl2", bl2: 0, "1": "bl4", bl4: 1, "2": "bl8", bl8: 2, "3": "bl16", bl16: 3, "4": "bl32", bl32: 4, "5": "bl64", bl64: 5, "6": "bl128", bl128: 6, "7": "bl256", bl256: 7};
  this.$rtti.$Enum("TBucketListSizes",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TBucketListSizes});
  rtl.createClass(this,"TBucketList",this.TCustomBucketList,function () {
    this.$init = function () {
      $mod.TCustomBucketList.$init.call(this);
      this.FBucketMask = 0;
    };
    this.BucketFor = function (AItem) {
      var Result = 0;
      Result = rtl.lw(rtl.lw(rtl.trunc(AItem) >>> 2) & this.FBucketMask);
      return Result;
    };
    this.Create$1 = function (ABuckets) {
      var L = 0;
      pas.System.TObject.Create.call(this);
      L = 1 << (ABuckets + 1);
      this.SetBucketCount(L);
      this.FBucketMask = L - 1;
      return this;
    };
  });
  rtl.createClass(this,"TObjectBucketList",this.TBucketList,function () {
    this.GetData$1 = function (AItem) {
      var Result = null;
      Result = rtl.getObject($mod.TCustomBucketList.GetData.call(this,AItem));
      return Result;
    };
    this.SetData$1 = function (AItem, AData) {
      $mod.TCustomBucketList.SetData.call(this,AItem,AData);
    };
    this.Add$1 = function (AItem, AData) {
      var Result = null;
      Result = rtl.getObject($mod.TCustomBucketList.Add.call(this,AItem,AData));
      return Result;
    };
    this.Remove$1 = function (AItem) {
      var Result = null;
      Result = rtl.getObject($mod.TCustomBucketList.Remove.call(this,AItem));
      return Result;
    };
  });
  $mod.$implcode = function () {
    $impl.NPRIMES = 28;
    $mod.$rtti.$StaticArray("PRIMELIST$a",{dims: [28], eltype: rtl.longword});
    $impl.PRIMELIST = [53,97,193,389,769,1543,3079,6151,12289,24593,49157,98317,196613,393241,786433,1572869,3145739,6291469,12582917,25165843,50331653,100663319,201326611,402653189,805306457,1610612741,3221225473,4294967291];
    rtl.createClass($impl,"TlistComponent",pas.Classes.TComponent,function () {
      this.$init = function () {
        pas.Classes.TComponent.$init.call(this);
        this.Flist = null;
      };
      this.$final = function () {
        this.Flist = undefined;
        pas.Classes.TComponent.$final.call(this);
      };
      this.Notification = function (AComponent, Operation) {
        if (Operation === pas.Classes.TOperation.opRemove) this.Flist.HandleFreeNotify(this,AComponent);
        pas.Classes.TComponent.Notification.apply(this,arguments);
      };
      rtl.addIntf(this,pas.System.IUnknown);
    });
    $mod.$resourcestrings = {DuplicateMsg: {org: "An item with key %0:s already exists"}, NotEmptyMsg: {org: "Hash table not empty."}, SErrNoSuchItem: {org: "No item in list for %p"}, SDuplicateItem: {org: "Item already exists in list: %p"}};
  };
},["JS"]);
rtl.module("WEBLib.Graphics",["System","Classes","Types","UITypes","Web","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.WEBDEFAULTFONT = "Arial";
  this.SysDefault = 0x20000000;
  this.clNone = -1;
  this.clBlack = 0x0;
  this.clMaroon = 0x80;
  this.clGreen = 0x8000;
  this.clOlive = 0x8080;
  this.clNavy = 0x800000;
  this.clPurple = 0x800080;
  this.clTeal = 0x808000;
  this.clGray = 0x808080;
  this.clSilver = 0xC0C0C0;
  this.clRed = 0xFF;
  this.clLime = 0xFF00;
  this.clYellow = 0xFFFF;
  this.clBlue = 0xFF0000;
  this.clFuchsia = 0xFF00FF;
  this.clAqua = 0xFFFF00;
  this.clLtGray = 0xC1C1C1;
  this.clDkGray = 0x818181;
  this.clWhite = 0xFFFFFF;
  this.clMoneyGreen = 0xC0DCC0;
  this.clSkyBlue = 0xF0CAA6;
  this.clCream = 0xF0FBFF;
  this.clMedGray = 0xA0A0A0;
  this.clDefault = 536870912;
  this.clBtnFace = 0xF0F0F0;
  this.clWindowText = 0x10101;
  this.clWindow = 0xFEFEFE;
  this.clHighlight = 0xD77800;
  this.clHighlightText = 0x30303;
  this.clInfoText = 0x20202;
  this.clInfoBk = 0xE1FFFF;
  this.clActiveCaption = 0xD1B499;
  this.clInactiveCaption = 0xDBCDBF;
  this.clInactiveCaptionText = 0x0;
  this.clHotLight = 0xCC6600;
  this.clScrollBar = 0xC8C8C8;
  this.clBackground = 15790320;
  this.clMenu = 15790320;
  this.clWindowFrame = 0x646464;
  this.clMenuText = 0;
  this.clCaptionText = 16777215;
  this.clActiveBorder = 0xB4B4B4;
  this.clAppWorkSpace = 0xABABAB;
  this.clBtnShadow = 0xA0A0A0;
  this.clGrayText = 0x6D6D6D;
  this.clBtnText = 0;
  this.clBtnHighlight = 16777215;
  this.cl3DDkShadow = 0x696969;
  this.cl3DLight = 0xE3E3E3;
  this.clMenuHighlight = 0xD77800;
  this.clMenuBar = 0xF0F0F0;
  this.clWebAliceblue = 0xFFF8F0;
  this.clWebAntiquewhite = 0xD7EBFA;
  this.clWebAqua = 0xFFFF00;
  this.clWebAquamarine = 0xD4FF7F;
  this.clWebAzure = 0xFFFFF0;
  this.clWebBeige = 0xDCF5F5;
  this.clWebBisque = 0xC4E4FF;
  this.clWebBlack = 0x0;
  this.clWebBlanchedalmond = 0xCDEBFF;
  this.clWebBlue = 0xFF0000;
  this.clWebBlueviolet = 0xE22B8A;
  this.clWebBrown = 0x2A2AA5;
  this.clWebBurlywood = 0x87B8DE;
  this.clWebCadetblue = 0xA09E5F;
  this.clWebChartreuse = 0xFF7F;
  this.clWebChocolate = 0x1E69D2;
  this.clWebCoral = 0x507FFF;
  this.clWebCornflowerblue = 0xED9564;
  this.clWebCornsilk = 0xDCF8FF;
  this.clWebCrimson = 0x3C14DC;
  this.clWebCyan = 0xFFFF00;
  this.clWebDarkblue = 0x8B0000;
  this.clWebDarkcyan = 0x8B8B00;
  this.clWebDarkgoldenrod = 0xB86B8;
  this.clWebDarkgray = 0xA9A9A9;
  this.clWebDarkgreen = 0x6400;
  this.clWebDarkgrey = 0xA9A9A9;
  this.clWebDarkkhaki = 0x6BB7BD;
  this.clWebDarkmagenta = 0x8B008B;
  this.clWebDarkolivegreen = 0x2F6B55;
  this.clWebDarkorange = 0x8CFF;
  this.clWebDarkorchid = 0xCC3299;
  this.clWebDarkred = 0x8B;
  this.clWebDarksalmon = 0x7A96E9;
  this.clWebDarkseagreen = 0x8FBC8F;
  this.clWebDarkslateblue = 0x8B3D48;
  this.clWebDarkslategray = 0x4F4F2F;
  this.clWebDarkslategrey = 0x4F4F2F;
  this.clWebDarkturquoise = 0xD1CE00;
  this.clWebDarkviolet = 0xD30094;
  this.clWebDeeppink = 0x9314FF;
  this.clWebDeepskyblue = 0xFFBF00;
  this.clWebDimgray = 0x696969;
  this.clWebDimgrey = 0x696969;
  this.clWebDodgerblue = 0xFF901E;
  this.clWebFirebrick = 0x2222B2;
  this.clWebFloralwhite = 0xF0FAFF;
  this.clWebForestgreen = 0x228B22;
  this.clWebFuchsia = 0xFF00FF;
  this.clWebGainsboro = 0xDCDCDC;
  this.clWebGhostwhite = 0xFFF8F8;
  this.clWebGold = 0xD7FF;
  this.clWebGoldenrod = 0x20A5DA;
  this.clWebGray = 0x808080;
  this.clWebGreen = 0x8000;
  this.clWebGreenyellow = 0x2FFFAD;
  this.clWebGrey = 0x808080;
  this.clWebHoneydew = 0xF0FFF0;
  this.clWebHotpink = 0xB469FF;
  this.clWebIndianred = 0x5C5CCD;
  this.clWebIndigo = 0x82004B;
  this.clWebIvory = 0xF0FFFF;
  this.clWebKhaki = 0x8CE6F0;
  this.clWebLavender = 0xFAE6E6;
  this.clWebLavenderblush = 0xF5F0FF;
  this.clWebLawngreen = 0xFC7C;
  this.clWebLemonchiffon = 0xCDFAFF;
  this.clWebLightblue = 0xE6D8AD;
  this.clWebLightcoral = 0x8080F0;
  this.clWebLightcyan = 0xFFFFE0;
  this.clWebLightgoldenrodyellow = 0xD2FAFA;
  this.clWebLightgray = 0xD3D3D3;
  this.clWebLightgreen = 0x90EE90;
  this.clWebLightgrey = 0xD3D3D3;
  this.clWebLightpink = 0xC1B6FF;
  this.clWebLightsalmon = 0x7AA0FF;
  this.clWebLightseagreen = 0xAAB220;
  this.clWebLightskyblue = 0xFACE87;
  this.clWebLightslategray = 0x998877;
  this.clWebLightslategrey = 0x998877;
  this.clWebLightsteelblue = 0xDEC4B0;
  this.clWebLightyellow = 0xE0FFFF;
  this.clWebLtGray = 0xC0C0C0;
  this.clWebMedGray = 0xA4A0A0;
  this.clWebDkGray = 0x808080;
  this.clWebMoneyGreen = 0xC0DCC0;
  this.clWebLegacySkyBlue = 0xF0CAA6;
  this.clWebCream = 0xF0FBFF;
  this.clWebLime = 0xFF00;
  this.clWebLimegreen = 0x32CD32;
  this.clWebLinen = 0xE6F0FA;
  this.clWebMagenta = 0xFF00FF;
  this.clWebMaroon = 0x80;
  this.clWebMediumaquamarine = 0xAACD66;
  this.clWebMediumblue = 0xCD0000;
  this.clWebMediumorchid = 0xD355BA;
  this.clWebMediumpurple = 0xDB7093;
  this.clWebMediumseagreen = 0x71B33C;
  this.clWebMediumslateblue = 0xEE687B;
  this.clWebMediumspringgreen = 0x9AFA00;
  this.clWebMediumturquoise = 0xCCD148;
  this.clWebMediumvioletred = 0x8515C7;
  this.clWebMidnightblue = 0x701919;
  this.clWebMintcream = 0xFAFFF5;
  this.clWebMistyrose = 0xE1E4FF;
  this.clWebMoccasin = 0xB5E4FF;
  this.clWebNavajowhite = 0xADDEFF;
  this.clWebNavy = 0x800000;
  this.clWebOldlace = 0xE6F5FD;
  this.clWebOlive = 0x8080;
  this.clWebOlivedrab = 0x238E6B;
  this.clWebOrange = 0xA5FF;
  this.clWebOrangered = 0x45FF;
  this.clWebOrchid = 0xD670DA;
  this.clWebPalegoldenrod = 0xAAE8EE;
  this.clWebPalegreen = 0x98FB98;
  this.clWebPaleturquoise = 0xEEEEAF;
  this.clWebPalevioletred = 0x9370DB;
  this.clWebPapayawhip = 0xD5EFFF;
  this.clWebPeachpuff = 0xB9DAFF;
  this.clWebPeru = 0x3F85CD;
  this.clWebPink = 0xCBC0FF;
  this.clWebPlum = 0xDDA0DD;
  this.clWebPowderblue = 0xE6E0B0;
  this.clWebPurple = 0x800080;
  this.clWebRed = 0xFF;
  this.clWebRosybrown = 0x8F8FBC;
  this.clWebRoyalblue = 0xE16941;
  this.clWebSaddlebrown = 0x13458B;
  this.clWebSalmon = 0x7280FA;
  this.clWebSandybrown = 0x60A4F4;
  this.clWebSeagreen = 0x578B2E;
  this.clWebSeashell = 0xEEF5FF;
  this.clWebSienna = 0x2D52A0;
  this.clWebSilver = 0xC0C0C0;
  this.clWebSkyblue = 0xEBCE87;
  this.clWebSlateblue = 0xCD5A6A;
  this.clWebSlategray = 0x908070;
  this.clWebSlategrey = 0x908070;
  this.clWebSnow = 0xFAFAFF;
  this.clWebSpringgreen = 0x7FFF00;
  this.clWebSteelblue = 0xB48246;
  this.clWebTan = 0x8CB4D2;
  this.clWebTeal = 0x808000;
  this.clWebThistle = 0xD8BFD8;
  this.clWebTomato = 0x4763FF;
  this.clWebTurquoise = 0xD0E040;
  this.clWebViolet = 0xEE82EE;
  this.clWebWheat = 0xB3DEF5;
  this.clWebWhite = 0xFFFFFF;
  this.clWebWhitesmoke = 0xF5F5F5;
  this.clWebYellow = 0xFFFF;
  this.clWebYellowgreen = 0x32CD9A;
  this.clAliceblue = 0xFFF8F0;
  this.clAntiquewhite = 0xD7EBFA;
  this.clAquamarine = 0xD4FF7F;
  this.clAzure = 0xFFFFF0;
  this.clBeige = 0xDCF5F5;
  this.clBisque = 0xC4E4FF;
  this.clBlanchedalmond = 0xCDEBFF;
  this.clBlueviolet = 0xE22B8A;
  this.clBrown = 0x2A2AA5;
  this.clBurlywood = 0x87B8DE;
  this.clCadetblue = 0xA09E5F;
  this.clChartreuse = 0xFF7F;
  this.clChocolate = 0x1E69D2;
  this.clCoral = 0x507FFF;
  this.clCornflowerblue = 0xED9564;
  this.clCornsilk = 0xDCF8FF;
  this.clCrimson = 0x3C14DC;
  this.clCyan = 0xFFFF00;
  this.clDarkblue = 0x8B0000;
  this.clDarkcyan = 0x8B8B00;
  this.clDarkgoldenrod = 0xB86B8;
  this.clDarkgray = 0xA9A9A9;
  this.clDarkgreen = 0x6400;
  this.clDarkgrey = 0xA9A9A9;
  this.clDarkkhaki = 0x6BB7BD;
  this.clDarkmagenta = 0x8B008B;
  this.clDarkolivegreen = 0x2F6B55;
  this.clDarkorange = 0x8CFF;
  this.clDarkorchid = 0xCC3299;
  this.clDarkred = 0x8B;
  this.clDarksalmon = 0x7A96E9;
  this.clDarkseagreen = 0x8FBC8F;
  this.clDarkslateblue = 0x8B3D48;
  this.clDarkslategray = 0x4F4F2F;
  this.clDarkslategrey = 0x4F4F2F;
  this.clDarkturquoise = 0xD1CE00;
  this.clDarkviolet = 0xD30094;
  this.clDeeppink = 0x9314FF;
  this.clDeepskyblue = 0xFFBF00;
  this.clDimgray = 0x696969;
  this.clDimgrey = 0x696969;
  this.clDodgerblue = 0xFF901E;
  this.clFirebrick = 0x2222B2;
  this.clFloralwhite = 0xF0FAFF;
  this.clForestgreen = 0x228B22;
  this.clGainsboro = 0xDCDCDC;
  this.clGhostwhite = 0xFFF8F8;
  this.clGold = 0xD7FF;
  this.clGoldenrod = 0x20A5DA;
  this.clGreenyellow = 0x2FFFAD;
  this.clGrey = 0x808080;
  this.clHoneydew = 0xF0FFF0;
  this.clHotpink = 0xB469FF;
  this.clIndianred = 0x5C5CCD;
  this.clIndigo = 0x82004B;
  this.clIvory = 0xF0FFFF;
  this.clKhaki = 0x8CE6F0;
  this.clLavender = 0xFAE6E6;
  this.clLavenderblush = 0xF5F0FF;
  this.clLawngreen = 0xFC7C;
  this.clLemonchiffon = 0xCDFAFF;
  this.clLightblue = 0xE6D8AD;
  this.clLightcoral = 0x8080F0;
  this.clLightcyan = 0xFFFFE0;
  this.clLightgoldenrodyellow = 0xD2FAFA;
  this.clLightgray = 0xD3D3D3;
  this.clLightgreen = 0x90EE90;
  this.clLightgrey = 0xD3D3D3;
  this.clLightpink = 0xC1B6FF;
  this.clLightsalmon = 0x7AA0FF;
  this.clLightseagreen = 0xAAB220;
  this.clLightskyblue = 0xFACE87;
  this.clLightslategray = 0x998877;
  this.clLightslategrey = 0x998877;
  this.clLightsteelblue = 0xDEC4B0;
  this.clLightyellow = 0xE0FFFF;
  this.clLegacySkyBlue = 0xF0CAA6;
  this.clLimegreen = 0x32CD32;
  this.clLinen = 0xE6F0FA;
  this.clMagenta = 0xFF00FF;
  this.clMediumaquamarine = 0xAACD66;
  this.clMediumblue = 0xCD0000;
  this.clMediumorchid = 0xD355BA;
  this.clMediumpurple = 0xDB7093;
  this.clMediumseagreen = 0x71B33C;
  this.clMediumslateblue = 0xEE687B;
  this.clMediumspringgreen = 0x9AFA00;
  this.clMediumturquoise = 0xCCD148;
  this.clMediumvioletred = 0x8515C7;
  this.clMidnightblue = 0x701919;
  this.clMintcream = 0xFAFFF5;
  this.clMistyrose = 0xE1E4FF;
  this.clMoccasin = 0xB5E4FF;
  this.clNavajowhite = 0xADDEFF;
  this.clOldlace = 0xE6F5FD;
  this.clOlivedrab = 0x238E6B;
  this.clOrange = 0xA5FF;
  this.clOrangered = 0x45FF;
  this.clOrchid = 0xD670DA;
  this.clPalegoldenrod = 0xAAE8EE;
  this.clPalegreen = 0x98FB98;
  this.clPaleturquoise = 0xEEEEAF;
  this.clPalevioletred = 0x9370DB;
  this.clPapayawhip = 0xD5EFFF;
  this.clPeachpuff = 0xB9DAFF;
  this.clPeru = 0x3F85CD;
  this.clPink = 0xCBC0FF;
  this.clPlum = 0xDDA0DD;
  this.clPowderblue = 0xE6E0B0;
  this.clRosybrown = 0x8F8FBC;
  this.clRoyalblue = 0xE16941;
  this.clSaddlebrown = 0x13458B;
  this.clSalmon = 0x7280FA;
  this.clSandybrown = 0x60A4F4;
  this.clSeagreen = 0x578B2E;
  this.clSeashell = 0xEEF5FF;
  this.clSienna = 0x2D52A0;
  this.clSlateblue = 0xCD5A6A;
  this.clSlategray = 0x908070;
  this.clSlategrey = 0x908070;
  this.clSnow = 0xFAFAFF;
  this.clSpringgreen = 0x7FFF00;
  this.clSteelblue = 0xB48246;
  this.clTan = 0x8CB4D2;
  this.clThistle = 0xD8BFD8;
  this.clTomato = 0x4763FF;
  this.clTurquoise = 0xD0E040;
  this.clViolet = 0xEE82EE;
  this.clWheat = 0xB3DEF5;
  this.clWhitesmoke = 0xF5F5F5;
  this.clYellowgreen = 0x32CD9A;
  this.clInactiveBorder = 0xFCF7F4;
  this.ANSI_CHARSET = 0;
  this.DEFAULT_CHARSET = 1;
  this.SYMBOL_CHARSET = 2;
  this.MAC_CHARSET = 77;
  this.SHIFTJIS_CHARSET = 128;
  this.HANGEUL_CHARSET = 129;
  this.JOHAB_CHARSET = 130;
  this.GB2312_CHARSET = 134;
  this.CHINESEBIG5_CHARSET = 136;
  this.GREEK_CHARSET = 161;
  this.TURKISH_CHARSET = 162;
  this.HEBREW_CHARSET = 177;
  this.ARABIC_CHARSET = 178;
  this.BALTIC_CHARSET = 186;
  this.RUSSIAN_CHARSET = 204;
  this.THAI_CHARSET = 222;
  this.EASTEUROPE_CHARSET = 238;
  this.OEM_CHARSET = 255;
  this.$rtti.$inherited("TColor",rtl.nativeint,{});
  this.TVerticalAlignment = {"0": "taAlignTop", taAlignTop: 0, "1": "taAlignBottom", taAlignBottom: 1, "2": "taVerticalCenter", taVerticalCenter: 2};
  this.$rtti.$Enum("TVerticalAlignment",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TVerticalAlignment});
  this.TPenStyle = {"0": "psSolid", psSolid: 0, "1": "psDash", psDash: 1, "2": "psDot", psDot: 2, "3": "psDashDot", psDashDot: 3, "4": "psDashDotDot", psDashDotDot: 4, "5": "psClear", psClear: 5, "6": "psInsideFrame", psInsideFrame: 6, "7": "psUserStyle", psUserStyle: 7, "8": "psAlternate", psAlternate: 8};
  this.$rtti.$Enum("TPenStyle",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TPenStyle});
  this.TPenMode = {"0": "pmBlack", pmBlack: 0, "1": "pmWhite", pmWhite: 1, "2": "pmNop", pmNop: 2, "3": "pmNot", pmNot: 3, "4": "pmCopy", pmCopy: 4, "5": "pmNotCopy", pmNotCopy: 5, "6": "pmMergePenNot", pmMergePenNot: 6, "7": "pmMaskPenNot", pmMaskPenNot: 7, "8": "pmMergeNotPen", pmMergeNotPen: 8, "9": "pmMaskNotPen", pmMaskNotPen: 9, "10": "pmMerge", pmMerge: 10, "11": "pmNotMerge", pmNotMerge: 11, "12": "pmMask", pmMask: 12, "13": "pmNotMask", pmNotMask: 13, "14": "pmXor", pmXor: 14, "15": "pmNotXor", pmNotXor: 15};
  this.$rtti.$Enum("TPenMode",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TPenMode});
  this.TBrushStyle = {"0": "bsSolid", bsSolid: 0, "1": "bsClear", bsClear: 1, "2": "bsHorizontal", bsHorizontal: 2, "3": "bsVertical", bsVertical: 3, "4": "bsFDiagonal", bsFDiagonal: 4, "5": "bsBDiagonal", bsBDiagonal: 5, "6": "bsCross", bsCross: 6, "7": "bsDiagCross", bsDiagCross: 7};
  this.$rtti.$Enum("TBrushStyle",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TBrushStyle});
  this.TBrushGradient = {"0": "bgNone", bgNone: 0, "1": "bgLinearVert", bgLinearVert: 1, "2": "bgLinearHorz", bgLinearHorz: 2, "3": "bgRadial", bgRadial: 3};
  this.$rtti.$Enum("TBrushGradient",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBrushGradient});
  this.TFontStyle = {"0": "fsBold", fsBold: 0, "1": "fsItalic", fsItalic: 1, "2": "fsStrikeOut", fsStrikeOut: 2, "3": "fsUnderline", fsUnderline: 3};
  this.$rtti.$Enum("TFontStyle",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TFontStyle});
  this.$rtti.$Set("TFontStyles",{comptype: this.$rtti["TFontStyle"]});
  this.$rtti.$Int("TFontCharset",{minvalue: 0, maxvalue: 255, ordtype: 3});
  this.TTextFormats = {"0": "tfBottom", tfBottom: 0, "1": "tfCalcRect", tfCalcRect: 1, "2": "tfCenter", tfCenter: 2, "3": "tfEditControl", tfEditControl: 3, "4": "tfEndEllipsis", tfEndEllipsis: 4, "5": "tfPathEllipsis", tfPathEllipsis: 5, "6": "tfExpandTabs", tfExpandTabs: 6, "7": "tfExternalLeading", tfExternalLeading: 7, "8": "tfLeft", tfLeft: 8, "9": "tfModifyString", tfModifyString: 9, "10": "tfNoClip", tfNoClip: 10, "11": "tfNoPrefix", tfNoPrefix: 11, "12": "tfRight", tfRight: 12, "13": "tfRtlReading", tfRtlReading: 13, "14": "tfSingleLine", tfSingleLine: 14, "15": "tfTop", tfTop: 15, "16": "tfVerticalCenter", tfVerticalCenter: 16, "17": "tfWordBreak", tfWordBreak: 17, "18": "tfHidePrefix", tfHidePrefix: 18, "19": "tfNoFullWidthCharBreak", tfNoFullWidthCharBreak: 19, "20": "tfPrefixOnly", tfPrefixOnly: 20, "21": "tfTabStop", tfTabStop: 21, "22": "tfWordEllipsis", tfWordEllipsis: 22, "23": "tfComposited", tfComposited: 23};
  this.$rtti.$Enum("TTextFormats",{minvalue: 0, maxvalue: 23, ordtype: 1, enumtype: this.TTextFormats});
  this.$rtti.$Set("TTextFormat",{comptype: this.$rtti["TTextFormats"]});
  this.$rtti.$inherited("TBinaryString",rtl.string,{});
  rtl.recNewT(this,"TCanvasPointF",function () {
    this.X = 0.0;
    this.Y = 0.0;
    this.$eq = function (b) {
      return (this.X === b.X) && (this.Y === b.Y);
    };
    this.$assign = function (s) {
      this.X = s.X;
      this.Y = s.Y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCanvasPointF",{},this);
    $r.addField("X",rtl.double);
    $r.addField("Y",rtl.double);
  });
  rtl.recNewT(this,"TCanvasRectF",function () {
    this.Left = 0.0;
    this.Top = 0.0;
    this.Right = 0.0;
    this.Bottom = 0.0;
    this.$eq = function (b) {
      return (this.Left === b.Left) && (this.Top === b.Top) && (this.Right === b.Right) && (this.Bottom === b.Bottom);
    };
    this.$assign = function (s) {
      this.Left = s.Left;
      this.Top = s.Top;
      this.Right = s.Right;
      this.Bottom = s.Bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCanvasRectF",{},this);
    $r.addField("Left",rtl.double);
    $r.addField("Top",rtl.double);
    $r.addField("Right",rtl.double);
    $r.addField("Bottom",rtl.double);
  });
  rtl.recNewT(this,"TCanvasSizeF",function () {
    this.cx = 0.0;
    this.cy = 0.0;
    this.$eq = function (b) {
      return (this.cx === b.cx) && (this.cy === b.cy);
    };
    this.$assign = function (s) {
      this.cx = s.cx;
      this.cy = s.cy;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCanvasSizeF",{},this);
    $r.addField("cx",rtl.double);
    $r.addField("cy",rtl.double);
  });
  rtl.createClass(this,"TPen",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FWidth = 0;
      this.FColor = 0;
      this.FStyle = 0;
      this.FMode = 0;
    };
    this.SetColor = function (Value) {
      this.FColor = Value;
    };
    this.Create$1 = function () {
      this.FColor = 0;
      this.FWidth = 1;
      this.FStyle = $mod.TPenStyle.psSolid;
      this.FMode = $mod.TPenMode.pmCopy;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TPen.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TPen).FColor;
        this.FStyle = rtl.as(Source,$mod.TPen).FStyle;
        this.FWidth = rtl.as(Source,$mod.TPen).FWidth;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Color",2,$mod.$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Mode",0,$mod.$rtti["TPenMode"],"FMode","FMode",4,{Default: $mod.TPenMode.pmCopy});
    $r.addProperty("Width",0,rtl.longint,"FWidth","FWidth",4,{Default: 1});
    $r.addProperty("Style",0,$mod.$rtti["TPenStyle"],"FStyle","FStyle",4,{Default: $mod.TPenStyle.psSolid});
  });
  rtl.createClass(this,"TGradientColor",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FColor = 0;
      this.FStop = 0.0;
    };
    this.Assign = function (Source) {
      if ($mod.TGradientColor.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TGradientColor).FColor;
        this.FStop = rtl.as(Source,$mod.TGradientColor).FStop;
      };
    };
    this.Create$1 = function () {
      this.FColor = -1;
      this.FStop = 0;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Stop",0,rtl.double,"FStop","FStop");
    $r.addProperty("Color",0,$mod.$rtti["TColor"],"FColor","FColor",4,{Default: -1});
  });
  rtl.createClass(this,"TBrush",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FColor = 0;
      this.FStyle = 0;
      this.FGradientColors = null;
      this.FGradient = 0;
    };
    this.$final = function () {
      this.FGradientColors = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function () {
      this.FColor = 16777215;
      this.FStyle = $mod.TBrushStyle.bsSolid;
      this.FGradient = $mod.TBrushGradient.bgNone;
      this.FGradientColors = pas.Classes.TList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FGradientColors");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TBrush.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TBrush).FColor;
        this.FStyle = rtl.as(Source,$mod.TBrush).FStyle;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.AddGradientColor = function (AColor, AStop) {
      var gr = null;
      gr = $mod.TGradientColor.$create("Create$1");
      gr.FColor = AColor;
      gr.FStop = AStop;
      this.FGradientColors.Add(gr);
    };
    this.GetGradientColor = function (AIndex, AColor, AStop) {
      if (AIndex < this.FGradientColors.GetCount()) {
        AColor.set(rtl.getObject(this.FGradientColors.Get(AIndex)).FColor);
        AStop.set(rtl.getObject(this.FGradientColors.Get(AIndex)).FStop);
      } else throw pas.SysUtils.Exception.$create("Create$1",["Invalid gradient color index"]);
    };
    this.GradientCount = function () {
      var Result = 0;
      Result = this.FGradientColors.GetCount();
      return Result;
    };
    this.ClearGradient = function () {
      var i = 0;
      var gr = null;
      for (var $l = this.FGradientColors.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        gr = rtl.getObject(this.FGradientColors.Get(i));
        gr = rtl.freeLoc(gr);
        this.FGradientColors.Delete(i);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Gradient",0,$mod.$rtti["TBrushGradient"],"FGradient","FGradient");
    $r.addProperty("Color",0,$mod.$rtti["TColor"],"FColor","FColor");
    $r.addProperty("Style",0,$mod.$rtti["TBrushStyle"],"FStyle","FStyle");
  });
  rtl.createClass(this,"TFont",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FName = "";
      this.FSize = 0;
      this.FColor = 0;
      this.FStyle = {};
      this.FOnChange = null;
      this.FHeight = 0;
      this.FCharset = 0;
      this.FOrientation = 0;
    };
    this.$final = function () {
      this.FStyle = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHeight = function (Value) {
      var d = 0.0;
      d = (-Value * 72) / 96;
      this.FSize = Math.round(d);
      if (this.FHeight !== Value) {
        this.FHeight = Value;
        this.DoChange();
      };
    };
    this.SetName = function (AName) {
      if (this.FName !== AName) {
        this.FName = AName;
        this.DoChange();
      };
    };
    this.SetSize = function (ASize) {
      if (this.FSize !== ASize) {
        this.FSize = ASize;
        this.DoChange();
      };
    };
    this.SetColor = function (AColor) {
      if (this.FColor !== AColor) {
        this.FColor = AColor;
        this.DoChange();
      };
    };
    this.SetStyle = function (AStyle) {
      if (rtl.neSet(this.FStyle,AStyle)) {
        this.FStyle = rtl.refSet(AStyle);
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Assign = function (Source) {
      if ($mod.TFont.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,$mod.TFont).FName;
        this.FColor = rtl.as(Source,$mod.TFont).FColor;
        this.FSize = rtl.as(Source,$mod.TFont).FSize;
        this.FStyle = rtl.refSet(rtl.as(Source,$mod.TFont).FStyle);
        this.DoChange();
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FName = $mod.WEBDEFAULTFONT;
      this.FSize = 8;
      this.FHeight = -11;
      this.FStyle = {};
      this.FColor = 0;
      return this;
    };
    this.ToString = function () {
      var Result = "";
      var s = "";
      s = "";
      if (($mod.TFontStyle.fsBold in this.FStyle) && ($mod.TFontStyle.fsItalic in this.FStyle)) {
        s = s + "bold italic"}
       else if ($mod.TFontStyle.fsBold in this.FStyle) {
        s = s + "bold"}
       else if ($mod.TFontStyle.fsItalic in this.FStyle) s = s + "italic";
      if (this.FSize !== 0) {
        Result = s + " " + $mod.FontSizeToHTML($mod.FontSizeToPx(this.FSize)) + " " + this.FName}
       else Result = s + " " + $mod.FontSizeToHTML($mod.FontSizeToPx(12)) + " " + this.FName;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Charset",0,$mod.$rtti["TFontCharset"],"FCharset","FCharset");
    $r.addProperty("Name",2,pas.UITypes.$rtti["TFontName"],"FName","SetName");
    $r.addProperty("Height",2,rtl.longint,"FHeight","SetHeight");
    $r.addProperty("Style",2,$mod.$rtti["TFontStyles"],"FStyle","SetStyle");
    $r.addProperty("Color",2,$mod.$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize");
  });
  this.TImageType = {"0": "itBase64", itBase64: 0, "1": "itBMP", itBMP: 1, "2": "itPNG", itPNG: 2, "3": "itJPEG", itJPEG: 3, "4": "itGIF", itGIF: 4, "5": "itSVG", itSVG: 5};
  this.$rtti.$Enum("TImageType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TImageType});
  this.$rtti.$Class("TCanvas");
  this.$rtti.$Class("TBitmap");
  this.$rtti.$RefToProcVar("TBitmapLoadedProc",{procsig: rtl.newTIProcSig([])});
  rtl.createClass(this,"TGraphic",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FAddToQueue = false;
      this.FCanvasElement = null;
      this.FEmpty = false;
      this.FData = "";
      this.FDataBin = "";
      this.FCanvas = null;
      this.FOnChange = null;
      this.FImage = null;
      this.FBitmap = null;
      this.FURL = "";
      this.FLoaded = null;
      this.FUsedCanvas = false;
    };
    this.$final = function () {
      this.FCanvasElement = undefined;
      this.FCanvas = undefined;
      this.FOnChange = undefined;
      this.FImage = undefined;
      this.FBitmap = undefined;
      this.FLoaded = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHeight = function (Value) {
      this.FImage.height = Value;
      this.RecreateCanvas();
      this.DoChange();
    };
    this.SetWidth = function (Value) {
      this.FImage.width = Value;
      this.RecreateCanvas();
      this.DoChange();
    };
    this.GetCanvas = function () {
      var Result = null;
      if (!(this.FCanvas != null)) this.RecreateCanvas();
      Result = this.FCanvas;
      this.FUsedCanvas = true;
      return Result;
    };
    this.GetData = function () {
      var Result = "";
      Result = this.FDataBin;
      return Result;
    };
    this.SetData = function (Value) {
      var hx = "";
      if (this.FDataBin !== Value) {
        this.FDataBin = Value;
        hx = pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FDataBin);
        if (pas.System.Pos("PHN2ZyB",hx) > 0) {
          this.LoadFromResource("data:image/svg+xml;base64," + hx)}
         else this.LoadFromResource("data:image/png;base64," + hx);
      };
    };
    this.DoChange = function () {
      var i = 0;
      this.FEmpty = (this.GetWidth() === 0) && (this.GetHeight() === 0);
      if (!this.FEmpty && (this.FData !== "") && !$impl.FCache.Exists(this.FData)) {
        $impl.FCache.Add$1($impl.TGraphicCache.$create("Create$1",[this.FImage,this.FData]));
        i = $impl.FQueue.IndexOf(this.FData);
        if ((i >= 0) && (i <= ($impl.FQueue.GetCount() - 1))) $impl.FQueue.Delete(i);
        $impl.FCacheCount -= 1;
        if ($impl.FCacheCount === 0) {
          if (pas["WEBLib.Forms"].Application.FOnImageCacheReady != null) pas["WEBLib.Forms"].Application.FOnImageCacheReady(pas["WEBLib.Forms"].Application);
        };
      };
      if (this.FOnChange != null) {
        this.FOnChange(this);
      };
      if (this.FLoaded != null) {
        this.FLoaded();
        this.FLoaded = null;
      };
    };
    this.SetURL = function (URL) {
      this.FURL = URL;
      this.LoadFromURL(URL,null);
    };
    this.GetWidth = function () {
      var Result = 0;
      var w = 0;
      w = 0;
      if (this.FImage != null) {
        w = this.FImage.width;
      };
      Result = w;
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      var h = 0;
      h = 0;
      if (this.FImage != null) {
        h = this.FImage.height;
      };
      Result = h;
      return Result;
    };
    this.RecreateCanvas = function () {
      if (!(this.FCanvasElement != null)) this.FCanvasElement = document.createElement("CANVAS");
      if (this.FCanvasElement != null) {
        this.FCanvasElement.height = this.GetHeight();
        this.FCanvasElement.width = this.GetWidth();
        if (!(this.FCanvas != null)) {
          this.FCanvas = $mod.TCanvas.$create("Create$1",[this.FCanvasElement]);
          this.FCanvas.FOnBeginScene = rtl.createCallback(this,"DoBeginScene");
          this.FCanvas.FOnEndScene = rtl.createCallback(this,"DoEndScene");
        };
      };
    };
    this.DoBeginScene = function (Sender) {
      this.FCanvas.Clear();
    };
    this.DoEndScene = function (Sender) {
      this.FAddToQueue = false;
      this.CaptureCanvas();
      this.FAddToQueue = true;
    };
    this.AssignEvents = function () {
      var me = this;
      this.FImage.onload = function() {
         me.DoChange();
        };
    };
    this.CreateImage = function () {
      this.FImage = new Image();
    };
    this.LoadFromCache = function (AData, ALoaded) {
      var dt = "";
      var o = null;
      var b = false;
      var s = "";
      var l = false;
      this.FData = AData;
      if (pas.System.Pos("DATA:",pas.SysUtils.UpperCase(AData)) > 0) {
        this.FDataBin = pas["WEBLib.WebTools"].HexImageEncodeFromBase64(AData);
      };
      dt = AData;
      if (dt === "") return;
      this.FLoaded = ALoaded;
      this.FUsedCanvas = false;
      if (!$impl.FCache.Find(dt,{get: function () {
          return o;
        }, set: function (v) {
          o = v;
        }})) {
        b = false;
        s = "";
        s = this.FImage.src;
        b = (s != '');
        l = b && (dt !== s);
        if (l) {
          this.CreateImage();
          this.AssignEvents();
        };
        if ((!l && ($impl.FQueue.IndexOf(dt) === -1)) || l) {
          this.FImage.src = dt;
          dt = this.FImage.src;
          this.FData = dt;
          if (pas.System.Pos("DATA:",pas.SysUtils.UpperCase(dt)) > 0) this.FDataBin = pas["WEBLib.WebTools"].HexImageEncodeFromBase64(dt);
          $impl.FCacheCount += 1;
          if (this.FAddToQueue) $impl.FQueue.Add(dt);
        } else if (!l && ($impl.FQueue.IndexOf(dt) !== -1)) {
          this.FImage.src = dt;
        };
      } else {
        this.FImage = o;
        this.DoChange();
      };
      if (this.FImage) {
        this.FEmpty = (this.FImage.src == '');
      };
    };
    this.CreateFromResource = function (AResource) {
      var Result = null;
      Result = this.CreateFromResource$1(AResource,0);
      return Result;
    };
    this.CreateFromResource$1 = function (AResource, AInstance) {
      var Result = null;
      Result = $mod.TGraphic.$create("Create$3");
      Result.LoadFromResource(AResource);
      return Result;
    };
    this.CreateFromURL = function (AURL) {
      var Result = null;
      Result = this.CreateFromURL$1(AURL,0);
      return Result;
    };
    this.CreateFromURL$1 = function (AURL, AInstance) {
      var Result = null;
      Result = $mod.TGraphic.$create("Create$3");
      Result.LoadFromURL(AURL,null);
      return Result;
    };
    this.Image = function () {
      var Result = null;
      Result = this.FImage;
      return Result;
    };
    this.Empty = function () {
      var Result = false;
      Result = this.FEmpty;
      return Result;
    };
    this.GetBase64Image = function () {
      var Result = "";
      Result = "";
      if (this.FCanvas != null) Result = this.FCanvas.GetBase64Image();
      return Result;
    };
    this.GetAsImage = function (AType) {
      var Result = "";
      Result = "";
      if (this.FCanvas != null) Result = this.FCanvas.GetAsImage(AType);
      return Result;
    };
    this.Create$1 = function (URL) {
      this.FAddToQueue = true;
      this.FEmpty = true;
      this.FData = "";
      this.FDataBin = "";
      this.Create$3();
      this.LoadFromURL(URL,null);
      return this;
    };
    this.Create$2 = function (Img) {
      this.FAddToQueue = true;
      this.FEmpty = true;
      this.FData = "";
      this.FDataBin = "";
      this.FURL = "";
      this.FImage = Img;
      this.FLoaded = null;
      return this;
    };
    this.Create$3 = function () {
      this.FAddToQueue = true;
      this.FEmpty = true;
      this.FData = "";
      this.FDataBin = "";
      this.FUsedCanvas = false;
      this.CreateImage();
      this.AssignEvents();
      return this;
    };
    this.CaptureCanvas = function () {
      if ((this.FCanvas != null) && (this.FCanvas.FElementCanvas != null)) this.LoadFromResource(this.FCanvas.FElementCanvas.toDataURL());
    };
    this.LoadFromCanvas = function (ACanvas) {
      if ((ACanvas != null) && (ACanvas.FElementCanvas != null)) this.LoadFromResource(ACanvas.FElementCanvas.toDataURL());
    };
    this.SetSize = function (AWidth, AHeight) {
      this.SetWidth(AWidth);
      this.SetHeight(AHeight);
    };
    this.Assign = function (Source) {
      var s = "";
      if ((Source != null) && $mod.TGraphic.isPrototypeOf(Source) && (rtl.as(Source,$mod.TGraphic).FCanvas != null)) {
        this.LoadFromCanvas(rtl.as(Source,$mod.TGraphic).FCanvas)}
       else if ((Source != null) && $mod.TGraphic.isPrototypeOf(Source) && (rtl.as(Source,$mod.TGraphic).FImage != null) && !rtl.as(Source,$mod.TGraphic).Empty()) {
        s = Source.FImage.src;
        this.LoadFromURL(s,null);
      } else if (!(Source != null)) {
        this.CreateImage();
        this.DoChange();
      };
    };
    this.LoadFromURL = function (AURL, ALoaded) {
      this.LoadFromURL$1(AURL,0,ALoaded);
    };
    this.LoadFromURL$1 = function (AURL, AHInstance, ALoaded) {
      this.FEmpty = true;
      this.LoadFromCache(AURL,ALoaded);
    };
    this.LoadFromFile = function (AFileName, ALoaded) {
      this.LoadFromURL$1(AFileName,0,ALoaded);
    };
    this.LoadFromResource = function (AResource) {
      this.LoadFromResource$1(AResource,0);
    };
    this.LoadFromResource$1 = function (AResource, AHInstance) {
      this.FEmpty = true;
      this.LoadFromCache(AResource,null);
    };
    this.LoadFromStream = function (AStream) {
      this.DoChange();
    };
    this.SaveToStream = function (AStream) {
      var s = "";
      var ms = null;
      s = this.GetAsImage($mod.TImageType.itBase64);
      ms = AStream;
      s = s.replace(/^data:image\/(png|jpg|jpeg);base64,/, "");
      
          var base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
          if (base64regex.test(s)) {
            var binary_string = window.atob(s);
            var len = binary_string.length;
            var bytes = new Uint8Array( len );
            for (var i = 0; i < len; i++)        {
                bytes[i] = binary_string.charCodeAt(i);
            }
            ms.Write(bytes, bytes.length);
          };
    };
    var $r = this.$rtti;
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("Data",3,$mod.$rtti["TBinaryString"],"GetData","SetData");
  });
  rtl.createClass(this,"TBitmap",this.TGraphic,function () {
    this.Assign = function (Source) {
      $mod.TGraphic.Assign.call(this,Source);
    };
  });
  rtl.recNewT(this,"TMatrix",function () {
    this.m11 = 0.0;
    this.m12 = 0.0;
    this.m13 = 0.0;
    this.m21 = 0.0;
    this.m22 = 0.0;
    this.m23 = 0.0;
    this.m31 = 0.0;
    this.m32 = 0.0;
    this.m33 = 0.0;
    this.$eq = function (b) {
      return (this.m11 === b.m11) && (this.m12 === b.m12) && (this.m13 === b.m13) && (this.m21 === b.m21) && (this.m22 === b.m22) && (this.m23 === b.m23) && (this.m31 === b.m31) && (this.m32 === b.m32) && (this.m33 === b.m33);
    };
    this.$assign = function (s) {
      this.m11 = s.m11;
      this.m12 = s.m12;
      this.m13 = s.m13;
      this.m21 = s.m21;
      this.m22 = s.m22;
      this.m23 = s.m23;
      this.m31 = s.m31;
      this.m32 = s.m32;
      this.m33 = s.m33;
      return this;
    };
    var $r = $mod.$rtti.$Record("TMatrix",{},this);
    $r.addField("m11",rtl.double);
    $r.addField("m12",rtl.double);
    $r.addField("m13",rtl.double);
    $r.addField("m21",rtl.double);
    $r.addField("m22",rtl.double);
    $r.addField("m23",rtl.double);
    $r.addField("m31",rtl.double);
    $r.addField("m32",rtl.double);
    $r.addField("m33",rtl.double);
  });
  rtl.createClass(this,"TCanvas",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FElementCanvas = null;
      this.FContext = null;
      this.FPen = null;
      this.FBrush = null;
      this.FFont = null;
      this.FPathOpen = false;
      this.FPathX = 0.0;
      this.FPathY = 0.0;
      this.FClipRect = $mod.TCanvasRectF.$new();
      this.FOnEndScene = null;
      this.FOnBeginScene = null;
      this.FApplyPixelRatio = false;
    };
    this.$final = function () {
      this.FElementCanvas = undefined;
      this.FContext = undefined;
      this.FPen = undefined;
      this.FBrush = undefined;
      this.FFont = undefined;
      this.FClipRect = undefined;
      this.FOnEndScene = undefined;
      this.FOnBeginScene = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetClipRect = function (Value) {
      this.FClipRect.$assign(Value);
      if (this.FContext != null) {
        this.FContext.beginPath();
        this.FContext.rect(this.FClipRect.Left,this.FClipRect.Top,this.FClipRect.Right - this.FClipRect.Left,this.FClipRect.Bottom - this.FClipRect.Top);
        this.FContext.clip();
      };
    };
    this.GetAccuOffset = function (X, Y, dx, dy) {
      dx.set(0);
      dy.set(0);
      if ((this.FPen.FWidth === 1) && (this.FPen.FStyle !== $mod.TPenStyle.psClear) && (pas.System.Frac(X) === 0)) dx.set(0.5);
      if ((this.FPen.FWidth === 1) && (this.FPen.FStyle !== $mod.TPenStyle.psClear) && (pas.System.Frac(Y) === 0)) dy.set(0.5);
    };
    this.GetPixel = function (X, Y) {
      var Result = 0;
      var imgd = null;
      Result = -1;
      if (this.FContext != null) {
        imgd = this.FContext.getImageData(X,Y,1,1);
        Result = $mod.RGBA(imgd.data[0],imgd.data[1],imgd.data[2],imgd.data[3]);
      };
      return Result;
    };
    this.SetPixel = function (X, Y, Clr) {
      if (this.FContext != null) {
        this.FContext.fillStyle = $mod.ColorToHTML(Clr);
        this.FContext.fillRect(X,Y,1,1);
      };
    };
    this.ApplyStroke = function () {
      if (this.FContext != null) {
        this.FContext.lineWidth = this.FPen.FWidth;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FPen.FColor);
        var $tmp = this.FPen.FStyle;
        if ($tmp === $mod.TPenStyle.psSolid) {
          this.FContext.setLineDash([])}
         else if ($tmp === $mod.TPenStyle.psDot) {
          this.FContext.setLineDash([1,2])}
         else if ($tmp === $mod.TPenStyle.psDash) {
          this.FContext.setLineDash([8,2])}
         else if ($tmp === $mod.TPenStyle.psDashDot) {
          this.FContext.setLineDash([6,2,2,2])}
         else if ($tmp === $mod.TPenStyle.psDashDotDot) {
          this.FContext.setLineDash([6,2,2,2,2,2])}
         else if ($tmp === $mod.TPenStyle.psClear) this.FContext.setLineDash([0,0xFFFF]);
      };
    };
    this.ApplyFill = function () {
      if (this.FContext != null) this.FContext.fillStyle = $mod.ColorToHTML(this.FBrush.FColor);
    };
    this.ApplyBrush = function (X1, Y1, X2, Y2) {
      var dx = 0.0;
      var dy = 0.0;
      var p = 0.0;
      var gr = null;
      var i = 0;
      var clr = "";
      var AColor = 0;
      var AStop = 0.0;
      this.GetAccuOffset(X1,Y1,{get: function () {
          return dx;
        }, set: function (v) {
          dx = v;
        }},{get: function () {
          return dy;
        }, set: function (v) {
          dy = v;
        }});
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsHorizontal,$mod.TBrushStyle.bsCross)) {
        p = Y1 + dy;
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < Y2) {
          this.FContext.moveTo(X1,p);
          this.FContext.lineTo(X2,p);
          p = p + 8;
        };
      };
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsVertical,$mod.TBrushStyle.bsCross)) {
        p = X1 + dx;
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < X2) {
          this.FContext.moveTo(p,Y1);
          this.FContext.lineTo(p,Y2);
          p = p + 8;
        };
      };
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsFDiagonal,$mod.TBrushStyle.bsDiagCross)) {
        p = (X1 + dx) - (X2 - X1);
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < X2) {
          this.FContext.moveTo(p,Y1);
          this.FContext.lineTo(p + (Y2 - Y1),Y2);
          p = p + 8;
        };
      };
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsBDiagonal,$mod.TBrushStyle.bsDiagCross)) {
        p = X1 + dx;
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < (X2 + (X2 - X1))) {
          this.FContext.moveTo(p,Y1);
          this.FContext.lineTo(p - (Y2 - Y1),Y2);
          p = p + 8;
        };
      };
      if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
        var $tmp = this.FBrush.FGradient;
        if ($tmp === $mod.TBrushGradient.bgLinearHorz) {
          gr = this.FContext.createLinearGradient(X1,Y1,X2,Y1)}
         else if ($tmp === $mod.TBrushGradient.bgLinearVert) {
          gr = this.FContext.createLinearGradient(X1,Y1,X1,Y2)}
         else if ($tmp === $mod.TBrushGradient.bgRadial) gr = this.FContext.createRadialGradient(X1 + ((X2 - X1) / 2),Y1 + ((Y2 - Y1) / 2),0,X1 + ((X2 - X1) / 2),Y1 + ((Y2 - Y1) / 2),(X2 - X1) / 2);
        clr = $mod.ColorToHTML($mod.ColorToRGB(this.FBrush.FColor));
        gr.addColorStop(0,clr);
        for (var $l = 0, $end = this.FBrush.GradientCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.FBrush.GetGradientColor(i,{get: function () {
              return AColor;
            }, set: function (v) {
              AColor = v;
            }},{get: function () {
              return AStop;
            }, set: function (v) {
              AStop = v;
            }});
          clr = $mod.ColorToHTML($mod.ColorToRGB(AColor));
          gr.addColorStop(AStop,clr);
        };
        this.FContext.fillStyle = gr;
        return;
      };
      this.FContext.stroke();
    };
    this.Create$1 = function (AControl) {
      this.FElementCanvas = AControl;
      if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
            this.FContext = AControl.getContext('2d');
          } else {
            this.FContext = AControl.getContext('2d',{ willReadFrequently: true});
      //      const dpr = window.devicePixelRatio || 1;
      //      console.log(dpr);
      //      this.FContext.scale(dpr, dpr);
          };
      this.FPen = $mod.TPen.$create("Create$1");
      this.FBrush = $mod.TBrush.$create("Create$1");
      this.FPathOpen = false;
      this.FFont = $mod.TFont.$create("Create$1");
      this.FApplyPixelRatio = false;
      return this;
    };
    this.Create$2 = function () {
      this.FElementCanvas = document.createElement("CANVAS");
      this.Create$1(this.FElementCanvas);
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.SetTransform = function (m11, m12, m21, m22, dx, dy) {
      var m = $mod.TMatrix.$new();
      var px = 0.0;
      if (this.FContext != null) {
        m.$assign($impl.MatrixIdentity());
        m.m11 = m11;
        m.m12 = m12;
        m.m21 = m21;
        m.m22 = m22;
        m.m31 = dx;
        m.m32 = dy;
        if (this.FApplyPixelRatio) {
          px = $impl.GetPixelRatio(this);
          m.$assign($impl.MatrixMultiply(m,$impl.MatrixCreateScaling(px,px)));
        };
        this.FContext.setTransform(m.m11,m.m12,m.m21,m.m22,m.m31,m.m32);
      };
    };
    this.Transform = function (m11, m12, m21, m22, dx, dy) {
      if (this.FContext != null) this.FContext.transform(m11,m12,m21,m22,dx,dy);
    };
    this.Rotate = function (Angle) {
      if (this.FContext != null) this.FContext.rotate(Angle);
    };
    this.Translate = function (X, Y) {
      if (this.FContext != null) this.FContext.translate(X,Y);
    };
    this.AngleArc = function (X, Y, Radius, StartAngle, SweepAngle) {
      this.AngleArc$1(X,Y,Radius,StartAngle,SweepAngle);
    };
    this.AngleArc$1 = function (X, Y, Radius, StartAngle, SweepAngle) {
      if (this.FContext != null) {
        this.FContext.beginPath();
        this.ApplyStroke();
        this.FContext.arc(X,Y,Radius,StartAngle,StartAngle + SweepAngle);
        this.FContext.stroke();
      };
    };
    this.CopyRect = function (DestRect, Canvas, SourceRect) {
      var sw = 0;
      var sh = 0;
      var dw = 0;
      var dh = 0;
      var imgData = null;
      var ACanvas = null;
      if (this.FContext != null) {
        sw = SourceRect.Right - SourceRect.Left;
        sh = SourceRect.Bottom - SourceRect.Top;
        dw = DestRect.Right - DestRect.Left;
        dh = DestRect.Bottom - DestRect.Top;
        imgData = this.FContext.getImageData(SourceRect.Left,SourceRect.Top,sw,sh);
        ACanvas = $mod.TCanvas.$create("Create$2");
        try {
          ACanvas.FElementCanvas.width = sw;
          ACanvas.FElementCanvas.height = sh;
          ACanvas.FContext.putImageData(imgData,0,0);
          Canvas.FContext.drawImage(ACanvas.FElementCanvas,DestRect.Left,DestRect.Top,dw,dh);
        } finally {
          ACanvas = rtl.freeLoc(ACanvas);
        };
      };
    };
    this.MoveTo = function (X, Y) {
      this.MoveTo$1(X,Y);
    };
    this.MoveTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        this.FPathOpen = true;
        this.FContext.beginPath();
        this.ApplyStroke();
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.moveTo(X + dx,Y + dy);
      };
    };
    this.LineTo = function (X, Y) {
      this.LineTo$1(X,Y);
    };
    this.LineTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      var clr = 0;
      if (this.FContext != null) {
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        var $tmp = this.FPen.FMode;
        if ($tmp === $mod.TPenMode.pmBlack) {
          this.FContext.strokeStyle = $mod.ColorToHTML(0)}
         else if ($tmp === $mod.TPenMode.pmWhite) {
          this.FContext.strokeStyle = $mod.ColorToHTML(16777215)}
         else if ($tmp === $mod.TPenMode.pmXor) {
          this.FContext.globalCompositeOperation = "xor"}
         else if ($tmp === $mod.TPenMode.pmMask) {
          this.FContext.globalCompositeOperation = "source-atop"}
         else if ($tmp === $mod.TPenMode.pmNotCopy) {
          clr = $mod.ColorToRGB(this.FPen.FColor) ^ 0xFFFFFFFF;
          this.FContext.strokeStyle = $mod.ColorToHTML(clr);
        } else if ($tmp === $mod.TPenMode.pmNotXor) {
          clr = $mod.ColorToRGB(this.FPen.FColor) ^ 0xFFFFFFFF;
          this.FContext.strokeStyle = $mod.ColorToHTML(clr);
          this.FContext.globalCompositeOperation = "xor";
        };
        if (!this.FPathOpen) {
          this.FContext.beginPath();
          this.ApplyStroke();
          this.FContext.moveTo(this.FPathX + dx,this.FPathY + dy);
        };
        this.FContext.lineTo(X + dx,Y + dy);
        this.FContext.stroke();
        this.FPathX = X;
        this.FPathY = Y;
        this.FPathOpen = false;
        this.FContext.globalCompositeOperation = "source-over";
      };
    };
    this.Rectangle = function (X1, Y1, X2, Y2) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        this.FContext.save();
        this.FContext.beginPath();
        this.ApplyStroke();
        this.ApplyFill();
        this.GetAccuOffset(X1,Y1,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        let region = new Path2D();
        region.rect(X1, Y1, X2- X1 + 1, Y2 - Y1 + 1);
        this.FContext.clip(region, "evenodd");
        this.ApplyBrush(X1,Y1,X2,Y2);
        if (!(this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsClear,$mod.TBrushStyle.bsHorizontal,$mod.TBrushStyle.bsVertical,$mod.TBrushStyle.bsCross,$mod.TBrushStyle.bsFDiagonal,$mod.TBrushStyle.bsBDiagonal,$mod.TBrushStyle.bsDiagCross))) {
          this.FContext.rect(X1 + dx,Y1 + dy,X2 - X1,Y2 - Y1);
          this.FContext.fill();
        };
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) {
          this.ApplyStroke();
          this.FContext.beginPath();
          this.FContext.rect(X1 + dx,Y1 + dy,X2 - X1,Y2 - Y1);
          this.FContext.stroke();
        };
        this.FContext.restore();
      };
    };
    this.Rectangle$1 = function (X1, Y1, X2, Y2) {
      this.Rectangle(X1,Y1,X2,Y2);
    };
    this.Rectangle$2 = function (Rect) {
      this.Rectangle$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Rectangle$3 = function (Rect) {
      this.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.RoundRect = function (X1, Y1, X2, Y2, X3, Y3) {
      this.RoundRect$1(X1,Y1,X2,Y2,X3,Y3);
    };
    this.RoundRect$1 = function (X1, Y1, X2, Y2, X3, Y3) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        if (X2 < X1) return;
        if (Y2 < Y1) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        this.ApplyFill();
        this.GetAccuOffset(X1,Y1,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.moveTo(X1 + (X3 / 2),Y1 + dy);
        this.FContext.lineTo(X2 - (X3 / 2),Y1 + dy);
        this.FContext.ellipse(X2 - dx - (X3 / 2),Y1 + dy + (Y3 / 2),X3 / 2,Y3 / 2,0,Math.PI * 1.5,0);
        this.FContext.lineTo(X2 - dx,Y2 - (Y3 / 2));
        this.FContext.ellipse(X2 - dx - (X3 / 2),Y2 - dy - (Y3 / 2),X3 / 2,Y3 / 2,0,0,Math.PI * 0.5);
        this.FContext.lineTo(X1 + (X3 / 2),Y2 - dy);
        this.FContext.ellipse(X1 + dx + (X3 / 2),Y2 - dy - (Y3 / 2),X3 / 2,Y3 / 2,0,Math.PI * 0.5,Math.PI);
        this.FContext.lineTo(X1 + dx,Y1 + (Y3 / 2) + dy);
        this.FContext.ellipse(X1 + dx + (X3 / 2),Y1 + dy + (Y3 / 2),X3 / 2,Y3 / 2,0,Math.PI,Math.PI * 1.5);
        if (this.FBrush.FStyle === $mod.TBrushStyle.bsSolid) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
        this.FContext.save();
        let region = new Path2D();
        region.moveTo(X1 + X3/2, Y1 + dy);
        region.lineTo(X2 - X3/2, Y1 + dy);
        region.ellipse(X2 - dx - X3 / 2, Y1 + dy + Y3/2, X3 / 2, Y3 / 2, 0, Math.PI * 1.5, 0);
        region.lineTo(X2 + dx, Y2 - Y3/2 );
        region.ellipse(X2 - dx - X3 / 2, Y2 - dy - Y3/2, X3 / 2, Y3 / 2, 0, 0, Math.PI * 0.5);
        region.lineTo(X1 + X3/2, Y2 + dy);
        region.ellipse(X1 + dx + X3 / 2, Y2 - dy - Y3/2, X3 / 2, Y3 / 2, 0, Math.PI * 0.5, Math.PI);
        region.lineTo(X1 + dx, Y1 + Y3/2 + dy);
        region.ellipse(X1 + dx + X3 / 2, Y1 + dy + Y3/2, X3 / 2, Y3 / 2, 0, Math.PI, Math.PI * 1.5);
        this.FContext.clip(region, "evenodd");
        this.ApplyBrush(X1,Y1,X2,Y2);
        this.FContext.restore();
      };
    };
    this.RoundRect$2 = function (Rect, CX, CY) {
      this.RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,CX,CY);
    };
    this.RoundRect$3 = function (Rect, CX, CY) {
      this.RoundRect$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,CX,CY);
    };
    this.FillRect = function (Rect) {
      this.Rectangle$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.FillRect$1 = function (Rect) {
      this.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Arc = function (X1, Y1, X2, Y2, X3, Y3, X4, Y4) {
      var rx = 0;
      var ry = 0;
      var angleStart = 0.0;
      var angleEnd = 0.0;
      if (this.FContext != null) {
        rx = rtl.trunc((X2 - X1) / 2);
        ry = rtl.trunc((Y2 - Y1) / 2);
        angleStart = $impl.AngleOfPoints(X1 + rx,Y1 + ry,X4,Y4);
        angleEnd = $impl.AngleOfPoints(X1 + rx,Y1 + ry,X3,Y3);
        this.FContext.beginPath();
        this.ApplyStroke();
        this.FContext.ellipse(X1 + rx,Y1 + ry,rx,ry,0,angleStart,angleEnd);
        this.FContext.stroke();
      };
    };
    this.Ellipse = function (X1, Y1, X2, Y2) {
      this.Ellipse$1(X1,Y1,X2,Y2);
    };
    this.Ellipse$1 = function (X1, Y1, X2, Y2) {
      var w = 0.0;
      var h = 0.0;
      var kappa = 0.0;
      var ox = 0.0;
      var oy = 0.0;
      var xe = 0.0;
      var ye = 0.0;
      var xm = 0.0;
      var ym = 0.0;
      if (this.FContext != null) {
        w = X2 - X1;
        h = Y2 - Y1;
        kappa = 0.5522848;
        ox = (w / 2) * kappa;
        oy = (h / 2) * kappa;
        xe = X1 + w;
        ye = Y1 + h;
        xm = X1 + (w / 2);
        ym = Y1 + (h / 2);
        this.FContext.save();
        let region = new Path2D();
        region.moveTo(X1, ym);
        region.bezierCurveTo(X1, ym - oy, xm - ox, Y1, xm, Y1);
        region.bezierCurveTo(xm + ox, Y1, xe, ym - oy, xe, ym);
        region.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
        region.bezierCurveTo(xm - ox, ye, X1, ym + oy, X1, ym);
        region.closePath();
        this.FContext.clip(region, "evenodd");
        if (!(this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsSolid,$mod.TBrushStyle.bsClear)) && (this.FBrush.FGradient === $mod.TBrushGradient.bgNone)) this.ApplyBrush(X1,Y1,X2,Y2);
        this.FContext.restore();
        this.FContext.beginPath();
        this.ApplyStroke();
        if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
          this.ApplyBrush(X1,Y1,X2,Y2);
        } else this.ApplyFill();
        this.FContext.moveTo(X1,ym);
        this.FContext.bezierCurveTo(X1,ym - oy,xm - ox,Y1,xm,Y1);
        this.FContext.bezierCurveTo(xm + ox,Y1,xe,ym - oy,xe,ym);
        this.FContext.bezierCurveTo(xe,ym + oy,xm + ox,ye,xm,ye);
        this.FContext.bezierCurveTo(xm - ox,ye,X1,ym + oy,X1,ym);
        this.FContext.closePath();
        if ((this.FBrush.FStyle === $mod.TBrushStyle.bsSolid) || (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone)) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Ellipse$2 = function (Rect) {
      this.Ellipse(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Ellipse$3 = function (Rect) {
      this.Ellipse$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Polyline = function (Points) {
      var l = 0;
      var i = 0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        i = 0;
        this.FContext.moveTo(Points[i].x,Points[i].y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].x,Points[i].y);
        };
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Polyline$1 = function (Points) {
      var l = 0;
      var i = 0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        i = 0;
        this.FContext.moveTo(Points[i].X,Points[i].Y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].X,Points[i].Y);
        };
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Polygon = function (Points) {
      var l = 0;
      var i = 0;
      var x1 = 0;
      var y1 = 0;
      var x2 = 0;
      var y2 = 0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        x1 = 0xFFFF;
        y1 = 0xFFFF;
        x2 = 0;
        y2 = 0;
        for (var $l = 0, $end = rtl.length(Points) - 1; $l <= $end; $l++) {
          i = $l;
          if (Points[i].x < x1) x1 = Points[i].x;
          if (Points[i].y < y1) y1 = Points[i].y;
          if (Points[i].x > x2) x2 = Points[i].x;
          if (Points[i].y > y2) y2 = Points[i].y;
        };
        if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
          this.ApplyBrush(x1,y1,x2,y2);
        } else this.ApplyFill();
        i = 0;
        this.FContext.moveTo(Points[i].x,Points[i].y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].x,Points[i].y);
        };
        this.FContext.closePath();
        if (this.FBrush.FStyle !== $mod.TBrushStyle.bsClear) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Polygon$1 = function (Points) {
      var l = 0;
      var i = 0;
      var x1 = 0.0;
      var y1 = 0.0;
      var x2 = 0.0;
      var y2 = 0.0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        x1 = 0xFFFF;
        y1 = 0xFFFF;
        x2 = 0;
        y2 = 0;
        for (var $l = 0, $end = rtl.length(Points) - 1; $l <= $end; $l++) {
          i = $l;
          if (Points[i].X < x1) x1 = Points[i].X;
          if (Points[i].Y < y1) y1 = Points[i].Y;
          if (Points[i].X > x2) x2 = Points[i].X;
          if (Points[i].Y > y2) y2 = Points[i].Y;
        };
        if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
          this.ApplyBrush(x1,y1,x2,y2)}
         else this.ApplyFill();
        i = 0;
        this.FContext.moveTo(Points[i].X,Points[i].Y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].X,Points[i].Y);
        };
        this.FContext.closePath();
        if (this.FBrush.FStyle !== $mod.TBrushStyle.bsClear) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.TextOut = function (X, Y, Text) {
      this.TextOut$1(X,Y,Text);
    };
    this.TextOut$1 = function (X, Y, Text) {
      var tm = null;
      var DrwText = "";
      if (this.FContext != null) {
        DrwText = Text.replace('\0','');
        this.FContext.fillStyle = $mod.ColorToHTML(this.FFont.FColor);
        this.FContext.font = this.FFont.ToString();
        this.FContext.textBaseline = "top";
        this.FContext.fillText(DrwText,X,Y);
        if ($mod.TFontStyle.fsUnderline in this.FFont.FStyle) {
          tm = this.FContext.measureText(DrwText);
          this.FContext.fillRect(X,Y + (this.FFont.FSize * 1.4),tm.width,1);
        };
        if ($mod.TFontStyle.fsStrikeOut in this.FFont.FStyle) {
          tm = this.FContext.measureText(DrwText);
          this.FContext.fillRect(X,Y + (this.FFont.FSize * 0.7),tm.width,1);
        };
      };
    };
    this.Draw = function (X, Y, Graphic) {
      this.Draw$1(X,Y,Graphic);
    };
    this.Draw$1 = function (X, Y, Graphic) {
      var img = null;
      if (this.FContext != null) {
        img = Graphic.Image();
        if (img != null) {
          if (Graphic.FUsedCanvas) {
            this.FContext.drawImage(Graphic.FCanvasElement,X,Y)}
           else this.FContext.drawImage(img,X,Y);
        };
      };
    };
    this.StretchDraw = function (Rect, Graphic) {
      this.StretchDraw$1($mod.TCanvasRectF.$clone($mod.CreateCanvasRectF(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom)),Graphic);
    };
    this.StretchDraw$1 = function (Rect, Graphic) {
      var img = null;
      if (this.FContext != null) {
        img = Graphic.Image();
        if (img != null) {
          if (Graphic.FUsedCanvas) {
            this.FContext.drawImage(Graphic.FCanvasElement,0,0,Graphic.GetWidth(),Graphic.GetHeight(),Rect.Left,Rect.Top,Rect.Right - Rect.Left,Rect.Bottom - Rect.Top)}
           else this.FContext.drawImage(img,0,0,Graphic.GetWidth(),Graphic.GetHeight(),Rect.Left,Rect.Top,Rect.Right - Rect.Left,Rect.Bottom - Rect.Top);
        };
      };
    };
    this.DrawFocusRect = function (Rect) {
      this.DrawFocusRect$1($mod.CreateCanvasRectF(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom));
    };
    this.DrawFocusRect$1 = function (Rect) {
      var ps = 0;
      ps = this.FPen.FStyle;
      this.FPen.FStyle = $mod.TPenStyle.psDot;
      this.FPen.FWidth = 1;
      this.FPen.SetColor(0);
      this.MoveTo$1(Rect.Left,Rect.Top);
      this.LineTo$1(Rect.Right,Rect.Top);
      this.LineTo$1(Rect.Right,Rect.Bottom);
      this.LineTo$1(Rect.Left,Rect.Bottom);
      this.LineTo$1(Rect.Left,Rect.Top);
      this.FPen.FStyle = ps;
    };
    this.BeginScene = function () {
      if (this.FOnBeginScene != null) this.FOnBeginScene(this);
    };
    this.EndScene = function () {
      if (this.FOnEndScene != null) this.FOnEndScene(this);
    };
    this.PathBegin = function () {
      if (this.FContext != null) this.FContext.beginPath();
    };
    this.PathClose = function () {
      if (this.FContext != null) this.FContext.closePath();
    };
    this.PathStroke = function () {
      if (this.FContext != null) {
        this.ApplyStroke();
        this.FContext.stroke();
      };
    };
    this.PathFill = function () {
      if (this.FContext != null) {
        this.ApplyFill();
        this.ApplyBrush(10,10,50,50);
        this.FContext.fill();
      };
    };
    this.PathMoveTo = function (X, Y) {
      this.PathMoveTo$1(X,Y);
    };
    this.PathMoveTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.moveTo(X + dx,Y + dy);
      };
    };
    this.PathLineTo = function (X, Y) {
      this.PathLineTo$1(X,Y);
    };
    this.PathLineTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.lineTo(X + dx,Y + dy);
      };
    };
    this.Save = function () {
      if (this.FContext != null) this.FContext.save();
    };
    this.Clip = function () {
      if (this.FContext != null) this.FContext.clip();
    };
    this.Restore = function () {
      if (this.FContext != null) this.FContext.restore();
    };
    this.Refresh = function () {
    };
    this.Clear = function () {
      if ((this.FContext != null) && (this.FElementCanvas != null)) this.FContext.clearRect(0,0,this.FElementCanvas.width,this.FElementCanvas.height);
    };
    this.Clear$1 = function (AColor) {
      var c = 0;
      var s = 0;
      this.Clear();
      if (this.FElementCanvas != null) {
        c = this.FBrush.FColor;
        s = this.FBrush.FStyle;
        this.FBrush.FColor = AColor;
        this.FBrush.FStyle = $mod.TBrushStyle.bsSolid;
        this.FillRect(pas.Types.Rect(0,0,this.FElementCanvas.width,this.FElementCanvas.height));
        this.FBrush.FColor = c;
        this.FBrush.FStyle = s;
      };
    };
    this.TextExtent = function (Text) {
      var Result = $mod.TCanvasSizeF.$new();
      Result.cx = this.TextWidth(Text);
      Result.cy = this.TextHeight(Text);
      return Result;
    };
    this.TextRect = function (ARect, Text, WordWrap, Calculate, AHorizontalAlignment, AVerticalAlignment) {
      var Result = pas.Types.TRect.$new();
      var r = $mod.TCanvasRectF.$new();
      r.$assign(this.TextRect$1($mod.TCanvasRectF.$clone($mod.CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom)),Text,WordWrap,Calculate,AHorizontalAlignment,AVerticalAlignment));
      Result.$assign(pas.Types.Rect(Math.round(r.Left),Math.round(r.Top),Math.round(r.Right),Math.round(r.Bottom)));
      return Result;
    };
    this.TextRect$1 = function (ARect, Text, WordWrap, Calculate, AHorizontalAlignment, AVerticalAlignment) {
      var $Self = this;
      var Result = $mod.TCanvasRectF.$new();
      var i = 0;
      var s = "";
      var sn = "";
      var st = "";
      var l = 0;
      var w = 0.0;
      var mw = 0.0;
      var f = false;
      var p = 0;
      var tw = 0.0;
      var th = 0.0;
      var lcnt = 0;
      var rs = $mod.TCanvasRectF.$new();
      var fws = 0.0;
      var ths = 0.0;
      var ww = false;
      var wwx = false;
      var fx = false;
      function DrawText(AText, AWidth, AHeight) {
        if (ww) {
          var $tmp = AHorizontalAlignment;
          if ($tmp === pas.Classes.TAlignment.taCenter) {
            $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Top,AText)}
           else if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
            $Self.TextOut$1(ARect.Left,ARect.Top,AText)}
           else if ($tmp === pas.Classes.TAlignment.taRightJustify) $Self.TextOut$1(ARect.Right - AWidth,ARect.Top,AText);
        } else {
          var $tmp1 = AHorizontalAlignment;
          if ($tmp1 === pas.Classes.TAlignment.taCenter) {
            var $tmp2 = AVerticalAlignment;
            if ($tmp2 === $mod.TVerticalAlignment.taAlignTop) {
              $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Top,AText)}
             else if ($tmp2 === $mod.TVerticalAlignment.taVerticalCenter) {
              $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Top + ((ARect.Bottom - ARect.Top - AHeight) / 2),AText)}
             else if ($tmp2 === $mod.TVerticalAlignment.taAlignBottom) $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Bottom - AHeight,AText);
          } else if ($tmp1 === pas.Classes.TAlignment.taLeftJustify) {
            var $tmp3 = AVerticalAlignment;
            if ($tmp3 === $mod.TVerticalAlignment.taAlignTop) {
              $Self.TextOut$1(ARect.Left,ARect.Top,AText)}
             else if ($tmp3 === $mod.TVerticalAlignment.taVerticalCenter) {
              $Self.TextOut$1(ARect.Left,ARect.Top + ((ARect.Bottom - ARect.Top - AHeight) / 2),AText)}
             else if ($tmp3 === $mod.TVerticalAlignment.taAlignBottom) $Self.TextOut$1(ARect.Left,ARect.Bottom - AHeight,AText);
          } else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) {
            var $tmp4 = AVerticalAlignment;
            if ($tmp4 === $mod.TVerticalAlignment.taAlignTop) {
              $Self.TextOut$1(ARect.Right - AWidth,ARect.Top,AText)}
             else if ($tmp4 === $mod.TVerticalAlignment.taVerticalCenter) {
              $Self.TextOut$1(ARect.Right - AWidth,ARect.Top + ((ARect.Bottom - ARect.Top - AHeight) / 2),AText)}
             else if ($tmp4 === $mod.TVerticalAlignment.taAlignBottom) $Self.TextOut$1(ARect.Right - AWidth,ARect.Bottom - AHeight,AText);
          };
        };
      };
      function FindNextWord(Text, APos) {
        var Result = "";
        var l = 0;
        var i = 0;
        Result = "";
        l = Text.length;
        if (APos.get() > l) return Result;
        i = APos.get();
        while (true) {
          if (((Text.charAt(i - 1) === "\n") && (Text.charAt(i - 1 - 1) === "\r")) || ((Text.charAt(i - 1) === "\r") && (Text.charAt(i - 1 - 1) === "\n")) || (Text.charAt(i - 1) === " ")) {
            if (Text.charAt(i - 1) === " ") {
              Result = pas.System.Copy(Text,APos.get(),i - (APos.get() - 1))}
             else Result = pas.System.Copy(Text,APos.get(),i - APos.get());
            break;
          } else if ((Text.charAt(i - 1) === "\n") || (Text.charAt(i - 1) === "\r") || (Text.charAt(i - 1) === " ")) {
            Result = pas.System.Copy(Text,APos.get(),i - (APos.get() - 1));
            break;
          } else if (i >= l) {
            Result = pas.System.Copy(Text,APos.get(),i - (APos.get() - 1));
            break;
          } else i += 1;
        };
        APos.set(i + 1);
        return Result;
      };
      ww = WordWrap || (pas.System.Pos("\r",Text) > 0) || (pas.System.Pos("\n",Text) > 0);
      wwx = !WordWrap && ((pas.System.Pos("\r",Text) > 0) || (pas.System.Pos("\n",Text) > 0));
      if (!ww) {
        w = this.TextWidth(Text);
        th = this.TextHeight(Text);
        if (!Calculate) DrawText(Text,w,th);
        Result.$assign($mod.CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Left + w,ARect.Top + th));
      } else {
        rs.$assign(ARect);
        mw = 0;
        i = 1;
        ths = this.FFont.FSize * 0.5;
        lcnt = 0;
        fws = 0;
        tw = 0;
        s = FindNextWord(Text,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }});
        w = this.TextWidth(s);
        th = this.TextHeight(s) + ths;
        mw = mw + w;
        if ((s.length > 0) && (s.charAt(s.length - 1) === " ")) mw = mw + fws;
        fx = false;
        while (i <= Text.length) {
          l = s.length;
          if ((l >= 2) && (((s.charAt(l - 1) === "\n") && (s.charAt(l - 1 - 1) === "\r")) || ((s.charAt(l - 1) === "\r") && (s.charAt(l - 1 - 1) === "\n")))) {
            s = pas.System.Copy(s,1,l - 2);
            f = true;
          } else if ((l >= 1) && ((s.charAt(l - 1) === "\n") || (s.charAt(l - 1) === "\r"))) {
            s = pas.System.Copy(s,1,l - 1);
            f = true;
          } else f = false;
          sn = FindNextWord(Text,{get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }});
          w = this.TextWidth(sn);
          th = Math.max(th,this.TextHeight(sn) + ths);
          if (((ARect.Left + mw + w) > ARect.Right) || f) {
            if ((s !== "") && !fx) {
              p = s.length;
              st = pas.System.Copy(s,1,p);
              lcnt += 1;
              if (mw > tw) tw = mw;
              if (!Calculate) DrawText(st,mw,th);
              mw = 0;
            };
            s = "";
            fx = false;
            if ((wwx && f) || !wwx) {
              ARect.Top = ARect.Top + th}
             else if (wwx && !f) fx = true;
            if ((pas.System.Trunc(ARect.Top) > pas.System.Trunc((ARect.Bottom - th) + ths)) && !Calculate) break;
          };
          mw = mw + w;
          if ((sn.length > 0) && (sn.charAt(sn.length - 1) === " ")) mw = mw + fws;
          s = s + sn;
        };
        if (s !== "") {
          p = s.length;
          st = pas.System.Copy(s,1,p);
          lcnt += 1;
          if (mw > tw) tw = mw;
          if (!Calculate) DrawText(st,mw,th);
        };
        Result.$assign($mod.CreateCanvasRectF(rs.Left,rs.Top,rs.Left + tw,rs.Top + (lcnt * th)));
      };
      return Result;
    };
    this.TextRect$2 = function (ARect, Text, TextFormat) {
      var Result = $mod.TCanvasRectF.$new();
      var ha = 0;
      var va = 0;
      ha = pas.Classes.TAlignment.taLeftJustify;
      va = $mod.TVerticalAlignment.taAlignTop;
      if ($mod.TTextFormats.tfCenter in TextFormat) {
        ha = pas.Classes.TAlignment.taCenter}
       else if ($mod.TTextFormats.tfRight in TextFormat) ha = pas.Classes.TAlignment.taRightJustify;
      if ($mod.TTextFormats.tfVerticalCenter in TextFormat) {
        va = $mod.TVerticalAlignment.taVerticalCenter}
       else if ($mod.TTextFormats.tfBottom in TextFormat) va = $mod.TVerticalAlignment.taAlignBottom;
      Result.$assign(this.TextRect$1($mod.TCanvasRectF.$clone(ARect),Text,$mod.TTextFormats.tfWordBreak in TextFormat,$mod.TTextFormats.tfCalcRect in TextFormat,ha,va));
      return Result;
    };
    this.TextWidth = function (Text) {
      var Result = 0.0;
      var f = "";
      var tm = null;
      if (this.FContext != null) {
        f = this.FFont.ToString();
        this.FContext.font = f;
        tm = this.FContext.measureText(Text);
        Result = tm.width;
      };
      return Result;
    };
    this.TextHeight = function (Text) {
      var Result = 0.0;
      Result = $mod.FontSizeToPx(this.FFont.FSize);
      return Result;
    };
    this.GetBase64Image = function () {
      var Result = "";
      Result = "";
      if (this.FElementCanvas != null) Result = this.FElementCanvas.toDataURL();
      return Result;
    };
    this.GetAsImage = function (AType) {
      var Result = "";
      Result = "";
      if (this.FElementCanvas != null) {
        var $tmp = AType;
        if ($tmp === $mod.TImageType.itBase64) {
          Result = this.FElementCanvas.toDataURL()}
         else if ($tmp === $mod.TImageType.itPNG) {
          Result = this.FElementCanvas.toDataURL("image/png")}
         else if ($tmp === $mod.TImageType.itJPEG) {
          Result = this.FElementCanvas.toDataURL("image/jpeg",1.0)}
         else if ($tmp === $mod.TImageType.itBMP) {
          Result = this.FElementCanvas.toDataURL("image/bmp")}
         else if ($tmp === $mod.TImageType.itGIF) {
          Result = this.FElementCanvas.toDataURL("image/gif")}
         else if ($tmp === $mod.TImageType.itSVG) Result = this.FElementCanvas.toDataURL("image/svg+xml");
      };
      return Result;
    };
    this.DownloadImage = function (AFileName, AType) {
      var s = "";
      var el = null;
      if (this.FElementCanvas != null) {
        s = this.GetAsImage(AType);
        el = document.createElement("a");
        el.setAttribute("href",s);
        if (AFileName !== "") el.setAttribute("download",AFileName);
        el.style.setProperty("display","none");
        document.body.appendChild(el);
        el.click();
        document.body.removeChild(el);
      };
    };
  });
  rtl.createClassExt(this,"TJSCSSStyleDeclarationEx",CSSStyleDeclaration,"",function () {
    this.$init = function () {
      this.filter = "";
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSHTMLElementEx",HTMLElement,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSCanvasRenderingContext2DEx",CanvasRenderingContext2D,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClass(this,"TURLPicture",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FFilename = "";
      this.FData = "";
      this.FOnDataChange = null;
      this.FWidth = 0;
      this.FHeight = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FOnDataChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetData = function (Value) {
      if (this.FData !== Value) {
        this.FData = Value;
        this.DataChanged();
      };
    };
    this.GetData = function () {
      var Result = "";
      Result = this.FData;
      return Result;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.DataChanged = function () {
      if (this.FOnDataChange != null) this.FOnDataChange(this);
    };
    this.LoadFromFile = function (AFileName) {
      this.FFilename = AFileName;
      this.Changed();
    };
    this.Assign = function (Source) {
      if ($mod.TURLPicture.isPrototypeOf(Source)) {
        this.FFilename = rtl.as(Source,$mod.TURLPicture).FFilename;
        this.Changed();
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("Data",3,$mod.$rtti["TBinaryString"],"GetData","SetData");
  });
  this.$rtti.$RefToProcVar("TThumbnailCreatedProc",{procsig: rtl.newTIProcSig([["ADataURL",rtl.string]])});
  this.ColorToRGB = function (Color) {
    var Result = 0;
    Result = Color;
    return Result;
  };
  this.ColorToHex = function (c) {
    var Result = "";
    var s = "";
    s = c.toString(16);
    
        while (s.length < 6)
        {
          s = "0" + s;
        };
    Result = pas.System.Copy(s,5,2) + pas.System.Copy(s,3,2) + pas.System.Copy(s,1,2);
    return Result;
  };
  this.ColorToHTML = function (c) {
    var Result = "";
    if ((c & 0xFFFFFFFF) === -1) {
      Result = "#00000000"}
     else if ((c & 0xFF000000) !== 0) {
      Result = "#" + $mod.ColorToHex(c & 0xFFFFFF) + pas.SysUtils.IntToHex(Math.floor((c & 0xFF000000) / 16777216) & 0xFF,2);
    } else Result = "#" + $mod.ColorToHex(c);
    return Result;
  };
  this.HTMLToColor = function (s) {
    var Result = 0;
    if (pas.System.Pos("#",s) === 1) pas.System.Delete({get: function () {
        return s;
      }, set: function (v) {
        s = v;
      }},1,1);
    Result = $mod.HexToColor(s);
    return Result;
  };
  this.ColorToString = function (Color) {
    var Result = "";
    var $tmp = Color;
    if ($tmp === -1) {
      Result = "clNone"}
     else if ($tmp === 0) {
      Result = "clBlack"}
     else if ($tmp === 128) {
      Result = "clMaroon"}
     else if ($tmp === 32768) {
      Result = "clGreen"}
     else if ($tmp === 32896) {
      Result = "clOlive"}
     else if ($tmp === 8388608) {
      Result = "clNavy"}
     else if ($tmp === 8388736) {
      Result = "clPurple"}
     else if ($tmp === 8421376) {
      Result = "clTeal"}
     else if ($tmp === 8421504) {
      Result = "clGray"}
     else if ($tmp === 12632256) {
      Result = "clSilver"}
     else if ($tmp === 255) {
      Result = "clRed"}
     else if ($tmp === 65280) {
      Result = "clLime"}
     else if ($tmp === 65535) {
      Result = "clYellow"}
     else if ($tmp === 16711680) {
      Result = "clBlue"}
     else if ($tmp === 16711935) {
      Result = "clFuchsia"}
     else if ($tmp === 16776960) {
      Result = "clAqua"}
     else if ($tmp === 16777215) {
      Result = "clWhite"}
     else if ($tmp === 12698049) {
      Result = "clLtGray"}
     else if ($tmp === 8487297) {
      Result = "clDkGray"}
     else if ($tmp === 536870912) {
      Result = "clDefault"}
     else if ($tmp === 15790320) {
      Result = "clBtnFace"}
     else if ($tmp === 65793) {
      Result = "clWindowText"}
     else if ($tmp === 16711422) {
      Result = "clWindow"}
     else if ($tmp === 14120960) {
      Result = "clHighlight"}
     else if ($tmp === 197379) {
      Result = "clHighlightText"}
     else if ($tmp === 131586) {
      Result = "clInfoText"}
     else if ($tmp === 14811135) {
      Result = "clInfoBk"}
     else if ($tmp === 13743257) {
      Result = "clActiveCaption"}
     else if ($tmp === 14405055) {
      Result = "clInactiveCaption"}
     else if ($tmp === 13395456) {
      Result = "clHotLight"}
     else {
      Result = "$" + $impl.ColorToVCL(Color);
    };
    return Result;
  };
  this.StringToColor = function (S) {
    var Result = 0;
    var us = "";
    var clr = 0;
    us = pas.SysUtils.UpperCase(S);
    if (us === "CLNONE") {
      Result = -1}
     else if (us === "CLBLACK") {
      Result = 0}
     else if (us === "CLMAROON") {
      Result = 128}
     else if (us === "CLGREEN") {
      Result = 32768}
     else if (us === "CLOLIVE") {
      Result = 32896}
     else if (us === "CLNAVY") {
      Result = 8388608}
     else if (us === "CLPURPLE") {
      Result = 8388736}
     else if (us === "CLTEAL") {
      Result = 8421376}
     else if (us === "CLGRAY") {
      Result = 8421504}
     else if (us === "CLSILVER") {
      Result = 12632256}
     else if (us === "CLRED") {
      Result = 255}
     else if (us === "CLLIME") {
      Result = 65280}
     else if (us === "CLYELLOW") {
      Result = 65535}
     else if (us === "CLBLUE") {
      Result = 16711680}
     else if (us === "CLFUCHSIA") {
      Result = 16711935}
     else if (us === "CLAQUA") {
      Result = 16776960}
     else if (us === "CLWHITE") {
      Result = 16777215}
     else if (us === "CLLTGRAY") {
      Result = 12698049}
     else if (us === "CLDKGRAY") {
      Result = 8487297}
     else if (us === "CLDEFAULT") {
      Result = 536870912}
     else if (us === "CLBTNFACE") {
      Result = 15790320}
     else if (us === "CLWINDOWTEXT") {
      Result = 65793}
     else if (us === "CLWINDOW") {
      Result = 16711422}
     else if (us === "CLHIGHLIGHT") {
      Result = 14120960}
     else if (us === "CLHIGHLIGHTTEXT") {
      Result = 16777215}
     else if (us === "CLINFOTEXT") {
      Result = 131586}
     else if (us === "CLINFOBK") {
      Result = 14811135}
     else if (us === "CLACTIVECAPTION") {
      Result = 13743257}
     else if (us === "CLINACTIVECAPTION") {
      Result = 14405055}
     else if (us === "CLHOTLIGHT") {
      Result = 13395456}
     else {
      clr = $mod.HexToColor(us);
      Result = ((clr & 0xFF) << 16) | (clr & 0xFF00) | ((clr & 0xFF0000) >>> 16) | (clr & 0xFF000000);
    };
    return Result;
  };
  this.CharsetToIdent = function (ACharSet) {
    var Result = "";
    var $tmp = ACharSet;
    if ($tmp === 0) {
      Result = "ANSI_CHARSET"}
     else if ($tmp === 1) {
      Result = "DEFAULT_CHARSET"}
     else if ($tmp === 2) {
      Result = "SYMBOL_CHARSET"}
     else if ($tmp === 77) {
      Result = "MAC_CHARSET"}
     else if ($tmp === 128) {
      Result = "SHIFTJIS_CHARSET"}
     else if ($tmp === 129) {
      Result = "HANGEUL_CHARSET"}
     else if ($tmp === 130) {
      Result = "JOHAB_CHARSET"}
     else if ($tmp === 134) {
      Result = "GB2312_CHARSET"}
     else if ($tmp === 136) {
      Result = "CHINESEBIG5_CHARSET"}
     else if ($tmp === 161) {
      Result = "GREEK_CHARSET"}
     else if ($tmp === 162) {
      Result = "TURKISH_CHARSET"}
     else if ($tmp === 177) {
      Result = "HEBREW_CHARSET"}
     else if ($tmp === 178) {
      Result = "ARABIC_CHARSET"}
     else if ($tmp === 186) {
      Result = "BALTIC_CHARSET"}
     else if ($tmp === 204) {
      Result = "RUSSIAN_CHARSET"}
     else if ($tmp === 222) {
      Result = "THAI_CHARSET"}
     else if ($tmp === 238) {
      Result = "EASTEUROPE_CHARSET"}
     else if ($tmp === 255) Result = "OEM_CHARSET";
    return Result;
  };
  this.IdentToCharset = function (S) {
    var Result = 0;
    if (S === "ANSI_CHARSET") Result = 0;
    if (S === "DEFAULT_CHARSET") Result = 1;
    if (S === "SYMBOL_CHARSET") Result = 2;
    if (S === "MAC_CHARSET") Result = 77;
    if (S === "SHIFTJIS_CHARSET") Result = 128;
    if (S === "HANGEUL_CHARSET") Result = 129;
    if (S === "JOHAB_CHARSET") Result = 130;
    if (S === "GB2312_CHARSET") Result = 134;
    if (S === "CHINESEBIG5_CHARSET") Result = 136;
    if (S === "GREEK_CHARSET") Result = 161;
    if (S === "TURKISH_CHARSET") Result = 162;
    if (S === "HEBREW_CHARSET") Result = 177;
    if (S === "ARABIC_CHARSET") Result = 178;
    if (S === "BALTIC_CHARSET") Result = 186;
    if (S === "RUSSIAN_CHARSET") Result = 204;
    if (S === "THAI_CHARSET") Result = 222;
    if (S === "EASTEUROPE_CHARSET") Result = 238;
    if (S === "OEM_CHARSET") Result = 255;
    return Result;
  };
  this.FontSizeToHTML = function (sz) {
    var Result = "";
    Result = pas.SysUtils.FloatToStr(sz) + "px";
    Result = pas.SysUtils.StringReplace(Result,",",".",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.HTMLChar = function (h) {
    var Result = 0;
    pas.System.Delete({get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},1,3);
    pas.System.Delete({get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},h.length - 1,1);
    Result = pas.SysUtils.StrToInt("0x" + h);
    return Result;
  };
  this.HexToColor = function (h) {
    var Result = 0;
    var s = "";
    var i = 0;
    s = "";
    for (var $l = 1, $end = h.length; $l <= $end; $l++) {
      i = $l;
      if (((h.charAt(i - 1) >= "0") && (h.charAt(i - 1) <= "9")) || ((h.charAt(i - 1) >= "A") && (h.charAt(i - 1) <= "F")) || ((h.charAt(i - 1) >= "a") && (h.charAt(i - 1) <= "f"))) s = s + h.charAt(i - 1);
    };
    if (s.length > 6) {
      s = "$" + pas.System.Copy(s,1,2) + pas.System.Copy(s,7,2) + pas.System.Copy(s,5,2) + pas.System.Copy(s,3,2)}
     else if (s.length === 3) {
      s = "$" + pas.System.Copy(s,3,1) + pas.System.Copy(s,3,1) + pas.System.Copy(s,2,1) + pas.System.Copy(s,2,1) + pas.System.Copy(s,1,1) + pas.System.Copy(s,1,1)}
     else s = "$" + pas.System.Copy(s,5,2) + pas.System.Copy(s,3,2) + pas.System.Copy(s,1,2);
    Result = pas.SysUtils.StrToInt64(s);
    return Result;
  };
  this.RGBToColor = function (argb) {
    var Result = 0;
    var r = "";
    var g = "";
    var b = "";
    var ri = 0;
    var gi = 0;
    var bi = 0;
    var e = 0;
    Result = -1;
    argb = pas.SysUtils.Trim(argb);
    if (pas.System.Pos("RGB",pas.SysUtils.UpperCase(argb)) > 0) {
      pas.System.Delete({get: function () {
          return argb;
        }, set: function (v) {
          argb = v;
        }},1,4);
      r = pas.System.Copy(argb,1,pas.System.Pos(",",argb) - 1);
      pas.System.Delete({get: function () {
          return argb;
        }, set: function (v) {
          argb = v;
        }},1,pas.System.Pos(",",argb) + 1);
      g = pas.System.Copy(argb,1,pas.System.Pos(",",argb) - 1);
      pas.System.Delete({get: function () {
          return argb;
        }, set: function (v) {
          argb = v;
        }},1,pas.System.Pos(",",argb) + 1);
      b = pas.System.Copy(argb,1,pas.System.Pos(")",argb) - 1);
      pas.System.val$3(r,{get: function () {
          return ri;
        }, set: function (v) {
          ri = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      pas.System.val$3(g,{get: function () {
          return gi;
        }, set: function (v) {
          gi = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      pas.System.val$3(b,{get: function () {
          return bi;
        }, set: function (v) {
          bi = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      Result = $mod.RGB(ri,gi,bi);
    };
    return Result;
  };
  this.FontSizeToPx = function (sz) {
    var Result = 0.0;
    Result = (sz * 96) / 72;
    return Result;
  };
  this.GetRValue = function (rgb) {
    var Result = 0;
    Result = rgb & 0xFF & 255;
    return Result;
  };
  this.GetGValue = function (rgb) {
    var Result = 0;
    Result = Math.floor(rgb / 256) & 0xFF & 255;
    return Result;
  };
  this.GetBValue = function (rgb) {
    var Result = 0;
    Result = Math.floor(rgb / 65536) & 0xFF & 255;
    return Result;
  };
  this.CreateCanvasRectF = function (Left, Top, Right, Bottom) {
    var Result = $mod.TCanvasRectF.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Right = Right;
    Result.Bottom = Bottom;
    return Result;
  };
  this.CreateCanvasPointF = function (X, Y) {
    var Result = $mod.TCanvasPointF.$new();
    Result.X = X;
    Result.Y = Y;
    return Result;
  };
  this.CreateCanvasSizeF = function (cx, cy) {
    var Result = $mod.TCanvasSizeF.$new();
    Result.cx = cx;
    Result.cy = cy;
    return Result;
  };
  this.CanvasRectF = function (Left, Top, Right, Bottom) {
    var Result = $mod.TCanvasRectF.$new();
    Result.$assign($mod.CreateCanvasRectF(Left,Top,Right,Bottom));
    return Result;
  };
  this.CanvasPointF = function (X, Y) {
    var Result = $mod.TCanvasPointF.$new();
    Result.$assign($mod.CreateCanvasPointF(X,Y));
    return Result;
  };
  this.CanvasSizeF = function (cx, cy) {
    var Result = $mod.TCanvasSizeF.$new();
    Result.$assign($mod.CreateCanvasSizeF(cx,cy));
    return Result;
  };
  this.RGB = function (r, g, b) {
    var Result = 0;
    Result = r | (g << 8) | (b << 16);
    return Result;
  };
  this.RGBA = function (r, g, b, a) {
    var Result = 0;
    Result = r | (g << 8) | (b << 16) | (a << 24);
    return Result;
  };
  this.CSSFont = function (Font) {
    var Result = "";
    var res = "";
    var fs = "";
    res = "font-family:" + Font.FName + ";";
    res = res + "font-style: normal;";
    if ($mod.TFontStyle.fsBold in Font.FStyle) res = res + "font-weight: bold;";
    if ($mod.TFontStyle.fsItalic in Font.FStyle) res = res + "font-style: italic;";
    fs = "";
    if ($mod.TFontStyle.fsUnderline in Font.FStyle) fs = fs + " underline";
    if ($mod.TFontStyle.fsStrikeOut in Font.FStyle) fs = fs + " line-through";
    if (fs !== "") res = res + "text-decoration:" + fs + ";";
    res = res + "font-size:" + pas.SysUtils.IntToStr(Font.FSize) + "pt;";
    Result = res;
    return Result;
  };
  this.CreateThumbnail = function (ADataURL, AWidth, AHeight, UseAspectRatio, ThumbnailReady) {
    var LImg = null;
    if ((AWidth <= 0) || (AHeight <= 0)) return;
    LImg = document.createElement("IMG");
    LImg.onload = function() {
    
          var w = LImg.width;
          var h = LImg.height;
    
          var neww = AWidth;
          var newh = AHeight;
    
          if (UseAspectRatio) {
            if ((w/neww) > (h/newh))
            {
              newh = h / (w/neww);
            }
            else
            {
              neww = w / (h/newh);
            }
          }
          var LCanvas = document.createElement('CANVAS');
          var ctx = LCanvas.getContext("2d");
          ctx.drawImage(LImg, 0, 0, neww, newh);
          var res = LCanvas.toDataURL("image/png");
          ThumbnailReady(res);
        };
    LImg.setAttribute("src",ADataURL);
  };
  $mod.$implcode = function () {
    rtl.createClass($impl,"TGraphicCache",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FImage = null;
        this.FID = "";
      };
      this.$final = function () {
        this.FImage = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function (AImage, AID) {
        this.FImage = AImage;
        this.FID = AID;
        return this;
      };
    });
    rtl.createClass($impl,"TGraphicCacheList",pas.contnrs.TObjectList,function () {
      this.Find = function (AID, FImage) {
        var Result = false;
        var I = 0;
        var it = null;
        Result = false;
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = rtl.as(this.GetItem(I),$impl.TGraphicCache);
          if ((it.FID === AID) && (it.FImage != null)) {
            FImage.set(it.FImage);
            Result = true;
            break;
          };
        };
        return Result;
      };
      this.Exists = function (AID) {
        var Result = false;
        var I = 0;
        var it = null;
        Result = false;
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = rtl.as(this.GetItem(I),$impl.TGraphicCache);
          if ((it.FID === AID) && (it.FImage != null)) {
            Result = true;
            break;
          };
        };
        return Result;
      };
    });
    $impl.FCache = null;
    $impl.FQueue = null;
    $impl.FCacheCount = 0;
    $impl.MatrixIdentity = function () {
      var Result = $mod.TMatrix.$new();
      Result.m11 = 1;
      Result.m12 = 0;
      Result.m13 = 0;
      Result.m21 = 0;
      Result.m22 = 1;
      Result.m23 = 0;
      Result.m31 = 0;
      Result.m32 = 0;
      Result.m33 = 1;
      return Result;
    };
    $impl.GetPixelRatio = function (ACanvas) {
      var Result = 0.0;
      var res = 0.0;
      var ca = null;
      ca = ACanvas;
      var ctx = ca.FContext,
          dpr = window.devicePixelRatio || 1,
          bsr = ctx.webkitBackingStorePixelRatio ||
                ctx.mozBackingStorePixelRatio ||
                ctx.msBackingStorePixelRatio ||
                ctx.oBackingStorePixelRatio ||
                ctx.backingStorePixelRatio || 1;
      res = dpr / bsr;
      Result = res;
      return Result;
    };
    $impl.MatrixCreateScaling = function (AScaleX, AScaleY) {
      var Result = $mod.TMatrix.$new();
      Result.$assign($impl.MatrixIdentity());
      Result.m11 = AScaleX;
      Result.m22 = AScaleY;
      return Result;
    };
    $impl.MatrixMultiply = function (AMatrix1, AMatrix2) {
      var Result = $mod.TMatrix.$new();
      Result.m11 = (AMatrix1.m11 * AMatrix2.m11) + (AMatrix1.m12 * AMatrix2.m21) + (AMatrix1.m13 * AMatrix2.m31);
      Result.m12 = (AMatrix1.m11 * AMatrix2.m12) + (AMatrix1.m12 * AMatrix2.m22) + (AMatrix1.m13 * AMatrix2.m32);
      Result.m13 = (AMatrix1.m11 * AMatrix2.m13) + (AMatrix1.m12 * AMatrix2.m23) + (AMatrix1.m13 * AMatrix2.m33);
      Result.m21 = (AMatrix1.m21 * AMatrix2.m11) + (AMatrix1.m22 * AMatrix2.m21) + (AMatrix1.m23 * AMatrix2.m31);
      Result.m22 = (AMatrix1.m21 * AMatrix2.m12) + (AMatrix1.m22 * AMatrix2.m22) + (AMatrix1.m23 * AMatrix2.m32);
      Result.m23 = (AMatrix1.m21 * AMatrix2.m13) + (AMatrix1.m22 * AMatrix2.m23) + (AMatrix1.m23 * AMatrix2.m33);
      Result.m31 = (AMatrix1.m31 * AMatrix2.m11) + (AMatrix1.m32 * AMatrix2.m21) + (AMatrix1.m33 * AMatrix2.m31);
      Result.m32 = (AMatrix1.m31 * AMatrix2.m12) + (AMatrix1.m32 * AMatrix2.m22) + (AMatrix1.m33 * AMatrix2.m32);
      Result.m33 = (AMatrix1.m31 * AMatrix2.m13) + (AMatrix1.m32 * AMatrix2.m23) + (AMatrix1.m33 * AMatrix2.m33);
      return Result;
    };
    $impl.ColorToVCL = function (c) {
      var Result = "";
      var s = "";
      s = c.toString(16);
      while (s.length < 6)
      {
        s = "0" + s;
      };
      Result = pas.System.Copy(s,1,2) + pas.System.Copy(s,3,2) + pas.System.Copy(s,5,2);
      return Result;
    };
    $impl.AngleOfPoints = function (x1, y1, x2, y2) {
      var Result = 0.0;
      var part1 = 0.0;
      var part2 = 0.0;
      var angle = 0.0;
      if ((x1 === x2) && (y1 === y2)) {
        Result = 0.0;
        return Result;
      };
      part1 = Math.abs(y2 - y1);
      if (part1 === 0) {
        part1 = 0.0000001;
        y1 = y1 + 0.0000001;
      };
      part2 = Math.abs(x2 - x1);
      if (part2 === 0) {
        part2 = 0.0000001;
        x1 = x1 + 0.0000001;
      };
      angle = Math.atan(part1 / part2);
      if ((x1 > x2) && (y1 < y2)) angle = Math.PI - angle;
      if ((x1 > x2) && (y1 > y2)) angle = angle + Math.PI;
      if ((x1 < x2) && (y1 > y2)) angle = (2 * Math.PI) - angle;
      while (angle >= (2 * Math.PI)) angle = angle - (2 * Math.PI);
      while (angle < 0) angle = angle + (2 * Math.PI);
      Result = angle;
      return Result;
    };
  };
  $mod.$init = function () {
    $impl.FCache = $impl.TGraphicCacheList.$create("Create$2");
    $impl.FQueue = pas.Classes.TStringList.$create("Create$1");
  };
},["WEBLib.Forms","WEBLib.WebTools","Math","SysUtils","contnrs"]);
rtl.module("WEBLib.Modules",["System","Classes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TDataModule");
  this.$rtti.$ClassRef("TDataModuleClass",{instancetype: this.$rtti["TDataModule"]});
  rtl.createClass(this,"TDataModule",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FHeight = 0;
      this.FOldCreateOrder = false;
      this.FOnCreate = null;
      this.FOnDestroy = null;
      this.FWidth = 0;
    };
    this.$final = function () {
      this.FOnCreate = undefined;
      this.FOnDestroy = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.DoCreate = function () {
      this.LoadDFMValues();
      if (this.FOnCreate != null) this.FOnCreate(this);
    };
    this.DoDestroy = function () {
      if (this.FOnDestroy != null) this.FOnDestroy(this);
    };
    this.LoadDFMValues = function () {
    };
    this.CreateNew = function (AOwner, Dummy) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      return this;
    };
    this.AfterConstruction = function () {
      pas.System.TObject.AfterConstruction.call(this);
      if (!this.FOldCreateOrder) this.DoCreate();
    };
    this.BeforeDestruction = function () {
      pas.Classes.TComponent.BeforeDestruction.call(this);
      if (!this.FOldCreateOrder) this.DoDestroy();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnCreate",0,pas.Classes.$rtti["TNotifyEvent"],"FOnCreate","FOnCreate");
    $r.addProperty("OnDestroy",0,pas.Classes.$rtti["TNotifyEvent"],"FOnDestroy","FOnDestroy");
  });
});
rtl.module("WEBLib.Lang",["System"],function () {
  "use strict";
  var $mod = this;
  this.TUILanguage = {"0": "lNone", lNone: 0, "1": "lAfar", lAfar: 1, "2": "lAbkhazian", lAbkhazian: 2, "3": "lAvestan", lAvestan: 3, "4": "lAfrikaans", lAfrikaans: 4, "5": "lAkan", lAkan: 5, "6": "lAmharic", lAmharic: 6, "7": "lAragonese", lAragonese: 7, "8": "lArabic", lArabic: 8, "9": "lAssamese", lAssamese: 9, "10": "lAvaric", lAvaric: 10, "11": "lAymara", lAymara: 11, "12": "lAzerbaijani", lAzerbaijani: 12, "13": "lBashkir", lBashkir: 13, "14": "lBelarusian", lBelarusian: 14, "15": "lBulgarian", lBulgarian: 15, "16": "lBihari", lBihari: 16, "17": "lBislama", lBislama: 17, "18": "lBambara", lBambara: 18, "19": "lBengali", lBengali: 19, "20": "lTibetan", lTibetan: 20, "21": "lBreton", lBreton: 21, "22": "lBosnian", lBosnian: 22, "23": "lCatalan", lCatalan: 23, "24": "lChechen", lChechen: 24, "25": "lChamorro", lChamorro: 25, "26": "lCorsican", lCorsican: 26, "27": "lCree", lCree: 27, "28": "lCzech", lCzech: 28, "29": "lOldSlavic", lOldSlavic: 29, "30": "lChuvash", lChuvash: 30, "31": "lWelsh", lWelsh: 31, "32": "lDanish", lDanish: 32, "33": "lGerman", lGerman: 33, "34": "lDivehi", lDivehi: 34, "35": "lDzongkha", lDzongkha: 35, "36": "lEwe", lEwe: 36, "37": "lEnglish", lEnglish: 37, "38": "lEsperanto", lEsperanto: 38, "39": "lSpanish", lSpanish: 39, "40": "lEstonian", lEstonian: 40, "41": "lBasque", lBasque: 41, "42": "lPersian", lPersian: 42, "43": "lFulah", lFulah: 43, "44": "lFinnish", lFinnish: 44, "45": "lFijian", lFijian: 45, "46": "lFaroese", lFaroese: 46, "47": "lFrench", lFrench: 47, "48": "lWesternFrisian", lWesternFrisian: 48, "49": "lIrish", lIrish: 49, "50": "lGaelic", lGaelic: 50, "51": "lGalician", lGalician: 51, "52": "lGuarani", lGuarani: 52, "53": "lGujarati", lGujarati: 53, "54": "lManx", lManx: 54, "55": "lHausa", lHausa: 55, "56": "lHebrew", lHebrew: 56, "57": "lHindi", lHindi: 57, "58": "lHiriMotu", lHiriMotu: 58, "59": "lCroatian", lCroatian: 59, "60": "lHaitian", lHaitian: 60, "61": "lHungarian", lHungarian: 61, "62": "lArmenian", lArmenian: 62, "63": "lHerero", lHerero: 63, "64": "lInterlingua", lInterlingua: 64, "65": "lIndonesian", lIndonesian: 65, "66": "lInterlingue", lInterlingue: 66, "67": "lIgbo", lIgbo: 67, "68": "lSichuanYi", lSichuanYi: 68, "69": "lInupiaq", lInupiaq: 69, "70": "lIdo", lIdo: 70, "71": "lIcelandic", lIcelandic: 71, "72": "lItalian", lItalian: 72, "73": "lInuktitut", lInuktitut: 73, "74": "lJapanese", lJapanese: 74, "75": "lJavanese", lJavanese: 75, "76": "lGeorgian", lGeorgian: 76, "77": "lKongo", lKongo: 77, "78": "lKikuyu", lKikuyu: 78, "79": "lKuanyama", lKuanyama: 79, "80": "lKazakh", lKazakh: 80, "81": "lKalaallisut", lKalaallisut: 81, "82": "lCentralKhmer", lCentralKhmer: 82, "83": "lKannada", lKannada: 83, "84": "lKorean", lKorean: 84, "85": "lKanuri", lKanuri: 85, "86": "lKashmiri", lKashmiri: 86, "87": "lKurdish", lKurdish: 87, "88": "lKomi", lKomi: 88, "89": "lCornish", lCornish: 89, "90": "lKirghiz", lKirghiz: 90, "91": "lLatin", lLatin: 91, "92": "lLuxembourgish", lLuxembourgish: 92, "93": "lGanda", lGanda: 93, "94": "lLimburgan", lLimburgan: 94, "95": "lLingala", lLingala: 95, "96": "lLao", lLao: 96, "97": "lLithuanian", lLithuanian: 97, "98": "lLubaKatanga", lLubaKatanga: 98, "99": "lLatvian", lLatvian: 99, "100": "lMalagasy", lMalagasy: 100, "101": "lMarshallese", lMarshallese: 101, "102": "lMaori", lMaori: 102, "103": "lMacedonian", lMacedonian: 103, "104": "lMalayalam", lMalayalam: 104, "105": "lMongolian", lMongolian: 105, "106": "lMarathi", lMarathi: 106, "107": "lMalay", lMalay: 107, "108": "lMaltese", lMaltese: 108, "109": "lBurmese", lBurmese: 109, "110": "lNauru", lNauru: 110, "111": "lNdebele", lNdebele: 111, "112": "lNepali", lNepali: 112, "113": "lNdonga", lNdonga: 113, "114": "lDutch", lDutch: 114, "115": "lNorwegian", lNorwegian: 115, "116": "lNavajo", lNavajo: 116, "117": "lChichewa", lChichewa: 117, "118": "lOccitan", lOccitan: 118, "119": "lOjibwa", lOjibwa: 119, "120": "lOromo", lOromo: 120, "121": "lOriya", lOriya: 121, "122": "lOssetian", lOssetian: 122, "123": "lPanjabi", lPanjabi: 123, "124": "lPali", lPali: 124, "125": "lPolish", lPolish: 125, "126": "lPushto", lPushto: 126, "127": "lPortuguese", lPortuguese: 127, "128": "lQuechua", lQuechua: 128, "129": "lRomansh", lRomansh: 129, "130": "lRundi", lRundi: 130, "131": "lRomanian", lRomanian: 131, "132": "lRussian", lRussian: 132, "133": "lKinyarwanda", lKinyarwanda: 133, "134": "lSanskrit", lSanskrit: 134, "135": "lSardinian", lSardinian: 135, "136": "lSindhi", lSindhi: 136, "137": "lNorthernSami", lNorthernSami: 137, "138": "lSango", lSango: 138, "139": "lSinhala", lSinhala: 139, "140": "lSlovak", lSlovak: 140, "141": "lSlovenian", lSlovenian: 141, "142": "lSamoan", lSamoan: 142, "143": "lShona", lShona: 143, "144": "lSomali", lSomali: 144, "145": "lAlbanian", lAlbanian: 145, "146": "lSerbian", lSerbian: 146, "147": "lSwati", lSwati: 147, "148": "lSotho", lSotho: 148, "149": "lSundanese", lSundanese: 149, "150": "lSwedish", lSwedish: 150, "151": "lSwahili", lSwahili: 151, "152": "lTamil", lTamil: 152, "153": "lTelugu", lTelugu: 153, "154": "lTajik", lTajik: 154, "155": "lThai", lThai: 155, "156": "lTigrinya", lTigrinya: 156, "157": "lTurkmen", lTurkmen: 157, "158": "lTagalog", lTagalog: 158, "159": "lTswana", lTswana: 159, "160": "lTonga", lTonga: 160, "161": "lTurkish", lTurkish: 161, "162": "lTsonga", lTsonga: 162, "163": "lTatar", lTatar: 163, "164": "lTwi", lTwi: 164, "165": "lTahitian", lTahitian: 165, "166": "lUighur", lUighur: 166, "167": "lUkrainian", lUkrainian: 167, "168": "lUrdu", lUrdu: 168, "169": "lUzbek", lUzbek: 169, "170": "lVenda", lVenda: 170, "171": "lVietnamese", lVietnamese: 171, "172": "lWalloon", lWalloon: 172, "173": "lWolof", lWolof: 173, "174": "lXhosa", lXhosa: 174, "175": "lYiddish", lYiddish: 175, "176": "lYoruba", lYoruba: 176, "177": "lZhuang", lZhuang: 177, "178": "lChinese", lChinese: 178, "179": "lZulu", lZulu: 179};
  this.$rtti.$Enum("TUILanguage",{minvalue: 0, maxvalue: 179, ordtype: 1, enumtype: this.TUILanguage});
  this.GetLanguageISO639_1Code = function (ALang) {
    var Result = "";
    var $tmp = ALang;
    if ($tmp === $mod.TUILanguage.lNone) {
      Result = ""}
     else if ($tmp === $mod.TUILanguage.lAfar) {
      Result = "aa"}
     else if ($tmp === $mod.TUILanguage.lAbkhazian) {
      Result = "ab"}
     else if ($tmp === $mod.TUILanguage.lAvestan) {
      Result = "ae"}
     else if ($tmp === $mod.TUILanguage.lAfrikaans) {
      Result = "af"}
     else if ($tmp === $mod.TUILanguage.lAkan) {
      Result = "ak"}
     else if ($tmp === $mod.TUILanguage.lAmharic) {
      Result = "am"}
     else if ($tmp === $mod.TUILanguage.lAragonese) {
      Result = "an"}
     else if ($tmp === $mod.TUILanguage.lArabic) {
      Result = "ar"}
     else if ($tmp === $mod.TUILanguage.lAssamese) {
      Result = "as"}
     else if ($tmp === $mod.TUILanguage.lAvaric) {
      Result = "av"}
     else if ($tmp === $mod.TUILanguage.lAymara) {
      Result = "ay"}
     else if ($tmp === $mod.TUILanguage.lAzerbaijani) {
      Result = "az"}
     else if ($tmp === $mod.TUILanguage.lBashkir) {
      Result = "ba"}
     else if ($tmp === $mod.TUILanguage.lBelarusian) {
      Result = "be"}
     else if ($tmp === $mod.TUILanguage.lBulgarian) {
      Result = "bg"}
     else if ($tmp === $mod.TUILanguage.lBihari) {
      Result = "bh"}
     else if ($tmp === $mod.TUILanguage.lBislama) {
      Result = "bi"}
     else if ($tmp === $mod.TUILanguage.lBambara) {
      Result = "bm"}
     else if ($tmp === $mod.TUILanguage.lBengali) {
      Result = "bn"}
     else if ($tmp === $mod.TUILanguage.lTibetan) {
      Result = "bo"}
     else if ($tmp === $mod.TUILanguage.lBreton) {
      Result = "br"}
     else if ($tmp === $mod.TUILanguage.lBosnian) {
      Result = "bd"}
     else if ($tmp === $mod.TUILanguage.lCatalan) {
      Result = "ca"}
     else if ($tmp === $mod.TUILanguage.lChechen) {
      Result = "ce"}
     else if ($tmp === $mod.TUILanguage.lChamorro) {
      Result = "ch"}
     else if ($tmp === $mod.TUILanguage.lCorsican) {
      Result = "co"}
     else if ($tmp === $mod.TUILanguage.lCree) {
      Result = "cr"}
     else if ($tmp === $mod.TUILanguage.lCzech) {
      Result = "cs"}
     else if ($tmp === $mod.TUILanguage.lOldSlavic) {
      Result = "cu"}
     else if ($tmp === $mod.TUILanguage.lChuvash) {
      Result = "cv"}
     else if ($tmp === $mod.TUILanguage.lWelsh) {
      Result = "cy"}
     else if ($tmp === $mod.TUILanguage.lDanish) {
      Result = "da"}
     else if ($tmp === $mod.TUILanguage.lGerman) {
      Result = "de"}
     else if ($tmp === $mod.TUILanguage.lDivehi) {
      Result = "dv"}
     else if ($tmp === $mod.TUILanguage.lDzongkha) {
      Result = "dz"}
     else if ($tmp === $mod.TUILanguage.lEwe) {
      Result = "ee"}
     else if ($tmp === $mod.TUILanguage.lEnglish) {
      Result = "en"}
     else if ($tmp === $mod.TUILanguage.lEsperanto) {
      Result = "eo"}
     else if ($tmp === $mod.TUILanguage.lSpanish) {
      Result = "es"}
     else if ($tmp === $mod.TUILanguage.lEstonian) {
      Result = "et"}
     else if ($tmp === $mod.TUILanguage.lBasque) {
      Result = "eu"}
     else if ($tmp === $mod.TUILanguage.lPersian) {
      Result = "fa"}
     else if ($tmp === $mod.TUILanguage.lFulah) {
      Result = "ff"}
     else if ($tmp === $mod.TUILanguage.lFinnish) {
      Result = "fi"}
     else if ($tmp === $mod.TUILanguage.lFijian) {
      Result = "fj"}
     else if ($tmp === $mod.TUILanguage.lFaroese) {
      Result = "fo"}
     else if ($tmp === $mod.TUILanguage.lFrench) {
      Result = "fr"}
     else if ($tmp === $mod.TUILanguage.lWesternFrisian) {
      Result = "fy"}
     else if ($tmp === $mod.TUILanguage.lIrish) {
      Result = "ga"}
     else if ($tmp === $mod.TUILanguage.lGaelic) {
      Result = "gd"}
     else if ($tmp === $mod.TUILanguage.lGalician) {
      Result = "gl"}
     else if ($tmp === $mod.TUILanguage.lGuarani) {
      Result = "gn"}
     else if ($tmp === $mod.TUILanguage.lGujarati) {
      Result = "gu"}
     else if ($tmp === $mod.TUILanguage.lManx) {
      Result = "gv"}
     else if ($tmp === $mod.TUILanguage.lHausa) {
      Result = "ha"}
     else if ($tmp === $mod.TUILanguage.lHebrew) {
      Result = "he"}
     else if ($tmp === $mod.TUILanguage.lHindi) {
      Result = "hi"}
     else if ($tmp === $mod.TUILanguage.lHiriMotu) {
      Result = "ho"}
     else if ($tmp === $mod.TUILanguage.lCroatian) {
      Result = "hr"}
     else if ($tmp === $mod.TUILanguage.lHaitian) {
      Result = "ht"}
     else if ($tmp === $mod.TUILanguage.lHungarian) {
      Result = "hu"}
     else if ($tmp === $mod.TUILanguage.lArmenian) {
      Result = "hy"}
     else if ($tmp === $mod.TUILanguage.lHerero) {
      Result = "hz"}
     else if ($tmp === $mod.TUILanguage.lInterlingua) {
      Result = "ia"}
     else if ($tmp === $mod.TUILanguage.lIndonesian) {
      Result = "id"}
     else if ($tmp === $mod.TUILanguage.lInterlingue) {
      Result = "ie"}
     else if ($tmp === $mod.TUILanguage.lIgbo) {
      Result = "ig"}
     else if ($tmp === $mod.TUILanguage.lSichuanYi) {
      Result = "ii"}
     else if ($tmp === $mod.TUILanguage.lInupiaq) {
      Result = "ik"}
     else if ($tmp === $mod.TUILanguage.lIdo) {
      Result = "id"}
     else if ($tmp === $mod.TUILanguage.lIcelandic) {
      Result = "is"}
     else if ($tmp === $mod.TUILanguage.lItalian) {
      Result = "it"}
     else if ($tmp === $mod.TUILanguage.lInuktitut) {
      Result = "iu"}
     else if ($tmp === $mod.TUILanguage.lJapanese) {
      Result = "ja"}
     else if ($tmp === $mod.TUILanguage.lJavanese) {
      Result = "jv"}
     else if ($tmp === $mod.TUILanguage.lGeorgian) {
      Result = "ka"}
     else if ($tmp === $mod.TUILanguage.lKongo) {
      Result = "kg"}
     else if ($tmp === $mod.TUILanguage.lKikuyu) {
      Result = "ki"}
     else if ($tmp === $mod.TUILanguage.lKuanyama) {
      Result = "kj"}
     else if ($tmp === $mod.TUILanguage.lKazakh) {
      Result = "kk"}
     else if ($tmp === $mod.TUILanguage.lKalaallisut) {
      Result = "kl"}
     else if ($tmp === $mod.TUILanguage.lCentralKhmer) {
      Result = "km"}
     else if ($tmp === $mod.TUILanguage.lKannada) {
      Result = "kn"}
     else if ($tmp === $mod.TUILanguage.lKorean) {
      Result = "ko"}
     else if ($tmp === $mod.TUILanguage.lKanuri) {
      Result = "kr"}
     else if ($tmp === $mod.TUILanguage.lKashmiri) {
      Result = "ks"}
     else if ($tmp === $mod.TUILanguage.lKurdish) {
      Result = "ku"}
     else if ($tmp === $mod.TUILanguage.lKomi) {
      Result = "kv"}
     else if ($tmp === $mod.TUILanguage.lCornish) {
      Result = "kw"}
     else if ($tmp === $mod.TUILanguage.lKirghiz) {
      Result = "ky"}
     else if ($tmp === $mod.TUILanguage.lLatin) {
      Result = "la"}
     else if ($tmp === $mod.TUILanguage.lLuxembourgish) {
      Result = "lb"}
     else if ($tmp === $mod.TUILanguage.lGanda) {
      Result = "lg"}
     else if ($tmp === $mod.TUILanguage.lLimburgan) {
      Result = "li"}
     else if ($tmp === $mod.TUILanguage.lLingala) {
      Result = "ln"}
     else if ($tmp === $mod.TUILanguage.lLao) {
      Result = "lo"}
     else if ($tmp === $mod.TUILanguage.lLithuanian) {
      Result = "lt"}
     else if ($tmp === $mod.TUILanguage.lLubaKatanga) {
      Result = "lu"}
     else if ($tmp === $mod.TUILanguage.lLatvian) {
      Result = "lv"}
     else if ($tmp === $mod.TUILanguage.lMalagasy) {
      Result = "mg"}
     else if ($tmp === $mod.TUILanguage.lMarshallese) {
      Result = "mh"}
     else if ($tmp === $mod.TUILanguage.lMaori) {
      Result = "mi"}
     else if ($tmp === $mod.TUILanguage.lMacedonian) {
      Result = "mk"}
     else if ($tmp === $mod.TUILanguage.lMalayalam) {
      Result = "ml"}
     else if ($tmp === $mod.TUILanguage.lMongolian) {
      Result = "mn"}
     else if ($tmp === $mod.TUILanguage.lMarathi) {
      Result = "mr"}
     else if ($tmp === $mod.TUILanguage.lMalay) {
      Result = "ms"}
     else if ($tmp === $mod.TUILanguage.lMaltese) {
      Result = "mt"}
     else if ($tmp === $mod.TUILanguage.lBurmese) {
      Result = "my"}
     else if ($tmp === $mod.TUILanguage.lNauru) {
      Result = "na"}
     else if ($tmp === $mod.TUILanguage.lNdebele) {
      Result = "nb"}
     else if ($tmp === $mod.TUILanguage.lNepali) {
      Result = "nd"}
     else if ($tmp === $mod.TUILanguage.lNdonga) {
      Result = "ng"}
     else if ($tmp === $mod.TUILanguage.lDutch) {
      Result = "nl"}
     else if ($tmp === $mod.TUILanguage.lNorwegian) {
      Result = "no"}
     else if ($tmp === $mod.TUILanguage.lNavajo) {
      Result = "nv"}
     else if ($tmp === $mod.TUILanguage.lChichewa) {
      Result = "ny"}
     else if ($tmp === $mod.TUILanguage.lOccitan) {
      Result = "oc"}
     else if ($tmp === $mod.TUILanguage.lOjibwa) {
      Result = "oj"}
     else if ($tmp === $mod.TUILanguage.lOromo) {
      Result = "om"}
     else if ($tmp === $mod.TUILanguage.lOriya) {
      Result = "or"}
     else if ($tmp === $mod.TUILanguage.lOssetian) {
      Result = "os"}
     else if ($tmp === $mod.TUILanguage.lPanjabi) {
      Result = "pa"}
     else if ($tmp === $mod.TUILanguage.lPali) {
      Result = "pi"}
     else if ($tmp === $mod.TUILanguage.lPolish) {
      Result = "pl"}
     else if ($tmp === $mod.TUILanguage.lPushto) {
      Result = "ps"}
     else if ($tmp === $mod.TUILanguage.lPortuguese) {
      Result = "pt"}
     else if ($tmp === $mod.TUILanguage.lQuechua) {
      Result = "qu"}
     else if ($tmp === $mod.TUILanguage.lRomansh) {
      Result = "rm"}
     else if ($tmp === $mod.TUILanguage.lRundi) {
      Result = "rn"}
     else if ($tmp === $mod.TUILanguage.lRomanian) {
      Result = "ro"}
     else if ($tmp === $mod.TUILanguage.lRussian) {
      Result = "ru"}
     else if ($tmp === $mod.TUILanguage.lKinyarwanda) {
      Result = "rw"}
     else if ($tmp === $mod.TUILanguage.lSanskrit) {
      Result = "sa"}
     else if ($tmp === $mod.TUILanguage.lSardinian) {
      Result = "sc"}
     else if ($tmp === $mod.TUILanguage.lSindhi) {
      Result = "sd"}
     else if ($tmp === $mod.TUILanguage.lNorthernSami) {
      Result = "se"}
     else if ($tmp === $mod.TUILanguage.lSango) {
      Result = "sg"}
     else if ($tmp === $mod.TUILanguage.lSinhala) {
      Result = "si"}
     else if ($tmp === $mod.TUILanguage.lSlovak) {
      Result = "sk"}
     else if ($tmp === $mod.TUILanguage.lSlovenian) {
      Result = "sl"}
     else if ($tmp === $mod.TUILanguage.lSamoan) {
      Result = "sm"}
     else if ($tmp === $mod.TUILanguage.lShona) {
      Result = "sn"}
     else if ($tmp === $mod.TUILanguage.lSomali) {
      Result = "so"}
     else if ($tmp === $mod.TUILanguage.lAlbanian) {
      Result = "sq"}
     else if ($tmp === $mod.TUILanguage.lSerbian) {
      Result = "sr"}
     else if ($tmp === $mod.TUILanguage.lSwati) {
      Result = "ss"}
     else if ($tmp === $mod.TUILanguage.lSotho) {
      Result = "st"}
     else if ($tmp === $mod.TUILanguage.lSundanese) {
      Result = "su"}
     else if ($tmp === $mod.TUILanguage.lSwedish) {
      Result = "sv"}
     else if ($tmp === $mod.TUILanguage.lSwahili) {
      Result = "sw"}
     else if ($tmp === $mod.TUILanguage.lTamil) {
      Result = "ta"}
     else if ($tmp === $mod.TUILanguage.lTelugu) {
      Result = "te"}
     else if ($tmp === $mod.TUILanguage.lTajik) {
      Result = "tg"}
     else if ($tmp === $mod.TUILanguage.lThai) {
      Result = "th"}
     else if ($tmp === $mod.TUILanguage.lTigrinya) {
      Result = "ti"}
     else if ($tmp === $mod.TUILanguage.lTurkmen) {
      Result = "tk"}
     else if ($tmp === $mod.TUILanguage.lTagalog) {
      Result = "tl"}
     else if ($tmp === $mod.TUILanguage.lTswana) {
      Result = "tn"}
     else if ($tmp === $mod.TUILanguage.lTonga) {
      Result = "to"}
     else if ($tmp === $mod.TUILanguage.lTurkish) {
      Result = "tr"}
     else if ($tmp === $mod.TUILanguage.lTsonga) {
      Result = "ts"}
     else if ($tmp === $mod.TUILanguage.lTatar) {
      Result = "tt"}
     else if ($tmp === $mod.TUILanguage.lTwi) {
      Result = "tw"}
     else if ($tmp === $mod.TUILanguage.lTahitian) {
      Result = "ty"}
     else if ($tmp === $mod.TUILanguage.lUighur) {
      Result = "ug"}
     else if ($tmp === $mod.TUILanguage.lUkrainian) {
      Result = "uk"}
     else if ($tmp === $mod.TUILanguage.lUrdu) {
      Result = "ur"}
     else if ($tmp === $mod.TUILanguage.lUzbek) {
      Result = "uz"}
     else if ($tmp === $mod.TUILanguage.lVenda) {
      Result = "ve"}
     else if ($tmp === $mod.TUILanguage.lVietnamese) {
      Result = "vi"}
     else if ($tmp === $mod.TUILanguage.lWalloon) {
      Result = "wa"}
     else if ($tmp === $mod.TUILanguage.lWolof) {
      Result = "wo"}
     else if ($tmp === $mod.TUILanguage.lXhosa) {
      Result = "xh"}
     else if ($tmp === $mod.TUILanguage.lYiddish) {
      Result = "yi"}
     else if ($tmp === $mod.TUILanguage.lYoruba) {
      Result = "yo"}
     else if ($tmp === $mod.TUILanguage.lZhuang) {
      Result = "za"}
     else if ($tmp === $mod.TUILanguage.lChinese) {
      Result = "zh"}
     else if ($tmp === $mod.TUILanguage.lZulu) Result = "zu";
    return Result;
  };
});
rtl.module("WEBLib.Menus",["System","Classes","SysUtils","WEBLib.Controls","WEBLib.Graphics","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TMainMenu");
  this.$rtti.$Class("TMenuItem");
  this.$rtti.$Class("TCustomMainMenu");
  this.TMenuItemAutoFlag = {"0": "maAutomatic", maAutomatic: 0, "1": "maManual", maManual: 1, "2": "maParent", maParent: 2};
  this.$rtti.$Enum("TMenuItemAutoFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMenuItemAutoFlag});
  this.TMenuBreak = {"0": "mbNone", mbNone: 0, "1": "mbBreak", mbBreak: 1, "2": "mbBarBreak", mbBarBreak: 2};
  this.$rtti.$Enum("TMenuBreak",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMenuBreak});
  this.$rtti.$Int("THelpContext",{minvalue: -2147483647, maxvalue: 2147483647, ordtype: 4});
  this.$rtti.$inherited("TShortCut",rtl.word,{});
  this.TMainMenuHamburgerMenuVisible = {"0": "hmAlways", hmAlways: 0, "1": "hmNever", hmNever: 1, "2": "hmResponsive", hmResponsive: 2};
  this.$rtti.$Enum("TMainMenuHamburgerMenuVisible",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMainMenuHamburgerMenuVisible});
  this.$rtti.$MethodVar("TMainMenuChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",this.$rtti["TMenuItem"]],["Rebuild",rtl.boolean]]), methodkind: 0});
  rtl.createClass(this,"TMenuItemList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.PutItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TMenuItem",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FOwner$1 = null;
      this.FCaption = "";
      this.FItems = null;
      this.FParentItem = null;
      this.FUpdateCount = 0;
      this.FOnClick = null;
      this.FChecked = false;
      this.FEnabled = false;
      this.FDefault = false;
      this.FAutoCheck = false;
      this.FHint = "";
      this.FAutoHotkeys = 0;
      this.FRadioItem = false;
      this.FGroupIndex = 0;
      this.FVisible = false;
      this.FShortCut = 0;
      this.FBreak = 0;
      this.FImageIndex = 0;
      this.FAutoLineReduction = 0;
      this.FHelpContext = 0;
      this.FElementClassName = "";
      this.FParentMenu = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FItems = undefined;
      this.FParentItem = undefined;
      this.FOnClick = undefined;
      this.FParentMenu = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetChecked = function (Value) {
      var pm = null;
      var Item = null;
      var OtherItem = null;
      var MenuOwner = null;
      var I = 0;
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        MenuOwner = this.FParentMenu;
        if (MenuOwner != null) {
          if ($mod.TMenuItem.isPrototypeOf(MenuOwner) && Value) {
            Item = MenuOwner;
            for (var $l = 0, $end = Item.FItems.GetCount() - 1; $l <= $end; $l++) {
              I = $l;
              OtherItem = Item.FItems.GetItem(I);
              if (OtherItem.FRadioItem && (OtherItem !== this)) OtherItem.SetChecked(false);
            };
          };
          while (!$mod.TCustomMainMenu.isPrototypeOf(MenuOwner) && (MenuOwner != null)) {
            MenuOwner = MenuOwner.FOwner;
          };
        };
        pm = this.GetParentMenu();
        if (pm != null) pm.UpdateElement();
      };
    };
    this.SetCaption = function (Value) {
      var pm = null;
      this.FCaption = Value;
      pm = this.GetParentMenu();
      if (pm != null) pm.UpdateElement();
    };
    this.SetImageIndex = function (Value) {
      var pm = null;
      this.FImageIndex = Value;
      pm = this.GetParentMenu();
      if (pm != null) pm.UpdateElement();
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.GetParentMenu().UpdateElement();
      };
    };
    this.GetMenuItem = function (AIndex) {
      var Result = null;
      Result = this.FItems.GetItem(AIndex);
      return Result;
    };
    this.SetMenuItem = function (AIndex, Value) {
      this.FItems.PutItem(AIndex,Value);
    };
    this.GetCount = function () {
      var Result = 0;
      if (this.FItems === null) {
        Result = 0}
       else Result = this.FItems.GetCount();
      return Result;
    };
    this.Create$1 = function (AOwner) {
      this.FParentMenu = null;
      if ($mod.TMainMenu.isPrototypeOf(AOwner)) this.FParentMenu = AOwner;
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FAutoHotkeys = $mod.TMenuItemAutoFlag.maParent;
      this.FAutoLineReduction = $mod.TMenuItemAutoFlag.maParent;
      this.FImageIndex = -1;
      this.FHint = "";
      this.FCaption = "MenuItem";
      this.FChecked = false;
      this.FEnabled = true;
      this.FDefault = false;
      this.FRadioItem = false;
      this.FVisible = true;
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Destroy = function () {
      var i = 0;
      var pm = null;
      var mnu = null;
      pm = this.GetParentMenu();
      if ((this.FParentItem != null) && (pm != null)) {
        pm.BeginUpdate();
        for (var $l = this.FParentItem.FItems.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FParentItem.FItems.GetItem(i) === this) {
            this.FParentItem.FItems.Delete(i);
          };
        };
        pm.EndUpdate();
      };
      if (this.FItems != null) {
        for (var $l1 = this.FItems.GetCount() - 1; $l1 >= 0; $l1--) {
          i = $l1;
          mnu = this.FItems.GetItem(i);
          mnu.FParentItem = null;
          mnu = rtl.freeLoc(mnu);
          this.FItems.Delete(i);
        };
      };
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Assign = function (Source) {
      var i = 0;
      var srcmenu = null;
      var mnu = null;
      var pm = null;
      if ($mod.TMenuItem.isPrototypeOf(Source)) {
        srcmenu = rtl.as(Source,$mod.TMenuItem);
        this.FAutoCheck = srcmenu.FAutoCheck;
        this.FAutoHotkeys = srcmenu.FAutoHotkeys;
        this.FAutoLineReduction = srcmenu.FAutoLineReduction;
        this.FBreak = srcmenu.FBreak;
        this.FCaption = srcmenu.FCaption;
        this.FChecked = srcmenu.FChecked;
        this.FDefault = srcmenu.FDefault;
        this.FEnabled = srcmenu.FEnabled;
        this.FGroupIndex = srcmenu.FGroupIndex;
        this.FHelpContext = srcmenu.FHelpContext;
        this.FHint = srcmenu.FHint;
        this.FImageIndex = srcmenu.FImageIndex;
        this.FRadioItem = srcmenu.FRadioItem;
        this.FShortCut = srcmenu.FShortCut;
        this.FVisible = srcmenu.FVisible;
        this.FElementClassName = srcmenu.FElementClassName;
        pm = this.GetParentMenu();
        if (this.FParentItem != null) this.SetName(pm.GetUniqueName(srcmenu.FCaption));
        if (srcmenu.FItems != null) {
          if (this.FItems != null) {
            for (var $l = this.FItems.GetCount() - 1; $l >= 0; $l--) {
              i = $l;
              this.RemoveItem(this.GetParentMenu().FParent,this.FItems.GetItem(i));
            };
            this.FItems.Clear();
          } else this.FItems = $mod.TMenuItemList.$create("Create$1");
          for (var $l1 = 0, $end = srcmenu.FItems.GetCount() - 1; $l1 <= $end; $l1++) {
            i = $l1;
            mnu = $mod.TMenuItem.$create("Create$1",[pm.FOwner]);
            mnu.FParentMenu = pm;
            mnu.FParentItem = this;
            mnu.Assign(srcmenu.FItems.GetItem(i));
            this.FItems.Add(mnu);
          };
        };
      };
    };
    this.BeginUpdate$1 = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate$1 = function () {
      if (this.FUpdateCount > 0) {
        this.FUpdateCount -= 1;
        if (this.FUpdateCount === 0) this.GetParentMenu().UpdateElement();
      };
    };
    this.SetParentComponent = function (Value) {
      pas.Classes.TComponent.SetParentComponent.apply(this,arguments);
      this.FParentMenu = Value;
      if (Value !== null) {
        if ($mod.TCustomMainMenu.isPrototypeOf(Value)) {
          if (!Value.FItems.IsChild(this)) Value.FItems.Add(this);
        } else if ($mod.TMenuItem.isPrototypeOf(Value)) {
          if (!Value.IsChild(this)) Value.Add(this);
        };
      };
    };
    this.Add = function (Item) {
      this.Insert$1(this.GetCount(),Item);
    };
    this.Insert$1 = function (Index, Item) {
      if (this.FItems === null) this.FItems = $mod.TMenuItemList.$create("Create$1");
      this.FItems.Insert(Index,Item);
      Item.FParentItem = this;
      if (Item.GetParentMenu() != null) Item.GetParentMenu().UpdateElement();
    };
    this.IsChild = function (Item) {
      var Result = false;
      var i = 0;
      Result = false;
      if (!(this.FItems != null)) return Result;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FItems.GetItem(i) === Item) {
          Result = true;
        };
      };
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner$1;
      return Result;
    };
    this.GetParentMenu = function () {
      var Result = null;
      var AOwner = null;
      Result = null;
      AOwner = this.FParentMenu;
      while ((AOwner != null) && $mod.TMenuItem.isPrototypeOf(AOwner)) {
        AOwner = AOwner.FParentMenu;
      };
      if (AOwner != null) Result = AOwner;
      return Result;
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      if (this.FItems != null) for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        Proc(this.FItems.GetItem(I));
      };
    };
    this.SetChildOrder = function (Child, Order) {
      var idx = 0;
      idx = this.FItems.IndexOf(Child);
      if ((idx >= 0) && (Order < this.FItems.GetCount())) {
        this.FItems.Move(idx,Order);
      };
    };
    this.RemoveItem = function (AOwner, AItem) {
      var I = 0;
      if (AItem.FItems != null) {
        for (var $l = AItem.FItems.GetCount() - 1; $l >= 0; $l--) {
          I = $l;
          this.RemoveItem(AOwner,AItem.FItems.GetItem(I));
        };
      };
      AOwner.RemoveComponent(AItem);
    };
    this.Clear = function () {
      var i = 0;
      var mnu = null;
      for (var $l = this.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        mnu = this.FItems.GetItem(i);
        if (mnu.FItems != null) mnu.FItems.Clear();
        mnu = rtl.freeLoc(mnu);
      };
    };
    this.Click = function () {
      var pm = null;
      if (this.FOnClick != null) this.FOnClick(this);
      pm = this.GetParentMenu();
      if (pm.FIsPopupMenu) {
        if ((pm.FLayer$1 != null) && !(pm.FContainer$1 != null)) {
          pm.FLayer$1.parentElement.removeChild(pm.FLayer$1);
          pm.FLayer$1 = null;
        };
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AutoCheck",0,rtl.boolean,"FAutoCheck","FAutoCheck",4,{Default: false});
    $r.addProperty("AutoHotkeys",0,$mod.$rtti["TMenuItemAutoFlag"],"FAutoHotkeys","FAutoHotkeys",4,{Default: $mod.TMenuItemAutoFlag.maParent});
    $r.addProperty("AutoLineReduction",0,$mod.$rtti["TMenuItemAutoFlag"],"FAutoLineReduction","FAutoLineReduction",4,{Default: $mod.TMenuItemAutoFlag.maParent});
    $r.addProperty("Break",0,$mod.$rtti["TMenuBreak"],"FBreak","FBreak",4,{Default: $mod.TMenuBreak.mbNone});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",4,{Default: false});
    $r.addProperty("Default",0,rtl.boolean,"FDefault","FDefault",4,{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("GroupIndex",0,rtl.byte,"FGroupIndex","FGroupIndex",4,{Default: 0});
    $r.addProperty("HelpContext",0,$mod.$rtti["THelpContext"],"FHelpContext","FHelpContext",4,{Default: 0});
    $r.addProperty("Hint",0,rtl.string,"FHint","FHint");
    $r.addProperty("ImageIndex",2,rtl.longint,"FImageIndex","SetImageIndex",4,{Default: -1});
    $r.addProperty("RadioItem",0,rtl.boolean,"FRadioItem","FRadioItem",4,{Default: false});
    $r.addProperty("ShortCut",0,$mod.$rtti["TShortCut"],"FShortCut","FShortCut",4,{Default: 0});
    $r.addProperty("Visible",0,rtl.boolean,"FVisible","FVisible",4,{Default: true});
    $r.addProperty("ElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","FElementClassName");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
  });
  this.$rtti.$Class("TMainMenuAppearance");
  rtl.createClass(this,"THamburgerMenu",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FVisible = 0;
      this.FCaption = "";
      this.FBackgroundColor = 0;
      this.FCaptionColor = 0;
      this.FResponsiveMaxWidth = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetBackgroundColor = function (Value) {
      if (this.FBackgroundColor !== Value) {
        this.FBackgroundColor = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetCaption = function (Value) {
      if (this.FCaption !== Value) {
        this.FCaption = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetCaptionColor = function (Value) {
      if (this.FCaptionColor !== Value) {
        this.FCaptionColor = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveMaxWidth = function (Value) {
      if (this.FResponsiveMaxWidth !== Value) {
        this.FResponsiveMaxWidth = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.Create$1 = function (AOwner) {
      this.FBackgroundColor = 12632256;
      this.FCaption = "Menu";
      this.FCaptionColor = 16777215;
      this.FVisible = $mod.TMainMenuHamburgerMenuVisible.hmResponsive;
      this.FResponsiveMaxWidth = 768;
      this.FOwner = AOwner;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas.Classes.TPersistent.Assign.apply(this,arguments);
      if ($mod.THamburgerMenu.isPrototypeOf(Source)) {
        this.FBackgroundColor = rtl.as(Source,$mod.THamburgerMenu).FBackgroundColor;
        this.FCaption = rtl.as(Source,$mod.THamburgerMenu).FCaption;
        this.FCaptionColor = rtl.as(Source,$mod.THamburgerMenu).FCaptionColor;
        this.FVisible = rtl.as(Source,$mod.THamburgerMenu).FVisible;
        this.FResponsiveMaxWidth = rtl.as(Source,$mod.THamburgerMenu).FResponsiveMaxWidth;
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("CaptionColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FCaptionColor","SetCaptionColor",4,{Default: 16777215});
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",4,{Default: 12632256});
    $r.addProperty("Visible",2,$mod.$rtti["TMainMenuHamburgerMenuVisible"],"FVisible","SetVisible",4,{Default: $mod.TMainMenuHamburgerMenuVisible.hmResponsive});
    $r.addProperty("ResponsiveMaxWidth",2,rtl.longint,"FResponsiveMaxWidth","SetResponsiveMaxWidth",4,{Default: 768});
  });
  rtl.createClass(this,"TMainMenuAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FBackgroundColor = 0;
      this.FHoverFontColor = 0;
      this.FHoverColor = 0;
      this.FImageURLs = null;
      this.FHamburgerMenu = null;
      this.FImageSize = 0;
      this.FSubmenuIndicator = "";
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FImageURLs = undefined;
      this.FHamburgerMenu = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetBackgroundColor = function (Value) {
      if (this.FBackgroundColor !== Value) {
        this.FBackgroundColor = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetHoverColor = function (Value) {
      if (this.FHoverColor !== Value) {
        this.FHoverColor = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetHoverFontColor = function (Value) {
      if (this.FHoverFontColor !== Value) {
        this.FHoverFontColor = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetImageURLs = function (Value) {
      this.FImageURLs.Assign(Value);
    };
    this.SetImageSize = function (Value) {
      if (this.FImageSize !== Value) {
        this.FImageSize = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetSubmenuIndicator = function (Value) {
      if (this.FSubmenuIndicator !== Value) {
        this.FSubmenuIndicator = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.HandleImageURLsChanged = function (Sender) {
      this.FOwner.UpdateElement();
    };
    this.Create$1 = function (AOwner) {
      this.FBackgroundColor = 0xF0F0F0;
      this.FHoverColor = 14120960;
      this.FHoverFontColor = 197379;
      this.FHamburgerMenu = $mod.THamburgerMenu.$create("Create$1",[this]);
      this.FImageURLs = pas.Classes.TStringList.$create("Create$1");
      this.FImageURLs.SetSkipLastLineBreak(true);
      this.FImageURLs.FOnChange = rtl.createCallback(this,"HandleImageURLsChanged");
      this.FImageSize = 16;
      this.FSubmenuIndicator = "&#9658;";
      this.FOwner = AOwner;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHamburgerMenu");
      rtl.free(this,"FImageURLs");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas.Classes.TPersistent.Assign.apply(this,arguments);
      if ($mod.TMainMenuAppearance.isPrototypeOf(Source)) {
        this.FBackgroundColor = rtl.as(Source,$mod.TMainMenuAppearance).FBackgroundColor;
        this.FHoverColor = rtl.as(Source,$mod.TMainMenuAppearance).FHoverColor;
        this.FHoverFontColor = rtl.as(Source,$mod.TMainMenuAppearance).FHoverFontColor;
        this.FHamburgerMenu.Assign(rtl.as(Source,$mod.TMainMenuAppearance).FHamburgerMenu);
        this.FImageURLs.Assign(rtl.as(Source,$mod.TMainMenuAppearance).FImageURLs);
        this.FImageSize = rtl.as(Source,$mod.TMainMenuAppearance).FImageSize;
        this.FSubmenuIndicator = rtl.as(Source,$mod.TMainMenuAppearance).FSubmenuIndicator;
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",4,{Default: 15790320});
    $r.addProperty("HamburgerMenu",0,$mod.$rtti["THamburgerMenu"],"FHamburgerMenu","FHamburgerMenu");
    $r.addProperty("HoverColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverColor","SetHoverColor",4,{Default: 14120960});
    $r.addProperty("HoverFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverFontColor","SetHoverFontColor",4,{Default: 197379});
    $r.addProperty("ImageURLs",2,pas.Classes.$rtti["TStringList"],"FImageURLs","SetImageURLs");
    $r.addProperty("ImageSize",2,rtl.longint,"FImageSize","SetImageSize",4,{Default: 16});
    $r.addProperty("SubmenuIndicator",2,rtl.string,"FSubmenuIndicator","SetSubmenuIndicator");
  });
  rtl.createClass(this,"TCustomMainMenu",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FItems = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.IsUpdating()) return;
      if (this.GetElementHandle() != null) this.UpdateElement();
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
    };
    this.GetUniqueName = function (AName) {
      var Result = "";
      var i = 0;
      var id = 0;
      var found = false;
      id = 1;
      if (AName === "") AName = this.FName + "item";
      AName = $impl.MakeValidName(AName);
      do {
        Result = AName + pas.SysUtils.IntToStr(id);
        found = true;
        for (var $l = 0, $end = this.FOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.FOwner.GetComponent(i).FName === Result) {
            found = false;
            id += 1;
            break;
          };
        };
      } while (!found);
      return Result;
    };
    this.SetName = function (NewName) {
      pas["WEBLib.Controls"].TCustomControl.SetName.apply(this,arguments);
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      this.UpdateElement();
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = $mod.TMenuItem.$create("Create$1",[this]);
      this.FItems.FParentMenu = this;
      this.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      this.SetHeight(30);
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      if ((this.FItems != null) && (this.FItems.FItems != null)) {
        for (var $l = 0, $end = this.FItems.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          Proc(this.FItems.FItems.GetItem(I));
        };
      };
    };
    this.SetChildOrder = function (Child, Order) {
      var idx = 0;
      idx = this.FItems.FItems.IndexOf(Child);
      if ((idx >= 0) && (Order < this.FItems.FItems.GetCount())) {
        this.FItems.FItems.Move(idx,Order);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Items",0,$mod.$rtti["TMenuItem"],"FItems","");
    $r.addProperty("OnChange",0,$mod.$rtti["TMainMenuChangeEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TMainMenu",this.TCustomMainMenu,function () {
    this.$init = function () {
      $mod.TCustomMainMenu.$init.call(this);
      this.FMenu = null;
      this.FMainMenu = false;
      this.FMenuIndex = 0;
      this.FAppearance = null;
      this.FContainer$1 = null;
      this.FIsPopupMenu = false;
      this.FShowPopup = false;
      this.FAutoMerge = false;
      this.FZIndex = "";
      this.FElementItemClassName = "";
      this.FDocClickPtr = null;
      this.FLayer$1 = null;
    };
    this.$final = function () {
      this.FMenu = undefined;
      this.FAppearance = undefined;
      this.FContainer$1 = undefined;
      this.FLayer$1 = undefined;
      $mod.TCustomMainMenu.$final.call(this);
    };
    this.HandleChange = function (Event) {
      var Result = false;
      var h = null;
      var it = null;
      Result = true;
      if (this.FIsPopupMenu) {
        this.FShowPopup = false;
        this.UpdateElement();
      };
      h = Event.target;
      if (!h.hasAttribute("id")) h = h.parentElement;
      it = this.GetItemByName(this.FItems,h.id);
      if (it != null) {
        if (it.FAutoCheck) it.SetChecked(!it.FChecked);
        if (this.FOnChange != null) this.FOnChange(this,it,false);
        it.Click();
      };
      return Result;
    };
    this.HandleDocClick = function (Event) {
      var Result = false;
      var popupel = null;
      Result = true;
      if (this.FIsPopupMenu) {
        popupel = this.GetElementHandle().getElementsByClassName("popup-menu");
        if ((popupel != null) && (popupel.item(0) != null)) {
          setTimeout(function(){popupel[0].style.display = "none"}, 25);
        };
        if (this.FLayer$1 != null) {
          this.FLayer$1.parentElement.removeChild(this.FLayer$1);
          this.FLayer$1 = null;
        };
      };
      return Result;
    };
    this.Loaded = function () {
      $mod.TCustomMainMenu.Loaded.call(this);
      if (this.IsUpdating()) return;
      if (!(this.FContainer$1 != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this.FParent) && (rtl.as(this.FParent,pas["WEBLib.Forms"].TCustomForm).FMenu === this)) {
        this.FContainer$1 = this.FParent;
      };
      if (this.GetElementHandle() != null) this.UpdateElement();
    };
    this.UpdateElement = function () {
      var MenuStyle = "";
      var MenuColorStyle = "";
      var MenuResponsiveStyle = "";
      var MenuImageSize = "";
      var ShowPopup = "";
      var ElHandle = null;
      var ElLabel = null;
      var ElSpan = null;
      var ElIcon = null;
      var ElCheckBox = null;
      var ElStyle = null;
      var ElScript = null;
      var ElItems = null;
      $mod.TCustomMainMenu.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if (!(this.GetElementHandle() != null) && !(this.FContainer$1 != null)) return;
      if (this.FContainer$1 != null) {
        ElHandle = this.FContainer$1.GetElementHandle();
        this.SetVisible(false);
      } else {
        ElHandle = this.GetElementHandle();
        ElHandle.style.setProperty("top",pas.SysUtils.IntToStr(this.GetTop()) + "px");
        ElHandle.style.setProperty("left",pas.SysUtils.IntToStr(this.GetLeft()) + "px");
        if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !(this.FContainer$1 != null)) this.GetElementHandle().style.setProperty("background-color","silver");
      };
      if (this.FMenu != null) this.FMenu.parentElement.removeChild(this.FMenu);
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      this.FMenu = document.createElement("NAV");
      this.FMenu.setAttribute("id",this.GetID() + "menu");
      this.FMenu.innerHTML = "";
      if (this.FContainer$1 != null) {
        this.FMenu.style.setProperty("top","0");
        this.FMenu.style.setProperty("left","0");
        this.FMenu.style.setProperty("position","absolute");
        this.FMenu.style.setProperty("width","100%");
        this.FMenu.style.setProperty("z-index",this.FZIndex);
      };
      ElHandle.style.setProperty("overflow","visible");
      if (this.FAppearance.FHamburgerMenu.FVisible !== $mod.TMainMenuHamburgerMenuVisible.hmAlways) {
        if (this.FShowPopup) {
          ShowPopup = "block"}
         else ShowPopup = "none";
        MenuResponsiveStyle = "  #" + this.GetID() + "menu .main-menu {\r" + "    display: block;\r" + "  }\r" + "  #" + this.GetID() + "menu #toggle-menu {\r" + "    display: none;\r" + "  }\r" + "  #" + this.GetID() + "menu ul span.drop-label {\r" + "    display: inline-block;\r" + "  }\r" + "  #" + this.GetID() + "menu li {\r" + "    float: left;\r" + "    border-width: 0 1px 0 0;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu li, \r" + "  #" + this.GetID() + "menu .sub-menu li {\r" + "    float: none;\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu {\r" + "    top: 100%;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu { \r" + "    top: 0;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu, \r" + "  #" + this.GetID() + "menu .sub-menu {\r" + "    border-width: 0;\r" + "    margin: 0;\r" + "    position: absolute;\r" + "    left: 0;\r" + "    min-width: 12em;\r" + "    z-index: 9999999;\r" + "\t   white-space: nowrap;\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu {\r" + "    top: 100%;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu { \r" + "    display: " + ShowPopup + ";\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu,\r" + "  #" + this.GetID() + 'menu input[type="checkbox"]:checked + .popup-menu,\r' + "  #" + this.GetID() + 'menu input[type="checkbox"]:checked + .sub-menu {\r' + "    display: none;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu li, \r" + "  #" + this.GetID() + "menu .sub-menu li {\r" + "    border-width: 1px;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu .sub-menu, \r" + "  #" + this.GetID() + "menu .sub-menu .sub-menu {\r" + "    top: 0;\r" + "    left: 100%;\r" + "  }\r" + "  #" + this.GetID() + 'menu li:hover > input[type="checkbox"] + .popup-menu, \r' + "  #" + this.GetID() + 'menu li:hover > input[type="checkbox"] + .sub-menu {\r' + "    display: block;\r" + "  }\r";
        if (this.FAppearance.FHamburgerMenu.FVisible === $mod.TMainMenuHamburgerMenuVisible.hmResponsive) {
          MenuResponsiveStyle = "@media only screen and (min-width: " + pas.SysUtils.IntToStr(this.FAppearance.FHamburgerMenu.FResponsiveMaxWidth) + "px) {\r" + MenuResponsiveStyle + "}";
        };
      };
      if (this.FAppearance.FImageSize > 0) {
        MenuImageSize = "  width: " + pas.SysUtils.IntToStr(this.FAppearance.FImageSize) + "px;\r" + "  height: " + pas.SysUtils.IntToStr(this.FAppearance.FImageSize) + "px;\r";
      };
      MenuStyle = "#" + this.GetID() + "menu ul {\r" + "  margin: 0;\r" + "  padding: 0;\r" + "}\r" + "#" + this.GetID() + "menu .main-menu {\r" + "  display: none;\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu {\r" + "  display: block;\r" + "}\r" + "#" + this.GetID() + "menu label img.icon," + "#" + this.GetID() + "menu label span.checked {\r" + MenuImageSize + "  margin-right: 10px;\r" + "  pointer-events: none;\r" + "}\r" + "#" + this.GetID() + "tm:checked + .main-menu {\r" + "  display: block;\r" + "}\r" + "#" + this.GetID() + 'menu input[type="checkbox"],\r' + "#" + this.GetID() + "menu ul span.drop-label {\r" + "  display: none;\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu .popup-menu,\r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  border-width: 1px;\r" + "  border-style: solid;\r" + "  border-color: rgba(0, 0, 0, .05);\r" + "  border-bottom: 0px;\r" + "  border-top: 0px;\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu {\r" + "  border-width: 0 0 3px;\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu,\r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  border-width: 1px 1px 0;\r" + "  margin: 0 1em;\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu li:first-child,\r" + "#" + this.GetID() + "menu .sub-menu li:first-child {\r" + "  border-top: 1px solid;\r" + "  border-color: rgba(0, 0, 0, .05);\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu li:last-child,\r" + "#" + this.GetID() + "menu .sub-menu li:last-child {\r" + "  border-bottom: 1px solid;\r" + "  border-color: rgba(0, 0, 0, .05);\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu li label {\r" + "  position: relative;\r" + "  display: block;\r" + "}\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu li label { \r" + "  padding: 0.75em 1.5em;\r" + "  text-decoration: none;\r" + "}\r" + "#" + this.GetID() + "menu li span.menu-separator { \r" + "  display: block;\r" + "  width: 100%;\r" + "  height: 1px;\r" + "  background-color: rgba(0, 0, 0, .05);\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu, \r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  display: none;\r" + "}\r" + "#" + this.GetID() + 'menu input[type="checkbox"]:checked + .popup-menu,\r' + "#" + this.GetID() + 'menu input[type="checkbox"]:checked + .sub-menu {\r' + "  display: block;\r" + "  z-index: 3000;\r" + "}\r" + "#" + this.GetID() + "menu span.drop-icon {\r" + "  margin-left: 10px;" + "}\r" + "#" + this.GetID() + "menu span.hamburger-icon {\r" + "  float: right;\r" + "  padding: 0;\r" + "  margin: 0;\r" + "  font-weight: 900;\r" + "}\r" + "@media only screen and (max-width: 64em) and (min-width: 52.01em) {\r" + "  #" + this.GetID() + "menu li {\r" + "    width: auto;\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu li {\r" + "    width: auto;\r" + "  }\r" + "}\r";
      MenuColorStyle = "";
      if (this.FElementClassName === "") {
        MenuColorStyle = "#" + this.GetID() + "menu .popup-menu, \r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FBackgroundColor) + ";\r" + "}\r" + "@media only screen and (max-width: 64em) and (min-width: 52.01em) {\r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHamburgerMenu.FBackgroundColor) + ";\r" + "}\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu li label {\r" + "}\r" + "#" + this.GetID() + "menu #toggle-menu {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHamburgerMenu.FBackgroundColor) + ";\r" + "  color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHamburgerMenu.FCaptionColor) + ";\r" + "}\r" + "#" + this.GetID() + "menu .main-menu li label {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FBackgroundColor) + ";\r" + "}\r" + "#" + this.GetID() + "menu li label:hover {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverColor) + ";\r" + "  color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverFontColor) + ";\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu label:hover, \r" + "#" + this.GetID() + "menu .sub-menu label:hover {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverColor) + ";\r" + "  color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverFontColor) + ";\r" + "}\r";
      };
      MenuStyle = MenuStyle + MenuColorStyle + MenuResponsiveStyle;
      this.FMainMenu = true;
      this.FMenuIndex = 0;
      ElStyle = document.createElement("STYLE");
      ElStyle.innerHTML = MenuStyle;
      ElScript = document.createElement("SCRIPT");
      ElScript.innerHTML = "function " + this.GetID() + "MenuClick(ctrl){" + "  el = ctrl.parentElement.parentElement;" + '  el.style.display = "none";' + '  setTimeout(function(){el.style.removeProperty("display")}, 25);' + "}" + "function " + this.GetID() + "MenuOut(ctrl){" + '  menuel = document.getElementById("' + this.GetID() + '");' + "  if(menuel) { " + '    popupel = menuel.getElementsByClassName("popup-menu");' + "    if(popupel) " + '      setTimeout(function(){popupel[0].style.display = "none"}, 25);' + "  }" + "}";
      ElLabel = document.createElement("LABEL");
      ElLabel.setAttribute("for",this.GetID() + "tm");
      ElLabel.setAttribute("id","toggle-menu");
      ElLabel.innerHTML = this.FAppearance.FHamburgerMenu.FCaption;
      ElSpan = document.createElement("SPAN");
      if (this.FElementItemClassName !== "") {
        ElSpan.setAttribute("class",this.FElementItemClassName)}
       else ElSpan.setAttribute("class","drop-label");
      ElLabel.appendChild(ElSpan);
      ElIcon = document.createElement("SPAN");
      ElIcon.setAttribute("class","hamburger-icon");
      ElIcon.innerHTML = "&#9776;";
      ElSpan.appendChild(ElIcon);
      ElCheckBox = document.createElement("INPUT");
      ElCheckBox.setAttribute("type","checkbox");
      ElCheckBox.setAttribute("id",this.GetID() + "tm");
      this.FMenu.appendChild(ElStyle);
      this.FMenu.appendChild(ElScript);
      this.FMenu.appendChild(ElLabel);
      this.FMenu.appendChild(ElCheckBox);
      ElItems = this.GetMenuSource(this.FItems);
      if (ElItems !== null) this.FMenu.appendChild(ElItems);
      ElHandle.appendChild(this.FMenu);
    };
    this.GetMenuSource = function (Item) {
      var Result = null;
      var I = 0;
      var it = null;
      var MenuClass = "";
      var ElListItem = null;
      var ElLabel = null;
      var ElCheckBox = null;
      var ElSymbol = null;
      var id = 0;
      var caption = "";
      Result = null;
      if ((Item.FItems != null) && (Item.FItems.GetCount() > 0)) {
        Result = document.createElement("UL");
        if (this.FMainMenu) {
          this.FMainMenu = false;
          if (this.FIsPopupMenu) {
            MenuClass = "popup-menu"}
           else MenuClass = "main-menu";
        } else MenuClass = "sub-menu";
        this.FMenuIndex = this.FMenuIndex + 1;
        Result.setAttribute("class",MenuClass);
        for (var $l = 0, $end = Item.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = Item.FItems.GetItem(I);
          id = id + 1;
          if (it.FName === "") {
            caption = pas.SysUtils.StringReplace(it.FCaption," ","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
            caption = $impl.MakeValidName(caption);
            if (caption === "") caption = "MenuItem" + pas.SysUtils.IntToStr(id);
            it.SetName(caption + pas.SysUtils.IntToStr(id));
          };
          if (it.FVisible) {
            ElListItem = document.createElement("LI");
            if (it.FCaption !== "-") {
              ElLabel = document.createElement("LABEL");
              if (this.FElementItemClassName !== "") {
                ElLabel.setAttribute("class",this.FElementItemClassName)}
               else ElLabel.setAttribute("class","drop-label");
              ElLabel.setAttribute("title",it.FHint);
              if ((it.FImageIndex >= 0) && (this.FAppearance.FImageURLs.GetCount() > it.FImageIndex)) {
                ElLabel.innerHTML = '<img class="icon" src="' + this.FAppearance.FImageURLs.Get(it.FImageIndex) + '">'}
               else if (it.FChecked) {
                if (it.FRadioItem) {
                  ElLabel.innerHTML = '<span class="checked">&#9679;</span>'}
                 else ElLabel.innerHTML = '<span class="checked">&#10004;</span>';
              };
              ElLabel.innerHTML = ElLabel.innerHTML + it.FCaption;
            } else {
              ElLabel = document.createElement("SPAN");
              ElLabel.setAttribute("class","menu-separator");
              ElLabel.innerHTML = "";
            };
            if ((it.FItems != null) && (it.FItems.GetCount() > 0)) {
              ElSymbol = document.createElement("SPAN");
              ElSymbol.setAttribute("class","drop-icon");
              ElSymbol.innerHTML = this.FAppearance.FSubmenuIndicator;
              ElLabel.setAttribute("for","sm" + pas.SysUtils.IntToStr(this.FMenuIndex));
              ElLabel.appendChild(ElSymbol);
              if (!it.FEnabled) ElLabel.style.setProperty("color","gray");
              ElCheckBox = document.createElement("INPUT");
              ElCheckBox.setAttribute("type","checkbox");
              ElCheckBox.setAttribute("id","sm" + pas.SysUtils.IntToStr(this.FMenuIndex));
              ElListItem.appendChild(ElLabel);
              ElListItem.appendChild(ElCheckBox);
              if (it.FEnabled) ElListItem.appendChild(this.GetMenuSource(it));
            } else {
              ElLabel.setAttribute("for",this.GetID() + "tm");
              ElLabel.setAttribute("id",it.FName);
              if (it.FEnabled) {
                if (MenuClass === "sub-menu") {
                  if (it.FEnabled) ElLabel.setAttribute("onMouseUp",this.GetID() + "MenuClick(this);");
                };
                ElLabel.addEventListener("click",rtl.createSafeCallback(this,"HandleChange"));
              } else ElLabel.style.setProperty("color","gray");
              ElListItem.appendChild(ElLabel);
            };
            Result.appendChild(ElListItem);
          };
        };
      };
      return Result;
    };
    this.GetItemByName = function (AMenu, Name) {
      var Result = null;
      var I = 0;
      var it = null;
      Result = null;
      if (AMenu.FItems != null) {
        for (var $l = 0, $end = AMenu.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = AMenu.FItems.GetItem(I);
          if (it.FName === Name) {
            Result = it;
            if (it.FOnClick != null) Result.FOnClick = it.FOnClick;
            return Result;
          };
          if (!(Result != null)) Result = this.GetItemByName(it,Name);
        };
      };
      return Result;
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FDocClickPtr = null;
    };
    this.CreateInitialize = function () {
      $mod.TCustomMainMenu.CreateInitialize.call(this);
      this.FAppearance = $mod.TMainMenuAppearance.$create("Create$1",[this]);
      this.FContainer$1 = null;
      this.FMainMenu = true;
      this.FMenuIndex = 0;
      this.FIsPopupMenu = false;
      this.FShowPopup = false;
      this.SetTop(0);
      this.SetLeft(0);
      this.SetWidth(100);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        this.SetWidthPercent(100);
        this.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      };
    };
    this.CreateElement = function () {
      var Result = null;
      var LLabel = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = document.createElement("DIV");
        LLabel = document.createElement("DIV");
        LLabel.innerHTML = "TWebMainMenu";
        this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
        LLabel.setAttribute("align","center");
        LLabel.style.setProperty("border","1px solid gray");
        LLabel.style.setProperty("vertical-align","middle");
        LLabel.style.setProperty("display","table-cell");
        Result.appendChild(LLabel);
      } else {
        Result = document.createElement("DIV");
        if (this.FIsPopupMenu) {
          this.FDocClickPtr = rtl.createCallback(this,"HandleDocClick");
        };
      };
      this.FZIndex = pas["WEBLib.Forms"].Application.MaxZIndexStr();
      pas["WEBLib.Forms"].Application.ChangeMaxZIndex(+1);
      return Result;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      $mod.TCustomMainMenu.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",0,$mod.$rtti["TMainMenuAppearance"],"FAppearance","FAppearance");
    $r.addProperty("Container",0,pas["WEBLib.Controls"].$rtti["TControl"],"FContainer$1","FContainer$1");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementItemClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementItemClassName","FElementItemClassName");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
  });
  rtl.createClass(this,"TWebMainMenu",this.TMainMenu,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPopupMenu",this.TMainMenu,function () {
    this.$init = function () {
      $mod.TMainMenu.$init.call(this);
      this.FOnPopup = null;
    };
    this.$final = function () {
      this.FOnPopup = undefined;
      $mod.TMainMenu.$final.call(this);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      if (pas["WEBLib.Controls"].TControl.isPrototypeOf(AOwner)) this.SetParent(AOwner);
      return this;
    };
    this.CreateInitialize = function () {
      $mod.TMainMenu.CreateInitialize.call(this);
      this.FAppearance.FHamburgerMenu.SetVisible($mod.TMainMenuHamburgerMenuVisible.hmNever);
      this.FIsPopupMenu = true;
    };
    this.Popup = function (X, Y) {
      var frm = null;
      var el = null;
      var LDidAppend = false;
      if (this.FOnPopup != null) this.FOnPopup(this);
      this.SetTop(Y);
      this.SetLeft(X);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        this.FLayer$1 = frm.CreateLayer();
        if (!frm.FPopup) {
          LDidAppend = false;
          if (frm.FFormContainer !== "") {
            el = document.getElementById(frm.FFormContainer);
            if (el != null) {
              el.appendChild(this.FLayer$1);
              LDidAppend = true;
            };
          };
          if (!LDidAppend && !(this.FContainer$1 != null)) {
            document.body.appendChild(this.FLayer$1);
          };
        } else {
          frm.GetElementHandle().appendChild(this.FLayer$1);
        };
        this.FLayer$1.style.setProperty("z-index",pas.SysUtils.IntToStr(pas["WEBLib.Forms"].Application.FMaxZIndex - 1));
        this.FLayer$1.addEventListener("click",this.FDocClickPtr);
      };
      this.FShowPopup = true;
      this.GetElementHandle().style.setProperty("z-index",pas.SysUtils.IntToStr(pas["WEBLib.Forms"].Application.FMaxZIndex));
      this.UpdateElement();
      this.FShowPopup = false;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnPopup",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPopup","FOnPopup");
  });
  rtl.createClass(this,"TWebPopupMenu",this.TPopupMenu,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TWebCustomControl");
  this.$rtti.$ClassRef("TWebCustomControlClass",{instancetype: this.$rtti["TWebCustomControl"]});
  rtl.createClass(this,"TWebCustomControl",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FPopupMenu = null;
    };
    this.$final = function () {
      this.FPopupMenu = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.HandleDoContextMenu = function (Event) {
      var Result = false;
      var pt = pas.Types.TPoint.$new();
      var r = null;
      pas["WEBLib.Controls"].TControl.HandleDoContextMenu.apply(this,arguments);
      if (this.FPopupMenu != null) {
        Event.stopPropagation();
        Event.preventDefault();
        pt.$assign(pas.Types.Point(Math.round(Event.clientX),Math.round(Event.clientY)));
        if ((this.FPopupMenu.FOwner != null) && (this.FPopupMenu.FOwner.GetContainer() != null)) {
          r = this.FPopupMenu.FOwner.GetContainer().getBoundingClientRect();
          pt.x = pt.x - Math.round(r.left);
          pt.y = pt.y - Math.round(r.top);
        };
        this.FPopupMenu.Popup(pt.x,pt.y);
        Result = true;
      };
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FPopupMenu)) this.FPopupMenu = null;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWebGraphicControl",pas["WEBLib.Controls"].TGraphicControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TGraphicControl.$init.call(this);
      this.FPopupMenu = null;
    };
    this.$final = function () {
      this.FPopupMenu = undefined;
      pas["WEBLib.Controls"].TGraphicControl.$final.call(this);
    };
    this.HandleDoContextMenu = function (Event) {
      var Result = false;
      var pt = pas.Types.TPoint.$new();
      var r = null;
      pas["WEBLib.Controls"].TControl.HandleDoContextMenu.apply(this,arguments);
      if (this.FPopupMenu != null) {
        Event.stopPropagation();
        Event.preventDefault();
        pt.$assign(pas.Types.Point(Math.round(Event.clientX),Math.round(Event.clientY)));
        if ((this.FPopupMenu.FOwner != null) && (this.FPopupMenu.FOwner.GetContainer() != null)) {
          r = this.FPopupMenu.FOwner.GetContainer().getBoundingClientRect();
          pt.x = pt.x - Math.round(r.left);
          pt.y = pt.y - Math.round(r.top);
        };
        this.FPopupMenu.Popup(pt.x,pt.y);
        Result = true;
      };
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FPopupMenu)) this.FPopupMenu = null;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TCrackedApplication",pas["WEBLib.Forms"].TApplication,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    rtl.createClass($impl,"TCrackedForm",pas["WEBLib.Forms"].TForm,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    var Alpha = rtl.createSet(null,65,90,null,97,122,95);
    var AlphaNum = rtl.unionSet(Alpha,rtl.createSet(null,48,57));
    $impl.MakeValidName = function (s) {
      var Result = "";
      var i = 0;
      Result = "";
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        if (s.charCodeAt(i - 1) in AlphaNum) Result = Result + s.charAt(i - 1);
      };
      return Result;
    };
  };
},["Types","WEBLib.Forms"]);
rtl.module("WEBLib.ClientConnector",["System","Classes","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TClientConnectorIdentifier = {"0": "ciUnknown", ciUnknown: 0, "1": "ciAndroid", ciAndroid: 1, "2": "ciiOS", ciiOS: 2, "3": "ciWindows", ciWindows: 3, "4": "ciMac", ciMac: 4};
  this.$rtti.$Enum("TClientConnectorIdentifier",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TClientConnectorIdentifier});
  this.$rtti.$MethodVar("TClientConnectorReceivedMessageEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AJSON",pas["WEBLib.JSON"].$rtti["TJSONObject"]]]), methodkind: 0});
  rtl.createClass(this,"TClientConnector",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FOnReceivedMessage = null;
    };
    this.$final = function () {
      this.FOnReceivedMessage = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      pas["WEBLib.Forms"].Application.FClientConnector = this;
      return this;
    };
    this.Destroy = function () {
      pas["WEBLib.Forms"].Application.FClientConnector = null;
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Receive = function (AJSON) {
      var js = null;
      var o = null;
      var s = "";
      js = pas["WEBLib.JSON"].TJSON.$create("Create");
      s = decodeURIComponent(AJSON);
      o = js.Parse(s);
      if (this.FOnReceivedMessage != null) this.FOnReceivedMessage(this,o);
      o = rtl.freeLoc(o);
    };
    this.Send = function (AJSON) {
      var s = "";
      s = JSON.stringify(AJSON.fjo$1);
      this.SendMessage(s);
    };
    var MAXBUFFERCOUNT = 500;
    this.SendMessage = function (AMessage) {
      var $Self = this;
      var s = "";
      var cid = 0;
      var scid = "";
      var sSub = "";
      var sc = 0;
      function InternalSend(m) {
        var $tmp = cid;
        if ($tmp === $mod.TClientConnectorIdentifier.ciAndroid) {
          injectedObject.Setjsvalue(m);
          injectedObject.performClick();
        } else if (($tmp === $mod.TClientConnectorIdentifier.ciiOS) || ($tmp === $mod.TClientConnectorIdentifier.ciMac)) {
          window.webkit.messageHandlers.bridge.postMessage(m);
        } else if ($tmp === $mod.TClientConnectorIdentifier.ciWindows) {
          window.location = m;
        } else if ($tmp === $mod.TClientConnectorIdentifier.ciUnknown) pas["WEBLib.Dialogs"].ShowMessage("Please perform handshake from client first.");
      };
      s = AMessage;
      scid = window.TMSWEBCoreClientIdentifier;
      cid = $mod.TClientConnectorIdentifier.ciUnknown;
      var $tmp = pas.SysUtils.LowerCase(scid);
      if ($tmp === "android") {
        cid = $mod.TClientConnectorIdentifier.ciAndroid}
       else if ($tmp === "ios") {
        cid = $mod.TClientConnectorIdentifier.ciiOS}
       else if ($tmp === "windows") {
        cid = $mod.TClientConnectorIdentifier.ciWindows}
       else if (($tmp === "mac") || ($tmp === "macos")) cid = $mod.TClientConnectorIdentifier.ciMac;
      var $tmp1 = pas.SysUtils.LowerCase(scid);
      if (($tmp1 === "mac") || ($tmp1 === "macos") || ($tmp1 === "ios")) {
        InternalSend($impl.Prefix + encodeURIComponent(s))}
       else if (($tmp1 === "android") || ($tmp1 === "windows")) {
        InternalSend($impl.Prefix + "BUFFERSTART");
        while (s.length > 0) {
          sc = Math.min(s.length & 0xFFFFFFFF,500);
          sSub = pas.System.Copy(s,1,sc);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,sc);
          InternalSend($impl.Prefix + encodeURIComponent(sSub));
        };
        InternalSend($impl.Prefix + "BUFFEREND");
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnReceivedMessage",0,$mod.$rtti["TClientConnectorReceivedMessageEvent"],"FOnReceivedMessage","FOnReceivedMessage");
  });
  rtl.createClass(this,"TWebClientConnector",this.TClientConnector,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    $impl.Prefix = "webclientevent://";
  };
},["Math","JS","WEBLib.Forms","SysUtils","WEBLib.Dialogs"]);
rtl.module("Rtl.BrowserLoadHelper",["System","Classes","SysUtils","JS","Web"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TBrowserLoadHelper",pas.Classes.TLoadHelper,function () {
    this.LoadText = function (aURL, aSync, OnLoaded, OnError) {
      var $Self = this;
      var ARequest = null;
      function doFetchOK(response) {
        var Result = undefined;
        Result = false;
        if (response.status !== 200) {
          if (OnError != null) OnError("Error " + pas.SysUtils.IntToStr(response.status) + ": " + response.statusText);
        } else response.text().then(function (value) {
          var Result = undefined;
          OnLoaded("" + value);
          return Result;
        });
        return Result;
      };
      function doFetchFail(response) {
        var Result = undefined;
        Result = false;
        OnError("Error 999: unknown error");
        return Result;
      };
      if (aSync) {
        window.fetch(aURL).then(doFetchOK).catch(doFetchFail)}
       else {
        ARequest = new XMLHttpRequest();
        ARequest.open("GET",aURL,false);
        ARequest.addEventListener("load",function (oEvent) {
          OnLoaded(ARequest.responseText);
        });
        ARequest.addEventListener("error",function (oEvent) {
          if (OnError != null) OnError(oEvent.message);
        });
        ARequest.send();
      };
    };
    this.LoadBytes = function (aURL, aSync, OnLoaded, OnError) {
      var $Self = this;
      var ARequest = null;
      function doFetchFail(response) {
        var Result = undefined;
        Result = false;
        if (rtl.isObject(response) && rtl.isExt(response,Error)) {
          OnError("Error 999: " + response.message)}
         else OnError("Error 999: unknown error");
        return Result;
      };
      function doFetchOK(response) {
        var Result = undefined;
        Result = false;
        if (response.status !== 200) {
          if (OnError != null) OnError("Error " + pas.SysUtils.IntToStr(response.status) + ": " + response.statusText);
        } else response.blob().then(function (value) {
          var Result = undefined;
          value.arrayBuffer().then(function (arr) {
            var Result = undefined;
            OnLoaded(arr);
            return Result;
          }).catch(doFetchFail);
          return Result;
        });
        return Result;
      };
      function StringToArrayBuffer(str) {
        var Result = null;
        var i = 0;
        var l = 0;
        l = str.length;
        Result = new ArrayBuffer(l * 2);
        var $with = new Uint16Array(Result);
        for (var $l = 1, $end = l; $l <= $end; $l++) {
          i = $l;
          $with[i - 1] = str.charCodeAt(i - 1);
        };
        return Result;
      };
      if (aSync) {
        window.fetch(aURL).then(doFetchOK).catch(doFetchFail)}
       else {
        ARequest = new XMLHttpRequest();
        ARequest.open("GET",aURL,false);
        ARequest.addEventListener("load",function (oEvent) {
          if (ARequest.status !== 200) {
            OnError("Error " + pas.SysUtils.IntToStr(ARequest.status) + ": " + ARequest.statusText)}
           else OnLoaded(StringToArrayBuffer(ARequest.responseText));
        });
        ARequest.addEventListener("error",function (oEvent) {
          if (OnError != null) OnError(oEvent.message);
        });
        ARequest.send();
      };
    };
  });
  $mod.$init = function () {
    pas.Classes.SetLoadHelperClass($mod.TBrowserLoadHelper);
  };
});
rtl.module("WEBLib.Forms",["System","Classes","Types","SysUtils","WEBLib.Graphics","WEBLib.Controls","WEBLib.Modules","WEBLib.Lang","WEBLib.Menus","Web","JS","WEBLib.ClientConnector","Rtl.BrowserLoadHelper"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.WEBCOREVERSION = "2.9.9.3";
  this.idOK = 1;
  this.idCancel = 2;
  this.idAbort = 3;
  this.idRetry = 4;
  this.idIgnore = 5;
  this.idYes = 6;
  this.idNo = 7;
  this.idClose = 8;
  this.idHelp = 9;
  this.idTryAgain = 10;
  this.idContinue = 11;
  this.mrNone = 0;
  this.mrOk = 1;
  this.mrCancel = 2;
  this.mrAbort = 3;
  this.mrRetry = 4;
  this.mrIgnore = 5;
  this.mrYes = 6;
  this.mrNo = 7;
  this.mrClose = 8;
  this.mrHelp = 9;
  this.mrTryAgain = 10;
  this.mrContinue = 11;
  this.mrAll = 11 + 1;
  this.mrNoToAll = 12 + 1;
  this.mrYesToAll = 13 + 1;
  this.rgiFirst = -1024;
  this.rgiLast = -513;
  this.igiFirst = 256;
  this.igiLast = 511;
  this.clTMSBlue = 0xE39E00;
  this.clTMSWEB = 0x8F8300;
  this.$rtti.$Class("TDragDockObject");
  this.$rtti.$Class("TCustomForm");
  this.$rtti.$Int("TConstraintSize",{minvalue: 0, maxvalue: 2147483647, ordtype: 5});
  this.TCloseAction = {"0": "caNone", caNone: 0, "1": "caHide", caHide: 1, "2": "caFree", caFree: 2, "3": "caMinimize", caMinimize: 3};
  this.$rtti.$Enum("TCloseAction",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TCloseAction});
  this.TFormStyle = {"0": "fsNormal", fsNormal: 0, "1": "fsStayOnTop", fsStayOnTop: 1};
  this.$rtti.$Enum("TFormStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFormStyle});
  this.TNavigationTarget = {"0": "ntBlank", ntBlank: 0, "1": "ntPage", ntPage: 1};
  this.$rtti.$Enum("TNavigationTarget",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TNavigationTarget});
  this.$rtti.$Int("TGestureID",{minvalue: -1024, maxvalue: 511, ordtype: 2});
  this.TInteractiveGestureFlag = {"0": "gfBegin", gfBegin: 0, "1": "gfInertia", gfInertia: 1, "2": "gfEnd", gfEnd: 2};
  this.$rtti.$Enum("TInteractiveGestureFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TInteractiveGestureFlag});
  this.$rtti.$Set("TInteractiveGestureFlags",{comptype: this.$rtti["TInteractiveGestureFlag"]});
  this.TMouseActivate = {"0": "maDefault", maDefault: 0, "1": "maActivate", maActivate: 1, "2": "maActivateAndEat", maActivateAndEat: 2, "3": "maNoActivate", maNoActivate: 3, "4": "maNoActivateAndEat", maNoActivateAndEat: 4};
  this.$rtti.$Enum("TMouseActivate",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMouseActivate});
  this.TScreenOrientation = {"0": "soPortrait", soPortrait: 0, "1": "soLandscape", soLandscape: 1};
  this.$rtti.$Enum("TScreenOrientation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TScreenOrientation});
  this.TApplicationColorScheme = {"0": "csNoScheme", csNoScheme: 0, "1": "csLight", csLight: 1, "2": "csDark", csDark: 2};
  this.$rtti.$Enum("TApplicationColorScheme",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TApplicationColorScheme});
  rtl.recNewT(this,"TSmallPoint",function () {
    this.x = 0;
    this.y = 0;
    this.$eq = function (b) {
      return (this.x === b.x) && (this.y === b.y);
    };
    this.$assign = function (s) {
      this.x = s.x;
      this.y = s.y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSmallPoint",{},this);
    $r.addField("x",rtl.smallint);
    $r.addField("y",rtl.smallint);
  });
  rtl.recNewT(this,"TAlignInfo",function () {
    this.AlignList = null;
    this.ControlIndex = 0;
    this.Align = 0;
    this.Scratch = 0;
    this.$eq = function (b) {
      return (this.AlignList === b.AlignList) && (this.ControlIndex === b.ControlIndex) && (this.Align === b.Align) && (this.Scratch === b.Scratch);
    };
    this.$assign = function (s) {
      this.AlignList = s.AlignList;
      this.ControlIndex = s.ControlIndex;
      this.Align = s.Align;
      this.Scratch = s.Scratch;
      return this;
    };
    var $r = $mod.$rtti.$Record("TAlignInfo",{},this);
    $r.addField("AlignList",pas.Classes.$rtti["TList"]);
    $r.addField("ControlIndex",rtl.longint);
    $r.addField("Align",pas["WEBLib.Controls"].$rtti["TAlign"]);
    $r.addField("Scratch",rtl.longint);
  });
  rtl.recNewT(this,"TGestureEventInfo",function () {
    this.GestureID = 0;
    this.Angle = 0.0;
    this.Distance = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Location = pas.Types.TPoint.$new();
      r.Flags = {};
      r.InertiaVector = $mod.TSmallPoint.$new();
      r.TapLocation = $mod.TSmallPoint.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.GestureID === b.GestureID) && this.Location.$eq(b.Location) && rtl.eqSet(this.Flags,b.Flags) && (this.Angle === b.Angle) && this.InertiaVector.$eq(b.InertiaVector) && (this.Distance === b.Distance) && this.TapLocation.$eq(b.TapLocation);
    };
    this.$assign = function (s) {
      this.GestureID = s.GestureID;
      this.Location.$assign(s.Location);
      this.Flags = rtl.refSet(s.Flags);
      this.Angle = s.Angle;
      this.InertiaVector.$assign(s.InertiaVector);
      this.Distance = s.Distance;
      this.TapLocation.$assign(s.TapLocation);
      return this;
    };
    var $r = $mod.$rtti.$Record("TGestureEventInfo",{},this);
    $r.addField("GestureID",$mod.$rtti["TGestureID"]);
    $r.addField("Location",pas.Types.$rtti["TPoint"]);
    $r.addField("Flags",$mod.$rtti["TInteractiveGestureFlags"]);
    $r.addField("Angle",rtl.double);
    $r.addField("InertiaVector",$mod.$rtti["TSmallPoint"]);
    $r.addField("Distance",rtl.longint);
    $r.addField("TapLocation",$mod.$rtti["TSmallPoint"]);
  });
  this.$rtti.$MethodVar("TCloseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Action",this.$rtti["TCloseAction"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TCloseQueryEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["CanClose",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TOrientationChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AOrientation",this.$rtti["TScreenOrientation"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TBeforeUnloadEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AMessage",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TAlignInsertBeforeEvent",{procsig: rtl.newTIProcSig([["Sender",pas["WEBLib.Controls"].$rtti["TWinControl"]],["C1",pas["WEBLib.Controls"].$rtti["TControl"]],["C2",pas["WEBLib.Controls"].$rtti["TControl"]]],rtl.boolean), methodkind: 1});
  this.$rtti.$MethodVar("TAlignPositionEvent",{procsig: rtl.newTIProcSig([["Sender",pas["WEBLib.Controls"].$rtti["TWinControl"]],["Control",pas["WEBLib.Controls"].$rtti["TControl"]],["NewLeft",rtl.longint,1],["NewTop",rtl.longint,1],["NewWidth",rtl.longint,1],["NewHeight",rtl.longint,1],["AlignRect",pas.Types.$rtti["TRect"],1],["AlignInfo",this.$rtti["TAlignInfo"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TCanResizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["NewWidth",rtl.longint,1],["NewHeight",rtl.longint,1],["Resize",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TConstrainedResizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["MinWidth",rtl.longint,1],["MinHeight",rtl.longint,1],["MaxWidth",rtl.longint,1],["MaxHeight",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TContextPopupEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TDockDropEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",this.$rtti["TDragDockObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TDockOverEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",this.$rtti["TDragDockObject"]],["X",rtl.longint],["Y",rtl.longint],["State",pas["WEBLib.Controls"].$rtti["TDragState"]],["Accept",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGestureEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["EventInfo",this.$rtti["TGestureEventInfo"],2],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGetSiteInfoEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DockClient",pas["WEBLib.Controls"].$rtti["TControl"]],["InfluenceRect",pas.Types.$rtti["TRect"],1],["MousePos",pas.Types.$rtti["TPoint"]],["CanDock",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseActivateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Button",pas["WEBLib.Controls"].$rtti["TMouseButton"]],["Shift",pas.Classes.$rtti["TShiftState"]],["X",rtl.longint],["Y",rtl.longint],["HitTest",rtl.longint],["MouseActivate",this.$rtti["TMouseActivate"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseWheelUpDownEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TStartDockEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DragObject",this.$rtti["TDragDockObject"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TUnDockEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Client",pas["WEBLib.Controls"].$rtti["TControl"]],["NewTarget",pas["WEBLib.Controls"].$rtti["TWinControl"]],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("THashChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["oldURL",rtl.string],["newURL",rtl.string]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TModalResultProc",{procsig: rtl.newTIProcSig([["AValue",rtl.longint]])});
  this.$rtti.$RefToProcVar("TFormCreatedProc",{procsig: rtl.newTIProcSig([["AForm",pas.System.$rtti["TObject"]]])});
  this.TWindowState = {"0": "wsNormal", wsNormal: 0, "1": "wsMinimized", wsMinimized: 1, "2": "wsMaximized", wsMaximized: 2};
  this.$rtti.$Enum("TWindowState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TWindowState});
  this.TPopupMode = {"0": "pmNone", pmNone: 0, "1": "pmAuto", pmAuto: 1, "2": "pmExplicit", pmExplicit: 2};
  this.$rtti.$Enum("TPopupMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TPopupMode});
  this.TPopupClose = {"0": "pcOnDeactivate", pcOnDeactivate: 0, "1": "pcNever", pcNever: 1};
  this.$rtti.$Enum("TPopupClose",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TPopupClose});
  this.TPosition = {"0": "poDesigned", poDesigned: 0, "1": "poDefault", poDefault: 1, "2": "poDefaultPosOnly", poDefaultPosOnly: 2, "3": "poDefaultSizeOnly", poDefaultSizeOnly: 3, "4": "poScreenCenter", poScreenCenter: 4, "5": "poDesktopCenter", poDesktopCenter: 5, "6": "poMainFormCenter", poMainFormCenter: 6, "7": "poOwnerFormCenter", poOwnerFormCenter: 7};
  this.$rtti.$Enum("TPosition",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TPosition});
  this.TApplicationErrorType = {"0": "aeSilent", aeSilent: 0, "1": "aeDialog", aeDialog: 1, "2": "aeAlert", aeAlert: 2, "3": "aeFooter", aeFooter: 3};
  this.$rtti.$Enum("TApplicationErrorType",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TApplicationErrorType});
  this.TFormBorderStyle = {"0": "fbNone", fbNone: 0, "1": "fbSingle", fbSingle: 1, "2": "fbSizeable", fbSizeable: 2, "3": "fbDialog", fbDialog: 3, "4": "fbDialogSizeable", fbDialogSizeable: 4};
  this.$rtti.$Enum("TFormBorderStyle",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TFormBorderStyle});
  this.$rtti.$Enum("TFormBorder",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFormBorderStyle});
  this.TBootstrapVersion = {"0": "bv3", bv3: 0, "1": "bv4", bv4: 1, "2": "bv5", bv5: 2};
  this.$rtti.$Enum("TBootstrapVersion",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TBootstrapVersion});
  rtl.createClass(this,"TCustomSizeConstraints",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FControl = null;
      this.FMaxHeight = 0;
      this.FMaxWidth = 0;
      this.FMinHeight = 0;
      this.FMinWidth = 0;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetConstraints = function (AIndex, AValue) {
      var $tmp = AIndex;
      if ($tmp === 0) {
        if (AValue !== this.FMaxHeight) {
          this.FMaxHeight = AValue;
          if ((AValue > 0) && (AValue < this.FMinHeight)) this.FMinHeight = AValue;
          this.Change();
        }}
       else if ($tmp === 1) {
        if (AValue !== this.FMaxWidth) {
          this.FMaxWidth = AValue;
          if ((AValue > 0) && (AValue < this.FMinWidth)) this.FMinWidth = AValue;
          this.Change();
        }}
       else if ($tmp === 2) {
        if (AValue !== this.FMinHeight) {
          this.FMinHeight = AValue;
          if ((this.FMaxHeight > 0) && (AValue > this.FMaxHeight)) this.FMaxHeight = AValue;
          this.Change();
        }}
       else if ($tmp === 3) if (AValue !== this.FMinWidth) {
        this.FMinWidth = AValue;
        if ((this.FMaxWidth > 0) && (AValue > this.FMaxWidth)) this.FMaxWidth = AValue;
        this.Change();
      };
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.AssignTo = function (ADest) {
      if ($mod.TCustomSizeConstraints.isPrototypeOf(ADest)) {
        ADest.FMinHeight = this.FMinHeight;
        ADest.FMaxHeight = this.FMaxHeight;
        ADest.FMinWidth = this.FMinWidth;
        ADest.FMaxWidth = this.FMaxWidth;
        ADest.Change();
      } else pas.Classes.TPersistent.AssignTo.call(this,ADest);
    };
    this.Create$1 = function (AControl) {
      pas.System.TObject.Create.call(this);
      this.FControl = AControl;
      return this;
    };
  });
  rtl.createClass(this,"TSizeConstraints",this.TCustomSizeConstraints,function () {
    var $r = this.$rtti;
    $r.addProperty("MaxHeight",18,$mod.$rtti["TConstraintSize"],"FMaxHeight","SetConstraints",4,{index: 0, Default: 0});
    $r.addProperty("MaxWidth",18,$mod.$rtti["TConstraintSize"],"FMaxWidth","SetConstraints",4,{index: 1, Default: 0});
    $r.addProperty("MinHeight",18,$mod.$rtti["TConstraintSize"],"FMinHeight","SetConstraints",4,{index: 2, Default: 0});
    $r.addProperty("MinWidth",18,$mod.$rtti["TConstraintSize"],"FMinWidth","SetConstraints",4,{index: 3, Default: 0});
  });
  rtl.createClass(this,"TDragDockObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBrush = null;
      this.FDockRect = pas.Types.TRect.$new();
      this.FDropAlign = 0;
      this.FDropOnControl = null;
      this.FEraseDockRect = pas.Types.TRect.$new();
      this.FEraseWhenMoving = false;
      this.FFloating = false;
      this.FFrameWidth = 0;
    };
    this.$final = function () {
      this.FBrush = undefined;
      this.FDockRect = undefined;
      this.FDropOnControl = undefined;
      this.FEraseDockRect = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AControl) {
      pas.System.TObject.Create.call(this);
      this.FBrush = pas["WEBLib.Graphics"].TBrush.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBrush");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
    };
  });
  rtl.createClass(this,"TCustomForm",pas["WEBLib.Controls"].TWinControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TWinControl.$init.call(this);
      this.FDesignContainer = null;
      this.FLayer$1 = null;
      this.FPopup = false;
      this.FDirectForm = false;
      this.FPopupElement = null;
      this.FFormFileName = "";
      this.FFormContent = "";
      this.FFormContainer = "";
      this.FFormElement = "";
      this.FFormStyle = 0;
      this.FOnCreate = null;
      this.FOnShow = null;
      this.FModalResult = 0;
      this.FOnPaint = null;
      this.FOnDeactivate = null;
      this.FOnCloseQuery = null;
      this.FOnClose = null;
      this.FModalProc = null;
      this.FCreatedProc = null;
      this.FWindowState = 0;
      this.FCaption = "";
      this.FIsResizing$1 = false;
      this.FOnScroll = null;
      this.FOnUnload = null;
      this.FOnBeforeUnload = null;
      this.FPopupMode = 0;
      this.FPopupClose = 0;
      this.FPosition = 0;
      this.FActiveControl = null;
      this.FMdx = 0;
      this.FMdy = 0;
      this.FDlgX = 0;
      this.FDlgY = 0;
      this.FCaptured$1 = false;
      this.FDown = false;
      this.FHasCaption = false;
      this.FMoveSpan = null;
      this.FCaptionElement = null;
      this.FCaptionCloseElement = null;
      this.FBorder = 0;
      this.FShadow = false;
      this.FTimerID = 0;
      this.FOrigWidth = 0;
      this.FOrigHeight = 0;
      this.FOldWidth = 0;
      this.FOldHeight = 0;
      this.FOnDestroy = null;
      this.FPopupOpacity = 0.0;
      this.FCreating = false;
      this.FCreated = false;
      this.FShown = false;
      this.FLoadedPtr = null;
      this.FDOMContentLoadedPtr = null;
      this.FUnloadPtr = null;
      this.FBeforeUnloadPtr = null;
      this.FResizePtr = null;
      this.FScrollPtr = null;
      this.FDocMouseUpPtr = null;
      this.FDocMouseMovePtr = null;
      this.FTitleDownPtr = null;
      this.FTitleTouchStartPtr = null;
      this.FDocTouchMovePtr = null;
      this.FDocTouchEndPtr = null;
      this.FDoClickPtr = null;
      this.FKeyDownPtr$1 = null;
      this.FOrientationChangePtr = null;
      this.FHashChangePtr = null;
      this.FCSSLibrary = 0;
      this.FNoHTML = false;
      this.FPrevActiveForm = null;
      this.FElementCaptionClassName = "";
      this.FElementPopupClassName = "";
      this.FMenu = null;
      this.FResizeObserver = null;
      this.FOnOrientationChange = null;
      this.FOnDOMContentLoaded = null;
      this.FShowClose = false;
      this.FOnHashChange = null;
      this.FDefaultCloseAction = 0;
    };
    this.$final = function () {
      this.FDesignContainer = undefined;
      this.FLayer$1 = undefined;
      this.FPopupElement = undefined;
      this.FOnCreate = undefined;
      this.FOnShow = undefined;
      this.FOnPaint = undefined;
      this.FOnDeactivate = undefined;
      this.FOnCloseQuery = undefined;
      this.FOnClose = undefined;
      this.FModalProc = undefined;
      this.FCreatedProc = undefined;
      this.FOnScroll = undefined;
      this.FOnUnload = undefined;
      this.FOnBeforeUnload = undefined;
      this.FActiveControl = undefined;
      this.FMoveSpan = undefined;
      this.FCaptionElement = undefined;
      this.FCaptionCloseElement = undefined;
      this.FOnDestroy = undefined;
      this.FPrevActiveForm = undefined;
      this.FMenu = undefined;
      this.FResizeObserver = undefined;
      this.FOnOrientationChange = undefined;
      this.FOnDOMContentLoaded = undefined;
      this.FOnHashChange = undefined;
      pas["WEBLib.Controls"].TWinControl.$final.call(this);
    };
    this.SetModalResult = function (Value) {
      this.FModalResult = Value;
      if (this.FModalResult !== 0) this.Close();
    };
    this.GetFormStyle = function () {
      var Result = 0;
      Result = this.FFormStyle;
      return Result;
    };
    this.SetFormStyle = function (Value) {
      this.FFormStyle = Value;
    };
    this.GetCanvas = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        this.FCaption = AValue;
        this.UpdateElement();
      };
    };
    this.SetActiveControl = function (Value) {
      this.FActiveControl = Value;
      if (this.FActiveControl != null) this.FActiveControl.SetFocus();
    };
    this.SetShadow = function (Value) {
      if (this.FShadow !== Value) {
        this.FShadow = Value;
        this.UpdateElement();
      };
    };
    this.SetBorder = function (Value) {
      if (this.FBorder !== Value) {
        this.FBorder = Value;
        if (this.GetContainer() != null) this.AlignControl(this);
      };
    };
    this.SetFormContainer = function (Value) {
      var el = null;
      var old = null;
      var i = 0;
      old = this.GetContainer();
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.FFormContainer = Value}
       else {
        if (pas.SysUtils.UpperCase(Value) === "BODY") {
          this.FFormContainer = ""}
         else this.FFormContainer = Value;
      };
      if ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) return;
      if (this.FLayer$1 != null) {
        el = this.FLayer$1}
       else if (Value === "") {
        el = document.body;
      } else {
        el = document.getElementById(Value);
        if (!(el != null)) el = document.body;
      };
      if (el != null) {
        this.FContainer = el;
        if (old != null) {
          for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (this.GetControls(i).FParentElement === old) this.GetControls(i).FParentElement = el;
            if ((this.GetControls(i).GetElementHandle() != null) && (this.GetControls(i).GetElementHandle().parentElement === old)) {
              el.appendChild(this.GetControls(i).GetElementHandle());
            };
          };
        };
      };
    };
    this.GetActiveControl = function () {
      var Result = null;
      var i = 0;
      Result = this.FActiveControl;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetControls(i).GetElementHandle() === document.activeElement) {
          Result = this.GetControls(i);
          break;
        };
      };
      return Result;
    };
    this.SetPosition = function (Value) {
      this.FPosition = Value;
    };
    this.ReadPixelsPerInch = function (AReader) {
    };
    this.WritePixelsPerInch = function (AWriter) {
    };
    this.SetWidth = function (AValue) {
      var eh = null;
      if (((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FFormContainer !== "")) || (!this.FPopup && !(this.GetElementHandle() != null))) {
        this.SetWidthInt(AValue);
        return;
      };
      pas["WEBLib.Controls"].TControl.SetWidth.apply(this,arguments);
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("width",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    this.SetHeight = function (AValue) {
      var eh = null;
      if (((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FFormContainer !== "")) || (!this.FPopup && !(this.GetElementHandle() != null))) {
        this.SetHeightInt(AValue);
        if (this.FormContainerElement() != null) {
          if ((pas.SysUtils.UpperCase(this.FormContainerElement().tagName) !== "BODY") && !this.GetIsLinked()) this.FormContainerElement().style.setProperty("height",pas.SysUtils.IntToStr(AValue) + "px");
        };
        return;
      };
      pas["WEBLib.Controls"].TControl.SetHeight.apply(this,arguments);
      if ((this.FFormContainer !== "") && (this.FormContainerElement() != null) && !(pas.SysUtils.UpperCase(this.FormContainerElement().tagName) === "BODY")) {
        this.FormContainerElement().style.setProperty("height",pas.SysUtils.IntToStr(AValue) + "px");
        this.Realign();
      };
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("height",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    this.SetClientHeight = function (Value) {
      if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
        this.SetHeight(Value + $mod.Application.FFormCaptionHeight);
      } else pas["WEBLib.Controls"].TControl.SetClientHeight.apply(this,arguments);
    };
    this.GetClientHeight = function () {
      var Result = 0;
      if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
        Result = this.GetHeight();
      } else Result = pas["WEBLib.Controls"].TControl.GetClientHeight.call(this);
      return Result;
    };
    this.HandleHashChange = function (Event) {
      var Result = false;
      var oldURL = "";
      var newURL = "";
      var newHash = "";
      var pc = null;
      var newform = null;
      oldURL = Event.oldURL;
      newURL = Event.newURL;
      if (this.FOnHashChange != null) {
        this.FOnHashChange(this,oldURL,newURL);
      };
      if ($mod.Application.FRouting) {
        newHash = pas.System.Copy(newURL,pas.System.Pos("#",newURL) + 1,newURL.length);
        pc = pas.Classes.GetClass("T" + this.FName);
        if ((pc != null) && ($mod.LastHash !== newHash)) {
          if ((pas.System.Pos("#" + this.FName + "?",oldURL + "?") !== 0) && (pas.System.Pos("#" + this.FName + "?",newURL + "?") === 0)) {
            this.Close();
          };
          if (!this.FPopup) {
            pc = pas.Classes.GetClass("T" + newHash);
            if (pc != null) {
              $mod.Application.AutoCreateForm(pc,{get: function () {
                  return newform;
                }, set: function (v) {
                  newform = v;
                }});
            };
          };
        };
      };
      Result = true;
      return Result;
    };
    this.HandleLoaded = function (Event) {
      var Result = false;
      this.Resize$1();
      this.InitAnchoring();
      Result = true;
      return Result;
    };
    this.HandleDOMContentLoaded = function (Event) {
      var Result = false;
      if (this.FOnDOMContentLoaded != null) this.FOnDOMContentLoaded(this);
      Result = true;
      return Result;
    };
    this.HandleScroll = function (Event) {
      var Result = false;
      if (this.FOnScroll != null) this.FOnScroll(this);
      Result = true;
      return Result;
    };
    this.HandleUnload = function (Event) {
      var Result = false;
      if (this.FOnUnload != null) this.FOnUnload(this);
      Result = true;
      return Result;
    };
    this.HandleBeforeUnload = function (Event) {
      var Result = false;
      var msg = "";
      msg = "";
      if (this.FOnBeforeUnload != null) this.FOnBeforeUnload(this,{get: function () {
          return msg;
        }, set: function (v) {
          msg = v;
        }});
      if (msg !== "") {
        Event.returnValue = msg;
        return msg;
      };
      Result = true;
      return Result;
    };
    this.HandleObserver = function () {
      var Result = false;
      this.Resize$1();
      Result = true;
      return Result;
    };
    this.HandleResize = function (Event) {
      var Result = false;
      if (this.FVisible && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (!(this.GetContainer() != null)) this.CreateControl();
        this.Resize$1();
        if (this.GetElementHandle() === document.body) window.setTimeout(rtl.createSafeCallback(this,"Resize$1"),25);
      };
      if (1 < 0) {
        this.HandleObserver();
      };
      Result = true;
      return Result;
    };
    this.HandleDocMouseMove = function (Event) {
      var Result = false;
      var deltax = 0.0;
      var deltay = 0.0;
      var el = null;
      var l = 0;
      var t = 0;
      if (this.FDown && (this.GetContainer() != null)) {
        deltax = Event.clientX - this.FMdx;
        deltay = Event.clientY - this.FMdy;
        if (this.FHasCaption && (this.FFormFileName !== "")) {
          el = this.GetContainer().parentNode}
         else el = this.GetContainer();
        el.style.setProperty("transform","");
        el.style.setProperty("position","absolute");
        l = Math.round(this.FDlgX + deltax);
        t = Math.round(this.FDlgY + deltay);
        el.style.setProperty("left",pas.SysUtils.IntToStr(l) + "px");
        el.style.setProperty("top",pas.SysUtils.IntToStr(t) + "px");
        this.FLeft = l;
        this.FTop = t;
      };
      Result = true;
      return Result;
    };
    this.HandleDocMouseUp = function (Event) {
      var Result = false;
      if (this.FDown) {
        this.FCaptured$1 = false;
        this.FDown = false;
        document.body.removeEventListener("mousemove",this.FDocMouseMovePtr);
        document.body.removeEventListener("mouseup",this.FDocMouseUpPtr);
        if (this.FMoveSpan != null) document.body.removeChild(this.FMoveSpan);
        this.FEventStopPropagation = rtl.unionSet(this.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeMouseMove,pas["WEBLib.Controls"].TElementEvent.eeMouseUp));
        this.FMoveSpan = null;
      };
      Result = true;
      return Result;
    };
    this.HandleTitleDown = function (Event) {
      var Result = false;
      var r = null;
      Event.stopPropagation();
      Event.preventDefault();
      this.FPopupClose = $mod.TPopupClose.pcNever;
      this.FMdx = Math.round(Event.clientX);
      this.FMdy = Math.round(Event.clientY);
      if (this.FHasCaption && (this.FFormFileName !== "")) {
        r = this.GetContainer().parentNode.getBoundingClientRect()}
       else r = this.GetContainer().getBoundingClientRect();
      this.FDlgX = Math.round(pas.System.Int(r.left));
      this.FDlgY = Math.round(pas.System.Int(r.top));
      this.FDown = true;
      if (!this.FCaptured$1) {
        this.FCaptured$1 = true;
        this.FMoveSpan = document.createElement("SPAN");
        this.FMoveSpan.style.setProperty("top","0");
        this.FMoveSpan.style.setProperty("left","0");
        this.FMoveSpan.style.setProperty("right","0");
        this.FMoveSpan.style.setProperty("bottom","0");
        this.FMoveSpan.style.setProperty("position","absolute");
        document.body.appendChild(this.FMoveSpan);
        this.FEventStopPropagation = rtl.diffSet(this.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeMouseMove,pas["WEBLib.Controls"].TElementEvent.eeMouseUp));
        document.body.addEventListener("mousemove",this.FDocMouseMovePtr);
        document.body.addEventListener("mouseup",this.FDocMouseUpPtr);
      };
      Result = true;
      return Result;
    };
    this.HandleTouchStart = function (Event) {
      var Result = false;
      var r = null;
      if (Event.touches.length === 0) return Result;
      Event.stopPropagation();
      Event.preventDefault();
      this.FPopupClose = $mod.TPopupClose.pcNever;
      this.FMdx = Math.round(Event.touches.item(0).clientX);
      this.FMdy = Math.round(Event.touches.item(0).clientY);
      if (this.FHasCaption && (this.FFormFileName !== "")) {
        r = this.GetContainer().parentNode.getBoundingClientRect()}
       else r = this.GetContainer().getBoundingClientRect();
      this.FDlgX = Math.round(pas.System.Int(r.left));
      this.FDlgY = Math.round(pas.System.Int(r.top));
      this.FDown = true;
      if (!this.FCaptured$1) {
        this.FCaptured$1 = true;
        this.FMoveSpan = document.createElement("SPAN");
        this.FMoveSpan.style.setProperty("top","0");
        this.FMoveSpan.style.setProperty("left","0");
        this.FMoveSpan.style.setProperty("right","0");
        this.FMoveSpan.style.setProperty("bottom","0");
        this.FMoveSpan.style.setProperty("position","absolute");
        document.body.appendChild(this.FMoveSpan);
        this.FEventStopPropagation = rtl.diffSet(this.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeTouchMove,pas["WEBLib.Controls"].TElementEvent.eeTouchEnd));
        document.body.addEventListener("touchmove",this.FDocTouchMovePtr);
        document.body.addEventListener("touchend",this.FDocTouchEndPtr);
      };
      Result = true;
      return Result;
    };
    this.HandleDocTouchMove = function (Event) {
      var Result = false;
      var deltax = 0.0;
      var deltay = 0.0;
      var el = null;
      var l = 0;
      var t = 0;
      if (this.FDown && (this.GetContainer() != null)) {
        if (Event.touches.length === 0) return Result;
        deltax = Event.touches.item(0).clientX - this.FMdx;
        deltay = Event.touches.item(0).clientY - this.FMdy;
        if (this.FHasCaption && (this.FFormFileName !== "")) {
          el = this.GetContainer().parentNode}
         else el = this.GetContainer();
        el.style.setProperty("transform","");
        el.style.setProperty("position","absolute");
        l = Math.round(this.FDlgX + deltax);
        t = Math.round(this.FDlgY + deltay);
        el.style.setProperty("left",pas.SysUtils.IntToStr(l) + "px");
        el.style.setProperty("top",pas.SysUtils.IntToStr(t) + "px");
        this.FLeft = l;
        this.FTop = t;
      };
      Result = true;
      return Result;
    };
    this.HandleDocTouchEnd = function (Event) {
      var Result = false;
      if (this.FDown) {
        this.FCaptured$1 = false;
        this.FDown = false;
        document.body.removeEventListener("touchmove",this.FDocTouchMovePtr);
        document.body.removeEventListener("touchend",this.FDocTouchEndPtr);
        if (this.FMoveSpan != null) document.body.removeChild(this.FMoveSpan);
        this.FEventStopPropagation = rtl.unionSet(this.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeTouchMove,pas["WEBLib.Controls"].TElementEvent.eeTouchEnd));
        this.FMoveSpan = null;
      };
      Result = true;
      return Result;
    };
    this.HandleCloseClick = function (Event) {
      var Result = false;
      var CanClose = false;
      CanClose = true;
      if (this.FOnCloseQuery != null) this.FOnCloseQuery(this,{get: function () {
          return CanClose;
        }, set: function (v) {
          CanClose = v;
        }});
      if (CanClose) this.Close();
      Result = true;
      return Result;
    };
    this.SetLeft = function (AValue) {
      var eh = null;
      pas["WEBLib.Controls"].TControl.SetLeft.apply(this,arguments);
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("left",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    this.SetTop = function (AValue) {
      var eh = null;
      pas["WEBLib.Controls"].TControl.SetTop.apply(this,arguments);
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("top",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    var cPixelsPerInch = "PixelsPerInch";
    this.DefineProperties = function (AFiler) {
      pas.Classes.TComponent.DefineProperties.call(this,AFiler);
      AFiler.DefineProperty(cPixelsPerInch,rtl.createCallback(this,"ReadPixelsPerInch"),rtl.createCallback(this,"WritePixelsPerInch"),false);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FLoadedPtr = null;
      this.FDOMContentLoadedPtr = null;
      this.FUnloadPtr = null;
      this.FBeforeUnloadPtr = null;
      this.FResizePtr = null;
      this.FScrollPtr = null;
      this.FDocMouseUpPtr = null;
      this.FDocMouseMovePtr = null;
      this.FTitleDownPtr = null;
      this.FDocTouchMovePtr = null;
      this.FDocTouchEndPtr = null;
      this.FTitleTouchStartPtr = null;
      this.FDoClickPtr = null;
      this.FKeyDownPtr$1 = null;
      this.FOrientationChangePtr = null;
      this.FHashChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      if (this.FLoadedPtr === null) {
        this.FLoadedPtr = rtl.createCallback(this,"HandleLoaded");
        this.FDOMContentLoadedPtr = rtl.createCallback(this,"HandleDOMContentLoaded");
        this.FUnloadPtr = rtl.createCallback(this,"HandleUnload");
        this.FBeforeUnloadPtr = rtl.createCallback(this,"HandleBeforeUnload");
        this.FResizePtr = rtl.createCallback(this,"HandleResize");
        this.FScrollPtr = rtl.createCallback(this,"HandleScroll");
        this.FDocMouseUpPtr = rtl.createCallback(this,"HandleDocMouseUp");
        this.FDocMouseMovePtr = rtl.createCallback(this,"HandleDocMouseMove");
        this.FTitleDownPtr = rtl.createCallback(this,"HandleTitleDown");
        this.FDoClickPtr = rtl.createCallback(this,"HandleDoClick$1");
        this.FKeyDownPtr$1 = rtl.createCallback(this,"HandleKeyDown");
        this.FOrientationChangePtr = rtl.createCallback(this,"HandleOrientationChange");
        this.FHashChangePtr = rtl.createCallback(this,"HandleHashChange");
        this.FTitleTouchStartPtr = rtl.createCallback(this,"HandleTouchStart");
        this.FDocTouchMovePtr = rtl.createCallback(this,"HandleDocTouchMove");
        this.FDocTouchEndPtr = rtl.createCallback(this,"HandleDocTouchEnd");
      };
    };
    this.VisibleChanged = function () {
      var LIsBody = false;
      pas["WEBLib.Controls"].TControl.VisibleChanged.call(this);
      if (this.FLayer$1 != null) {
        if (this.FVisible) {
          this.FLayer$1.style.setProperty("display","")}
         else this.FLayer$1.style.setProperty("display","none");
      } else {
        LIsBody = pas.SysUtils.LowerCase(this.GetID()) === pas["WEBLib.WebTools"].cBodyTag;
        if ((this.GetContainer() != null) && (this.FFormContainer !== "") && !LIsBody) {
          if (this.FVisible) {
            this.GetContainer().style.setProperty("display","")}
           else this.GetContainer().style.setProperty("display","none");
        };
      };
    };
    this.Resize$1 = function () {
      var i = 0;
      var ch = 0;
      var neww = 0;
      var newh = 0;
      var eh = null;
      var dr = null;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      this.FIsResizing$1 = true;
      if (this.FPopup && (this.FPopupElement != null)) {
        eh = this.FPopupElement;
        dr = eh.getBoundingClientRect();
        neww = Math.round(dr.right - dr.left - 2);
        if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
          ch = this.GetCaptionHeight();
          newh = Math.round(dr.bottom - dr.top - ch - 2);
        } else newh = Math.round(dr.bottom - dr.top - 2);
      } else {
        neww = window.innerWidth;
        newh = window.innerHeight;
      };
      this.UpdateControlSize(neww,newh);
      if (!(pas["WEBLib.Controls"].IsAndroid() && (document.activeElement.tagName === "INPUT"))) this.AlignControl(this);
      this.DoResize();
      this.FIsResizing$1 = false;
      if (!this.IsUpdating()) {
        if ((this.FOrigRect.Left === -1) && (this.FOrigRect.Top === -1)) this.InitAnchoring();
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.GetControls(i).UpdateAnchoring();
        };
      };
    };
    this.CreateControl = function () {
      var s = "";
      if (!this.FVisible && !this.FPopup) return;
      pas["WEBLib.Controls"].TControl.CreateControl.call(this);
      s = "";
      if (typeof CONTAINERID !== "undefined") {
        try {
          s = CONTAINERID;
        }
        catch(e)
        {
        }
      };
      if (s !== "") this.SetFormContainer(s);
      this.UpdateSize();
    };
    this.DoClose = function (CloseAction) {
      if ((this.FModalProc != null) && (CloseAction.get() !== $mod.TCloseAction.caNone)) {
        this.FModalProc(this.FModalResult);
        this.FModalProc = null;
      };
    };
    this.BindEvents = function () {
      var pc = null;
      var hash = "";
      pas["WEBLib.Controls"].TControl.BindEvents.call(this);
      if (document.readyState !== "loading") if (this.FOnDOMContentLoaded != null) this.FOnDOMContentLoaded(this);
      window.addEventListener("resize",this.FResizePtr);
      window.addEventListener("load",this.FLoadedPtr);
      window.addEventListener("DOMContentLoaded",this.FDOMContentLoadedPtr);
      document.addEventListener("scroll",this.FScrollPtr);
      window.addEventListener("unload",this.FUnloadPtr);
      window.addEventListener("beforeunload",this.FBeforeUnloadPtr);
      window.addEventListener("keydown",this.FKeyDownPtr$1);
      window.addEventListener("orientationchange",this.FOrientationChangePtr);
      window.addEventListener("hashchange",this.FHashChangePtr);
      pc = pas.Classes.GetClass(this.$classname);
      if ((pc != null) && !this.FPopup && $mod.Application.FRouting) {
        hash = this.$classname;
        pas.System.Delete({get: function () {
            return hash;
          }, set: function (v) {
            hash = v;
          }},1,1);
        $mod.LastHash = hash;
        window.location.hash = hash;
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if ((this.FLayer$1 != null) && (this.FPopupClose === $mod.TPopupClose.pcOnDeactivate)) this.FLayer$1.removeEventListener("click",this.FDoClickPtr);
      if (this.FResizeObserver != null) {
        this.FResizeObserver.disconnect();
      };
      window.removeEventListener("resize",this.FResizePtr);
      window.removeEventListener("load",this.FLoadedPtr);
      window.removeEventListener("DOMContentLoaded",this.FDOMContentLoadedPtr);
      document.removeEventListener("scroll",this.FScrollPtr);
      window.removeEventListener("unload",this.FUnloadPtr);
      window.removeEventListener("beforeunload",this.FBeforeUnloadPtr);
      window.removeEventListener("keydown",this.FKeyDownPtr$1);
      window.removeEventListener("orientationchange",this.FOrientationChangePtr);
      window.removeEventListener("hashchange",this.FHashChangePtr);
    };
    this.DoCreate = function () {
      this.BeginUpdate();
      this.LoadDFMValues();
      this.Loaded();
      if (this.FOnCreate != null) this.FOnCreate(this);
      this.FCreating = false;
      this.EndUpdate();
      this.UpdateChildren(this);
      this.Realign();
      this.DoResize();
    };
    this.Realign = function () {
      var el = null;
      var dr = null;
      var r = pas.Types.TRect.$new();
      if ((this.FFormContainer !== "") && (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone)) {
        el = document.getElementById(this.FFormContainer);
        if (el != null) {
          dr = el.getBoundingClientRect();
          if ((dr.width === 0) && (dr.height === 0) && (el.style.getPropertyValue("position") === "absolute")) {
            r.$assign(pas["WEBLib.Controls"].GetHTMLElementAbsoluteRect(el));
          } else {
            r.$assign(pas.Types.Rect(Math.round(dr.left),Math.round(dr.top),Math.round(dr.right),Math.round(dr.bottom)));
          };
          this.SetBoundsInt(r.Left,r.Top,r.Right - r.Left,r.Bottom - r.Top);
        };
      };
      pas["WEBLib.Controls"].TControl.Realign.call(this);
    };
    this.DoResize = function () {
      var w = 0;
      var h = 0;
      w = this.GetWidth();
      h = this.GetHeight();
      if ((w === this.FOldWidth) && (h === this.FOldHeight)) return;
      this.FOldWidth = w;
      this.FOldHeight = h;
      if (this.FOnResize != null) this.FOnResize(this);
    };
    this.DoShow = function () {
      this.DoAutoFocus();
      if ((this.FOnShow != null) && !this.FShown) {
        this.FShown = true;
        this.FOnShow(this);
      };
    };
    this.DoAutoFocus = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ((this.GetControls(i).FTabOrder === 0) && this.GetControls(i).FTabStop) {
          this.GetControls(i).SetFocus();
        };
      };
    };
    this.Paint = function () {
    };
    this.HandleDoClick$1 = function (Event) {
      var Result = false;
      Event.stopPropagation();
      if (this.FPopupClose === $mod.TPopupClose.pcOnDeactivate) this.Close();
      Result = true;
      return Result;
    };
    this.HandleKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      k = this.GetKeyCode(Event.key,true);
      if (!pas.System.Assigned(k)) return Result;
      if ((k === 27) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && this.FPopup) {
        this.Close();
      };
      Result = true;
      return Result;
    };
    this.HandleOrientationChange = function (Event) {
      var Result = false;
      var so = 0;
      var isPortrait = false;
      this.Resize$1();
      this.Realign();
      Result = true;
      if (this.FOnOrientationChange != null) {
        var mql = window.matchMedia("(orientation: portrait)");
        isPortrait = (mql.matches);
        if (isPortrait) {
          so = $mod.TScreenOrientation.soLandscape}
         else so = $mod.TScreenOrientation.soPortrait;
        this.FOnOrientationChange(this,so);
      };
      if (this.FOnResize != null) this.FOnResize(this);
      return Result;
    };
    this.HandleDoResize = function () {
      var dr = null;
      var neww = 0;
      var newh = 0;
      dr = this.GetContainer().getBoundingClientRect();
      neww = Math.round(dr.right - dr.left);
      newh = Math.round(dr.bottom - dr.top);
      if ((neww !== this.FOrigWidth) || (newh !== this.FOrigHeight)) {
        this.SetWidth(neww);
        this.SetHeight(newh);
        dr = this.GetContainer().getBoundingClientRect();
        this.FOrigWidth = Math.round(dr.right - dr.left);
        this.FOrigHeight = Math.round(dr.bottom - dr.top);
        this.AlignControl(this);
      };
    };
    this.KeyPreview = function (Key, Shift) {
      var i = 0;
      var lt = 0;
      var ft = 0;
      var lti = 0;
      var fti = 0;
      lt = -1;
      ft = 0xFFFF;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (!this.GetControls(i).FVisible && this.GetControls(i).FEnabled) continue;
        if (this.GetControls(i).FTabOrder < ft) {
          ft = this.GetControls(i).FTabOrder;
          fti = i;
        };
        if (this.GetControls(i).FTabOrder > lt) {
          lt = this.GetControls(i).FTabOrder;
          lti = i;
        };
        if ((Key.get() === 13) || (Key.get() === 27)) this.GetControls(i).HandleKeyPreview(Key.get());
      };
      if ($mod.Application.FMainForm === this) return;
      if ((Key.get() === 9) && !(pas.Classes.TShiftState$a.ssShift in Shift) && (lti < this.GetControlsCount()) && (fti >= 0) && (fti !== lti)) {
        if (this.GetControls(lti).Focused()) {
          this.GetControls(fti).SetFocus();
          Key.set(0);
        };
      };
      if ((Key.get() === 9) && (pas.Classes.TShiftState$a.ssShift in Shift) && (fti >= 0) && (lti < this.GetControlsCount()) && (fti !== lti)) {
        if (this.GetControls(fti).Focused()) {
          this.GetControls(lti).SetFocus();
          Key.set(0);
        };
      };
    };
    this.GetWidth = function () {
      var Result = 0;
      var dr = null;
      var el = null;
      if (this.FFormElement !== "") {
        el = document.getElementById(this.FFormElement);
        if (el != null) {
          dr = el.getBoundingClientRect();
          Result = Math.round(dr.right - dr.left);
          return Result;
        };
      };
      if (this.GetElementHandle() === document.body) {
        dr = document.documentElement.getBoundingClientRect();
        Result = Math.round(dr.width);
        if (Result > window.innerWidth) Result = window.innerWidth;
      } else {
        if (this.FPopup) {
          Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this)}
         else {
          Result = Math.round(this.GetElementHandle().offsetWidth);
          if (Result === 0) {
            if (this.FFormContainer !== "") {
              Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this)}
             else Result = window.innerWidth;
          };
        };
      };
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      var d = 0;
      var s = "";
      var css = null;
      var el = null;
      var dr = null;
      if (this.FFormElement !== "") {
        el = document.getElementById(this.FFormElement);
        if (el != null) {
          dr = el.getBoundingClientRect();
          Result = Math.round(dr.bottom - dr.top);
          return Result;
        };
      };
      if (this.GetElementHandle() === document.body) {
        css = window.getComputedStyle(this.GetElementHandle());
        s = css.getPropertyValue("margin-top");
        s = pas.System.Copy(s,1,s.length - 2);
        d = Math.round(pas.SysUtils.StrToFloat$1(s,pas.SysUtils.TFormatSettings.Invariant()) - 2);
        dr = document.documentElement.getBoundingClientRect();
        Result = Math.round(dr.height);
        if (Result > window.innerHeight) Result = window.innerHeight - Math.max(0,d);
      } else {
        if (this.FPopup) {
          Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this);
        } else {
          Result = Math.round(this.GetElementHandle().offsetHeight);
          if (Result === 0) {
            if (this.FFormContainer !== "") {
              Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this)}
             else Result = window.innerHeight;
          };
        };
      };
      return Result;
    };
    this.GetLeft = function () {
      var Result = 0;
      var el = null;
      var dr = null;
      if (this.FPopup) {
        Result = pas["WEBLib.Controls"].TControl.GetLeft.call(this);
      } else {
        if (this.FFormElement !== "") {
          el = document.getElementById(this.FFormElement);
          if (el != null) {
            dr = el.getBoundingClientRect();
            Result = Math.round(dr.left);
          };
        } else {
          el = null;
          if (this.FFormContainer !== "") el = document.getElementById(this.FFormContainer);
          if (!(el != null)) el = this.GetElementHandle();
          Result = Math.round(el.offsetLeft);
        };
      };
      return Result;
    };
    this.GetTop = function () {
      var Result = 0;
      var el = null;
      var dr = null;
      if (this.FPopup) {
        Result = pas["WEBLib.Controls"].TControl.GetTop.call(this)}
       else {
        if (this.FFormElement !== "") {
          el = document.getElementById(this.FFormElement);
          if (el != null) {
            dr = el.getBoundingClientRect();
            Result = Math.round(dr.top);
          };
        } else {
          el = null;
          if (this.FFormContainer !== "") el = document.getElementById(this.FFormContainer);
          if (!(el != null)) el = this.GetElementHandle();
          Result = Math.round(el.offsetTop);
        };
      };
      return Result;
    };
    this.GetClientRect = function () {
      var Result = pas.Types.TRect.$new();
      Result.$assign(pas["WEBLib.Controls"].TControl.GetClientRect.call(this));
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      var eh = null;
      var caph = null;
      if (!this.FPopup && (this.FormContainerElement() != null)) {
        Result = this.FormContainerElement();
        return Result;
      };
      Result = document.createElement("DIV");
      this.FLayer$1 = this.CreateLayer();
      document.body.appendChild(this.FLayer$1);
      eh = this.FLayer$1;
      if (this.FPopupClose === $mod.TPopupClose.pcOnDeactivate) {
        this.GetMethodPointers();
        eh.addEventListener("click",this.FDoClickPtr);
      };
      eh.style.setProperty(pas["WEBLib.Controls"].CSSZIndex,$mod.Application.MaxZIndexStr());
      if (this.FBorder === $mod.TFormBorderStyle.fbSizeable) {
        Result.style.setProperty("resize","both");
        Result.style.setProperty("overflow","auto");
      };
      this.FHasCaption = false;
      if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbSizeable,$mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
        caph = this.CreateCaption();
        Result.appendChild(caph);
      };
      return Result;
    };
    this.UpdateElement = function () {
      var clr = "";
      var el = null;
      if (this.FCreating) return;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if ((this.GetElementHandle() != null) || (this.GetContainer() != null)) {
        if (this.FCaption !== "") {
          if (!this.FPopup) {
            window.document.title = this.FCaption}
           else {
            if (this.FCaptionElement != null) {
              el = this.FCaptionElement.childNodes.item(0);
              if (el != null) el.nodeValue = this.FCaption;
              if (this.FShowClose && !(this.FCaptionCloseElement != null)) {
                this.FCaptionCloseElement = document.createElement("SPAN");
                this.FCaptionCloseElement.style.setProperty("float","right");
                this.FCaptionCloseElement.style.setProperty("cursor","default");
                this.FCaptionCloseElement.style.setProperty("margin-right","8px");
                this.FCaptionCloseElement.innerHTML = "&#x2716;";
                this.FCaptionElement.appendChild(this.FCaptionCloseElement);
                this.FCaptionCloseElement.addEventListener("click",rtl.createSafeCallback(this,"HandleCloseClick"));
                this.FCaptionCloseElement.addEventListener("touchstart",rtl.createSafeCallback(this,"HandleCloseClick"));
              };
              pas["WEBLib.Controls"].SetHTMLElementFont(this.FCaptionElement,this.FFont,!((this.FElementCaptionClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
            };
          };
        };
      };
      if (this.GetContainer() != null) {
        clr = pas["WEBLib.Graphics"].ColorToHTML(this.FColor);
        if (this.GetContainer() != null) {
          if ((this.FColor !== -1) && (this.FColor !== 16777215) && !this.FPopup && (this.FElementClassName === "")) this.GetContainer().style.setProperty(pas["WEBLib.Controls"].CSSBackground,clr);
          if (!this.FPopup && (this.FCSSLibrary !== pas["WEBLib.Controls"].TCSSLibrary.cssNone)) document.body.style.removeProperty(pas["WEBLib.Controls"].CSSBackground);
          if ((this.FElementClassName !== "") || (this.FColor === -1) || ((this.FColor === 16777215) && !this.FPopup)) this.GetContainer().style.removeProperty(pas["WEBLib.Controls"].CSSBackground);
          if ((this.FElementClassName === "") && !this.FPopup) {
            document.documentElement.style.setProperty('height','100%');
          };
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetContainer(),this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        };
        if (this.FPopup) {
          if (!(this.FPopupElement != null)) this.FPopupElement = this.GetContainer();
          if (this.FElementPopupClassName !== "") {
            this.GetContainer().style.removeProperty("border");
            this.FPopupElement.setAttribute("class",this.FElementPopupClassName);
          } else {
            if (this.FShadow) {
              this.FPopupElement.style.setProperty("box-shadow","3px 3px 3px silver");
            } else {
              this.FPopupElement.style.removeProperty("box-shadow");
            };
            this.FPopupElement.style.setProperty("border","1px solid gray");
          };
          if ((this.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (this.FElementClassName === "")) {
            this.FPopupElement.setAttribute("class","card");
            this.FPopupElement.style.setProperty("display","block");
            this.GetContainer().style.removeProperty("box-shadow");
          };
        } else {
          this.GetContainer().style.removeProperty("box-shadow");
        };
      };
    };
    this.ContainerElement = function () {
      var Result = null;
      Result = this.FormContainerElement();
      return Result;
    };
    this.FormContainerElement = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        if (this.FDesignContainer != null) Result = this.FDesignContainer;
      };
      if (this.FFormContainer !== "") {
        Result = document.getElementById(this.FFormContainer);
        if (!(Result != null)) Result = document.body;
      } else {
        Result = document.body;
      };
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = window;
        return Result;
      };
      if (this.FFormContainer !== "") {
        Result = window;
      } else {
        if (!this.FPopup) {
          Result = window;
        } else Result = pas["WEBLib.Controls"].TControl.GetElementBindHandle.call(this);
      };
      return Result;
    };
    this.GetElementHandle = function () {
      var Result = null;
      if (this.FPopup) {
        Result = pas["WEBLib.Controls"].TControl.GetElementHandle.call(this);
        if (!(Result != null)) Result = this.FPopupElement;
      } else Result = this.FormContainerElement();
      return Result;
    };
    this.SetElementClassName = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetElementClassName.apply(this,arguments);
      if (this.FPopup && (this.FPopupElement != null)) {
        this.FPopupElement.setAttribute("class",AValue);
      };
    };
    this.CloseQuery = function () {
      var Result = false;
      Result = true;
      if (this.FOnCloseQuery != null) this.FOnCloseQuery(this,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.LoadDFMValues = function () {
    };
    this.Init = function () {
    };
    this.IsFocused = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.CreateLayer = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      Result.style.setProperty("top","0");
      Result.style.setProperty("left","0");
      Result.style.setProperty("right","0");
      Result.style.setProperty("bottom","0");
      Result.style.setProperty("webkit-user-select","none");
      Result.style.setProperty("moz-user-select","none");
      Result.style.setProperty("khtml-user-select","none");
      Result.style.setProperty("ms-user-select","none");
      Result.style.setProperty("user-select","none");
      Result.style.setProperty("position","absolute");
      Result.style.setProperty("z-index",$mod.Application.MaxZIndexStr());
      return Result;
    };
    this.CreateCaption = function () {
      var Result = null;
      var BarHeight = "";
      BarHeight = pas.SysUtils.IntToStr($mod.Application.FFormCaptionHeight);
      this.FCaptionElement = document.createElement("DIV");
      this.FCaptionElement.innerHTML = this.FCaption;
      this.FCaptionElement.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML($mod.Application.FThemeColor));
      this.FCaptionElement.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML($mod.Application.FThemeTextColor));
      this.FCaptionElement.style.setProperty("cursor","move");
      this.FCaptionElement.style.setProperty("height",BarHeight + "px");
      this.FCaptionElement.style.setProperty("line-height",BarHeight + "px");
      this.FCaptionElement.style.setProperty("border-bottom","1px solid black");
      this.FCaptionElement.style.setProperty("padding-left","4px");
      this.FCaptionElement.style.setProperty("-moz-user-select","none");
      this.FCaptionElement.style.setProperty("-webkit-user-select","none");
      this.FCaptionElement.style.setProperty("-ms-user-select","none");
      this.FCaptionElement.style.setProperty("user-select","none");
      this.FCaptionElement.style.setProperty("-o-user-select","none");
      if (this.FElementCaptionClassName !== "") this.FCaptionElement.setAttribute("class",this.FElementCaptionClassName);
      pas["WEBLib.Controls"].SetHTMLElementFont(this.FCaptionElement,this.FFont,!((this.FElementCaptionClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
      if (!(this.FTitleDownPtr != null)) this.GetMethodPointers();
      this.FCaptionElement.innerHTML = this.FCaption;
      this.FCaptionElement.addEventListener("mousedown",this.FTitleDownPtr);
      this.FCaptionElement.addEventListener("touchstart",this.FTitleTouchStartPtr);
      this.FHasCaption = true;
      Result = this.FCaptionElement;
      return Result;
    };
    this.GetCaptionHeight = function () {
      var Result = 0;
      var r = null;
      Result = 0;
      if ((this.FCaptionElement != null) && (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable))) {
        r = this.FCaptionElement.getBoundingClientRect();
        Result = Math.round(r.bottom - r.top);
      };
      return Result;
    };
    this.SetColorScheme = function (AScheme) {
      var s = "";
      if (!$mod.Application.FThemed) return;
      var $tmp = AScheme;
      if ($tmp === $mod.TApplicationColorScheme.csDark) {
        this.SetColor(0x202124);
        s = "label,option,td,table,ul,li {background-color: #202124; color: #BEC1C6;}" + "\r\n" + "body,input,textarea,select,fieldset {background-color: #202124; color: #BEC1C6; border: 1px solid gray;}" + "\r\n" + "input:focus, textarea:focus, select:focus, span:focus { border: 1px solid silver; outline: none !important;}";
        this.AddCSS("appscheme",s);
      } else if ($tmp === $mod.TApplicationColorScheme.csLight) {
        this.SetColor(16777215);
        this.RemoveCSS("appscheme");
      };
    };
    this.SetCSSLibrary = function (ALibrary) {
      this.FCSSLibrary = ALibrary;
      if ((ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
    };
    this.SetFormPos = function () {
      if (!(this.GetContainer() != null)) return;
      if (this.FPosition === $mod.TPosition.poScreenCenter) {
        this.FLeft = Math.round(($mod.WinWidth() - this.GetWidth()) / 2) + window.scrollX;
        this.FTop = Math.round(($mod.WinHeight() - this.GetHeight()) / 2) + window.scrollY;
      };
      this.GetContainer().style.setProperty("position","absolute");
      this.GetContainer().style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()) + "px");
      this.GetContainer().style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()) + "px");
      this.GetContainer().style.setProperty("left",pas.SysUtils.IntToStr(this.GetLeft()) + "px");
      this.GetContainer().style.setProperty("top",pas.SysUtils.IntToStr(this.GetTop()) + "px");
    };
    this.GetHTMLFileName = function (ADirectForm) {
      var Result = "";
      if (ADirectForm) {
        Result = ""}
       else Result = this.$module.$name + $mod.Application.GetFormExtension();
      return Result;
    };
    this.LoadedDone = function () {
      $mod.Application.TriggerNotification();
    };
    this.Loaded = function () {
      var el = null;
      pas["WEBLib.Controls"].TControl.Loaded.call(this);
      if ((this.FFormContainer !== "") && (this.FElementClassName !== "")) {
        el = this.FormContainerElement();
        if (el != null) {
          el.setAttribute("class",this.FElementClassName);
        };
      };
      this.LoadedDone();
    };
    this.ColorChanging = function () {
      pas["WEBLib.Controls"].TControl.ColorChanging.call(this);
      if (this.GetContainer() != null) {
        this.GetContainer().style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
      };
    };
    this.SetParent = function (AValue) {
      if ((AValue != null) && (this.FLayer$1 != null)) {
        AValue.GetContainer().appendChild(this.FLayer$1);
      } else pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TControl.CreateInitialize.call(this);
      this.FAllowTouch = true;
      this.FModalResult = 0;
      this.FFormStyle = $mod.TFormStyle.fsNormal;
      this.FBorder = $mod.TFormBorderStyle.fbSizeable;
      this.FShadow = true;
      this.FShowClose = true;
      this.FDefaultCloseAction = $mod.TCloseAction.caHide;
      this.FTimerID = -1;
      this.FCaptionElement = null;
      this.FColor = 16777215;
      window.addEventListener("load",this.FLoadedPtr);
    };
    this.Create$2 = function (id) {
      this.FNoHTML = false;
      this.FCreating = true;
      this.FFormContainer = id;
      if (id === "") {
        pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag)}
       else pas["WEBLib.Controls"].TControl.Create$2.call(this,id);
      this.FFormElement = "";
      this.FModalResult = 0;
      this.FFormStyle = $mod.TFormStyle.fsNormal;
      this.FDefaultCloseAction = $mod.TCloseAction.caHide;
      this.DoCreate();
      return this;
    };
    this.Create$5 = function (id, AReference) {
      this.FCreating = true;
      this.FFormContainer = id;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,id);
      AReference.set(this);
      this.FFormElement = "";
      this.FModalResult = 0;
      this.FFormStyle = $mod.TFormStyle.fsNormal;
      this.FDefaultCloseAction = $mod.TCloseAction.caHide;
      this.DoCreate();
      return this;
    };
    this.Create$1 = function (AOwner) {
      this.FNoHTML = false;
      this.FCreating = true;
      this.FResizeObserver = null;
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FBorder = $mod.TFormBorderStyle.fbSingle;
      this.FFormFileName = "";
      this.FPopupMode = $mod.TPopupMode.pmNone;
      this.FPopupClose = $mod.TPopupClose.pcOnDeactivate;
      this.FPopup = true;
      this.FPosition = $mod.TPosition.poScreenCenter;
      this.FPopupOpacity = 1.0;
      this.FCreated = true;
      return this;
    };
    this.Create$7 = function (AOwner, IsPopup, ABorder, ATitle) {
      this.FNoHTML = false;
      this.FCreating = true;
      this.FResizeObserver = null;
      pas["WEBLib.Controls"].TControl.Create$1.call(this,AOwner);
      this.FBorder = ABorder;
      this.FCaption = ATitle;
      this.FFormFileName = "";
      this.FPopupMode = $mod.TPopupMode.pmNone;
      this.FPopupClose = $mod.TPopupClose.pcOnDeactivate;
      this.FPopup = IsPopup;
      this.FPosition = $mod.TPosition.poScreenCenter;
      this.FPopupOpacity = 1.0;
      return this;
    };
    this.CreateNew = function (AOwner, Dummy) {
      this.Create$1(AOwner);
      return this;
    };
    this.CreateNew$1 = function (AFileName) {
      this.FCreating = true;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.FFormFileName = AFileName;
      if (this.FFormFileName !== "") $mod.Application.LoadForm(this,AFileName);
      return this;
    };
    this.CreateNew$2 = function () {
      var AFileName = "";
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName(false);
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.FFormFileName = AFileName;
      if (this.FFormFileName !== "") $mod.Application.LoadForm(this,AFileName);
      return this;
    };
    this.CreateNew$3 = function (AProc) {
      this.FCreatedProc = AProc;
      this.CreateNew$2();
      return this;
    };
    this.CreateNew$4 = function (AElementID, AProc) {
      this.CreateNew$5(AElementID,"",AProc);
      return this;
    };
    this.CreateNew$5 = function (AElementID, AFileName, AProc) {
      this.FCreating = true;
      this.FFormContainer = AElementID;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,AElementID);
      this.FCreatedProc = AProc;
      this.FFormElement = AElementID;
      if (AFileName === "") AFileName = this.$class.GetHTMLFileName(false);
      if (AFileName !== "") {
        $mod.Application.LoadForm(this,AFileName)}
       else if (this.FCreatedProc != null) this.FCreatedProc(this);
      return this;
    };
    this.CreateNewDirect = function (AElementID, AProc) {
      this.FCreating = true;
      this.FFormContainer = AElementID;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,AElementID);
      this.FCreatedProc = AProc;
      this.FFormElement = AElementID;
      this.Init();
      this.LoadDFMValues();
      if (this.FCreatedProc != null) this.FCreatedProc(this);
      return this;
    };
    this.CreateDialog = function (ACaption) {
      var AFileName = "";
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName(false);
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.SetCaption(ACaption);
      this.FPopup = true;
      this.SetBorder($mod.TFormBorderStyle.fbDialog);
      this.FFormFileName = AFileName;
      $mod.Application.LoadForm(this,AFileName);
      return this;
    };
    this.CreateDialogNew = function (ACaption) {
      var AFileName = "";
      this.FNoHTML = true;
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName(false);
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.SetCaption(ACaption);
      this.FPopup = true;
      this.SetPosition($mod.TPosition.poScreenCenter);
      this.SetBorder($mod.TFormBorderStyle.fbDialog);
      this.FFormFileName = AFileName;
      return this;
    };
    this.Load = function () {
      var $Self = this;
      var Result = null;
      this.FShown = false;
      this.FFormFileName = this.$class.GetHTMLFileName(this.FDirectForm);
      this.Loading();
      if (this.FFormFileName === "") {
        this.Init();
        this.LoadDFMValues();
        Result = new Promise(function (ASuccess, AFailed) {
          ASuccess($Self);
        });
      } else {
        Result = new Promise(function (ASuccess, AFailed) {
          $mod.Application.LoadForm$1($Self,$Self.FFormFileName,function (AForm) {
            ASuccess(AForm);
          });
        });
      };
      return Result;
    };
    this.Execute = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowModal$1(function (AValue) {
          ASuccess(AValue);
        });
      });
      return Result;
    };
    this.LoadAndExecute = function () {
      var $Self = this;
      var Result = null;
      async function LoadAsync() {
        var Result = false;
        Result = await $Self.Load();
        return Result;
      };
      LoadAsync();
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowModal$1(function (AValue) {
          ASuccess(AValue);
        });
      });
      return Result;
    };
    this.Destroy = function () {
      if (this.FVisible) this.Close();
      if (this.FOnDestroy != null) this.FOnDestroy(this);
      pas["WEBLib.Controls"].TControl.Destroy.call(this);
      if (this.FLayer$1 != null) {
        if (this.FormContainerElement() === this.FLayer$1.parentNode) this.FormContainerElement().removeChild(this.FLayer$1);
        this.FLayer$1 = null;
      };
    };
    this.Close = function () {
      var lAction = 0;
      var el = null;
      if (this.CloseQuery()) {
        this.UnbindEvents();
        lAction = this.FDefaultCloseAction;
        if (this.FTimerID !== -1) {
          window.clearInterval(this.FTimerID);
          this.FTimerID = -1;
        };
        if (this.FOnClose != null) this.FOnClose(this,{get: function () {
            return lAction;
          }, set: function (v) {
            lAction = v;
          }});
        if (lAction !== $mod.TCloseAction.caNone) {
          if (this.FLayer$1 != null) {
            if (this.GetContainer().parentNode === this.FLayer$1) {
              this.FLayer$1.removeChild(this.GetContainer());
            } else {
              if (this.GetContainer().parentNode.parentNode === this.FLayer$1) this.FLayer$1.removeChild(this.GetContainer().parentNode);
            };
            this.FContainer = null;
            if (this.FormContainerElement() === this.FLayer$1.parentNode) {
              this.FormContainerElement().removeChild(this.FLayer$1);
              $mod.Application.ChangeMaxZIndex(-1);
            };
            this.FLayer$1 = null;
          };
          if (this.FFormFileName === "") {
            if ((this.FFormElement !== "") && (this.GetContainer() != null)) {
              this.GetContainer().innerHTML = "";
              this.FContainer = null;
            } else if (this.GetContainer() != null) {
              if (this.FormContainerElement() === this.GetContainer().parentNode) this.FormContainerElement().removeChild(this.GetContainer());
              this.FContainer = null;
            };
          } else {
            if (this.FFormElement !== "") {
              this.GetContainer().innerHTML = "";
              this.FContainer = null;
            };
          };
          if ((this.FFormElement !== this.FFormContainer) && (this.FFormElement !== "")) {
            el = document.getElementById(this.FFormElement);
            if (el != null) el.innerHTML = "";
          };
          this.DoClose({get: function () {
              return lAction;
            }, set: function (v) {
              lAction = v;
            }});
          if ((lAction === $mod.TCloseAction.caFree) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
            this.SetVisible(false);
            $impl.ReleaseForm(this);
            if ($mod.Application.FMainForm === this) $mod.Application.FMainForm = null;
          };
          $mod.Application.FActiveForm = this.FPrevActiveForm;
          this.FShown = false;
          this.SetVisible(false);
        };
      };
    };
    this.GetUniqueComponentName = function (AComponent) {
      var Result = "";
      var s = "";
      var i = 0;
      var j = 0;
      var found = false;
      i = 1;
      do {
        found = false;
        s = pas.System.Copy(this.$classname,2,this.$classname.length) + "_" + pas.System.Copy(AComponent.$classname,2,AComponent.$classname.length) + pas.SysUtils.IntToStr(i);
        i += 1;
        for (var $l = 0, $end = this.GetComponentCount() - 1; $l <= $end; $l++) {
          j = $l;
          if (this.GetComponent(j).FName === s) {
            found = true;
            break;
          };
        };
      } while (!(found === false));
      Result = s;
      return Result;
    };
    this.IsMiletus = function () {
      var Result = false;
      var cl = null;
      cl = this.$class.ClassType();
      Result = false;
      do {
        cl = cl.$ancestor;
        if ((cl != null) && (cl.$classname === "TMiletusForm")) {
          Result = true;
          break;
        };
      } while (!(!(cl != null) || (cl.$classname === "TForm")));
      return Result;
    };
    this.PreventDefault$1 = function () {
      this.GetElementEvent().preventDefault();
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.Resize$1();
        this.SetBoundsInt(X,Y,AWidth,AHeight);
      } else pas["WEBLib.Controls"].TControl.SetBounds.call(this,X,Y,AWidth,AHeight);
    };
    this.SelectFirst = function () {
      if (this.GetControlsCount() > 0) this.GetControls(0).SetFocus();
    };
    this.SelectNext = function (CurControl, GoForward, CheckTabStop) {
      var i = 0;
      if (this.GetControlsCount() > 0) {
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.GetControls(i) === CurControl) {
            if (GoForward) {
              if ((i + 1) <= (this.GetControlsCount() - 1)) {
                this.GetControls(i + 1).SetFocus()}
               else this.GetControls(0).SetFocus();
            } else {
              if ((i - 1) >= 0) {
                this.GetControls(i - 1).SetFocus()}
               else this.GetControls(this.GetControlsCount() - 1).SetFocus();
            };
            break;
          };
        };
      };
    };
    this.Show$1 = function () {
      var dr = null;
      var el = null;
      if (this.FCreating && this.FPopup) {
        $mod.Application.ChangeMaxZIndex(+1);
        this.FCreating = false;
        this.UpdateElement();
      };
      if (this.FFormFileName === "") {
        if (!(this.GetContainer() != null)) {
          if (this.FPopup) {
            this.FContainer = this.CreateElement();
            this.FPopupElement = this.GetContainer();
            this.SetFormPos();
            this.UpdateElement();
            this.FLayer$1.appendChild(this.GetContainer());
          } else {
            this.FContainer = this.CreateLayer();
            this.GetContainer().style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
            document.body.appendChild(this.GetContainer());
          };
        } else {
          if ((this.FElementClassName !== "") && this.FDirectForm) {
            el = document.createElement("DIV");
            el.setAttribute("class",this.FElementClassName);
            el.appendChild(this.GetContainer());
            this.FContainer = el;
          };
          if (this.FPopup) {
            this.SetFormPos();
            this.FLayer$1.appendChild(this.GetContainer());
          } else {
            if (this.FLayer$1 != null) {
              this.FLayer$1.appendChild(this.GetContainer());
            } else {
              document.body.appendChild(this.GetContainer());
            };
          };
        };
        if (this.FPopup) {
          if (this.FPopupOpacity < 1) {
            this.FLayer$1.style.setProperty(pas["WEBLib.Controls"].CSSBackground,"rgb(0,0,0," + pas["WEBLib.WebTools"].DoubleToHTML(this.FPopupOpacity) + ")");
          };
          if (this.FBorder === $mod.TFormBorderStyle.fbSizeable) {
            dr = this.GetContainer().getBoundingClientRect();
            this.FOrigWidth = Math.round(dr.right - dr.left);
            this.FOrigHeight = Math.round(dr.bottom - dr.top);
            this.FTimerID = window.setInterval(rtl.createSafeCallback(this,"HandleDoResize"),100);
          } else {
            this.GetContainer().style.setProperty("resize","");
            this.GetContainer().style.setProperty("overflow","");
          };
        };
      };
      this.SetVisible(true);
      this.DoShow();
    };
    this.ShowModal = function () {
      var Result = 0;
      Result = this.ShowModal$1(null);
      return Result;
    };
    this.ShowModal$1 = function (AProc) {
      var Result = 0;
      if (this.FNoHTML || (this.FFormFileName === "")) {
        this.FPrevActiveForm = $mod.Application.FActiveForm;
        $mod.Application.FActiveForm = this;
        if (!this.FCreated) $mod.Application.CreateNewForm(this,"");
      };
      Result = 0;
      this.FNoHTML = false;
      this.FModalProc = AProc;
      this.SetModalResult(0);
      this.Show$1();
      return Result;
    };
    this.AddCSS = function (id, css) {
      function writeStylesOnce(styleName, cssText) {
          var styleElement = document.getElementById(styleName);
          if (styleElement) {
               styleElement.innerHTML = cssText;
            return;
            }
          styleElement = document.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          document.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      writeStylesOnce(id,css);
    };
    this.RemoveCSS = function (id) {
      var el = null;
      el = document.getElementById(id);
      if (el != null) document.head.removeChild(el);
    };
    this.UpdateCSS = function (id, css) {
      this.RemoveCSS(id);
      this.AddCSS(id,css);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TForm");
  this.$rtti.$ClassRef("TFormClass",{instancetype: this.$rtti["TForm"]});
  rtl.createClass(this,"TForm",this.TCustomForm,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("CSSLibrary",2,pas["WEBLib.Controls"].$rtti["TCSSLibrary"],"FCSSLibrary","SetCSSLibrary",4,{Default: pas["WEBLib.Controls"].TCSSLibrary.cssNone});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("FormContainer",2,pas["WEBLib.Controls"].$rtti["TElementID"],"FFormContainer","SetFormContainer");
    $r.addProperty("FormStyle",3,$mod.$rtti["TFormStyle"],"GetFormStyle","SetFormStyle");
    $r.addProperty("Menu",0,pas["WEBLib.Controls"].$rtti["TCustomControl"],"FMenu","FMenu");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("Shadow",2,rtl.boolean,"FShadow","SetShadow",4,{Default: true});
    $r.addProperty("ShowClose",0,rtl.boolean,"FShowClose","FShowClose",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("OnBeforeUnload",0,$mod.$rtti["TBeforeUnloadEvent"],"FOnBeforeUnload","FOnBeforeUnload");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnClose",0,$mod.$rtti["TCloseEvent"],"FOnClose","FOnClose");
    $r.addProperty("OnCloseQuery",0,$mod.$rtti["TCloseQueryEvent"],"FOnCloseQuery","FOnCloseQuery");
    $r.addProperty("OnCreate",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnCreate","FOnCreate");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDeactivate",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDeactivate","FOnDeactivate");
    $r.addProperty("OnDestroy",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDestroy","FOnDestroy");
    $r.addProperty("OnDOMContentLoaded",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDOMContentLoaded","FOnDOMContentLoaded");
    $r.addProperty("OnHashChange",0,$mod.$rtti["THashChangeEvent"],"FOnHashChange","FOnHashChange");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnShow",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnShow","FOnShow");
    $r.addProperty("OnScroll",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnScroll","FOnScroll");
    $r.addProperty("OnOrientationChange",0,$mod.$rtti["TOrientationChangeEvent"],"FOnOrientationChange","FOnOrientationChange");
    $r.addProperty("OnPaint",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPaint","FOnPaint");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnUnload",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnUnload","FOnUnload");
  });
  this.$rtti.$ClassRef("TWebFormClass",{instancetype: this.$rtti["TForm"]});
  rtl.createClass(this,"TCustomFrame",pas["WEBLib.Controls"].TCustomHTMLDiv,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomHTMLDiv.$init.call(this);
      this.FAutoScroll = false;
      this.FAutoSize = false;
      this.FBiDiMode$1 = 0;
      this.FConstraints = null;
      this.FCtl3D$1 = false;
      this.FDockSite = false;
      this.FDragCursor = 0;
      this.FDragKind = 0;
      this.FDragMode$1 = 0;
      this.FOnAlignInsertBefore = null;
      this.FOnAlignPosition = null;
      this.FOnCanResize = null;
      this.FOnConstrainedResize = null;
      this.FOnContextPopup = null;
      this.FOnDockDrop = null;
      this.FOnDockOver = null;
      this.FOnEndDock = null;
      this.FOnGesture = null;
      this.FOnGetSiteInfo = null;
      this.FOnMouseActivate = null;
      this.FOnMouseWheelDown$1 = null;
      this.FOnMouseWheelUp$1 = null;
      this.FOnStartDock = null;
      this.FOnUnDock = null;
      this.FPadding = null;
      this.FParentBackground = false;
      this.FParentCtl3D$1 = false;
      this.FPopupMenu = null;
      this.FStyleElements = {};
    };
    this.$final = function () {
      this.FConstraints = undefined;
      this.FOnAlignInsertBefore = undefined;
      this.FOnAlignPosition = undefined;
      this.FOnCanResize = undefined;
      this.FOnConstrainedResize = undefined;
      this.FOnContextPopup = undefined;
      this.FOnDockDrop = undefined;
      this.FOnDockOver = undefined;
      this.FOnEndDock = undefined;
      this.FOnGesture = undefined;
      this.FOnGetSiteInfo = undefined;
      this.FOnMouseActivate = undefined;
      this.FOnMouseWheelDown$1 = undefined;
      this.FOnMouseWheelUp$1 = undefined;
      this.FOnStartDock = undefined;
      this.FOnUnDock = undefined;
      this.FPadding = undefined;
      this.FPopupMenu = undefined;
      this.FStyleElements = undefined;
      pas["WEBLib.Controls"].TCustomHTMLDiv.$final.call(this);
    };
    var cMethodGet = "GET";
    var cTypeLoad = "load";
    var cHeaderCacheControl = "Cache-Control";
    var cValueNoCache = "no-cache";
    this.LoadHTMLFile = function (AId) {
      var $Self = this;
      var lFileName = "";
      var lRequest = null;
      function DoStatusCreate(AEvent) {
        var Result = false;
        var lElement = null;
        var lResponse = "";
        if (AEvent === null) return false;
        lResponse = AEvent.target.responseText;
        lElement = document.getElementById(AId);
        lElement.innerHTML = lResponse;
        Result = true;
        return Result;
      };
      lFileName = this.$class.GetHTMLFileName();
      if (lFileName !== "") {
        lRequest = new XMLHttpRequest();
        lRequest.addEventListener(cTypeLoad,rtl.createSafeCallback(null,DoStatusCreate));
        lRequest.open(cMethodGet,lFileName);
        lRequest.setRequestHeader(cHeaderCacheControl,cValueNoCache);
        lRequest.send();
      };
    };
    this.SetConstraints = function (AValue) {
      this.FConstraints.Assign(AValue);
    };
    this.SetPopupMenu = function (AValue) {
      this.FPopupMenu = AValue;
    };
    this.SetPadding = function (AValue) {
      this.FPadding.Assign(AValue);
    };
    this.GetHTMLFileName = function () {
      var Result = "";
      Result = this.$module.$name + $mod.Application.GetFormExtension();
      return Result;
    };
    this.LoadDFMValues = function () {
    };
    this.UpdateElement = function () {
      var nocolor = false;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      nocolor = this.FColor in rtl.createSet(15790320,-1,16777215,16711422);
      if ((this.GetElementHandle() != null) && !this.IsUpdating() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && nocolor) {
        this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(0xF0F0F0));
      };
    };
    this.Create$2 = function (AId) {
      pas["WEBLib.Controls"].TControl.Create$2.call(this,AId);
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      this.LoadHTMLFile(AId);
      return this;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.call(this,AOwner);
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      this.FConstraints = $mod.TSizeConstraints.$create("Create$1",[this]);
      return this;
    };
    this.CreateNew = function (AOwner) {
      this.Create$1(AOwner);
      this.BeforeLoadDFMValues();
      try {
        this.LoadFromForm();
      } finally {
        this.AfterLoadDFMValues();
      };
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FConstraints");
      rtl.free(this,"FPadding");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.LoadFromForm = function () {
      this.LoadDFMValues();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TFrame");
  this.$rtti.$ClassRef("TFrameClass",{instancetype: this.$rtti["TFrame"]});
  rtl.createClass(this,"TFrame",this.TCustomFrame,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoScroll",0,rtl.boolean,"FAutoScroll","FAutoScroll",4,{Default: false});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize",4,{Default: false});
    $r.addProperty("BiDiMode",4,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode$1","FBiDiMode$1");
    $r.addProperty("Constraints",2,$mod.$rtti["TSizeConstraints"],"FConstraints","SetConstraints");
    $r.addProperty("DockSite",0,rtl.boolean,"FDockSite","FDockSite",4,{Default: false});
    $r.addProperty("DoubleBuffered",0,rtl.boolean,"FDoubleBuffered","FDoubleBuffered",4,{Default: false});
    $r.addProperty("DragCursor",0,pas["WEBLib.Controls"].$rtti["TCursor"],"FDragCursor","FDragCursor",4,{Default: 12});
    $r.addProperty("DragKind",0,pas["WEBLib.Controls"].$rtti["TDragKind"],"FDragKind","FDragKind",4,{Default: pas["WEBLib.Controls"].TDragKind.dkDrag});
    $r.addProperty("DragMode",0,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode$1","FDragMode$1",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Ctl3D",4,rtl.boolean,"FCtl3D$1","FCtl3D$1");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("ParentBackground",0,rtl.boolean,"FParentBackground","FParentBackground",4,{Default: true});
    $r.addProperty("ParentBiDiMode",0,rtl.boolean,"FParentBiDiMode","FParentBiDiMode",4,{Default: true});
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",4,{Default: false});
    $r.addProperty("ParentCtl3D",0,rtl.boolean,"FParentCtl3D$1","FParentCtl3D$1",4,{Default: true});
    $r.addProperty("ParentDoubleBuffered",0,rtl.boolean,"FParentDoubleBuffered","FParentDoubleBuffered",4,{Default: true});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ParentShowHint",0,rtl.boolean,"FParentShowHint","FParentShowHint");
    $r.addProperty("PopupMenu",2,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","SetPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("OnAlignInsertBefore",0,$mod.$rtti["TAlignInsertBeforeEvent"],"FOnAlignInsertBefore","FOnAlignInsertBefore");
    $r.addProperty("OnAlignPosition",0,$mod.$rtti["TAlignPositionEvent"],"FOnAlignPosition","FOnAlignPosition");
    $r.addProperty("OnCanResize",0,$mod.$rtti["TCanResizeEvent"],"FOnCanResize","FOnCanResize");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnConstrainedResize",0,$mod.$rtti["TConstrainedResizeEvent"],"FOnConstrainedResize","FOnConstrainedResize");
    $r.addProperty("OnContextPopup",0,$mod.$rtti["TContextPopupEvent"],"FOnContextPopup","FOnContextPopup");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDockDrop",0,$mod.$rtti["TDockDropEvent"],"FOnDockDrop","FOnDockDrop");
    $r.addProperty("OnDockOver",0,$mod.$rtti["TDockOverEvent"],"FOnDockOver","FOnDockOver");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDock",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FOnEndDock","FOnEndDock");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnGesture",0,$mod.$rtti["TGestureEvent"],"FOnGesture","FOnGesture");
    $r.addProperty("OnGetSiteInfo",0,$mod.$rtti["TGetSiteInfoEvent"],"FOnGetSiteInfo","FOnGetSiteInfo");
    $r.addProperty("OnMouseActivate",0,$mod.$rtti["TMouseActivateEvent"],"FOnMouseActivate","FOnMouseActivate");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnMouseWheelDown",0,$mod.$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelDown$1","FOnMouseWheelDown$1");
    $r.addProperty("OnMouseWheelUp",0,$mod.$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelUp$1","FOnMouseWheelUp$1");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnStartDock",0,$mod.$rtti["TStartDockEvent"],"FOnStartDock","FOnStartDock");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnUnDock",0,$mod.$rtti["TUnDockEvent"],"FOnUnDock","FOnUnDock");
  });
  rtl.recNewT(this,"TApplicationError",function () {
    this.AMessage = "";
    this.AFile = "";
    this.ALineNumber = 0;
    this.AColNumber = 0;
    this.AStack = "";
    this.AError = null;
    this.$eq = function (b) {
      return (this.AMessage === b.AMessage) && (this.AFile === b.AFile) && (this.ALineNumber === b.ALineNumber) && (this.AColNumber === b.AColNumber) && (this.AStack === b.AStack) && (this.AError === b.AError);
    };
    this.$assign = function (s) {
      this.AMessage = s.AMessage;
      this.AFile = s.AFile;
      this.ALineNumber = s.ALineNumber;
      this.AColNumber = s.AColNumber;
      this.AStack = s.AStack;
      this.AError = s.AError;
      return this;
    };
    var $r = $mod.$rtti.$Record("TApplicationError",{},this);
    $r.addField("AMessage",rtl.string);
    $r.addField("AFile",rtl.string);
    $r.addField("ALineNumber",rtl.longint);
    $r.addField("AColNumber",rtl.longint);
    $r.addField("AStack",rtl.string);
    $r.addField("AError",pas.JS.$rtti["TJSObject"]);
  });
  this.THintPosition = {"0": "hpLeft", hpLeft: 0, "1": "hpTop", hpTop: 1, "2": "hpRight", hpRight: 2, "3": "hpBottom", hpBottom: 3};
  this.$rtti.$Enum("THintPosition",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.THintPosition});
  this.TOnlineStatus = {"0": "osOnline", osOnline: 0, "1": "osOffline", osOffline: 1};
  this.$rtti.$Enum("TOnlineStatus",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TOnlineStatus});
  this.$rtti.$MethodVar("TApplicationErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AError",this.$rtti["TApplicationError"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationHashChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AHash",rtl.string],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationOnlineChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AStatus",this.$rtti["TOnlineStatus"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationActiveChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Active",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationCallBackEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AQuery",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationExceptionEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["E",pas.SysUtils.$rtti["Exception"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationPopStateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["State",rtl.jsvalue]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationAutoCreateFormEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AInstanceClass",this.$rtti["TFormClass"]],["AReference",null,1]]), methodkind: 0});
  rtl.createClass(this,"TApplication",pas["WEBLib.Controls"].TControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TControl.$init.call(this);
      this.FAppContainer = "";
      this.FMainFormOnTaskBar = false;
      this.FCanCreateForm = false;
      this.FAppInitializing = false;
      this.FLastReq = null;
      this.FFormCaptionHeight = 0;
      this.FActiveForm = null;
      this.FMainForm = null;
      this.FLoadForm = null;
      this.FInitFormClassName = "";
      this.FFormStack = null;
      this.FParameters = null;
      this.FIsRedirect = false;
      this.FLanguage = 0;
      this.FOnImageCacheReady = null;
      this.FOnError = null;
      this.FOnHashChange = null;
      this.FAutoFormRoute = false;
      this.FErrorType = 0;
      this.FClientConnector = null;
      this.FOnOnlineChange = null;
      this.FOnActivate = null;
      this.FThemeTextColor = 0;
      this.FThemeColor = 0;
      this.FThemed = false;
      this.FThemeButtonClassName = "";
      this.FOnOAuthToken = null;
      this.FOnOAuthCallBack = null;
      this.FOnFontCacheReady = null;
      this.FOnPopState = null;
      this.FMaxZIndex = 0;
      this.FCreatedProc = null;
      this.FHandleOAuth = false;
      this.FHintPause = 0;
      this.FHintHidePause = 0;
      this.FHintPosition = 0;
      this.FHintClassName = "";
      this.FOnExit$1 = null;
      this.FOnException = null;
      this.FOnAutoCreateForm = null;
      this.FRouting = false;
      this.FSBW = 0;
    };
    this.$final = function () {
      this.FLastReq = undefined;
      this.FActiveForm = undefined;
      this.FMainForm = undefined;
      this.FLoadForm = undefined;
      this.FFormStack = undefined;
      this.FParameters = undefined;
      this.FOnImageCacheReady = undefined;
      this.FOnError = undefined;
      this.FOnHashChange = undefined;
      this.FClientConnector = undefined;
      this.FOnOnlineChange = undefined;
      this.FOnActivate = undefined;
      this.FOnOAuthToken = undefined;
      this.FOnOAuthCallBack = undefined;
      this.FOnFontCacheReady = undefined;
      this.FOnPopState = undefined;
      this.FCreatedProc = undefined;
      this.FOnExit$1 = undefined;
      this.FOnException = undefined;
      this.FOnAutoCreateForm = undefined;
      pas["WEBLib.Controls"].TControl.$final.call(this);
    };
    this.DoFormLoad = function (Event) {
      var Result = false;
      var LResponse = "";
      LResponse = Event.target.responseText;
      this.CreateNewForm(this.FLoadForm,LResponse);
      if (this.FCreatedProc != null) {
        this.FCreatedProc(this);
        this.FCreatedProc = null;
      };
      Result = true;
      return Result;
    };
    this.DoFormAbort = function (Event) {
      var Result = false;
      pas["WEBLib.Dialogs"].ShowMessage("Failed to load form HTML template file");
      Result = true;
      return Result;
    };
    this.DoHandleError = function (Event) {
      var Result = false;
      var err = $mod.TApplicationError.$new();
      var el = null;
      var sp = null;
      var x = null;
      var msg = "";
      var pmsg = "";
      var pstack = "";
      var s = "";
      var isError = false;
      var isPromise = false;
      var jserror = undefined;
      var ex = null;
      isError = true;
      isPromise = false;
      jserror = null;
      err.AFile = "";
      err.ALineNumber = 0;
      err.AColNumber = 0;
      err.AError = null;
      if (Event.message == undefined) {
        isError = false;
        if (Event instanceof PromiseRejectionEvent)
        {
          isError = true;
          isPromise = true;
          pmsg = Event.reason.FMessage;
          pstack = Event.reason.FStack;
          jserror = Event.reason;
        }
      };
      if (!isPromise && (Event.message === "ResizeObserver loop limit exceeded")) return Result;
      if (!isPromise && (Event.message === "ResizeObserver loop completed with undelivered notifications.")) return Result;
      if (!isError) {
        err.AMessage = "Undefined JavaScript exception";
        err.AFile = "";
        err.ALineNumber = 0;
        err.AColNumber = 0;
        err.AError = null;
        if (this.FOnError != null) this.FOnError(this,$mod.TApplicationError.$clone(err),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
        return Result;
      };
      if (isPromise) {
        err.AMessage = pmsg;
        err.AStack = pstack;
        err.AError = jserror;
      } else {
        err.AMessage = Event.message;
        err.AFile = Event.filename;
        err.ALineNumber = Event.lineno;
        err.AColNumber = Event.colno;
        err.AError = Event.error;
        err.AStack = "";
      };
      s = "";
      if (Event.error != null) {
        if (Event.error.stack) {
          err.AStack = Event.error.stack;
        }
        if (Event.error.fMessage) {
          err.AMessage = Event.error.fMessage;
        };
        function objToString (obj) {
              var str = '';
              for (var p in obj) {
                  if (obj.hasOwnProperty(p)) {
                      str += p + '::' + obj[p] + '\n';
                  }
              }
              return str;
              }
        
              // detect if it was an RTL exception
              if (Event.error.hasOwnProperty('FJSError'))
              {
                jserror = Event.error['FJSError'];
              }
        
              s = objToString(Event.error);
      };
      if (pas.System.Assigned(jserror)) {
        ex = err.AError; //Event.error;
        if (this.FOnException != null) this.FOnException(this,ex);
      };
      Result = false;
      msg = "ERROR<br>" + err.AMessage + " | " + s + err.AStack + "<BR> at " + err.AFile + " [" + pas.SysUtils.IntToStr(err.ALineNumber) + ":" + pas.SysUtils.IntToStr(err.AColNumber) + "]";
      var $tmp = this.FErrorType;
      if ($tmp === $mod.TApplicationErrorType.aeFooter) {
        el = document.getElementById("tmserrormessage");
        if (el != null) {
          rtl.asExt(el.firstChild,HTMLElement).innerHTML = msg;
        } else {
          el = document.createElement("DIV");
          el.setAttribute("id","tmserrormessage");
          el.style.setProperty("position","absolute");
          el.style.setProperty("font-family","Courier");
          el.style.setProperty("font-size","8pt");
          el.style.setProperty("bottom","0");
          el.style.setProperty("width","100%");
          el.style.setProperty("height","100px");
          el.style.setProperty("background","#ff0000");
          el.style.setProperty("color","#ffffff");
          document.body.style.setProperty("padding","0");
          document.body.style.setProperty("margin","0");
          sp = document.createElement("SPAN");
          sp.style.setProperty("margin-left","4px");
          sp.style.setProperty("float","left");
          sp.style.setProperty("overflow","hidden");
          sp.style.setProperty("display","block");
          sp.innerHTML = msg;
          el.appendChild(sp);
          x = document.createElement("SPAN");
          x.style.setProperty("font-family","Courier");
          x.style.setProperty("font-size","8pt");
          x.style.setProperty("font-weight","bold");
          x.style.setProperty("position","absolute");
          x.style.setProperty("width","20px");
          x.style.setProperty("vertical-align","top");
          x.style.setProperty("cursor","pointer");
          x.style.setProperty("text-align","right");
          x.style.setProperty("right","4px");
          x.style.setProperty("display","block");
          x.innerHTML = "X";
          x.onclick = rtl.createSafeCallback(this,"DoErrorClose");
          el.appendChild(x);
          document.body.appendChild(el);
        };
      } else if ($tmp === $mod.TApplicationErrorType.aeAlert) {
        window.alert(msg)}
       else if ($tmp === $mod.TApplicationErrorType.aeDialog) {
        this.AddControlLink("googlematerial","https://fonts.googleapis.com/icon?family=Material+Icons");
        pas["WEBLib.Dialogs"].MessageDlg(msg,pas["WEBLib.Dialogs"].TMsgDlgType.mtError,rtl.createSet(pas["WEBLib.Dialogs"].TMsgDlgBtn.mbOK),null);
      };
      if (this.FOnError != null) this.FOnError(this,$mod.TApplicationError.$clone(err),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DoHandleExit = function (Event) {
      var Result = false;
      Result = true;
      if (this.FOnExit$1 != null) this.FOnExit$1(this);
      return Result;
    };
    this.DoHashChange = function (Event) {
      var Result = false;
      var s = "";
      var fc = null;
      var frm = null;
      var bdy = null;
      var Handled = false;
      Result = true;
      if (!this.FAutoFormRoute) return Result;
      s  = location.hash;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Handled = false;
      if (this.FOnHashChange != null) this.FOnHashChange(this,s,{get: function () {
          return Handled;
        }, set: function (v) {
          Handled = v;
        }});
      if (Handled) return Result;
      if (s === "") s = this.FInitFormClassName;
      if (s !== "") {
        if (this.FInitFormClassName === "") this.FInitFormClassName = this.FActiveForm.$classname;
        fc = pas.Classes.GetClass(s);
        if (fc != null) {
          bdy = document.body;
          this.CreateForm$6(fc,bdy,{get: function () {
              return frm;
            }, set: function (v) {
              frm = v;
            }});
        };
      };
      return Result;
    };
    this.DoPopState = function (Event) {
      var Result = false;
      if (this.FOnPopState != null) this.FOnPopState(this,Event.state);
      Result = true;
      return Result;
    };
    this.DoErrorClose = function (Event) {
      var Result = false;
      document.body.removeChild(Event.target.parentElement);
      Result = true;
      return Result;
    };
    this.DoUpdateOnlineStatus = function (Event) {
      var Result = false;
      Result = true;
      if (this.FOnOnlineChange != null) {
        if (window.navigator.onLine) {
          this.FOnOnlineChange(this,$mod.TOnlineStatus.osOnline)}
         else this.FOnOnlineChange(this,$mod.TOnlineStatus.osOffline);
      };
      return Result;
    };
    this.DoVisibilityChange = function (Event) {
      var Result = false;
      var res = false;
      Result = true;
      res = document.visibilityState === "visible";
      if (this.FOnActivate != null) this.FOnActivate(this,res);
      return Result;
    };
    this.SetLanguage = function (Value) {
      this.FLanguage = Value;
    };
    this.GetIsOnline = function () {
      var Result = false;
      Result = window.navigator.onLine;
      return Result;
    };
    this.GetIsMobile = function () {
      var Result = false;
      var mob = false;
      function TestMobile() {
            var check = false;
           (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
           return check;
           };
      
          mob = TestMobile();
      Result = mob;
      return Result;
    };
    this.GetIsPWA = function () {
      var Result = false;
      var pwa = false;
      pwa = ('standalone' in window.navigator) && (window.navigator.standalone);
      Result = pwa;
      return Result;
    };
    this.InternalDownloadFile = function (AData, AFileName, AType, ANewTab) {
      var lElement = document.createElement('a');
      var lBlob = new Blob([AData], {type: AType})
      var lUrl = window.URL.createObjectURL(lBlob);
      lElement.href = lUrl;
      if (AFileName != ''){
        lElement.setAttribute('download', AFileName);
      }
      lElement.style.display = 'none';
      if (ANewTab == true) {
        lElement.target = '_blank';
      }
      document.body.appendChild(lElement);
      lElement.click();
      document.body.removeChild(lElement);
    };
    this.CreateNewForm = function (AForm, HTML) {
      var eh = null;
      var op = null;
      var span = null;
      var childspan = null;
      var formspan = null;
      var l = 0;
      var t = 0;
      var w = 0;
      var h = 0;
      var LCreatedProc = null;
      var LCaptionDiv = null;
      var LCaptionHeight = 0;
      var ro = null;
      if (this.FMainForm === null) this.FMainForm = AForm;
      span = null;
      formspan = null;
      LCaptionHeight = 0;
      if (!AForm.FPopup && (AForm.FFormElement !== "")) {
        AForm.FLayer$1 = null;
        eh = document.getElementById(AForm.FFormElement);
        if (eh != null) {
          eh.innerHTML = HTML;
          if ((AForm.FElementClassName === "") && (AForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssNone)) eh.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(AForm.FColor));
        };
      } else {
        AForm.ClearControls();
        AForm.FLayer$1 = AForm.CreateLayer();
        document.body.appendChild(AForm.FLayer$1);
        eh = AForm.FLayer$1;
        if (AForm.FPopup && (AForm.FPopupOpacity < 1)) {
          op = AForm.CreateLayer();
          op.style.setProperty(pas["WEBLib.Controls"].CSSBackground,"rgb(0,0,0," + pas["WEBLib.WebTools"].DoubleToHTML(AForm.FPopupOpacity) + ")");
          op.style.setProperty(pas["WEBLib.Controls"].CSSZIndex,$mod.Application.MaxZIndexStr());
          eh.appendChild(op);
        };
        $mod.Application.ChangeMaxZIndex(+1);
        span = document.createElement("DIV");
        span.style.setProperty(pas["WEBLib.Controls"].CSSZIndex,$mod.Application.MaxZIndexStr());
        AForm.FPopupElement = span;
        if (AForm.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
          span.style.setProperty("resize","both");
          span.style.setProperty("overflow","auto");
          ro = null;
          try
          {
          var frm = AForm;
          ro = new ResizeObserver( function(entries)  {
             window.requestAnimationFrame(() => {
                if (!Array.isArray(entries) || !entries.length) {
                  return;
                }
             entries.forEach( function(entry) {
               frm.HandleObserver();
               });
               } );
          });
            // Observe the scrollingElement for when the window gets resized
            ro.observe(span);
          }
          catch(err)
          {
            span.style.removeProperty('resize');
            span.style.removeProperty('overflow');
          };
          AForm.FResizeObserver = ro;
        };
        if (AForm.FElementClassName !== "") span.setAttribute("class",AForm.FElementClassName);
        if (AForm.FShadow && AForm.FPopup) span.style.setProperty("box-shadow","3px 3px 3px silver");
        eh.appendChild(span);
        AForm.GetMethodPointers();
        if (AForm.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
          LCaptionDiv = AForm.CreateCaption();
          span.appendChild(LCaptionDiv);
          childspan = document.createElement("DIV");
          childspan.style.setProperty("position","absolute");
          childspan.style.setProperty("width","100%");
          childspan.setAttribute("id","childspan");
          span.appendChild(childspan);
          formspan = childspan;
          LCaptionHeight = $mod.Application.FFormCaptionHeight;
        } else {
          formspan = span;
        };
        formspan.innerHTML = HTML;
        AForm.FContainer = formspan;
      };
      AForm.Init();
      AForm.LoadDFMValues();
      if ((AForm.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) && (AForm.FElementCaptionClassName !== "")) {
        LCaptionDiv.classList.add(AForm.FElementCaptionClassName);
        LCaptionDiv.style.removeProperty("background-color");
        LCaptionDiv.style.removeProperty("color");
      };
      if (AForm.FLayer$1 != null) {
        if (!AForm.FPopup) {
          if (AForm.FElementClassName === "") {
            if (AForm.FColor !== -1) {
              eh.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(AForm.FColor))}
             else eh.style.setProperty(pas["WEBLib.Controls"].CSSBackground,"white");
          } else eh.setAttribute("class",AForm.FElementClassName);
          if ((AForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (AForm.FElementClassName === "")) {
            eh.setAttribute("class","card");
            eh.style.removeProperty("background-color");
            eh.style.setProperty("display","block");
          };
        };
      };
      if ((span != null) && (AForm.FFormContainer === "") && AForm.FPopup && (AForm.FPosition === $mod.TPosition.poScreenCenter)) {
        span.style.setProperty("position","absolute");
        l = Math.max(0,Math.round(($mod.WinWidth() - AForm.GetWidth()) / 2)) + window.scrollX;
        t = Math.max(0,Math.round(($mod.WinHeight() - AForm.GetHeight()) / 2)) + window.scrollY;
        w = AForm.GetWidth();
        h = AForm.GetClientHeight() + LCaptionHeight;
        AForm.FTop = t;
        AForm.FLeft = l;
        AForm.SetWidthInt(w);
        AForm.SetHeightInt(h);
        if ((AForm.FElementClassName === "") && (AForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssNone)) {
          span.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(AForm.FColor));
          span.style.setProperty("border","1px Black solid");
        };
        span.style.setProperty("top",pas.SysUtils.IntToStr(t) + "px");
        span.style.setProperty("left",pas.SysUtils.IntToStr(l) + "px");
        span.style.setProperty("width",pas.SysUtils.IntToStr(w) + "px");
        span.style.setProperty("height",pas.SysUtils.IntToStr(h) + "px");
      };
      if (formspan != null) this.ActivateChildScripts(formspan);
      if (AForm.FOnCreate != null) AForm.FOnCreate(AForm);
      if (AForm.FCreatedProc != null) {
        LCreatedProc = AForm.FCreatedProc;
        AForm.FCreatedProc = null;
        LCreatedProc(AForm);
      };
      AForm.Loaded();
      AForm.InitAnchoring();
      AForm.UpdateChildAnchoring();
      AForm.FCreating = false;
      AForm.UpdateElement();
      if (!AForm.EventsBound()) AForm.BindEvents();
      AForm.Resize$1();
      AForm.DoShow();
    };
    this.GetFormExtension = function () {
      var Result = "";
      if (this.FLanguage !== pas["WEBLib.Lang"].TUILanguage.lNone) {
        Result = "_" + pas["WEBLib.Lang"].GetLanguageISO639_1Code(this.FLanguage) + pas["WEBLib.WebTools"].cHTMLExt}
       else Result = pas["WEBLib.WebTools"].cHTMLExt;
      return Result;
    };
    var sExternalBrowserAuthorizationOK = '<div class="text2">Application succesfully authorized</div>You can close this browser window';
    var sExternalBrowserAuthorizationFailed = '<div class="text2">Application authorization failed</div><br/>Please try again.';
    var LB = "\r\n";
    var ImageFail = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeA" + "AAACXBIWXMAAA7DAAAOwwHHb6hkAAABtElEQVR4nO2bUY7CMAxEhz0NB+EgrDjXCg6yB+E4+9NKCAiN" + "7XHcjf1+ED+Z6ahNHScFiqIoBNwvp+v9crpG+3hG6+sgFQFwXv7ejj+/31JBDyy+ugN4ElkJD8Hqqyu" + "AhohYjA3D12YAGyIiMSYsXx8D6BTpFmPB9NUMQCjSJcaA7ettAEqRTTErHr5eAjCKfBSz4OXryzhgiz" + "OzWCJd/Fs8HoFHzHeCtxf2JNgt3MMID8zXoMpAtDarEDIbidJklMJUQ6MDty6GNDSNRdxtluWwhReDU" + "fONKADAx2jkZCsOAOAaXn4pY2let6oAAN/qTIG61lAHAOwmBFO1aQoACA/BXGqbAwDCQqCsOCkBAMND" + "oC23aQEAw0Kg9hqoAQDuIdAbLfQAALcQXFptLgEA9BDc+oxeLbF/Qz0C7AFTT4KpX4OpC6HUpXDqxVD" + "q5fBOLn5lbEMkdUssdVM0dVs89cZI6q2x1JujqbfHUx+Q2MPFj/LidUqsKajB05NXS4y6Zl/GurHGe6" + "QOSpLF5jgqqxSb67C0UGzO4/KdYnN/MLEhluOTmYZY+MWvDPU122dzRVHk5g+X6Lw5aVkK9AAAAABJRU5ErkJggg==";
    var ImageSuccess = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaX" + "HeAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACC0lEQVR4nO2Zv3GDMBSHv+QyQEbICM4EOW+Q9BS4o2QTU" + "9LZBQNkg6zgETyCR0iRkOMIAv3Xk0+/zsiI931nI3iCkpKSkpKSkpKSkpJ7SDN0x2bo3nW//xCymNhp" + "hu4E1MAN2PdVe9k6524ETODHXIHXvmpva+c9BqwpWhbgAV6Ar61zsxeggB+z+x1XJmsBG/Bj6mboWtV" + "gtvcATfhpPvqq/ZwfzFKABTwoVobsBFjCj7kyWxmyugc4wsPCypCNAA/wY/L7C3iEP/dVe5geEC8gJD" + "wIFxAaHgQLiAEPQgXEggeBAmLCgzABseFBkIAU8CBEQCp4ECAgJTwYChibCzYXWpmv9jCVFTwYCJgVa" + "31BxXwucapFS4CiWOsLS4EHDQEbxRoXIAkeNgRoFqtdiDR4WBFgWOxmQRLhQdEQsSi2bobuqBqUCg8L" + "vwDHYg991Z49zjeNd3iYCfBU7J8E6fAAT7PPOw9znpqhA3hDODz8F7Dnp2vqKmJ1O8ogQeFh+R7wjB8" + "JrgkOD4plUICEKPCw/hyQSkI0eNh+EowtISo86L0LxJIQHR703wZDS0gCD2b9gFASksGDeUfIt4Sk8G" + "DRE/QoITk8WDZFPUgQAQ8OXWEHCWLgwbEtbiFBFDx42BcwkCAOHjxtjGhIEAkPHneGViSIhQfPW2MLE" + "kTDQ4C9wYmEi3T4kpKSkm+5ax+YhPsUTQAAAABJRU5ErkJggg==";
    var PlaceHolderImage = "#PLACEHOLDERIMAGE#";
    var PlaceHolderText = "#PLACEHOLDERTEXT#";
    var PlaceHolderColor = "#PLACEHOLDERCOLOR#";
    var AuthHTMLTemplate = "<!doctype html>" + LB + '<html lang="en">' + LB + "<head>" + LB + "  <title>Authentication Result</title>" + LB + '  <meta name="viewport" content="width=device-width, initial-scale=1">' + LB + "</head>" + LB + "<body>" + LB + "<style>" + LB + "  hr" + LB + "  {" + LB + "    border: none;" + LB + "    height: 1px;" + LB + "    background-color: rgb(171, 171, 171);" + LB + "  }" + LB + "  div.container" + LB + "  {" + LB + "    position: fixed;" + LB + "    font-family: Arial;" + LB + "    font-size: 12pt;" + LB + "    max-width: 100%;" + LB + "    max-height: 100%;" + LB + "    top: 50%;" + LB + "    left: 50%;" + LB + "    transform: translate(-50%, -50%);" + LB + "  }" + LB + "  div.section" + LB + "  {" + LB + "    display: inline-block;" + LB + "    margin: 15px;" + LB + "    padding: 5px;" + LB + "    float: left;" + LB + "  }" + LB + "  div.image img" + LB + "  {" + LB + "    height: 100%;" + LB + "  }" + LB + "  div.text" + LB + "  {" + LB + "    padding-top: 15px;" + LB + "  }" + LB + "  div.text2" + LB + "  {" + LB + "    font-size: 18pt;" + LB + "    color: #PLACEHOLDERCOLOR#;" + LB + "  }" + LB + "  span.title" + LB + "  {" + LB + "    font-size: 26px;" + LB + "  }" + LB + "</style>" + LB + '  <div class="container">' + LB + '  <div class="section image">' + LB + '    <img src="#PLACEHOLDERIMAGE#">' + LB + "  </div>" + LB + '  <div class="section text">' + LB + "  #PLACEHOLDERTEXT#" + LB + "  </div>" + LB + "  </div>" + LB + " </body>" + LB + "</html>";
    this.GetAuthorizationPageHTML = function (AAuthorizationSuccess) {
      var $Self = this;
      var Result = "";
      function ReplacePlaceHolders(APlaceHolders, APlaceHolderValues) {
        var Result = "";
        var I = 0;
        var s = "";
        s = AuthHTMLTemplate;
        for (var $l = 0, $end = rtl.length(APlaceHolders) - 1; $l <= $end; $l++) {
          I = $l;
          s = pas.SysUtils.StringReplace(s,APlaceHolders[I],APlaceHolderValues[I],rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        };
        Result = s;
        return Result;
      };
      if (AAuthorizationSuccess) {
        Result = ReplacePlaceHolders([PlaceHolderImage,PlaceHolderText,PlaceHolderColor],[ImageSuccess,sExternalBrowserAuthorizationOK,"rgb(104, 164, 144)"])}
       else Result = ReplacePlaceHolders([PlaceHolderImage,PlaceHolderText,PlaceHolderColor],[ImageFail,sExternalBrowserAuthorizationFailed,"rgb(216, 99, 68)"]);
      return Result;
    };
    this.GetColorScheme = function () {
      var Result = 0;
      Result = $mod.TApplicationColorScheme.csNoScheme;
      if (window.matchMedia("(prefers-color-scheme)").media !== "not all") {
        if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
          Result = $mod.TApplicationColorScheme.csDark}
         else Result = $mod.TApplicationColorScheme.csLight;
      };
      return Result;
    };
    this.GetActive = function () {
      var Result = false;
      Result = !document.hidden;
      return Result;
    };
    this.GetBootstrapVersion = function () {
      var Result = 0;
      var bv = "";
      bv = "";
      if (typeof bootstrap !== 'undefined') {
        bv = bootstrap.Tooltip.VERSION;
      };
      Result = $mod.TBootstrapVersion.bv3;
      if (pas.System.Pos("4.",bv) === 1) {
        Result = $mod.TBootstrapVersion.bv4}
       else if (pas.System.Pos("5.",bv) === 1) Result = $mod.TBootstrapVersion.bv5;
      return Result;
    };
    this.ReloadForm = function () {
      var $Self = this;
      var lFileName = "";
      function DoStatusCreate(Event) {
        var Result = false;
        var i = 0;
        var ctl = null;
        var s = "";
        var sl = null;
        var response = "";
        response = Event.target.responseText;
        sl = pas.Classes.TStringList.$create("Create$1");
        for (var $l = $Self.FActiveForm.GetControlsCount() - 1; $l >= 0; $l--) {
          i = $l;
          ctl = $Self.FActiveForm.GetControls(i);
          s = ctl.SaveState();
          ctl.GetElementHandle().id = ctl.FName;
          s = ctl.FName + "=" + s;
          sl.Add(s);
        };
        for (var $l1 = $Self.FActiveForm.GetControlsCount() - 1; $l1 >= 0; $l1--) {
          i = $l1;
          ctl = $Self.FActiveForm.GetControls(i);
          $Self.FActiveForm.RemoveComponent(ctl);
          ctl = rtl.freeLoc(ctl);
        };
        $Self.FActiveForm.ClearControls();
        $Self.FActiveForm.UnbindEvents();
        document.body.innerHTML = response;
        $Self.FActiveForm.CreateControl();
        $Self.FActiveForm.DoCreate();
        $Self.FActiveForm.Init();
        for (var $l2 = $Self.FActiveForm.GetControlsCount() - 1; $l2 >= 0; $l2--) {
          i = $l2;
          ctl = $Self.FActiveForm.GetControls(i);
          s = sl.GetValue(ctl.FName);
          if (s !== "") ctl.LoadState(s);
        };
        sl = rtl.freeLoc(sl);
        $Self.FActiveForm.DoShow();
        Result = true;
        return Result;
      };
      lFileName = this.FActiveForm.$class.GetHTMLFileName(false);
      this.FLastReq = new XMLHttpRequest();
      this.FLastReq.addEventListener("load",rtl.createSafeCallback(null,DoStatusCreate));
      this.FLastReq.open("GET",lFileName);
      this.FLastReq.setRequestHeader("Cache-Control","no-cache");
      this.FLastReq.send();
    };
    this.ActivateChildScripts = function (AElement) {
      function nodeScriptReplace(node) {
                  if ( nodeScriptIs(node) === true ) {
                          node.parentNode.replaceChild( nodeScriptClone(node) , node );
                  }
                  else {
                          var i        = 0;
                          var children = node.childNodes;
                          while ( i < children.length ) {
                                  nodeScriptReplace( children[i++] );
                          }
                  }
      
                  return node;
          }
          function nodeScriptIs(node) {
                  return node.tagName === 'SCRIPT';
          }
          function nodeScriptClone(node){
                  var script  = document.createElement("script");
                  script.async = false;
                  script.text = node.innerHTML;
                  for( var i = node.attributes.length-1; i >= 0; i-- ) {
                          script.setAttribute( node.attributes[i].name, node.attributes[i].value );
                  }
                  return script;
          }
          nodeScriptReplace(AElement);
    };
    this.ChangeMaxZIndex = function (Delta) {
      this.FMaxZIndex = this.FMaxZIndex + Delta;
    };
    this.TriggerNotification = function () {
    };
    this.AutoCreateForm = function (AInstanceClass, AReference) {
      if (this.FOnAutoCreateForm != null) {
        this.FOnAutoCreateForm(this,AInstanceClass,AReference)}
       else this.CreateForm(AInstanceClass,AReference);
    };
    this.SetHash = function (AValue) {
      window.location.hash = AValue;
    };
    this.GetHash = function () {
      var Result = "";
      var s = "";
      s = window.location.hash;
      if ((s.length > 0) && (s.charAt(0) === "#")) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Result = s;
      return Result;
    };
    this.PushForm = function (AForm) {
      var i = 0;
      for (var $l = 0, $end = AForm.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        AForm.GetControls(i).PersistinHTML();
      };
      AForm.FFormContent = document.body.innerHTML;
      for (var $l1 = 0, $end1 = AForm.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        AForm.GetControls(i).DisableTab();
      };
      this.FFormStack.Add(AForm);
    };
    this.PopForm = function () {
      var Result = null;
      var i = 0;
      var frm = "";
      if (this.FFormStack.GetCount() > 0) {
        Result = rtl.getObject(this.FFormStack.Get(this.FFormStack.GetCount() - 1));
        frm = Result.FFormContent;
        this.FFormStack.Delete(this.FFormStack.GetCount() - 1);
        document.body.innerHTML = frm;
        Result.InitFromHTML();
        Result.BindEvents();
        for (var $l = 0, $end = Result.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          Result.GetControls(i).HookElement();
        };
        for (var $l1 = 0, $end1 = Result.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          Result.GetControls(i).RecreateCanvas();
          Result.GetControls(i).InternalResize();
        };
        $mod.Application.FActiveForm = Result;
      };
      return Result;
    };
    this.LockForm = function (AForm) {
      var i = 0;
      for (var $l = 0, $end = AForm.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        AForm.GetControls(i).DisableTab();
      };
    };
    this.UnLockForm = function (AForm) {
      var i = 0;
      for (var $l = 0, $end = AForm.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        AForm.GetControls(i).EnableTab();
      };
    };
    this.Create$1 = function (AOwner) {
      this.FFormStack = pas.Classes.TList.$create("Create$1");
      this.FParameters = pas.Classes.TStringList.$create("Create$1");
      this.FAppContainer = pas["WEBLib.WebTools"].cBodyTag;
      this.FMainForm = null;
      this.FActiveForm = null;
      this.FInitFormClassName = "";
      this.FIsRedirect = false;
      this.FAutoFormRoute = false;
      this.FThemed = false;
      this.FThemeColor = 14917120;
      this.FThemeTextColor = 16777215;
      this.FFormCaptionHeight = 22;
      this.FMaxZIndex = 998;
      this.FHandleOAuth = true;
      this.FHintPause = 200;
      this.FHintHidePause = 250;
      this.FHintPosition = $mod.THintPosition.hpTop;
      this.FHintClassName = "";
      this.FSBW = -1;
      window.addEventListener("error",rtl.createCallback(this,"DoHandleError"));
      window.addEventListener("unhandledrejection",rtl.createCallback(this,"DoHandleError"));
      window.addEventListener("beforeunload",rtl.createSafeCallback(this,"DoHandleExit"));
      this.FErrorType = $mod.TApplicationErrorType.aeSilent;
      this.FErrorType = $mod.TApplicationErrorType.aeFooter;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFormStack");
      rtl.free(this,"FParameters");
      pas["WEBLib.Controls"].TControl.Destroy.call(this);
    };
    this.MaxZIndexStr = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.FMaxZIndex);
      return Result;
    };
    this.IsPWAInstalled = function () {
      var $Self = this;
      var Result = null;
      var b = false;
      var s = "";
      b = false;
      s = window.location.hostname;
      Result = new Promise(async function (ASuccess, AFailed) {
        if ('getInstalledRelatedApps' in window.navigator) {
         const relatedApps = await navigator.getInstalledRelatedApps();
         relatedApps.forEach((app) => {
            if (app.id.indexOf(s) >= 0)
            {
              b = true;
            }
         });
        };
        ASuccess(b);
      });
      return Result;
    };
    this.CalcScrollBarWidth = function () {
      var Result = 0;
      var res = 0;
      if (this.FSBW !== -1) {
        Result = this.FSBW;
        return Result;
      };
      function getScrollbarWidth() {
            // Create a temporary div element
            const div = document.createElement('div');
      
            // Apply styles to force a scrollbar
            div.style.overflow = 'scroll';
            div.style.position = 'absolute';
            div.style.top = '-9999px'; // Move it off-screen
            div.style.width = '100px';
            div.style.height = '100px';
      
            // Append the div to the body
            document.body.appendChild(div);
      
            // Calculate the scrollbar width
            const scrollbarWidth = div.offsetWidth - div.clientWidth;
      
            // Remove the temporary element
            document.body.removeChild(div);
      
            res = scrollbarWidth;
          }
          getScrollbarWidth();
      this.FSBW = res;
      Result = this.FSBW;
      return Result;
    };
    this.GoBack = function () {
      window.history.back();
    };
    this.CreateNewForm$1 = function (AInstanceClass) {
      var Result = null;
      if (!($mod.VSIDE != null)) {
        Result = AInstanceClass.$create("Create$2",[pas["WEBLib.WebTools"].cBodyTag])}
       else Result = AInstanceClass.$create("Create$2",[""]);
      return Result;
    };
    this.CreateNewForm$2 = function (AInstanceClass, AElementID) {
      var Result = null;
      var el = null;
      var AForm = null;
      el = document.getElementById(AElementID);
      AForm = AInstanceClass.$create("Create$2",[AElementID]);
      AForm.FDesignContainer = el;
      AForm.SetFormContainer(AElementID);
      AForm.FFormElement = AElementID;
      AForm.CreateControl();
      AForm.FContainer = el;
      AForm.Init();
      Result = AForm;
      return Result;
    };
    this.CreateForm = function (AInstanceClass, AReference) {
      this.CreateForm$2(AInstanceClass,this.FAppContainer,AReference,null);
    };
    this.CreateForm$1 = function (AInstanceClass, AElementID, AReference) {
      this.CreateForm$2(AInstanceClass,AElementID,AReference,null);
    };
    this.CreateForm$2 = function (AInstanceClass, AElementID, AReference, AProc) {
      this.CreateForm$3(AInstanceClass,AElementID,AReference,AProc,true);
    };
    this.CreateForm$3 = function (AInstanceClass, AElementID, AReference, AProc, LoadHTML) {
      var $Self = this;
      var LFileName = "";
      function DoStatusCreate(Event) {
        var Result = false;
        var LElem = null;
        var LForm = null;
        var LResponse = "";
        var LIsBody = false;
        var LisLoaded = false;
        LisLoaded = Event != null;
        if (LisLoaded) {
          LResponse = Event.target.responseText;
          LIsBody = pas.SysUtils.LowerCase(AElementID) === pas["WEBLib.WebTools"].cBodyTag;
          if (LIsBody) {
            LElem = document.body}
           else LElem = document.getElementById(AElementID);
          LElem.innerHTML = LResponse;
        } else {
          LElem = document.body;
        };
        LForm = AInstanceClass.$create("Create$5",[AElementID,AReference]);
        LForm.FFormFileName = LFileName;
        if (LForm.FFormContainer === "") LForm.SetFormContainer(AElementID);
        if (!LIsBody) {
          LForm.FFormElement = AElementID;
          LForm.FContainer = LElem;
        };
        LForm.CreateControl();
        LForm.Init();
        LForm.SetColorScheme($mod.Application.GetColorScheme());
        LForm.FPrevActiveForm = $Self.FActiveForm;
        $Self.FActiveForm = LForm;
        if ($Self.FMainForm === null) $Self.FMainForm = LForm;
        if (AProc != null) AProc(LForm);
        Result = true;
        if (LisLoaded) $Self.ActivateChildScripts(LElem);
        $Self.FActiveForm.DoShow();
        $Self.FActiveForm.Resize$1();
        return Result;
      };
      if (this.FIsRedirect) return;
      if (this.FAppInitializing) {
        if (this.FCanCreateForm) {
          this.FCanCreateForm = false}
         else return;
      };
      LFileName = AInstanceClass.GetHTMLFileName(false);
      if ((LFileName !== "") && LoadHTML) {
        this.FLastReq = new XMLHttpRequest();
        this.FLastReq.addEventListener("load",rtl.createSafeCallback(null,DoStatusCreate));
        this.FLastReq.open("GET",LFileName);
        this.FLastReq.setRequestHeader("Cache-Control","no-cache");
        this.FLastReq.send();
      } else {
        DoStatusCreate(null);
      };
    };
    this.CreateForm$4 = function (AInstanceClass, AReference) {
      var lModule = null;
      lModule = AInstanceClass.$create("Create$1",[this]);
      AReference.set(lModule);
    };
    var cHTMLCode = '<html><head><meta http-equiv="Content-type" content="text/html; ' + 'charset=utf-8" /><title>TMS Web Project</title><style></style></head>' + "<body></body></html>";
    this.CreateForm$5 = function (AInstanceClass, AReference) {
      var lFrame = null;
      var lForm = null;
      lForm = $impl.TFramePreviewForm.$create("Create$1",[$mod.Application]);
      lFrame = AInstanceClass.$create("Create$1",[lForm]);
      lForm.FFrame = lFrame;
      lForm.FPopup = false;
      AReference.set(lFrame);
      $mod.Application.FActiveForm = lForm;
      $mod.Application.CreateNewForm(lForm,cHTMLCode);
    };
    this.CreateForm$6 = function (AInstanceClass, AElement, AReference) {
      this.CreateForm$2(AInstanceClass,AElement.id,AReference,null);
    };
    this.CreateFormDirect = function (AInstanceClass, AReference) {
      this.CreateForm$3(AInstanceClass,this.FAppContainer,AReference,null,false);
    };
    this.CreateFormDirect$1 = function (AInstanceClass, AElementID, AReference) {
      this.CreateForm$3(AInstanceClass,AElementID,AReference,null,false);
    };
    this.CreateFormDirect$2 = function (AInstanceClass, AReference) {
      this.CreateForm$4(AInstanceClass,AReference);
    };
    this.CreateFormDirect$3 = function (AInstanceClass, AReference) {
      this.CreateForm$5(AInstanceClass,AReference);
    };
    this.LoadForm = function (AForm, AFormFile) {
      AForm.FPrevActiveForm = this.FActiveForm;
      this.FActiveForm = AForm;
      this.FLoadForm = AForm;
      if (this.FMainForm === null) this.FMainForm = AForm;
      this.FLastReq = new XMLHttpRequest();
      this.FLastReq.addEventListener("load",rtl.createSafeCallback(this,"DoFormLoad"));
      this.FLastReq.addEventListener("abort",rtl.createSafeCallback(this,"DoFormAbort"));
      this.FLastReq.open("GET",AFormFile);
      this.FLastReq.send();
    };
    this.LoadForm$1 = function (AForm, AFormFile, FormLoaded) {
      this.FCreatedProc = FormLoaded;
      this.LoadForm(AForm,AFormFile);
    };
    this.ChangeCSS = function (id, href) {
      var styleElement = document.getElementById(id);
      if (styleElement) {
        styleElement.href = href;
        return;
      };
    };
    this.InsertCSS = function (id, href) {
      var styleElement = null;
      styleElement = document.getElementById(id);
      if (styleElement != null) {
        styleElement.href = href;
        return;
      };
      styleElement = document.createElement("link");
      styleElement.id = id;
      styleElement.rel = 'stylesheet';
      styleElement.href = href;
      document.getElementsByTagName("head").item(0).appendChild(styleElement);
    };
    this.RemoveCSS = function (id) {
      var styleElement = null;
      styleElement = document.getElementById(id);
      if (styleElement != null) {
        styleElement.parentNode.removeChild(styleElement);
      };
    };
    this.HasCSS = function (href) {
      var Result = false;
      var els = null;
      var i = 0;
      var s = "";
      Result = false;
      els = document.querySelectorAll("head > link");
      for (var $l = 0, $end = els.length - 1; $l <= $end; $l++) {
        i = $l;
        s = els.item(i).href;
        if (pas.SysUtils.CompareText(s,href) === 0) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.ChangeLanguage = function (Value) {
      this.FLanguage = Value;
      if (this.FMainForm != null) this.ReloadForm();
    };
    this.Initialize = function () {
      var query = "";
      var token = "";
      var p = 0;
      var b = false;
      this.FCanCreateForm = true;
      this.FAppInitializing = true;
      this.FParameters.Clear();
      query = window.location.href;
      this.InitFormatSettings(pas["WEBLib.WebTools"].GetBrowserLocale());
      this.FParameters.SetDelimiter("&");
      this.FParameters.FStrictDelimiter = true;
      p = pas.System.Pos("?",query);
      if (p > 0) query = pas.System.Copy(query,p + 1,query.length);
      this.FParameters.SetDelimitedText(query);
      b = (window.name == "Authentication");
      if (this.FOnOAuthCallBack != null) {
        if ((this.FParameters.IndexOfName("oauthcallback") !== -1) || b) {
          this.FOnOAuthCallBack(this,query);
          this.FIsRedirect = true;
          document.body.innerHTML = this.GetAuthorizationPageHTML(true);
          return;
        };
      };
      if ((this.FParameters.IndexOfName("code") !== -1) && this.FHandleOAuth) {
        if (this.FOnOAuthToken != null) this.FOnOAuthToken(this,query);
        this.FIsRedirect = true;
        token = this.FParameters.GetValue("code");
        if (window.opener && window.opener.processAuthData){
          window.opener.processAuthData(token);
          window.close();
        };
      };
      window.addEventListener("hashchange",rtl.createSafeCallback(this,"DoHashChange"));
      window.addEventListener("online",rtl.createSafeCallback(this,"DoUpdateOnlineStatus"));
      window.addEventListener("offline",rtl.createSafeCallback(this,"DoUpdateOnlineStatus"));
      window.addEventListener("popstate",rtl.createCallback(this,"DoPopState"));
      document.addEventListener("visibilitychange",rtl.createSafeCallback(this,"DoVisibilityChange"));
      if (window.opener !== null) if (this.FParameters.IndexOfName("access_token") !== -1) {
        this.FIsRedirect = true;
        token = this.FParameters.GetValue("access_token");
        if (window.opener && window.opener.processAuthData){
          window.opener.processAuthData(token);
            window.close();
        };
      };
    };
    this.Route = function () {
      var Result = false;
      var frm = null;
      var hash = "";
      var pc = null;
      var i = 0;
      Result = false;
      this.FRouting = true;
      hash = window.location.hash;
      if (hash !== "") {
        hash = rtl.setCharAt(hash,0,"T");
        i = pas.System.Pos("?",hash);
        if (i > 0) hash = rtl.strSetLength(hash,i - 1);
        pc = pas.Classes.GetClass(hash);
        if (pc != null) {
          Result = true;
          $mod.Application.AutoCreateForm(pc,{get: function () {
              return frm;
            }, set: function (v) {
              frm = v;
            }});
        };
      };
      return Result;
    };
    this.InitFormatSettings = function (BrowserLocale) {
      var timestr = "";
      var i = 0;
      var locale = "";
      locale = BrowserLocale;
      pas.SysUtils.FormatSettings.ShortDateFormat = pas["WEBLib.WebTools"].GetLocaleShortDateFormat(locale);
      if (pas.System.Pos("/",pas.SysUtils.FormatSettings.ShortDateFormat) > 0) pas.SysUtils.FormatSettings.DateSeparator = "/";
      if (pas.System.Pos(".",pas.SysUtils.FormatSettings.ShortDateFormat) > 0) pas.SysUtils.FormatSettings.DateSeparator = ".";
      if (pas.System.Pos("-",pas.SysUtils.FormatSettings.ShortDateFormat) > 0) pas.SysUtils.FormatSettings.DateSeparator = "-";
      var event = new Date('Jan 1, 1980 06:07:08 GMT+00:00');
      var loc = "";
      if (locale == "") { loc = navigator.language; } else
      { loc = locale; }
      timestr = event.toLocaleTimeString(loc);
      if (pas.System.Pos(":",timestr) > 0) pas.SysUtils.FormatSettings.TimeSeparator = ":";
      if (pas.System.Pos(".",timestr) > 0) pas.SysUtils.FormatSettings.TimeSeparator = ".";
      if (pas.System.Pos("-",timestr) > 0) pas.SysUtils.FormatSettings.TimeSeparator = "-";
      for (i = 1; i <= 7; i++) {
        pas.SysUtils.FormatSettings.ShortDayNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleShortDayName(i,locale);
        pas.SysUtils.FormatSettings.LongDayNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleLongDayName(i,locale);
      };
      for (i = 1; i <= 12; i++) {
        pas.SysUtils.FormatSettings.ShortMonthNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleShortMonthName(i,locale);
        pas.SysUtils.FormatSettings.LongMonthNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleLongMonthName(i,locale);
      };
      pas.SysUtils.FormatSettings.DecimalSeparator = pas["WEBLib.WebTools"].GetLocaleDecimalSeparator("");
      if (pas.SysUtils.FormatSettings.DecimalSeparator === ".") {
        pas.SysUtils.FormatSettings.ThousandSeparator = ","}
       else pas.SysUtils.FormatSettings.ThousandSeparator = ".";
    };
    this.ReceiveMessageFromClient = function (AMessage) {
      if (this.FClientConnector != null) this.FClientConnector.Receive(AMessage);
    };
    this.RouteForm = function (AParameter) {
      var frm = null;
      var fc = null;
      fc = pas.Classes.GetClass(AParameter);
      $mod.Application.CreateForm(fc,{get: function () {
          return frm;
        }, set: function (v) {
          frm = v;
        }});
    };
    this.Run = function () {
      this.FCanCreateForm = true;
      this.FAppInitializing = false;
    };
    this.RunScript = function (Source) {
      eval(Source);
    };
    this.Terminate = function () {
      window.location.href = "about:blank";
    };
    this.Navigate = function (AURL, ATarget) {
      if (ATarget === $mod.TNavigationTarget.ntBlank) {
        window.open(AURL,"_blank")}
       else window.location.href = AURL;
    };
    this.Download = function (AURL) {
      window.location.href = AURL;
    };
    this.DownloadTextFile = function (AText, AFileName) {
      var element = document.createElement('a');
      element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(AText));
      if (AFileName != ''){
        element.setAttribute('download', AFileName);
      }
      element.style.display = 'none';
      document.body.appendChild(element);
      element.click();
      document.body.removeChild(element);
    };
    this.DownloadBinaryFile = function (AData, AFileName, ANewTab) {
      var lElement = document.createElement('a');
          var lUrl = window.URL.createObjectURL(AData);
          lElement.href = lUrl;
      
          if (AFileName != ''){
            lElement.setAttribute('download', AFileName);
          }
      
          lElement.style.display = 'none';
          if (ANewTab == true) {
            lElement.target = '_blank';
          }
          document.body.appendChild(lElement);
          lElement.click();
          document.body.removeChild(lElement);
    };
    this.DownloadBinaryFile$1 = function (AData, AFileName, ANewTab) {
      this.DownloadBinaryFile$2(Uint8Array.from(AData),AFileName,ANewTab);
    };
    this.DownloadBinaryFile$2 = function (AData, AFileName, ANewTab) {
      this.InternalDownloadFile(AData,AFileName,"octet/stream",ANewTab);
    };
    this.DownloadPDFFile = function (AData, AFileName, ANewTab) {
      this.DownloadPDFFile$1(Uint8Array.from(AData),AFileName,ANewTab);
    };
    this.DownloadPDFFile$1 = function (AData, AFileName, ANewTab) {
      this.InternalDownloadFile(AData,AFileName,"application/pdf",ANewTab);
    };
    this.EXEName = function () {
      var Result = "";
      Result = window.document.location.href;
      return Result;
    };
    this.IDETheme = function () {
      var Result = "";
      var s = "";
      Result = "";
      if (!($mod.VSIDE != null)) return Result;
      s = pas["WEBLib.Forms"].VSIDE.theme;
      Result = s;
      return Result;
    };
    this.IDECSS = function () {
      var Result = "";
      Result = "";
      if (this.IDETheme() === "vscode-light") {
        Result = ".IDECaption { background-color: #F0F0F0 !important; color: #555555 !important; border: 1px solid #DDDDDD !important}" + "\r\n" + ".IDEBkg { background-color: white !important; color: #555555 !important; border: 1px solid #DDDDDD !important}" + "\r\n" + ".IDEButton { background-color: #FAFAFA !important; font-size:10pt; color: #555555 !important; border: 1px solid #DDDDDD !important}" + "\r\n" + ".IDEButton:hover {background-color:#F0F0F0 !important}" + "\r\n" + ".IDEFont {font-size:10pt !important}";
      };
      if (this.IDETheme() === "vscode") {
        Result = ".IDECaption,.IDEButton { background-color: #3F3E43 !important; color: #FFFFFF !important; border: 1px solid #35353A !important}" + "\r\n" + ".IDEBkg { background-color: #2A2A2C !important; color: #A9ACB4 !important; border: 1px solid #35353A !important}" + "\r\n" + ".IDEButton:hover {background-color:#434857 !important}" + "\r\n" + ".IDEFont {font-size:10pt !important}";
      };
      return Result;
    };
    this.Version = function () {
      var Result = "";
      Result = $mod.WEBCOREVERSION;
      return Result;
    };
    this.IDEMessage = function (Msg) {
      pas["WEBLib.Forms"].VSIDE.ShowMessage(Msg);
    };
    this.IDEOpenURL = function (URL) {
      pas["WEBLib.Forms"].VSIDE.Open(URL);
    };
    this.NeedsFormRouting = function () {
      var Result = false;
      var s = "";
      Result = pas["WEBLib.WebTools"].HasQueryParam("form",{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},true);
      if (Result) this.RouteForm(s);
      return Result;
    };
    this.ObjectURL = function (AFile) {
      var Result = "";
      var res = "";
      res = URL.createObjectURL(AFile);
      Result = res;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.GetParentForm = function (AControl) {
    var Result = null;
    var FOwner = null;
    Result = null;
    FOwner = AControl;
    while ((FOwner != null) && !$mod.TCustomForm.isPrototypeOf(FOwner)) {
      if ((FOwner === AControl) && (FOwner.FOwner === null)) {
        FOwner = AControl.FParent}
       else FOwner = FOwner.FOwner;
    };
    if ((FOwner != null) && $mod.TCustomForm.isPrototypeOf(FOwner)) Result = rtl.as(FOwner,$mod.TCustomForm);
    return Result;
  };
  this.Log = function (v) {
    console.log(v);
  };
  this.Log$1 = function (arr) {
    var i = 0;
    var s = "";
    s = "[";
    for (var $l = 0, $end = rtl.length(arr) - 1; $l <= $end; $l++) {
      i = $l;
      function isPrimitive(test) {
              return (test !== Object(test));
            };
      
            if (isPrimitive(arr[i])) {
               var su1 = arr[i].toString();
               if (s != "[") { s = s + ","; }
               s = s + su1;
               }
            else
            {
              console.log(arr[i]);
               if (s != "[") { s = s + ","; }
               s = s + "#object";
            };
    };
    s = s + "]";
    $mod.Log(s);
  };
  this.WinWidth = function () {
    var Result = 0;
    var w = 0;
    if ($mod.VSIDE != null) {
      w = pas["WEBLib.Forms"].VSIDE.clientWidth();
    } else w = window.innerWidth;
    Result = w;
    return Result;
  };
  this.WinHeight = function () {
    var Result = 0;
    var h = 0;
    if ($mod.VSIDE != null) {
      h = pas["WEBLib.Forms"].VSIDE.clientHeight();
    } else h = window.innerHeight;
    Result = h;
    return Result;
  };
  this.Sleep = function (milliseconds) {
    var Result = null;
    Result = new Promise(function (resolve, reject) {
      window.setTimeout(function () {
        resolve(milliseconds);
      },milliseconds);
    });
    return Result;
  };
  this.Application = null;
  this.HandShakeScript = null;
  this.VSIDE = null;
  this.LastHash = "";
  this.FrameCount = 0;
  $mod.$implcode = function () {
    rtl.createClass($impl,"TFramePreviewForm",$mod.TForm,function () {
      this.$init = function () {
        $mod.TForm.$init.call(this);
        this.FFrame = null;
      };
      this.$final = function () {
        this.FFrame = undefined;
        $mod.TForm.$final.call(this);
      };
      this.LoadDFMValues = function () {
        $mod.TCustomForm.LoadDFMValues.call(this);
        this.FFrame.SetParentComponent(this);
        this.FFrame.LoadFromForm();
        this.FFrame.BeforeLoadDFMValues();
        try {
          this.FFrame.SetName("Frame1");
          this.FFrame.SetLeft(0);
          this.FFrame.SetTop(0);
          this.FFrame.SetWidth(640);
          this.FFrame.SetHeight(480);
        } finally {
          this.FFrame.AfterLoadDFMValues();
        };
        this.SetName("Form1" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: $mod, get: function () {
            return this.p.FrameCount;
          }, set: function (v) {
            this.p.FrameCount = v;
          }}));
        $mod.FrameCount += 1;
        this.SetLeft(0);
        this.SetTop(0);
        this.SetWidth(640);
        this.SetHeight(480);
      };
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    $impl.ReleaseForm = function (AForm) {
      AForm = rtl.freeLoc(AForm);
      AForm = null;
    };
  };
  $mod.$init = function () {
    $mod.FrameCount = 0;
    $mod.HandShakeScript = document.createElement("script");
    $mod.HandShakeScript.id = "HandShakeScript";
    $mod.HandShakeScript.type = "text/javascript";
    $mod.HandShakeScript.innerHTML = "var IDE = null;" + "\r\n" + 'var TMSWEBCoreClientIdentifier = "unknown";' + "\r\n" + 'var TMSWEBCoreOAuthCallback = "unknown";' + "\r\n" + "function HandShake(cid){" + "\r\n" + "  TMSWEBCoreClientIdentifier = cid;" + "\r\n" + "}";
    document.body.appendChild($mod.HandShakeScript);
    $mod.Application = $mod.TApplication.$create("Create$1",[null]);
  };
},["WEBLib.Dialogs","WEBLib.WebTools","WEBLib.JSON","WEBLib.Utils","Math"]);
rtl.module("WEBLib.StdCtrls",["System","Classes","WEBLib.Controls","SysUtils","Web","WEBLib.Graphics","Types","WEBLib.WebTools","WEBLib.Forms","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  this.TEditCharCase = {"0": "wecLowerCase", wecLowerCase: 0, "1": "wecNormal", wecNormal: 1, "2": "wecMixedCase", wecMixedCase: 2, "3": "wecUpperCase", wecUpperCase: 3};
  this.$rtti.$Enum("TEditCharCase",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TEditCharCase});
  this.TCheckBoxState = {"0": "cbChecked", cbChecked: 0, "1": "cbGrayed", cbGrayed: 1, "2": "cbUnchecked", cbUnchecked: 2};
  this.$rtti.$Enum("TCheckBoxState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCheckBoxState});
  this.TDateTimeKind = {"0": "dtkDate", dtkDate: 0, "1": "dtkTime", dtkTime: 1};
  this.$rtti.$Enum("TDateTimeKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDateTimeKind});
  this.TEllipsisPosition = {"0": "epEndEllipsis", epEndEllipsis: 0, "1": "epNone", epNone: 1, "2": "epPathEllipsis", epPathEllipsis: 2, "3": "epWordEllipsis", epWordEllipsis: 3};
  this.$rtti.$Enum("TEllipsisPosition",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TEllipsisPosition});
  this.TTextLayout = {"0": "tlTop", tlTop: 0, "1": "tlCenter", tlCenter: 1, "2": "tlBottom", tlBottom: 2};
  this.$rtti.$Enum("TTextLayout",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTextLayout});
  this.TSysLinkType = {"0": "sltID", sltID: 0, "1": "sltURL", sltURL: 1};
  this.$rtti.$Enum("TSysLinkType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TSysLinkType});
  this.TAutoCompletion = {"0": "acOff", acOff: 0, "1": "acHonorificPrefix", acHonorificPrefix: 1, "2": "acGivenName", acGivenName: 2, "3": "acAdditionalName", acAdditionalName: 3, "4": "acFamilyName", acFamilyName: 4, "5": "acHonorificSuffix", acHonorificSuffix: 5, "6": "acNickName", acNickName: 6, "7": "acEmail", acEmail: 7, "8": "acUserName", acUserName: 8, "9": "acNewPassword", acNewPassword: 9, "10": "acCurrentPassword", acCurrentPassword: 10, "11": "acOrganizationTitle", acOrganizationTitle: 11, "12": "acOrganization", acOrganization: 12, "13": "acStreetAddress", acStreetAddress: 13, "14": "acAddressLine1", acAddressLine1: 14, "15": "acAddressLine2", acAddressLine2: 15, "16": "acAddressLine3", acAddressLine3: 16, "17": "acAddressLevel1", acAddressLevel1: 17, "18": "acAddressLevel2", acAddressLevel2: 18, "19": "acAddressLevel3", acAddressLevel3: 19, "20": "acAddressLevel4", acAddressLevel4: 20, "21": "acCountry", acCountry: 21, "22": "acCountryName", acCountryName: 22, "23": "acPostalCode", acPostalCode: 23, "24": "acCCName", acCCName: 24, "25": "acCCGivenName", acCCGivenName: 25, "26": "acCCAdditionalName", acCCAdditionalName: 26, "27": "acCCFamilyName", acCCFamilyName: 27, "28": "acCCNumber", acCCNumber: 28, "29": "acExpiry", acExpiry: 29, "30": "acExpiryMonth", acExpiryMonth: 30, "31": "acExpiryYear", acExpiryYear: 31, "32": "acCSC", acCSC: 32, "33": "acType", acType: 33, "34": "acTransactionCurrency", acTransactionCurrency: 34, "35": "acTransactionAmount", acTransactionAmount: 35, "36": "acLanguage", acLanguage: 36, "37": "acBirthday", acBirthday: 37, "38": "acBirthdayDay", acBirthdayDay: 38, "39": "acBirthDayMonth", acBirthDayMonth: 39, "40": "acBirthDayYear", acBirthDayYear: 40, "41": "acSex", acSex: 41, "42": "acTelephone", acTelephone: 42, "43": "acTelephoneCountryCode", acTelephoneCountryCode: 43, "44": "acTelephoneNational", acTelephoneNational: 44, "45": "acTelephoneAreaCode", acTelephoneAreaCode: 45, "46": "acTelephoneLocal", acTelephoneLocal: 46, "47": "acTelephoneExtension", acTelephoneExtension: 47, "48": "acIMPP", acIMPP: 48, "49": "acURL", acURL: 49, "50": "acPhoto", acPhoto: 50, "51": "acNone", acNone: 51, "52": "acNope", acNope: 52};
  this.$rtti.$Enum("TAutoCompletion",{minvalue: 0, maxvalue: 52, ordtype: 1, enumtype: this.TAutoCompletion});
  this.TEditType = {"0": "weString", weString: 0, "1": "weFloat", weFloat: 1, "2": "weHex", weHex: 2, "3": "weNumeric", weNumeric: 3, "4": "weSignedFloat", weSignedFloat: 4, "5": "weSignedNumeric", weSignedNumeric: 5, "6": "weSearch", weSearch: 6};
  this.$rtti.$Enum("TEditType",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TEditType});
  this.THTMLType = {"0": "tLABELTAG", tLABELTAG: 0, "1": "tSPAN", tSPAN: 1, "2": "tDIV", tDIV: 2, "3": "tH1", tH1: 3, "4": "tH2", tH2: 4, "5": "tH3", tH3: 5, "6": "tH4", tH4: 6, "7": "tH5", tH5: 7, "8": "tH6", tH6: 8, "9": "tP", tP: 9};
  this.$rtti.$Enum("THTMLType",{minvalue: 0, maxvalue: 9, ordtype: 1, enumtype: this.THTMLType});
  this.$rtti.$MethodVar("TLinkClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Link",rtl.string],["LinkType",this.$rtti["TSysLinkType"]]]), methodkind: 0});
  rtl.createClass(this,"TCustomLabel",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FContent = null;
      this.FAutoSize = false;
      this.FEllipsisPosition = 0;
      this.FWordWrap = false;
      this.FAlignment = 0;
      this.FLayout = 0;
      this.FTransparent = false;
      this.FHTMLType = 0;
      this.FFocusControl = null;
      this.FShowAccelChar = false;
      this.FColor$1 = 0;
      this.FHasAccel = false;
      this.FHasHTML = false;
      this.FElementLabelClassName = "";
      this.FOrigWidth = 0;
      this.FOldWidth = 0;
      this.FOldHeight = 0;
      this.FHTML = "";
    };
    this.$final = function () {
      this.FContent = undefined;
      this.FFocusControl = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetLayout = function (Value) {
      if (this.FLayout !== Value) {
        this.FLayout = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElementVisual();
      };
    };
    this.GetContentHandle = function () {
      var Result = null;
      Result = this.FContent;
      return Result;
    };
    this.SetTransparent = function (Value) {
      if (this.FTransparent !== Value) {
        this.FTransparent = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetHTMLType = function (Value) {
      var el = null;
      if (this.FHTMLType !== Value) {
        this.FHTMLType = Value;
        if (this.FHTMLType in rtl.createSet(null,$mod.THTMLType.tH1,$mod.THTMLType.tH6)) this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        if ((this.GetElementHandle() != null) && (this.FContent != null)) {
          el = this.GetElementHandle().firstChild;
          if ((el != null) && (el.getAttribute("data-lbl") === "lbl")) {
            this.GetElementHandle().removeChild(this.FContent);
            this.FContent = this.CreateLabelElement();
            this.GetElementHandle().appendChild(this.FContent);
            this.UpdateElement();
          };
        };
      };
    };
    this.SetColorEx = function (Value) {
      this.FColor$1 = Value;
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FColor$1 !== 16777215)) this.SetTransparent(false);
      this.UpdateElement();
    };
    this.SetElementLabelClassName = function (Value) {
      if (this.FElementLabelClassName !== Value) {
        this.FElementLabelClassName = Value;
        this.UpdateElement();
      };
    };
    this.SetHTML = function (Value) {
      if (this.FHTML !== Value) {
        this.FHTML = Value;
        this.UpdateElementData();
      };
    };
    this.SetWidth = function (AValue) {
      if ((AValue !== -1) && (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.FOrigWidth = AValue;
      pas["WEBLib.Controls"].TControl.SetWidth.apply(this,arguments);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FContent = this.CreateLabelElement();
      Result.appendChild(this.FContent);
      return Result;
    };
    this.CreateLabelElement = function () {
      var Result = null;
      Result = null;
      var $tmp = this.FHTMLType;
      if ($tmp === $mod.THTMLType.tSPAN) {
        Result = document.createElement("SPAN")}
       else if ($tmp === $mod.THTMLType.tDIV) {
        Result = document.createElement("DIV")}
       else if ($tmp === $mod.THTMLType.tH1) {
        Result = document.createElement("H1")}
       else if ($tmp === $mod.THTMLType.tH2) {
        Result = document.createElement("H2")}
       else if ($tmp === $mod.THTMLType.tH3) {
        Result = document.createElement("H3")}
       else if ($tmp === $mod.THTMLType.tH4) {
        Result = document.createElement("H4")}
       else if ($tmp === $mod.THTMLType.tH5) {
        Result = document.createElement("H5")}
       else if ($tmp === $mod.THTMLType.tH6) {
        Result = document.createElement("H6")}
       else if ($tmp === $mod.THTMLType.tLABELTAG) {
        Result = document.createElement("LABEL")}
       else if ($tmp === $mod.THTMLType.tP) Result = document.createElement("P");
      Result.setAttribute("data-lbl","lbl");
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FCaption;
      return Result;
    };
    this.CanShowFocus = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.SetParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
      if (this.FAutoSize && (this.FAlignment !== pas.Classes.TAlignment.taLeftJustify) && (this.FOrigWidth !== -1)) {
        this.SetLeft((this.GetLeft() + this.FOrigWidth) - this.GetWidth());
        this.FOrigWidth = -1;
      };
    };
    this.BindElement = function () {
      this.FContent = this.GetContainer().firstElementChild;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.FShowAccelChar && (this.FFocusControl != null)) this.UpdateElementData();
    };
    this.UpdateAutoSize = function () {
      if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone)) {
        if ((this.GetElementHandle() != null) && pas["WEBLib.WebTools"].ElementVisible(this.GetElementHandle())) {
          this.SetWidth(-1);
          this.SetHeight(-1);
        };
        this.FEllipsisPosition = $mod.TEllipsisPosition.epNone;
      };
    };
    this.UpdateElementData = function () {
      var lTxt = "";
      var acc = "";
      var ml = false;
      var contentelement = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      acc = "";
      lTxt = this.GetDisplayText();
      if (this.FShowAccelChar && (pas.System.Pos("&",lTxt) > 0)) {
        lTxt = pas["WEBLib.WebTools"].ProcessAccelerator(lTxt,{get: function () {
            return acc;
          }, set: function (v) {
            acc = v;
          }})}
       else {
        if (this.FHTML === "") {
          lTxt = pas["WEBLib.WebTools"].HTMLToString(lTxt)}
         else lTxt = this.FHTML;
      };
      ml = false;
      if (pas.System.Pos("\r",lTxt) > 0) {
        ml = true;
        if (pas.System.Pos("\n",lTxt) > 0) lTxt = pas.SysUtils.StringReplace(lTxt,"\n","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
        lTxt = pas.SysUtils.StringReplace(lTxt,"\r","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      } else if (pas.System.Pos("\n",lTxt) > 0) {
        ml = true;
        lTxt = pas.SysUtils.StringReplace(lTxt,"\n","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      };
      if (this.GetIsLinked() && (lTxt === "") && (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      if (this.GetContentHandle() != null) {
        if (this.GetIsLinked()) {
          contentelement = this.GetContentHandle();
          if (this.GetID() !== "") {
            contentelement = document.getElementById(this.GetID());
          };
          if (contentelement != null) {
            if (pas.System.Assigned(this.GetContentHandle().nodeValue)) {
              contentelement.nodeValue = lTxt}
             else if (contentelement.childElementCount === 0) contentelement.innerHTML = lTxt;
          };
        } else {
          if ((this.GetContentHandle().childElementCount > 0) && pas.System.Assigned(this.GetContentHandle().nodeValue) && !this.FHasAccel && !this.FHasHTML && !ml) {
            this.GetContentHandle().nodeValue = lTxt;
          } else {
            this.GetContentHandle().innerHTML = lTxt;
          };
        };
      } else this.GetElementHandle().innerHTML = lTxt;
      this.FHasHTML = pas.System.Pos("</",lTxt) > 0;
      this.FHasAccel = acc !== "";
      if ((acc !== "") && (this.FFocusControl != null)) {
        this.GetContentHandle().setAttribute("accesskey",acc);
        this.GetContentHandle().setAttribute("for",this.FFocusControl.GetID());
      };
    };
    this.UpdateElementVisual = function () {
      var ow = 0;
      var oh = 0;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.IsUpdating()) return;
      if (this.GetElementHandle() != null) {
        oh = Math.round(this.GetElementHandle().offsetHeight);
        ow = Math.round(this.GetElementHandle().offsetWidth);
        if (oh > 0) this.FOldHeight = oh;
        if (ow > 0) this.FOldWidth = ow;
        if (this.FVisible && (!this.FAutoSize || (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone)) && ((this.FAlignment !== pas.Classes.TAlignment.taLeftJustify) || (this.FLayout !== $mod.TTextLayout.tlTop))) this.GetElementHandle().style.setProperty("display","table");
        this.GetElementHandle().setAttribute("zindex","1");
        if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.GetElementHandle().style.setProperty("overflow","")}
         else this.GetElementHandle().style.setProperty("overflow","hidden");
      };
      if (this.GetContentHandle() != null) {
        var $tmp = this.FLayout;
        if ($tmp === $mod.TTextLayout.tlTop) {
          this.GetContentHandle().style.setProperty("vertical-align","top")}
         else if ($tmp === $mod.TTextLayout.tlCenter) {
          this.GetContentHandle().style.setProperty("vertical-align","middle")}
         else if ($tmp === $mod.TTextLayout.tlBottom) this.GetContentHandle().style.setProperty("vertical-align","bottom");
        var $tmp1 = this.FAlignment;
        if ($tmp1 === pas.Classes.TAlignment.taLeftJustify) {
          this.GetContentHandle().style.removeProperty("text-align")}
         else if ($tmp1 === pas.Classes.TAlignment.taCenter) {
          this.GetContentHandle().style.setProperty("text-align","center")}
         else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) this.GetContentHandle().style.setProperty("text-align","right");
        pas["WEBLib.Controls"].SetHTMLElementColor(this.GetElementHandle(),this.FColor$1,this.FTransparent || (this.FColor$1 === -1) || (this.FColor$1 === 16711422));
        pas["WEBLib.Controls"].SetHTMLElementColor(this.GetContentHandle(),this.FColor$1,this.FTransparent || (this.FColor$1 === -1) || (this.FColor$1 === 16711422));
        this.GetContentHandle().style.setProperty("display","table-cell");
        if (this.FElementClassName === "") {
          if (this.FEnabled && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && !this.GetIsLinked()) {
            this.GetContentHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor))}
           else this.GetContentHandle().style.removeProperty("color");
          this.SetElementPointer(this.GetContentHandle(),this.FCursor);
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetContentHandle(),this.FFont,!((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && !this.GetIsLinked()));
        } else {
          this.GetContentHandle().style.removeProperty("color");
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetContentHandle(),this.FFont,true);
        };
        if (this.FElementLabelClassName !== "") {
          this.GetContentHandle().setAttribute("class",this.FElementLabelClassName)}
         else this.GetContentHandle().removeAttribute("class");
        if ((this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) || (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute)) {
          if (this.FEllipsisPosition === $mod.TEllipsisPosition.epNone) {
            this.GetContentHandle().style.setProperty("text-overflow","clip")}
           else this.GetContentHandle().style.setProperty("text-overflow","ellipsis");
        } else this.GetContentHandle().style.removeProperty("text-overflow");
        if (this.FWordWrap) {
          this.GetContentHandle().style.setProperty("white-space","normal")}
         else this.GetContentHandle().style.setProperty("white-space","nowrap");
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
        if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.GetElementHandle().style.removeProperty("width");
          this.GetElementHandle().style.removeProperty("height");
        };
      };
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone) && (this.GetElementHandle() != null)) {
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.GetElementHandle().style.removeProperty("width");
          this.GetElementHandle().style.removeProperty("height");
        };
      };
      if ((this.GetContentHandle() != null) && (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight,pas["WEBLib.Controls"].TAlign.alClient)) && !this.FAutoSize && (this.FLayout in rtl.createSet($mod.TTextLayout.tlCenter,$mod.TTextLayout.tlBottom))) {
        this.GetContentHandle().style.setProperty("height",pas.SysUtils.TIntegerHelper.ToString$1.call({p: this.GetHeight(), get: function () {
            return this.p;
          }, set: function (v) {
            this.p = v;
          }}) + "px");
      };
    };
    this.SetAutoSize = function (AValue) {
      if (this.FAutoSize !== AValue) {
        this.FAutoSize = AValue;
        this.UpdateAutoSize();
        this.UpdateElement();
      };
    };
    this.SetCaption = function (AValue) {
      var dw = 0;
      if (this.FCaption !== AValue) {
        dw = this.GetWidth();
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateAutoSize();
        this.UpdateElement();
        dw = dw - this.GetWidth();
        if (this.FAutoSize && (this.FAlignment !== pas.Classes.TAlignment.taLeftJustify) && (dw !== 0) && (pas["WEBLib.Controls"].TAnchorKind.akRight in this.FAnchors) && !this.IsUpdating()) this.SetLeft(this.GetLeft() + dw);
      };
    };
    this.SetControlCursor = function (Value) {
      pas["WEBLib.Controls"].TControl.SetControlCursor.apply(this,arguments);
      if ((this.FElementClassName === "") && (this.GetContentHandle() != null)) this.SetElementPointer(this.GetContentHandle(),this.FCursor);
    };
    this.SetEllipsisPosition = function (AValue) {
      if (this.FEllipsisPosition !== AValue) {
        this.FEllipsisPosition = AValue;
        if (this.FEllipsisPosition !== $mod.TEllipsisPosition.epNone) this.FAutoSize = false;
        this.UpdateElement();
      };
    };
    this.GetWidth = function () {
      var Result = 0;
      if (this.FAutoSize && (this.GetElementHandle() != null) && (this.FParent != null)) {
        Result = Math.round(this.GetElementHandle().offsetWidth);
        if (Result === 0) Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this);
        if ((Result === 0) && (this.FCaption !== "") && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) Result = this.FOldWidth;
      } else Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this);
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      if (this.FAutoSize && (this.GetElementHandle() != null) && (this.FParent != null)) {
        Result = Math.round(this.GetElementHandle().offsetHeight);
        if (Result === 0) Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this);
        if ((Result === 0) && (this.FCaption !== "") && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) Result = this.FOldHeight;
      } else Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this);
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FAutoSize = true;
      this.FLayout = $mod.TTextLayout.tlTop;
      this.FEllipsisPosition = $mod.TEllipsisPosition.epNone;
      this.FColor$1 = 16777215;
      this.FTransparent = true;
      this.FAlignment = pas.Classes.TAlignment.taLeftJustify;
      this.SetTabStop(false);
      this.FShowAccelChar = true;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TLabel",this.TCustomLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: true});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",4,{Default: 16777215});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EllipsisPosition",2,$mod.$rtti["TEllipsisPosition"],"FEllipsisPosition","SetEllipsisPosition",4,{Default: $mod.TEllipsisPosition.epNone});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementLabelClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","SetElementLabelClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("FocusControl",0,pas["WEBLib.Controls"].$rtti["TWinControl"],"FFocusControl","FFocusControl");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HTML",2,rtl.string,"FHTML","SetHTML");
    $r.addProperty("HTMLType",2,$mod.$rtti["THTMLType"],"FHTMLType","SetHTMLType",4,{Default: $mod.THTMLType.tLABELTAG});
    $r.addProperty("Layout",2,$mod.$rtti["TTextLayout"],"FLayout","SetLayout",4,{Default: $mod.TTextLayout.tlTop});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowAccelChar",0,rtl.boolean,"FShowAccelChar","FShowAccelChar",4,{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",4,{Default: false});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
  });
  rtl.createClass(this,"TWebLabel",this.TLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomInput",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.IsInputControl = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "EDIT";
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("INPUT");
      Result.setAttribute("type",this.GetInputType());
      return Result;
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if ((this.GetContainer() != null) && !this.GetIsLinked()) {
        this.GetContainer().style.setProperty("-moz-box-sizing","border-box");
        this.GetContainer().style.setProperty("-webkit-box-sizing","border-box");
        this.GetContainer().style.setProperty("box-sizing","border-box");
      };
    };
    this.LoadState = function (AState) {
      this.GetElementHandle().value = AState;
    };
    this.SaveState = function () {
      var Result = "";
      Result = this.GetElementHandle().value;
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetShowFocus(true);
      this.FNoUserSelect = false;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomEdit",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FCharCase = 0;
      this.FMaxLength = 0;
      this.FReadOnly = false;
      this.FText = "";
      this.FTextHint = "";
      this.FSelStart = 0;
      this.FAlignment = 0;
      this.FHideSelection = false;
      this.FPasswordChar = "\x00";
      this.FOnChange = null;
      this.FAutoSize = false;
      this.FAutoSelect = false;
      this.FSelLength = 0;
      this.FNumeric = false;
      this.FAutoCompletion = 0;
      this.FEditType = 0;
      this.FRequired = false;
      this.FAutoFocus = false;
      this.FPattern = "";
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
      this.FHandleSearchPtr = null;
      this.FSpellCheck = false;
      this.FRequiredText = "";
      this.FOnSearch = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FOnSearch = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.SetAlignment = function (Value) {
      this.FAlignment = Value;
      this.UpdateElement();
    };
    this.SetHideSelection = function (Value) {
      if (this.FHideSelection !== Value) {
        this.FHideSelection = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoSelect = function (Value) {
      if (this.FAutoSelect !== Value) {
        this.FAutoSelect = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoSize = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateElement();
      };
    };
    this.SetSelLength = function (Value) {
      this.FSelLength = Value;
      this.UpdateElement();
    };
    this.SetSelStart = function (Value) {
      this.FSelStart = Value;
      this.UpdateElement();
    };
    this.SetPasswordChar = function (Value) {
      this.FPasswordChar = Value;
      this.UpdateElement();
    };
    this.SetNumeric = function (Value) {
      this.FNumeric = Value;
      this.UpdateElement();
    };
    this.SetAutoCompletion = function (Value) {
      if (this.FAutoCompletion !== Value) {
        this.FAutoCompletion = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoFocus = function (Value) {
      if (this.FAutoFocus !== Value) {
        this.FAutoFocus = Value;
        this.UpdateElement();
      };
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.SetPattern = function (Value) {
      if (this.FPattern !== Value) {
        this.FPattern = Value;
        this.UpdateElement();
      };
    };
    this.GetSelLength = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionEnd - this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.GetSelStart = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.SetEditType = function (Value) {
      if (this.FEditType !== Value) {
        this.FEditType = Value;
        this.UpdateElement();
      };
    };
    this.GetSelText = function () {
      var Result = "";
      Result = pas.System.Copy(this.GetText(),this.GetSelStart() + 1,this.GetSelLength());
      return Result;
    };
    this.SetSpellCheck = function (Value) {
      if (this.FSpellCheck !== Value) {
        this.FSpellCheck = Value;
        this.UpdateElement();
      };
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.DoHandlePaste = function (Event) {
      var Result = false;
      var s = "";
      var clp = false;
      clp = false;
      var clipboardData = Event.clipboardData || window.clipboardData;
      if (clipboardData) {
      s = clipboardData.getData('Text');
      clp = true;
      };
      if (clp && (!this.CanPaste(s) || !this.Validate(s))) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleCut = function (Event) {
      var Result = false;
      if (!this.CanCut()) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      if (this.FRequiredText !== "") {
        this.GetElementInputHandle().setCustomValidity("");
      };
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementInputHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.DoHandleSearch = function (Event) {
      var Result = false;
      Result = true;
      if (this.FOnSearch != null) this.FOnSearch(this);
      return Result;
    };
    this.IsCustomEditor = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.KeyPress = function (Key) {
      var isValid = false;
      pas["WEBLib.Controls"].TControl.KeyPress.call(this,Key);
      isValid = true;
      var $tmp = this.FEditType;
      if ($tmp === $mod.TEditType.weNumeric) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57)}
       else if ($tmp === $mod.TEditType.weSignedNumeric) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,43,45)}
       else if ($tmp === $mod.TEditType.weFloat) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,44,46)}
       else if ($tmp === $mod.TEditType.weSignedFloat) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,44,46,43,45)}
       else if ($tmp === $mod.TEditType.weHex) isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,null,65,70);
      if (!isValid) Key.set("\x00");
    };
    this.DoEnter = function () {
      var el = null;
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      if (this.FAutoSelect && (this.GetElementInputHandle() != null)) {
        el = this.GetElementInputHandle();
        el.select();
      };
    };
    this.GetInputType = function () {
      var Result = "";
      if (this.FPasswordChar !== "\x00") {
        Result = "PASSWORD"}
       else if (this.FNumeric) {
        Result = "NUMBER"}
       else if (this.FEditType in rtl.createSet($mod.TEditType.weFloat,$mod.TEditType.weNumeric)) {
        Result = "TEL"}
       else if (this.FEditType === $mod.TEditType.weSearch) {
        Result = "SEARCH"}
       else Result = "TEXT";
      return Result;
    };
    this.PersistinHTML = function () {
      this.GetElementInputHandle().setAttribute("value",this.GetText());
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FText;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().value;
      if (this.FCharCase === $mod.TEditCharCase.wecUpperCase) Result = pas.SysUtils.UpperCase(Result);
      if (this.FCharCase === $mod.TEditCharCase.wecLowerCase) Result = pas.SysUtils.LowerCase(Result);
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FText;
      return Result;
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.Validate = function (AValue) {
      var Result = false;
      var i = 0;
      var Key = "\x00";
      var isvalid = false;
      Result = true;
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        i = $l;
        Key = AValue.charAt(i - 1);
        isvalid = true;
        var $tmp = this.FEditType;
        if ($tmp === $mod.TEditType.weNumeric) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57)}
         else if ($tmp === $mod.TEditType.weSignedNumeric) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,43,45)}
         else if ($tmp === $mod.TEditType.weFloat) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,44,46)}
         else if ($tmp === $mod.TEditType.weSignedFloat) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,44,46,43,45)}
         else if ($tmp === $mod.TEditType.weHex) isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,null,65,70);
        if (!isvalid) {
          Result = false;
          break;
        };
      };
      return Result;
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
      this.FHandleSearchPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandlePastePtr = rtl.createCallback(this,"DoHandlePaste");
      this.FHandleCutPtr = rtl.createCallback(this,"DoHandleCut");
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
      this.FHandleSearchPtr = rtl.createCallback(this,"DoHandleSearch");
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().addEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().addEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().addEventListener("invalid",this.FHandleInvalidPtr);
        this.GetElementInputHandle().addEventListener("search",this.FHandleSearchPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().removeEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().removeEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
        this.GetElementInputHandle().removeEventListener("search",this.FHandleSearchPtr);
      };
    };
    this.UpdateElementData = function () {
      var eh = null;
      var ss = 0;
      var sl = 0;
      var isNum = false;
      var doAc = false;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetElementInputHandle() != null) {
        if (!this.GetIsLinked()) {
          var $tmp = this.FCharCase;
          if ($tmp === $mod.TEditCharCase.wecUpperCase) {
            this.GetElementInputHandle().style.setProperty("text-transform","uppercase")}
           else if ($tmp === $mod.TEditCharCase.wecLowerCase) {
            this.GetElementInputHandle().style.setProperty("text-transform","lowercase")}
           else if ($tmp === $mod.TEditCharCase.wecMixedCase) {
            this.GetElementInputHandle().style.setProperty("text-transform","capitalize")}
           else if ($tmp === $mod.TEditCharCase.wecNormal) this.GetElementInputHandle().style.setProperty("text-transform","initial");
        };
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FTextHint !== "") this.GetElementInputHandle().placeholder = this.FTextHint;
        doAc = true;
        if (this.GetIsLinked()) {
          doAc = !this.GetElementInputHandle().hasAttribute("autocomplete");
        };
        if (doAc) {
          if (this.FAutoCompletion === $mod.TAutoCompletion.acNope) {
            this.GetElementInputHandle().setAttribute("autocomplete","nope");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          } else if (this.FAutoCompletion === $mod.TAutoCompletion.acNone) {
            this.GetElementInputHandle().setAttribute("autocomplete","off");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          } else if (this.FAutoCompletion !== $mod.TAutoCompletion.acOff) {
            this.GetElementInputHandle().setAttribute("autocomplete","on");
            if (!this.GetIsLinked()) this.GetElementInputHandle().setAttribute("name",$mod.GetAutoCompletionName(this.FAutoCompletion));
          } else {
            this.GetElementInputHandle().removeAttribute("autocomplete");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          };
        };
        if (!this.GetIsLinked()) {
          this.GetElementInputHandle().setAttribute("type",this.GetInputType());
          this.GetElementInputHandle().setAttribute("role","textbox");
          var $tmp1 = this.FAlignment;
          if ($tmp1 === pas.Classes.TAlignment.taLeftJustify) {
            this.GetElementInputHandle().style.removeProperty("text-align")}
           else if ($tmp1 === pas.Classes.TAlignment.taCenter) {
            this.GetElementInputHandle().style.setProperty("text-align","center")}
           else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) this.GetElementInputHandle().style.setProperty("text-align","right");
        };
        if (this.FRequired) {
          this.GetElementInputHandle().setAttribute("required","")}
         else if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("required");
        if (this.FAutoFocus) {
          this.GetElementInputHandle().setAttribute("autofocus","")}
         else if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("autofocus");
        if (this.FPattern !== "") {
          this.GetElementInputHandle().setAttribute("pattern",this.FPattern)}
         else this.GetElementInputHandle().removeAttribute("pattern");
        if (this.FMaxLength <= 0) {
          this.GetElementInputHandle().removeAttribute("maxLength")}
         else this.GetElementInputHandle().maxLength = this.FMaxLength;
        this.GetElementInputHandle().value = this.GetDisplayText();
        isNum = pas.SysUtils.UpperCase(this.GetInputType()) === "NUMBER";
        if (!this.FSpellCheck) {
          this.GetElementInputHandle().setAttribute("spellcheck","false")}
         else this.GetElementInputHandle().removeAttribute("spellcheck");
        if (!isNum && !this.GetIsLinked() && !this.IsCustomEditor()) {
          ss = this.FSelStart;
          sl = this.FSelStart + this.FSelLength;
          eh = this.GetElementInputHandle();
          setTimeout(function() {
            eh.setSelectionRange(ss, sl);
          }, 1);
        };
      };
    };
    this.UpdateSelection = function () {
      this.FSelStart = this.GetSelStart();
      this.FSelLength = this.GetSelLength();
    };
    this.SetCharCase = function (AValue) {
      if (this.FCharCase !== AValue) {
        this.FCharCase = AValue;
        this.UpdateElement();
      };
    };
    this.SetMaxLength = function (AValue) {
      if (this.FMaxLength !== AValue) {
        this.FMaxLength = AValue;
        this.UpdateElementData();
      };
    };
    this.SetReadOnly = function (AValue) {
      if (this.FReadOnly !== AValue) {
        this.FReadOnly = AValue;
        this.UpdateElement();
      };
    };
    this.SetText = function (AValue) {
      this.FText = AValue;
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().value = this.GetDisplayText();
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
      };
    };
    this.SetTextHint = function (AValue) {
      this.FTextHint = AValue;
      this.UpdateElement();
    };
    this.CanPaste = function (AValue) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CanCut = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FAutoCompletion = $mod.TAutoCompletion.acOff;
      this.FEditType = $mod.TEditType.weString;
      this.FText = "";
      this.FCharCase = $mod.TEditCharCase.wecNormal;
      this.FMaxLength = 0;
      this.FReadOnly = false;
      this.FTextHint = "";
      this.FPasswordChar = "\x00";
      this.FSpellCheck = true;
      this.FAutoSelect = true;
      this.SetHeight(25);
    };
    this.Clear = function () {
      this.SetText("");
    };
    this.ClearSelection = function () {
      var s = "";
      s = this.GetText();
      this.SetText(pas.System.Copy(s,1,this.GetSelStart()) + pas.System.Copy(s,this.GetSelStart() + this.GetSelLength(),s.length));
    };
    this.Change = function () {
      if (this.GetElementHandle() != null) this.FText = this.GetElementInputHandle().value;
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.SelectAll = function () {
      if (this.GetElementInputHandle() != null) this.GetElementInputHandle().select();
    };
    this.CopyToClipboard = function () {
      var s = "";
      s = this.GetText();
      navigator.clipboard.writeText(s);
    };
    this.SetSelection = function (ASelStart, ASelLength) {
      var eh = null;
      this.FSelStart = ASelStart;
      this.FSelLength = ASelLength;
      eh = this.GetElementInputHandle();
      if (eh != null) {
        eh.setSelectionRange(ASelStart, ASelStart + ASelLength);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TEdit",this.TCustomEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,$mod.$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",4,{Default: $mod.TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",4,{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",4,{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("CharCase",2,$mod.$rtti["TEditCharCase"],"FCharCase","SetCharCase",4,{Default: $mod.TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,$mod.$rtti["TEditType"],"FEditType","SetEditType",4,{Default: $mod.TEditType.weString});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",4,{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",4,{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnSearch",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSearch","FOnSearch");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebEdit",this.TEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSpinEdit",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FIncrement = 0;
      this.FMaxValue = 0;
      this.FMinValue = 0;
      this.FValue = 0;
      this.FAutoSize = false;
      this.FOnChange = null;
      this.FReadOnly = false;
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
      this.FRequiredText = "";
      this.FRequired = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.GetValue());
      return Result;
    };
    this.SetText = function (Value) {
      var i = 0;
      i = 0;
      if (pas.SysUtils.TryStrToInt(Value,{get: function () {
          return i;
        }, set: function (v) {
          i = v;
        }})) {
        this.SetValue(i)}
       else this.SetValue(0);
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        this.UpdateElement();
      };
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.KeyPress = function (Key) {
      if (!(Key.get().charCodeAt() in rtl.createSet(null,48,57))) {
        Key.set("\x00");
        this.PreventDefault();
        this.StopPropagation();
      };
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
    };
    this.PersistinHTML = function () {
      this.GetElementInputHandle().setAttribute("value",pas.SysUtils.IntToStr(this.GetValue()));
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "NUMBER";
      return Result;
    };
    this.UpdateElementData = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetContainer() != null) {
        this.GetContainer().setAttribute("inputmode","numeric");
        this.GetContainer().setAttribute("pattern","[0-9]*");
        this.GetContainer().value = this.GetDisplayText();
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FRequired) {
          this.GetElementInputHandle().setAttribute("required","")}
         else this.GetElementInputHandle().removeAttribute("required");
      };
    };
    this.GetValue = function () {
      var Result = 0;
      var s = "";
      Result = this.FValue;
      if (!(this.GetContainer() != null)) return Result;
      s = this.GetContainer().value;
      if (s !== "") Result = pas.SysUtils.StrToInt(s);
      return Result;
    };
    this.SetIncrement = function (AValue) {
      this.FIncrement = AValue;
      if (this.GetContainer() != null) this.GetContainer().setAttribute("step",pas.SysUtils.IntToStr(AValue));
    };
    this.SetMaxValue = function (AValue) {
      this.FMaxValue = AValue;
      if (this.GetContainer() != null) this.GetContainer().setAttribute("max",pas.SysUtils.IntToStr(AValue));
    };
    this.SetMinValue = function (AValue) {
      this.FMinValue = AValue;
      if (this.GetContainer() != null) this.GetContainer().setAttribute("min",pas.SysUtils.IntToStr(AValue));
    };
    this.SetValue = function (AValue) {
      this.FValue = AValue;
      this.UpdateElement();
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      if (this.FRequiredText !== "") {
        this.GetElementInputHandle().setCustomValidity("");
      };
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementInputHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.FValue);
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().addEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.Change = function () {
      this.FValue = this.GetValue();
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FIncrement = 1;
      this.FMaxValue = 100;
      this.FMinValue = 0;
      this.SetShowFocus(true);
      this.SetHeight(25);
      this.AddControlStyle('input[type="number"]::-webkit-inner-spin-button { opacity: 1 !important; }');
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize");
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Increment",2,rtl.longint,"FIncrement","SetIncrement");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxValue",2,rtl.longint,"FMaxValue","SetMaxValue",4,{Default: 100});
    $r.addProperty("MinValue",2,rtl.longint,"FMinValue","SetMinValue",4,{Default: 0});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Value",3,rtl.longint,"GetValue","SetValue");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebSpinEdit",this.TSpinEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TDateTimePicker",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FDate = 0.0;
      this.FTime = 0.0;
      this.FKind = 0;
      this.FOnChange = null;
      this.FReadOnly = false;
      this.FElementCheck = null;
      this.FElementPicker = null;
      this.FShowCheckBox = false;
      this.FClickPtr$1 = null;
      this.FHandleChangePtr = null;
      this.FFocusPtr = null;
      this.FBlurPtr = null;
      this.FChecked = false;
      this.FShowSeconds = false;
      this.FAutoDropDown = false;
      this.FIsBootstrap = false;
      this.FMax = 0.0;
      this.FMin = 0.0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FElementCheck = undefined;
      this.FElementPicker = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.SetDate = function (AValue) {
      if (this.FDate !== AValue) {
        this.FDate = pas.System.Int(AValue);
        this.FTime = 0;
        this.UpdateElementData();
      };
    };
    this.GetDate = function () {
      var Result = 0.0;
      var str = "";
      Result = pas.System.Int(this.FDate) + pas.System.Frac(this.FTime);
      if (!(this.GetElementPicker() != null)) return Result;
      str = this.GetElementPicker().value;
      if (this.FKind === $mod.TDateTimeKind.dtkDate) {
        Result = pas["WEBLib.WebTools"].PickerDateToDate(str) + pas.System.Frac(this.FTime);
      } else Result = this.FTime;
      return Result;
    };
    this.SetTime = function (AValue) {
      if (this.FTime !== AValue) {
        this.FDate = 0;
        this.FTime = AValue;
        this.UpdateElementData();
      };
    };
    this.GetTime = function () {
      var Result = 0.0;
      var str = "";
      if (this.FDate > 0) {
        Result = pas.System.Frac(this.FTime) + pas.System.Int(this.FDate)}
       else Result = pas.System.Frac(this.FTime);
      if (!(this.GetElementPicker() != null)) return Result;
      str = this.GetElementPicker().value;
      if (this.FKind === $mod.TDateTimeKind.dtkTime) {
        Result = pas["WEBLib.WebTools"].PickerTimeToTime(str) + pas.System.Int(this.FDate);
      } else Result = this.FTime;
      return Result;
    };
    this.SetKind = function (AValue) {
      var dt = 0.0;
      this.FKind = AValue;
      if (this.GetElementPicker() != null) {
        dt = pas.System.Int(this.FDate) + pas.System.Frac(this.FTime);
        if (AValue === $mod.TDateTimeKind.dtkDate) {
          this.GetElementPicker().setAttribute("type","DATE")}
         else this.GetElementPicker().setAttribute("type","TIME");
        this.SetDate(dt);
        this.SetTime(dt);
        this.UpdateElement();
      };
    };
    this.SetText = function (Value) {
      if (!(this.GetElementPicker() != null)) return;
    };
    this.GetText = function () {
      var Result = "";
      Result = "";
      if (!(this.GetElementPicker() != null)) return Result;
      Result = this.GetElementPicker().value;
      return Result;
    };
    this.SetReadOnly = function (Value) {
      this.FReadOnly = Value;
      this.UpdateElement();
    };
    this.SetShowCheckBox = function (Value) {
      if (this.FShowCheckBox !== Value) {
        this.FShowCheckBox = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetChecked = function (Value) {
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        this.UpdateElementVisual();
      };
    };
    this.GetDateTime = function () {
      var Result = 0.0;
      Result = pas.System.Int(this.FDate) + pas.System.Frac(this.FTime);
      return Result;
    };
    this.SetDateTime = function (Value) {
      this.FDate = pas.System.Int(Value);
      this.FTime = pas.System.Frac(Value);
      this.UpdateElementData();
    };
    this.SetShowSeconds = function (Value) {
      if (this.FShowSeconds !== Value) {
        this.FShowSeconds = Value;
        this.UpdateElement();
      };
    };
    this.SetMax = function (Value) {
      if (this.FMax !== Value) {
        this.FMax = Value;
        this.UpdateElementData();
      };
    };
    this.SetMin = function (Value) {
      if (this.FMin !== Value) {
        this.FMin = Value;
        this.UpdateElementData();
      };
    };
    this.DoCheckClick = function (Event) {
      var Result = false;
      this.FChecked = this.FElementCheck.checked;
      if (this.FChecked) {
        this.GetElementPicker().removeAttribute("disabled")}
       else this.GetElementPicker().setAttribute("disabled","true");
      Result = true;
      return Result;
    };
    this.DoPickerFocus = function (Event) {
      var Result = false;
      if (!this.GetIsLinked() && !this.FIsBootstrap) this.GetElementHandle().style.setProperty("outline","auto");
      Result = true;
      this.DoEnter();
      return Result;
    };
    this.DoPickerBlur = function (Event) {
      var Result = false;
      if (!this.GetIsLinked() && !this.FIsBootstrap) this.GetElementHandle().style.setProperty("outline","none");
      Result = true;
      this.DoExit();
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.HandleDoEnter = function (Event) {
      var Result = false;
      var el = null;
      Result = pas["WEBLib.Controls"].TControl.HandleDoEnter.call(this,Event);
      if (this.FAutoDropDown) {
        el = this.GetElementPicker();
        el.showPicker();
      };
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.GetElementPicker();
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.FElementCheck != null) this.FElementCheck.addEventListener("click",this.FClickPtr$1);
      if (this.GetElementPicker() != null) {
        this.GetElementPicker().addEventListener("input",this.FHandleChangePtr);
        this.GetElementPicker().addEventListener("focus",this.FFocusPtr);
        this.GetElementPicker().addEventListener("blur",this.FBlurPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.FElementCheck != null) this.FElementCheck.removeEventListener("click",this.FClickPtr$1);
      if (this.GetElementPicker() != null) {
        this.GetElementPicker().removeEventListener("input",this.FHandleChangePtr);
        this.GetElementPicker().removeEventListener("focus",this.FFocusPtr);
        this.GetElementPicker().removeEventListener("blur",this.FBlurPtr);
      };
    };
    this.UpdateElementData = function () {
      var el = null;
      var s = "";
      var i = 0;
      var d = 0;
      var m = 0;
      var y = 0;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      el = this.GetElementPicker();
      if (el != null) {
        if (!this.GetIsLinked()) el.setAttribute("step","1");
        var $tmp = this.FKind;
        if ($tmp === $mod.TDateTimeKind.dtkTime) {
          if (this.FShowSeconds) {
            s = pas.SysUtils.FormatDateTime("HH:MM:SS",this.FTime)}
           else s = pas.SysUtils.FormatDateTime("HH:MM",this.FTime);
          for (var $l = 1, $end = s.length; $l <= $end; $l++) {
            i = $l;
            if (!(s.charCodeAt(i - 1) in rtl.createSet(null,48,57))) s = rtl.setCharAt(s,i - 1,":");
          };
          el.value = s;
          if (!this.FShowSeconds) el.setAttribute("step","60");
        } else if ($tmp === $mod.TDateTimeKind.dtkDate) {
          if (this.FDate === 0) {
            el.value = ""}
           else {
            s = pas.SysUtils.FormatDateTime("yyyy-MM-dd",this.FDate);
            for (var $l1 = 1, $end1 = s.length; $l1 <= $end1; $l1++) {
              i = $l1;
              if (!(s.charCodeAt(i - 1) in rtl.createSet(null,48,57))) s = rtl.setCharAt(s,i - 1,"-");
            };
            el.value = s;
          };
        };
        if (!this.GetIsLinked()) {
          if (this.FTabStop) {
            el.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder))}
           else el.setAttribute("tabindex","-1");
        } else {
          if (this.FTabStop) el.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder));
        };
        if (this.FKind === $mod.TDateTimeKind.dtkDate) {
          if (this.FMin !== 0) {
            pas.SysUtils.DecodeDate(this.FMin,{get: function () {
                return y;
              }, set: function (v) {
                y = v;
              }},{get: function () {
                return m;
              }, set: function (v) {
                m = v;
              }},{get: function () {
                return d;
              }, set: function (v) {
                d = v;
              }});
            el.setAttribute("min",pas.SysUtils.Format("%d",pas.System.VarRecs(0,y)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,m)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,d)));
          } else el.removeAttribute("min");
          if (this.FMax !== 0) {
            pas.SysUtils.DecodeDate(this.FMax,{get: function () {
                return y;
              }, set: function (v) {
                y = v;
              }},{get: function () {
                return m;
              }, set: function (v) {
                m = v;
              }},{get: function () {
                return d;
              }, set: function (v) {
                d = v;
              }});
            el.setAttribute("max",pas.SysUtils.Format("%d",pas.System.VarRecs(0,y)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,m)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,d)));
          } else el.removeAttribute("max");
        };
        el.readOnly = this.IsReadOnly();
        if (this.IsEnabled()) {
          el.removeAttribute("disabled")}
         else el.setAttribute("disabled","");
      };
    };
    this.UpdateElementVisual = function () {
      var frm = null;
      $mod.TCustomInput.UpdateElementVisual.call(this);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      this.FIsBootstrap = (frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (this.FElementClassName !== "");
      if ((this.GetElementPicker() != null) && (this.GetElementHandle() != null) && (this.FElementCheck != null)) {
        this.FElementCheck.setAttribute("type","CHECKBOX");
        if (this.FKind === $mod.TDateTimeKind.dtkDate) {
          this.GetElementPicker().setAttribute("type","DATE")}
         else this.GetElementPicker().setAttribute("type","TIME");
        if (this.FElementClassName === "") {
          this.GetElementPicker().style.setProperty("border","none");
          this.GetElementPicker().style.setProperty("border-width","0px");
          this.GetElementPicker().style.setProperty("outline","none");
          this.GetElementPicker().style.setProperty("font-family","inherit");
          this.GetElementPicker().style.setProperty("font-size","inherit");
          this.GetElementPicker().style.setProperty("width","100%");
          this.GetElementPicker().style.setProperty("height","100%");
        } else {
          if (this.FIsBootstrap) {
            this.GetElementPicker().setAttribute("class",this.FElementClassName);
            this.GetElementHandle().removeAttribute("class");
          };
        };
        if (!this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("padding","1px");
          this.GetElementHandle().style.setProperty("outline","none");
        };
        if ((this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) && (this.FElementClassName === "")) {
          if (!this.FEnabled) {
            this.GetElementHandle().style.setProperty("border","1px silver solid")}
           else this.GetElementHandle().style.setProperty("border","1px solid");
          this.GetElementHandle().style.setProperty("border-radius","3px");
        } else {
          if (this.FIsBootstrap) {
            this.GetElementHandle().style.removeProperty("border");
            this.GetElementHandle().style.removeProperty("box-sizing");
          };
        };
        if (this.FElementCheck != null) {
          if (this.FShowCheckBox) {
            this.FElementCheck.style.setProperty("display","")}
           else this.FElementCheck.style.setProperty("display","none");
        };
        if (this.FShowCheckBox) {
          if (this.FChecked) {
            this.GetElementPicker().removeAttribute("disabled")}
           else this.GetElementPicker().setAttribute("disabled","true");
        };
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FElementCheck = document.createElement("INPUT");
      this.FElementPicker = document.createElement("INPUT");
      Result.appendChild(this.FElementCheck);
      Result.appendChild(this.FElementPicker);
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      if (this.FKind === $mod.TDateTimeKind.dtkDate) {
        Result = "DATE"}
       else Result = "TIME";
      return Result;
    };
    this.Change = function () {
      this.FTime = this.GetTime();
      this.FDate = this.GetDate();
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FBlurPtr = null;
      this.FFocusPtr = null;
      this.FClickPtr$1 = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FClickPtr$1 = rtl.createCallback(this,"DoCheckClick");
      this.FFocusPtr = rtl.createCallback(this,"DoPickerFocus");
      this.FBlurPtr = rtl.createCallback(this,"DoPickerBlur");
    };
    this.GetElementPicker = function () {
      var Result = null;
      if (this.GetIsLinked()) {
        Result = this.GetElementHandle()}
       else Result = this.FElementPicker;
      return Result;
    };
    this.SetEnabled = function (Value) {
      var el = null;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      el = this.GetElementPicker();
      if (el != null) {
        if (Value) {
          el.removeAttribute("disabled")}
         else el.setAttribute("disabled","");
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FMin = 0;
      this.FMax = 0;
      this.SetDate(pas.SysUtils.Now());
      this.SetShowFocus(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(170);
        this.SetHeight(25);
      };
      this.FDate = pas.System.Int(pas.SysUtils.Now());
      this.FTime = 0;
      this.FReadOnly = false;
      this.FShowSeconds = true;
      this.FIsBootstrap = false;
    };
    this.Clear = function () {
      this.GetElementPicker().value = "";
    };
    this.SetFocus = function () {
      var $Self = this;
      var el = null;
      function IntSetFocus() {
        el.focus();
      };
      if (1 < 0) IntSetFocus();
      if (this.GetElementPicker() != null) {
        el = this.GetElementPicker();
        setTimeout(IntSetFocus, 100);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoDropDown",0,rtl.boolean,"FAutoDropDown","FAutoDropDown",4,{Default: false});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",4,{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Date",3,pas.System.$rtti["TDate"],"GetDate","SetDate");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Kind",2,$mod.$rtti["TDateTimeKind"],"FKind","SetKind");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Max",2,pas.System.$rtti["TDateTime"],"FMax","SetMax");
    $r.addProperty("Min",2,pas.System.$rtti["TDateTime"],"FMin","SetMin");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowCheckBox",2,rtl.boolean,"FShowCheckBox","SetShowCheckBox",4,{Default: false});
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("ShowSeconds",2,rtl.boolean,"FShowSeconds","SetShowSeconds",4,{Default: true});
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Time",3,pas.System.$rtti["TTime"],"GetTime","SetTime");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebDateTimePicker",this.TDateTimePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TButton",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FModalResult = 0;
      this.FDefault = false;
      this.FCancel = false;
      this.FButtonType = "";
    };
    this.SetButtonType = function (Value) {
      this.FButtonType = Value;
      this.UpdateElementData();
    };
    this.SetDefault = function (Value) {
      this.FDefault = Value;
      if (this.FDefault) this.SetFocus();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("BUTTON");
      Result.setAttribute("type","BUTTON");
      return Result;
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElementData();
      };
    };
    this.UpdateElementData = function () {
      var acc = "";
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetIsLinked() && (this.FCaption === "")) return;
      if (this.GetElementHandle() != null) {
        if ((this.GetElementHandle().childElementCount === 0) || (pas.System.Pos("</",this.FCaption) > 0) || !this.GetIsLinked()) {
          this.GetElementHandle().innerHTML = pas["WEBLib.WebTools"].ProcessAccelerator(this.FCaption,{get: function () {
              return acc;
            }, set: function (v) {
              acc = v;
            }});
        };
        if (acc !== "") this.GetElementHandle().setAttribute("accesskey",acc);
        this.GetElementHandle().setAttribute("role","button");
        this.GetElementHandle().setAttribute("aria-label",this.FCaption);
        if (this.FButtonType !== "") {
          this.GetElementHandle().setAttribute("type",this.FButtonType)}
         else this.GetElementHandle().setAttribute("type","BUTTON");
      };
    };
    this.UpdateElementVisual = function () {
      var ecn = "";
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.removeProperty("outline");
        this.GetElementHandle().style.removeProperty("user-select");
        ecn = pas.SysUtils.UpperCase(this.FElementClassName);
        if ((ecn === "BTN") || (pas.System.Pos("BTN ",ecn) > 0)) ;
      };
    };
    this.HandleKeyPreview = function (Key) {
      pas["WEBLib.Controls"].TControl.HandleKeyPreview.apply(this,arguments);
      if (this.FDefault && (Key === 13)) {
        this.Click();
      };
      if (this.FCancel && (Key === 27)) {
        this.Click();
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("btn btn-light");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FCaption === "")) this.SetCaption(this.FName);
      this.SetColor(-1);
      this.FModalResult = 0;
    };
    this.Click = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (this.FModalResult !== 0) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if (frm != null) frm.SetModalResult(this.FModalResult);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ButtonType",2,rtl.string,"FButtonType","SetButtonType");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Cancel",0,rtl.boolean,"FCancel","FCancel",4,{Default: false});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Default",2,rtl.boolean,"FDefault","SetDefault",4,{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",4,{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebButton",this.TButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCheckBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FChecked = false;
      this.FState = 0;
      this.FElementButtonClassName = "";
      this.FElementLabelClassName = "";
      this.FOnCheckClick = null;
      this.FAlignment = 0;
      this.FAllowGrayed = false;
    };
    this.$final = function () {
      this.FOnCheckClick = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElementVisual();
      };
    };
    this.Loaded = function () {
      var lbl = null;
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.GetContainer() != null) {
        if (!this.GetIsLinked()) {
          lbl = this.GetContainer().children.item(1);
          lbl.onclick = rtl.createSafeCallback(this,"HandleLabelClick");
        };
      };
    };
    this.UpdateElementData = function () {
      var chk = null;
      var btn = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetContainer() != null) {
        chk = this.GetCheckElement();
        if (chk != null) {
          chk.disabled = !this.IsEnabled();
          chk.checked = this.FChecked;
          chk.indeterminate = this.GetState() === $mod.TCheckBoxState.cbGrayed;
        };
        if (!this.GetIsLinked()) {
          if (this.FCaption !== "") this.GetContainer().lastElementChild.innerHTML = this.FCaption;
          this.GetElementHandle().setAttribute("tabindex","-1");
          btn = this.GetElementHandle().firstChild;
          btn.setAttribute("tabindex","-1");
        };
        if (this.FTabStop) this.GetContainer().setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder));
      };
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if ((this.GetContainer() != null) && !this.GetIsLinked() && (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute)) {
        if (this.FHeightStyle !== pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
          this.GetContainer().firstElementChild.style.setProperty("height","100%")}
         else this.GetContainer().firstElementChild.style.removeProperty("height");
      };
    };
    this.UpdateElementVisual = function () {
      var btn = null;
      var lbl = null;
      var frm = null;
      var isbs = false;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        btn = this.GetElementHandle().firstChild;
        if (btn != null) {
          if (this.FElementClassName === "") {
            btn.style.setProperty("vertical-align","middle");
            btn.style.setProperty("margin-top","0px");
          };
          if (this.FElementButtonClassName !== "") {
            btn.setAttribute("class",this.FElementButtonClassName)}
           else btn.removeAttribute("class");
        };
        lbl = this.GetElementHandle().lastElementChild;
        if (lbl != null) {
          if (this.FElementLabelClassName !== "") {
            lbl.setAttribute("class",this.FElementLabelClassName)}
           else lbl.removeAttribute("class");
        };
        if (!this.FTabStop || !this.FShowFocus || (this.FElementClassName !== "")) this.GetElementHandle().style.setProperty("outline","none");
        if (!this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("user-select","none");
          if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
            if (this.FElementButtonClassName === "") {
              if (this.FAlignment === pas.Classes.TAlignment.taRightJustify) {
                btn.style.removeProperty("float");
              } else {
                btn.style.setProperty("float","right");
              };
              if (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
                btn.style.removeProperty("height")}
               else if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) btn.style.setProperty("height","100%");
              btn.style.setProperty("vertical-align","middle");
              if (!$mod.TCheckGroup.isPrototypeOf(this.FParent)) {
                btn.style.setProperty("margin-top","0px");
                btn.style.setProperty("margin-bottom","0px");
              };
            };
            frm = pas["WEBLib.Forms"].GetParentForm(this);
            isbs = (frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap);
            if ((this.FElementLabelClassName === "") || isbs) {
              lbl = this.GetContainer().lastElementChild;
              lbl.style.setProperty("margin-left","4px");
              lbl.style.setProperty("vertical-align","middle");
              lbl.style.setProperty("min-height","100%");
              lbl.style.setProperty("height","100%");
              lbl.style.setProperty("overflow","hidden");
              lbl.style.setProperty("display","inline-flex");
              lbl.style.setProperty("align-items","center");
            };
          };
        };
      };
    };
    this.PersistinHTML = function () {
      var cb = null;
      if (!(this.GetContainer() != null)) return;
      cb = this.GetCheckElement();
      if (cb.checked) {
        cb.setAttribute("checked","checked")}
       else cb.removeAttribute("checked");
    };
    this.CreateElement = function () {
      var Result = null;
      var btn = null;
      var lbl = null;
      Result = document.createElement("SPAN");
      btn = document.createElement("INPUT");
      lbl = document.createElement("SPAN");
      btn.setAttribute("TYPE","CHECKBOX");
      btn.setAttribute("id",this.GetID() + "ck");
      btn.setAttribute("role","checkbox");
      lbl.setAttribute("id",this.GetID() + "lbl");
      lbl.setAttribute("value",this.GetID());
      Result.appendChild(btn);
      Result.appendChild(lbl);
      rtl.asExt(btn,HTMLInputElement).onclick = rtl.createSafeCallback(this,"HandleCheckClick");
      return Result;
    };
    this.SetChecked = function (AValue) {
      this.FChecked = AValue;
      if (AValue) {
        this.FState = $mod.TCheckBoxState.cbChecked}
       else this.FState = $mod.TCheckBoxState.cbUnchecked;
      this.UpdateElement();
    };
    this.GetChecked = function () {
      var Result = false;
      var el = null;
      if (this.GetContainer() != null) {
        el = this.GetCheckElement();
        if (el != null) this.FChecked = el.checked;
      };
      Result = this.FChecked;
      return Result;
    };
    this.SetState = function (AValue) {
      this.FState = AValue;
      this.FChecked = this.FState === $mod.TCheckBoxState.cbChecked;
      this.UpdateElement();
    };
    this.GetState = function () {
      var Result = 0;
      Result = this.FState;
      return Result;
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        if (this.GetContainer() != null) {
          if (this.GetIsLinked()) {
            if ((this.GetContainer().lastElementChild != null) && (this.GetContainer().lastElementChild.tagName === "SPAN")) this.GetContainer().lastElementChild.innerHTML = AValue;
          } else if (this.GetContainer().lastElementChild != null) this.GetContainer().lastElementChild.innerHTML = AValue;
        };
      };
    };
    this.SetEnabled = function (Value) {
      var el = null;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      if (this.GetContainer() != null) {
        el = this.GetCheckElement();
        if (el != null) el.disabled = !Value;
      };
    };
    this.HandleLabelClick = function (Event) {
      var Result = false;
      var chk = null;
      Event.preventDefault();
      Event.stopPropagation();
      if ((this.GetContainer() != null) && this.FEnabled) {
        if (this.FAllowGrayed) {
          if (this.FState === $mod.TCheckBoxState.cbUnchecked) {
            this.FState = $mod.TCheckBoxState.cbGrayed}
           else if (this.FState === $mod.TCheckBoxState.cbGrayed) {
            this.FState = $mod.TCheckBoxState.cbChecked}
           else if (this.FState === $mod.TCheckBoxState.cbChecked) this.FState = $mod.TCheckBoxState.cbUnchecked;
          chk = this.GetCheckElement();
          chk.checked = this.FState === $mod.TCheckBoxState.cbChecked;
          chk.indeterminate = this.FState === $mod.TCheckBoxState.cbGrayed;
        } else {
          chk = this.GetCheckElement();
          chk.checked = !chk.checked;
        };
      };
      this.DoCheckClick();
      Result = true;
      return Result;
    };
    this.HandleCheckClick = function (Event) {
      var Result = false;
      var chk = null;
      Event.stopPropagation();
      if (this.FEnabled) {
        if (this.FAllowGrayed) {
          if (this.FState === $mod.TCheckBoxState.cbUnchecked) {
            this.FState = $mod.TCheckBoxState.cbGrayed}
           else if (this.FState === $mod.TCheckBoxState.cbGrayed) {
            this.FState = $mod.TCheckBoxState.cbChecked}
           else if (this.FState === $mod.TCheckBoxState.cbChecked) this.FState = $mod.TCheckBoxState.cbUnchecked;
          chk = this.GetCheckElement();
          chk.checked = this.FState === $mod.TCheckBoxState.cbChecked;
          chk.indeterminate = this.FState === $mod.TCheckBoxState.cbGrayed;
        };
      };
      this.DoCheckClick();
      Result = true;
      return Result;
    };
    this.Click = function () {
      var chk = null;
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (!this.GetIsLinked()) {
        if (this.FAllowGrayed && this.FEnabled) {
          if (this.FState === $mod.TCheckBoxState.cbUnchecked) {
            this.FState = $mod.TCheckBoxState.cbGrayed}
           else if (this.FState === $mod.TCheckBoxState.cbGrayed) {
            this.FState = $mod.TCheckBoxState.cbChecked}
           else if (this.FState === $mod.TCheckBoxState.cbChecked) this.FState = $mod.TCheckBoxState.cbUnchecked;
          chk = this.GetCheckElement();
          chk.checked = this.FState === $mod.TCheckBoxState.cbChecked;
          chk.indeterminate = this.FState === $mod.TCheckBoxState.cbGrayed;
        };
        if (!this.FAllowGrayed && this.FEnabled) {
          this.FChecked = this.GetChecked();
          if (this.FChecked) {
            this.FState = $mod.TCheckBoxState.cbChecked}
           else this.FState = $mod.TCheckBoxState.cbUnchecked;
          chk = this.GetCheckElement();
          chk.checked = !chk.checked;
        };
      };
      this.DoCheckClick();
      this.SetFocus();
    };
    this.DoCheckClick = function () {
      if (this.FOnCheckClick != null) this.FOnCheckClick(this);
    };
    this.GetCheckElement = function () {
      var Result = null;
      if (this.GetIsLinked()) {
        if (this.GetElementHandle().tagName === "INPUT") {
          Result = this.GetElementHandle()}
         else Result = this.GetContainer().firstElementChild;
      } else Result = this.GetContainer().firstElementChild;
      return Result;
    };
    this.KeyPress = function (ch) {
      var chk = null;
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
      if (ch.get() === " ") {
        if ((this.GetContainer() != null) && !this.GetIsLinked()) {
          chk = this.GetCheckElement();
          chk.checked = !chk.checked;
        };
      };
    };
    this.LoadState = function (AState) {
      var cb = null;
      if (!(this.GetContainer() != null)) return;
      cb = this.GetCheckElement();
      cb.checked = AState === "1";
    };
    this.SaveState = function () {
      var Result = "";
      var cb = null;
      if (!(this.GetContainer() != null)) return Result;
      cb = this.GetCheckElement();
      if (cb.checked) {
        Result = "1"}
       else Result = "0";
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("custom-control custom-checkbox");
        this.FElementButtonClassName = "custom-control-input";
        this.FElementLabelClassName = "custom-control-label";
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(-1);
      this.FChecked = false;
      this.FState = $mod.TCheckBoxState.cbUnchecked;
      this.SetAlignment(pas.Classes.TAlignment.taRightJustify);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FCaption === "")) this.SetCaption(this.FName);
      this.SetShowFocus(true);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taRightJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("AllowGrayed",0,rtl.boolean,"FAllowGrayed","FAllowGrayed",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked",4,{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: -1});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementLabelClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","FElementLabelClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("State",3,$mod.$rtti["TCheckBoxState"],"GetState","SetState",4,{Default: $mod.TCheckBoxState.cbUnchecked});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebCheckBox",this.TCheckBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TRadioButton",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FChecked = false;
      this.FGroupName = "";
      this.FElementButtonClassName = "";
      this.FElementLabelClassName = "";
    };
    this.PersistinHTML = function () {
      var rb = null;
      if (!(this.GetContainer() != null)) return;
      rb = this.GetRadioElement();
      if (rb.checked) {
        rb.setAttribute("checked","checked")}
       else rb.removeAttribute("checked");
    };
    this.CreateElement = function () {
      var Result = null;
      var btn = null;
      var lbl = null;
      Result = document.createElement("SPAN");
      btn = document.createElement("INPUT");
      lbl = document.createElement("SPAN");
      Result.addEventListener("click",rtl.createSafeCallback(this,"HandleLabelClick"));
      btn.setAttribute("TYPE","RADIO");
      btn.setAttribute("id",this.GetID() + "rd");
      btn.setAttribute("name",this.FGroupName);
      btn.setAttribute("role","radio");
      btn.setAttribute("tabindex","-1");
      btn.addEventListener("click",rtl.createSafeCallback(this,"HandleRadioClick"));
      lbl.setAttribute("id",this.GetID() + "lbl");
      lbl.setAttribute("value",this.GetID());
      Result.appendChild(btn);
      Result.appendChild(lbl);
      return Result;
    };
    this.SetChecked = function (AValue) {
      var el = null;
      this.FChecked = AValue;
      if (this.GetContainer() != null) {
        el = this.GetRadioElement();
        if (el != null) el.checked = AValue;
      };
    };
    this.GetChecked = function () {
      var Result = false;
      var el = null;
      Result = this.FChecked;
      if (this.GetContainer() != null) {
        el = this.GetRadioElement();
        if (el != null) Result = el.checked;
      };
      return Result;
    };
    this.SetEnabled = function (Value) {
      var el = null;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      if (this.GetContainer() != null) {
        el = this.GetRadioElement();
        if (el != null) el.disabled = !Value;
      };
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        if ((this.GetContainer() != null) && !this.GetIsLinked()) this.GetContainer().lastElementChild.innerHTML = AValue;
      };
    };
    this.SetGroupName = function (AValue) {
      this.FGroupName = AValue;
      this.UpdateElementData();
    };
    this.HandleLabelClick = function (Event) {
      var Result = false;
      var rb = null;
      if ((this.GetContainer() != null) && this.FEnabled) {
        rb = this.GetRadioElement();
        rb.checked = true;
      };
      Result = true;
      return Result;
    };
    this.HandleRadioClick = function (Event) {
      var Result = false;
      this.SetFocus();
      Result = true;
      return Result;
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if ((this.GetContainer() != null) && !this.GetIsLinked()) {
        if (this.FHeightStyle !== pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
          this.GetContainer().firstElementChild.style.setProperty("height","100%")}
         else this.GetContainer().firstElementChild.style.removeProperty("height");
      };
    };
    this.UpdateElementData = function () {
      var btn = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetContainer() != null) {
        if (this.GetIsLinked()) {
          this.GetElementHandle().setAttribute("name",this.FGroupName)}
         else {
          this.GetContainer().firstElementChild.setAttribute("name",this.FGroupName);
          btn = this.GetElementHandle().firstChild;
          btn.disabled = !this.FEnabled;
        };
        if (!this.GetIsLinked()) {
          if (this.FCaption !== "") this.GetContainer().lastElementChild.innerHTML = this.FCaption;
          this.GetElementHandle().setAttribute("tabindex","-1");
          if (this.FTabStop && (btn != null)) btn.setAttribute("tabindex","-1");
        };
        if (this.FTabStop) this.GetContainer().setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder));
      };
    };
    this.UpdateElementVisual = function () {
      var btn = null;
      var lbl = null;
      var isbs = false;
      var frm = null;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (!this.GetIsLinked()) {
          btn = this.GetElementHandle().firstChild;
          btn.style.setProperty("margin-right","4px");
          btn.style.setProperty("vertical-align","middle");
          btn.style.setProperty("margin-top","0px");
          if (btn != null) {
            if (this.FElementButtonClassName !== "") {
              btn.setAttribute("class",this.FElementButtonClassName)}
             else btn.removeAttribute("class");
          };
          lbl = this.GetElementHandle().lastElementChild;
          if (lbl != null) {
            if (this.FElementLabelClassName !== "") {
              lbl.setAttribute("class",this.FElementLabelClassName)}
             else lbl.removeAttribute("class");
          };
        };
        if (!this.FTabStop || !this.FShowFocus || (this.FElementClassName !== "")) this.GetElementHandle().style.setProperty("outline","none");
        if (!this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("user-select","none");
          this.GetElementHandle().style.setProperty("white-space","normal");
          if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
            if (this.FElementButtonClassName === "") {
              if (this.FHeightStyle !== pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
                btn.style.setProperty("height","100%")}
               else btn.style.removeProperty("height");
              btn.style.setProperty("vertical-align","middle");
              if (!$mod.TRadioGroup.isPrototypeOf(this.FParent)) {
                btn.style.setProperty("margin-top","0px");
                btn.style.setProperty("margin-bottom","0px");
              };
            };
            frm = pas["WEBLib.Forms"].GetParentForm(this);
            isbs = (frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap);
            if ((this.FElementLabelClassName === "") || isbs) {
              lbl = this.GetContainer().lastElementChild;
              lbl.style.setProperty("vertical-align","middle");
              lbl.style.setProperty("min-height","100%");
              lbl.style.setProperty("height","100%");
              if (!$mod.TRadioGroup.isPrototypeOf(this.FParent)) lbl.style.setProperty("position","absolute");
              lbl.style.setProperty("overflow","hidden");
              lbl.style.setProperty("display","inline-flex");
              lbl.style.setProperty("align-items","center");
            };
          };
        };
      };
    };
    this.GetRadioElement = function () {
      var Result = null;
      if (this.GetIsLinked()) {
        Result = this.GetElementHandle()}
       else Result = this.GetContainer().firstElementChild;
      return Result;
    };
    this.KeyPress = function (ch) {
      var rb = null;
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
      if (ch.get() === " ") {
        rb = this.GetRadioElement();
        rb.checked = true;
      };
    };
    this.LoadState = function (AState) {
      var rb = null;
      if (!(this.GetContainer() != null)) return;
      rb = this.GetRadioElement();
      rb.checked = AState === "1";
    };
    this.SaveState = function () {
      var Result = "";
      var rb = null;
      if (!(this.GetContainer() != null)) return Result;
      rb = this.GetRadioElement();
      if (rb.checked) {
        Result = "1"}
       else Result = "0";
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(-1);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FCaption === "")) this.SetCaption(this.FName);
      this.FGroupName = "";
      this.SetShowFocus(true);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked",4,{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: -1});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementLabelClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","FElementLabelClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("GroupName",2,rtl.string,"FGroupName","SetGroupName");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebRadioButton",this.TRadioButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TListBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FMultiSelect = false;
      this.FSelected = null;
      this.FItemHeight = 0;
      this.FSorted = false;
      this.FOnChange = null;
      this.FHandleChangePtr = null;
      this.FElementItemClassName = "";
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FSelected = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetItemHeight = function (Value) {
      this.FItemHeight = Value;
    };
    this.SetSorted = function (Value) {
      this.FSorted = Value;
      this.FItems.SetSorted(Value);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FItems.GetCount();
      return Result;
    };
    this.GetElementSelectHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.GetSelCount = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      if (this.GetContainer() != null) {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.GetContainer().options.item(i).selected) Result += 1;
        };
      };
      return Result;
    };
    this.GetValues = function (AIndex) {
      var Result = "";
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        Result = opt.getAttribute("value");
      };
      return Result;
    };
    this.SetValues = function (AIndex, Value) {
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        opt.setAttribute("value",Value);
      };
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.DoUpdateList = function () {
      var i = 0;
      var j = 0;
      var opt = null;
      var k = "";
      var v = "";
      var s = "";
      if (!(this.GetContainer() != null)) return;
      if (this.IsUpdating()) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = this.GetContainer().options.length - 1; $l >= 0; $l--) {
        i = $l;
        this.GetContainer().remove(i);
      };
      for (var $l1 = 0, $end = this.FItems.GetCount() - 1; $l1 <= $end; $l1++) {
        i = $l1;
        s = this.FItems.Get(i);
        k = s;
        v = s;
        j = pas.System.Pos(this.FItems.GetNameValueSeparator(),s);
        if (j > 0) {
          v = pas.System.Copy(s,1,j - 1);
          k = pas.System.Copy(s,j + 1,0xFFFF);
        } else k = "";
        opt = new Option(v);
        if (k !== "") opt.setAttribute("value",k);
        opt.setAttribute("role","listitem");
        if (this.FElementItemClassName !== "") opt.setAttribute("class",this.FElementItemClassName);
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) opt.setAttribute("draggable","true");
        this.GetContainer().add(opt);
      };
      this.UpdateElementData();
    };
    this.PersistinHTML = function () {
      var i = 0;
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetContainer().options.item(i).selected) {
          this.GetContainer().options.item(i).setAttribute("selected","selected")}
         else this.GetContainer().options.item(i).removeAttribute("selected");
      };
    };
    this.GetItemIndex = function () {
      var Result = 0;
      Result = this.FItemIndex;
      if (this.GetContainer() != null) Result = this.GetContainer().selectedIndex;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SELECT");
      Result.setAttribute("Size","2");
      return Result;
    };
    this.GetSelected = function (AIndex) {
      var Result = false;
      if (AIndex < this.FSelected.GetCount()) {
        Result = !(this.FSelected.Get(AIndex) == false)}
       else Result = false;
      if (this.GetElementHandle().tagName !== "SELECT") return Result;
      if ((this.GetContainer() != null) && (AIndex < this.GetContainer().options.length)) Result = this.GetContainer().options.item(AIndex).selected;
      return Result;
    };
    this.SetSelected = function (AIndex, AValue) {
      while (AIndex >= this.FSelected.GetCount()) this.FSelected.Add(false);
      this.FSelected.Put(AIndex,AValue);
      if (this.GetContainer() != null) {
        this.GetContainer().options.item(AIndex).selected = AValue;
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetItemIndex = function (AIndex) {
      if (this.FItemIndex !== AIndex) {
        this.FItemIndex = AIndex;
        this.UpdateElement();
      };
    };
    this.SetMultiSelect = function (AValue) {
      this.FMultiSelect = AValue;
      if (this.GetContainer() != null) this.GetContainer().multiple = AValue;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
      this.UpdateElement();
    };
    this.UpdateElementData = function () {
      var i = 0;
      var b = false;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetElementSelectHandle() != null) {
        this.GetElementSelectHandle().style.setProperty("overflow","auto");
        if (!this.FMultiSelect) {
          this.GetElementSelectHandle().selectedIndex = this.FItemIndex}
         else {
          for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (this.FSelected.GetCount() > i) {
              b = !(this.FSelected.Get(i) == false);
              if (this.GetContainer() != null) this.GetContainer().options.item(i).selected = b;
            };
          };
        };
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementSelectHandle() != null) {
        this.GetElementSelectHandle().style.setProperty("overflow","auto");
        this.GetElementSelectHandle().setAttribute("role","listbox");
        this.GetElementSelectHandle().setAttribute("aria-busy","true");
      };
    };
    this.UpdateParent = function () {
      pas["WEBLib.Controls"].TControl.UpdateParent.call(this);
      this.DoUpdateList();
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().addEventListener("change",this.FHandleChangePtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().removeEventListener("change",this.FHandleChangePtr);
      };
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.SaveState = function () {
      var Result = "";
      var i = 0;
      var s = "";
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetSelected(i)) {
          s = s + ",1"}
         else s = s + ",0";
      };
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Result = s;
      return Result;
    };
    this.LoadState = function (AState) {
      var sl = null;
      var i = 0;
      sl = pas.Classes.TStringList.$create("Create$1");
      sl.SetDelimiter(",");
      sl.SetCommaText(AState);
      for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.SetSelected(i,sl.Get(i) === "1");
      };
      sl = rtl.freeLoc(sl);
    };
    this.EnableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().options.item(I).setAttribute("draggable","true");
      };
    };
    this.DisableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().options.item(I).setAttribute("draggable","false");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.SetSkipLastLineBreak(true);
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FMultiSelect = false;
      this.FSelected = pas.Classes.TList.$create("Create$1");
      this.FItemIndex = -1;
      this.SetShowFocus(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(160);
        this.SetHeight(180);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      rtl.free(this,"FSelected");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.ClearSelection = function () {
      var i = 0;
      this.SetItemIndex(-1);
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        i = $l;
        this.GetContainer().options.item(i).selected = false;
      };
    };
    this.SelectAll = function () {
      var i = 0;
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        i = $l;
        this.SetSelected(i,true);
        this.GetContainer().options.item(i).selected = true;
      };
    };
    this.DeleteSelected = function () {
      var i = 0;
      this.FItems.BeginUpdate();
      for (var $l = this.FItems.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.GetSelected(i)) this.FItems.Delete(i);
      };
      this.FItems.EndUpdate();
    };
    this.AddItem = function (Item, AObject) {
      this.FItems.AddObject(Item,AObject);
    };
    this.Clear = function () {
      this.BeginUpdate();
      this.FItems.Clear();
      this.EndUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementItemClassName",0,rtl.string,"FElementItemClassName","FElementItemClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemHeight",2,rtl.longint,"FItemHeight","SetItemHeight");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("MultiSelect",2,rtl.boolean,"FMultiSelect","SetMultiSelect");
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",4,{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebListBox",this.TListBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TComboBoxStyle = {"0": "csDropDownList", csDropDownList: 0, "1": "csDropDown", csDropDown: 1};
  this.$rtti.$Enum("TComboBoxStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TComboBoxStyle});
  rtl.createClass(this,"TCustomComboBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FStyle = 0;
      this.FDroppedDown = false;
      this.FOnChange = null;
      this.FTextHint = "";
      this.FListName = "";
      this.FText = "";
      this.FHandleChangePtr = null;
      this.FHandleInputPtr = null;
      this.FHandleFocusInPtr = null;
      this.FHandleFocusOutPtr = null;
      this.FOnFocusOut = null;
      this.FOnFocusIn = null;
      this.FRequired = false;
      this.FRequiredText = "";
      this.FHandleInvalidPtr = null;
      this.FSorted = false;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      this.FOnFocusOut = undefined;
      this.FOnFocusIn = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      var el = null;
      var AName = "";
      var AValue = "";
      Result = "";
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        if (this.GetElementHandle() != null) Result = this.GetElementHandle().value;
      } else if (this.GetItemIndex() >= 0) {
        if (this.GetItemIndex() < this.FItems.GetCount()) {
          this.FItems.GetNameValue(this.GetItemIndex(),{get: function () {
              return AName;
            }, set: function (v) {
              AName = v;
            }},{get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }});
          if ((AName !== "") && (AValue !== "")) {
            Result = AName}
           else Result = this.FItems.Get(this.GetItemIndex());
        } else {
          if (this.GetIsLinked()) {
            if (this.GetItemIndex() < this.GetElementHandle().childElementCount) {
              el = this.GetElementHandle().children.item(this.GetItemIndex());
              if (el.tagName === "OPTION") Result = el.innerHTML;
            };
          };
        };
      };
      return Result;
    };
    this.SetText = function (Value) {
      var I = 0;
      var AName = "";
      var AValue = "";
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        this.FText = Value;
        this.UpdateElement();
      } else {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FItems.GetNameValue(I,{get: function () {
              return AName;
            }, set: function (v) {
              AName = v;
            }},{get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }});
          if ((Value === this.FItems.Get(I)) || (Value === AName)) this.SetItemIndex(I);
        };
      };
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        if (!this.GetIsLinked()) this.RecreateElement();
      };
    };
    this.SetDroppedDown = function (Value) {
      this.FDroppedDown = Value;
    };
    this.GetElementSelectHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.SetTextHint = function (Value) {
      if (this.FTextHint !== Value) {
        this.FTextHint = Value;
        this.DoUpdateList();
      };
    };
    this.GetValues = function (AIndex) {
      var Result = "";
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        Result = opt.getAttribute("value");
      };
      return Result;
    };
    this.SetValues = function (AIndex, Value) {
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        opt.setAttribute("value",Value);
      };
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.SetSorted = function (Value) {
      this.FItems.SetSorted(true);
      this.FSorted = Value;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      if (this.FRequiredText !== "") {
        this.GetElementHandle().setCustomValidity("");
      };
      Result = true;
      return Result;
    };
    this.DoHandleInput = function (Event) {
      var Result = false;
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) this.Change();
      Result = true;
      return Result;
    };
    this.DoHandleFocusIn = function (Event) {
      var Result = false;
      if (this.FOnFocusIn != null) this.FOnFocusIn(this);
      Result = true;
      return Result;
    };
    this.DoHandleFocusOut = function (Event) {
      var Result = false;
      if (this.FOnFocusOut != null) this.FOnFocusOut(this);
      Result = true;
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FHandleInputPtr = null;
      this.FHandleInvalidPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInputPtr = rtl.createCallback(this,"DoHandleInput");
      this.FHandleFocusInPtr = rtl.createCallback(this,"DoHandleFocusIn");
      this.FHandleFocusOutPtr = rtl.createCallback(this,"DoHandleFocusOut");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
    };
    this.AddTextHint = function () {
      var opt = null;
      if ((this.FTextHint !== "") && (this.FStyle === $mod.TComboBoxStyle.csDropDownList)) {
        opt = document.createElement("OPTION");
        opt.setAttribute("value","");
        opt.setAttribute("disabled","true");
        opt.setAttribute("selected","true");
        opt.setAttribute("hidden","true");
        opt.innerHTML = this.FTextHint;
        this.GetContainer().appendChild(opt);
      };
    };
    this.DoUpdateList = function () {
      var i = 0;
      var j = 0;
      var s = "";
      var k = "";
      var v = "";
      var opt = null;
      var el = null;
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName === "INPUT") {
        this.GetElementHandle().value = this.GetText();
        el = document.getElementById(this.FName + "_LIST");
        if (el != null) el.parentNode.removeChild(el);
        if (this.FTextHint !== "") this.GetElementHandle().placeholder = this.FTextHint;
        el = document.createElement("DATALIST");
        el.setAttribute("id",this.FListName);
        document.body.appendChild(el);
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          s = this.FItems.Get(i);
          opt = document.createElement("OPTION");
          k = s;
          v = s;
          j = pas.System.Pos(this.FItems.GetNameValueSeparator(),s);
          if (j > 0) {
            v = pas.System.Copy(s,1,j - 1);
            k = pas.System.Copy(s,j + 1,0xFFFF);
          };
          opt.setAttribute("value",k);
          opt.innerHTML = v;
          el.appendChild(opt);
        };
      } else {
        if (this.GetElementHandle().tagName !== "SELECT") return;
        for (var $l1 = this.GetContainer().options.length - 1; $l1 >= 0; $l1--) {
          i = $l1;
          this.GetContainer().remove(i);
        };
        this.AddTextHint();
        for (var $l2 = 0, $end1 = this.FItems.GetCount() - 1; $l2 <= $end1; $l2++) {
          i = $l2;
          s = this.FItems.Get(i);
          opt = document.createElement("OPTION");
          k = s;
          v = s;
          j = pas.System.Pos(this.FItems.GetNameValueSeparator(),s);
          if (j > 0) {
            v = pas.System.Copy(s,1,j - 1);
            k = pas.System.Copy(s,j + 1,0xFFFF);
          };
          opt.setAttribute("value",k);
          opt.innerHTML = v;
          this.GetContainer().appendChild(opt);
        };
      };
      this.UpdateElement();
    };
    this.LoadState = function (AState) {
      var idx = 0;
      var e = 0;
      pas.System.val$6(AState,{get: function () {
          return idx;
        }, set: function (v) {
          idx = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      if (e === 0) this.SetItemIndex(idx);
    };
    this.SaveState = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.GetItemIndex());
      return Result;
    };
    this.GetItemIndex = function () {
      var Result = 0;
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        Result = this.FItems.IndexOf(this.FText);
      } else {
        Result = this.FItemIndex;
        if (this.GetContainer() != null) {
          Result = this.GetContainer().selectedIndex;
          if (this.FTextHint !== "") Result = Result - 1;
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      if (this.FStyle === $mod.TComboBoxStyle.csDropDownList) {
        Result = document.createElement("SELECT")}
       else {
        Result = document.createElement("INPUT");
        this.FListName = this.FName + "_LIST";
        Result.setAttribute("list",this.FListName);
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().addEventListener("input",this.FHandleInputPtr);
        this.GetElementHandle().addEventListener("change",this.FHandleChangePtr);
        this.GetElementHandle().addEventListener("focusin",this.FHandleFocusInPtr);
        this.GetElementHandle().addEventListener("focusout",this.FHandleFocusOutPtr);
        this.GetElementHandle().addEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().removeEventListener("input",this.FHandleInputPtr);
        this.GetElementHandle().removeEventListener("change",this.FHandleChangePtr);
        this.GetElementHandle().removeEventListener("focusin",this.FHandleFocusInPtr);
        this.GetElementHandle().removeEventListener("focusout",this.FHandleFocusOutPtr);
        this.GetElementHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UpdateElementData = function () {
      var d = 0;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.FRequired) {
        this.GetElementHandle().setAttribute("required","")}
       else if (!this.GetIsLinked()) this.GetElementHandle().removeAttribute("required");
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        if (this.GetElementHandle() != null) {
          this.GetElementHandle().value = this.FText;
          this.FListName = this.FName + "_LIST";
          this.GetElementHandle().setAttribute("list",this.FListName);
        };
      } else if (this.GetElementSelectHandle() != null) {
        d = 0;
        if (this.FTextHint !== "") d = 1;
        this.GetElementSelectHandle().selectedIndex = this.FItemIndex + d;
        this.GetElementSelectHandle().setAttribute("role","combobox");
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
    };
    this.UpdateParent = function () {
      pas["WEBLib.Controls"].TControl.UpdateParent.call(this);
      this.DoUpdateList();
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetItemIndex = function (AIndex) {
      if (this.FItemIndex !== AIndex) {
        this.FItemIndex = AIndex;
        if ((AIndex >= 0) && (this.FStyle in rtl.createSet($mod.TComboBoxStyle.csDropDown,$mod.TComboBoxStyle.csDropDownList)) && (AIndex < this.FItems.GetCount())) this.FText = this.FItems.Get(AIndex);
        this.UpdateElement();
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
    };
    this.Change = function () {
      this.FItemIndex = this.GetItemIndex();
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.PersistinHTML = function () {
      var sel = null;
      pas["WEBLib.Controls"].TControl.PersistinHTML.call(this);
      sel = this.GetElementHandle().children.item(this.GetItemIndex());
      if (sel != null) sel.setAttribute("selected","selected");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-select");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FItemIndex = -1;
      this.FStyle = $mod.TComboBoxStyle.csDropDownList;
      this.SetShowFocus(true);
      this.SetHeight(25);
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.FItems.Clear();
    };
    this.AddItem = function (Item, AObject) {
      this.FItems.AddObject(Item,AObject);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TComboBox",this.TCustomComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("OnFocusIn",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnFocusIn","FOnFocusIn");
    $r.addProperty("OnFocusOut",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnFocusOut","FOnFocusOut");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("Style",2,$mod.$rtti["TComboBoxStyle"],"FStyle","SetStyle");
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebComboBox",this.TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TFontPicker",this.TCustomComboBox,function () {
    this.CreateInitialize = function () {
      var $Self = this;
      var tst = false;
      function Add(s) {
        tst = d.detect(s);
        if (tst) $Self.FItems.Add(s);
      };
      $mod.TCustomComboBox.CreateInitialize.call(this);
      var Detector = function() {
          // a font will be compared against all the three default fonts.
          // and if it doesn't match all 3 then that font is not available.
          var baseFonts = ['monospace', 'sans-serif', 'serif'];
      
          //we use m or w because these two characters take up the maximum width.
          // And we use a LLi so that the same matching fonts can get separated
          var testString = "mmmmmmmmmmlli";
      
          //we test using 72px font size, we may use any size. I guess larger the better.
          var testSize = '72px';
      
          var h = document.getElementsByTagName("body")[0];
      
          // create a SPAN in the document to get the width of the text we use to test
          var s = document.createElement("span");
          s.style.fontSize = testSize;
          s.innerHTML = testString;
          var defaultWidth = {};
          var defaultHeight = {};
          for (var index in baseFonts) {
              //get the default width for the three base fonts
              s.style.fontFamily = baseFonts[index];
              h.appendChild(s);
              defaultWidth[baseFonts[index]] = s.offsetWidth; //width for the default font
              defaultHeight[baseFonts[index]] = s.offsetHeight; //height for the defualt font
              h.removeChild(s);
          }
      
          function detect(font) {
              var detected = false;
              for (var index in baseFonts) {
                  s.style.fontFamily = font + ',' + baseFonts[index]; // name of the font along with the base font for fallback.
                  h.appendChild(s);
                  var matched = (s.offsetWidth != defaultWidth[baseFonts[index]] || s.offsetHeight != defaultHeight[baseFonts[index]]);
                  h.removeChild(s);
                  detected = detected || matched;
              }
              return detected;
          }
      
          this.detect = detect;
          };
      
          var d = new Detector();
          //tst = d.detect("Arial");
      Add("Arial");
      Add("Arial Black");
      Add("Arial Narrow");
      Add("Courier");
      Add("Courier New");
      Add("Georgia");
      Add("Lucida Console");
      Add("Modena");
      Add("Monotype Corsiva");
      Add("Papyrus");
      Add("Tahoma");
      Add("Times");
      Add("Times New Roman");
      Add("Trebuchet MS");
      Add("Verdana");
      Add("Verona");
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TWebFontPicker",this.TFontPicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TFontSizePickerMode = {"0": "fmPointSize", fmPointSize: 0, "1": "fmRelativeSize", fmRelativeSize: 1};
  this.$rtti.$Enum("TFontSizePickerMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFontSizePickerMode});
  rtl.createClass(this,"TFontSizePicker",this.TCustomComboBox,function () {
    this.$init = function () {
      $mod.TCustomComboBox.$init.call(this);
      this.FPickerMode = 0;
    };
    this.SetPickerMode = function (AValue) {
      this.FPickerMode = AValue;
      this.Init();
    };
    this.Init = function () {
      this.FItems.Clear();
      var $tmp = this.FPickerMode;
      if ($tmp === $mod.TFontSizePickerMode.fmPointSize) {
        this.FItems.Add("8");
        this.FItems.Add("9");
        this.FItems.Add("10");
        this.FItems.Add("11");
        this.FItems.Add("12");
        this.FItems.Add("14");
        this.FItems.Add("16");
        this.FItems.Add("18");
        this.FItems.Add("20");
        this.FItems.Add("22");
        this.FItems.Add("24");
        this.FItems.Add("26");
        this.FItems.Add("28");
        this.FItems.Add("36");
        this.FItems.Add("48");
        this.FItems.Add("72");
      } else if ($tmp === $mod.TFontSizePickerMode.fmRelativeSize) {
        this.FItems.Add("8");
        this.FItems.Add("9");
        this.FItems.Add("10");
        this.FItems.Add("14");
        this.FItems.Add("18");
        this.FItems.Add("24");
        this.FItems.Add("36");
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomComboBox.CreateInitialize.call(this);
      this.SetPickerMode($mod.TFontSizePickerMode.fmPointSize);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("PickerMode",2,$mod.$rtti["TFontSizePickerMode"],"FPickerMode","SetPickerMode");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TLineSpacingPicker",this.TCustomComboBox,function () {
    this.CreateInitialize = function () {
      $mod.TCustomComboBox.CreateInitialize.call(this);
      this.FItems.Clear();
      this.FItems.Add("1");
      this.FItems.Add("1.5");
      this.FItems.Add("2");
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TWebFontSizePicker",this.TFontSizePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomMemo",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FWordWrap = false;
      this.FBlockChange = false;
      this.FLines = null;
      this.FSelStart = 0;
      this.FSelLength = 0;
      this.FCaretPosition = pas.Types.TPoint.$new();
      this.FAutoSize = false;
      this.FOnChange = null;
      this.FReadOnly = false;
      this.FTextHint = "";
      this.FHandleChangePtr = null;
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleInputPtr = null;
      this.FHandleInvalidPtr = null;
      this.FWantTabs = false;
      this.FAutoCompletion = 0;
      this.FSpellCheck = false;
      this.FModified = false;
      this.FScrollbars = 0;
      this.FRequiredText = "";
      this.FRequired = false;
      this.FMaxLength = 0;
      this.FAllowResize = false;
    };
    this.$final = function () {
      this.FLines = undefined;
      this.FCaretPosition = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      if (this.GetElementInputHandle() != null) {
        this.FBlockChange = true;
        this.FLines.SetTextStr(this.GetElementInputHandle().value);
        this.FBlockChange = false;
      };
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.SetText = function (Value) {
      this.FLines.SetTextStr(Value);
    };
    this.SetSelLength = function (Value) {
      if (this.FSelLength !== Value) {
        this.FSelLength = Value;
        this.UpdateElement();
      };
    };
    this.SetSelStart = function (Value) {
      if (this.FSelStart !== Value) {
        this.FSelStart = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoSize = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateElement();
      };
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        this.UpdateElement();
      };
    };
    this.GetSelLength = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionEnd - this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.GetSelStart = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.SetTextHint = function (Value) {
      if (this.FTextHint !== Value) {
        this.FTextHint = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoCompletion = function (Value) {
      if (this.FAutoCompletion !== Value) {
        this.FAutoCompletion = Value;
        this.UpdateElementData();
      };
    };
    this.SetSpellCheck = function (Value) {
      if (this.FSpellCheck !== Value) {
        this.FSpellCheck = Value;
        this.UpdateElement();
      };
    };
    this.SetWantTabs = function (Value) {
      if (this.FWantTabs !== Value) {
        this.FWantTabs = Value;
        this.UpdateElement();
      };
    };
    this.SetWordWrap = function (Value) {
      if (this.FWordWrap !== Value) {
        this.FWordWrap = Value;
        this.UpdateElement();
      };
    };
    this.GetCaretPos = function () {
      var Result = pas.Types.TPoint.$new();
      Result.$assign(this.GetCaret());
      return Result;
    };
    this.SetCaretPos = function (Value) {
      this.SetCaret(Value.x,Value.y);
    };
    this.SetScrollBars = function (Value) {
      if (this.FScrollbars !== Value) {
        this.FScrollbars = Value;
        this.UpdateElement();
      };
    };
    this.GetSelText = function () {
      var Result = "";
      Result = "";
      if (this.GetElementInputHandle() != null) Result = pas.SysUtils.TStringHelper.Substring$1.call({p: this.GetElementInputHandle(), get: function () {
          return this.p.value;
        }, set: function (v) {
          this.p.value = v;
        }},this.GetSelStart(),this.GetSelStart() + this.GetSelLength());
      return Result;
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.SetMaxLength = function (Value) {
      if (this.FMaxLength !== Value) {
        this.FMaxLength = Value;
        this.UpdateElementData();
      };
    };
    this.SetAllowResize = function (Value) {
      if (this.FAllowResize !== Value) {
        this.FAllowResize = Value;
        this.UpdateElement();
      };
    };
    this.IsInputControl = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.HandleDoKeyDown = function (Event) {
      var Result = false;
      var eh = null;
      var AEvent = null;
      AEvent = Event;
      if ((this.GetKeyCode(AEvent.key,true) === 9) && this.FWantTabs) {
        eh = this.GetElementInputHandle();
        var sstart = eh.selectionStart;
              var send = eh.selectionEnd;
        
              eh.value = eh.value.substring(0, sstart) + "\t" +eh.value.substring(send);
              // put caret at right position again
              eh.selectionStart = eh.selectionEnd = sstart + 1;
        
              AEvent.stopPropagation();
              AEvent.preventDefault();
      } else pas["WEBLib.Controls"].TControl.HandleDoKeyDown.apply(this,arguments);
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("TEXTAREA");
      return Result;
    };
    this.DoHandlePaste = function (Event) {
      var Result = false;
      var s = "";
      var clp = false;
      clp = false;
      var clipboardData = Event.clipboardData || window.clipboardData;
      if (clipboardData) {
        s = clipboardData.getData('Text');
        clp = true;
      };
      if (clp && !this.CanPaste(s)) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleCut = function (Event) {
      var Result = false;
      if (!this.CanCut()) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleInput = function (Event) {
      var Result = false;
      this.GetText();
      this.Change();
      if (this.FAutoSize) this.DoAutoSize();
      Result = true;
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.FModified = true;
      this.Change();
      if (this.FRequiredText !== "") {
        this.GetElementInputHandle().setCustomValidity("");
      };
      Result = true;
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementInputHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.PersistinHTML = function () {
      this.GetElementInputHandle().innerHTML = this.FLines.GetTextStr();
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.DoAutoSize = function () {
      var sh = 0;
      var el = null;
      this.GetElementInputHandle().style.setProperty("overflow","hidden");
      this.GetElementInputHandle().style.setProperty("height","auto");
      el = this.GetElementInputHandle();
      sh = el.scrollHeight;
      this.GetElementInputHandle().style.setProperty("height",pas.SysUtils.TIntegerHelper.ToString$1.call({get: function () {
          return sh;
        }, set: function (v) {
          sh = v;
        }}) + "px");
      this.SetHeightInt(sh);
      this.Realign();
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleInputPtr);
        this.GetElementInputHandle().addEventListener("change",this.FHandleChangePtr);
        this.GetElementInputHandle().addEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().addEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().addEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleInputPtr);
        this.GetElementInputHandle().removeEventListener("change",this.FHandleChangePtr);
        this.GetElementInputHandle().removeEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().removeEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UpdateElementData = function () {
      var ss = 0;
      var sl = 0;
      var e = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if ((this.GetElementInputHandle() != null) && !this.FBlockChange) {
        if (this.FRequired) {
          this.GetElementInputHandle().setAttribute("required","")}
         else if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("required");
        this.GetElementInputHandle().value = this.GetDisplayText();
        if (this.GetElementInputHandle().tagName === "TEXTAREA") {
          this.GetElementInputHandle().setSelectionRange(this.GetSelStart(),this.GetSelStart() + this.GetSelLength());
        };
        if (!this.GetIsLinked()) {
          if (!this.FAllowResize) {
            this.GetElementInputHandle().style.setProperty("resize","none")}
           else this.GetElementInputHandle().style.removeProperty("resize");
        };
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FTextHint !== "") this.GetElementInputHandle().placeholder = this.FTextHint;
        if (this.FMaxLength <= 0) {
          this.GetElementInputHandle().removeAttribute("maxLength")}
         else this.GetElementInputHandle().maxLength = this.FMaxLength;
        if (!this.GetIsLinked()) {
          if (this.FAutoCompletion === $mod.TAutoCompletion.acNone) {
            this.GetElementInputHandle().setAttribute("autocomplete","none");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          } else if (this.FAutoCompletion !== $mod.TAutoCompletion.acOff) {
            this.GetElementInputHandle().setAttribute("autocomplete","on");
            if (!this.GetIsLinked()) this.GetElementInputHandle().setAttribute("name",$mod.GetAutoCompletionName(this.FAutoCompletion));
          } else {
            this.GetElementInputHandle().removeAttribute("autocomplete");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          };
          ss = this.FSelStart;
          sl = this.FSelStart + this.FSelLength;
          e = this.GetElementInputHandle();
          setTimeout(function() {
            e.setSelectionRange(ss, sl);
          }, 1);
        };
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if ((this.GetElementInputHandle() != null) && !this.FBlockChange && !this.GetIsLinked()) {
        if (this.FAutoSize) {
          this.GetElementInputHandle().style.setProperty("overflow","hidden");
          this.GetElementInputHandle().style.setProperty("height","auto");
        } else {
          this.GetElementInputHandle().style.setProperty("overflow","auto");
          var $tmp = this.FScrollbars;
          if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssNone) {
            this.GetElementInputHandle().style.setProperty("overflow","hidden");
          } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssVertical) {
            this.GetElementInputHandle().style.removeProperty("overflow");
            this.GetElementInputHandle().style.setProperty("overflow-x","hidden");
            this.GetElementInputHandle().style.setProperty("overflow-y","auto");
          } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssHorizontal) {
            this.GetElementInputHandle().style.removeProperty("overflow");
            this.GetElementInputHandle().style.setProperty("overflow-x","auto");
            this.GetElementInputHandle().style.setProperty("overflow-y","hidden");
          } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssBoth) {
            this.GetElementInputHandle().style.setProperty("overflow","auto");
          };
        };
        this.GetElementInputHandle().style.setProperty("margin","0");
        if ((this.FColor !== -1) && (this.FColor !== 16711422)) {
          this.GetElementInputHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.GetElementInputHandle().style.removeProperty("background-color");
        if (!this.FSpellCheck) {
          this.GetElementInputHandle().setAttribute("spellcheck","false")}
         else if (this.GetElementInputHandle().hasAttribute("spellcheck")) this.GetElementInputHandle().removeAttribute("spellcheck");
        if (!this.FWordWrap) {
          this.GetElementInputHandle().setAttribute("wrap","off")}
         else if (this.GetElementInputHandle().hasAttribute("wrap")) this.GetElementInputHandle().removeAttribute("wrap");
      };
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.UpdateSelection = function () {
      this.FSelStart = this.GetSelStart();
      this.FSelLength = this.GetSelLength();
    };
    this.SetLines = function (ALines) {
      this.FLines.Assign(ALines);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FHandleInputPtr = null;
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleInvalidPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInputPtr = rtl.createCallback(this,"DoHandleInput");
      this.FHandlePastePtr = rtl.createCallback(this,"DoHandlePaste");
      this.FHandleCutPtr = rtl.createCallback(this,"DoHandleCut");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
    };
    this.DoLinesChange = function (Sender) {
      if ((this.GetElementInputHandle() != null) && !this.FBlockChange) {
        this.GetElementInputHandle().value = this.GetDisplayText();
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
      };
    };
    this.CanPaste = function (AValue) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CanCut = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.SaveState = function () {
      var Result = "";
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.LoadState = function (AState) {
      this.FLines.SetTextStr(AState);
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.SetCaret = function (x, y) {
      var i = 0;
      var l = 0;
      l = 0;
      for (var $l = 0, $end = this.FLines.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (i < y) l = l + this.FLines.Get(i).length + 1;
      };
      this.SetSelStart(l + x);
    };
    this.GetCaret = function () {
      var Result = pas.Types.TPoint.$new();
      var l = 0;
      var i = 0;
      var ll = 0;
      var tl = 0;
      var ss = 0;
      l = 0;
      tl = 0;
      ss = this.GetSelStart();
      for (var $l = 0, $end = this.FLines.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        ll = this.FLines.Get(i).length + 1;
        if (ss > (tl + ll)) {
          l += 1;
          tl = tl + ll;
        } else {
          break;
        };
      };
      Result.x = ss - tl;
      Result.y = l;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FSpellCheck = true;
      this.FLines = pas.Classes.TStringList.$create("Create$1");
      this.FLines.SetSkipLastLineBreak(true);
      this.FLines.FOnChange = rtl.createCallback(this,"DoLinesChange");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
      this.SetShowFocus(true);
      this.SetClipChildren(false);
      this.FWantTabs = false;
      this.FAutoSize = false;
      this.FMaxLength = 0;
      this.FAutoCompletion = $mod.TAutoCompletion.acOff;
      this.FWordWrap = true;
      this.FScrollbars = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      this.FNoUserSelect = false;
    };
    this.Destroy = function () {
      rtl.free(this,"FLines");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.FLines.Clear();
    };
    this.SelectAll = function () {
      if (this.GetElementInputHandle() != null) this.GetElementInputHandle().select();
    };
    this.CopyToClipboard = function () {
      var s = "";
      s = this.GetText();
      navigator.clipboard.writeText(s);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.ScrollBy = function (DeltaX, DeltaY) {
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().scrollTop = this.GetElementHandle().scrollTop + DeltaY;
        this.GetElementHandle().scrollLeft = this.GetElementHandle().scrollLeft + DeltaX;
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TMemo",this.TCustomMemo,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize");
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Lines",2,pas.Classes.$rtti["TStrings"],"FLines","SetLines");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength");
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",4,{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly");
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("SelStart",3,rtl.longint,"GetSelStart","SetSelStart");
    $r.addProperty("SelLength",3,rtl.longint,"GetSelLength","SetSelLength");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("Spellcheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebMemo",this.TMemo,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TControlGroup",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FControls$1 = null;
      this.FOldCount = 0;
      this.FColumns = 0;
      this.FItems = null;
      this.FOnChange = null;
      this.FElementButtonClassName = "";
      this.FElementLabelClassName = "";
      this.FElementGroupClassName = "";
      this.FControlPosition = 0;
      this.FElementLegendClassName = "";
    };
    this.$final = function () {
      this.FControls$1 = undefined;
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetControlPosition = function (Value) {
      if (this.FControlPosition !== Value) {
        this.FControlPosition = Value;
        this.DoUpdateList();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      var legend = null;
      Result = document.createElement("FIELDSET");
      legend = document.createElement("LEGEND");
      Result.appendChild(legend);
      legend.innerHTML = this.FCaption;
      legend.setAttribute("class","w-auto " + this.FElementLegendClassName);
      if (this.FCaption === "") {
        legend.style.setProperty("display","none")}
       else legend.style.setProperty("display","");
      legend.style.setProperty("float","none");
      Result.style.setProperty("display","inline-block");
      Result.style.setProperty("-webkit-padding-before","0px");
      Result.style.setProperty("-webkit-padding-after","0px");
      Result.style.setProperty("-webkit-padding-end","0px");
      Result.style.setProperty("-webkit-padding-start","0px");
      Result.style.setProperty("border","1px");
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.DoHandleClick = function (AControl) {
      this.Change();
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.DoControlClick = function (Sender) {
      this.DoHandleClick(rtl.as(Sender,pas["WEBLib.Controls"].TCustomControl));
    };
    this.SetCaption = function (AValue) {
      var el = null;
      pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
      if (!(this.GetContainer() != null)) return;
      el = this.GetContainer().firstElementChild;
      if (el != null) {
        el.innerHTML = AValue;
        if (AValue === "") {
          el.style.setProperty("display","none")}
         else el.style.setProperty("display","");
      };
    };
    this.SetColumns = function (AValue) {
      if ((this.FColumns > 0) && (this.FColumns !== AValue)) {
        this.FColumns = AValue;
        this.DoUpdateList();
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
      this.DoUpdateList();
    };
    this.DoUpdateList = function () {
      var i = 0;
      var s = "";
      var rd = null;
      var dx = 0;
      var dy = 0;
      var dc = 0;
      var col = 0;
      var row = 0;
      var ypos = 0;
      var legend = null;
      var chk = [];
      if (!(this.GetContainer() != null)) return;
      if (this.FItems.GetCount() === 0) return;
      dy = Math.round(this.FFont.FSize * 2.5);
      dx = rtl.trunc(this.GetWidth() / this.FColumns);
      if (this.FCaption !== "") {
        dc = this.FFont.FSize}
       else dc = 4;
      col = 0;
      row = 0;
      if (this.FOldCount > 0) chk = rtl.arraySetLength(chk,false,this.FOldCount);
      for (var $l = 0, $end = this.FOldCount - 1; $l <= $end; $l++) {
        i = $l;
        rd = rtl.getObject(this.FControls$1.Get(i));
        if ($mod.TRadioButton.isPrototypeOf(rd)) chk[i] = rtl.as(rd,$mod.TRadioButton).GetChecked();
        if ($mod.TCheckBox.isPrototypeOf(rd)) chk[i] = rtl.as(rd,$mod.TCheckBox).GetChecked();
        rd = rtl.freeLoc(rd);
      };
      this.FControls$1.Clear();
      while (this.GetContainer().childElementCount > 0) this.GetContainer().removeChild(this.GetContainer().firstChild);
      if (this.FCaption !== "") {
        legend = document.createElement("LEGEND");
        this.GetElementHandle().appendChild(legend);
        legend.innerHTML = this.FCaption;
        legend.setAttribute("class","w-auto " + this.FElementLegendClassName);
        legend.style.setProperty("float","none");
        pas["WEBLib.Controls"].SetHTMLElementFont(legend,this.FFont,!((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && (this.FElementClassName === "")));
      };
      if (this.FElementGroupClassName !== "") {
        this.GetElementHandle().setAttribute("class",this.FElementGroupClassName)}
       else this.GetElementHandle().setAttribute("class","border p-2");
      this.GetContainer().style.setProperty("margin","0px");
      for (var $l1 = 0, $end1 = this.FItems.GetCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        ypos = dc + (row * dy);
        s = this.FItems.Get(i);
        rd = this.CreateGroupControl(4 + (col * dx),ypos,i,s,this.FControlPosition,this.GetGroupControlState(i),true);
        rd.SetEnabled(this.FEnabled);
        this.FControls$1.Add(rd);
        if (i <= this.FOldCount) {
          if ($mod.TRadioButton.isPrototypeOf(rd)) rtl.as(rd,$mod.TRadioButton).SetChecked(chk[i]);
          if ($mod.TCheckBox.isPrototypeOf(rd)) rtl.as(rd,$mod.TCheckBox).SetChecked(chk[i]);
        };
        if (!this.GetIsLinked()) {
          rd.GetContainer().style.setProperty("float","left");
          rd.GetContainer().style.setProperty("width",pas.SysUtils.IntToStr(pas.System.Trunc(100 / this.FColumns) - 5) + "%");
          if (this.FTabStop) {
            rd.GetContainer().setAttribute("tabindex",pas.SysUtils.TIntegerHelper.ToString$1.call({p: this, get: function () {
                return this.p.FTabOrder;
              }, set: function (v) {
                this.p.FTabOrder = v;
              }}));
            this.GetContainer().setAttribute("tabindex","-1");
          } else rd.GetContainer().setAttribute("tabindex","-1");
        };
        if ((i % this.FColumns) === 0) rd.GetContainer().style.setProperty("clear","left");
        this.GetElementHandle().appendChild(rd.GetContainer());
        if (col < (this.FColumns - 1)) {
          col += 1}
         else {
          col = 0;
          row += 1;
        };
      };
      this.FOldCount = this.FItems.GetCount();
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
    };
    this.FontChanged = function () {
      pas["WEBLib.Controls"].TControl.FontChanged.call(this);
      this.DoUpdateList();
    };
    this.CreateGroupControl = function (ALeft, ATop, AIndex, ACaption, APosition, AState, AEnabled) {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetGroupControlState = function (AIndex) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetGroupControl = function (AIndex) {
      var Result = null;
      Result = rtl.getObject(this.FControls$1.Get(AIndex));
      return Result;
    };
    this.SetEnabled = function (Value) {
      var i = 0;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      for (var $l = 0, $end = this.FControls$1.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        rtl.getObject(this.FControls$1.Get(i)).SetEnabled(Value);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FColumns = 1;
      this.FControls$1 = pas.Classes.TList.$create("Create$1");
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FOldCount = -1;
      this.FControlPosition = pas["WEBLib.Controls"].TElementPosition.epAbsolute;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(200);
        this.SetHeight(200);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FControls$1");
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.SetHeight = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetHeight.apply(this,arguments);
      this.DoUpdateList();
    };
    this.SetWidth = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetWidth.apply(this,arguments);
      this.DoUpdateList();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Columns",2,rtl.longint,"FColumns","SetColumns");
    $r.addProperty("ControlPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FControlPosition","SetControlPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementGroupClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementGroupClassName","FElementGroupClassName");
    $r.addProperty("ElementLabelClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","FElementLabelClassName");
    $r.addProperty("ElementLegendClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLegendClassName","FElementLegendClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TRadioGroup",this.TControlGroup,function () {
    this.$init = function () {
      $mod.TControlGroup.$init.call(this);
      this.FItemIndex = 0;
      this.FOldItemIndex = 0;
    };
    this.DoHandleClick = function (AControl) {
      if (this.GetItemIndex() === this.FOldItemIndex) return;
      this.Change();
      this.FOldItemIndex = this.GetItemIndex();
    };
    this.GetItemIndex = function () {
      var Result = 0;
      var el = null;
      var i = 0;
      Result = this.FItemIndex;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        el = document.getElementById(this.GetID() + pas.SysUtils.IntToStr(i) + "rd");
        if (el != null) {
          if (el.checked) Result = i;
        };
      };
      return Result;
    };
    this.SetItemIndex = function (AIndex) {
      var el = null;
      if ((AIndex === -1) && (this.GetItemIndex() >= 0)) {
        el = document.getElementById(this.GetID() + pas.SysUtils.IntToStr(this.GetItemIndex()) + "rd");
        if (el != null) el.checked = false;
        this.FItemIndex = -1;
      } else {
        this.FItemIndex = AIndex;
        if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
          el = document.getElementById(this.GetID() + pas.SysUtils.IntToStr(AIndex) + "rd");
          if (el != null) el.checked = true;
        };
      };
    };
    this.CreateGroupControl = function (ALeft, ATop, AIndex, ACaption, APosition, AState, AEnabled) {
      var Result = null;
      var rd = null;
      var id = "";
      id = this.GetID();
      if (id === "") id = this.FName;
      rd = $mod.TRadioButton.$create("Create$2",[id + pas.SysUtils.IntToStr(AIndex)]);
      rd.SetElementPosition(APosition);
      rd.SetElementFont(this.FElementFont);
      rd.SetElementClassName(this.FElementClassName);
      rd.FElementButtonClassName = this.FElementButtonClassName;
      rd.FElementLabelClassName = this.FElementLabelClassName;
      rd.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      rd.SetParentFont(false);
      rd.FFont.Assign(this.FFont);
      rd.SetParent(this);
      rd.SetCaption(ACaption);
      rd.SetGroupName(id);
      rd.SetTop(ATop);
      rd.SetLeft(ALeft);
      rd.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      rd.SetWidthPercent(100);
      rd.FOnClick = rtl.createCallback(this,"DoControlClick");
      rd.SetChecked(AState);
      rd.SetEnabled(AEnabled);
      rd.FTag$1 = AIndex;
      rd.SetTabStop(true);
      Result = rd;
      return Result;
    };
    this.GetGroupControlState = function (AIndex) {
      var Result = false;
      Result = AIndex === this.FItemIndex;
      return Result;
    };
    this.LoadState = function (AState) {
      var idx = 0;
      var e = 0;
      pas.System.val$6(AState,{get: function () {
          return idx;
        }, set: function (v) {
          idx = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      if (e === 0) this.SetItemIndex(idx);
    };
    this.SaveState = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.GetItemIndex());
      return Result;
    };
    this.CreateInitialize = function () {
      $mod.TControlGroup.CreateInitialize.call(this);
      this.FItemIndex = -1;
      this.FOldItemIndex = -2;
    };
    this.SetFocus = function () {
      var idx = 0;
      var rd = null;
      if (this.FItems.GetCount() === 0) return;
      idx = this.GetItemIndex();
      if (idx < 0) idx = 0;
      rd = this.GetGroupControl(idx);
      if (rd != null) rd.SetFocus();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex");
  });
  rtl.createClass(this,"TWebRadioGroup",this.TRadioGroup,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TCheckClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AIndex",rtl.longint]]), methodkind: 0});
  rtl.createClass(this,"TCheckGroup",this.TControlGroup,function () {
    this.$init = function () {
      $mod.TControlGroup.$init.call(this);
      this.FOnCheckClick = null;
    };
    this.$final = function () {
      this.FOnCheckClick = undefined;
      $mod.TControlGroup.$final.call(this);
    };
    this.GetChecked = function (AIndex) {
      var Result = false;
      Result = rtl.as(this.GetGroupControl(AIndex),$mod.TCheckBox).GetChecked();
      return Result;
    };
    this.SetChecked = function (AIndex, Value) {
      rtl.as(this.GetGroupControl(AIndex),$mod.TCheckBox).SetChecked(Value);
    };
    this.DoHandleClick = function (AControl) {
      $mod.TControlGroup.DoHandleClick.apply(this,arguments);
      if (this.FOnCheckClick != null) this.FOnCheckClick(this,AControl.FTag$1);
    };
    this.CreateGroupControl = function (ALeft, ATop, AIndex, ACaption, APosition, AState, AEnabled) {
      var Result = null;
      var cb = null;
      var id = "";
      id = this.GetID();
      if (id === "") id = this.FName;
      cb = $mod.TCheckBox.$create("Create$2",[id + pas.SysUtils.IntToStr(AIndex)]);
      cb.SetCaption(ACaption);
      cb.SetElementPosition(APosition);
      cb.SetElementFont(this.FElementFont);
      cb.SetElementClassName(this.FElementClassName);
      cb.FElementButtonClassName = this.FElementButtonClassName;
      cb.FElementLabelClassName = this.FElementLabelClassName;
      cb.SetParentFont(false);
      cb.FFont.Assign(this.FFont);
      cb.SetParent(this);
      cb.SetTop(ATop);
      cb.SetLeft(ALeft);
      cb.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      cb.SetWidthPercent(100);
      cb.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      cb.FOnCheckClick = rtl.createCallback(this,"DoControlClick");
      cb.SetChecked(AState);
      cb.SetEnabled(AEnabled);
      cb.FTag$1 = AIndex;
      cb.SetTabStop(true);
      Result = cb;
      return Result;
    };
    this.GetGroupControlState = function (AIndex) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.SaveState = function () {
      var Result = "";
      var i = 0;
      var s = "";
      s = "";
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetChecked(i)) {
          s = s + ",1"}
         else s = s + ",0";
      };
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Result = s;
      return Result;
    };
    this.LoadState = function (AState) {
      var sl = null;
      var i = 0;
      sl = pas.Classes.TStringList.$create("Create$1");
      sl.SetDelimiter(",");
      sl.SetCommaText(AState);
      for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.SetChecked(i,sl.Get(i) === "1");
      };
      sl = rtl.freeLoc(sl);
    };
    this.CreateInitialize = function () {
      $mod.TControlGroup.CreateInitialize.call(this);
    };
    this.SetFocus = function () {
      var cb = null;
      if (this.FItems.GetCount() > 0) {
        cb = this.GetGroupControl(0);
        if (cb != null) cb.SetFocus();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnCheckClick",0,$mod.$rtti["TCheckClickEvent"],"FOnCheckClick","FOnCheckClick");
  });
  rtl.createClass(this,"TWebCheckGroup",this.TCheckGroup,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TColorPicker",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FColor$1 = 0;
      this.FOnSelect = null;
      this.FHandleChangePtr = null;
    };
    this.$final = function () {
      this.FOnSelect = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.UpdateElementVisual = function () {
      $mod.TCustomInput.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("padding","0px");
        this.GetElementHandle().style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth() - 2) + "px");
        this.GetElementHandle().style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight() - 2) + "px");
        this.GetElementHandle().style.setProperty("min-width","32px");
      };
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Select();
      Result = true;
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "COLOR";
      return Result;
    };
    this.GetColor = function () {
      var Result = 0;
      Result = this.FColor$1;
      if (this.GetContainer() != null) Result = pas["WEBLib.Graphics"].HexToColor(this.GetContainer().value);
      return Result;
    };
    this.SetColor$1 = function (AValue) {
      this.FColor$1 = AValue;
      if (this.GetContainer() != null) this.GetContainer().value = pas["WEBLib.Graphics"].ColorToHTML(AValue);
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleChangePtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleChangePtr);
      };
    };
    this.Select = function () {
      if (this.FOnSelect != null) this.FOnSelect(this);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("form-control");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FColor$1 = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",3,pas["WEBLib.Graphics"].$rtti["TColor"],"GetColor","SetColor$1");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnSelect",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSelect","FOnSelect");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebColorPicker",this.TColorPicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollBarContent",pas["WEBLib.Controls"].TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollBar",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FScrolling = false;
      this.FPageSizing = false;
      this.FContent = null;
      this.FKind = 0;
      this.FPosition = 0;
      this.FSmallChange = 0;
      this.FMax = 0;
      this.FMin = 0;
      this.FLargeChange = 0;
      this.FPageSize = 0;
      this.FOnChange = null;
      this.FScrollPtr = null;
    };
    this.$final = function () {
      this.FContent = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetKind = function (Value) {
      if (this.FKind !== Value) {
        this.FKind = Value;
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          this.SetBounds(this.GetLeft(),this.GetTop(),this.GetHeight(),17);
        } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
          this.SetBounds(this.GetLeft(),this.GetTop(),17,this.GetWidth());
        };
        this.UpdateElement();
        this.UpdateContent();
      };
    };
    this.SetPosition = function (Value) {
      if (this.FPosition !== Value) {
        this.FPosition = Value;
        this.UpdateContent();
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.SetMax = function (Value) {
      if (this.FMax !== Value) {
        this.FMax = Value;
        this.UpdateContent();
      };
    };
    this.SetMin = function (Value) {
      if (this.FMin !== Value) {
        this.FMin = Value;
        this.UpdateContent();
      };
    };
    this.SetPageSize = function (Value) {
      if (this.FPageSize !== Value) {
        this.FPageSizing = true;
        this.FPageSize = Value;
        this.UpdateContent();
      };
    };
    this.GetPosition = function () {
      var Result = 0;
      Result = 0;
      if (this.GetElement() != null) {
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          Result = Math.round(this.GetValue(this.GetElement().scrollLeft))}
         else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) Result = Math.round(this.GetValue(this.GetElement().scrollTop));
      } else Result = this.FPosition;
      return Result;
    };
    this.GetPageSize = function () {
      var Result = 0;
      Result = this.FPageSize;
      if (Result === 0) Result = 25;
      return Result;
    };
    this.GetValue = function (XYPos) {
      var Result = 0.0;
      Result = 0;
      if (this.FContent != null) {
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          if (this.FContent.GetWidth() > 0) Result = (XYPos / this.FContent.GetWidth()) * (this.FMax - this.FMin);
        } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
          if (this.FContent.GetHeight() > 0) Result = (XYPos / this.FContent.GetHeight()) * (this.FMax - this.FMin);
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.DoScroll = function (Event) {
      var Result = false;
      var p = 0;
      this.FScrolling = true;
      p = this.GetPosition();
      if (!this.FPageSizing && !(p === this.FPosition) && (this.FOnChange != null)) this.FOnChange(this);
      this.FPageSizing = false;
      this.FPosition = p;
      this.FScrolling = false;
      Result = true;
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) this.GetElementHandle().addEventListener("scroll",this.FScrollPtr);
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) this.GetElementHandle().removeEventListener("scroll",this.FScrollPtr);
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("overflow","auto");
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          this.GetElementHandle().style.setProperty("overflow-y","hidden");
          this.GetElementHandle().style.setProperty("overflow-x","");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
          this.GetElementHandle().style.setProperty("overflow-y","");
          this.GetElementHandle().style.setProperty("overflow-x","hidden");
        };
      };
    };
    this.UpdateContent = function () {
      var x = 0;
      var y = 0;
      var w = 0;
      var h = 0;
      var ps = 0;
      var v = 0.0;
      if (!(this.FContent != null) || !(this.GetElementHandle() != null) || this.FScrolling) return;
      ps = this.GetPageSize();
      v = (this.FMax - this.FMin) / ps;
      var $tmp = this.FKind;
      if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
        y = 0;
        h = this.GetHeight();
        w = Math.round(v * this.GetWidth());
        x = Math.round(((this.FPosition - this.FMin) / (this.FMax - this.FMin)) * w);
      } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
        x = 0;
        w = this.GetWidth();
        h = Math.round(v * this.GetHeight());
        y = Math.round(((this.FPosition - this.FMin) / (this.FMax - this.FMin)) * h);
      };
      this.FContent.SetBounds(0,0,w,h);
      this.GetElementHandle().scrollLeft = x;
      this.GetElementHandle().scrollTop = y;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateContent();
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FScrollPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FScrollPtr = rtl.createCallback(this,"DoScroll");
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetTabStop(true);
      this.FKind = pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal;
      this.FPosition = 0;
      this.FMin = 0;
      this.FMax = 100;
      this.FSmallChange = 1;
      this.FLargeChange = 1;
      this.FPageSizing = false;
      this.FContent = $mod.TScrollBarContent.$create("Create$1",[this]);
      this.FContent.SetParent(this);
      this.FContent.SetWidth(121);
      this.FContent.SetHeight(17);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(121);
        this.SetHeight(17);
      };
      this.UpdateContent();
    };
    this.Destroy = function () {
      rtl.free(this,"FContent");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.Controls"].TControl.SetBounds.apply(this,arguments);
      this.UpdateContent();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Kind",2,pas["WEBLib.Controls"].$rtti["TScrollBarKind"],"FKind","SetKind");
    $r.addProperty("Position",3,rtl.longint,"GetPosition","SetPosition");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("SmallChange",0,rtl.longint,"FSmallChange","FSmallChange");
    $r.addProperty("LargeChange",0,rtl.longint,"FLargeChange","FLargeChange");
    $r.addProperty("Max",2,rtl.longint,"FMax","SetMax");
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin");
    $r.addProperty("PageSize",3,rtl.longint,"GetPageSize","SetPageSize");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebScrollBar",this.TScrollBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.GetAutoCompletionName = function (aAutoCompletion) {
    var Result = "";
    var $tmp = aAutoCompletion;
    if ($tmp === $mod.TAutoCompletion.acOff) {
      Result = ""}
     else if ($tmp === $mod.TAutoCompletion.acHonorificPrefix) {
      Result = "honorific-prefix"}
     else if ($tmp === $mod.TAutoCompletion.acGivenName) {
      Result = "given-name"}
     else if ($tmp === $mod.TAutoCompletion.acAdditionalName) {
      Result = "additional-name"}
     else if ($tmp === $mod.TAutoCompletion.acFamilyName) {
      Result = "family-name"}
     else if ($tmp === $mod.TAutoCompletion.acHonorificSuffix) {
      Result = "honorific-suffix"}
     else if ($tmp === $mod.TAutoCompletion.acNickName) {
      Result = "nickname"}
     else if ($tmp === $mod.TAutoCompletion.acEmail) {
      Result = "email"}
     else if ($tmp === $mod.TAutoCompletion.acUserName) {
      Result = "username"}
     else if ($tmp === $mod.TAutoCompletion.acNewPassword) {
      Result = "new-password"}
     else if ($tmp === $mod.TAutoCompletion.acCurrentPassword) {
      Result = "current-password"}
     else if ($tmp === $mod.TAutoCompletion.acOrganizationTitle) {
      Result = "organization-title"}
     else if ($tmp === $mod.TAutoCompletion.acOrganization) {
      Result = "organization"}
     else if ($tmp === $mod.TAutoCompletion.acStreetAddress) {
      Result = "street-address"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLine1) {
      Result = "address-line1"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLine2) {
      Result = "address-line2"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLine3) {
      Result = "address-line3"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel1) {
      Result = "address-level1"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel2) {
      Result = "address-level2"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel3) {
      Result = "address-level3"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel4) {
      Result = "address-level4"}
     else if ($tmp === $mod.TAutoCompletion.acCountry) {
      Result = "country"}
     else if ($tmp === $mod.TAutoCompletion.acCountryName) {
      Result = "country-name"}
     else if ($tmp === $mod.TAutoCompletion.acPostalCode) {
      Result = "postal-code"}
     else if ($tmp === $mod.TAutoCompletion.acCCName) {
      Result = "cc-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCGivenName) {
      Result = "cc-given-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCAdditionalName) {
      Result = "cc-additional-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCFamilyName) {
      Result = "cc-family-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCNumber) {
      Result = "cc-number"}
     else if ($tmp === $mod.TAutoCompletion.acExpiry) {
      Result = "cc-exp"}
     else if ($tmp === $mod.TAutoCompletion.acExpiryMonth) {
      Result = "cc-exp-month"}
     else if ($tmp === $mod.TAutoCompletion.acExpiryYear) {
      Result = "cc-exp-year"}
     else if ($tmp === $mod.TAutoCompletion.acCSC) {
      Result = "cc-csc"}
     else if ($tmp === $mod.TAutoCompletion.acType) {
      Result = "cc-type"}
     else if ($tmp === $mod.TAutoCompletion.acTransactionCurrency) {
      Result = "transaction-currency"}
     else if ($tmp === $mod.TAutoCompletion.acTransactionAmount) {
      Result = "transaction-amount"}
     else if ($tmp === $mod.TAutoCompletion.acLanguage) {
      Result = "language"}
     else if ($tmp === $mod.TAutoCompletion.acBirthday) {
      Result = "bday"}
     else if ($tmp === $mod.TAutoCompletion.acBirthdayDay) {
      Result = "bday-day"}
     else if ($tmp === $mod.TAutoCompletion.acBirthDayMonth) {
      Result = "bday-month"}
     else if ($tmp === $mod.TAutoCompletion.acBirthDayYear) {
      Result = "bday-year"}
     else if ($tmp === $mod.TAutoCompletion.acSex) {
      Result = "sex"}
     else if ($tmp === $mod.TAutoCompletion.acTelephone) {
      Result = "tel"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneCountryCode) {
      Result = "tel-country-code"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneNational) {
      Result = "tel-national"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneAreaCode) {
      Result = "tel-area-code"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneLocal) {
      Result = "tel-local"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneExtension) {
      Result = "tel-extension"}
     else if ($tmp === $mod.TAutoCompletion.acIMPP) {
      Result = "impp"}
     else if ($tmp === $mod.TAutoCompletion.acURL) {
      Result = "url"}
     else if ($tmp === $mod.TAutoCompletion.acPhoto) {
      Result = "photo"}
     else if ($tmp === $mod.TAutoCompletion.acNope) Result = "nope";
    return Result;
  };
});
rtl.module("TimeSpan",["System"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.recNewT(this,"TTimeSpan",function () {
    this.FTicks = 0;
    this.FMinValue = 0;
    this.FMaxValue = 0;
    this.FZero = 0;
    this.cIntLengthShift = 52 - 1;
    this.MillisecondsPerTick = 0.0001;
    this.SecondsPerTick = 1e-7;
    this.MinutesPerTick = 1.6666666666666667E-9;
    this.HoursPerTick = 2.7777777777777777E-11;
    this.DaysPerTick = 1.1574074074074074E-12;
    this.MillisPerSecond = 1000;
    this.MillisPerMinute = 60 * 1000;
    this.MillisPerHour = 60 * 60000;
    this.MillisPerDay = 24 * 3600000;
    this.MaxSeconds = 922337203685;
    this.MinSeconds = -922337203685;
    this.MaxMilliseconds = 922337203685477;
    this.MinMilliseconds = -922337203685477;
    this.TicksPerMillisecond = 10000;
    this.TicksPerSecond = 1000 * 10000;
    this.TicksPerMinute = 60 * 10000000;
    this.TicksPerHour = 60 * 600000000;
    this.TicksPerDay = 24 * 36000000000;
    this.$eq = function (b) {
      return this.FTicks === b.FTicks;
    };
    this.$assign = function (s) {
      this.FTicks = s.FTicks;
      return this;
    };
    this.GetDays = function () {
      var Result = 0;
      Result = rtl.trunc(this.FTicks / 864000000000) & 0xFFFFFFFF;
      return Result;
    };
    this.GetHours = function () {
      var Result = 0;
      Result = (rtl.trunc(this.FTicks / 36000000000) % 24) & 0xFFFFFFFF;
      return Result;
    };
    this.GetMinutes = function () {
      var Result = 0;
      Result = (rtl.trunc(this.FTicks / 600000000) % 60) & 0xFFFFFFFF;
      return Result;
    };
    this.GetSeconds = function () {
      var Result = 0;
      Result = (rtl.trunc(this.FTicks / 10000000) % 60) & 0xFFFFFFFF;
      return Result;
    };
    this.GetMilliseconds = function () {
      var Result = 0;
      Result = (rtl.trunc(this.FTicks / 10000) % 1000) & 0xFFFFFFFF;
      return Result;
    };
    this.GetTotalDays = function () {
      var Result = 0.0;
      Result = this.FTicks * 1.1574074074074074E-12;
      return Result;
    };
    this.GetTotalHours = function () {
      var Result = 0.0;
      Result = this.FTicks * 2.7777777777777777E-11;
      return Result;
    };
    this.GetTotalMinutes = function () {
      var Result = 0.0;
      Result = this.FTicks * 1.6666666666666667E-9;
      return Result;
    };
    this.GetTotalSeconds = function () {
      var Result = 0.0;
      Result = this.FTicks * 1E-7;
      return Result;
    };
    this.GetTotalMilliseconds = function () {
      var Result = 0.0;
      Result = 1E-4;
      Result = this.FTicks * Result;
      if (Result > 922337203685477) {
        Result = 922337203685477}
       else if (Result < -922337203685477) Result = -922337203685477;
      return Result;
    };
    this.GetScaledInterval = function (AValue, AScale) {
      var Result = $mod.TTimeSpan.$new();
      var lNewValue = 0.0;
      if (isNaN(AValue)) throw pas.SysUtils.EArgumentException.$create("Create$1",[rtl.getResStr($mod,"STimespanValueCannotBeNan")]);
      lNewValue = AValue * AScale;
      if (AValue >= 0.0) {
        lNewValue = lNewValue + 0.5}
       else lNewValue = lNewValue - 0.5;
      if ((lNewValue > 922337203685477) || (lNewValue < -922337203685477)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr($mod,"STimespanElementTooLong")]);
      Result.$assign($mod.TTimeSpan.$new().Create(pas.System.Trunc(lNewValue) * 10000));
      return Result;
    };
    this.get_MaxValue = function () {
      var Result = $mod.TTimeSpan.$new();
      Result.FTicks = $mod.TTimeSpan.FMaxValue;
      return Result;
    };
    this.get_MinValue = function () {
      var Result = $mod.TTimeSpan.$new();
      Result.FTicks = $mod.TTimeSpan.FMinValue;
      return Result;
    };
    this.get_Zero = function () {
      var Result = $mod.TTimeSpan.$new();
      Result.FTicks = $mod.TTimeSpan.FZero;
      return Result;
    };
    this.Create = function (ATicks) {
      this.FTicks = ATicks;
      return this;
    };
    this.Create$1 = function (AHours, AMinutes, ASeconds) {
      this.FTicks = (AHours * 3600) + (AMinutes * 60) + ASeconds;
      if ((this.FTicks > 922337203685) || (this.FTicks < -922337203685)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr($mod,"STimespanTooLong")]);
      this.FTicks = this.FTicks * 10000000;
      return this;
    };
    this.Create$2 = function (ADays, AHours, AMinutes, ASeconds) {
      this.Create$3(ADays,AHours,AMinutes,ASeconds,0);
      return this;
    };
    this.Create$3 = function (ADays, AHours, AMinutes, ASeconds, AMilliseconds) {
      var lTicks = 0;
      lTicks = (((ADays * 86400) + (AHours * 3600) + (AMinutes * 60) + ASeconds) * 1000) + AMilliseconds;
      if ((lTicks > 922337203685477) || (lTicks < -922337203685477)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr($mod,"STimespanTooLong")]);
      this.FTicks = lTicks * 10000;
      return this;
    };
    this.Add = function (ATimeSpan) {
      var Result = $mod.TTimeSpan.$new();
      var lNewTicks = 0;
      lNewTicks = this.FTicks + ATimeSpan.FTicks;
      if ((Math.floor(this.FTicks / 2251799813685248) === Math.floor(ATimeSpan.FTicks / 2251799813685248)) && (Math.floor(this.FTicks / 2251799813685248) !== Math.floor(lNewTicks / 2251799813685248))) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr($mod,"STimespanTooLong")]);
      Result.$assign($mod.TTimeSpan.$new().Create(lNewTicks));
      return Result;
    };
    this.Duration = function () {
      var Result = $mod.TTimeSpan.$new();
      if (this.FTicks === this.get_MinValue().FTicks) throw pas.SysUtils.EIntOverflow.$create("Create$1",[rtl.getResStr($mod,"SInvalidTimespanDuration")]);
      if (this.FTicks < 0) {
        Result.$assign($mod.TTimeSpan.$new().Create(-this.FTicks))}
       else Result.$assign($mod.TTimeSpan.$new().Create(this.FTicks));
      return Result;
    };
    this.Negate = function () {
      var Result = $mod.TTimeSpan.$new();
      if (this.FTicks === this.get_MinValue().FTicks) throw pas.SysUtils.EIntOverflow.$create("Create$1",[rtl.getResStr($mod,"SCannotNegateTimespan")]);
      Result.$assign($mod.TTimeSpan.$new().Create(-this.FTicks));
      return Result;
    };
    this.Subtract = function (ATimeSpan) {
      var Result = $mod.TTimeSpan.$new();
      var lNewTicks = 0;
      lNewTicks = this.FTicks - ATimeSpan.FTicks;
      if ((Math.floor(this.FTicks / 2251799813685248) !== Math.floor(ATimeSpan.FTicks / 2251799813685248)) && (Math.floor(this.FTicks / 2251799813685248) !== Math.floor(lNewTicks / 2251799813685248))) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr($mod,"STimespanTooLong")]);
      Result.$assign($mod.TTimeSpan.$new().Create(lNewTicks));
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      var lFormat = "";
      var lDays = 0;
      var lSecondTicks = 0;
      var lTicks = 0;
      lFormat = "%1:.2d:%2:.2d:%3:.2d";
      lDays = rtl.trunc(this.FTicks / 864000000000);
      lTicks = this.FTicks % 864000000000;
      if (this.FTicks < 0) lTicks = -lTicks;
      if (lDays !== 0) lFormat = "%0:d." + lFormat;
      lSecondTicks = lTicks % 10000000;
      if (lSecondTicks !== 0) lFormat = lFormat + ".%4:.7d";
      Result = pas.SysUtils.TStringHelper.Format(lFormat,pas.System.VarRecs(19,lDays,19,rtl.trunc(lTicks / 36000000000) % 24,19,rtl.trunc(lTicks / 600000000) % 60,19,rtl.trunc(lTicks / 10000000) % 60,19,lSecondTicks));
      return Result;
    };
    this.FromDays = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.GetScaledInterval(AValue,86400000));
      return Result;
    };
    this.FromHours = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.GetScaledInterval(AValue,3600000));
      return Result;
    };
    this.FromMinutes = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.GetScaledInterval(AValue,60000));
      return Result;
    };
    this.FromSeconds = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.GetScaledInterval(AValue,1000));
      return Result;
    };
    this.FromMilliseconds = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.GetScaledInterval(AValue,1));
      return Result;
    };
    this.FromTicks = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.$new().Create(AValue));
      return Result;
    };
    this.Subtract$1 = function (ADateTimeLeft, ADateTimeRight) {
      var Result = $mod.TTimeSpan.$new();
      Result.$assign($mod.TTimeSpan.$new().Create(pas.System.Trunc(pas.SysUtils.TimeStampToMSecs(pas.SysUtils.DateTimeToTimeStamp(ADateTimeLeft)) - pas.SysUtils.TimeStampToMSecs(pas.SysUtils.DateTimeToTimeStamp(ADateTimeRight))) * 10000));
      return Result;
    };
    this.Parse = function (AValue) {
      var Result = $mod.TTimeSpan.$new();
      var lParser = $impl.TTimeSpanParser.$new();
      Result.$assign($mod.TTimeSpan.$new().Create(lParser.Convert(AValue)));
      return Result;
    };
    this.TryParse = function (AValue, ATimeSpan) {
      var Result = false;
      var lTicks = 0;
      var lParser = $impl.TTimeSpanParser.$new();
      Result = lParser.TryConvert(AValue,{get: function () {
          return lTicks;
        }, set: function (v) {
          lTicks = v;
        }}) === $impl.TTimeSpanParser.TParseError.peNone;
      if (Result) {
        ATimeSpan.$assign($mod.TTimeSpan.$new().Create(lTicks))}
       else ATimeSpan.$assign($mod.TTimeSpan.get_Zero());
      return Result;
    };
    var $r = $mod.$rtti.$Record("TTimeSpan",{},this);
    $r.addMethod("Create",2,[["ATicks",rtl.nativeint]]);
    $r.addMethod("Create$1",2,[["AHours",rtl.longint,2],["AMinutes",rtl.longint,2],["ASeconds",rtl.longint,2]]);
    $r.addMethod("Create$2",2,[["ADays",rtl.longint,2],["AHours",rtl.longint,2],["AMinutes",rtl.longint,2],["ASeconds",rtl.longint,2]]);
    $r.addMethod("Create$3",2,[["ADays",rtl.longint,2],["AHours",rtl.longint,2],["AMinutes",rtl.longint,2],["ASeconds",rtl.longint,2],["AMilliseconds",rtl.longint,2]]);
    $r.addMethod("Add",1,[["ATimeSpan",$r,2]],2,$r);
    $r.addMethod("Duration",1,[],2,$r);
    $r.addMethod("Negate",1,[],2,$r);
    $r.addMethod("Subtract",1,[["ATimeSpan",$r,2]],2,$r);
    $r.addMethod("ToString",1,[],2,rtl.string);
    $r.addMethod("FromDays",5,[["AValue",rtl.double,2]],2,$r,1);
    $r.addMethod("FromHours",5,[["AValue",rtl.double,2]],2,$r,1);
    $r.addMethod("FromMinutes",5,[["AValue",rtl.double,2]],2,$r,1);
    $r.addMethod("FromSeconds",5,[["AValue",rtl.double,2]],2,$r,1);
    $r.addMethod("FromMilliseconds",5,[["AValue",rtl.double,2]],2,$r,1);
    $r.addMethod("FromTicks",5,[["AValue",rtl.nativeint,2]],2,$r,1);
    $r.addMethod("Subtract$1",5,[["ADateTimeLeft",pas.System.$rtti["TDateTime"],2],["ADateTimeRight",pas.System.$rtti["TDateTime"],2]],2,$r,1);
    $r.addMethod("Parse",5,[["AValue",rtl.string,2]],2,$r,1);
    $r.addMethod("TryParse",5,[["AValue",rtl.string,2],["ATimeSpan",$r,4]],2,rtl.boolean,1);
    $r.addProperty("Ticks",0,rtl.nativeint,"FTicks","",2);
    $r.addProperty("Days",1,rtl.longint,"GetDays","",2);
    $r.addProperty("Hours",1,rtl.longint,"GetHours","",2);
    $r.addProperty("Minutes",1,rtl.longint,"GetMinutes","",2);
    $r.addProperty("Seconds",1,rtl.longint,"GetSeconds","",2);
    $r.addProperty("Milliseconds",1,rtl.longint,"GetMilliseconds","",2);
    $r.addProperty("TotalDays",1,rtl.double,"GetTotalDays","",2);
    $r.addProperty("TotalHours",1,rtl.double,"GetTotalHours","",2);
    $r.addProperty("TotalMinutes",1,rtl.double,"GetTotalMinutes","",2);
    $r.addProperty("TotalSeconds",1,rtl.double,"GetTotalSeconds","",2);
    $r.addProperty("TotalMilliseconds",1,rtl.double,"GetTotalMilliseconds","",2);
    $r.addProperty("MinValue",33,$r,"get_MinValue","",2);
    $r.addProperty("MaxValue",33,$r,"get_MaxValue","",2);
    $r.addProperty("Zero",33,$r,"get_Zero","",2);
  },true);
  $mod.$implcode = function () {
    rtl.recNewT($impl,"TTimeSpanParser",function () {
      this.TParseError = {"0": "peNone", peNone: 0, "1": "peFormat", peFormat: 1, "2": "peOverflow", peOverflow: 2, "3": "peOverflowHMS", peOverflowHMS: 3};
      $mod.$rtti.$Enum("TTimeSpanParser.TParseError",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TParseError});
      this.FStr = "";
      this.FPos = 0;
      this.$eq = function (b) {
        return (this.FStr === b.FStr) && (this.FPos === b.FPos);
      };
      this.$assign = function (s) {
        this.FStr = s.FStr;
        this.FPos = s.FPos;
        return this;
      };
      this.CurrentChar = function () {
        var Result = "\x00";
        if ((this.FPos >= 1) && (this.FPos <= this.FStr.length)) {
          Result = this.FStr.charAt(this.FPos - 1)}
         else Result = "\x00";
        return Result;
      };
      this.NextChar = function () {
        var Result = "\x00";
        if (this.FPos <= this.FStr.length) this.FPos += 1;
        Result = this.CurrentChar();
        return Result;
      };
      this.NextNonDigit = function () {
        var Result = "\x00";
        var lCount = 0;
        for (var $l = this.FPos, $end = this.FStr.length; $l <= $end; $l++) {
          lCount = $l;
          Result = this.FStr.charAt(lCount - 1);
          if ((Result < "0") || (Result > "9")) return Result;
        };
        Result = "\x00";
        return Result;
      };
      this.Convert = function (AValue) {
        var Result = 0;
        Result = 0;
        var $tmp = this.TryConvert(AValue,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
        if ($tmp === $impl.TTimeSpanParser.TParseError.peFormat) {
          throw pas.SysUtils.Exception.$create("Create$1",[rtl.getResStr($mod,"SInvalidTimespanFormat")])}
         else if ($tmp === $impl.TTimeSpanParser.TParseError.peOverflow) {
          throw pas.SysUtils.EIntOverflow.$create("Create$1",[rtl.getResStr($mod,"STimespanTooLong")])}
         else if ($tmp === $impl.TTimeSpanParser.TParseError.peOverflowHMS) throw pas.SysUtils.EIntOverflow.$create("Create$1",[rtl.getResStr($mod,"STimespanElementTooLong")]);
        return Result;
      };
      this.TryConvert = function (AString, AValue) {
        var Result = 0;
        var lDays = 0;
        var lIsNegative = false;
        var lTicks = 0;
        var lTimeVal = 0;
        lTicks = 0;
        AValue.set(0);
        this.FStr = AString;
        this.FPos = 1;
        this.SkipWhite();
        lIsNegative = false;
        if (this.CurrentChar() === "-") {
          lIsNegative = true;
          this.NextChar();
        };
        if (this.NextNonDigit() === ":") {
          Result = this.ConvertTime({get: function () {
              return lTicks;
            }, set: function (v) {
              lTicks = v;
            }});
          if (Result !== $impl.TTimeSpanParser.TParseError.peNone) return Result;
        } else {
          Result = this.NextInt(0xa2e3ff,{get: function () {
              return lDays;
            }, set: function (v) {
              lDays = v;
            }});
          if (Result !== $impl.TTimeSpanParser.TParseError.peNone) return Result;
          lTicks = lDays * 864000000000;
          if (this.CurrentChar() === ".") {
            this.NextChar();
            Result = this.ConvertTime({get: function () {
                return lTimeVal;
              }, set: function (v) {
                lTimeVal = v;
              }});
            if (Result !== $impl.TTimeSpanParser.TParseError.peNone) return Result;
            lTicks = lTicks + lTimeVal;
          };
        };
        if (lIsNegative) {
          lTicks = -lTicks;
          if (lTicks > 0) return $impl.TTimeSpanParser.TParseError.peOverflow;
        } else if (lTicks < 0) return $impl.TTimeSpanParser.TParseError.peOverflow;
        this.SkipWhite();
        if (this.FPos <= this.FStr.length) return $impl.TTimeSpanParser.TParseError.peFormat;
        AValue.set(lTicks);
        Result = $impl.TTimeSpanParser.TParseError.peNone;
        return Result;
      };
      this.NextInt = function (AMaxValue, AValue) {
        var Result = 0;
        var lChar = "\x00";
        var lStartPos = 0;
        AValue.set(0);
        lStartPos = this.FPos;
        lChar = this.CurrentChar();
        while ((lChar >= "0") && (lChar <= "9")) {
          if ((AValue.get() & 0xF0000000) !== 0) return $impl.TTimeSpanParser.TParseError.peOverflow;
          AValue.set((AValue.get() * 10) + (lChar.charCodeAt() - 0x30));
          if (AValue.get() < 0) return $impl.TTimeSpanParser.TParseError.peOverflow;
          lChar = this.NextChar();
        };
        if (this.FPos === lStartPos) return $impl.TTimeSpanParser.TParseError.peFormat;
        if (AValue.get() > AMaxValue) return $impl.TTimeSpanParser.TParseError.peOverflow;
        Result = $impl.TTimeSpanParser.TParseError.peNone;
        return Result;
      };
      this.ConvertTime = function (ATime) {
        var Result = 0;
        var lChar = "\x00";
        var lPart = 0;
        ATime.set(0);
        Result = this.NextInt(23,{get: function () {
            return lPart;
          }, set: function (v) {
            lPart = v;
          }});
        if (Result !== $impl.TTimeSpanParser.TParseError.peNone) {
          if (Result === $impl.TTimeSpanParser.TParseError.peOverflow) Result = $impl.TTimeSpanParser.TParseError.peOverflowHMS;
          return Result;
        };
        ATime.set(lPart * 36000000000);
        if (this.CurrentChar() !== ":") return $impl.TTimeSpanParser.TParseError.peFormat;
        this.NextChar();
        Result = this.NextInt(59,{get: function () {
            return lPart;
          }, set: function (v) {
            lPart = v;
          }});
        if (Result !== $impl.TTimeSpanParser.TParseError.peNone) {
          if (Result === $impl.TTimeSpanParser.TParseError.peOverflow) Result = $impl.TTimeSpanParser.TParseError.peOverflowHMS;
          return Result;
        };
        ATime.set(ATime.get() + (lPart * 600000000));
        if (this.CurrentChar() === ":") {
          if (this.NextChar() !== ".") {
            Result = this.NextInt(59,{get: function () {
                return lPart;
              }, set: function (v) {
                lPart = v;
              }});
            if (Result !== $impl.TTimeSpanParser.TParseError.peNone) {
              if (Result === $impl.TTimeSpanParser.TParseError.peOverflow) Result = $impl.TTimeSpanParser.TParseError.peOverflowHMS;
              return Result;
            };
            ATime.set(ATime.get() + (lPart * 10000000));
          };
          if (this.CurrentChar() === ".") {
            lChar = this.NextChar();
            lPart = 10000000;
            while ((lPart > 1) && (lChar >= "0") && (lChar <= "9")) {
              lPart = rtl.trunc(lPart / 10);
              ATime.set(ATime.get() + ((lChar.charCodeAt() - 0x30) * lPart));
              lChar = this.NextChar();
            };
          };
        };
        Result = $impl.TTimeSpanParser.TParseError.peNone;
        return Result;
      };
      this.SkipWhite = function () {
        var lChar = "\x00";
        lChar = this.CurrentChar();
        while ((lChar === " ") || (lChar === "\t")) lChar = this.NextChar();
      };
      var $r = $mod.$rtti.$Record("TTimeSpanParser",{},this);
      $r.addMethod("CurrentChar",1,[],2,rtl.char);
      $r.addMethod("NextChar",1,[],2,rtl.char);
      $r.addMethod("NextNonDigit",1,[],2,rtl.char);
      $r.addMethod("Convert",1,[["AValue",rtl.string,2]],2,rtl.nativeint);
      $r.addMethod("TryConvert",1,[["AString",rtl.string,2],["AValue",rtl.nativeint,4]],2,$mod.$rtti["TTimeSpanParser.TParseError"]);
      $r.addMethod("NextInt",1,[["AMaxValue",rtl.longint],["AValue",rtl.longint,4]],2,$mod.$rtti["TTimeSpanParser.TParseError"]);
      $r.addMethod("ConvertTime",1,[["ATime",rtl.nativeint,4]],2,$mod.$rtti["TTimeSpanParser.TParseError"]);
      $r.addMethod("SkipWhite",0,[]);
    });
    $mod.$resourcestrings = {SCannotNegateTimespan: {org: "Negating the minimum value of a Timespan is invalid"}, SInvalidTimespanDuration: {org: "The duration cannot be returned because the absolute value exceeds the value of TTimeSpan.MaxValue"}, SInvalidTimespanFormat: {org: "Invalid Timespan format"}, STimespanElementTooLong: {org: "Timespan element too long"}, STimespanTooLong: {org: "Timespan too long"}, STimespanValueCannotBeNan: {org: "Value cannot be NaN"}};
  };
  $mod.$init = function () {
    (function () {
      $mod.TTimeSpan.FMinValue = 9007199254740991;
      $mod.TTimeSpan.FMaxValue = -9007199254740991;
    })();
  };
},["SysUtils","Math"]);
rtl.module("Generics.Defaults",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$rtti.$Interface("IComparer<System.Longint>");
  $mod.$rtti.$Interface("IComparer<System.String>");
  $mod.$rtti.$Interface("IComparer<System.TObject>");
  $mod.$rtti.$Interface("IEnumerator<System.TObject>");
  $mod.$rtti.$Interface("IEnumerable<System.TObject>");
  $mod.$rtti.$Interface("IEnumerator<System.String>");
  $mod.$rtti.$Interface("IEnumerable<System.String>");
  $mod.$rtti.$Interface("IEnumerator<System.Longint>");
  $mod.$rtti.$Interface("IEnumerable<System.Longint>");
  $mod.$rtti.$Interface("IComparer<System.Double>");
  $mod.$rtti.$Interface("IEnumerator<System.Double>");
  $mod.$rtti.$Interface("IEnumerable<System.Double>");
  $mod.$rtti.$Interface("IComparer<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Interface("IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Interface("IEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Interface("IComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Interface("IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Interface("IEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Interface("IComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Interface("IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Interface("IEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TDefaultComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TDelegatedComparerEvents<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$Longint","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Compare",1,[["Left",rtl.longint,2],["Right",rtl.longint,2]],2,rtl.longint);
  },"IComparer<System.Longint>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$String","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Compare",1,[["Left",rtl.string,2],["Right",rtl.string,2]],2,rtl.longint);
  },"IComparer<System.String>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$TObject","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Compare",1,[["Left",pas.System.$rtti["TObject"],2],["Right",pas.System.$rtti["TObject"],2]],2,rtl.longint);
  },"IComparer<System.TObject>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$TObject","{8EA8CE58-C397-337B-B088-7563ADDB2494}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCurrent",1,[],2,pas.System.$rtti["TObject"]);
    $r.addMethod("MoveNext",1,[],2,rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,pas.System.$rtti["TObject"],"GetCurrent","",2);
  },"IEnumerator<System.TObject>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$TObject","{E2FFA1CE-C397-3543-95B0-3285A78D1225}",["GetEnumerator"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<System.TObject>"]);
  },"IEnumerable<System.TObject>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$String","{742D446C-82CD-3563-961B-59A5E06F9EFD}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCurrent",1,[],2,rtl.string);
    $r.addMethod("MoveNext",1,[],2,rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,rtl.string,"GetCurrent","",2);
  },"IEnumerator<System.String>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$String","{A2E8B32C-82CD-3E79-8678-FDE8178D1227}",["GetEnumerator"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<System.String>"]);
  },"IEnumerable<System.String>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$Longint","{BE4D2658-C397-337B-B088-7563ADDB2523}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCurrent",1,[],2,rtl.longint);
    $r.addMethod("MoveNext",1,[],2,rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,rtl.longint,"GetCurrent","",2);
  },"IEnumerator<System.Longint>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$Longint","{12A3F9CE-C397-3543-95B0-3285A78D12B5}",["GetEnumerator"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<System.Longint>"]);
  },"IEnumerable<System.Longint>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$Double","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Compare",1,[["Left",rtl.double,2],["Right",rtl.double,2]],2,rtl.longint);
  },"IComparer<System.Double>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$Double","{FF4B346C-82CD-3563-961B-59A5E06F9D0A}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCurrent",1,[],2,rtl.double);
    $r.addMethod("MoveNext",1,[],2,rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,rtl.double,"GetCurrent","",2);
  },"IEnumerator<System.Double>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$Double","{2D06A32C-82CD-3E79-8678-FDE8178D1135}",["GetEnumerator"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<System.Double>"]);
  },"IEnumerable<System.Double>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$TTMSFNCObjectReference","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("Compare",1,[["Left",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"],2],["Right",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"],2]],2,rtl.longint);
    };
  },"IComparer<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$TTMSFNCObjectReference","{CB4FB947-4FC0-3EE9-9891-10C2A41DEFE5}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("GetCurrent",1,[],2,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"]);
      $r.addMethod("MoveNext",1,[],2,rtl.boolean);
      $r.addMethod("Reset",0,[]);
      $r.addProperty("Current",1,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"],"GetCurrent","",2);
    };
  },"IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$TTMSFNCObjectReference","{DC1D42A4-DB4C-3D87-B7B7-10D0EACDFDCD}",["GetEnumerator"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>"]);
    };
  },"IEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("Compare",1,[["Left",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],2],["Right",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],2]],2,rtl.longint);
    };
  },"IComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty","{138FCA5C-B9E0-37F6-AF5B-9FFF0B2C092C}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("GetCurrent",1,[],2,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"]);
      $r.addMethod("MoveNext",1,[],2,rtl.boolean);
      $r.addMethod("Reset",0,[]);
      $r.addProperty("Current",1,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],"GetCurrent","",2);
    };
  },"IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty","{146E5B59-9457-309F-8A6E-5AFF0B2DEE87}",["GetEnumerator"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>"]);
    };
  },"IEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createInterface(this,"IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassItem","{505778ED-F783-4456-9691-32F419CC5E18}",["Compare"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("Compare",1,[["Left",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"],2],["Right",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"],2]],2,rtl.longint);
    };
  },"IComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createInterface(this,"IEnumerator$$$G$$generics$defaults$$TTMSFNCJSONToClassItem","{53D75BB4-08C5-3F79-9891-10C2A41DED26}",["GetCurrent","MoveNext","Reset"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("GetCurrent",1,[],2,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"]);
      $r.addMethod("MoveNext",1,[],2,rtl.boolean);
      $r.addMethod("Reset",0,[]);
      $r.addProperty("Current",1,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"],"GetCurrent","",2);
    };
  },"IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createInterface(this,"IEnumerable$$$G$$generics$defaults$$TTMSFNCJSONToClassItem","{64A4E411-9450-3E17-B7B7-10D0EACDFB0E}",["GetEnumerator"],pas.System.IUnknown,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $r.addMethod("GetEnumerator",1,[],2,$mod.$rtti["IEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>"]);
    };
  },"IEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  this.$rtti.$RefToProcVar("TOnComparison<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>",{init: function () {
      this.procsig = rtl.newTIProcSig([["Left",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],2],["Right",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],2]],rtl.longint);
    }});
  rtl.createClass(this,"TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty",pas.System.TInterfacedObject,function () {
    this.$initSpec = function () {
      this.DefaultComparer = null;
    };
    this.Default = function () {
      var Result = null;
      var $ok = false;
      try {
        if ($mod.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.DefaultComparer === null) $mod.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.DefaultComparer = $mod.TDefaultComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$create("Create");
        Result = rtl.setIntfL(Result,rtl.queryIntfT($mod.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.DefaultComparer,$mod.IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty),true);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.Construct = function (AComparison) {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,rtl.queryIntfT($mod.TDelegatedComparerEvents$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$create("Create$1",[AComparison]),$mod.IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty),true);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    rtl.addIntf(this,$mod.IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty);
    rtl.addIntf(this,pas.System.IUnknown);
  },"TComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TDefaultComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty",this.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
    };
    this.Compare = function (ALeft, ARight) {
      var Result = 0;
      if (ALeft < ARight) return -1;
      if (ALeft > ARight) return 1;
      Result = 0;
      if (ALeft === ARight) return Result;
      return Result;
    };
    rtl.addIntf(this,$mod.IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty);
    rtl.addIntf(this,pas.System.IUnknown);
  },"TDefaultComparer<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TDelegatedComparerEvents$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty",this.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$init.call(this);
      this.FComparison = null;
    };
    this.$final = function () {
      this.FComparison = undefined;
      $mod.TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$final.call(this);
    };
    this.Compare = function (ALeft, ARight) {
      var Result = 0;
      Result = this.FComparison(ALeft,ARight);
      return Result;
    };
    this.Create$1 = function (AComparison) {
      pas.System.TObject.Create.call(this);
      this.FComparison = AComparison;
      return this;
    };
    rtl.addIntf(this,$mod.IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty);
    rtl.addIntf(this,pas.System.IUnknown);
  },"TDelegatedComparerEvents<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
});
rtl.module("Generics.Strings",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$resourcestrings = {SArgumentOutOfRange: {org: "Argument out of range"}};
});
rtl.module("Generics.Collections",["System","Classes","SysUtils","RTLConsts","Types","JS","Generics.Strings","Generics.Defaults"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>>");
  $mod.$rtti.$Class("TEnumerator<System.Longint>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.Double,System.Double>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.Double,System.Double>>");
  $mod.$rtti.$Class("TEnumerable<System.Longint>");
  $mod.$rtti.$Class("TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.String,System.TObject>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.String,System.TObject>>");
  $mod.$rtti.$Class("TEnumerator<System.String>");
  $mod.$rtti.$Class("TEnumerator<System.TObject>");
  $mod.$rtti.$Class("TEnumerable<System.TObject>");
  $mod.$rtti.$Class("TEnumerable<System.String>");
  $mod.$rtti.$Class("TDictionary<System.String,System.TObject>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.Longint,System.TObject>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.Longint,System.TObject>>");
  $mod.$rtti.$Class("TDictionary<System.Longint,System.TObject>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.Longint,System.Longint>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.Longint,System.Longint>>");
  $mod.$rtti.$Class("TDictionary<System.Longint,System.Longint>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.Longint,System.Boolean>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.Longint,System.Boolean>>");
  $mod.$rtti.$Class("TEnumerator<System.Boolean>");
  $mod.$rtti.$Class("TEnumerable<System.Boolean>");
  $mod.$rtti.$Class("TDictionary<System.Longint,System.Boolean>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.Longint,System.Double>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.Longint,System.Double>>");
  $mod.$rtti.$Class("TEnumerator<System.Double>");
  $mod.$rtti.$Class("TEnumerable<System.Double>");
  $mod.$rtti.$Class("TDictionary<System.Longint,System.Double>");
  $mod.$rtti.$Class("TCustomArrayHelper<System.TObject>");
  $mod.$rtti.$Class("TArrayHelper<System.TObject>");
  $mod.$rtti.$Class("TCustomList<System.TObject>");
  $mod.$rtti.$Class("TCustomListEnumerator<System.TObject>");
  $mod.$rtti.$Class("TList<System.TObject>");
  $mod.$rtti.$Class("TObjectList<System.TObject>");
  $mod.$rtti.$Class("TCustomArrayHelper<System.String>");
  $mod.$rtti.$Class("TArrayHelper<System.String>");
  $mod.$rtti.$Class("TCustomList<System.String>");
  $mod.$rtti.$Class("TCustomListEnumerator<System.String>");
  $mod.$rtti.$Class("TList<System.String>");
  $mod.$rtti.$Class("TCustomArrayHelper<System.Longint>");
  $mod.$rtti.$Class("TArrayHelper<System.Longint>");
  $mod.$rtti.$Class("TCustomList<System.Longint>");
  $mod.$rtti.$Class("TCustomListEnumerator<System.Longint>");
  $mod.$rtti.$Class("TList<System.Longint>");
  $mod.$rtti.$Class("TCustomArrayHelper<System.Double>");
  $mod.$rtti.$Class("TArrayHelper<System.Double>");
  $mod.$rtti.$Class("TCustomList<System.Double>");
  $mod.$rtti.$Class("TCustomListEnumerator<System.Double>");
  $mod.$rtti.$Class("TList<System.Double>");
  $mod.$rtti.$Class("TEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TCustomArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TCustomListEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TObjectList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  $mod.$rtti.$Class("TEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TCustomArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TCustomListEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TObjectList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  $mod.$rtti.$Class("TEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TCustomArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TCustomListEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TObjectList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  $mod.$rtti.$Class("TEnumerator<Generics.Collections.TPair<System.String,WEBLib.DesignIntf.TIconData>>");
  $mod.$rtti.$Class("TEnumerable<Generics.Collections.TPair<System.String,WEBLib.DesignIntf.TIconData>>");
  $mod.$rtti.$Class("TEnumerator<WEBLib.DesignIntf.TIconData>");
  $mod.$rtti.$Class("TEnumerable<WEBLib.DesignIntf.TIconData>");
  $mod.$rtti.$Class("TDictionary<System.String,WEBLib.DesignIntf.TIconData>");
  $mod.$rtti.$Class("TObjectDictionary<System.String,WEBLib.DesignIntf.TIconData>");
  this.TCollectionNotification = {"0": "cnAdded", cnAdded: 0, "1": "cnRemoved", cnRemoved: 1, "2": "cnExtracted", cnExtracted: 2};
  this.$rtti.$Enum("TCollectionNotification",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCollectionNotification});
  rtl.recNewT(this,"TBinarySearchResult",function () {
    this.FoundIndex = 0;
    this.CandidateIndex = 0;
    this.CompareResult = 0;
    this.$eq = function (b) {
      return (this.FoundIndex === b.FoundIndex) && (this.CandidateIndex === b.CandidateIndex) && (this.CompareResult === b.CompareResult);
    };
    this.$assign = function (s) {
      this.FoundIndex = s.FoundIndex;
      this.CandidateIndex = s.CandidateIndex;
      this.CompareResult = s.CompareResult;
      return this;
    };
    var $r = $mod.$rtti.$Record("TBinarySearchResult",{},this);
    $r.addField("FoundIndex",rtl.nativeint);
    $r.addField("CandidateIndex",rtl.nativeint);
    $r.addField("CompareResult",rtl.nativeint);
  });
  this.TDirection = {"0": "FromBeginning", FromBeginning: 0, "1": "fromEnd", fromEnd: 1};
  this.$rtti.$Enum("TDirection",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDirection});
  rtl.createClass(this,"EDictionary",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$Generics$Collections$TDictionary$TKey$Generics$Collections$TDictionary$TValue$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$Generics$Collections$TDictionary$TKey$Generics$Collections$TDictionary$TValue$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$TKey$$TValue.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>>");
  this.TDictionaryOwnership = {"0": "doOwnsKeys", doOwnsKeys: 0, "1": "doOwnsValues", doOwnsValues: 1};
  this.$rtti.$Enum("TDictionaryOwnership",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDictionaryOwnership});
  this.$rtti.$Set("TDictionaryOwnerships",{comptype: this.$rtti["TDictionaryOwnership"]});
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$Generics$Collections$TObjectDictionary$TKey$Generics$Collections$TObjectDictionary$TValue$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$Generics$Collections$TObjectDictionary$TKey$Generics$Collections$TObjectDictionary$TValue$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$TKey$$TValue.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$Double$$Double",function () {
    this.Key = 0.0;
    this.Value = 0.0;
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.Double,System.Double>",{},this);
    $r.addField("Key",rtl.double);
    $r.addField("Value",rtl.double);
    $r.addMethod("Create",2,[["AKey",rtl.double,2],["AValue",rtl.double,2]]);
  });
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$",function () {
    this.Key = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Value = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.Key === b.Key) && this.Value.$eq(b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value.$assign(s.Value);
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value.$assign(AValue);
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>",{},this);
    $r.addField("Key",rtl.longint);
    $r.addField("Value",$mod.$rtti["TPair<System.Double,System.Double>"]);
    $r.addMethod("Create",2,[["AKey",rtl.longint,2],["AValue",$mod.$rtti["TPair<System.Double,System.Double>"],2]]);
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$Longint",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<System.Longint>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$Double$System$Double$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.Double,System.Double>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$Double$System$Double$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$Double$$Double.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.Double,System.Double>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$Longint",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<System.Longint>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<System.Longint>",{procsig: rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",rtl.longint,2],["AAction",this.$rtti["TCollectionNotification"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TCollectionNotifyEvent<Generics.Collections.TPair<System.Double,System.Double>>",{procsig: rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TPair<System.Double,System.Double>"],2],["AAction",this.$rtti["TCollectionNotification"]]]), methodkind: 0});
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$",this.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$,function () {
    rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$new();
        var A = [];
        A = this.FVal.value;
        Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$new());
        Result.Create(rtl.trunc(A[0]),rtl.getObject(A[1]));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FIter = ADictionary.FMap.entries();
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>.TPairEnumerator");
    rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0;
        Result = rtl.trunc(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.keys());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>.TKeyEnumerator");
    rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$Double$System$Double$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Double$System$Double$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Double$System$Double$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
        Result.$assign(rtl.getObject(this.FVal.value));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.values());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>.TValueEnumerator");
    rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$TPair$System$Double$System$Double$,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Double$System$Double$.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Double$System$Double$.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = this.DoGetEnumerator();
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        var I = 0;
        var P = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
        Result = rtl.arraySetLength(Result,$mod.TPair$$$G$$generics$collections$$Double$$Double,this.FMap.size);
        var $in = this.GetEnumerator$1();
        try {
          while ($in.MoveNext$1()) {
            P = $in.GetCurrent();
            Result[I].$assign(P);
            I += 1;
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
        return Result;
      };
    },"TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>.TValueCollection");
    rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = this.GetEnumerator$1();
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        Result = $mod.TEnumerable$$$G$$generics$collections$$Longint.ToArray.call(this);
        return Result;
      };
    },"TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>.TKeyCollection");
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = 0;
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = rtl.trunc(v.value);
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result.$assign(rtl.getObject(V));
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(rtl.getObject(V),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,$mod.TPair$$$G$$generics$collections$$Double$$Double.$clone(Value));
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),$mod.TPair$$$G$$generics$collections$$Double$$Double.$clone(Value));
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
      var V = undefined;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result.$assign(rtl.getObject(V));
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$new();
      var K = 0;
      Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,rtl.getObject(this.FMap.get(K)));
        this.FMap.delete(K);
      } else Result.Create(Key,$mod.TPair$$$G$$generics$collections$$Double$$Double.$new());
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = 0;
      var V = $mod.TPair$$$G$$generics$collections$$Double$$Double.$new();
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = rtl.trunc(A[0]);
            V.$assign(rtl.getObject(A[1]));
            this.FMap.delete(K);
            this.PairNotify(K,$mod.TPair$$$G$$generics$collections$$Double$$Double.$clone(V),$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.$assign(rtl.getObject(this.FMap.get(K)));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = 0;
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value.$eq(rtl.getObject(Res.value));
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$Generics$Collections$TPair$System$Double$System$Double$$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$String$$TObject",function () {
    this.Key = "";
    this.Value = null;
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.String,System.TObject>",{},this);
    $r.addField("Key",rtl.string);
    $r.addField("Value",pas.System.$rtti["TObject"]);
    $r.addMethod("Create",2,[["AKey",rtl.string,2],["AValue",pas.System.$rtti["TObject"],2]]);
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$String$System$TObject$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.String,System.TObject>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$String$System$TObject$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$String$$TObject.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.String,System.TObject>>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$String",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<System.String>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TObject",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<System.TObject>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TObject",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<System.TObject>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$String",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<System.String>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<System.String>",{procsig: rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",rtl.string,2],["AAction",this.$rtti["TCollectionNotification"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TCollectionNotifyEvent<System.TObject>",{procsig: rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",pas.System.$rtti["TObject"],2],["AAction",this.$rtti["TCollectionNotification"]]]), methodkind: 0});
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$String$$TObject",this.TEnumerable$$$G$$generics$collections$$TPair$System$String$System$TObject$,function () {
    rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$String$System$TObject$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$String$System$TObject$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$String$System$TObject$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$String$$TObject.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$String$$TObject.$new();
        var A = [];
        A = this.FVal.value;
        Result.$assign($mod.TPair$$$G$$generics$collections$$String$$TObject.$new());
        Result.Create("" + A[0],rtl.getObject(A[1]));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FIter = ADictionary.FMap.entries();
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.String,System.TObject>.TPairEnumerator");
    rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$String,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$String.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$String.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = "";
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = "";
        Result = "" + this.FVal.value;
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.keys());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.String,System.TObject>.TKeyEnumerator");
    rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TObject,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TObject.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TObject.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = null;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = null;
        Result = rtl.getObject(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.values());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.String,System.TObject>.TValueEnumerator");
    rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$TObject,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$TObject.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$TObject.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$String$$TObject.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = this.DoGetEnumerator();
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        var I = 0;
        var P = null;
        Result = rtl.arraySetLength(Result,null,this.FMap.size);
        var $in = this.GetEnumerator$1();
        try {
          while ($in.MoveNext$1()) {
            P = $in.GetCurrent();
            Result[I] = P;
            I += 1;
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
        return Result;
      };
    },"TDictionary<System.String,System.TObject>.TValueCollection");
    rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$String,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$String.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$String.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = this.GetEnumerator$1();
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$String$$TObject.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        Result = $mod.TEnumerable$$$G$$generics$collections$$String.ToArray.call(this);
        return Result;
      };
    },"TDictionary<System.String,System.TObject>.TKeyCollection");
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$String$System$TObject$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$String$System$TObject$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = "";
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = "" + v.value;
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = null;
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result = rtl.getObject(V);
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(rtl.getObject(V),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,Value);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),Value);
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = null;
      var V = undefined;
      var K = "";
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result = rtl.getObject(V);
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$String$$TObject.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$String$$TObject.$new();
      var K = "";
      Result.$assign($mod.TPair$$$G$$generics$collections$$String$$TObject.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,rtl.getObject(this.FMap.get(K)));
        this.FMap.delete(K);
      } else Result.Create(Key,null);
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = "";
      var V = null;
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = "" + A[0];
            V = rtl.getObject(A[1]);
            this.FMap.delete(K);
            this.PairNotify(K,V,$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = "";
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.set(rtl.getObject(this.FMap.get(K)));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = "";
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value === rtl.getObject(Res.value);
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$String$System$TObject$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.String,System.TObject>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$Longint$$TObject",function () {
    this.Key = 0;
    this.Value = null;
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.Longint,System.TObject>",{},this);
    $r.addField("Key",rtl.longint);
    $r.addField("Value",pas.System.$rtti["TObject"]);
    $r.addMethod("Create",2,[["AKey",rtl.longint,2],["AValue",pas.System.$rtti["TObject"],2]]);
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$TObject$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.Longint,System.TObject>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$TObject$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$Longint$$TObject.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.Longint,System.TObject>>");
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$Longint$$TObject",this.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$TObject$,function () {
    rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$TObject$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$TObject$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$TObject$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$TObject.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$TObject.$new();
        var A = [];
        A = this.FVal.value;
        Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$TObject.$new());
        Result.Create(rtl.trunc(A[0]),rtl.getObject(A[1]));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FIter = ADictionary.FMap.entries();
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.TObject>.TPairEnumerator");
    rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0;
        Result = rtl.trunc(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.keys());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.TObject>.TKeyEnumerator");
    rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TObject,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TObject.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TObject.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = null;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = null;
        Result = rtl.getObject(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.values());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.TObject>.TValueEnumerator");
    rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$TObject,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$TObject.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$TObject.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$TObject.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = this.DoGetEnumerator();
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        var I = 0;
        var P = null;
        Result = rtl.arraySetLength(Result,null,this.FMap.size);
        var $in = this.GetEnumerator$1();
        try {
          while ($in.MoveNext$1()) {
            P = $in.GetCurrent();
            Result[I] = P;
            I += 1;
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
        return Result;
      };
    },"TDictionary<System.Longint,System.TObject>.TValueCollection");
    rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = this.GetEnumerator$1();
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$TObject.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        Result = $mod.TEnumerable$$$G$$generics$collections$$Longint.ToArray.call(this);
        return Result;
      };
    },"TDictionary<System.Longint,System.TObject>.TKeyCollection");
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$TObject$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$TObject$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = 0;
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = rtl.trunc(v.value);
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = null;
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result = rtl.getObject(V);
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(rtl.getObject(V),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,Value);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),Value);
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = null;
      var V = undefined;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result = rtl.getObject(V);
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$Longint$$TObject.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$Longint$$TObject.$new();
      var K = 0;
      Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$TObject.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,rtl.getObject(this.FMap.get(K)));
        this.FMap.delete(K);
      } else Result.Create(Key,null);
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = 0;
      var V = null;
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = rtl.trunc(A[0]);
            V = rtl.getObject(A[1]);
            this.FMap.delete(K);
            this.PairNotify(K,V,$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.set(rtl.getObject(this.FMap.get(K)));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = 0;
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value === rtl.getObject(Res.value);
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$TObject$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.Longint,System.TObject>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$Longint$$Longint",function () {
    this.Key = 0;
    this.Value = 0;
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.Longint,System.Longint>",{},this);
    $r.addField("Key",rtl.longint);
    $r.addField("Value",rtl.longint);
    $r.addMethod("Create",2,[["AKey",rtl.longint,2],["AValue",rtl.longint,2]]);
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Longint$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.Longint,System.Longint>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Longint$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$Longint$$Longint.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.Longint,System.Longint>>");
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$Longint$$Longint",this.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Longint$,function () {
    rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Longint$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Longint$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Longint$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Longint.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Longint.$new();
        var A = [];
        A = this.FVal.value;
        Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$Longint.$new());
        Result.Create(rtl.trunc(A[0]),rtl.trunc(A[1]));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FIter = ADictionary.FMap.entries();
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Longint>.TPairEnumerator");
    rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0;
        Result = rtl.trunc(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.keys());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Longint>.TKeyEnumerator");
    rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0;
        Result = rtl.trunc(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.values());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Longint>.TValueEnumerator");
    rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$Longint.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = this.DoGetEnumerator();
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        var I = 0;
        var P = 0;
        Result = rtl.arraySetLength(Result,0,this.FMap.size);
        var $in = this.GetEnumerator$1();
        try {
          while ($in.MoveNext$1()) {
            P = $in.GetCurrent();
            Result[I] = P;
            I += 1;
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
        return Result;
      };
    },"TDictionary<System.Longint,System.Longint>.TValueCollection");
    rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = this.GetEnumerator$1();
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$Longint.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        Result = $mod.TEnumerable$$$G$$generics$collections$$Longint.ToArray.call(this);
        return Result;
      };
    },"TDictionary<System.Longint,System.Longint>.TKeyCollection");
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Longint$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Longint$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = 0;
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = rtl.trunc(v.value);
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = 0;
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result = rtl.trunc(V);
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(rtl.trunc(V),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,Value);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),Value);
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = 0;
      var V = undefined;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result = rtl.trunc(V);
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$Longint$$Longint.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Longint.$new();
      var K = 0;
      Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$Longint.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,rtl.trunc(this.FMap.get(K)));
        this.FMap.delete(K);
      } else Result.Create(Key,-2147483648);
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = 0;
      var V = 0;
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = rtl.trunc(A[0]);
            V = rtl.trunc(A[1]);
            this.FMap.delete(K);
            this.PairNotify(K,V,$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.set(rtl.trunc(this.FMap.get(K)));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = 0;
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value === rtl.trunc(Res.value);
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Longint$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.Longint,System.Longint>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$Longint$$Boolean",function () {
    this.Key = 0;
    this.Value = false;
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.Longint,System.Boolean>",{},this);
    $r.addField("Key",rtl.longint);
    $r.addField("Value",rtl.boolean);
    $r.addMethod("Create",2,[["AKey",rtl.longint,2],["AValue",rtl.boolean,2]]);
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.Longint,System.Boolean>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.Longint,System.Boolean>>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$Boolean",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<System.Boolean>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$Boolean",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<System.Boolean>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<System.Boolean>",{procsig: rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",rtl.boolean,2],["AAction",this.$rtti["TCollectionNotification"]]]), methodkind: 0});
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$Longint$$Boolean",this.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$,function () {
    rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$new();
        var A = [];
        A = this.FVal.value;
        Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$new());
        Result.Create(rtl.trunc(A[0]),!(A[1] == false));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FIter = ADictionary.FMap.entries();
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Boolean>.TPairEnumerator");
    rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0;
        Result = rtl.trunc(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.keys());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Boolean>.TKeyEnumerator");
    rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Boolean,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Boolean.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Boolean.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = false;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = false;
        Result = !(this.FVal.value == false);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.values());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Boolean>.TValueEnumerator");
    rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$Boolean,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Boolean.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Boolean.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$Boolean.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = this.DoGetEnumerator();
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        var I = 0;
        var P = false;
        Result = rtl.arraySetLength(Result,false,this.FMap.size);
        var $in = this.GetEnumerator$1();
        try {
          while ($in.MoveNext$1()) {
            P = $in.GetCurrent();
            Result[I] = P;
            I += 1;
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
        return Result;
      };
    },"TDictionary<System.Longint,System.Boolean>.TValueCollection");
    rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = this.GetEnumerator$1();
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$Boolean.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        Result = $mod.TEnumerable$$$G$$generics$collections$$Longint.ToArray.call(this);
        return Result;
      };
    },"TDictionary<System.Longint,System.Boolean>.TKeyCollection");
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = 0;
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = rtl.trunc(v.value);
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = false;
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result = !(V == false);
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(!(V == false),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,Value);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),Value);
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = false;
      var V = undefined;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result = !(V == false);
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$new();
      var K = 0;
      Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$Boolean.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,!(this.FMap.get(K) == false));
        this.FMap.delete(K);
      } else Result.Create(Key,false);
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = 0;
      var V = false;
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = rtl.trunc(A[0]);
            V = !(A[1] == false);
            this.FMap.delete(K);
            this.PairNotify(K,V,$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.set(!(this.FMap.get(K) == false));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = 0;
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value === !(Res.value == false);
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Boolean$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.Longint,System.Boolean>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$Longint$$Double",function () {
    this.Key = 0;
    this.Value = 0.0;
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPair<System.Longint,System.Double>",{},this);
    $r.addField("Key",rtl.longint);
    $r.addField("Value",rtl.double);
    $r.addMethod("Create",2,[["AKey",rtl.longint,2],["AValue",rtl.double,2]]);
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Double$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.Longint,System.Double>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Double$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$Longint$$Double.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.Longint,System.Double>>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$Double",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<System.Double>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$Double",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<System.Double>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<System.Double>",{procsig: rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",rtl.double,2],["AAction",this.$rtti["TCollectionNotification"]]]), methodkind: 0});
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$Longint$$Double",this.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Double$,function () {
    rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Double$,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Double$.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$TPair$System$Longint$System$Double$.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Double.$new();
        Result.$assign(this.DoGetCurrent());
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Double.$new();
        var A = [];
        A = this.FVal.value;
        Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$Double.$new());
        Result.Create(rtl.trunc(A[0]),rtl.getNumber(A[1]));
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FIter = ADictionary.FMap.entries();
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Double>.TPairEnumerator");
    rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0;
        Result = rtl.trunc(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.keys());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Double>.TKeyEnumerator");
    rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$Double,function () {
      this.$init = function () {
        $mod.TEnumerator$$$G$$generics$collections$$Double.$init.call(this);
        this.FIter = null;
        this.FVal = null;
      };
      this.$final = function () {
        this.FIter = undefined;
        this.FVal = undefined;
        $mod.TEnumerator$$$G$$generics$collections$$Double.$final.call(this);
      };
      this.GetCurrent = function () {
        var Result = 0.0;
        Result = this.DoGetCurrent();
        return Result;
      };
      this.DoGetCurrent = function () {
        var Result = 0.0;
        Result = rtl.getNumber(this.FVal.value);
        return Result;
      };
      this.DoMoveNext = function () {
        var Result = false;
        this.FVal = this.FIter.next();
        Result = !this.FVal.done;
        return Result;
      };
      this.Create$1 = function (AIter) {
        this.FIter = AIter;
        return this;
      };
      this.Create$2 = function (ADictionary) {
        this.Create$1(ADictionary.FMap.values());
        return this;
      };
      this.MoveNext$1 = function () {
        var Result = false;
        Result = this.DoMoveNext();
        return Result;
      };
    },"TDictionary<System.Longint,System.Double>.TValueEnumerator");
    rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$Double,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Double.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Double.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$Double.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = this.DoGetEnumerator();
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        var I = 0;
        var P = 0.0;
        Result = rtl.arraySetLength(Result,0.0,this.FMap.size);
        var $in = this.GetEnumerator$1();
        try {
          while ($in.MoveNext$1()) {
            P = $in.GetCurrent();
            Result[I] = P;
            I += 1;
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
        return Result;
      };
    },"TDictionary<System.Longint,System.Double>.TValueCollection");
    rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$Longint,function () {
      this.$init = function () {
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
        this.FMap = null;
      };
      this.$final = function () {
        this.FMap = undefined;
        $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
      };
      this.GetCount = function () {
        var Result = 0;
        Result = this.FMap.size;
        return Result;
      };
      this.DoGetEnumerator = function () {
        var Result = null;
        Result = this.GetEnumerator$1();
        return Result;
      };
      this.Create$1 = function (ADictionary) {
        this.FMap = ADictionary.FMap;
        return this;
      };
      this.GetEnumerator$1 = function () {
        var Result = null;
        Result = $mod.TDictionary$$$G$$generics$collections$$Longint$$Double.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
        return Result;
      };
      this.ToArray = function () {
        var Result = [];
        Result = $mod.TEnumerable$$$G$$generics$collections$$Longint.ToArray.call(this);
        return Result;
      };
    },"TDictionary<System.Longint,System.Double>.TKeyCollection");
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Double$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Double$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = 0;
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = rtl.trunc(v.value);
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = 0.0;
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result = rtl.getNumber(V);
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(rtl.getNumber(V),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,Value);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),Value);
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = 0.0;
      var V = undefined;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result = rtl.getNumber(V);
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$Longint$$Double.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$Longint$$Double.$new();
      var K = 0;
      Result.$assign($mod.TPair$$$G$$generics$collections$$Longint$$Double.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,rtl.getNumber(this.FMap.get(K)));
        this.FMap.delete(K);
      } else Result.Create(Key,0.0);
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = 0;
      var V = 0.0;
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = rtl.trunc(A[0]);
            V = rtl.getNumber(A[1]);
            this.FMap.delete(K);
            this.PairNotify(K,V,$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = 0;
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.set(rtl.getNumber(this.FMap.get(K)));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = 0;
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value === rtl.getNumber(Res.value);
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$Longint$System$Double$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.Longint,System.Double>");
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$TObject",pas.System.TObject,function () {
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<System.TObject>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$TObject",this.TCustomArrayHelper$$$G$$generics$collections$$TObject,function () {
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = null;
      var Q = null;
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<System.TObject>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$TObject",this.TEnumerable$$$G$$generics$collections$$TObject,function () {
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TObject.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TObject.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push(null);
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push(null);
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = null;
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TCustomList<System.TObject>.FItems$a",{eltype: pas.System.$rtti["TObject"]});
  },"TCustomList<System.TObject>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$TObject",this.TEnumerator$$$G$$generics$collections$$TObject,function () {
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$TObject.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$TObject.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = null;
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<System.TObject>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$TObject",this.TCustomList$$$G$$generics$collections$$TObject,function () {
    rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$TObject,function () {
    },"TList<System.TObject>.TEnumerator");
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$TObject.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$TObject.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,null,AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = null;
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = null;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = null;
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = null;
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = null;
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = null}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = null;
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = null;
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = null;
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = null;
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$TObject.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$TObject.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TObject.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TObject.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<System.TObject>");
  rtl.createClass(this,"TObjectList$$$G$$generics$collections$$TObject",this.TList$$$G$$generics$collections$$TObject,function () {
    this.$init = function () {
      $mod.TList$$$G$$generics$collections$$TObject.$init.call(this);
      this.FObjectsOwner = false;
    };
    this.Notify = function (aValue, Action) {
      $mod.TCustomList$$$G$$generics$collections$$TObject.Notify.call(this,aValue,Action);
      if (this.FObjectsOwner && (Action === $mod.TCollectionNotification.cnRemoved)) aValue = rtl.freeLoc(aValue);
    };
    this.Create$4 = function (aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TObject.Create$1.call(this);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$5 = function (AComparer, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TObject.Create$2.call(this,AComparer);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$6 = function (aCollection, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TObject.Create$3.call(this,aCollection);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
  },"TObjectList<System.TObject>");
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$String",pas.System.TObject,function () {
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<System.String>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$String",this.TCustomArrayHelper$$$G$$generics$collections$$String,function () {
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = "";
      var Q = "";
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<System.String>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$String",this.TEnumerable$$$G$$generics$collections$$String,function () {
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$String.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$String.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push("");
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push("");
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = "";
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = "";
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TCustomList<System.String>.FItems$a",{eltype: rtl.string});
  },"TCustomList<System.String>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$String",this.TEnumerator$$$G$$generics$collections$$String,function () {
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$String.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$String.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = "";
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = "";
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<System.String>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$String",this.TCustomList$$$G$$generics$collections$$String,function () {
    rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$String,function () {
    },"TList<System.String>.TEnumerator");
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$String.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$String.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,"",AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = "";
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = "";
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = "";
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = "";
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = "";
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = "";
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = "";
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = "";
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = "";
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = "";
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = ""}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = "";
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = "";
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = "";
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = "";
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$String.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$String.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$String.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$String.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<System.String>");
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$Longint",pas.System.TObject,function () {
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<System.Longint>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$Longint",this.TCustomArrayHelper$$$G$$generics$collections$$Longint,function () {
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = 0;
      var Q = 0;
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<System.Longint>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$Longint",this.TEnumerable$$$G$$generics$collections$$Longint,function () {
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$Longint.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$Longint.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push(-2147483648);
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push(-2147483648);
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = 0;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = -2147483648;
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TCustomList<System.Longint>.FItems$a",{eltype: rtl.longint});
  },"TCustomList<System.Longint>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$Longint",this.TEnumerator$$$G$$generics$collections$$Longint,function () {
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$Longint.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$Longint.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = 0;
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = 0;
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<System.Longint>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$Longint",this.TCustomList$$$G$$generics$collections$$Longint,function () {
    rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$Longint,function () {
    },"TList<System.Longint>.TEnumerator");
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$Longint.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$Longint.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,0,AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = 0;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = 0;
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = -2147483648;
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = 0;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = 0;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = 0;
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = 0;
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = -2147483648}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = 0;
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = 0;
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = 0;
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = 0;
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$Longint.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$Longint.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$Longint.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$Longint.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<System.Longint>");
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$Double",pas.System.TObject,function () {
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<System.Double>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$Double",this.TCustomArrayHelper$$$G$$generics$collections$$Double,function () {
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = 0.0;
      var Q = 0.0;
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<System.Double>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$Double",this.TEnumerable$$$G$$generics$collections$$Double,function () {
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$Double.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$Double.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push(0.0);
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push(0.0);
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = 0.0;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = 0.0;
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TCustomList<System.Double>.FItems$a",{eltype: rtl.double});
  },"TCustomList<System.Double>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$Double",this.TEnumerator$$$G$$generics$collections$$Double,function () {
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$Double.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$Double.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = 0.0;
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = 0.0;
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<System.Double>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$Double",this.TCustomList$$$G$$generics$collections$$Double,function () {
    rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$Double,function () {
    },"TList<System.Double>.TEnumerator");
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$Double.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$Double.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,0.0,AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = 0.0;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = 0.0;
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = 0.0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = 0.0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = 0.0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = 0.0;
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = 0.0;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = 0.0;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = 0.0;
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = 0.0;
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = 0.0}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = 0.0;
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = 0.0;
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = 0.0;
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = 0.0;
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$Double.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$Double.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$Double.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$Double.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<System.Double>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TTMSFNCObjectReference",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>",{init: function () {
      this.procsig = rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"],2],["AAction",$mod.$rtti["TCollectionNotification"]]]);
    }, methodkind: 0});
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference",this.TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference,function () {
    this.$initSpec = function () {
    };
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = null;
      var Q = null;
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$TTMSFNCObjectReference",this.TEnumerable$$$G$$generics$collections$$TTMSFNCObjectReference,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $mod.$rtti.$DynArray("TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>.FItems$a",{eltype: pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"]});
    };
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TTMSFNCObjectReference.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TTMSFNCObjectReference.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push(null);
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push(null);
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = null;
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
  },"TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference",this.TEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = null;
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$TTMSFNCObjectReference",this.TCustomList$$$G$$generics$collections$$TTMSFNCObjectReference,function () {
    this.$initSpec = function () {
      rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference,function () {
      },"TList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>.TEnumerator");
    };
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCObjectReference.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCObjectReference.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,null,AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = null;
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = null;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = null;
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = null;
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = null;
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = null}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = null;
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = null;
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = null;
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = null;
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TObjectList$$$G$$generics$collections$$TTMSFNCObjectReference",this.TList$$$G$$generics$collections$$TTMSFNCObjectReference,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TList$$$G$$generics$collections$$TTMSFNCObjectReference.$init.call(this);
      this.FObjectsOwner = false;
    };
    this.Notify = function (aValue, Action) {
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCObjectReference.Notify.call(this,aValue,Action);
      if (this.FObjectsOwner && (Action === $mod.TCollectionNotification.cnRemoved)) aValue = rtl.freeLoc(aValue);
    };
    this.Create$4 = function (aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCObjectReference.Create$1.call(this);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$5 = function (AComparer, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCObjectReference.Create$2.call(this,AComparer);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$6 = function (aCollection, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCObjectReference.Create$3.call(this,aCollection);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
  },"TObjectList<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>",{init: function () {
      this.procsig = rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],2],["AAction",$mod.$rtti["TCollectionNotification"]]]);
    }, methodkind: 0});
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",this.TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
    };
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = null;
      var Q = null;
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",this.TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $mod.$rtti.$DynArray("TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>.FItems$a",{eltype: pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"]});
    };
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push(null);
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push(null);
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = null;
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
  },"TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",this.TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = null;
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",this.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
      rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
      },"TList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>.TEnumerator");
    };
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,null,AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = null;
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = null;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = null;
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = null;
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = null;
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = null}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = null;
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = null;
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = null;
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = null;
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TObjectList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty",this.TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$init.call(this);
      this.FObjectsOwner = false;
    };
    this.Notify = function (aValue, Action) {
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.Notify.call(this,aValue,Action);
      if (this.FObjectsOwner && (Action === $mod.TCollectionNotification.cnRemoved)) aValue = rtl.freeLoc(aValue);
    };
    this.Create$4 = function (aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.Create$1.call(this);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$5 = function (AComparer, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.Create$2.call(this,AComparer);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$6 = function (aCollection, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.Create$3.call(this,aCollection);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
  },"TObjectList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassItem",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>",{init: function () {
      this.procsig = rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"],2],["AAction",$mod.$rtti["TCollectionNotification"]]]);
    }, methodkind: 0});
  rtl.createClass(this,"TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.Sort = function (AValues, AComparer) {
      this.Sort$1(AValues,AComparer,0,rtl.length(AValues.get()));
    };
    this.Sort$1 = function (AValues, AComparer, AIndex, ACount) {
      if (ACount <= 1) return;
      this.QuickSort(AValues,AIndex,(AIndex + ACount) - 1,AComparer);
    };
    this.BinarySearch$2 = function (AValues, AItem, AFoundIndex, AComparer) {
      var Result = false;
      Result = this.BinarySearch$1(AValues,AItem,AFoundIndex,AComparer,0,rtl.length(AValues));
      return Result;
    };
    this.BinarySearch$3 = function (AValues, AItem, ASearchResult, AComparer) {
      var Result = false;
      Result = this.BinarySearch(AValues,AItem,ASearchResult,AComparer,0,rtl.length(AValues));
      return Result;
    };
  },"TCustomArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createClass(this,"TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem",this.TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
    this.$initSpec = function () {
    };
    this.QuickSort = function (AValues, ALeft, ARight, AComparer) {
      var I = 0;
      var J = 0;
      var P = null;
      var Q = null;
      if (((ARight - ALeft) <= 0) || (rtl.length(AValues.get()) === 0)) return;
      do {
        I = ALeft;
        J = ARight;
        P = AValues.get()[ALeft + Math.floor((ARight - ALeft) / 2)];
        do {
          while (AComparer.Compare(AValues.get()[I],P) < 0) I += 1;
          while (AComparer.Compare(AValues.get()[J],P) > 0) J -= 1;
          if (I <= J) {
            if (I !== J) {
              Q = AValues.get()[I];
              AValues.get()[I] = AValues.get()[J];
              AValues.get()[J] = Q;
            };
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if ((J - ALeft) < (ARight - I)) {
          if (ALeft < J) this.QuickSort(AValues,ALeft,J,AComparer);
          ALeft = I;
        } else {
          if (I < ARight) this.QuickSort(AValues,I,ARight,AComparer);
          ARight = J;
        };
      } while (!(ALeft >= ARight));
    };
    this.BinarySearch = function (AValues, AItem, ASearchResult, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var ilo = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      ilo = imid * imid;
      imid = ilo * imid;
      while (imin < imax) {
        imid = rtl.trunc((imax + imin) / 2);
        ASearchResult.CompareResult = AComparer.Compare(AValues[imid],AItem);
        if (ASearchResult.CompareResult < 0) {
          imin = imid + 1}
         else {
          if (ASearchResult.CompareResult === 0) {
            ASearchResult.FoundIndex = imid;
            ASearchResult.CandidateIndex = imid;
            return true;
          };
          imax = imid;
        };
      };
      Result = imax === imin;
      if (Result) {
        ASearchResult.CompareResult = AComparer.Compare(AValues[imin],AItem);
        ASearchResult.CandidateIndex = imin;
        Result = ASearchResult.CompareResult === 0;
        if (Result) {
          ASearchResult.FoundIndex = imin}
         else ASearchResult.FoundIndex = -1;
      } else {
        ASearchResult.CompareResult = 0;
        ASearchResult.FoundIndex = -1;
        ASearchResult.CandidateIndex = -1;
      };
      return Result;
    };
    this.BinarySearch$1 = function (AValues, AItem, AFoundIndex, AComparer, AIndex, ACount) {
      var Result = false;
      var imin = 0;
      var imax = 0;
      var imid = 0;
      var LCompare = 0;
      imin = AIndex;
      imax = (AIndex + ACount) - 1;
      while (imin < imax) {
        imid = rtl.trunc((imin + imax) / 2);
        LCompare = AComparer.Compare(AValues[imid],AItem);
        if (LCompare < 0) {
          imin = imid + 1}
         else {
          if (LCompare === 0) {
            AFoundIndex.set(imid);
            return true;
          };
          imax = imid;
        };
      };
      LCompare = AComparer.Compare(AValues[imin],AItem);
      Result = (imax === imin) && (LCompare === 0);
      if (Result) {
        AFoundIndex.set(imin)}
       else AFoundIndex.set(-1);
      return Result;
    };
  },"TArrayHelper<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createClass(this,"TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassItem",this.TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
    this.$initSpec = function () {
      var $r = this.$rtti;
      $mod.$rtti.$DynArray("TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>.FItems$a",{eltype: pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"]});
    };
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$init.call(this);
      this.FOnNotify = null;
      this.FLength = 0;
      this.FItems = [];
    };
    this.$final = function () {
      this.FOnNotify = undefined;
      this.FItems = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$final.call(this);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FItems);
      return Result;
    };
    this.PrepareAddingItem = function () {
      var Result = 0;
      if (this.FLength === rtl.length(this.FItems)) this.FItems.push(null);
      Result = this.FLength;
      this.FLength += 1;
      return Result;
    };
    this.PrepareAddingRange = function (ACount) {
      var Result = 0;
      var l = 0;
      if (ACount < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (ACount === 0) return this.FLength - 1;
      for (var $l = rtl.length(this.FItems) + 1, $end = this.FLength + ACount; $l <= $end; $l++) {
        l = $l;
        this.FItems.push(null);
      };
      Result = this.FLength;
      this.FLength += ACount;
      return Result;
    };
    this.Notify = function (AValue, ACollectionNotification) {
      if (this.FOnNotify != null) this.FOnNotify(this,AValue,ACollectionNotification);
    };
    this.DoRemove = function (AIndex, ACollectionNotification) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      this.FLength -= 1;
      this.FItems[AIndex] = null;
      this.FItems.splice(AIndex,1);
      this.Notify(Result,ACollectionNotification);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FLength;
      return Result;
    };
  },"TCustomList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createClass(this,"TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem",this.TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$init.call(this);
      this.FList = null;
      this.FIndex = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      $mod.TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$final.call(this);
    };
    this.DoMoveNext = function () {
      var Result = false;
      this.FIndex += 1;
      Result = (this.FList.FLength > 0) && (this.FIndex < this.FList.FLength);
      return Result;
    };
    this.DoGetCurrent = function () {
      var Result = null;
      Result = this.GetCurrent();
      return Result;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FList.FItems[this.FIndex];
      return Result;
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FList = AList;
      return this;
    };
  },"TCustomListEnumerator<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createClass(this,"TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem",this.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
    this.$initSpec = function () {
      rtl.createClass(this,"TEnumerator",$mod.TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
      },"TList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>.TEnumerator");
    };
    this.$init = function () {
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$init.call(this);
      this.FComparer = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FComparer",null);
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$final.call(this);
    };
    this.SameValue = function (Left, Right) {
      var Result = false;
      if (this.FComparer != null) {
        Result = this.FComparer.Compare(Left,Right) === 0}
       else Result = Left === Right;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue < this.FLength) this.SetCount(AValue);
      this.FItems = rtl.arraySetLength(this.FItems,null,AValue);
    };
    this.SetCount = function (AValue) {
      if (AValue < 0) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      if (AValue > this.GetCapacity()) {
        this.SetCapacity(AValue)}
       else if (AValue < this.FLength) this.DeleteRange(AValue,this.FLength - AValue);
      this.FLength = AValue;
    };
    this.InitializeList = function () {
    };
    this.InternalInsert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.FItems.splice(AIndex,0,AValue);
      this.FLength += 1;
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.GetEnumerator$1();
      return Result;
    };
    this.GetItem = function (AIndex) {
      var Result = null;
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Result = this.FItems[AIndex];
      return Result;
    };
    this.SetItem = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.Notify(this.FItems[AIndex],$mod.TCollectionNotification.cnRemoved);
      this.FItems[AIndex] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function () {
      this.InitializeList();
      return this;
    };
    this.Create$2 = function (AComparer) {
      this.InitializeList();
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Create$3 = function (ACollection) {
      var LItem = null;
      this.Create$1();
      var $in = ACollection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LItem = $in.DoGetCurrent();
          this.Add(LItem);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Destroy = function () {
      this.SetCapacity(0);
    };
    this.Add = function (AValue) {
      var Result = 0;
      Result = this.PrepareAddingItem();
      this.FItems[Result] = AValue;
      this.Notify(AValue,$mod.TCollectionNotification.cnAdded);
      return Result;
    };
    this.AddRange = function (AValues) {
      this.InsertRange(this.FLength,AValues);
    };
    this.AddRange$1 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.Add(LValue);
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.AddRange$2 = function (AEnumerable) {
      var LValue = null;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.Add(LValue);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Insert = function (AIndex, AValue) {
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      this.InternalInsert(AIndex,AValue);
    };
    this.InsertRange = function (AIndex, AValues) {
      var LLength = 0;
      var i = 0;
      var LValue = null;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LLength = rtl.length(AValues);
      if (LLength === 0) return;
      if (AIndex !== this.PrepareAddingRange(LLength)) {
        for (var $l = AIndex, $end = this.FLength - LLength - 1; $l <= $end; $l++) {
          i = $l;
          this.FItems[i + LLength] = this.FItems[i];
        };
        for (var $l1 = 0, $end1 = LLength - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FItems[AIndex + i] = null;
        };
      };
      for (var $l2 = 0, $end2 = LLength - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        LValue = AValues[i];
        this.FItems[i + AIndex] = LValue;
        this.Notify(LValue,$mod.TCollectionNotification.cnAdded);
      };
    };
    this.InsertRange$1 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.GetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        rtl._Release($in)
      };
    };
    this.InsertRange$2 = function (AIndex, AEnumerable) {
      var LValue = null;
      var i = 0;
      if ((AIndex < 0) || (AIndex > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      i = 0;
      var $in = AEnumerable.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          LValue = $in.DoGetCurrent();
          this.InternalInsert(AIndex + i,LValue);
          i += 1;
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
    };
    this.Remove = function (AValue) {
      var Result = 0;
      Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.RemoveItem = function (AValue, Direction) {
      var Result = 0;
      if (Direction === $mod.TDirection.fromEnd) {
        Result = this.LastIndexOf(AValue)}
       else Result = this.IndexOf(AValue);
      if (Result >= 0) this.DoRemove(Result,$mod.TCollectionNotification.cnRemoved);
      return Result;
    };
    this.Delete = function (AIndex) {
      this.DoRemove(AIndex,$mod.TCollectionNotification.cnRemoved);
    };
    this.DeleteRange = function (AIndex, ACount) {
      var LDeleted = [];
      var i = 0;
      if (ACount === 0) return;
      if ((ACount < 0) || (AIndex < 0) || ((AIndex + ACount) > this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      LDeleted = this.FItems.splice(AIndex,this.FLength);
      this.FLength -= ACount;
      for (var $l = 0, $end = rtl.length(LDeleted) - 1; $l <= $end; $l++) {
        i = $l;
        this.Notify(LDeleted[i],$mod.TCollectionNotification.cnRemoved);
      };
    };
    this.ExtractIndex = function (AIndex) {
      var Result = null;
      Result = this.DoRemove(AIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Extract = function (AValue) {
      var Result = null;
      var LIndex = 0;
      LIndex = this.IndexOf(AValue);
      if (LIndex < 0) {
        Result = null}
       else Result = this.DoRemove(LIndex,$mod.TCollectionNotification.cnExtracted);
      return Result;
    };
    this.Exchange = function (AIndex1, AIndex2) {
      var LTemp = null;
      LTemp = this.FItems[AIndex1];
      this.FItems[AIndex1] = this.FItems[AIndex2];
      this.FItems[AIndex2] = LTemp;
    };
    this.Move = function (AIndex, ANewIndex) {
      var Arr = null;
      var LTemp = undefined;
      var i = 0;
      if (ANewIndex === AIndex) return;
      if ((ANewIndex < 0) || (ANewIndex >= this.FLength)) throw pas.SysUtils.EArgumentOutOfRangeException.$create("Create$1",[rtl.getResStr(pas["Generics.Strings"],"SArgumentOutOfRange")]);
      Arr = this.FItems;
      LTemp = Arr[AIndex];
      if (AIndex < ANewIndex) {
        for (var $l = AIndex, $end = ANewIndex - 1; $l <= $end; $l++) {
          i = $l;
          Arr[i] = Arr[i + 1];
        }}
       else for (var $l1 = AIndex, $end1 = ANewIndex + 1; $l1 >= $end1; $l1--) {
        i = $l1;
        Arr[i] = Arr[i - 1];
      };
      Arr[ANewIndex] = LTemp;
    };
    this.First = function () {
      var Result = null;
      Result = this.GetItem(0);
      return Result;
    };
    this.Last = function () {
      var Result = null;
      Result = this.GetItem(this.FLength - 1);
      return Result;
    };
    this.Clear = function () {
      this.SetCount(0);
      this.SetCapacity(0);
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = this.IndexOf(AValue) >= 0;
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = 0, $end = this.FLength - 1; $l <= $end; $l++) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      var i = 0;
      for (var $l = this.FLength - 1; $l >= 0; $l--) {
        i = $l;
        if (this.SameValue(AValue,this.FItems[i])) return i;
      };
      Result = -1;
      return Result;
    };
    this.Reverse = function () {
      var a = 0;
      var b = 0;
      var LTemp = null;
      a = 0;
      b = this.FLength - 1;
      while (a < b) {
        LTemp = this.FItems[a];
        this.FItems[a] = this.FItems[b];
        this.FItems[b] = LTemp;
        a += 1;
        b -= 1;
      };
    };
    this.TrimExcess = function () {
      this.SetCapacity(this.FLength);
    };
    this.Sort = function () {
      $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},this.FComparer,0,this.FLength);
    };
    this.Sort$1 = function (AComparer) {
      $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem.Sort$1({p: this, get: function () {
          return this.p.FItems;
        }, set: function (v) {
          this.p.FItems = v;
        }},AComparer,0,this.FLength);
    };
    this.BinarySearch = function (AItem, AIndex) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem.BinarySearch$1(this.FItems,AItem,AIndex,this.FComparer,0,this.FLength);
      return Result;
    };
    this.BinarySearch$1 = function (AItem, AIndex, AComparer) {
      var Result = false;
      Result = $mod.TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem.BinarySearch$1(this.FItems,AItem,AIndex,AComparer,0,this.FLength);
      return Result;
    };
  },"TList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.createClass(this,"TObjectList$$$G$$generics$collections$$TTMSFNCJSONToClassItem",this.TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$init.call(this);
      this.FObjectsOwner = false;
    };
    this.Notify = function (aValue, Action) {
      $mod.TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.Notify.call(this,aValue,Action);
      if (this.FObjectsOwner && (Action === $mod.TCollectionNotification.cnRemoved)) aValue = rtl.freeLoc(aValue);
    };
    this.Create$4 = function (aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.Create$1.call(this);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$5 = function (AComparer, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.Create$2.call(this,AComparer);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
    this.Create$6 = function (aCollection, aOwnsObjects) {
      $mod.TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.Create$3.call(this,aCollection);
      this.FObjectsOwner = aOwnsObjects;
      return this;
    };
  },"TObjectList<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>");
  rtl.recNewT(this,"TPair$$$G$$generics$collections$$String$$TIconData",function () {
    var $r = $mod.$rtti.$Record("TPair<System.String,WEBLib.DesignIntf.TIconData>",{},this);
    this.$initSpec = function () {
      this.Key = "";
      this.Value = null;
      $r.addField("Key",rtl.string);
      $r.addField("Value",pas["WEBLib.DesignIntf"].$rtti["TIconData"]);
      $r.addMethod("Create",2,[["AKey",rtl.string,2],["AValue",pas["WEBLib.DesignIntf"].$rtti["TIconData"],2]]);
    };
    this.$eq = function (b) {
      return (this.Key === b.Key) && (this.Value === b.Value);
    };
    this.$assign = function (s) {
      this.Key = s.Key;
      this.Value = s.Value;
      return this;
    };
    this.Create = function (AKey, AValue) {
      this.Key = AKey;
      this.Value = AValue;
      return this;
    };
  });
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$",pas.System.TObject,function () {
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<Generics.Collections.TPair<System.String,WEBLib.DesignIntf.TIconData>>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$",pas.System.TObject,function () {
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push($mod.TPair$$$G$$generics$collections$$String$$TIconData.$clone(LEnumerator.DoGetCurrent()));
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<Generics.Collections.TPair<System.String,WEBLib.DesignIntf.TIconData>>");
  rtl.createClass(this,"TEnumerator$$$G$$generics$collections$$TIconData",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.MoveNext = function () {
      var Result = false;
      Result = this.DoMoveNext();
      return Result;
    };
  },"TEnumerator<WEBLib.DesignIntf.TIconData>");
  rtl.createClass(this,"TEnumerable$$$G$$generics$collections$$TIconData",pas.System.TObject,function () {
    this.$initSpec = function () {
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = this.DoGetEnumerator();
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      var LEnumerator = null;
      Result = [];
      LEnumerator = this.GetEnumerator();
      try {
        while (LEnumerator.MoveNext()) Result.push(LEnumerator.DoGetCurrent());
      } finally {
        LEnumerator = rtl.freeLoc(LEnumerator);
      };
      return Result;
    };
  },"TEnumerable<WEBLib.DesignIntf.TIconData>");
  this.$rtti.$MethodVar("TCollectionNotifyEvent<WEBLib.DesignIntf.TIconData>",{init: function () {
      this.procsig = rtl.newTIProcSig([["ASender",pas.System.$rtti["TObject"]],["AItem",pas["WEBLib.DesignIntf"].$rtti["TIconData"],2],["AAction",$mod.$rtti["TCollectionNotification"]]]);
    }, methodkind: 0});
  rtl.createClass(this,"TDictionary$$$G$$generics$collections$$String$$TIconData",this.TEnumerable$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$,function () {
    this.$initSpec = function () {
      rtl.createClass(this,"TPairEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$,function () {
        this.$init = function () {
          $mod.TEnumerator$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$.$init.call(this);
          this.FIter = null;
          this.FVal = null;
        };
        this.$final = function () {
          this.FIter = undefined;
          this.FVal = undefined;
          $mod.TEnumerator$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$.$final.call(this);
        };
        this.GetCurrent = function () {
          var Result = $mod.TPair$$$G$$generics$collections$$String$$TIconData.$new();
          Result.$assign(this.DoGetCurrent());
          return Result;
        };
        this.DoGetCurrent = function () {
          var Result = $mod.TPair$$$G$$generics$collections$$String$$TIconData.$new();
          var A = [];
          A = this.FVal.value;
          Result.$assign($mod.TPair$$$G$$generics$collections$$String$$TIconData.$new());
          Result.Create("" + A[0],rtl.getObject(A[1]));
          return Result;
        };
        this.DoMoveNext = function () {
          var Result = false;
          this.FVal = this.FIter.next();
          Result = !this.FVal.done;
          return Result;
        };
        this.Create$1 = function (ADictionary) {
          this.FIter = ADictionary.FMap.entries();
          return this;
        };
        this.MoveNext$1 = function () {
          var Result = false;
          Result = this.DoMoveNext();
          return Result;
        };
      },"TDictionary<System.String,WEBLib.DesignIntf.TIconData>.TPairEnumerator");
      rtl.createClass(this,"TKeyEnumerator",$mod.TEnumerator$$$G$$generics$collections$$String,function () {
        this.$init = function () {
          $mod.TEnumerator$$$G$$generics$collections$$String.$init.call(this);
          this.FIter = null;
          this.FVal = null;
        };
        this.$final = function () {
          this.FIter = undefined;
          this.FVal = undefined;
          $mod.TEnumerator$$$G$$generics$collections$$String.$final.call(this);
        };
        this.GetCurrent = function () {
          var Result = "";
          Result = this.DoGetCurrent();
          return Result;
        };
        this.DoGetCurrent = function () {
          var Result = "";
          Result = "" + this.FVal.value;
          return Result;
        };
        this.DoMoveNext = function () {
          var Result = false;
          this.FVal = this.FIter.next();
          Result = !this.FVal.done;
          return Result;
        };
        this.Create$1 = function (AIter) {
          this.FIter = AIter;
          return this;
        };
        this.Create$2 = function (ADictionary) {
          this.Create$1(ADictionary.FMap.keys());
          return this;
        };
        this.MoveNext$1 = function () {
          var Result = false;
          Result = this.DoMoveNext();
          return Result;
        };
      },"TDictionary<System.String,WEBLib.DesignIntf.TIconData>.TKeyEnumerator");
      rtl.createClass(this,"TValueEnumerator",$mod.TEnumerator$$$G$$generics$collections$$TIconData,function () {
        this.$init = function () {
          $mod.TEnumerator$$$G$$generics$collections$$TIconData.$init.call(this);
          this.FIter = null;
          this.FVal = null;
        };
        this.$final = function () {
          this.FIter = undefined;
          this.FVal = undefined;
          $mod.TEnumerator$$$G$$generics$collections$$TIconData.$final.call(this);
        };
        this.GetCurrent = function () {
          var Result = null;
          Result = this.DoGetCurrent();
          return Result;
        };
        this.DoGetCurrent = function () {
          var Result = null;
          Result = rtl.getObject(this.FVal.value);
          return Result;
        };
        this.DoMoveNext = function () {
          var Result = false;
          this.FVal = this.FIter.next();
          Result = !this.FVal.done;
          return Result;
        };
        this.Create$1 = function (AIter) {
          this.FIter = AIter;
          return this;
        };
        this.Create$2 = function (ADictionary) {
          this.Create$1(ADictionary.FMap.values());
          return this;
        };
        this.MoveNext$1 = function () {
          var Result = false;
          Result = this.DoMoveNext();
          return Result;
        };
      },"TDictionary<System.String,WEBLib.DesignIntf.TIconData>.TValueEnumerator");
      rtl.createClass(this,"TValueCollection",$mod.TEnumerable$$$G$$generics$collections$$TIconData,function () {
        this.$init = function () {
          $mod.TEnumerable$$$G$$generics$collections$$TIconData.$init.call(this);
          this.FMap = null;
        };
        this.$final = function () {
          this.FMap = undefined;
          $mod.TEnumerable$$$G$$generics$collections$$TIconData.$final.call(this);
        };
        this.GetCount = function () {
          var Result = 0;
          Result = this.FMap.size;
          return Result;
        };
        this.DoGetEnumerator = function () {
          var Result = null;
          Result = $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.TValueEnumerator.$create("Create$1",[this.FMap.values()]);
          return Result;
        };
        this.Create$1 = function (ADictionary) {
          this.FMap = ADictionary.FMap;
          return this;
        };
        this.GetEnumerator$1 = function () {
          var Result = null;
          Result = this.DoGetEnumerator();
          return Result;
        };
        this.ToArray = function () {
          var Result = [];
          var I = 0;
          var P = null;
          Result = rtl.arraySetLength(Result,null,this.FMap.size);
          var $in = this.GetEnumerator$1();
          try {
            while ($in.MoveNext$1()) {
              P = $in.GetCurrent();
              Result[I] = P;
              I += 1;
            }
          } finally {
            $in = rtl.freeLoc($in)
          };
          return Result;
        };
      },"TDictionary<System.String,WEBLib.DesignIntf.TIconData>.TValueCollection");
      rtl.createClass(this,"TKeyCollection",$mod.TEnumerable$$$G$$generics$collections$$String,function () {
        this.$init = function () {
          $mod.TEnumerable$$$G$$generics$collections$$String.$init.call(this);
          this.FMap = null;
        };
        this.$final = function () {
          this.FMap = undefined;
          $mod.TEnumerable$$$G$$generics$collections$$String.$final.call(this);
        };
        this.GetCount = function () {
          var Result = 0;
          Result = this.FMap.size;
          return Result;
        };
        this.DoGetEnumerator = function () {
          var Result = null;
          Result = this.GetEnumerator$1();
          return Result;
        };
        this.Create$1 = function (ADictionary) {
          this.FMap = ADictionary.FMap;
          return this;
        };
        this.GetEnumerator$1 = function () {
          var Result = null;
          Result = $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.TKeyEnumerator.$create("Create$1",[this.FMap.keys()]);
          return Result;
        };
        this.ToArray = function () {
          var Result = [];
          Result = $mod.TEnumerable$$$G$$generics$collections$$String.ToArray.call(this);
          return Result;
        };
      },"TDictionary<System.String,WEBLib.DesignIntf.TIconData>.TKeyCollection");
    };
    this.$init = function () {
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$.$init.call(this);
      this.FMap = null;
      this.FComparer = null;
      this.FOnKeyNotify = null;
      this.FOnValueNotify = null;
      this.FKeyCollection = null;
      this.FValueCollection = null;
    };
    this.$final = function () {
      this.FMap = undefined;
      rtl.setIntfP(this,"FComparer",null);
      this.FOnKeyNotify = undefined;
      this.FOnValueNotify = undefined;
      this.FKeyCollection = undefined;
      this.FValueCollection = undefined;
      $mod.TEnumerable$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$.$final.call(this);
    };
    this.GetEffectiveKey = function (Key) {
      var Result = "";
      var it = null;
      var v = null;
      if (!(this.FComparer != null)) return Key;
      it = this.FMap.keys();
      v = it.next();
      while (!v.done) {
        Result = "" + v.value;
        if (this.FComparer.Compare(Result,Key) === 0) return Result;
        v = it.next();
      };
      Result = Key;
      return Result;
    };
    this.GetItem = function (Key) {
      var Result = null;
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (pas.JS.isUndefined(V)) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictKeyNotFound")]);
      Result = rtl.getObject(V);
      return Result;
    };
    this.SetItem = function (Key, Value) {
      var V = undefined;
      V = this.FMap.get(this.GetEffectiveKey(Key));
      if (!pas.JS.isUndefined(V)) this.ValueNotify(rtl.getObject(V),$mod.TCollectionNotification.cnRemoved);
      this.FMap.set(Key,Value);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoAdd = function (Key, Value) {
      this.FMap.set(this.GetEffectiveKey(Key),Value);
      this.KeyNotify(Key,$mod.TCollectionNotification.cnAdded);
      this.ValueNotify(Value,$mod.TCollectionNotification.cnAdded);
    };
    this.DoRemove = function (Key, Notification) {
      var Result = null;
      var V = undefined;
      var K = "";
      K = this.GetEffectiveKey(Key);
      V = this.FMap.get(K);
      if (!pas.JS.isUndefined(V)) {
        this.FMap.delete(K);
        Result = rtl.getObject(V);
        this.KeyNotify(Key,Notification);
        this.ValueNotify(Result,Notification);
      };
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FMap.size;
      return Result;
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = (this.FOnKeyNotify === null) && (this.FOnValueNotify === null);
      return Result;
    };
    this.DoGetEnumerator = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.PairNotify = function (Key, Value, Action) {
      this.KeyNotify(Key,Action);
      this.ValueNotify(Value,Action);
    };
    this.KeyNotify = function (Key, Action) {
      if (this.FOnKeyNotify != null) this.FOnKeyNotify(this,Key,Action);
    };
    this.ValueNotify = function (Value, Action) {
      if (this.FOnValueNotify != null) this.FOnValueNotify(this,Value,Action);
    };
    this.Create$1 = function (ACapacity) {
      this.FMap = new Map();
      if (ACapacity > 0) ;
      return this;
    };
    this.Create$2 = function (Collection) {
      var aPair = $mod.TPair$$$G$$generics$collections$$String$$TIconData.$new();
      this.Create$1(0);
      var $in = Collection.GetEnumerator();
      try {
        while ($in.MoveNext()) {
          aPair = $in.DoGetCurrent();
          this.Add(aPair.Key,aPair.Value);
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      return this;
    };
    this.Create$3 = function (AComparer) {
      this.Create$1(0);
      rtl.setIntfP(this,"FComparer",AComparer);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FKeyCollection;
        }, set: function (v) {
          this.p.FKeyCollection = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FValueCollection;
        }, set: function (v) {
          this.p.FValueCollection = v;
        }});
      this.Clear();
      this.FMap = null;
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Key, Value) {
      if (this.FMap.has(this.GetEffectiveKey(Key))) throw $mod.EDictionary.$create("Create$1",[rtl.getResStr($mod,"SErrDictDuplicateKey")]);
      this.DoAdd(Key,Value);
    };
    this.Remove = function (Key) {
      this.DoRemove(Key,$mod.TCollectionNotification.cnRemoved);
    };
    this.ExtractPair = function (Key) {
      var Result = $mod.TPair$$$G$$generics$collections$$String$$TIconData.$new();
      var K = "";
      Result.$assign($mod.TPair$$$G$$generics$collections$$String$$TIconData.$new());
      K = this.GetEffectiveKey(Key);
      if (this.FMap.has(K)) {
        Result.Create(Key,rtl.getObject(this.FMap.get(K)));
        this.FMap.delete(K);
      } else Result.Create(Key,null);
      return Result;
    };
    this.Clear = function () {
      var Iter = null;
      var IVal = null;
      var A = [];
      var K = "";
      var V = null;
      if (this.CanClearMap()) {
        this.FMap.clear()}
       else {
        Iter = this.FMap.entries();
        do {
          IVal = Iter.next();
          if (!IVal.done) {
            A = IVal.value;
            K = "" + A[0];
            V = rtl.getObject(A[1]);
            this.FMap.delete(K);
            this.PairNotify(K,V,$mod.TCollectionNotification.cnRemoved);
          };
        } while (!IVal.done);
      };
    };
    this.TryGetValue = function (Key, Value) {
      var Result = false;
      var K = "";
      K = this.GetEffectiveKey(Key);
      Result = this.FMap.has(K);
      if (Result) Value.set(rtl.getObject(this.FMap.get(K)));
      return Result;
    };
    this.AddOrSetValue = function (Key, Value) {
      var k = "";
      k = this.GetEffectiveKey(Key);
      if (!this.FMap.has(k)) {
        this.DoAdd(Key,Value)}
       else this.SetItem(k,Value);
    };
    this.ContainsKey = function (Key) {
      var Result = false;
      Result = this.FMap.has(this.GetEffectiveKey(Key));
      return Result;
    };
    this.ContainsValue = function (Value) {
      var Result = false;
      var It = null;
      var Res = null;
      Result = false;
      It = this.FMap.values();
      do {
        Res = It.next();
        if (!Res.done) Result = Value === rtl.getObject(Res.value);
      } while (!(Result || Res.done));
      return Result;
    };
    this.ToArray = function () {
      var Result = [];
      Result = $mod.TEnumerable$$$G$$generics$collections$$TPair$System$String$WEBLib$DesignIntf$TIconData$.ToArray.call(this);
      return Result;
    };
    this.GetKeys = function () {
      var Result = null;
      if (this.FKeyCollection === null) this.FKeyCollection = this.TKeyCollection.$create("Create$1",[this]);
      Result = this.FKeyCollection;
      return Result;
    };
    this.GetValues = function () {
      var Result = null;
      if (this.FValueCollection === null) this.FValueCollection = this.TValueCollection.$create("Create$1",[this]);
      Result = this.FValueCollection;
      return Result;
    };
    this.GetEnumerator$1 = function () {
      var Result = null;
      Result = this.TPairEnumerator.$create("Create$1",[this]);
      return Result;
    };
  },"TDictionary<System.String,WEBLib.DesignIntf.TIconData>");
  rtl.createClass(this,"TObjectDictionary$$$G$$generics$collections$$String$$TIconData",this.TDictionary$$$G$$generics$collections$$String$$TIconData,function () {
    this.$initSpec = function () {
    };
    this.$init = function () {
      $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.$init.call(this);
      this.FOwnerships = {};
    };
    this.$final = function () {
      this.FOwnerships = undefined;
      $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.$final.call(this);
    };
    this.CanClearMap = function () {
      var Result = false;
      Result = $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.CanClearMap.call(this) && rtl.eqSet(this.FOwnerships,{});
      return Result;
    };
    this.KeyNotify = function (Key, Action) {
      $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.KeyNotify.call(this,Key,Action);
      if (($mod.TDictionaryOwnership.doOwnsKeys in this.FOwnerships) && (Action === $mod.TCollectionNotification.cnRemoved)) Key = rtl.freeLoc(Key);
    };
    this.ValueNotify = function (Value, Action) {
      $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.ValueNotify.call(this,Value,Action);
      if (($mod.TDictionaryOwnership.doOwnsValues in this.FOwnerships) && (Action === $mod.TCollectionNotification.cnRemoved)) Value = rtl.freeLoc(Value);
    };
    this.Create$4 = function (aOwnerships, ACapacity) {
      this.FOwnerships = rtl.refSet(aOwnerships);
      $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.Create$1.call(this,ACapacity);
      return this;
    };
    this.Create$5 = function (aOwnerships) {
      $mod.TDictionary$$$G$$generics$collections$$String$$TIconData.Create$1.call(this,0);
      this.FOwnerships = rtl.refSet(aOwnerships);
      return this;
    };
  },"TObjectDictionary<System.String,WEBLib.DesignIntf.TIconData>");
  $mod.$implcode = function () {
    $mod.$resourcestrings = {SErrDictKeyNotFound: {org: "Key value not found"}, SErrDictDuplicateKey: {org: "Duplicate key value"}};
  };
},[]);
rtl.module("dateutils.helper",["System","Generics.Defaults","Generics.Collections"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TDateUtilsHelper",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FCache = null;
    };
    this.$final = function () {
      this.FCache = undefined;
      pas.System.TObject.$final.call(this);
    };
    var cJanuary = 0;
    var cDecember = 11;
    this.CalcPoints = function (AYear, AValue) {
      var Result = false;
      var lMonth = 0;
      var lDay = 0;
      var lHour = 0;
      var lDate = null;
      var lOffset = 0;
      var lOffsetNext = 0;
      var lFirst = false;
      var lDateTime = 0.0;
      lFirst = true;
      for (lMonth = 0; lMonth <= 11; lMonth++) {
        for (var $l = 1, $end = pas.SysUtils.MonthDays[+pas.SysUtils.IsLeapYear(AYear)][(lMonth + 1) - 1]; $l <= $end; $l++) {
          lDay = $l;
          for (lHour = 0; lHour <= 23; lHour++) {
            lDate = new Date(AYear,lMonth,lDay,lHour,0,0,0);
            lOffset = lDate.getTimezoneOffset();
            lDate.setHours(lDate.getHours() + 1);
            lOffsetNext = lDate.getTimezoneOffset();
            if (lOffset !== lOffsetNext) {
              lDateTime = pas.SysUtils.EncodeDate(AYear,lMonth + 1,lDay);
              if (lFirst) {
                AValue.Key = lDateTime + pas.SysUtils.EncodeTime(lHour + 1,0,0,0)}
               else AValue.Value = lDateTime + pas.SysUtils.EncodeTime(lHour,0,0,0);
              lFirst = false;
            };
          };
        };
      };
      Result = !lFirst;
      if (Result) this.FCache.Add(AYear,AValue);
      return Result;
    };
    this.Find = function (AYear, AResult) {
      var Result = false;
      Result = this.FCache.TryGetValue(AYear,AResult);
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FCache = pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$Longint$$TPair$System$Double$System$Double$.$create("Create$1",[0]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCache");
      pas.System.TObject.Destroy.call(this);
    };
    this.Force = function (AYear, AValue) {
      var Result = false;
      Result = this.Find(AYear,AValue);
      if (!Result) Result = this.CalcPoints(AYear,AValue);
      return Result;
    };
  });
},["SysUtils","JS"]);
rtl.module("DateUtils",["System","SysUtils","Math","TimeSpan","dateutils.helper"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.DaysPerWeek = 7;
  this.WeeksPerFortnight = 2;
  this.MonthsPerYear = 12;
  this.YearsPerDecade = 10;
  this.YearsPerCentury = 100;
  this.YearsPerMillennium = 1000;
  this.DayMonday = 1;
  this.DayTuesday = 2;
  this.DayWednesday = 3;
  this.DayThursday = 4;
  this.DayFriday = 5;
  this.DaySaturday = 6;
  this.DaySunday = 7;
  this.OneHour = 1 / 24;
  this.OneMinute = 1 / 1440;
  this.OneSecond = 1 / 86400;
  this.OneMillisecond = 1 / 86400000;
  this.$rtti.$StaticArray("DaysPerYear$a",{dims: [2], eltype: rtl.word});
  this.DaysPerYear = [365,366];
  this.RecodeLeaveFieldAsIs = 65535;
  this.ApproxDaysPerMonth = 30.4375;
  this.ApproxDaysPerYear = 365.25;
  this.DateOf = function (AValue) {
    var Result = 0.0;
    Result = pas.System.Trunc(AValue);
    return Result;
  };
  this.TimeOf = function (AValue) {
    var Result = 0.0;
    Result = pas.System.Frac(AValue);
    return Result;
  };
  this.IsInLeapYear = function (AValue) {
    var Result = false;
    Result = pas.SysUtils.IsLeapYear($mod.YearOf(AValue));
    return Result;
  };
  this.IsPM = function (AValue) {
    var Result = false;
    Result = $mod.HourOf(AValue) >= 12;
    return Result;
  };
  this.IsValidDate = function (AYear, AMonth, ADay) {
    var Result = false;
    Result = (AYear !== 0) && (AYear < 10000) && $impl.IsValidMonth(AMonth) && (ADay !== 0) && (ADay <= pas.SysUtils.MonthDays[+pas.SysUtils.IsLeapYear(AYear)][AMonth - 1]);
    return Result;
  };
  this.IsValidTime = function (AHour, AMinute, ASecond, AMilliSecond) {
    var Result = false;
    Result = (AHour === 24) && (AMinute === 0) && (ASecond === 0) && (AMilliSecond === 0);
    Result = Result || ((AHour < 24) && (AMinute < 60) && (ASecond < 60) && (AMilliSecond < 1000));
    return Result;
  };
  this.IsValidDateTime = function (AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) {
    var Result = false;
    Result = $mod.IsValidDate(AYear,AMonth,ADay) && $mod.IsValidTime(AHour,AMinute,ASecond,AMilliSecond);
    return Result;
  };
  this.IsValidDateDay = function (AYear, ADayOfYear) {
    var Result = false;
    Result = (AYear !== 0) && (ADayOfYear !== 0) && (AYear < 10000) && (ADayOfYear <= $mod.DaysPerYear[+pas.SysUtils.IsLeapYear(AYear)]);
    return Result;
  };
  this.IsValidDateWeek = function (AYear, AWeekOfYear, ADayOfWeek) {
    var Result = false;
    Result = (AYear !== 0) && (AYear < 10000) && $impl.IsValidDayOfWeek(ADayOfWeek) && (AWeekOfYear !== 0) && (AWeekOfYear <= $mod.WeeksInAYear(AYear));
    return Result;
  };
  this.IsValidDateMonthWeek = function (AYear, AMonth, AWeekOfMonth, ADayOfWeek) {
    var Result = false;
    Result = (AYear !== 0) && (AYear < 10000) && $impl.IsValidMonth(AMonth) && $impl.IsValidWeekOfMonth(AWeekOfMonth) && $impl.IsValidDayOfWeek(ADayOfWeek);
    return Result;
  };
  this.WeeksInYear = function (AValue) {
    var Result = 0;
    Result = $mod.WeeksInAYear($mod.YearOf(AValue));
    return Result;
  };
  this.WeeksInAYear = function (AYear) {
    var Result = 0;
    var DOW = 0;
    Result = 52;
    DOW = $mod.DayOfTheWeek($mod.StartOfAYear(AYear));
    if ((DOW === 4) || ((DOW === 3) && pas.SysUtils.IsLeapYear(AYear))) Result += 1;
    return Result;
  };
  this.DaysInYear = function (AValue) {
    var Result = 0;
    Result = $mod.DaysPerYear[+pas.SysUtils.IsLeapYear($mod.YearOf(AValue))];
    return Result;
  };
  this.DaysInAYear = function (AYear) {
    var Result = 0;
    Result = $mod.DaysPerYear[+pas.SysUtils.IsLeapYear(AYear)];
    return Result;
  };
  this.DaysInMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    Result = pas.SysUtils.MonthDays[+pas.SysUtils.IsLeapYear(Y)][M - 1];
    return Result;
  };
  this.DaysInAMonth = function (AYear, AMonth) {
    var Result = 0;
    Result = pas.SysUtils.MonthDays[+pas.SysUtils.IsLeapYear(AYear)][AMonth - 1];
    return Result;
  };
  this.Today = function () {
    var Result = 0.0;
    Result = pas.SysUtils.Date();
    return Result;
  };
  this.Yesterday = function () {
    var Result = 0.0;
    Result = pas.SysUtils.Date() - 1;
    return Result;
  };
  this.Tomorrow = function () {
    var Result = 0.0;
    Result = pas.SysUtils.Date() + 1;
    return Result;
  };
  this.IsToday = function (AValue) {
    var Result = false;
    Result = $mod.IsSameDay(AValue,pas.SysUtils.Date());
    return Result;
  };
  this.IsSameDay = function (AValue, ABasis) {
    var Result = false;
    var D = 0.0;
    D = AValue - pas.System.Trunc(ABasis);
    Result = (D >= 0) && (D < 1);
    return Result;
  };
  this.IsSameMonth = function (Avalue, ABasis) {
    var Result = false;
    Result = $mod.YearOf(Avalue) === $mod.YearOf(ABasis);
    Result = Result && ($mod.MonthOf(Avalue) === $mod.MonthOf(ABasis));
    return Result;
  };
  this.PreviousDayOfWeek = function (DayOfWeek) {
    var Result = 0;
    if (!$impl.IsValidDayOfWeek(DayOfWeek)) throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidDayOfWeek"),pas.System.VarRecs(0,DayOfWeek)]);
    Result = $impl.DOWMap[DayOfWeek - 1];
    return Result;
  };
  this.YearOf = function (AValue) {
    var Result = 0;
    var D = 0;
    var M = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }});
    return Result;
  };
  this.MonthOf = function (AValue) {
    var Result = 0;
    var Y = 0;
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    return Result;
  };
  this.WeekOf = function (AValue) {
    var Result = 0;
    Result = $mod.WeekOfTheYear(AValue);
    return Result;
  };
  this.DayOf = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.HourOf = function (AValue) {
    var Result = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    return Result;
  };
  this.MinuteOf = function (AValue) {
    var Result = 0;
    var H = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    return Result;
  };
  this.SecondOf = function (AValue) {
    var Result = 0;
    var H = 0;
    var N = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    return Result;
  };
  this.MilliSecondOf = function (AValue) {
    var Result = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.StartOfTheYear = function (AValue) {
    var Result = 0.0;
    Result = pas.SysUtils.EncodeDate($mod.YearOf(AValue),1,1);
    return Result;
  };
  this.EndOfTheYear = function (AValue) {
    var Result = 0.0;
    Result = $mod.EncodeDateTime($mod.YearOf(AValue),12,31,23,59,59,999);
    return Result;
  };
  this.StartOfAYear = function (AYear) {
    var Result = 0.0;
    Result = pas.SysUtils.EncodeDate(AYear,1,1);
    return Result;
  };
  this.EndOfAYear = function (AYear) {
    var Result = 0.0;
    Result = $mod.EncodeDateTime(AYear,12,31,23,59,59,999);
    return Result;
  };
  this.StartOfTheMonth = function (AValue) {
    var Result = 0.0;
    var Y = 0;
    var M = 0;
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    Result = pas.SysUtils.EncodeDate(Y,M,1);
    return Result;
  };
  this.EndOfTheMonth = function (AValue) {
    var Result = 0.0;
    var Y = 0;
    var M = 0;
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    Result = $mod.EncodeDateTime(Y,M,pas.SysUtils.MonthDays[+pas.SysUtils.IsLeapYear(Y)][M - 1],23,59,59,999);
    return Result;
  };
  this.StartOfAMonth = function (AYear, AMonth) {
    var Result = 0.0;
    Result = pas.SysUtils.EncodeDate(AYear,AMonth,1);
    return Result;
  };
  this.EndOfAMonth = function (AYear, AMonth) {
    var Result = 0.0;
    Result = $mod.EncodeDateTime(AYear,AMonth,pas.SysUtils.MonthDays[+pas.SysUtils.IsLeapYear(AYear)][AMonth - 1],23,59,59,999);
    return Result;
  };
  this.StartOfTheWeek = function (AValue) {
    var Result = 0.0;
    Result = (pas.System.Trunc(AValue) - $mod.DayOfTheWeek(AValue)) + 1;
    return Result;
  };
  this.EndOfTheWeek = function (AValue) {
    var Result = 0.0;
    Result = $mod.EndOfTheDay((AValue - $mod.DayOfTheWeek(AValue)) + 7);
    return Result;
  };
  this.StartOfAWeek = function (AYear, AWeekOfYear, ADayOfWeek) {
    var Result = 0.0;
    Result = $mod.EncodeDateWeek(AYear,AWeekOfYear,ADayOfWeek);
    return Result;
  };
  this.StartOfAWeek$1 = function (AYear, AWeekOfYear) {
    var Result = 0.0;
    Result = $mod.StartOfAWeek(AYear,AWeekOfYear,1);
    return Result;
  };
  this.EndOfAWeek = function (AYear, AWeekOfYear, ADayOfWeek) {
    var Result = 0.0;
    Result = $mod.EndOfTheDay($mod.EncodeDateWeek(AYear,AWeekOfYear,ADayOfWeek));
    return Result;
  };
  this.EndOfAWeek$1 = function (AYear, AWeekOfYear) {
    var Result = 0.0;
    Result = $mod.EndOfAWeek(AYear,AWeekOfYear,7);
    return Result;
  };
  this.StartOfTheDay = function (AValue) {
    var Result = 0.0;
    Result = pas.System.Trunc(AValue);
    return Result;
  };
  this.EndOfTheDay = function (AValue) {
    var Result = 0.0;
    var Y = 0;
    var M = 0;
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    Result = $mod.EncodeDateTime(Y,M,D,23,59,59,999);
    return Result;
  };
  this.StartOfADay = function (AYear, AMonth, ADay) {
    var Result = 0.0;
    Result = pas.SysUtils.EncodeDate(AYear,AMonth,ADay);
    return Result;
  };
  this.StartOfADay$1 = function (AYear, ADayOfYear) {
    var Result = 0.0;
    Result = ($mod.StartOfAYear(AYear) + ADayOfYear) - 1;
    return Result;
  };
  this.EndOfADay = function (AYear, AMonth, ADay) {
    var Result = 0.0;
    Result = $mod.EndOfTheDay(pas.SysUtils.EncodeDate(AYear,AMonth,ADay));
    return Result;
  };
  this.EndOfADay$1 = function (AYear, ADayOfYear) {
    var Result = 0.0;
    Result = (($mod.StartOfAYear(AYear) + ADayOfYear) - 1) + pas.SysUtils.EncodeTime(23,59,59,999);
    return Result;
  };
  this.MonthOfTheYear = function (AValue) {
    var Result = 0;
    Result = $mod.MonthOf(AValue);
    return Result;
  };
  this.WeekOfTheYear = function (AValue) {
    var Result = 0;
    var Y = 0;
    var DOW = 0;
    $mod.DecodeDateWeek(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return DOW;
      }, set: function (v) {
        DOW = v;
      }});
    return Result;
  };
  this.WeekOfTheYear$1 = function (AValue, AYear) {
    var Result = 0;
    var DOW = 0;
    $mod.DecodeDateWeek(AValue,AYear,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return DOW;
      }, set: function (v) {
        DOW = v;
      }});
    return Result;
  };
  this.DayOfTheYear = function (AValue) {
    var Result = 0;
    Result = pas.System.Trunc((AValue - $mod.StartOfTheYear(AValue)) + 1);
    return Result;
  };
  this.HourOfTheYear = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = H + (($mod.DayOfTheYear(AValue) - 1) * 24);
    return Result;
  };
  this.MinuteOfTheYear = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = M + ((H + (($mod.DayOfTheYear(AValue) - 1) * 24)) * 60);
    return Result;
  };
  this.SecondOfTheYear = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = ((M + ((H + (($mod.DayOfTheYear(AValue) - 1) * 24)) * 60)) * 60) + S;
    return Result;
  };
  this.MilliSecondOfTheYear = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = ((((M + ((H + (($mod.DayOfTheYear(AValue) - 1) * 24)) * 60)) * 60) + S) * 1000) + MS;
    return Result;
  };
  this.WeekOfTheMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    var DOW = 0;
    $mod.DecodeDateMonthWeek(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return DOW;
      }, set: function (v) {
        DOW = v;
      }});
    return Result;
  };
  this.WeekOfTheMonth$1 = function (AValue, AYear, AMonth) {
    var Result = 0;
    var DOW = 0;
    $mod.DecodeDateMonthWeek(AValue,AYear,AMonth,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},{get: function () {
        return DOW;
      }, set: function (v) {
        DOW = v;
      }});
    return Result;
  };
  this.DayOfTheMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.HourOfTheMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = ((D - 1) * 24) + H;
    return Result;
  };
  this.MinuteOfTheMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = ((((D - 1) * 24) + H) * 60) + N;
    return Result;
  };
  this.SecondOfTheMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = ((((((D - 1) * 24) + H) * 60) + N) * 60) + S;
    return Result;
  };
  this.MilliSecondOfTheMonth = function (AValue) {
    var Result = 0;
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = ((((((((D - 1) * 24) + H) * 60) + N) * 60) + S) * 1000) + MS;
    return Result;
  };
  this.DayOfTheWeek = function (AValue) {
    var Result = 0;
    Result = $impl.DOWMap[pas.SysUtils.DayOfWeek(AValue) - 1];
    return Result;
  };
  this.HourOfTheWeek = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (($mod.DayOfTheWeek(AValue) - 1) * 24) + H;
    return Result;
  };
  this.MinuteOfTheWeek = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (((($mod.DayOfTheWeek(AValue) - 1) * 24) + H) * 60) + M;
    return Result;
  };
  this.SecondOfTheWeek = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (((((($mod.DayOfTheWeek(AValue) - 1) * 24) + H) * 60) + M) * 60) + S;
    return Result;
  };
  this.MilliSecondOfTheWeek = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (((((((($mod.DayOfTheWeek(AValue) - 1) * 24) + H) * 60) + M) * 60) + S) * 1000) + MS;
    return Result;
  };
  this.HourOfTheDay = function (AValue) {
    var Result = 0;
    Result = $mod.HourOf(AValue);
    return Result;
  };
  this.MinuteOfTheDay = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (H * 60) + M;
    return Result;
  };
  this.SecondOfTheDay = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (((H * 60) + M) * 60) + S;
    return Result;
  };
  this.MilliSecondOfTheDay = function (AValue) {
    var Result = 0;
    var H = 0;
    var M = 0;
    var S = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (((((H * 60) + M) * 60) + S) * 1000) + MS;
    return Result;
  };
  this.MinuteOfTheHour = function (AValue) {
    var Result = 0;
    Result = $mod.MinuteOf(AValue);
    return Result;
  };
  this.SecondOfTheHour = function (AValue) {
    var Result = 0;
    var H = 0;
    var S = 0;
    var M = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (M * 60) + S;
    return Result;
  };
  this.MilliSecondOfTheHour = function (AValue) {
    var Result = 0;
    var H = 0;
    var S = 0;
    var M = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (((M * 60) + S) * 1000) + MS;
    return Result;
  };
  this.SecondOfTheMinute = function (AValue) {
    var Result = 0;
    Result = $mod.SecondOf(AValue);
    return Result;
  };
  this.MilliSecondOfTheMinute = function (AValue) {
    var Result = 0;
    var H = 0;
    var S = 0;
    var M = 0;
    var MS = 0;
    pas.SysUtils.DecodeTime(AValue,{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Result = (S * 1000) + MS;
    return Result;
  };
  this.MilliSecondOfTheSecond = function (AValue) {
    var Result = 0;
    Result = $mod.MilliSecondOf(AValue);
    return Result;
  };
  this.WithinPastYears = function (ANow, AThen, AYears) {
    var Result = false;
    Result = $mod.YearsBetween(ANow,AThen,false) <= AYears;
    return Result;
  };
  this.WithinPastMonths = function (ANow, AThen, AMonths) {
    var Result = false;
    Result = $mod.MonthsBetween(ANow,AThen,false) <= AMonths;
    return Result;
  };
  this.WithinPastWeeks = function (ANow, AThen, AWeeks) {
    var Result = false;
    Result = $mod.WeeksBetween(ANow,AThen) <= AWeeks;
    return Result;
  };
  this.WithinPastDays = function (ANow, AThen, ADays) {
    var Result = false;
    Result = $mod.DaysBetween(ANow,AThen) <= ADays;
    return Result;
  };
  this.WithinPastHours = function (ANow, AThen, AHours) {
    var Result = false;
    Result = $mod.HoursBetween(ANow,AThen) <= AHours;
    return Result;
  };
  this.WithinPastMinutes = function (ANow, AThen, AMinutes) {
    var Result = false;
    Result = $mod.MinutesBetween(ANow,AThen) <= AMinutes;
    return Result;
  };
  this.WithinPastSeconds = function (ANow, AThen, ASeconds) {
    var Result = false;
    Result = $mod.SecondsBetween(ANow,AThen) <= ASeconds;
    return Result;
  };
  this.WithinPastMilliSeconds = function (ANow, AThen, AMilliSeconds) {
    var Result = false;
    Result = $mod.MilliSecondsBetween(ANow,AThen) <= AMilliSeconds;
    return Result;
  };
  this.YearsBetween = function (ANow, AThen, AExact) {
    var Result = 0;
    var yy = 0;
    var mm = 0;
    var dd = 0;
    if (AExact && (ANow >= -693594) && (AThen >= -693594) && (ANow <= pas.SysUtils.MaxDateTime) && (AThen <= pas.SysUtils.MaxDateTime)) {
      $mod.PeriodBetween(ANow,AThen,{get: function () {
          return yy;
        }, set: function (v) {
          yy = v;
        }},{get: function () {
          return mm;
        }, set: function (v) {
          mm = v;
        }},{get: function () {
          return dd;
        }, set: function (v) {
          dd = v;
        }});
      Result = yy;
    } else Result = pas.System.Trunc((Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) / $mod.ApproxDaysPerYear);
    return Result;
  };
  this.MonthsBetween = function (ANow, AThen, AExact) {
    var Result = 0;
    var y = 0;
    var m = 0;
    var d = 0;
    if (AExact && (ANow >= -693594) && (AThen >= -693594) && (ANow <= pas.SysUtils.MaxDateTime) && (AThen <= pas.SysUtils.MaxDateTime)) {
      $mod.PeriodBetween(ANow,AThen,{get: function () {
          return y;
        }, set: function (v) {
          y = v;
        }},{get: function () {
          return m;
        }, set: function (v) {
          m = v;
        }},{get: function () {
          return d;
        }, set: function (v) {
          d = v;
        }});
      Result = (y * 12) + m;
    } else Result = pas.System.Trunc((Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) / $mod.ApproxDaysPerMonth);
    return Result;
  };
  this.WeeksBetween = function (ANow, AThen) {
    var Result = 0;
    Result = rtl.trunc(pas.System.Trunc(Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) / 7);
    return Result;
  };
  this.DaysBetween = function (ANow, AThen) {
    var Result = 0;
    Result = pas.System.Trunc(Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9);
    return Result;
  };
  this.HoursBetween = function (ANow, AThen) {
    var Result = 0;
    Result = pas.System.Trunc((Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) * 24);
    return Result;
  };
  this.MinutesBetween = function (ANow, AThen) {
    var Result = 0;
    Result = pas.System.Trunc((Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) * 1440);
    return Result;
  };
  this.SecondsBetween = function (ANow, AThen) {
    var Result = 0;
    Result = pas.System.Trunc((Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) * 86400);
    return Result;
  };
  this.MilliSecondsBetween = function (ANow, AThen) {
    var Result = 0;
    Result = pas.System.Trunc((Math.abs($impl.DateTimeDiff(ANow,AThen)) + 5.7870370370370369E-9) * 86400000);
    return Result;
  };
  this.PeriodBetween = function (ANow, AThen, Years, months, days) {
    var Y1 = 0;
    var Y2 = 0;
    var M1 = 0;
    var M2 = 0;
    var D1 = 0;
    var D2 = 0;
    if (AThen > ANow) {
      pas.SysUtils.DecodeDate(ANow,{get: function () {
          return Y1;
        }, set: function (v) {
          Y1 = v;
        }},{get: function () {
          return M1;
        }, set: function (v) {
          M1 = v;
        }},{get: function () {
          return D1;
        }, set: function (v) {
          D1 = v;
        }});
      pas.SysUtils.DecodeDate(AThen,{get: function () {
          return Y2;
        }, set: function (v) {
          Y2 = v;
        }},{get: function () {
          return M2;
        }, set: function (v) {
          M2 = v;
        }},{get: function () {
          return D2;
        }, set: function (v) {
          D2 = v;
        }});
    } else {
      pas.SysUtils.DecodeDate(AThen,{get: function () {
          return Y1;
        }, set: function (v) {
          Y1 = v;
        }},{get: function () {
          return M1;
        }, set: function (v) {
          M1 = v;
        }},{get: function () {
          return D1;
        }, set: function (v) {
          D1 = v;
        }});
      pas.SysUtils.DecodeDate(ANow,{get: function () {
          return Y2;
        }, set: function (v) {
          Y2 = v;
        }},{get: function () {
          return M2;
        }, set: function (v) {
          M2 = v;
        }},{get: function () {
          return D2;
        }, set: function (v) {
          D2 = v;
        }});
    };
    Years.set(Y2 - Y1);
    if ((M1 > M2) || ((M1 === M2) && (D1 > D2))) Years.set(Years.get() - 1);
    if (M1 > M2) M2 += 12;
    months.set(M2 - M1);
    if (D2 >= D1) {
      days.set(D2 - D1)}
     else {
      if (months.get() === 0) {
        months.set(11)}
       else months.set(months.get() - 1);
      days.set(($mod.DaysInAMonth(Y1,M1) - D1) + D2);
    };
  };
  this.YearSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) / $mod.ApproxDaysPerYear;
    return Result;
  };
  this.MonthSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) / $mod.ApproxDaysPerMonth;
    return Result;
  };
  this.WeekSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) / 7;
    return Result;
  };
  this.DaySpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen));
    return Result;
  };
  this.HourSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) * 24;
    return Result;
  };
  this.MinuteSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) * 1440;
    return Result;
  };
  this.SecondSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) * 86400;
    return Result;
  };
  this.MilliSecondSpan = function (ANow, AThen) {
    var Result = 0.0;
    Result = Math.abs($impl.DateTimeDiff(ANow,AThen)) * 86400000;
    return Result;
  };
  this.IncYear = function (AValue, ANumberOfYears) {
    var Result = 0.0;
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Y = Y + ANumberOfYears;
    if ((M === 2) && (D === 29) && !pas.SysUtils.IsLeapYear(Y)) D = 28;
    Result = $mod.EncodeDateTime(Y,M,D,H,N,S,MS);
    return Result;
  };
  this.IncYear$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncYear(AValue,1);
    return Result;
  };
  this.IncWeek = function (AValue, ANumberOfWeeks) {
    var Result = 0.0;
    Result = AValue + (ANumberOfWeeks * 7);
    $impl.MaybeSkipTimeWarp(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.IncWeek$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncWeek(AValue,1);
    return Result;
  };
  this.IncDay = function (AValue, ANumberOfDays) {
    var Result = 0.0;
    Result = AValue + ANumberOfDays;
    $impl.MaybeSkipTimeWarp(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.IncDay$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncDay(AValue,1);
    return Result;
  };
  this.IncHour = function (AValue, ANumberOfHours) {
    var Result = 0.0;
    if (AValue >= 0) {
      Result = AValue + (ANumberOfHours / 24)}
     else Result = $impl.IncNegativeTime(AValue,ANumberOfHours / 24);
    $impl.MaybeSkipTimeWarp(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.IncHour$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncHour(AValue,1);
    return Result;
  };
  this.IncMinute = function (AValue, ANumberOfMinutes) {
    var Result = 0.0;
    if (AValue >= 0) {
      Result = AValue + (ANumberOfMinutes / 1440)}
     else Result = $impl.IncNegativeTime(AValue,ANumberOfMinutes / 1440);
    $impl.MaybeSkipTimeWarp(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.IncMinute$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncMinute(AValue,1);
    return Result;
  };
  this.IncSecond = function (AValue, ANumberOfSeconds) {
    var Result = 0.0;
    if (AValue >= 0) {
      Result = AValue + (ANumberOfSeconds / 86400)}
     else Result = $impl.IncNegativeTime(AValue,ANumberOfSeconds / 86400);
    $impl.MaybeSkipTimeWarp(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.IncSecond$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncSecond(AValue,1);
    return Result;
  };
  this.IncMilliSecond = function (AValue, ANumberOfMilliSeconds) {
    var Result = 0.0;
    if (AValue >= 0) {
      Result = AValue + (ANumberOfMilliSeconds / 86400000)}
     else Result = $impl.IncNegativeTime(AValue,ANumberOfMilliSeconds / 86400000);
    $impl.MaybeSkipTimeWarp(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }});
    return Result;
  };
  this.IncMilliSecond$1 = function (AValue) {
    var Result = 0.0;
    Result = $mod.IncMilliSecond(AValue,1);
    return Result;
  };
  this.EncodeDateTime = function (AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) {
    var Result = 0.0;
    if (!$mod.TryEncodeDateTime(AYear,AMonth,ADay,AHour,AMinute,ASecond,AMilliSecond,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) $mod.InvalidDateTimeError$1(AYear,AMonth,ADay,AHour,AMinute,ASecond,AMilliSecond);
    return Result;
  };
  this.DecodeDateTime = function (AValue, AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) {
    pas.SysUtils.DecodeTime(AValue,AHour,AMinute,ASecond,AMilliSecond);
    if (AHour.get() === 24) {
      AHour.set(0);
      pas.SysUtils.DecodeDate(Math.round(AValue),AYear,AMonth,ADay);
    } else pas.SysUtils.DecodeDate(AValue,AYear,AMonth,ADay);
  };
  this.TryEncodeDateTime = function (AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond, AValue) {
    var Result = false;
    var tmp = 0.0;
    Result = pas.SysUtils.TryEncodeDate(AYear,AMonth,ADay,AValue);
    Result = Result && pas.SysUtils.TryEncodeTime(AHour,AMinute,ASecond,AMilliSecond,{get: function () {
        return tmp;
      }, set: function (v) {
        tmp = v;
      }});
    if (Result) AValue.set(pas.SysUtils.ComposeDateTime(AValue.get(),tmp));
    return Result;
  };
  this.EncodeDateWeek = function (AYear, AWeekOfYear, ADayOfWeek) {
    var Result = 0.0;
    if (!$mod.TryEncodeDateWeek(AYear,AWeekOfYear,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},ADayOfWeek)) $mod.InvalidDateWeekError(AYear,AWeekOfYear,ADayOfWeek);
    return Result;
  };
  this.EncodeDateWeek$1 = function (AYear, AWeekOfYear) {
    var Result = 0.0;
    Result = $mod.EncodeDateWeek(AYear,AWeekOfYear,1);
    return Result;
  };
  this.DecodeDateWeek = function (AValue, AYear, AWeekOfYear, ADayOfWeek) {
    var DOY = 0;
    var D = 0;
    var YS = 0.0;
    var YSDOW = 0;
    var YEDOW = 0;
    AYear.set($mod.YearOf(AValue));
    ADayOfWeek.set(pas.SysUtils.DayOfWeek(AValue) - 1);
    if (ADayOfWeek.get() === 0) ADayOfWeek.set(7);
    YS = $mod.StartOfAYear(AYear.get());
    DOY = pas.System.Trunc(AValue - YS) + 1;
    YSDOW = $mod.DayOfTheWeek(YS);
    if (YSDOW < 5) {
      DOY += YSDOW - 1}
     else DOY -= 8 - YSDOW;
    if (DOY <= 0) {
      $mod.DecodeDateWeek(YS - 1,AYear,AWeekOfYear,{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }})}
     else {
      AWeekOfYear.set(rtl.trunc(DOY / 7));
      if ((DOY % 7) !== 0) AWeekOfYear.set(AWeekOfYear.get() + 1);
      if (AWeekOfYear.get() > 52) {
        YEDOW = YSDOW;
        if (pas.SysUtils.IsLeapYear(AYear.get())) {
          YEDOW += 1;
          if (YEDOW > 7) YEDOW = 1;
        };
        if (YEDOW < 4) {
          AYear.set(AYear.get() + 1);
          AWeekOfYear.set(1);
        };
      };
    };
  };
  this.TryEncodeDateWeek = function (AYear, AWeekOfYear, AValue, ADayOfWeek) {
    var Result = false;
    var DOW = 0;
    var Rest = 0;
    Result = $mod.IsValidDateWeek(AYear,AWeekOfYear,ADayOfWeek);
    if (Result) {
      AValue.set(pas.SysUtils.EncodeDate(AYear,1,1) + (7 * (AWeekOfYear - 1)));
      DOW = $mod.DayOfTheWeek(AValue.get());
      Rest = ADayOfWeek - DOW;
      if (DOW > 4) Rest += 7;
      AValue.set(AValue.get() + Rest);
    };
    return Result;
  };
  this.TryEncodeDateWeek$1 = function (AYear, AWeekOfYear, AValue) {
    var Result = false;
    Result = $mod.TryEncodeDateWeek(AYear,AWeekOfYear,AValue,1);
    return Result;
  };
  this.EncodeDateDay = function (AYear, ADayOfYear) {
    var Result = 0.0;
    if (!$mod.TryEncodeDateDay(AYear,ADayOfYear,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) $mod.InvalidDateDayError(AYear,ADayOfYear);
    return Result;
  };
  this.DecodeDateDay = function (AValue, AYear, ADayOfYear) {
    var M = 0;
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,AYear,{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    ADayOfYear.set(pas.System.Trunc(AValue - pas.SysUtils.EncodeDate(AYear.get(),1,1)) + 1);
  };
  this.TryEncodeDateDay = function (AYear, ADayOfYear, AValue) {
    var Result = false;
    Result = (ADayOfYear !== 0) && (ADayOfYear <= $mod.DaysPerYear[+pas.SysUtils.IsLeapYear(AYear)]);
    if (Result) AValue.set((pas.SysUtils.EncodeDate(AYear,1,1) + ADayOfYear) - 1);
    return Result;
  };
  this.EncodeDateMonthWeek = function (AYear, AMonth, AWeekOfMonth, ADayOfWeek) {
    var Result = 0.0;
    if (!$mod.TryEncodeDateMonthWeek(AYear,AMonth,AWeekOfMonth,ADayOfWeek,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) $mod.InvalidDateMonthWeekError(AYear,AMonth,AWeekOfMonth,ADayOfWeek);
    return Result;
  };
  this.DecodeDateMonthWeek = function (AValue, AYear, AMonth, AWeekOfMonth, ADayOfWeek) {
    var D = 0;
    var SDOM = 0;
    var EDOM = 0;
    var SOM = 0.0;
    var DOM = 0;
    pas.SysUtils.DecodeDate(AValue,AYear,AMonth,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    ADayOfWeek.set($mod.DayOfTheWeek(AValue));
    SOM = pas.SysUtils.EncodeDate(AYear.get(),AMonth.get(),1);
    SDOM = $mod.DayOfTheWeek(SOM);
    DOM = (D - 1) + SDOM;
    if (SDOM > 4) DOM -= 7;
    if (DOM <= 0) {
      $mod.DecodeDateMonthWeek(SOM - 1,AYear,AMonth,AWeekOfMonth,{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }})}
     else {
      AWeekOfMonth.set(rtl.trunc(DOM / 7));
      if ((DOM % 7) !== 0) AWeekOfMonth.set(AWeekOfMonth.get() + 1);
      EDOM = $mod.DayOfTheWeek($mod.EndOfAMonth(AYear.get(),AMonth.get()));
      if ((EDOM < 4) && (($mod.DaysInAMonth(AYear.get(),AMonth.get()) - D) < EDOM)) {
        AWeekOfMonth.set(1);
        AMonth.set(AMonth.get() + 1);
        if (AMonth.get() === 13) {
          AMonth.set(1);
          AYear.set(AYear.get() + 1);
        };
      };
    };
  };
  this.TryEncodeDateMonthWeek = function (AYear, AMonth, AWeekOfMonth, ADayOfWeek, AValue) {
    var Result = false;
    var S = 0;
    var DOM = 0;
    Result = $mod.IsValidDateMonthWeek(AYear,AMonth,AWeekOfMonth,ADayOfWeek);
    if (Result) {
      AValue.set(pas.SysUtils.EncodeDate(AYear,AMonth,1));
      DOM = (((AWeekOfMonth - 1) * 7) + ADayOfWeek) - 1;
      S = $mod.DayOfTheWeek(AValue.get());
      DOM -= S - 1;
      if ((S === 5) || (S === 6) || (S === 7)) DOM += 7;
      AValue.set(AValue.get() + DOM);
    };
    return Result;
  };
  this.TryEncodeTimeInterval = function (Hour, Min, Sec, MSec, Time) {
    var Result = false;
    Result = (Min < 60) && (Sec < 60) && (MSec < 1000);
    if (Result) Time.set(((Hour * 3600000) + (Min * 60000) + (Sec * 1000) + MSec) / 86400000);
    return Result;
  };
  this.EncodeTimeInterval = function (Hour, Minute, Second, MilliSecond) {
    var Result = 0.0;
    if (!$mod.TryEncodeTimeInterval(Hour,Minute,Second,MilliSecond,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidHourMinuteSecMsec"),pas.System.VarRecs(0,Hour,0,Minute,0,Second,0,MilliSecond)]);
    return Result;
  };
  this.RecodeYear = function (AValue, AYear) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,AYear,65535,65535,65535,65535,65535,65535);
    return Result;
  };
  this.RecodeMonth = function (AValue, AMonth) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,AMonth,65535,65535,65535,65535,65535);
    return Result;
  };
  this.RecodeDay = function (AValue, ADay) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,65535,ADay,65535,65535,65535,65535);
    return Result;
  };
  this.RecodeHour = function (AValue, AHour) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,65535,65535,AHour,65535,65535,65535);
    return Result;
  };
  this.RecodeMinute = function (AValue, AMinute) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,65535,65535,65535,AMinute,65535,65535);
    return Result;
  };
  this.RecodeSecond = function (AValue, ASecond) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,65535,65535,65535,65535,ASecond,65535);
    return Result;
  };
  this.RecodeMilliSecond = function (AValue, AMilliSecond) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,65535,65535,65535,65535,65535,AMilliSecond);
    return Result;
  };
  this.RecodeDate = function (AValue, AYear, AMonth, ADay) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,AYear,AMonth,ADay,65535,65535,65535,65535);
    return Result;
  };
  this.RecodeTime = function (AValue, AHour, AMinute, ASecond, AMilliSecond) {
    var Result = 0.0;
    Result = $mod.RecodeDateTime(AValue,65535,65535,65535,AHour,AMinute,ASecond,AMilliSecond);
    return Result;
  };
  this.RecodeDateTime = function (AValue, AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) {
    var Result = 0.0;
    if (!$mod.TryRecodeDateTime(AValue,AYear,AMonth,ADay,AHour,AMinute,ASecond,AMilliSecond,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) $mod.InvalidDateTimeError(AYear,AMonth,ADay,AHour,AMinute,ASecond,AMilliSecond,AValue);
    return Result;
  };
  this.TryRecodeDateTime = function (AValue, AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond, AResult) {
    var Result = false;
    function FV(AV, Arg) {
      if (Arg !== 65535) AV.set(Arg);
    };
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    FV({get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},AYear);
    FV({get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},AMonth);
    FV({get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},ADay);
    FV({get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},AHour);
    FV({get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},AMinute);
    FV({get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},ASecond);
    FV({get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }},AMilliSecond);
    Result = $mod.TryEncodeDateTime(Y,M,D,H,N,S,MS,AResult);
    return Result;
  };
  this.CompareDateTime = function (A, B) {
    var Result = 0;
    if ($mod.SameDateTime(A,B)) {
      Result = 0}
     else if (pas.System.Trunc(A) === pas.System.Trunc(B)) {
      if (Math.abs(pas.System.Frac(A)) > Math.abs(pas.System.Frac(B))) {
        Result = 1}
       else Result = -1;
    } else {
      if (A > B) {
        Result = 1}
       else Result = -1;
    };
    return Result;
  };
  this.CompareDate = function (A, B) {
    var Result = 0;
    if ($mod.SameDate(A,B)) {
      Result = 0}
     else if (A < B) {
      Result = -1}
     else Result = 1;
    return Result;
  };
  this.CompareTime = function (A, B) {
    var Result = 0;
    if ($mod.SameTime(A,B)) {
      Result = 0}
     else if (pas.System.Frac(A) < pas.System.Frac(B)) {
      Result = -1}
     else Result = 1;
    return Result;
  };
  this.SameDateTime = function (A, B) {
    var Result = false;
    Result = Math.abs(A - B) < 1.1574074074074074E-8;
    return Result;
  };
  this.SameDate = function (A, B) {
    var Result = false;
    Result = pas.System.Trunc(A) === pas.System.Trunc(B);
    return Result;
  };
  this.SameTime = function (A, B) {
    var Result = false;
    Result = pas.System.Frac(Math.abs(A - B)) < 1.1574074074074074E-8;
    return Result;
  };
  this.NthDayOfWeek = function (AValue) {
    var Result = 0;
    Result = $impl.InternalNthDayOfWeek($mod.DayOfTheMonth(AValue));
    return Result;
  };
  this.DecodeDayOfWeekInMonth = function (AValue, AYear, AMonth, ANthDayOfWeek, ADayOfWeek) {
    var D = 0;
    pas.SysUtils.DecodeDate(AValue,AYear,AMonth,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    ADayOfWeek.set($mod.DayOfTheWeek(AValue));
    ANthDayOfWeek.set($impl.InternalNthDayOfWeek(D));
  };
  this.EncodeDayOfWeekInMonth = function (AYear, AMonth, ANthDayOfWeek, ADayOfWeek) {
    var Result = 0.0;
    if (!$mod.TryEncodeDayOfWeekInMonth(AYear,AMonth,ANthDayOfWeek,ADayOfWeek,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) $mod.InvalidDayOfWeekInMonthError(AYear,AMonth,ANthDayOfWeek,ADayOfWeek);
    return Result;
  };
  this.TryEncodeDayOfWeekInMonth = function (AYear, AMonth, ANthDayOfWeek, ADayOfWeek, AValue) {
    var Result = false;
    var SOM = 0;
    var D = 0;
    SOM = $mod.DayOfTheWeek(pas.SysUtils.EncodeDate(AYear,AMonth,1));
    D = ((1 + ADayOfWeek) - SOM) + (7 * (ANthDayOfWeek - 1));
    if (SOM > ADayOfWeek) D = D + 7;
    Result = pas.SysUtils.TryEncodeDate(AYear,AMonth,D,AValue);
    return Result;
  };
  this.InvalidDateTimeError = function (AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond, ABaseDate) {
    function DoField(Arg, Def, Unknown) {
      var Result = "";
      if (Def === 0) ;
      if (Arg !== 65535) {
        Result = pas.SysUtils.Format("%.*d",pas.System.VarRecs(19,Unknown.length,0,Arg))}
       else if (ABaseDate === 0) {
        Result = Unknown}
       else Result = pas.SysUtils.Format("%.*d",pas.System.VarRecs(19,Unknown.length,0,Arg));
      return Result;
    };
    var Y = 0;
    var M = 0;
    var D = 0;
    var H = 0;
    var N = 0;
    var S = 0;
    var MS = 0;
    var Msg = "";
    $mod.DecodeDateTime(ABaseDate,{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return H;
      }, set: function (v) {
        H = v;
      }},{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }},{get: function () {
        return S;
      }, set: function (v) {
        S = v;
      }},{get: function () {
        return MS;
      }, set: function (v) {
        MS = v;
      }});
    Msg = DoField(AYear,Y,"????");
    Msg = Msg + pas.SysUtils.FormatSettings.DateSeparator + DoField(AMonth,M,"??");
    Msg = Msg + pas.SysUtils.FormatSettings.DateSeparator + DoField(ADay,D,"??");
    Msg = Msg + " " + DoField(AHour,H,"??");
    Msg = Msg + pas.SysUtils.FormatSettings.TimeSeparator + DoField(AMinute,N,"??");
    Msg = Msg + pas.SysUtils.FormatSettings.TimeSeparator + DoField(ASecond,S,"??");
    Msg = Msg + pas.SysUtils.FormatSettings.DecimalSeparator + DoField(AMilliSecond,MS,"???");
    throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeStamp"),pas.System.VarRecs(18,Msg)]);
  };
  this.InvalidDateTimeError$1 = function (AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) {
    $mod.InvalidDateTimeError(AYear,AMonth,ADay,AHour,AMinute,ASecond,AMilliSecond,0);
  };
  this.InvalidDateWeekError = function (AYear, AWeekOfYear, ADayOfWeek) {
    throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidDateWeek"),pas.System.VarRecs(0,AYear,0,AWeekOfYear,0,ADayOfWeek)]);
  };
  this.InvalidDateDayError = function (AYear, ADayOfYear) {
    throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidDayOfYear"),pas.System.VarRecs(0,AYear,0,ADayOfYear)]);
  };
  this.InvalidDateMonthWeekError = function (AYear, AMonth, AWeekOfMonth, ADayOfWeek) {
    throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidDateMonthWeek"),pas.System.VarRecs(0,AYear,0,AMonth,0,AWeekOfMonth,0,ADayOfWeek)]);
  };
  this.InvalidDayOfWeekInMonthError = function (AYear, AMonth, ANthDayOfWeek, ADayOfWeek) {
    throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidDayOfWeekInMonth"),pas.System.VarRecs(0,AYear,0,AMonth,0,ANthDayOfWeek,0,ADayOfWeek)]);
  };
  this.DateTimeToJulianDate = function (AValue) {
    var Result = 0.0;
    var day = 0;
    var month = 0;
    var year = 0;
    var a = 0;
    var y = 0;
    var m = 0;
    pas.SysUtils.DecodeDate(AValue,{get: function () {
        return year;
      }, set: function (v) {
        year = v;
      }},{get: function () {
        return month;
      }, set: function (v) {
        month = v;
      }},{get: function () {
        return day;
      }, set: function (v) {
        day = v;
      }});
    a = rtl.trunc((14 - month) / 12);
    y = (year + 4800) - a;
    m = (month + (12 * a)) - 3;
    Result = ((((day + rtl.trunc(((153 * m) + 2) / 5) + (365 * y) + rtl.trunc(y / 4)) - rtl.trunc(y / 100)) + rtl.trunc(y / 400)) - 32045.5) + pas.System.Frac(AValue);
    return Result;
  };
  this.JulianDateToDateTime = function (AValue) {
    var Result = 0.0;
    if (!$mod.TryJulianDateToDateTime(AValue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidJulianDate"),pas.System.VarRecs(3,AValue)]);
    return Result;
  };
  this.TryJulianDateToDateTime = function (AValue, ADateTime) {
    var Result = false;
    var a = 0;
    var b = 0;
    var c = 0;
    var d = 0;
    var e = 0;
    var m = 0;
    var day = 0;
    var month = 0;
    var year = 0;
    a = pas.System.Trunc(AValue + 32044.5);
    b = rtl.trunc(((4 * a) + 3) / 146097);
    c = a - rtl.trunc((146097 * b) / 4);
    d = rtl.trunc(((4 * c) + 3) / 1461);
    e = c - rtl.trunc((1461 * d) / 4);
    m = rtl.trunc(((5 * e) + 2) / 153);
    day = (e - rtl.trunc(((153 * m) + 2) / 5)) + 1;
    month = (m + 3) - (12 * rtl.trunc(m / 10));
    year = (((100 * b) + d) - 4800) + rtl.trunc(m / 10);
    Result = pas.SysUtils.TryEncodeDate(year,month,day,ADateTime);
    if (Result) ADateTime.set(ADateTime.get() + pas.System.Frac(AValue - 0.5));
    return Result;
  };
  this.DateTimeToModifiedJulianDate = function (AValue) {
    var Result = 0.0;
    Result = $mod.DateTimeToJulianDate(AValue) - 2400000.5;
    return Result;
  };
  this.ModifiedJulianDateToDateTime = function (AValue) {
    var Result = 0.0;
    Result = $mod.JulianDateToDateTime(AValue + 2400000.5);
    return Result;
  };
  this.TryModifiedJulianDateToDateTime = function (AValue, ADateTime) {
    var Result = false;
    Result = $mod.TryJulianDateToDateTime(AValue + 2400000.5,ADateTime);
    return Result;
  };
  this.DateTimeToUnix = function (AValue) {
    var Result = 0;
    Result = Math.round($impl.DateTimeDiff($mod.RecodeMilliSecond(AValue,0),25569) * 86400);
    return Result;
  };
  this.UnixToDateTime = function (AValue, AReturnUTC) {
    var Result = 0.0;
    if (AReturnUTC) {
      Result = $mod.IncSecond(25569,AValue)}
     else Result = $mod.TTimeZone.GetLocal().ToLocalTime($mod.IncSecond(25569,AValue));
    return Result;
  };
  var Epoch = 24107 * 24 * 3600;
  this.UnixTimeStampToMac = function (AValue) {
    var Result = 0;
    Result = AValue + 2082844800;
    return Result;
  };
  this.DateTimeToMac = function (AValue) {
    var Result = 0;
    var Epoch = 0.0;
    Epoch = $mod.EncodeDateTime(1904,1,1,0,0,0,0);
    Result = $mod.SecondsBetween(Epoch,AValue);
    return Result;
  };
  this.MacToDateTime = function (AValue) {
    var Result = 0.0;
    var Epoch = 0.0;
    Epoch = $mod.EncodeDateTime(1904,1,1,0,0,0,0);
    Result = $mod.IncSecond(Epoch,AValue);
    return Result;
  };
  var Epoch$1 = 24107 * 24 * 3600;
  this.MacTimeStampToUnix = function (AValue) {
    var Result = 0;
    Result = AValue - 2082844800;
    return Result;
  };
  this.DateTimeToDosDateTime = function (AValue) {
    var Result = 0;
    var year = 0;
    var month = 0;
    var day = 0;
    var hour = 0;
    var min = 0;
    var sec = 0;
    var msec = 0;
    var zs = 0;
    $mod.DecodeDateTime(AValue,{get: function () {
        return year;
      }, set: function (v) {
        year = v;
      }},{get: function () {
        return month;
      }, set: function (v) {
        month = v;
      }},{get: function () {
        return day;
      }, set: function (v) {
        day = v;
      }},{get: function () {
        return hour;
      }, set: function (v) {
        hour = v;
      }},{get: function () {
        return min;
      }, set: function (v) {
        min = v;
      }},{get: function () {
        return sec;
      }, set: function (v) {
        sec = v;
      }},{get: function () {
        return msec;
      }, set: function (v) {
        msec = v;
      }});
    Result = -1980;
    Result = Result + (year & 127);
    Result = Result << 4;
    Result = Result + month;
    Result = Result << 5;
    Result = Result + day;
    Result = Result << 16;
    zs = hour;
    zs = zs << 6;
    zs = zs + min;
    zs = zs << 5;
    zs = zs + rtl.trunc(sec / 2);
    Result = Result + (zs & 0xffff);
    return Result;
  };
  this.DosDateTimeToDateTime = function (AValue) {
    var Result = 0.0;
    var year = 0;
    var month = 0;
    var day = 0;
    var hour = 0;
    var min = 0;
    var sec = 0;
    sec = (AValue & 31) * 2;
    AValue = AValue >>> 5;
    min = AValue & 63;
    AValue = AValue >>> 6;
    hour = AValue & 31;
    AValue = AValue >>> 5;
    day = AValue & 31;
    AValue = AValue >>> 5;
    month = AValue & 15;
    AValue = AValue >>> 4;
    year = AValue + 1980;
    Result = $mod.EncodeDateTime(year,month,day,hour,min,sec,0);
    return Result;
  };
  this.UniversalTimeToLocal = function (UT) {
    var Result = 0.0;
    var lOffset = 0;
    $impl.GetLocalTimeOffset$1(UT,true,{get: function () {
        return lOffset;
      }, set: function (v) {
        lOffset = v;
      }});
    Result = $mod.UniversalTimeToLocal$1(UT,-lOffset);
    return Result;
  };
  this.UniversalTimeToLocal$1 = function (UT, TZOffset) {
    var Result = 0.0;
    if (TZOffset > 0) {
      Result = UT + pas.SysUtils.EncodeTime(rtl.trunc(TZOffset / 60),TZOffset % 60,0,0)}
     else if (TZOffset < 0) {
      Result = UT - pas.SysUtils.EncodeTime(rtl.trunc(Math.abs(TZOffset) / 60),Math.abs(TZOffset) % 60,0,0)}
     else Result = UT;
    return Result;
  };
  this.LocalTimeToUniversal = function (LT) {
    var Result = 0.0;
    var lOffset = 0;
    $impl.GetLocalTimeOffset$1(LT,false,{get: function () {
        return lOffset;
      }, set: function (v) {
        lOffset = v;
      }});
    Result = $mod.LocalTimeToUniversal$1(LT,-lOffset);
    return Result;
  };
  this.LocalTimeToUniversal$1 = function (LT, TZOffset) {
    var Result = 0.0;
    if (TZOffset > 0) {
      Result = LT - pas.SysUtils.EncodeTime(rtl.trunc(TZOffset / 60),TZOffset % 60,0,0)}
     else if (TZOffset < 0) {
      Result = LT + pas.SysUtils.EncodeTime(rtl.trunc(Math.abs(TZOffset) / 60),Math.abs(TZOffset) % 60,0,0)}
     else Result = LT;
    return Result;
  };
  this.DateTimeToRFC3339 = function (ADate) {
    var Result = "";
    Result = pas.SysUtils.FormatDateTime('yyyy-mm-dd"T"hh":"nn":"ss"."zzz"Z"',ADate);
    return Result;
  };
  this.DateToRFC3339 = function (ADate) {
    var Result = "";
    Result = pas.SysUtils.FormatDateTime("yyyy-mm-dd",ADate);
    return Result;
  };
  this.TimeToRFC3339 = function (ADate) {
    var Result = "";
    Result = pas.SysUtils.FormatDateTime('hh":"nn":"ss"."zzz',ADate);
    return Result;
  };
  var TPartPos = {"0": "ppTime", ppTime: 0, "1": "ppYear", ppYear: 1, "2": "ppMonth", ppMonth: 2, "3": "ppDay", ppDay: 3, "4": "ppHour", ppHour: 4, "5": "ppMinute", ppMinute: 5, "6": "ppSec", ppSec: 6, "7": "ppMSec", ppMSec: 7};
  var P = [11,1,6,9,12,15,18,21];
  this.TryRFC3339ToDateTime = function (Avalue, ADateTime) {
    var Result = false;
    var lY = 0;
    var lM = 0;
    var lD = 0;
    var lH = 0;
    var lMi = 0;
    var lS = 0;
    var lMs = 0;
    if (pas.SysUtils.Trim(Avalue) === "") {
      Result = true;
      ADateTime.set(0);
    };
    lY = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppYear],4),-1);
    lM = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppMonth],2),-1);
    lD = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppDay],2),-1);
    if (Avalue.length >= P[TPartPos.ppTime]) {
      lH = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppHour],2),-1);
      lMi = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppMinute],2),-1);
      if (Avalue.length >= P[TPartPos.ppSec]) {
        lS = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppSec],2),-1)}
       else lS = 0;
      if (Avalue.length >= P[TPartPos.ppMSec]) lMs = pas.SysUtils.StrToIntDef(pas.System.Copy(Avalue,P[TPartPos.ppMSec],3),-1);
    } else {
      lH = 0;
      lMi = 0;
      lS = 0;
      lMs = 0;
    };
    Result = (lY >= 0) && (lM >= 0) && (lD >= 0) && (lH >= 0) && (lMi >= 0) && (lS >= 0) && (lMs >= 0);
    if (!Result) {
      ADateTime.set(0)}
     else if ((lY === 0) || (lM === 0) || (lD === 0)) {
      ADateTime.set(pas.SysUtils.EncodeTime(lH,lMi,lS,0))}
     else ADateTime.set(pas.SysUtils.EncodeDate(lY,lM,lD) + pas.SysUtils.EncodeTime(lH,lMi,lS,lMs));
    return Result;
  };
  this.RFC3339ToDateTime = function (Avalue) {
    var Result = 0.0;
    if (!$mod.TryRFC3339ToDateTime(Avalue,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = 0;
    return Result;
  };
  this.DateTimeToMilliseconds = function (ADateTime) {
    var Result = 0;
    var LTimeStamp = pas.SysUtils.TTimeStamp.$new();
    LTimeStamp.$assign(pas.SysUtils.DateTimeToTimeStamp(ADateTime));
    Result = LTimeStamp.Date;
    Result = (Result * 86400000) + LTimeStamp.Time;
    return Result;
  };
  this.TimeToMilliseconds = function (ATime) {
    var Result = 0;
    Result = Math.round(Math.abs($mod.TimeOf(ATime)) * 86400000);
    return Result;
  };
  rtl.createClass(this,"TDateTimeScanner",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FPattern = "";
      this.FText = "";
      this.FPatternOffset = 0;
      this.FLen = 0;
      this.FPatternLen = 0;
      this.FPatternPos = 0;
      this.FPos = 0;
      this.FY = 0;
      this.FM = 0;
      this.FD = 0;
      this.FTimeval = 0.0;
    };
    this.ArrayMatchError = function () {
      $impl.raiseexception(pas.SysUtils.Format($impl.SNoArrayMatch,pas.System.VarRecs(0,this.FPatternPos + 1,0,this.FPos)));
    };
    this.DoDateTime = function () {
      this.MatchPattern(pas.SysUtils.FormatSettings.ShortDateFormat);
      this.MatchPattern("\t");
      this.MatchPattern(pas.SysUtils.FormatSettings.LongTimeFormat);
      this.FPatternPos += 1;
    };
    this.SetPattern = function (AValue) {
      if (this.FPattern === AValue) return;
      this.FPattern = AValue;
      this.FPatternLen = this.FPattern.length;
    };
    this.SetText = function (AValue) {
      if (this.FText === AValue) return;
      this.FText = AValue;
      this.FLen = this.FText.length;
    };
    this.ScanFixedInt = function (maxv) {
      var Result = 0;
      var c = "\x00";
      var n = "\x00";
      var oi = 0;
      Result = 0;
      oi = this.FPos;
      c = this.FPattern.charAt(this.FPatternPos - 1);
      while ((this.FPatternPos <= this.FPatternLen) && (this.FPattern.charAt(this.FPatternPos - 1) === c)) this.FPatternPos += 1;
      n = this.FText.charAt(this.FPos - 1);
      while ((maxv > 0) && (this.FPos <= this.FLen) && (n.charCodeAt() in rtl.createSet(null,48,57))) {
        Result = ((Result * 10) + n.charCodeAt()) - 48;
        this.FPos += 1;
        maxv -= 1;
        if (this.FPos <= this.FLen) n = this.FText.charAt(this.FPos - 1);
      };
      if (oi === this.FPos) $impl.raiseexception(pas.SysUtils.Format($impl.SPatternCharMismatch,pas.System.VarRecs(9,c,0,oi)));
      return Result;
    };
    this.ScanPatternLength = function () {
      var Result = 0;
      var c = "\x00";
      var i = 0;
      Result = this.FPatternPos;
      i = this.FPatternPos;
      c = this.FPattern.charAt(i - 1);
      while ((i <= this.FPatternLen) && (this.FPattern.charAt(i - 1) === c)) i += 1;
      Result = i - Result;
      return Result;
    };
    this.MatchChar = function (c) {
      var N = "\x00";
      if (this.FPos <= this.FLen) {
        N = this.FText.charAt(this.FPos - 1)}
       else N = "?";
      if (N !== c) $impl.raiseexception(pas.SysUtils.Format($impl.SNoCharMatch,pas.System.VarRecs(9,N,9,c,0,this.FPatternPos + this.FPatternOffset,0,this.FPos)));
      this.FPatternPos += 1;
      this.FPos += 1;
    };
    this.FindIMatch = function (values, aTerm) {
      var Result = 0;
      var l = 0;
      var i = 0;
      Result = -1;
      l = rtl.length(values) - 1;
      i = 0;
      while ((i <= l) && (Result === -1)) {
        if (pas.SysUtils.SameText(pas.System.Copy(aTerm,1,values[i].length),values[i])) Result = i;
        i += 1;
      };
      return Result;
    };
    this.FindMatch = function (Values) {
      var Result = 0;
      Result = this.FindIMatch(Values,pas.System.Copy(this.FText,this.FPos,(this.FLen - this.FPos) + 1));
      if (Result === -1) {
        this.ArrayMatchError()}
       else {
        this.FPos += Values[Result].length + 1;
        this.FPatternPos += Values[Result].length + 1;
        Result += 1;
      };
      return Result;
    };
    this.MatchPattern = function (aPattern) {
      var T = "";
      var cPos = 0;
      T = this.FPattern;
      cPos = this.FPatternPos;
      this.FPatternOffset = this.FPatternPos;
      this.FPattern = aPattern;
      this.FPatternLen = aPattern.length;
      try {
        this.Scan(-1);
      } finally {
        this.FPattern = T;
        this.FPatternLen = aPattern.length;
        this.FPatternPos = cPos;
        this.FPatternOffset = 0;
      };
    };
    this.DoYear = function () {
      var I = 0;
      var pivot = 0;
      I = this.ScanPatternLength();
      this.FY = this.ScanFixedInt(4);
      if (I <= 2) {
        pivot = $mod.YearOf(pas.SysUtils.Now()) - pas.SysUtils.TwoDigitYearCenturyWindow;
        this.FY += rtl.trunc(pivot / 100) * 100;
        if ((pas.SysUtils.TwoDigitYearCenturyWindow > 0) && (this.FY < pivot)) this.FY += 100;
      };
    };
    this.DoMonth = function () {
      var I = 0;
      I = this.ScanPatternLength();
      var $tmp = I;
      if (($tmp === 1) || ($tmp === 2)) {
        this.FM = this.ScanFixedInt(2)}
       else if ($tmp === 3) {
        this.FM = this.FindMatch(pas.SysUtils.FormatSettings.ShortMonthNames)}
       else if ($tmp === 4) this.FM = this.FindMatch(pas.SysUtils.FormatSettings.LongMonthNames);
    };
    this.DoDay = function () {
      var I = 0;
      I = this.ScanPatternLength();
      var $tmp = I;
      if (($tmp === 1) || ($tmp === 2)) {
        this.FD = this.ScanFixedInt(2)}
       else if ($tmp === 3) {
        this.FD = this.FindMatch(pas.SysUtils.FormatSettings.ShortDayNames)}
       else if ($tmp === 4) {
        this.FD = this.FindMatch(pas.SysUtils.FormatSettings.LongDayNames)}
       else if ($tmp === 5) {
        this.MatchPattern(pas.SysUtils.FormatSettings.ShortDateFormat)}
       else if ($tmp === 6) this.MatchPattern(pas.SysUtils.FormatSettings.LongDateFormat);
    };
    this.DoTime = function () {
      var I = 0;
      I = this.ScanPatternLength();
      var $tmp = I;
      if ($tmp === 1) {
        this.MatchPattern(pas.SysUtils.FormatSettings.ShortTimeFormat)}
       else if ($tmp === 2) this.MatchPattern(pas.SysUtils.FormatSettings.LongTimeFormat);
    };
    this.DoAMPM = function () {
      var I = 0;
      I = this.FindIMatch($impl.AMPMformatting,pas.System.Copy(this.FPattern,this.FPatternPos,5));
      var $tmp = I;
      if ($tmp === 0) {
        I = this.FindIMatch(["AM","PM"],pas.System.Copy(this.FText,this.FPos,2));
        var $tmp1 = I;
        if ($tmp1 === 0) {}
        else if ($tmp1 === 1) {
          this.FTimeval = this.FTimeval + (12 * 0.041666666666666664)}
         else {
          this.ArrayMatchError();
        };
        this.FPatternPos += $impl.AMPMformatting[0].length;
        this.FPos += 2;
      } else if ($tmp === 1) {
        var $tmp2 = pas.System.upcase(this.FText.charAt(this.FPos - 1));
        if ($tmp2 === "A") {}
        else if ($tmp2 === "P") {
          this.FTimeval = this.FTimeval + (12 * 0.041666666666666664)}
         else {
          this.ArrayMatchError();
        };
        this.FPatternPos += $impl.AMPMformatting[1].length;
        this.FPos += 1;
      } else if ($tmp === 2) {
        I = this.FindIMatch([pas.SysUtils.FormatSettings.TimeAMString,pas.SysUtils.FormatSettings.TimePMString],pas.System.Copy(this.FText,this.FPos,5));
        var $tmp3 = I;
        if ($tmp3 === 0) {
          this.FPos += pas.SysUtils.FormatSettings.TimeAMString.length}
         else if ($tmp3 === 1) {
          this.FTimeval = this.FTimeval + (12 * 0.041666666666666664);
          this.FPos += pas.SysUtils.FormatSettings.TimePMString.length;
        } else {
          this.ArrayMatchError();
        };
        this.FPatternPos += $impl.AMPMformatting[2].length;
        this.FPatternPos += 2;
        this.FPos += 2;
      } else {
        this.MatchChar(this.FPattern.charAt(this.FPatternPos - 1));
      };
    };
    this.Scan = function (StartPos) {
      var Result = 0.0;
      var lasttoken = "\x00";
      var activequote = "\x00";
      var lch = "\x00";
      var i = 0;
      if (StartPos < 1) StartPos = 1;
      if (this.FPos < StartPos) this.FPos = StartPos;
      this.FPatternPos = 1;
      activequote = "\x00";
      lasttoken = " ";
      while ((this.FPos <= this.FLen) && (this.FPatternPos <= this.FPatternLen)) {
        lch = pas.System.upcase(this.FPattern.charAt(this.FPatternPos - 1));
        if (activequote !== "\x00") {
          if (activequote !== lch) {
            this.MatchChar(lch)}
           else {
            activequote = "\x00";
            this.FPatternPos += 1;
          };
        } else {
          if ((lch === "M") && (lasttoken === "H")) {
            i = this.ScanPatternLength();
            if (i > 2) $impl.raiseexception(pas.SysUtils.Format($impl.SHHMMError,pas.System.VarRecs(0,this.FPatternOffset + this.FPatternPos + 1)));
            this.FTimeval = this.FTimeval + (this.ScanFixedInt(2) * 6.9444444444444447E-4);
          } else {
            var $tmp = lch;
            if ($tmp === "Y") {
              this.DoYear()}
             else if ($tmp === "M") {
              this.DoMonth()}
             else if ($tmp === "D") {
              this.DoDay()}
             else if ($tmp === "T") {
              this.DoTime()}
             else if ($tmp === "H") {
              this.FTimeval = this.FTimeval + (this.ScanFixedInt(2) * 0.041666666666666664)}
             else if ($tmp === "N") {
              this.FTimeval = this.FTimeval + (this.ScanFixedInt(2) * 6.9444444444444447E-4)}
             else if ($tmp === "S") {
              this.FTimeval = this.FTimeval + (this.ScanFixedInt(2) * 1.1574074074074073E-5)}
             else if ($tmp === "Z") {
              this.FTimeval = this.FTimeval + (this.ScanFixedInt(3) * 1.1574074074074074E-8)}
             else if ($tmp === "A") {
              this.DoAMPM()}
             else if ($tmp === "/") {
              this.MatchChar(pas.SysUtils.FormatSettings.DateSeparator)}
             else if ($tmp === ":") {
              this.MatchChar(pas.SysUtils.FormatSettings.TimeSeparator);
              lch = lasttoken;
            } else if (($tmp === "'") || ($tmp === '"')) {
              activequote = lch;
              this.FPatternPos += 1;
            } else if ($tmp === "C") {
              this.DoDateTime()}
             else if ($tmp === "?") {
              this.FPatternPos += 1;
              this.FPos += 1;
            } else if ($tmp === "\t") {
              while ((this.FPos <= this.FLen) && (this.FText.charCodeAt(this.FPos - 1) in $impl.whitespace)) this.FPos += 1;
              this.FPatternPos += 1;
            } else {
              this.MatchChar(this.FPattern.charAt(this.FPatternPos - 1));
            };
          };
          lasttoken = lch;
        };
      };
      Result = this.FTimeval;
      if ((this.FY > 0) && (this.FM > 0) && (this.FD > 0)) Result = Result + pas.SysUtils.EncodeDate(this.FY,this.FM,this.FD);
      return Result;
    };
  });
  this.ScanDateTime = function (APattern, AValue, APos) {
    var Result = 0.0;
    var T = null;
    T = $mod.TDateTimeScanner.$create("Create");
    try {
      T.SetPattern(APattern);
      T.SetText(AValue);
      Result = T.Scan(APos);
    } finally {
      T = rtl.freeLoc(T);
    };
    return Result;
  };
  this.TLocalTimeType = {"0": "lttStandard", lttStandard: 0, "1": "lttDaylight", lttDaylight: 1, "2": "lttAmbiguous", lttAmbiguous: 2, "3": "lttInvalid", lttInvalid: 3};
  this.$rtti.$Enum("TLocalTimeType",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TLocalTimeType});
  rtl.createClass(this,"ELocalTimeInvalid",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EDateTimeException",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"TTimeZone",pas.System.TObject,function () {
    this.FLocal = null;
    this.GetAbbreviationForNow = function () {
      var Result = "";
      Result = this.GetAbbreviation(pas.SysUtils.Now(),false);
      return Result;
    };
    this.GetCurrentUtcOffset = function () {
      var Result = pas.TimeSpan.TTimeSpan.$new();
      Result.$assign(this.GetUtcOffset(pas.SysUtils.Now(),false));
      return Result;
    };
    this.GetDisplayNameForNow = function () {
      var Result = "";
      Result = this.GetDisplayName(pas.SysUtils.Now(),false);
      return Result;
    };
    this.GetLocal = function () {
      var Result = null;
      if (!(this.FLocal != null)) $mod.TTimeZone.FLocal = $mod.TLocalTimeZone.$create("Create$1");
      Result = this.FLocal;
      return Result;
    };
    this.GetUtcOffsetInSeconds = function (ADateTime, AForceDaylight) {
      var Result = 0;
      var lDSTSave = 0;
      var lOffset = 0;
      var lType = 0;
      this.DoGetOffsetsAndType(ADateTime,{get: function () {
          return lOffset;
        }, set: function (v) {
          lOffset = v;
        }},{get: function () {
          return lDSTSave;
        }, set: function (v) {
          lDSTSave = v;
        }},{get: function () {
          return lType;
        }, set: function (v) {
          lType = v;
        }});
      if (lType === $mod.TLocalTimeType.lttInvalid) {
        throw $mod.ELocalTimeInvalid.$create("CreateFmt",[rtl.getResStr($mod,"SLocalTimeInvalid"),pas.System.VarRecs(18,pas.SysUtils.DateTimeToStr(ADateTime,false))])}
       else if ((lType === $mod.TLocalTimeType.lttDaylight) || ((lType === $mod.TLocalTimeType.lttAmbiguous) && AForceDaylight)) {
        Result = lOffset + lDSTSave}
       else Result = lOffset;
      return Result;
    };
    var cAbbreviationFormat_Hours = "%s%s%.2d";
    var cAbbreviationFormat_Minutes = "%s%s%.2d:%.2d";
    var cGMT = "GMT";
    var cMinus = "-";
    var cPlus = "+";
    this.GetAbbreviation = function (ADateTime, AForceDaylight) {
      var Result = "";
      var lAbsOffset = 0;
      var lHours = 0;
      var lMinutes = 0;
      var lOffset = 0;
      var lSignChar = "\x00";
      lOffset = this.GetUtcOffsetInSeconds(ADateTime,AForceDaylight);
      if (lOffset === 0) {
        Result = cGMT}
       else {
        lAbsOffset = Math.abs(lOffset);
        lHours = rtl.trunc(lAbsOffset / 3600);
        lMinutes = rtl.trunc((lAbsOffset % 3600) / 60);
        if (lOffset < 0) {
          lSignChar = cMinus}
         else lSignChar = cPlus;
        if (lMinutes > 0) {
          Result = pas.SysUtils.Format(cAbbreviationFormat_Minutes,pas.System.VarRecs(18,cGMT,9,lSignChar,0,lHours,0,lMinutes))}
         else Result = pas.SysUtils.Format(cAbbreviationFormat_Hours,pas.System.VarRecs(18,cGMT,9,lSignChar,0,lHours));
      };
      return Result;
    };
    this.GetDisplayName = function (ADateTime, AForceDaylight) {
      var Result = "";
      if (this.GetLocalTimeType(ADateTime) === $mod.TLocalTimeType.lttInvalid) throw $mod.ELocalTimeInvalid.$create("CreateFmt",[rtl.getResStr($mod,"SLocalTimeInvalid"),pas.System.VarRecs(18,pas.SysUtils.DateTimeToStr(ADateTime,false))]);
      Result = this.DoGetDisplayName(ADateTime,AForceDaylight);
      return Result;
    };
    this.GetLocalTimeType = function (ADateTime) {
      var Result = 0;
      var lDSTSave = 0;
      var lOffset = 0;
      this.DoGetOffsetsAndType(ADateTime,{get: function () {
          return lOffset;
        }, set: function (v) {
          lOffset = v;
        }},{get: function () {
          return lDSTSave;
        }, set: function (v) {
          lDSTSave = v;
        }},{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetUtcOffset = function (ADateTime, AForceDaylight) {
      var Result = pas.TimeSpan.TTimeSpan.$new();
      Result.$assign(pas.TimeSpan.TTimeSpan.FromSeconds(this.GetUtcOffsetInSeconds(ADateTime,AForceDaylight)));
      return Result;
    };
    this.HasDST = function () {
      var Result = false;
      Result = this.HasDST$1(pas.SysUtils.Now());
      return Result;
    };
    this.HasDST$1 = function (AYear) {
      var Result = false;
      var lDstSave = 0;
      var lOffset = 0;
      var lType = 0;
      this.DoGetOffsetsAndType(AYear,{get: function () {
          return lOffset;
        }, set: function (v) {
          lOffset = v;
        }},{get: function () {
          return lDstSave;
        }, set: function (v) {
          lDstSave = v;
        }},{get: function () {
          return lType;
        }, set: function (v) {
          lType = v;
        }});
      Result = lDstSave !== 0;
      return Result;
    };
    this.IncMilliSecond = function (AValue, ANumberOfMilliSeconds) {
      var Result = 0.0;
      var lTempTime = 0;
      var lTimeStamp = pas.SysUtils.TTimeStamp.$new();
      lTimeStamp.$assign(pas.SysUtils.DateTimeToTimeStamp(AValue));
      lTempTime = pas.SysUtils.TimeStampToMSecs(lTimeStamp);
      lTempTime = lTempTime + ANumberOfMilliSeconds;
      lTimeStamp.$assign(pas.SysUtils.MSecsToTimeStamp(lTempTime));
      Result = pas.SysUtils.TimeStampToDateTime(lTimeStamp);
      return Result;
    };
    this.IncSecond = function (AValue, ANumberOfSeconds) {
      var Result = 0.0;
      Result = this.IncMilliSecond(AValue,ANumberOfSeconds * 1000);
      return Result;
    };
    this.IsAmbiguousTime = function (ADateTime) {
      var Result = false;
      Result = this.GetLocalTimeType(ADateTime) === $mod.TLocalTimeType.lttAmbiguous;
      return Result;
    };
    this.IsDaylightTime = function (ADateTime, AForceDaylight) {
      var Result = false;
      var $tmp = this.GetLocalTimeType(ADateTime);
      if ($tmp === $mod.TLocalTimeType.lttDaylight) {
        Result = true}
       else if ($tmp === $mod.TLocalTimeType.lttAmbiguous) {
        Result = AForceDaylight}
       else {
        Result = false;
      };
      return Result;
    };
    this.IsInvalidTime = function (ADateTime) {
      var Result = false;
      Result = this.GetLocalTimeType(ADateTime) === $mod.TLocalTimeType.lttInvalid;
      return Result;
    };
    this.IsStandardTime = function (ADateTime, AForceDaylight) {
      var Result = false;
      var $tmp = this.GetLocalTimeType(ADateTime);
      if ($tmp === $mod.TLocalTimeType.lttStandard) {
        Result = true}
       else if ($tmp === $mod.TLocalTimeType.lttAmbiguous) {
        Result = !AForceDaylight}
       else {
        Result = false;
      };
      return Result;
    };
    this.ToLocalTime = function (ADateTime) {
      var Result = 0.0;
      var lDSTSave = 0;
      var lOffset = 0;
      var lType = 0;
      this.DoGetOffsetsAndType(ADateTime,{get: function () {
          return lOffset;
        }, set: function (v) {
          lOffset = v;
        }},{get: function () {
          return lDSTSave;
        }, set: function (v) {
          lDSTSave = v;
        }},{get: function () {
          return lType;
        }, set: function (v) {
          lType = v;
        }});
      Result = this.IncSecond(ADateTime,lOffset);
      this.DoGetOffsetsAndType(Result,{get: function () {
          return lOffset;
        }, set: function (v) {
          lOffset = v;
        }},{get: function () {
          return lDSTSave;
        }, set: function (v) {
          lDSTSave = v;
        }},{get: function () {
          return lType;
        }, set: function (v) {
          lType = v;
        }});
      if (lType in rtl.createSet($mod.TLocalTimeType.lttInvalid,$mod.TLocalTimeType.lttDaylight)) Result = this.IncSecond(Result,lDSTSave);
      return Result;
    };
    this.ToUniversalTime = function (ADateTime, AForceDaylight) {
      var Result = 0.0;
      var lOffset = 0;
      lOffset = this.GetUtcOffsetInSeconds(ADateTime,AForceDaylight);
      Result = this.IncSecond(ADateTime,-lOffset);
      return Result;
    };
  });
  rtl.createClass(this,"TLocalTimeZone",this.TTimeZone,function () {
    this.$init = function () {
      $mod.TTimeZone.$init.call(this);
      this.FDST = null;
    };
    this.$final = function () {
      this.FDST = undefined;
      $mod.TTimeZone.$final.call(this);
    };
    this.DoGetDisplayName = function (ADateTime, AForceDaylight) {
      var Result = "";
      var lDateTime = 0;
      var lLocale = "";
      lLocale = undefined;
      lDateTime = $mod.DateTimeToUnix(ADateTime) * 1000;
      Result = (new Date(lDateTime)).toLocaleDateString(lLocale,pas.JS.New(["day","2-digit","timeZoneName","long"]));
      Result = pas.SysUtils.TStringHelper.Substring.call({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},4);
      return Result;
    };
    this.DoGetID = function () {
      var Result = "";
      var lLocale = "";
      lLocale = undefined;
      Result = (new Date()).toLocaleDateString(lLocale,pas.JS.New(["day","2-digit","timeZoneName","longGeneric"]));
      Result = pas.SysUtils.TStringHelper.Substring.call({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},4);
      return Result;
    };
    var cIndexJanuary = 0;
    var cIndexJuly = 6;
    this.DoGetOffsetsAndType = function (ADateTime, AOffset, ADstSave, AType) {
      var lDate = null;
      var lOffsetSummer = 0;
      var lOffsetWinter = 0;
      var lStdOffset = 0;
      var lDST = pas["Generics.Collections"].TPair$$$G$$generics$collections$$Double$$Double.$new();
      lDate = new Date($mod.DateTimeToUnix(ADateTime) * 1000);
      lOffsetSummer = (new Date($mod.YearOf(ADateTime),6,1,0,0,0,0)).getTimezoneOffset();
      lOffsetWinter = (new Date($mod.YearOf(ADateTime),0,1,0,0,0,0)).getTimezoneOffset();
      lStdOffset = Math.max(lOffsetSummer,lOffsetWinter);
      AOffset.set(-lStdOffset * 60);
      ADstSave.set(Math.abs(lOffsetSummer - lOffsetWinter) * 60);
      if (this.FDST.Force($mod.YearOf(ADateTime),lDST)) {
        if ((ADateTime > lDST.Key) && (ADateTime < $mod.IncHour$1(lDST.Key))) {
          AType.set($mod.TLocalTimeType.lttInvalid);
          return;
        };
        if ((ADateTime > lDST.Value) && (ADateTime < $mod.IncHour$1(lDST.Value))) {
          AType.set($mod.TLocalTimeType.lttAmbiguous);
          return;
        };
      };
      if (lDate.getTimezoneOffset() === lStdOffset) {
        AType.set($mod.TLocalTimeType.lttStandard)}
       else AType.set($mod.TLocalTimeType.lttDaylight);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FDST = pas["dateutils.helper"].TDateUtilsHelper.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FDST");
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.TISO8601ToDateOption = {"0": "ioReturnUTC", ioReturnUTC: 0, "1": "ioNoTZIsLocal", ioNoTZIsLocal: 1};
  this.$rtti.$Enum("TISO8601ToDateOption",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TISO8601ToDateOption});
  this.$rtti.$Set("TISO8601ToDateOptions",{comptype: this.$rtti["TISO8601ToDateOption"]});
  this.ISO8601ToDate = function (AISODate, AReturnUTC) {
    var Result = 0.0;
    if (!$mod.TryISO8601ToDate$1(AISODate,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},rtl.refSet($impl.CISO8601ToDateOptions[+AReturnUTC]))) throw $mod.EDateTimeException.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeStamp"),pas.System.VarRecs(18,AISODate)]);
    return Result;
  };
  this.ISO8601ToDate$1 = function (AISODate, AOptions) {
    var Result = 0.0;
    if (!$mod.TryISO8601ToDate$1(AISODate,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},rtl.refSet(AOptions))) throw $mod.EDateTimeException.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeStamp"),pas.System.VarRecs(18,AISODate)]);
    return Result;
  };
  this.TryISO8601ToDate = function (AISODate, AValue, AReturnUTC) {
    var Result = false;
    Result = $mod.TryISO8601ToDate$1(AISODate,AValue,rtl.refSet($impl.CISO8601ToDateOptions[+AReturnUTC]));
    return Result;
  };
  this.TryISO8601ToDate$1 = function (AISODate, AValue, AOptions) {
    var Result = false;
    var S = "";
    var TZ = "";
    var L = 0;
    var Offset = 0;
    var TZOffset = 0;
    S = AISODate;
    L = S.length;
    if (L === 0) return false;
    if (S.charAt(L - 1) === "Z") {
      TZ = "Z";
      S = pas.System.Copy(S,1,L - 1);
    } else if (((L > 11) && ((S.charCodeAt(10) in rtl.createSet(84,32)) || (S.charCodeAt(8) in rtl.createSet(84,32)))) || (S.charAt(0) === "T")) {
      if (S.charCodeAt(L - 2 - 1) in rtl.createSet(43,45)) {
        TZ = pas.System.Copy(S,L - 2,3);
        S = pas.System.Copy(S,1,L - 3);
      } else if (S.charCodeAt(L - 4 - 1) in rtl.createSet(43,45)) {
        TZ = pas.System.Copy(S,L - 4,5);
        S = pas.System.Copy(S,1,L - 5);
      } else if ((S.charCodeAt(L - 5 - 1) in rtl.createSet(43,45)) && ((L > 13) || (S.charAt(0) === "T"))) {
        TZ = pas.System.Copy(S,L - 5,6);
        S = pas.System.Copy(S,1,L - 6);
      };
    };
    Result = $impl.TryISOStrToDateTime(S,AValue);
    if (TZ === "") {
      if ($mod.TISO8601ToDateOption.ioNoTZIsLocal in AOptions) {
        if ($mod.TISO8601ToDateOption.ioReturnUTC in AOptions) AValue.set($mod.LocalTimeToUniversal(AValue.get()));
      } else {
        if (!($mod.TISO8601ToDateOption.ioReturnUTC in AOptions)) {
          Result = Result && $impl.GetLocalTimeOffset$1(AValue.get(),false,{get: function () {
              return TZOffset;
            }, set: function (v) {
              TZOffset = v;
            }});
          if (!Result) return Result;
          AValue.set($mod.IncMinute(AValue.get(),TZOffset));
        };
      };
    } else {
      Result = Result && $impl.TryISOTZStrToTZOffset(TZ,{get: function () {
          return TZOffset;
        }, set: function (v) {
          TZOffset = v;
        }});
      if (!Result) return Result;
      AValue.set($mod.IncMinute(AValue.get(),TZOffset));
      if ($mod.TISO8601ToDateOption.ioReturnUTC in AOptions) {
        Offset = 0}
       else Offset = -$impl.GetLocalTimeOffset$2(AValue.get(),true);
      AValue.set($mod.IncMinute(AValue.get(),Offset));
    };
    return Result;
  };
  var SDateFormat = "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d.%.3dZ";
  var SOffsetFormat = "%s%s%.02d:%.02d";
  var Neg = ["+","-"];
  this.DateToISO8601 = function (ADate, AInputIsUTC) {
    var Result = "";
    var y = 0;
    var mo = 0;
    var d = 0;
    var h = 0;
    var mi = 0;
    var se = 0;
    var ms = 0;
    var Bias = 0;
    var TimeZone = null;
    pas.SysUtils.DecodeDate(ADate,{get: function () {
        return y;
      }, set: function (v) {
        y = v;
      }},{get: function () {
        return mo;
      }, set: function (v) {
        mo = v;
      }},{get: function () {
        return d;
      }, set: function (v) {
        d = v;
      }});
    pas.SysUtils.DecodeTime(ADate,{get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},{get: function () {
        return mi;
      }, set: function (v) {
        mi = v;
      }},{get: function () {
        return se;
      }, set: function (v) {
        se = v;
      }},{get: function () {
        return ms;
      }, set: function (v) {
        ms = v;
      }});
    Result = pas.SysUtils.Format(SDateFormat,pas.System.VarRecs(0,y,0,mo,0,d,0,h,0,mi,0,se,0,ms));
    if (!AInputIsUTC) {
      TimeZone = $mod.TTimeZone.GetLocal();
      Bias = pas.System.Trunc(TimeZone.GetUtcOffset(ADate,false).Negate().GetTotalMinutes());
      if (Bias !== 0) {
        Result = rtl.strSetLength(Result,pas.SysUtils.TStringHelper.GetLength.call({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }}) - 1);
        Result = pas.SysUtils.Format(SOffsetFormat,pas.System.VarRecs(18,Result,18,Neg[+(Bias > 0)],0,rtl.trunc(Math.abs(Bias) / 60),0,Math.abs(Bias) % 60));
      };
    };
    return Result;
  };
  $mod.$implcode = function () {
    $impl.TDateTimeEpsilon = 2.2204460493e-16;
    $impl.HalfMilliSecond = 1.1574074074074074E-8 / 2;
    $impl.IsValidMonth = function (AMonth) {
      var Result = false;
      Result = (AMonth >= 1) && (AMonth <= 12);
      return Result;
    };
    $impl.IsValidDayOfWeek = function (ADayOfWeek) {
      var Result = false;
      Result = (ADayOfWeek >= 1) && (ADayOfWeek <= 7);
      return Result;
    };
    $impl.IsValidWeekOfMonth = function (AWeekOfMonth) {
      var Result = false;
      Result = (AWeekOfMonth >= 1) && (AWeekOfMonth <= 5);
      return Result;
    };
    $mod.$rtti.$StaticArray("DOWMap$a",{dims: [7], eltype: rtl.word});
    $impl.DOWMap = [7,1,2,3,4,5,6];
    $impl.DateTimeDiff = function (ANow, AThen) {
      var Result = 0.0;
      Result = ANow - AThen;
      if ((ANow > 0) && (AThen < 0)) {
        Result = Result - 0.5}
       else if ((ANow < -1.0) && (AThen > -1.0)) Result = Result + 0.5;
      return Result;
    };
    $impl.MaybeSkipTimeWarp = function (OldDate, NewDate) {
      if ((OldDate >= 0) && (NewDate.get() < -2.2204460493E-16)) {
        NewDate.set(pas.System.Int((NewDate.get() - 1.0) + 2.2204460493E-16) - pas.System.Frac(1.0 + pas.System.Frac(NewDate.get())))}
       else if ((OldDate <= -1.0) && (NewDate.get() > (-1.0 + 2.2204460493E-16))) NewDate.set(pas.System.Int((NewDate.get() + 1.0) - 2.2204460493E-16) + pas.System.Frac(1.0 - Math.abs(pas.System.Frac(1.0 + NewDate.get()))));
    };
    $impl.IncNegativeTime = function (AValue, Addend) {
      var Result = 0.0;
      var newtime = 0.0;
      newtime = -pas.System.Frac(AValue) + pas.System.Frac(Addend);
      if (pas.Math.SameValue(newtime,pas.System.Int(newtime) + 1,2.2204460493E-16)) {
        newtime = pas.System.Int(newtime) + 1}
       else if (pas.Math.SameValue(newtime,pas.System.Int(newtime),2.2204460493E-16)) newtime = pas.System.Int(newtime);
      if (newtime < -2.2204460493E-16) {
        newtime = 1.0 + newtime;
        AValue = pas.System.Int(AValue) - 1;
      } else if (newtime >= (1.0 - 2.2204460493E-16)) {
        newtime = newtime - 1.0;
        AValue = pas.System.Int(AValue) + 1;
      };
      Result = (pas.System.Int(AValue) + pas.System.Int(Addend)) - newtime;
      return Result;
    };
    $impl.LFAI = 65535;
    $impl.InternalNthDayOfWeek = function (DoM) {
      var Result = 0;
      Result = rtl.trunc((DoM - 1) / 7) + 1;
      return Result;
    };
    $impl.whitespace = rtl.createSet(32,13,10);
    $impl.hrfactor = 1 / 24;
    $impl.minfactor = 1 / (24 * 60);
    $impl.secfactor = 1 / (24 * 60 * 60);
    $impl.mssecfactor = 1 / (24 * 60 * 60 * 1000);
    $mod.$rtti.$StaticArray("AMPMformatting$a",{dims: [3], eltype: rtl.string});
    $impl.AMPMformatting = ["am/pm","a/p","ampm"];
    $impl.raiseexception = function (s) {
      throw pas.SysUtils.EConvertError.$create("Create$1",[s]);
    };
    $impl.GetLocalTimeOffset = function () {
      var Result = 0;
      Result = (new Date()).getTimezoneOffset();
      return Result;
    };
    $impl.GetLocalTimeOffset$1 = function (DateTime, InputIsUTC, Offset) {
      var Result = false;
      Offset.set(pas.SysUtils.DateTimeToJSDate(DateTime,InputIsUTC).getTimezoneOffset());
      Result = true;
      return Result;
    };
    $impl.GetLocalTimeOffset$2 = function (DateTime, InputIsUTC) {
      var Result = 0;
      if (!$impl.GetLocalTimeOffset$1(DateTime,InputIsUTC,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = $impl.GetLocalTimeOffset();
      return Result;
    };
    $impl.SPatternCharMismatch = 'Pattern mismatch char "%s" at position %d.';
    $impl.SNoCharMatch = 'Mismatch char "%s" <> "%s" at pattern position %d, string position %d.';
    $impl.SHHMMError = "mm in a sequence hh:mm is interpreted as minutes. No longer versions allowed! (Position : %d).";
    $impl.SNoArrayMatch = "Can't match any allowed value at pattern position %d, string position %d.";
    $impl.TryISOStrToDate = function (aString, outDate) {
      var Result = false;
      var xYear = 0;
      var xMonth = 0;
      var xDay = 0;
      var $tmp = aString.length;
      if ($tmp === 4) {
        Result = pas.SysUtils.TryStrToInt(aString,{get: function () {
            return xYear;
          }, set: function (v) {
            xYear = v;
          }}) && pas.SysUtils.TryEncodeDate(xYear,1,1,outDate)}
       else if ($tmp === 6) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,4),{get: function () {
            return xYear;
          }, set: function (v) {
            xYear = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,5,2),{get: function () {
            return xMonth;
          }, set: function (v) {
            xMonth = v;
          }}) && pas.SysUtils.TryEncodeDate(xYear,xMonth,1,outDate)}
       else if ($tmp === 7) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,4),{get: function () {
            return xYear;
          }, set: function (v) {
            xYear = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,6,2),{get: function () {
            return xMonth;
          }, set: function (v) {
            xMonth = v;
          }}) && pas.SysUtils.TryEncodeDate(xYear,xMonth,1,outDate)}
       else if ($tmp === 8) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,4),{get: function () {
            return xYear;
          }, set: function (v) {
            xYear = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,5,2),{get: function () {
            return xMonth;
          }, set: function (v) {
            xMonth = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,7,2),{get: function () {
            return xDay;
          }, set: function (v) {
            xDay = v;
          }}) && pas.SysUtils.TryEncodeDate(xYear,xMonth,xDay,outDate)}
       else if ($tmp === 10) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,4),{get: function () {
            return xYear;
          }, set: function (v) {
            xYear = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,6,2),{get: function () {
            return xMonth;
          }, set: function (v) {
            xMonth = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,9,2),{get: function () {
            return xDay;
          }, set: function (v) {
            xDay = v;
          }}) && pas.SysUtils.TryEncodeDate(xYear,xMonth,xDay,outDate)}
       else {
        Result = false;
      };
      if (!Result) outDate.set(0);
      return Result;
    };
    $impl.TryISOStrToTime = function (aString, outTime) {
      var Result = false;
      var xHour = 0;
      var xMinute = 0;
      var xSecond = 0;
      var xLength = 0;
      var res = 0;
      var xFractionalSecond = 0.0;
      var tmp = "";
      Result = true;
      xLength = aString.length;
      if ((xLength > 0) && (aString.charAt(xLength - 1) === "Z")) {
        xLength -= 1;
      } else if ((xLength > 6) && pas.SysUtils.CharInSet(aString.charAt(xLength - 5 - 1),["+","-"])) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,xLength - 4,2),{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }}) && (aString.charAt(xLength - 2 - 1) === ":") && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,xLength - 1,2),{get: function () {
            return xMinute;
          }, set: function (v) {
            xMinute = v;
          }});
        xLength -= 6;
      } else if ((xLength > 5) && pas.SysUtils.CharInSet(aString.charAt(xLength - 4 - 1),["+","-"])) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,xLength - 3,2),{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,xLength - 1,2),{get: function () {
            return xMinute;
          }, set: function (v) {
            xMinute = v;
          }});
        xLength -= 5;
      } else if ((xLength > 3) && pas.SysUtils.CharInSet(aString.charAt(xLength - 2 - 1),["+","-"])) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,xLength - 1,2),{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }});
        xLength -= 3;
      };
      if (!Result) {
        outTime.set(0);
        return Result;
      };
      var $tmp = xLength;
      if ($tmp === 2) {
        Result = pas.SysUtils.TryStrToInt(aString,{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }}) && pas.SysUtils.TryEncodeTime(xHour,0,0,0,outTime)}
       else if ($tmp === 4) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,2),{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,3,2),{get: function () {
            return xMinute;
          }, set: function (v) {
            xMinute = v;
          }}) && pas.SysUtils.TryEncodeTime(xHour,xMinute,0,0,outTime)}
       else if ($tmp === 5) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,2),{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }}) && (aString.charAt(2) === ":") && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,4,2),{get: function () {
            return xMinute;
          }, set: function (v) {
            xMinute = v;
          }}) && pas.SysUtils.TryEncodeTime(xHour,xMinute,0,0,outTime)}
       else if ($tmp === 6) {
        Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,2),{get: function () {
            return xHour;
          }, set: function (v) {
            xHour = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,3,2),{get: function () {
            return xMinute;
          }, set: function (v) {
            xMinute = v;
          }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,5,2),{get: function () {
            return xSecond;
          }, set: function (v) {
            xSecond = v;
          }}) && pas.SysUtils.TryEncodeTime(xHour,xMinute,xSecond,0,outTime)}
       else {
        if ((xLength >= 8) && (aString.charAt(2) === ":") && (aString.charAt(5) === ":")) {
          Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,2),{get: function () {
              return xHour;
            }, set: function (v) {
              xHour = v;
            }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,4,2),{get: function () {
              return xMinute;
            }, set: function (v) {
              xMinute = v;
            }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,7,2),{get: function () {
              return xSecond;
            }, set: function (v) {
              xSecond = v;
            }}) && pas.SysUtils.TryEncodeTime(xHour,xMinute,xSecond,0,outTime);
          if (Result && (xLength >= 9)) {
            tmp = pas.System.Copy(aString,10,xLength - 9);
            pas.System.val$8("." + tmp,{get: function () {
                return xFractionalSecond;
              }, set: function (v) {
                xFractionalSecond = v;
              }},{get: function () {
                return res;
              }, set: function (v) {
                res = v;
              }});
            Result = res === 0;
            if (Result) outTime.set(outTime.get() + (xFractionalSecond * 1.1574074074074073E-5));
          };
        } else if ((xLength >= 7) && (aString.charCodeAt(6) in rtl.createSet(46,44))) {
          Result = pas.SysUtils.TryStrToInt(pas.System.Copy(aString,1,2),{get: function () {
              return xHour;
            }, set: function (v) {
              xHour = v;
            }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,3,2),{get: function () {
              return xMinute;
            }, set: function (v) {
              xMinute = v;
            }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(aString,5,2),{get: function () {
              return xSecond;
            }, set: function (v) {
              xSecond = v;
            }}) && pas.SysUtils.TryEncodeTime(xHour,xMinute,xSecond,0,outTime);
          tmp = pas.System.Copy(aString,8,xLength - 7);
          if (Result && (tmp !== "")) {
            pas.System.val$8("." + tmp,{get: function () {
                return xFractionalSecond;
              }, set: function (v) {
                xFractionalSecond = v;
              }},{get: function () {
                return res;
              }, set: function (v) {
                res = v;
              }});
            Result = res === 0;
            if (Result) outTime.set(outTime.get() + (xFractionalSecond * 1.1574074074074073E-5));
          };
        } else Result = false;
      };
      if (!Result) outTime.set(0);
      return Result;
    };
    $impl.TryISOStrToDateTime = function (aString, outDateTime) {
      var Result = false;
      var xLength = 0;
      var sDate = "";
      var sTime = "";
      var xDate = 0.0;
      var xTime = 0.0;
      xLength = aString.length;
      if (xLength === 0) return false;
      if (aString.charAt(0) === "T") {
        Result = $impl.TryISOStrToTime(pas.System.Copy(aString,2,aString.length - 1),outDateTime);
        return Result;
      };
      if (xLength in rtl.createSet(4,7,8,10)) {
        Result = $impl.TryISOStrToDate(aString,outDateTime);
        return Result;
      };
      if ((xLength > 11) && pas.SysUtils.CharInSet(aString.charAt(10),[" ","T"])) {
        sDate = pas.System.Copy(aString,1,10);
        sTime = pas.System.Copy(aString,12,aString.length);
      } else if ((xLength > 9) && pas.SysUtils.CharInSet(aString.charAt(8),[" ","T"])) {
        sDate = pas.System.Copy(aString,1,8);
        sTime = pas.System.Copy(aString,10,aString.length);
      } else return false;
      Result = $impl.TryISOStrToDate(sDate,{get: function () {
          return xDate;
        }, set: function (v) {
          xDate = v;
        }}) && $impl.TryISOStrToTime(sTime,{get: function () {
          return xTime;
        }, set: function (v) {
          xTime = v;
        }});
      if (Result) {
        outDateTime.set(xDate + xTime)}
       else outDateTime.set(0);
      return Result;
    };
    $impl.TryISOTZStrToTZOffset = function (TZ, TZOffset) {
      var Result = false;
      var H = 0;
      var M = 0;
      Result = (TZ === "Z") || (TZ === "");
      if (Result) {
        TZOffset.set(0)}
       else {
        Result = TZ.charCodeAt(0) in rtl.createSet(43,45);
        if (!Result) return Result;
        var $tmp = TZ.length;
        if ($tmp === 3) {
          Result = pas.SysUtils.TryStrToInt(pas.System.Copy(TZ,2,2),{get: function () {
              return H;
            }, set: function (v) {
              H = v;
            }});
          M = 0;
        } else if ($tmp === 5) {
          Result = pas.SysUtils.TryStrToInt(pas.System.Copy(TZ,2,2),{get: function () {
              return H;
            }, set: function (v) {
              H = v;
            }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(TZ,4,2),{get: function () {
              return M;
            }, set: function (v) {
              M = v;
            }})}
         else if ($tmp === 6) {
          Result = pas.SysUtils.TryStrToInt(pas.System.Copy(TZ,2,2),{get: function () {
              return H;
            }, set: function (v) {
              H = v;
            }}) && pas.SysUtils.TryStrToInt(pas.System.Copy(TZ,5,2),{get: function () {
              return M;
            }, set: function (v) {
              M = v;
            }})}
         else {
          Result = false;
        };
        if (!Result) return Result;
        TZOffset.set((H * 60) + M);
        if (TZ.charAt(0) === "+") TZOffset.set(-TZOffset.get());
      };
      return Result;
    };
    $impl.CISO8601ToDateOptions$a$clone = function (a) {
      var b = [];
      b.length = 2;
      for (var c = 0; c < 2; c++) b[c] = rtl.refSet(a[c]);
      return b;
    };
    $mod.$rtti.$StaticArray("CISO8601ToDateOptions$a",{dims: [2], eltype: $mod.$rtti["TISO8601ToDateOptions"]});
    $impl.CISO8601ToDateOptions = [{},rtl.createSet($mod.TISO8601ToDateOption.ioReturnUTC)];
    $mod.$resourcestrings = {SLocalTimeInvalid: {org: 'The given "%s" local time is invalid (situated within the missing period prior to DST).'}};
  };
},["JS","RTLConsts"]);
rtl.module("DBConst",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$resourcestrings = {SActiveDataset: {org: "Operation cannot be performed on an active dataset"}, SBadParamFieldType: {org: 'Bad fieldtype for parameter "%s".'}, SCantSetAutoIncFields: {org: "AutoInc Fields are read-only"}, SConnected: {org: "Operation cannot be performed on a connected database"}, SDatasetReadOnly: {org: "Dataset is read-only."}, SDatasetRegistered: {org: 'Dataset already registered : "%s"'}, SDuplicateFieldName: {org: 'Duplicate fieldname : "%s"'}, SErrAssTransaction: {org: "Cannot assign transaction while old transaction active!"}, SErrColumnNotFound: {org: 'Column "%s" not found.'}, SErrDatabasenAssigned: {org: "Database not assigned!"}, SErrNoDatabaseAvailable: {org: "Invalid operation: Not attached to database"}, SErrNoDatabaseName: {org: "Database connect string (DatabaseName) not filled in!"}, SErrNoSelectStatement: {org: "Cannot open a non-select statement"}, SErrNoStatement: {org: "SQL statement not set"}, SErrTransAlreadyActive: {org: "Transaction already active"}, SErrTransactionnSet: {org: "Transaction not set"}, SErrIndexResultTooLong: {org: 'Index result for "%s" too long, >100 characters (%d).'}, SErrIndexBasedOnInvField: {org: 'Field "%s" has an invalid field type (%s) to base index on.'}, SErrIndexBasedOnUnkField: {org: 'Index based on unknown field "%s".'}, SErrConnTransactionnSet: {org: "Transaction of connection not set"}, SErrNotASQLConnection: {org: '"%s" is not a TSQLConnection'}, SErrNotASQLQuery: {org: '"%s" is not a TCustomSQLQuery'}, STransNotActive: {org: "Operation cannot be performed on an inactive transaction"}, STransActive: {org: "Operation cannot be performed on an active transaction"}, SFieldNotFound: {org: 'Field not found : "%s"'}, SInactiveDataset: {org: "Operation cannot be performed on an inactive dataset"}, SInvalidDisplayValues: {org: '"%s" are not valid boolean displayvalues'}, SInvalidFieldKind: {org: "%s : invalid field kind : "}, SInvalidBookmark: {org: "Invalid bookmark"}, SInvalidFieldSize: {org: "Invalid field size : %d"}, SInvalidTypeConversion: {org: "Invalid type conversion to %s in field %s"}, SNeedField: {org: "Field %s is required, but not supplied."}, SNeedFieldName: {org: "Field needs a name"}, SNoDataset: {org: 'No dataset asssigned for field : "%s"'}, SNoDatasetRegistered: {org: 'No such dataset registered : "%s"'}, SNoDatasets: {org: "No datasets are attached to the database"}, SNoSuchRecord: {org: "Could not find the requested record."}, SNoTransactionRegistered: {org: 'No such transaction registered : "%s"'}, SNoTransactions: {org: "No transactions are attached to the database"}, SNotABoolean: {org: '"%s" is not a valid boolean'}, SNotAFloat: {org: '"%s" is not a valid float'}, SNotAninteger: {org: '"%s" is not a valid integer'}, SNotConnected: {org: "Operation cannot be performed on an disconnected database"}, SNotEditing: {org: 'Operation not allowed, dataset "%s" is not in an edit or insert state.'}, SParameterNotFound: {org: 'Parameter "%s" not found'}, SRangeError: {org: "%f is not between %f and %f for %s"}, SReadOnlyField: {org: "Field %s cannot be modified, it is read-only."}, STransactionRegistered: {org: 'Transaction already registered : "%s"'}, SUniDirectional: {org: "Operation cannot be performed on an unidirectional dataset"}, SUnknownField: {org: 'No field named "%s" was found in dataset "%s"'}, SUnknownFieldType: {org: "Unknown field type : %s"}, SUnknownParamFieldType: {org: 'Unknown fieldtype for parameter "%s".'}, SMetadataUnavailable: {org: "The metadata is not available for this type of database."}, SDeletedRecord: {org: "The record is deleted."}, SIndexNotFound: {org: "Index '%s' not found"}, SParameterCountIncorrect: {org: "The number of parameters is incorrect."}, SUnsupportedParameter: {org: "Parameters of the type '%s' are not (yet) supported."}, SFieldValueError: {org: "Invalid value for field '%s'"}, SInvalidCalcType: {org: "Field '%s' cannot be a calculated or lookup field"}, SDuplicateName: {org: "Duplicate name '%s' in %s"}, SNoParseSQL: {org: "%s is only possible if ParseSQL is True"}, SLookupInfoError: {org: "Lookup information for field '%s' is incomplete"}, SUnsupportedFieldType: {org: "Fieldtype %s is not supported"}, SInvPacketRecordsValue: {org: "PacketRecords has to be larger then 0"}, SInvPacketRecordsValueFieldNames: {org: "PacketRecords must be -1 if IndexFieldNames is set"}, SInvalidSearchFieldType: {org: "Searching in fields of type %s is not supported"}, SDatasetEmpty: {org: "The dataset is empty"}, SFieldIsNull: {org: "The field is null"}, SOnUpdateError: {org: "An error occurred while applying the updates in a record: %s"}, SApplyRecNotSupported: {org: "Applying updates is not supported by this TDataset descendent"}, SNoWhereFields: {org: "No %s query specified and failed to generate one. (No fields for inclusion in where statement found)"}, SNoUpdateFields: {org: "No %s query specified and failed to generate one. (No fields found for insert- or update-statement found)"}, SNotSupported: {org: "Operation is not supported by this type of database"}, SDBCreateDropFailed: {org: "Creation or dropping of database failed"}, SMaxIndexes: {org: "The maximum amount of indexes is reached"}, SMinIndexes: {org: "The minimum amount of indexes is 1"}, STooManyFields: {org: "More fields specified then really exist"}, SFieldIndexError: {org: "Field index out of range"}, SIndexFieldMissing: {org: "Cannot access index field '%s'"}, SNoFieldIndexes: {org: "No index currently active"}, SNotIndexField: {org: "Field '%s' is not indexed and cannot be modified"}, SErrUnknownConnectorType: {org: 'Unknown connector type: "%s"'}, SNoIndexFieldNameGiven: {org: "There are no fields selected to base the index on"}, SStreamNotRecognised: {org: "The data-stream format is not recognized"}, SNoReaderClassRegistered: {org: "There is no TDatapacketReaderClass registered for this kind of data-stream"}, SErrCircularDataSourceReferenceNotAllowed: {org: "Circular datasource references are not allowed."}, SCommitting: {org: "Committing transaction"}, SRollingBack: {org: "Rolling back transaction"}, SCommitRetaining: {org: "Commit and retaining transaction"}, SRollBackRetaining: {org: "Rollback and retaining transaction"}, SErrNoFieldsDefined: {org: "Can not create a dataset when there are no fielddefinitions or fields defined"}, SErrApplyUpdBeforeRefresh: {org: "Must apply updates before refreshing data"}, SErrNoDataset: {org: "Missing (compatible) underlying dataset, can not open"}, SErrDisconnectedPacketRecords: {org: "For disconnected TSQLQuery instances, packetrecords must be -1"}, SErrImplicitNoRollBack: {org: "Implicit use of transactions does not allow rollback."}, SErrNoImplicitTransaction: {org: "Connection %s does not allow implicit transactions."}, SErrImplictTransactionStart: {org: 'Error: attempt to implicitly start a transaction on Connection "%s", transaction "%s".'}, SErrImplicitConnect: {org: 'Error: attempt to implicitly activate connection "%s".'}, SErrFailedToUpdateRecord: {org: "Failed to apply record updates: %d rows updated."}, SErrRefreshNotSingleton: {org: "Refresh SQL resulted in multiple records: %d."}, SErrRefreshEmptyResult: {org: "Refresh SQL resulted in empty result set."}, SErrNoKeyFieldForRefreshClause: {org: "No key field found to construct refresh SQL WHERE clause"}, SErrFailedToFetchReturningResult: {org: "Failed to fetch returning result"}, SLogParamValue: {org: 'Parameter "%s" value : "%s"'}, SErrInvalidDateTime: {org: 'Invalid date/time value : "%s"'}, SatEOFInternalOnly: {org: "loAtEOF is for internal use only."}, SErrInsertingSameRecordtwice: {org: "Attempt to insert the same record twice."}, SErrDoApplyUpdatesNeedsProxy: {org: "Cannot apply updates without Data proxy"}, SNestedDataSetClass: {org: "Nested dataset must inherit from %s"}, SCircularDataLink: {org: "Circular datalinks are not allowed"}};
});
rtl.module("DB",["System","Classes","SysUtils","JS","Types","DateUtils"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.dsMaxBufferCount = rtl.trunc(2147483647 / 8);
  this.dsMaxStringSize = 8192;
  this.$rtti.$StaticArray("YesNoChars$a",{dims: [2], eltype: rtl.char});
  this.YesNoChars = ["N","Y"];
  this.SQLDelimiterCharacters = rtl.createSet(59,44,32,40,41,13,10,9);
  this.TDataSetState = {"0": "dsInactive", dsInactive: 0, "1": "dsBrowse", dsBrowse: 1, "2": "dsEdit", dsEdit: 2, "3": "dsInsert", dsInsert: 3, "4": "dsSetKey", dsSetKey: 4, "5": "dsCalcFields", dsCalcFields: 5, "6": "dsFilter", dsFilter: 6, "7": "dsNewValue", dsNewValue: 7, "8": "dsOldValue", dsOldValue: 8, "9": "dsCurValue", dsCurValue: 9, "10": "dsBlockRead", dsBlockRead: 10, "11": "dsInternalCalc", dsInternalCalc: 11, "12": "dsOpening", dsOpening: 12, "13": "dsRefreshFields", dsRefreshFields: 13};
  this.$rtti.$Enum("TDataSetState",{minvalue: 0, maxvalue: 13, ordtype: 1, enumtype: this.TDataSetState});
  this.TDataEvent = {"0": "deFieldChange", deFieldChange: 0, "1": "deRecordChange", deRecordChange: 1, "2": "deDataSetChange", deDataSetChange: 2, "3": "deDataSetScroll", deDataSetScroll: 3, "4": "deLayoutChange", deLayoutChange: 4, "5": "deUpdateRecord", deUpdateRecord: 5, "6": "deUpdateState", deUpdateState: 6, "7": "deCheckBrowseMode", deCheckBrowseMode: 7, "8": "dePropertyChange", dePropertyChange: 8, "9": "deFieldListChange", deFieldListChange: 9, "10": "deFocusControl", deFocusControl: 10, "11": "deParentScroll", deParentScroll: 11, "12": "deConnectChange", deConnectChange: 12, "13": "deReconcileError", deReconcileError: 13, "14": "deDisabledStateChange", deDisabledStateChange: 14};
  this.$rtti.$Enum("TDataEvent",{minvalue: 0, maxvalue: 14, ordtype: 1, enumtype: this.TDataEvent});
  this.TUpdateStatus = {"0": "usModified", usModified: 0, "1": "usInserted", usInserted: 1, "2": "usDeleted", usDeleted: 2};
  this.$rtti.$Enum("TUpdateStatus",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TUpdateStatus});
  this.$rtti.$Set("TUpdateStatusSet",{comptype: this.$rtti["TUpdateStatus"]});
  this.TResolveStatus = {"0": "rsUnresolved", rsUnresolved: 0, "1": "rsResolving", rsResolving: 1, "2": "rsResolved", rsResolved: 2, "3": "rsResolveFailed", rsResolveFailed: 3};
  this.$rtti.$Enum("TResolveStatus",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TResolveStatus});
  this.$rtti.$Set("TResolveStatusSet",{comptype: this.$rtti["TResolveStatus"]});
  this.TUpdateMode = {"0": "upWhereAll", upWhereAll: 0, "1": "upWhereChanged", upWhereChanged: 1, "2": "upWhereKeyOnly", upWhereKeyOnly: 2};
  this.$rtti.$Enum("TUpdateMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TUpdateMode});
  this.TResolverResponse = {"0": "rrSkip", rrSkip: 0, "1": "rrAbort", rrAbort: 1, "2": "rrMerge", rrMerge: 2, "3": "rrApply", rrApply: 3, "4": "rrIgnore", rrIgnore: 4};
  this.$rtti.$Enum("TResolverResponse",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TResolverResponse});
  this.TProviderFlag = {"0": "pfInUpdate", pfInUpdate: 0, "1": "pfInWhere", pfInWhere: 1, "2": "pfInKey", pfInKey: 2, "3": "pfHidden", pfHidden: 3, "4": "pfRefreshOnInsert", pfRefreshOnInsert: 4, "5": "pfRefreshOnUpdate", pfRefreshOnUpdate: 5};
  this.$rtti.$Enum("TProviderFlag",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TProviderFlag});
  this.$rtti.$Set("TProviderFlags",{comptype: this.$rtti["TProviderFlag"]});
  this.$rtti.$Class("TFieldDef");
  this.$rtti.$Class("TFieldDefs");
  this.$rtti.$Class("TField");
  this.$rtti.$Class("TFields");
  this.$rtti.$Class("TDataSet");
  this.$rtti.$Class("TDataSource");
  this.$rtti.$Class("TDataLink");
  this.$rtti.$Class("TDataProxy");
  this.$rtti.$Class("TDataRequest");
  this.$rtti.$Class("TRecordUpdateDescriptor");
  this.$rtti.$Class("TRecordUpdateDescriptorList");
  this.$rtti.$Class("TRecordUpdateBatch");
  rtl.createClass(this,"EDatabaseError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EUpdateError",this.EDatabaseError,function () {
    this.$init = function () {
      $mod.EDatabaseError.$init.call(this);
      this.FContext = "";
      this.FErrorCode = 0;
      this.FOriginalException = null;
      this.FPreviousError = 0;
    };
    this.$final = function () {
      this.FOriginalException = undefined;
      $mod.EDatabaseError.$final.call(this);
    };
    this.Create$2 = function (NativeError, Context, ErrCode, PrevError, E) {
      pas.SysUtils.Exception.CreateFmt.call(this,NativeError,pas.System.VarRecs(18,Context));
      this.FContext = Context;
      this.FErrorCode = ErrCode;
      this.FPreviousError = PrevError;
      this.FOriginalException = E;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FOriginalException");
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.$rtti.$ClassRef("TFieldClass",{instancetype: this.$rtti["TField"]});
  this.TFieldType = {"0": "ftUnknown", ftUnknown: 0, "1": "ftString", ftString: 1, "2": "ftSmallint", ftSmallint: 2, "3": "ftInteger", ftInteger: 3, "4": "ftWord", ftWord: 4, "5": "ftBoolean", ftBoolean: 5, "6": "ftFloat", ftFloat: 6, "7": "ftCurrency", ftCurrency: 7, "8": "ftBCD", ftBCD: 8, "9": "ftDate", ftDate: 9, "10": "ftTime", ftTime: 10, "11": "ftDateTime", ftDateTime: 11, "12": "ftBytes", ftBytes: 12, "13": "ftVarBytes", ftVarBytes: 13, "14": "ftAutoInc", ftAutoInc: 14, "15": "ftBlob", ftBlob: 15, "16": "ftMemo", ftMemo: 16, "17": "ftGraphic", ftGraphic: 17, "18": "ftFmtMemo", ftFmtMemo: 18, "19": "ftParadoxOle", ftParadoxOle: 19, "20": "ftDBaseOle", ftDBaseOle: 20, "21": "ftTypedBinary", ftTypedBinary: 21, "22": "ftCursor", ftCursor: 22, "23": "ftFixedChar", ftFixedChar: 23, "24": "ftWideString", ftWideString: 24, "25": "ftLargeint", ftLargeint: 25, "26": "ftADT", ftADT: 26, "27": "ftArray", ftArray: 27, "28": "ftReference", ftReference: 28, "29": "ftDataSet", ftDataSet: 29, "30": "ftOraBlob", ftOraBlob: 30, "31": "ftOraClob", ftOraClob: 31, "32": "ftVariant", ftVariant: 32, "33": "ftInterface", ftInterface: 33, "34": "ftIDispatch", ftIDispatch: 34, "35": "ftGuid", ftGuid: 35, "36": "ftTimeStamp", ftTimeStamp: 36, "37": "ftFMTBcd", ftFMTBcd: 37, "38": "ftFixedWideChar", ftFixedWideChar: 38, "39": "ftWideMemo", ftWideMemo: 39, "40": "ftOraTimeStamp", ftOraTimeStamp: 40, "41": "ftOraInterval", ftOraInterval: 41, "42": "ftLongWord", ftLongWord: 42, "43": "ftShortint", ftShortint: 43, "44": "ftByte", ftByte: 44, "45": "ftExtended", ftExtended: 45, "46": "ftConnection", ftConnection: 46, "47": "ftParams", ftParams: 47, "48": "ftStream", ftStream: 48, "49": "ftTimeStampOffset", ftTimeStampOffset: 49, "50": "ftObject", ftObject: 50, "51": "ftSingle", ftSingle: 51};
  this.$rtti.$Enum("TFieldType",{minvalue: 0, maxvalue: 51, ordtype: 1, enumtype: this.TFieldType});
  this.ftNonTextTypes = rtl.createSet(this.TFieldType.ftBytes,this.TFieldType.ftVarBytes,this.TFieldType.ftBlob,this.TFieldType.ftMemo,this.TFieldType.ftGraphic,this.TFieldType.ftFmtMemo,this.TFieldType.ftParadoxOle,this.TFieldType.ftDBaseOle,this.TFieldType.ftTypedBinary,this.TFieldType.ftCursor,this.TFieldType.ftADT,this.TFieldType.ftArray,this.TFieldType.ftReference,this.TFieldType.ftDataSet);
  this.TFieldAttribute = {"0": "faHiddenCol", faHiddenCol: 0, "1": "faReadonly", faReadonly: 1, "2": "faRequired", faRequired: 2, "3": "faLink", faLink: 3, "4": "faUnNamed", faUnNamed: 4, "5": "faFixed", faFixed: 5};
  this.$rtti.$Enum("TFieldAttribute",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TFieldAttribute});
  this.$rtti.$Set("TFieldAttributes",{comptype: this.$rtti["TFieldAttribute"]});
  rtl.createClass(this,"TNamedItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FName = "";
    };
    this.GetDisplayName = function () {
      var Result = "";
      Result = this.FName;
      return Result;
    };
    this.SetDisplayName = function (Value) {
      var TmpInd = 0;
      if (this.FName === Value) return;
      if ((Value !== "") && $mod.TFieldDefs.isPrototypeOf(this.FCollection)) {
        TmpInd = this.FCollection.IndexOf(Value);
        if ((TmpInd >= 0) && (TmpInd !== this.GetIndex())) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SDuplicateName"),pas.System.VarRecs(18,Value,18,this.FCollection.$classname));
      };
      this.FName = Value;
      pas.Classes.TCollectionItem.SetDisplayName.call(this,Value);
    };
    var $r = this.$rtti;
    $r.addProperty("Name",2,rtl.string,"FName","SetDisplayName");
  });
  rtl.createClass(this,"TDefCollection",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FDataset = null;
      this.FUpdated = false;
    };
    this.$final = function () {
      this.FDataset = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.SetItemName = function (Item) {
      var N = null;
      var TN = "";
      N = rtl.as(Item,$mod.TNamedItem);
      if (N.FName === "") {
        TN = pas.System.Copy(this.$classname,2,5) + pas.SysUtils.IntToStr(N.FID + 1);
        if (this.FDataset != null) TN = this.FDataset.FName + TN;
        N.SetDisplayName(TN);
      } else pas.Classes.TCollection.SetItemName.call(this,Item);
    };
    this.create$3 = function (ADataset, AOwner, AClass) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,AClass);
      this.FDataset = ADataset;
      return this;
    };
    this.Find = function (AName) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.AnsiSameText(this.GetItem(i).FName,AName)) {
          Result = this.GetItem(i);
          break;
        };
      };
      return Result;
    };
    this.GetItemNames = function (List) {
      var i = 0;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        List.Add(this.GetItem(i).FName);
      };
    };
    this.IndexOf = function (AName) {
      var Result = 0;
      var i = 0;
      Result = -1;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.AnsiSameText(this.GetItem(i).FName,AName)) {
          Result = i;
          break;
        };
      };
      return Result;
    };
  });
  rtl.createClass(this,"TFieldDef",this.TNamedItem,function () {
    this.$init = function () {
      $mod.TNamedItem.$init.call(this);
      this.FAttributes = {};
      this.FDataType = 0;
      this.FFieldNo = 0;
      this.FInternalCalcField = false;
      this.FPrecision = 0;
      this.FRequired = false;
      this.FSize = 0;
    };
    this.$final = function () {
      this.FAttributes = undefined;
      $mod.TNamedItem.$final.call(this);
    };
    this.GetFieldClass = function () {
      var Result = null;
      if ((this.FCollection != null) && $mod.TFieldDefs.isPrototypeOf(this.FCollection) && (this.FCollection.FDataset != null)) {
        Result = this.FCollection.FDataset.GetFieldClass(this.FDataType)}
       else Result = null;
      return Result;
    };
    this.SetAttributes = function (AValue) {
      this.FAttributes = rtl.refSet(AValue);
      this.Changed(false);
    };
    this.SetDataType = function (AValue) {
      this.FDataType = AValue;
      this.Changed(false);
    };
    this.SetPrecision = function (AValue) {
      this.FPrecision = AValue;
      this.Changed(false);
    };
    this.SetSize = function (AValue) {
      this.FSize = AValue;
      this.Changed(false);
    };
    this.SetRequired = function (AValue) {
      this.FRequired = AValue;
      this.Changed(false);
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.call(this,ACollection);
      this.FFieldNo = this.GetIndex() + 1;
      return this;
    };
    this.Create$3 = function (AOwner, AName, ADataType, ASize, ARequired, AFieldNo) {
      pas.Classes.TCollectionItem.Create$1.call(this,AOwner);
      this.SetDisplayName(AName);
      this.FDataType = ADataType;
      this.FSize = ASize;
      this.FRequired = ARequired;
      this.FPrecision = -1;
      this.FFieldNo = AFieldNo;
      return this;
    };
    this.Destroy = function () {
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      var fd = null;
      fd = null;
      if ($mod.TFieldDef.isPrototypeOf(Source)) fd = rtl.as(Source,$mod.TFieldDef);
      if (fd != null) {
        this.FCollection.BeginUpdate();
        try {
          this.SetDisplayName(fd.FName);
          this.SetDataType(fd.FDataType);
          this.SetSize(fd.FSize);
          this.SetPrecision(fd.FPrecision);
          this.FRequired = fd.FRequired;
        } finally {
          this.FCollection.EndUpdate();
        };
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.CreateField = function (AOwner) {
      var Result = null;
      var TheField = null;
      TheField = this.GetFieldClass();
      if (TheField === null) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SUnknownFieldType"),pas.System.VarRecs(18,this.FName));
      Result = TheField.$create("Create$1",[AOwner]);
      try {
        Result.FFieldDef = this;
        Result.SetSize(this.FSize);
        Result.FRequired = this.FRequired;
        Result.FFieldName = this.FName;
        Result.FDisplayLabel = this.GetDisplayName();
        Result.FFieldNo = this.FFieldNo;
        Result.SetFieldType(this.FDataType);
        Result.FReadOnly = $mod.TFieldAttribute.faReadonly in this.FAttributes;
        Result.SetDataset(this.FCollection.FDataset);
        if ($mod.TFloatField.isPrototypeOf(Result)) Result.SetPrecision(this.FPrecision);
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Attributes",2,$mod.$rtti["TFieldAttributes"],"FAttributes","SetAttributes",4,{Default: {}});
    $r.addProperty("DataType",2,$mod.$rtti["TFieldType"],"FDataType","SetDataType");
    $r.addProperty("Precision",2,rtl.longint,"FPrecision","SetPrecision",4,{Default: 0});
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",4,{Default: 0});
  });
  this.$rtti.$ClassRef("TFieldDefClass",{instancetype: this.$rtti["TFieldDef"]});
  rtl.createClass(this,"TFieldDefs",this.TDefCollection,function () {
    this.$init = function () {
      $mod.TDefCollection.$init.call(this);
      this.FHiddenFields = false;
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, AValue) {
      this.SetItem(Index,AValue);
    };
    this.FieldDefClass = function () {
      var Result = null;
      Result = $mod.TFieldDef;
      return Result;
    };
    this.Create$4 = function (ADataSet) {
      $mod.TDefCollection.create$3.call(this,ADataSet,this.Owner(),this.$class.FieldDefClass());
      return this;
    };
    this.Add$1 = function (AName, ADataType, ASize, APrecision, ARequired, AReadOnly, AFieldNo) {
      var Result = null;
      Result = this.$class.FieldDefClass().$create("Create$3",[this,this.MakeNameUnique(AName),ADataType,ASize,ARequired,AFieldNo]);
      if (AReadOnly) Result.SetAttributes(rtl.unionSet(Result.FAttributes,rtl.createSet($mod.TFieldAttribute.faReadonly)));
      return Result;
    };
    this.Add$2 = function (AName, ADataType, ASize, ARequired, AFieldNo) {
      var Result = null;
      Result = this.$class.FieldDefClass().$create("Create$3",[this,AName,ADataType,ASize,ARequired,AFieldNo]);
      return Result;
    };
    this.Add$3 = function (AName, ADataType, ASize, ARequired) {
      if (AName.length === 0) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SNeedFieldName"),this.FDataset);
      this.BeginUpdate();
      try {
        this.Add$2(AName,ADataType,ASize,ARequired,this.GetCount() + 1);
      } finally {
        this.EndUpdate();
      };
    };
    this.Add$4 = function (AName, ADataType, ASize) {
      this.Add$3(AName,ADataType,ASize,false);
    };
    this.Add$5 = function (AName, ADataType) {
      this.Add$3(AName,ADataType,0,false);
    };
    this.Add$6 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.AddFieldDef = function () {
      var Result = null;
      Result = this.$class.FieldDefClass().$create("Create$3",[this,"",$mod.TFieldType.ftUnknown,0,false,this.GetCount() + 1]);
      return Result;
    };
    this.Assign$2 = function (FieldDefs) {
      var I = 0;
      this.Clear();
      for (var $l = 0, $end = FieldDefs.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.Add$3(FieldDefs.GetItem$1(I).FName,FieldDefs.GetItem$1(I).FDataType,FieldDefs.GetItem$1(I).FSize,FieldDefs.GetItem$1(I).FRequired);
      };
    };
    this.Find$1 = function (AName) {
      var Result = null;
      Result = rtl.as($mod.TDefCollection.Find.call(this,AName),$mod.TFieldDef);
      if (Result === null) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SFieldNotFound"),pas.System.VarRecs(18,AName),this.FDataset);
      return Result;
    };
    this.Update$1 = function () {
      if (!this.FUpdated) {
        if (this.FDataset != null) this.FDataset.InitFieldDefs();
        this.FUpdated = true;
      };
    };
    this.MakeNameUnique = function (AName) {
      var Result = "";
      var DblFieldCount = 0;
      DblFieldCount = 0;
      Result = AName;
      while ($mod.TDefCollection.Find.call(this,Result) != null) {
        DblFieldCount += 1;
        Result = AName + "_" + pas.SysUtils.IntToStr(DblFieldCount);
      };
      return Result;
    };
  });
  this.$rtti.$ClassRef("TFieldDefsClass",{instancetype: this.$rtti["TFieldDefs"]});
  this.TFieldKind = {"0": "fkData", fkData: 0, "1": "fkCalculated", fkCalculated: 1, "2": "fkLookup", fkLookup: 2, "3": "fkInternalCalc", fkInternalCalc: 3};
  this.$rtti.$Enum("TFieldKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TFieldKind});
  this.$rtti.$Set("TFieldKinds",{comptype: this.$rtti["TFieldKind"]});
  this.$rtti.$MethodVar("TFieldNotifyEvent",{procsig: rtl.newTIProcSig([["Sender",this.$rtti["TField"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFieldGetTextEvent",{procsig: rtl.newTIProcSig([["Sender",this.$rtti["TField"]],["aText",rtl.string,1],["DisplayText",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TFieldSetTextEvent",{procsig: rtl.newTIProcSig([["Sender",this.$rtti["TField"]],["aText",rtl.string,2]]), methodkind: 0});
  this.$rtti.$DynArray("TFieldChars",{eltype: rtl.char});
  this.TAutoRefreshFlag = {"0": "arNone", arNone: 0, "1": "arAutoInc", arAutoInc: 1, "2": "arDefault", arDefault: 2};
  this.$rtti.$Enum("TAutoRefreshFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TAutoRefreshFlag});
  rtl.createClass(this,"TLookupList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function () {
      this.FList = pas.Classes.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      this.Clear();
      this.FList.$destroy("Destroy");
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (AKey, AValue) {
      var LookupRec = null;
      LookupRec = pas.JS.New(["Key",AKey,"Value",AValue]);
      this.FList.Add(LookupRec);
    };
    this.Clear = function () {
      this.FList.Clear();
    };
    this.FirstKeyByValue = function (AValue) {
      var Result = undefined;
      var i = 0;
      for (var $l = 0, $end = this.FList.FCount - 1; $l <= $end; $l++) {
        i = $l;
        var $with = this.FList.Get(i);
        if ($with["Value"] == AValue) {
          Result = $with["Key"];
          return Result;
        };
      };
      Result = null;
      return Result;
    };
    this.ValueOfKey = function (AKey) {
      var $Self = this;
      var Result = undefined;
      function VarArraySameValues(VarArray1, VarArray2) {
        var Result = false;
        var i = 0;
        Result = true;
        if (rtl.length(VarArray1) !== rtl.length(VarArray2)) return Result;
        for (var $l = 0, $end = rtl.length(VarArray1); $l <= $end; $l++) {
          i = $l;
          if (VarArray1[i] != VarArray2[i]) {
            Result = false;
            return Result;
          };
        };
        return Result;
      };
      var I = 0;
      Result = null;
      if (pas.JS.isNull(AKey)) return Result;
      I = this.FList.FCount - 1;
      if (rtl.isArray(AKey)) {
        while ((I >= 0) && !VarArraySameValues(this.FList.Get(I)["Key"],AKey)) I -= 1}
       else while ((I >= 0) && (this.FList.Get(I)["Key"] != AKey)) I -= 1;
      if (I >= 0) Result = this.FList.Get(I)["Value"];
      return Result;
    };
    this.ValuesToStrings = function (AStrings) {
      var i = 0;
      var p = null;
      AStrings.Clear();
      for (var $l = 0, $end = this.FList.FCount - 1; $l <= $end; $l++) {
        i = $l;
        p = this.FList.Get(i);
        AStrings.AddObject("" + p["Value"],p);
      };
    };
  });
  rtl.createClass(this,"TField",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FAlignment = 0;
      this.FAttributeSet = "";
      this.FAutoGenerateValue = 0;
      this.FCalculated = false;
      this.FConstraintErrorMessage = "";
      this.FCustomConstraint = "";
      this.FDataSet = null;
      this.FDataType = 0;
      this.FDefaultExpression = "";
      this.FDisplayLabel = "";
      this.FDisplayWidth = 0;
      this.FFieldDef = null;
      this.FFieldKind = 0;
      this.FFieldName = "";
      this.FFieldNo = 0;
      this.FFields = null;
      this.FHasConstraints = false;
      this.FImportedConstraint = "";
      this.FIsIndexField = false;
      this.FKeyFields = "";
      this.FLookupCache = false;
      this.FLookupDataSet = null;
      this.FLookupKeyfields = "";
      this.FLookupresultField = "";
      this.FLookupList = null;
      this.FOnChange = null;
      this.FOnGetText = null;
      this.FOnSetText = null;
      this.FOnValidate = null;
      this.FOrigin = "";
      this.FReadOnly = false;
      this.FRequired = false;
      this.FSize = 0;
      this.FValidChars = [];
      this.FValueBuffer = undefined;
      this.FValidating = false;
      this.FVisible = false;
      this.FProviderFlags = {};
    };
    this.$final = function () {
      this.FDataSet = undefined;
      this.FFieldDef = undefined;
      this.FFields = undefined;
      this.FLookupDataSet = undefined;
      this.FLookupList = undefined;
      this.FOnChange = undefined;
      this.FOnGetText = undefined;
      this.FOnSetText = undefined;
      this.FOnValidate = undefined;
      this.FValidChars = undefined;
      this.FProviderFlags = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.GetIndex = function () {
      var Result = 0;
      if (this.FDataSet != null) {
        Result = this.FDataSet.FFieldList.IndexOf(this)}
       else Result = -1;
      return Result;
    };
    this.GetLookup = function () {
      var Result = false;
      Result = this.FFieldKind === $mod.TFieldKind.fkLookup;
      return Result;
    };
    this.SetAlignment = function (AValue) {
      if (this.FAlignment !== AValue) {
        this.FAlignment = AValue;
        this.PropertyChanged(false);
      };
    };
    this.SetIndex = function (AValue) {
      if (this.FFields !== null) this.FFields.SetFieldIndex(this,AValue);
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = rtl.strSetLength(Result,0);
      if (this.FOnGetText != null) {
        this.FOnGetText(this,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},true)}
       else this.GetText({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},true);
      return Result;
    };
    this.GetEditText = function () {
      var Result = "";
      Result = rtl.strSetLength(Result,0);
      if (this.FOnGetText != null) {
        this.FOnGetText(this,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},false)}
       else this.GetText({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},false);
      return Result;
    };
    this.SetEditText = function (AValue) {
      if (this.FOnSetText != null) {
        this.FOnSetText(this,AValue)}
       else this.SetText(AValue);
    };
    this.SetDisplayLabel = function (AValue) {
      if (this.FDisplayLabel !== AValue) {
        this.FDisplayLabel = AValue;
        this.PropertyChanged(true);
      };
    };
    this.SetDisplayWidth = function (AValue) {
      if (this.FDisplayWidth !== AValue) {
        this.FDisplayWidth = AValue;
        this.PropertyChanged(true);
      };
    };
    this.GetDisplayWidth = function () {
      var Result = 0;
      if (this.FDisplayWidth === 0) {
        Result = this.GetDefaultWidth()}
       else Result = this.FDisplayWidth;
      return Result;
    };
    var ValueToLookupMap = [$mod.TFieldKind.fkData,$mod.TFieldKind.fkLookup];
    this.SetLookup = function (AValue) {
      this.FFieldKind = ValueToLookupMap[+AValue];
    };
    this.SetReadOnly = function (AValue) {
      if (this.FReadOnly !== AValue) {
        this.FReadOnly = AValue;
        this.PropertyChanged(true);
      };
    };
    this.SetVisible = function (AValue) {
      if (this.FVisible !== AValue) {
        this.FVisible = AValue;
        this.PropertyChanged(true);
      };
    };
    this.IsDisplayLabelStored = function () {
      var Result = false;
      Result = this.GetDisplayName() !== this.FFieldName;
      return Result;
    };
    this.IsDisplayWidthStored = function () {
      var Result = false;
      Result = this.FDisplayWidth !== 0;
      return Result;
    };
    this.GetLookupList = function () {
      var Result = null;
      if (!(this.FLookupList != null)) this.FLookupList = $mod.TLookupList.$create("Create$1");
      Result = this.FLookupList;
      return Result;
    };
    this.CalcLookupValue = function () {
      if ((this.FLookupDataSet != null) && this.FLookupDataSet.GetActive()) {
        this.SetAsJSValue(this.FLookupDataSet.Lookup(this.FLookupKeyfields,this.FDataSet.GetFieldValues(this.FKeyFields),this.FLookupresultField))}
       else this.SetAsJSValue(null);
    };
    this.RaiseAccessError = function (TypeName) {
      var E = null;
      E = this.AccessError(TypeName);
      throw E;
    };
    this.AccessError = function (TypeName) {
      var Result = null;
      Result = $mod.EDatabaseError.$create("CreateFmt",[rtl.getResStr(pas.DBConst,"SInvalidTypeConversion"),pas.System.VarRecs(18,TypeName,18,this.FFieldName)]);
      return Result;
    };
    this.CheckInactive = function () {
      if (this.FDataSet != null) this.FDataSet.CheckInactive();
    };
    this.CheckTypeSize = function (AValue) {
      if ((AValue !== 0) && !this.IsBlob()) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidFieldSize"),pas.System.VarRecs(0,AValue));
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Bind = function (Binding) {
      if (Binding && (this.FFieldKind === $mod.TFieldKind.fkLookup)) {
        if ((this.FLookupDataSet === null) || (this.FLookupKeyfields === "") || (this.FLookupresultField === "") || (this.FKeyFields === "")) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SLookupInfoError"),pas.System.VarRecs(18,this.GetDisplayName()));
        this.FFields.CheckFieldNames(this.FKeyFields);
        this.FLookupDataSet.Open();
        this.FLookupDataSet.FFieldList.CheckFieldNames(this.FLookupKeyfields);
        this.FLookupDataSet.FieldByName(this.FLookupresultField);
        if (this.FLookupCache) this.RefreshLookupList();
      };
    };
    this.DataChanged = function () {
      this.FDataSet.DataEvent($mod.TDataEvent.deFieldChange,this);
    };
    this.GetAsBoolean = function () {
      var Result = false;
      this.RaiseAccessError($impl.SBoolean);
      Result = false;
      return Result;
    };
    this.GetAsBytes = function () {
      var Result = [];
      this.RaiseAccessError($impl.SBytes);
      Result = [];
      return Result;
    };
    this.GetAsLargeInt = function () {
      var Result = 0;
      this.RaiseAccessError($impl.SLargeInt);
      Result = 0;
      return Result;
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      this.RaiseAccessError($impl.SDateTime);
      Result = 0.0;
      return Result;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      this.RaiseAccessError($impl.SDateTime);
      Result = 0.0;
      return Result;
    };
    this.GetAsLongint = function () {
      var Result = 0;
      Result = this.GetAsInteger();
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      this.RaiseAccessError($impl.SInteger);
      Result = 0;
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      return Result;
    };
    this.GetOldValue = function () {
      var Result = undefined;
      var SaveState = 0;
      SaveState = this.FDataSet.FState;
      try {
        this.FDataSet.SetTempState($mod.TDataSetState.dsOldValue);
        Result = this.GetAsJSValue();
      } finally {
        this.FDataSet.RestoreState(SaveState);
      };
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      Result = this.GetClassDesc();
      return Result;
    };
    this.GetCanModify = function () {
      var Result = false;
      Result = !this.FReadOnly;
      if (Result) {
        Result = this.FFieldKind in rtl.createSet($mod.TFieldKind.fkData,$mod.TFieldKind.fkInternalCalc);
        if (Result) {
          Result = (this.FDataSet != null) && this.FDataSet.GetActive();
          if (Result) Result = this.FDataSet.GetCanModify();
        };
      };
      return Result;
    };
    this.GetClassDesc = function () {
      var Result = "";
      var ClassN = "";
      ClassN = pas.System.Copy(this.$classname,2,pas.System.Pos("Field",this.$classname) - 2);
      if (this.GetIsNull()) {
        Result = "(" + pas.SysUtils.LowerCase(ClassN) + ")"}
       else Result = "(" + pas.SysUtils.UpperCase(ClassN) + ")";
      return Result;
    };
    this.GetDataSize = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetDefaultWidth = function () {
      var Result = 0;
      Result = 10;
      return Result;
    };
    this.GetDisplayName = function () {
      var Result = "";
      if (this.FDisplayLabel !== "") {
        Result = this.FDisplayLabel}
       else Result = this.FFieldName;
      return Result;
    };
    this.GetCurValue = function () {
      var Result = undefined;
      var SaveState = 0;
      SaveState = this.FDataSet.FState;
      try {
        this.FDataSet.SetTempState($mod.TDataSetState.dsCurValue);
        Result = this.GetAsJSValue();
      } finally {
        this.FDataSet.RestoreState(SaveState);
      };
      return Result;
    };
    this.GetNewValue = function () {
      var Result = undefined;
      var SaveState = 0;
      SaveState = this.FDataSet.FState;
      try {
        this.FDataSet.SetTempState($mod.TDataSetState.dsNewValue);
        Result = this.GetAsJSValue();
      } finally {
        this.FDataSet.RestoreState(SaveState);
      };
      return Result;
    };
    this.GetIsNull = function () {
      var Result = false;
      Result = pas.JS.isNull(this.GetData());
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      AText.set(this.GetAsString());
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.call(this,AComponent,Operation);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FLookupDataSet)) this.FLookupDataSet = null;
    };
    this.PropertyChanged = function (LayoutAffected) {
      if ((this.FDataSet !== null) && this.FDataSet.GetActive()) if (LayoutAffected) {
        this.FDataSet.DataEvent($mod.TDataEvent.deLayoutChange,0)}
       else this.FDataSet.DataEvent($mod.TDataEvent.deDataSetChange,0);
    };
    this.SetAsBoolean = function (AValue) {
      this.RaiseAccessError($impl.SBoolean);
    };
    this.SetAsDateTime = function (AValue) {
      this.RaiseAccessError($impl.SDateTime);
    };
    this.SetAsFloat = function (AValue) {
      this.RaiseAccessError($impl.SFloat);
    };
    this.SetAsLongint = function (AValue) {
      this.SetAsInteger(AValue);
    };
    this.SetAsInteger = function (AValue) {
      this.RaiseAccessError($impl.SInteger);
    };
    this.SetAsLargeInt = function (AValue) {
      this.RaiseAccessError($impl.SLargeInt);
    };
    this.SetAsJSValue = function (AValue) {
      if (pas.JS.isNull(AValue)) {
        this.Clear()}
       else try {
        this.SetVarValue(AValue);
      } catch ($e) {
        if (pas.SysUtils.EVariantError.isPrototypeOf($e)) {
          $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SFieldValueError"),pas.System.VarRecs(18,this.GetDisplayName()))}
         else throw $e
      };
    };
    this.SetAsString = function (AValue) {
      this.RaiseAccessError($impl.SString);
    };
    this.SetDataset = function (AValue) {
      if (AValue === this.FDataSet) return;
      if (this.FDataSet != null) {
        this.FDataSet.CheckInactive();
        this.FDataSet.FFieldList.Remove(this);
      };
      if (AValue != null) {
        AValue.CheckInactive();
        AValue.FFieldList.Add(this);
      };
      this.FDataSet = AValue;
    };
    this.SetDataType = function (AValue) {
      this.FDataType = AValue;
    };
    this.SetNewValue = function (AValue) {
      var SaveState = 0;
      SaveState = this.FDataSet.FState;
      try {
        this.FDataSet.SetTempState($mod.TDataSetState.dsNewValue);
        this.SetAsJSValue(AValue);
      } finally {
        this.FDataSet.RestoreState(SaveState);
      };
    };
    this.SetSize = function (AValue) {
      this.CheckInactive();
      this.$class.CheckTypeSize(AValue);
      this.FSize = AValue;
    };
    this.SetText = function (AValue) {
      this.SetAsString(AValue);
    };
    this.SetVarValue = function (AValue) {
      this.RaiseAccessError($impl.SJSValue);
    };
    this.SetAsBytes = function (AValue) {
      this.RaiseAccessError($impl.SBytes);
    };
    this.DefineProperties = function (Filer) {
      var $Self = this;
      function IgnoreReadString(Reader) {
        Reader.ReadString();
      };
      function IgnoreReadBoolean(Reader) {
        Reader.ReadBoolean();
      };
      function IgnoreWrite(Writer) {
        if (Writer === null) ;
      };
      Filer.DefineProperty("AttributeSet",IgnoreReadString,IgnoreWrite,false);
      Filer.DefineProperty("Calculated",IgnoreReadBoolean,IgnoreWrite,false);
      Filer.DefineProperty("Lookup",IgnoreReadBoolean,IgnoreWrite,false);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FVisible = true;
      this.FValidChars = rtl.arraySetLength(this.FValidChars,"\x00",255);
      this.FProviderFlags = rtl.createSet($mod.TProviderFlag.pfInUpdate,$mod.TProviderFlag.pfInWhere);
      return this;
    };
    this.Destroy = function () {
      if (this.FDataSet != null) {
        this.FDataSet.SetActive(false);
        if (this.FFields != null) this.FFields.Remove(this);
      };
      rtl.free(this,"FLookupList");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.GetParentComponent = function () {
      var Result = null;
      Result = this.FDataSet;
      return Result;
    };
    this.SetParentComponent = function (Value) {
      this.SetDataset(rtl.as(Value,$mod.TDataSet));
    };
    this.HasParent = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.Assign = function (Source) {
      if (Source === null) {
        this.Clear()}
       else if ($mod.TField.isPrototypeOf(Source)) {
        this.SetAsJSValue(Source.GetAsJSValue());
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.AssignValue = function (AValue) {
      var $Self = this;
      function error() {
        $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SFieldValueError"),pas.System.VarRecs(18,$Self.GetDisplayName()));
      };
      var $tmp = pas.JS.GetValueType(AValue);
      if ($tmp === pas.JS.TJSValueType.jvtNull) {
        this.Clear()}
       else if ($tmp === pas.JS.TJSValueType.jvtBoolean) {
        this.SetAsBoolean(!(AValue == false))}
       else if ($tmp === pas.JS.TJSValueType.jvtInteger) {
        this.SetAsLargeInt(rtl.trunc(AValue))}
       else if ($tmp === pas.JS.TJSValueType.jvtFloat) {
        this.SetAsFloat(rtl.getNumber(AValue))}
       else if ($tmp === pas.JS.TJSValueType.jvtString) {
        this.SetAsString("" + AValue)}
       else if ($tmp === pas.JS.TJSValueType.jvtArray) {
        this.SetAsBytes(AValue)}
       else {
        error();
      };
    };
    this.Clear = function () {
      this.SetData(null);
    };
    this.FocusControl = function () {
      var Field1 = null;
      Field1 = this;
      this.FDataSet.DataEvent($mod.TDataEvent.deFocusControl,Field1);
    };
    this.GetData = function () {
      var Result = undefined;
      if (this.FDataSet === null) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SNoDataset"),pas.System.VarRecs(18,this.FFieldName));
      if (this.FValidating) {
        Result = this.FValueBuffer}
       else {
        Result = this.FDataSet.GetFieldData(this);
        if (pas.JS.isUndefined(Result)) Result = null;
      };
      return Result;
    };
    this.IsBlob = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.IsValidChar = function (InputChar) {
      var Result = false;
      Result = pas.SysUtils.CharInSet(InputChar,this.FValidChars);
      return Result;
    };
    this.RefreshLookupList = function () {
      var tmpActive = false;
      if (!(this.FLookupDataSet != null) || (this.FLookupKeyfields.length === 0) || (this.FLookupresultField.length === 0) || (this.FKeyFields.length === 0)) return;
      tmpActive = this.FLookupDataSet.GetActive();
      try {
        this.FLookupDataSet.SetActive(true);
        this.FFields.CheckFieldNames(this.FKeyFields);
        this.FLookupDataSet.FFieldList.CheckFieldNames(this.FLookupKeyfields);
        this.FLookupDataSet.FieldByName(this.FLookupresultField);
        this.GetLookupList().Clear();
        this.FLookupDataSet.DisableControls();
        try {
          this.FLookupDataSet.First();
          while (!this.FLookupDataSet.GetEOF()) {
            this.FLookupDataSet.Next();
          };
        } finally {
          this.FLookupDataSet.EnableControls();
        };
      } finally {
        this.FLookupDataSet.SetActive(tmpActive);
      };
    };
    this.SetData = function (Buffer) {
      if (!(this.FDataSet != null)) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SNoDataset"),pas.System.VarRecs(18,this.FFieldName));
      this.FDataSet.SetFieldData(this,Buffer);
    };
    this.SetFieldType = function (AValue) {
    };
    this.Validate = function (Buffer) {
      if (this.FOnValidate != null) {
        this.FValueBuffer = Buffer;
        this.FValidating = true;
        try {
          this.FOnValidate(this);
        } finally {
          this.FValidating = false;
        };
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("CustomConstraint",0,rtl.string,"FCustomConstraint","FCustomConstraint");
    $r.addProperty("ConstraintErrorMessage",0,rtl.string,"FConstraintErrorMessage","FConstraintErrorMessage");
    $r.addProperty("DefaultExpression",0,rtl.string,"FDefaultExpression","FDefaultExpression");
    $r.addProperty("DisplayLabel",15,rtl.string,"GetDisplayName","SetDisplayLabel",4,{stored: "IsDisplayLabelStored"});
    $r.addProperty("DisplayWidth",15,rtl.longint,"GetDisplayWidth","SetDisplayWidth",4,{stored: "IsDisplayWidthStored"});
    $r.addProperty("FieldKind",0,$mod.$rtti["TFieldKind"],"FFieldKind","FFieldKind");
    $r.addProperty("FieldName",0,rtl.string,"FFieldName","FFieldName");
    $r.addProperty("HasConstraints",0,rtl.boolean,"FHasConstraints","");
    $r.addProperty("Index",3,rtl.longint,"GetIndex","SetIndex");
    $r.addProperty("ImportedConstraint",0,rtl.string,"FImportedConstraint","FImportedConstraint");
    $r.addProperty("KeyFields",0,rtl.string,"FKeyFields","FKeyFields");
    $r.addProperty("LookupCache",0,rtl.boolean,"FLookupCache","FLookupCache");
    $r.addProperty("LookupDataSet",0,$mod.$rtti["TDataSet"],"FLookupDataSet","FLookupDataSet");
    $r.addProperty("LookupKeyFields",0,rtl.string,"FLookupKeyfields","FLookupKeyfields");
    $r.addProperty("LookupResultField",0,rtl.string,"FLookupresultField","FLookupresultField");
    $r.addProperty("Origin",0,rtl.string,"FOrigin","FOrigin");
    $r.addProperty("ProviderFlags",0,$mod.$rtti["TProviderFlags"],"FProviderFlags","FProviderFlags");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly");
    $r.addProperty("Required",0,rtl.boolean,"FRequired","FRequired");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("OnChange",0,$mod.$rtti["TFieldNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnGetText",0,$mod.$rtti["TFieldGetTextEvent"],"FOnGetText","FOnGetText");
    $r.addProperty("OnSetText",0,$mod.$rtti["TFieldSetTextEvent"],"FOnSetText","FOnSetText");
    $r.addProperty("OnValidate",0,$mod.$rtti["TFieldNotifyEvent"],"FOnValidate","FOnValidate");
  });
  rtl.createClass(this,"TStringField",this.TField,function () {
    this.$init = function () {
      $mod.TField.$init.call(this);
      this.FFixedChar = false;
      this.FTransliterate = false;
    };
    this.CheckTypeSize = function (AValue) {
      if (AValue < 0) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidFieldSize"),pas.System.VarRecs(0,AValue));
    };
    this.GetAsBoolean = function () {
      var Result = false;
      var S = "";
      S = this.GetAsString();
      Result = (S.length > 0) && (pas.System.upcase(S.charAt(0)).charCodeAt() in rtl.createSet(84,$mod.YesNoChars[1].charCodeAt()));
      return Result;
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      Result = pas.SysUtils.StrToDateTime(this.GetAsString());
      return Result;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      Result = pas.SysUtils.StrToFloat(this.GetAsString());
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      Result = pas.SysUtils.StrToInt(this.GetAsString());
      return Result;
    };
    this.GetAsLargeInt = function () {
      var Result = 0;
      Result = pas.SysUtils.StrToInt64(this.GetAsString());
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var V = undefined;
      V = this.GetData();
      if (rtl.isString(V)) {
        Result = "" + V}
       else Result = "";
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      return Result;
    };
    this.GetDefaultWidth = function () {
      var Result = 0;
      Result = this.FSize;
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      AText.set(this.GetAsString());
    };
    this.SetAsBoolean = function (AValue) {
      if (AValue) {
        this.SetAsString("T")}
       else this.SetAsString("F");
    };
    this.SetAsDateTime = function (AValue) {
      this.SetAsString(pas.SysUtils.DateTimeToStr(AValue,false));
    };
    this.SetAsFloat = function (AValue) {
      this.SetAsString(pas.SysUtils.FloatToStr(AValue));
    };
    this.SetAsInteger = function (AValue) {
      this.SetAsString(pas.SysUtils.IntToStr(AValue));
    };
    this.SetAsLargeInt = function (AValue) {
      this.SetAsString(pas.SysUtils.IntToStr(AValue));
    };
    this.SetAsString = function (AValue) {
      this.SetData(AValue);
    };
    this.SetVarValue = function (AValue) {
      if (rtl.isString(AValue)) {
        this.SetAsString("" + AValue)}
       else this.RaiseAccessError(rtl.getResStr(pas.DBConst,"SFieldValueError"));
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftString);
      this.FFixedChar = false;
      this.FTransliterate = false;
      this.FSize = 20;
      return this;
    };
    this.SetFieldType = function (AValue) {
      if (AValue in rtl.createSet($mod.TFieldType.ftString,$mod.TFieldType.ftFixedChar,$mod.TFieldType.ftWideString)) this.SetDataType(AValue);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",4,{Default: 20});
  });
  rtl.createClass(this,"TNumericField",this.TField,function () {
    this.$init = function () {
      $mod.TField.$init.call(this);
      this.FDisplayFormat = "";
      this.FEditFormat = "";
    };
    this.CheckTypeSize = function (AValue) {
      if (AValue > 16) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidFieldSize"),pas.System.VarRecs(0,AValue));
    };
    this.RangeError = function (AValue, Min, Max) {
      $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SRangeError"),pas.System.VarRecs(3,AValue,3,Min,3,Max,18,this.FFieldName));
    };
    this.SetDisplayFormat = function (AValue) {
      if (this.FDisplayFormat !== AValue) {
        this.FDisplayFormat = AValue;
        this.PropertyChanged(true);
      };
    };
    this.SetEditFormat = function (AValue) {
      if (this.FEditFormat !== AValue) {
        this.FEditFormat = AValue;
        this.PropertyChanged(true);
      };
    };
    this.GetAsBoolean = function () {
      var Result = false;
      Result = this.GetAsInteger() !== 0;
      return Result;
    };
    this.SetAsBoolean = function (AValue) {
      this.SetAsInteger(AValue + 0);
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.call(this,AOwner);
      this.SetAlignment(pas.Classes.TAlignment.taRightJustify);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taRightJustify});
    $r.addProperty("DisplayFormat",2,rtl.string,"FDisplayFormat","SetDisplayFormat");
    $r.addProperty("EditFormat",2,rtl.string,"FEditFormat","SetEditFormat");
  });
  rtl.createClass(this,"TIntegerField",this.TNumericField,function () {
    this.$init = function () {
      $mod.TNumericField.$init.call(this);
      this.FMinValue = 0;
      this.FMaxValue = 0;
      this.FMinRange = 0;
      this.FMaxRange = 0;
    };
    this.SetMinValue = function (AValue) {
      if ((AValue >= this.FMinRange) && (AValue <= this.FMaxRange)) {
        this.FMinValue = AValue}
       else this.RangeError(AValue,this.FMinRange,this.FMaxRange);
    };
    this.SetMaxValue = function (AValue) {
      if ((AValue >= this.FMinRange) && (AValue <= this.FMaxRange)) {
        this.FMaxValue = AValue}
       else this.RangeError(AValue,this.FMinRange,this.FMaxRange);
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      Result = this.GetAsInteger();
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      if (!this.GetValue({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = 0;
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var L = 0;
      if (this.GetValue({get: function () {
          return L;
        }, set: function (v) {
          L = v;
        }})) {
        Result = pas.SysUtils.IntToStr(L)}
       else Result = "";
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      var L = 0;
      if (this.GetValue({get: function () {
          return L;
        }, set: function (v) {
          L = v;
        }})) {
        Result = L}
       else Result = null;
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      var l = 0;
      var fmt = "";
      AText.set("");
      if (!this.GetValue({get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }})) return;
      if (ADisplayText || (this.FEditFormat === "")) {
        fmt = this.FDisplayFormat}
       else fmt = this.FEditFormat;
      if (fmt.length !== 0) {
        AText.set(pas.SysUtils.FormatFloat(fmt,l))}
       else AText.set("" + l);
    };
    this.GetValue = function (AValue) {
      var Result = false;
      var V = undefined;
      V = this.GetData();
      Result = pas.JS.isInteger(V);
      if (Result) AValue.set(rtl.trunc(V));
      return Result;
    };
    this.SetAsFloat = function (AValue) {
      this.SetAsInteger(Math.round(AValue));
    };
    this.SetAsInteger = function (AValue) {
      if (this.CheckRange(AValue)) {
        this.SetData(AValue)}
       else if ((this.FMinValue !== 0) || (this.FMaxValue !== 0)) {
        this.RangeError(AValue,this.FMinValue,this.FMaxValue)}
       else this.RangeError(AValue,this.FMinRange,this.FMaxRange);
    };
    this.SetAsString = function (AValue) {
      var L = 0;
      var Code = 0;
      if (AValue.length === 0) {
        this.Clear()}
       else {
        pas.System.val$6(AValue,{get: function () {
            return L;
          }, set: function (v) {
            L = v;
          }},{get: function () {
            return Code;
          }, set: function (v) {
            Code = v;
          }});
        if (Code === 0) {
          this.SetAsInteger(L)}
         else $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SNotAninteger"),pas.System.VarRecs(18,AValue));
      };
    };
    this.SetVarValue = function (AValue) {
      if (pas.JS.isInteger(AValue)) {
        this.SetAsInteger(rtl.trunc(AValue))}
       else this.RaiseAccessError($impl.SInteger);
    };
    this.GetAsLargeInt = function () {
      var Result = 0;
      Result = this.GetAsInteger();
      return Result;
    };
    this.SetAsLargeInt = function (AValue) {
      if ((AValue >= this.FMinRange) && (AValue <= this.FMaxRange)) {
        this.SetAsInteger(AValue)}
       else this.RangeError(AValue,this.FMinRange,this.FMaxRange);
    };
    this.Create$1 = function (AOwner) {
      $mod.TNumericField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftInteger);
      this.FMinRange = -2147483648;
      this.FMaxRange = 2147483647;
      return this;
    };
    this.CheckRange = function (AValue) {
      var Result = false;
      if ((this.FMinValue !== 0) || (this.FMaxValue !== 0)) {
        Result = (AValue >= this.FMinValue) && (AValue <= this.FMaxValue)}
       else Result = (AValue >= this.FMinRange) && (AValue <= this.FMaxRange);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("MaxValue",2,rtl.longint,"FMaxValue","SetMaxValue",4,{Default: 0});
    $r.addProperty("MinValue",2,rtl.longint,"FMinValue","SetMinValue",4,{Default: 0});
  });
  rtl.createClass(this,"TSmallIntField",this.TIntegerField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWordField",this.TIntegerField,function () {
    this.SetAsWord = function (AValue) {
      this.SetAsInteger(AValue);
    };
    this.GetAsWord = function () {
      var Result = 0;
      var w = 0;
      if (!this.GetValue({get: function () {
          return w;
        }, set: function (v) {
          w = v;
        }})) {
        Result = 0}
       else Result = w;
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TLargeintField",this.TNumericField,function () {
    this.$init = function () {
      $mod.TNumericField.$init.call(this);
      this.FMinValue = 0;
      this.FMaxValue = 0;
      this.FMinRange = 0;
      this.FMaxRange = 0;
    };
    this.SetMinValue = function (AValue) {
      if ((AValue >= this.FMinRange) && (AValue <= this.FMaxRange)) {
        this.FMinValue = AValue}
       else this.RangeError(AValue,this.FMinRange,this.FMaxRange);
    };
    this.SetMaxValue = function (AValue) {
      if ((AValue >= this.FMinRange) && (AValue <= this.FMaxRange)) {
        this.FMaxValue = AValue}
       else this.RangeError(AValue,this.FMinRange,this.FMaxRange);
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      Result = this.GetAsLargeInt();
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      Result = this.GetAsLargeInt();
      return Result;
    };
    this.GetAsLargeInt = function () {
      var Result = 0;
      if (!this.GetValue({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = 0;
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var L = 0;
      if (this.GetValue({get: function () {
          return L;
        }, set: function (v) {
          L = v;
        }})) {
        Result = pas.SysUtils.IntToStr(L)}
       else Result = "";
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      var L = 0;
      if (this.GetValue({get: function () {
          return L;
        }, set: function (v) {
          L = v;
        }})) {
        Result = L}
       else Result = null;
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      var l = 0;
      var fmt = "";
      AText.set("");
      if (!this.GetValue({get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }})) return;
      if (ADisplayText || (this.FEditFormat === "")) {
        fmt = this.FDisplayFormat}
       else fmt = this.FEditFormat;
      if (fmt.length !== 0) {
        AText.set(pas.SysUtils.FormatFloat(fmt,l))}
       else AText.set("" + l);
    };
    this.GetValue = function (AValue) {
      var Result = false;
      var P = undefined;
      P = this.GetData();
      Result = pas.JS.isInteger(P);
      if (Result) AValue.set(rtl.trunc(P));
      return Result;
    };
    this.SetAsFloat = function (AValue) {
      this.SetAsLargeInt(Math.round(AValue));
    };
    this.SetAsInteger = function (AValue) {
      this.SetAsLargeInt(AValue);
    };
    this.SetAsLargeInt = function (AValue) {
      if (this.CheckRange(AValue)) {
        this.SetData(AValue)}
       else this.RangeError(AValue,this.FMinValue,this.FMaxValue);
    };
    this.SetAsString = function (AValue) {
      var L = 0;
      var code = 0;
      if (AValue.length === 0) {
        this.Clear()}
       else {
        pas.System.val(AValue,{get: function () {
            return L;
          }, set: function (v) {
            L = v;
          }},{get: function () {
            return code;
          }, set: function (v) {
            code = v;
          }});
        if (code === 0) {
          this.SetAsLargeInt(L)}
         else $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SNotAninteger"),pas.System.VarRecs(18,AValue));
      };
    };
    this.SetVarValue = function (AValue) {
      if (pas.JS.isInteger(AValue)) {
        this.SetAsLargeInt(rtl.trunc(AValue))}
       else this.RaiseAccessError($impl.SLargeInt);
    };
    this.Create$1 = function (AOwner) {
      $mod.TNumericField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftLargeint);
      this.FMinRange = -9007199254740991;
      this.FMaxRange = 9007199254740991;
      return this;
    };
    this.CheckRange = function (AValue) {
      var Result = false;
      if ((this.FMinValue !== 0) || (this.FMaxValue !== 0)) {
        Result = (AValue >= this.FMinValue) && (AValue <= this.FMaxValue)}
       else Result = (AValue >= this.FMinRange) && (AValue <= this.FMaxRange);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("MaxValue",2,rtl.nativeint,"FMaxValue","SetMaxValue",4,{Default: 0});
    $r.addProperty("MinValue",2,rtl.nativeint,"FMinValue","SetMinValue",4,{Default: 0});
  });
  rtl.createClass(this,"TAutoIncField",this.TIntegerField,function () {
    this.SetAsInteger = function (AValue) {
      $mod.TIntegerField.SetAsInteger.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      $mod.TIntegerField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftAutoInc);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TFloatField",this.TNumericField,function () {
    this.$init = function () {
      $mod.TNumericField.$init.call(this);
      this.FCurrency = false;
      this.FMaxValue = 0.0;
      this.FMinValue = 0.0;
      this.FPrecision = 0;
    };
    this.SetCurrency = function (AValue) {
      if (this.FCurrency === AValue) return;
      this.FCurrency = AValue;
    };
    this.SetPrecision = function (AValue) {
      if ((AValue === -1) || (AValue > 1)) {
        this.FPrecision = AValue}
       else this.FPrecision = 2;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      var P = undefined;
      P = this.GetData();
      if (rtl.isNumber(P)) {
        Result = rtl.getNumber(P)}
       else Result = 0.0;
      return Result;
    };
    this.GetAsLargeInt = function () {
      var Result = 0;
      Result = Math.round(this.GetAsFloat());
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      Result = Math.round(this.GetAsFloat());
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      var P = undefined;
      P = this.GetData();
      if (rtl.isNumber(P)) {
        Result = P}
       else Result = null;
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var P = undefined;
      P = this.GetData();
      if (rtl.isNumber(P)) {
        Result = pas.SysUtils.FloatToStr(rtl.getNumber(P))}
       else Result = "";
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      var fmt = "";
      var E = 0.0;
      var Digits = 0;
      var ff = 0;
      var P = undefined;
      AText.set("");
      P = this.GetData();
      if (!rtl.isNumber(P)) return;
      E = rtl.getNumber(P);
      if (ADisplayText || (this.FEditFormat.length === 0)) {
        fmt = this.FDisplayFormat}
       else fmt = this.FEditFormat;
      Digits = 0;
      if (!this.FCurrency) {
        ff = pas.SysUtils.TFloatFormat.ffGeneral}
       else {
        Digits = 2;
        ff = pas.SysUtils.TFloatFormat.ffFixed;
      };
      if (fmt !== "") {
        AText.set(pas.SysUtils.FormatFloat(fmt,E))}
       else AText.set(pas.SysUtils.FloatToStrF(E,ff,this.FPrecision,Digits));
    };
    this.SetAsFloat = function (AValue) {
      if (this.CheckRange(AValue)) {
        this.SetData(AValue)}
       else this.RangeError(AValue,this.FMinValue,this.FMaxValue);
    };
    this.SetAsLargeInt = function (AValue) {
      this.SetAsFloat(AValue);
    };
    this.SetAsInteger = function (AValue) {
      this.SetAsFloat(AValue);
    };
    this.SetAsString = function (AValue) {
      var f = 0.0;
      if (AValue === "") {
        this.Clear()}
       else {
        if (!pas.SysUtils.TryStrToFloat$2(AValue,{get: function () {
            return f;
          }, set: function (v) {
            f = v;
          }})) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SNotAFloat"),pas.System.VarRecs(18,AValue));
        this.SetAsFloat(f);
      };
    };
    this.SetVarValue = function (AValue) {
      if (rtl.isNumber(AValue)) {
        this.SetAsFloat(rtl.getNumber(AValue))}
       else this.RaiseAccessError("Float");
    };
    this.Create$1 = function (AOwner) {
      $mod.TNumericField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftFloat);
      this.FPrecision = 15;
      return this;
    };
    this.CheckRange = function (AValue) {
      var Result = false;
      if ((this.FMinValue !== 0) || (this.FMaxValue !== 0)) {
        Result = (AValue >= this.FMinValue) && (AValue <= this.FMaxValue)}
       else Result = true;
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Currency",2,rtl.boolean,"FCurrency","SetCurrency",4,{Default: false});
    $r.addProperty("MaxValue",0,rtl.double,"FMaxValue","FMaxValue");
    $r.addProperty("MinValue",0,rtl.double,"FMinValue","FMinValue");
    $r.addProperty("Precision",2,rtl.longint,"FPrecision","SetPrecision",4,{Default: 15});
  });
  rtl.createClass(this,"TBooleanField",this.TField,function () {
    this.FDisplays$a$clone = function (a) {
      var b = [];
      b.length = 2;
      for (var c = 0; c < 2; c++) b[c] = a[c].slice(0);
      return b;
    };
    this.$init = function () {
      $mod.TField.$init.call(this);
      this.FDisplayValues = "";
      this.FDisplays = rtl.arraySetLength(null,"",2,2);
    };
    this.$final = function () {
      this.FDisplays = undefined;
      $mod.TField.$final.call(this);
    };
    this.SetDisplayValues = function (AValue) {
      var I = 0;
      if (this.FDisplayValues !== AValue) {
        I = pas.System.Pos(";",AValue);
        if ((I < 2) || (I === AValue.length)) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidDisplayValues"),pas.System.VarRecs(18,AValue));
        this.FDisplayValues = AValue;
        this.FDisplays[0][1] = pas.System.Copy(AValue,1,I - 1);
        this.FDisplays[1][1] = pas.SysUtils.UpperCase(this.FDisplays[0][1]);
        this.FDisplays[0][0] = pas.System.Copy(AValue,I + 1,AValue.length - I);
        this.FDisplays[1][0] = pas.SysUtils.UpperCase(this.FDisplays[0][0]);
        this.PropertyChanged(true);
      };
    };
    this.GetAsBoolean = function () {
      var Result = false;
      var P = undefined;
      P = this.GetData();
      if (pas.JS.isBoolean(P)) {
        Result = !(P == false)}
       else Result = false;
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var P = undefined;
      P = this.GetData();
      if (pas.JS.isBoolean(P)) {
        Result = this.FDisplays[0][+!(P == false)]}
       else Result = "";
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      var P = undefined;
      P = this.GetData();
      if (pas.JS.isBoolean(P)) {
        Result = !(P == false)}
       else Result = null;
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      Result = this.GetAsBoolean() + 0;
      return Result;
    };
    this.GetDefaultWidth = function () {
      var Result = 0;
      Result = this.FDisplays[0][0].length;
      if (Result < this.FDisplays[0][1].length) Result = this.FDisplays[0][1].length;
      return Result;
    };
    this.SetAsBoolean = function (AValue) {
      this.SetData(AValue);
    };
    this.SetAsString = function (AValue) {
      var Temp = "";
      Temp = pas.SysUtils.UpperCase(AValue);
      if (Temp === "") {
        this.Clear()}
       else if (pas.System.Pos(Temp,this.FDisplays[1][1]) === 1) {
        this.SetAsBoolean(true)}
       else if (pas.System.Pos(Temp,this.FDisplays[1][0]) === 1) {
        this.SetAsBoolean(false)}
       else $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SNotABoolean"),pas.System.VarRecs(18,AValue));
    };
    this.SetAsInteger = function (AValue) {
      this.SetAsBoolean(AValue !== 0);
    };
    this.SetVarValue = function (AValue) {
      if (pas.JS.isBoolean(AValue)) {
        this.SetAsBoolean(!(AValue == false))}
       else if (rtl.isNumber(AValue)) this.SetAsBoolean(rtl.getNumber(AValue) !== 0);
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftBoolean);
      this.SetDisplayValues("True;False");
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $mod.$rtti.$StaticArray("TBooleanField.FDisplays$a",{dims: [2,2], eltype: rtl.string});
    $r.addProperty("DisplayValues",2,rtl.string,"FDisplayValues","SetDisplayValues");
  });
  rtl.createClass(this,"TDateTimeField",this.TField,function () {
    this.$init = function () {
      $mod.TField.$init.call(this);
      this.FDisplayFormat = "";
    };
    this.SetDisplayFormat = function (AValue) {
      if (this.FDisplayFormat !== AValue) {
        this.FDisplayFormat = AValue;
        this.PropertyChanged(true);
      };
    };
    this.ConvertToDateTime = function (aValue, aRaiseError) {
      var Result = 0.0;
      if (pas.JS.isNull(aValue)) {
        Result = 0}
       else if (this.FDataSet != null) {
        Result = this.FDataSet.ConvertToDateTime(this,aValue,aRaiseError)}
       else Result = $mod.TDataSet.DefaultConvertToDateTime(this,aValue,aRaiseError);
      return Result;
    };
    this.DateTimeToNativeDateTime = function (aValue) {
      var Result = undefined;
      if (this.FDataSet != null) {
        Result = this.FDataSet.ConvertDateTimeToNative(this,aValue)}
       else Result = $mod.TDataSet.DefaultConvertDateTimeToNative(this,aValue);
      return Result;
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      Result = this.ConvertToDateTime(this.GetData(),false);
      return Result;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      Result = this.GetAsDateTime();
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      this.GetText({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},false);
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      if (!rtl.isString(Result)) Result = null;
      return Result;
    };
    this.GetDataSize = function () {
      var Result = 0;
      Result = $mod.TField.GetDataSize.call(this);
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      var R = 0.0;
      var F = "";
      R = this.ConvertToDateTime(this.GetData(),false);
      if (R === 0) {
        AText.set("")}
       else {
        if (ADisplayText && (this.FDisplayFormat.length !== 0)) {
          F = this.FDisplayFormat}
         else {
          var $tmp = this.FDataType;
          if ($tmp === $mod.TFieldType.ftTime) {
            F = pas.SysUtils.FormatSettings.LongTimeFormat}
           else if ($tmp === $mod.TFieldType.ftDate) {
            F = pas.SysUtils.FormatSettings.ShortDateFormat}
           else {
            F = "c";
          };
        };
        AText.set(pas.SysUtils.FormatDateTime(F,R));
      };
    };
    this.SetAsDateTime = function (AValue) {
      this.SetData(this.DateTimeToNativeDateTime(AValue));
    };
    this.SetAsFloat = function (AValue) {
      this.SetAsDateTime(AValue);
    };
    this.SetAsString = function (AValue) {
      var R = 0.0;
      if (AValue !== "") {
        R = pas.SysUtils.StrToDateTime(AValue);
        this.SetData(this.DateTimeToNativeDateTime(R));
      } else this.SetData(null);
    };
    this.SetVarValue = function (AValue) {
      this.SetAsDateTime(this.ConvertToDateTime(AValue,true));
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftDateTime);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DisplayFormat",2,rtl.string,"FDisplayFormat","SetDisplayFormat");
  });
  rtl.createClass(this,"TDateField",this.TDateTimeField,function () {
    this.Create$1 = function (AOwner) {
      $mod.TDateTimeField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftDate);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTimeField",this.TDateTimeField,function () {
    this.SetAsString = function (AValue) {
      var R = 0.0;
      if (AValue !== "") {
        R = pas.SysUtils.StrToTime(AValue);
        this.SetData(this.DateTimeToNativeDateTime(R));
      } else this.SetData(null);
    };
    this.Create$1 = function (AOwner) {
      $mod.TDateTimeField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftTime);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TBinaryField",this.TField,function () {
    this.CheckTypeSize = function (AValue) {
      if (AValue < 1) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidFieldSize"),pas.System.VarRecs(0,AValue));
    };
    this.BlobToBytes = function (aValue) {
      var Result = [];
      if (this.FDataSet != null) {
        Result = this.FDataSet.BlobDataToBytes(aValue)}
       else Result = $mod.TDataSet.DefaultBlobDataToBytes(aValue);
      return Result;
    };
    this.BytesToBlob = function (aValue) {
      var Result = undefined;
      if (this.FDataSet != null) {
        Result = this.FDataSet.BytesToBlobData(rtl.arrayRef(aValue))}
       else Result = $mod.TDataSet.DefaultBytesToBlobData(rtl.arrayRef(aValue));
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var V = undefined;
      var S = [];
      var I = 0;
      Result = "";
      V = this.GetData();
      if (V != null) if (this.FDataType in rtl.createSet($mod.TFieldType.ftMemo,$mod.TFieldType.ftGraphic)) {
        Result = "" + V}
       else {
        S = this.BlobToBytes(V);
        for (var $l = 0, $end = rtl.length(S) - 1; $l <= $end; $l++) {
          I = $l;
          Result = Result.concat(String.fromCharCode(S[I]));
        };
      };
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      return Result;
    };
    this.GetValue = function (AValue) {
      var Result = false;
      var V = undefined;
      V = this.GetData();
      Result = V != null;
      if (Result) {
        AValue.set(this.BlobToBytes(V))}
       else AValue.set(rtl.arraySetLength(AValue.get(),0,0));
      return Result;
    };
    this.SetAsString = function (AValue) {
      var B = [];
      var i = 0;
      if (this.FDataType in rtl.createSet($mod.TFieldType.ftMemo,$mod.TFieldType.ftGraphic)) {
        this.SetData(AValue)}
       else {
        B = rtl.arraySetLength(B,0,AValue.length);
        for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
          i = $l;
          B[i - 1] = AValue.charCodeAt(i - 1);
        };
        this.SetAsBytes(B);
      };
    };
    this.SetVarValue = function (AValue) {
      var B = [];
      var I = 0;
      var Len = 0;
      if (rtl.isArray(AValue)) {
        Len = rtl.length(AValue);
        B = rtl.arraySetLength(B,0,Len);
        for (var $l = 1, $end = Len - 1; $l <= $end; $l++) {
          I = $l;
          B[I] = AValue[I];
        };
        this.SetAsBytes(B);
      } else if (rtl.isString(AValue)) {
        this.SetAsString("" + AValue)}
       else this.RaiseAccessError("Blob");
    };
    this.GetAsBytes = function () {
      var Result = [];
      var V = undefined;
      V = this.GetData();
      if (pas.System.Assigned(V)) {
        Result = this.BlobToBytes(V)}
       else Result = rtl.arraySetLength(Result,0,0);
      return Result;
    };
    this.SetAsBytes = function (aValue) {
      this.SetData(this.BytesToBlob(rtl.arrayRef(aValue)));
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.call(this,AOwner);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",4,{Default: 16});
  });
  this.TBlobDisplayValue = {"0": "dvClass", dvClass: 0, "1": "dvFull", dvFull: 1, "2": "dvClip", dvClip: 2, "3": "dvFit", dvFit: 3};
  this.$rtti.$Enum("TBlobDisplayValue",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBlobDisplayValue});
  this.TBlobStreamMode = {"0": "bmRead", bmRead: 0, "1": "bmWrite", bmWrite: 1, "2": "bmReadWrite", bmReadWrite: 2};
  this.$rtti.$Enum("TBlobStreamMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TBlobStreamMode});
  this.$rtti.$Enum("TBlobType",{minvalue: 15, maxvalue: 39, ordtype: 1, enumtype: this.TFieldType});
  rtl.createClass(this,"TBlobField",this.TBinaryField,function () {
    this.$init = function () {
      $mod.TBinaryField.$init.call(this);
      this.FDisplayValue = 0;
      this.FModified = false;
    };
    this.GetBlobType = function () {
      var Result = $mod.TFieldType.ftBlob;
      Result = this.FDataType;
      return Result;
    };
    this.SetBlobType = function (AValue) {
      if (this.GetBlobType() !== AValue) {
        this.SetFieldType(AValue);
        this.PropertyChanged(true);
      };
    };
    this.SetDisplayValue = function (AValue) {
      if (this.FDisplayValue === AValue) return;
      this.FDisplayValue = AValue;
      this.PropertyChanged(false);
    };
    this.CheckTypeSize = function (AValue) {
      if (AValue < 0) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidFieldSize"),pas.System.VarRecs(0,AValue));
    };
    this.GetBlobSize = function () {
      var Result = 0;
      var B = [];
      B = this.GetAsBytes();
      Result = rtl.length(B);
      return Result;
    };
    this.GetIsNull = function () {
      var Result = false;
      if (!this.FModified) {
        Result = $mod.TField.GetIsNull.call(this)}
       else Result = this.GetBlobSize() === 0;
      return Result;
    };
    this.GetText = function (AText, ADisplayText) {
      var $tmp = this.FDisplayValue;
      if ($tmp === $mod.TBlobDisplayValue.dvClass) {
        AText.set(this.GetClassDesc())}
       else if ($tmp === $mod.TBlobDisplayValue.dvFull) {
        AText.set(this.GetAsString())}
       else if ($tmp === $mod.TBlobDisplayValue.dvClip) {
        AText.set(this.GetAsString());
        if (ADisplayText && (AText.get().length > this.GetDisplayWidth())) AText.set(pas.System.Copy(this.GetEditText(),1,this.GetDisplayWidth()) + "...");
      } else if ($tmp === $mod.TBlobDisplayValue.dvFit) {
        AText.set(this.GetAsString());
        if (ADisplayText && (AText.get().length > this.GetDisplayWidth())) AText.set(this.GetClassDesc());
      };
    };
    this.Create$1 = function (AOwner) {
      $mod.TBinaryField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftBlob);
      return this;
    };
    this.Clear = function () {
      this.SetData(null);
    };
    this.IsBlob = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.SetFieldType = function (AValue) {
      if (AValue in rtl.createSet(null,$mod.TFieldType.ftBlob,$mod.TFieldType.ftWideMemo)) this.SetDataType(AValue);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DisplayValue",2,$mod.$rtti["TBlobDisplayValue"],"FDisplayValue","SetDisplayValue",4,{Default: $mod.TBlobDisplayValue.dvClass});
    $r.addProperty("BlobType",3,$mod.$rtti["TBlobType"],"GetBlobType","SetBlobType");
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",4,{Default: 0});
  });
  rtl.createClass(this,"TMemoField",this.TBlobField,function () {
    this.GetText = function (AText, ADisplayText) {
      AText.set($mod.TBinaryField.GetAsString.call(this));
    };
    this.Create$1 = function (AOwner) {
      $mod.TBlobField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftMemo);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TGraphicField",this.TBlobField,function () {
    this.Create$1 = function (AOwner) {
      $mod.TBlobField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftGraphic);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TVariantField",this.TField,function () {
    this.CheckTypeSize = function (aValue) {
    };
    this.GetAsBoolean = function () {
      var Result = false;
      Result = this.GetAsJSValue() == true;
      return Result;
    };
    this.SetAsBoolean = function (aValue) {
      this.SetVarValue(aValue);
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      var V = undefined;
      V = this.GetData();
      if (this.FDataSet != null) {
        Result = this.FDataSet.ConvertToDateTime(this,V,true)}
       else Result = $mod.TDataSet.DefaultConvertToDateTime(this,V,true);
      return Result;
    };
    this.SetAsDateTime = function (aValue) {
      this.SetVarValue(aValue);
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      var V = undefined;
      V = this.GetData();
      if (rtl.isNumber(V)) {
        Result = rtl.getNumber(V)}
       else if (rtl.isString(V)) {
        Result = parseFloat("" + V)}
       else this.RaiseAccessError("Variant");
      return Result;
    };
    this.SetAsFloat = function (aValue) {
      this.SetVarValue(aValue);
    };
    this.GetAsInteger = function () {
      var Result = 0;
      var V = undefined;
      V = this.GetData();
      if (pas.JS.isInteger(V)) {
        Result = rtl.trunc(V)}
       else if (rtl.isString(V)) {
        Result = parseInt("" + V)}
       else this.RaiseAccessError("Variant");
      return Result;
    };
    this.SetAsInteger = function (AValue) {
      this.SetVarValue(AValue);
    };
    this.GetAsString = function () {
      var Result = "";
      var V = undefined;
      V = this.GetData();
      if (pas.JS.isInteger(V)) {
        Result = pas.SysUtils.IntToStr(rtl.trunc(V))}
       else if (rtl.isNumber(V)) {
        Result = pas.SysUtils.FloatToStr(rtl.getNumber(V))}
       else if (rtl.isString(V)) {
        Result = "" + V}
       else this.RaiseAccessError("Variant");
      return Result;
    };
    this.SetAsString = function (aValue) {
      this.SetVarValue(aValue);
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      return Result;
    };
    this.SetVarValue = function (aValue) {
      this.SetData(aValue);
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.call(this,AOwner);
      this.SetDataType($mod.TFieldType.ftVariant);
      return this;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TDataSetField",this.TField,function () {
    this.$init = function () {
      $mod.TField.$init.call(this);
      this.FNestedDataSet = null;
    };
    this.$final = function () {
      this.FNestedDataSet = undefined;
      $mod.TField.$final.call(this);
    };
    this.AssignNestedDataSet = function (Value) {
      if (this.FNestedDataSet != null) {
        this.FNestedDataSet.Close();
        this.FNestedDataSet.FDataSetField = null;
        if (this.FDataSet != null) this.FDataSet.GetNestedDataSets().Remove(this.FNestedDataSet);
      };
      if (Value != null) this.FDataSet.GetNestedDataSets().Add(Value);
      this.FNestedDataSet = Value;
    };
    this.Bind = function (Binding) {
      $mod.TField.Bind.apply(this,arguments);
      if (this.FNestedDataSet != null) if (Binding) {
        if (this.FNestedDataSet.FState === $mod.TDataSetState.dsInactive) this.FNestedDataSet.Open();
      } else this.FNestedDataSet.Close();
    };
    this.Create$1 = function (AOwner) {
      $mod.TField.Create$1.apply(this,arguments);
      this.SetDataType($mod.TFieldType.ftDataSet);
      return this;
    };
    this.Destroy = function () {
      this.AssignNestedDataSet(null);
      $mod.TField.Destroy.call(this);
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TIndexDefs");
  this.TIndexOption = {"0": "ixPrimary", ixPrimary: 0, "1": "ixUnique", ixUnique: 1, "2": "ixDescending", ixDescending: 2, "3": "ixCaseInsensitive", ixCaseInsensitive: 3, "4": "ixExpression", ixExpression: 4, "5": "ixNonMaintained", ixNonMaintained: 5};
  this.$rtti.$Enum("TIndexOption",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TIndexOption});
  this.$rtti.$Set("TIndexOptions",{comptype: this.$rtti["TIndexOption"]});
  rtl.createClass(this,"TIndexDef",this.TNamedItem,function () {
    this.$init = function () {
      $mod.TNamedItem.$init.call(this);
      this.FCaseinsFields = "";
      this.FDescFields = "";
      this.FExpression = "";
      this.FFields = "";
      this.FOptions = {};
      this.FSource = "";
    };
    this.$final = function () {
      this.FOptions = undefined;
      $mod.TNamedItem.$final.call(this);
    };
    this.GetExpression = function () {
      var Result = "";
      Result = this.FExpression;
      return Result;
    };
    this.SetCaseInsFields = function (AValue) {
      if (this.FCaseinsFields === AValue) return;
      if (AValue !== "") this.FOptions = rtl.unionSet(this.FOptions,rtl.createSet($mod.TIndexOption.ixCaseInsensitive));
      this.FCaseinsFields = AValue;
    };
    this.SetDescFields = function (AValue) {
      if (this.FDescFields === AValue) return;
      if (AValue !== "") this.FOptions = rtl.unionSet(this.FOptions,rtl.createSet($mod.TIndexOption.ixDescending));
      this.FDescFields = AValue;
    };
    this.SetExpression = function (AValue) {
      this.FExpression = AValue;
    };
    this.Create$2 = function (Owner, AName, TheFields, TheOptions) {
      this.FName = AName;
      pas.Classes.TCollectionItem.Create$1.call(this,Owner);
      this.FFields = TheFields;
      this.FOptions = rtl.refSet(TheOptions);
      return this;
    };
    this.Assign = function (Source) {
      var idef = null;
      idef = null;
      if ($mod.TIndexDef.isPrototypeOf(Source)) idef = rtl.as(Source,$mod.TIndexDef);
      if (idef != null) {
        this.FName = idef.FName;
        this.FFields = idef.FFields;
        this.FOptions = rtl.refSet(idef.FOptions);
        this.FCaseinsFields = idef.FCaseinsFields;
        this.FDescFields = idef.FDescFields;
        this.FSource = idef.FSource;
        this.FExpression = idef.GetExpression();
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    var $r = this.$rtti;
    $r.addProperty("Expression",3,rtl.string,"GetExpression","SetExpression");
    $r.addProperty("Fields",0,rtl.string,"FFields","FFields");
    $r.addProperty("CaseInsFields",2,rtl.string,"FCaseinsFields","SetCaseInsFields");
    $r.addProperty("DescFields",2,rtl.string,"FDescFields","SetDescFields");
    $r.addProperty("Options",0,$mod.$rtti["TIndexOptions"],"FOptions","FOptions");
    $r.addProperty("Source",0,rtl.string,"FSource","FSource");
  });
  this.$rtti.$ClassRef("TIndexDefClass",{instancetype: this.$rtti["TIndexDef"]});
  rtl.createClass(this,"TIndexDefs",this.TDefCollection,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = rtl.as(pas.Classes.TCollection.GetItem.call(this,Index),$mod.TIndexDef);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.Create$4 = function (ADataSet) {
      $mod.TDefCollection.create$3.call(this,ADataSet,this.Owner(),$mod.TIndexDef);
      return this;
    };
    this.Add$1 = function (Name, Fields, Options) {
      this.FItemClass.$create("Create$2",[this,Name,Fields,rtl.refSet(Options)]);
    };
    this.AddIndexDef = function () {
      var Result = null;
      Result = this.FItemClass.$create("Create$2",[this,"","",{}]);
      return Result;
    };
    this.Find$1 = function (IndexName) {
      var Result = null;
      Result = rtl.as($mod.TDefCollection.Find.call(this,IndexName),$mod.TIndexDef);
      if (Result === null) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SIndexNotFound"),pas.System.VarRecs(18,IndexName),this.FDataset);
      return Result;
    };
    this.FindIndexForFields = function (Fields) {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetIndexForFields = function (Fields, CaseInsensitive) {
      var Result = null;
      var i = 0;
      var FieldsLen = 0;
      var Last = null;
      Last = null;
      FieldsLen = Fields.length;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        Result = this.GetItem$1(i);
        if (rtl.eqSet(rtl.intersectSet(Result.FOptions,rtl.createSet($mod.TIndexOption.ixDescending,$mod.TIndexOption.ixExpression)),{}) && (!CaseInsensitive || ($mod.TIndexOption.ixCaseInsensitive in Result.FOptions)) && pas.SysUtils.AnsiSameText(Fields,Result.FFields)) {
          return Result;
        } else if (pas.SysUtils.AnsiSameText(Fields,pas.System.Copy(Result.FFields,1,FieldsLen)) && ((Result.FFields.length === FieldsLen) || (Result.FFields.charAt((FieldsLen + 1) - 1) === ";"))) {
          if ((Last === null) || ((Last !== null) && (Last.FFields.length > Result.FFields.length))) Last = Result;
        };
      };
      Result = Last;
      return Result;
    };
    this.Update$1 = function () {
      if (!this.FUpdated && (this.FDataset != null)) {
        this.FDataset.UpdateIndexDefs();
        this.FUpdated = true;
      };
    };
  });
  rtl.createClass(this,"TCheckConstraint",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCustomConstraint = "";
      this.FErrorMessage = "";
      this.FFromDictionary = false;
      this.FImportedConstraint = "";
    };
    this.Assign = function (Source) {
    };
    var $r = this.$rtti;
    $r.addProperty("CustomConstraint",0,rtl.string,"FCustomConstraint","FCustomConstraint");
    $r.addProperty("ErrorMessage",0,rtl.string,"FErrorMessage","FErrorMessage");
    $r.addProperty("FromDictionary",0,rtl.boolean,"FFromDictionary","FFromDictionary");
    $r.addProperty("ImportedConstraint",0,rtl.string,"FImportedConstraint","FImportedConstraint");
  });
  rtl.createClass(this,"TCheckConstraints",pas.Classes.TCollection,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = null;
      return Result;
    };
    this.SetItem$1 = function (index, Value) {
    };
    this.GetOwner = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.Create$2 = function (AOwner) {
      pas.Classes.TCollection.Create$1.call(this,$mod.TCheckConstraint);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = null;
      return Result;
    };
  });
  rtl.createClass(this,"TFieldsEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FPosition = 0;
      this.FFields = null;
    };
    this.$final = function () {
      this.FFields = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FFields.GetField(this.FPosition);
      return Result;
    };
    this.Create$1 = function (AFields) {
      pas.System.TObject.Create.call(this);
      this.FFields = AFields;
      this.FPosition = -1;
      return this;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FFields.GetCount();
      return Result;
    };
  });
  rtl.createClass(this,"TFields",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FDataset = null;
      this.FFieldList = null;
      this.FOnChange = null;
      this.FValidFieldKinds = {};
    };
    this.$final = function () {
      this.FDataset = undefined;
      this.FFieldList = undefined;
      this.FOnChange = undefined;
      this.FValidFieldKinds = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.ClearFieldDefs = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetField(i).FFieldDef = null;
      };
    };
    this.Changed = function () {
      if ((this.FDataset !== null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FDataset.FComponentState)) this.FDataset.DataEvent($mod.TDataEvent.deFieldListChange,0);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.CheckfieldKind = function (Fieldkind, Field) {
      if (!(Fieldkind in this.FValidFieldKinds)) $mod.DatabaseErrorFmt(rtl.getResStr(pas.DBConst,"SInvalidFieldKind"),pas.System.VarRecs(18,Field.FFieldName));
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FFieldList.FCount;
      return Result;
    };
    this.GetField = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.FFieldList.Get(Index));
      return Result;
    };
    this.SetField = function (Index, Value) {
      this.GetField(Index).Assign(Value);
    };
    this.SetFieldIndex = function (Field, Value) {
      var Old = 0;
      Old = this.FFieldList.IndexOf(Field);
      if (Old === -1) return;
      if (Value < 0) Value = 0;
      if (Value >= this.GetCount()) Value = this.GetCount() - 1;
      if (Value !== Old) {
        this.FFieldList.Delete(Old);
        this.FFieldList.Insert(Value,Field);
        Field.PropertyChanged(true);
        this.Changed();
      };
    };
    this.Create$1 = function (ADataset) {
      this.FDataset = ADataset;
      this.FFieldList = pas.Classes.TFPList.$create("Create");
      this.FValidFieldKinds = rtl.createSet(null,$mod.TFieldKind.fkData,$mod.TFieldKind.fkInternalCalc);
      return this;
    };
    this.Destroy = function () {
      if (this.FFieldList != null) this.Clear();
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFieldList;
        }, set: function (v) {
          this.p.FFieldList = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
    this.Add = function (Field) {
      this.CheckFieldName(Field.FFieldName);
      this.FFieldList.Add(Field);
      Field.FFields = this;
      this.Changed();
    };
    this.CheckFieldName = function (Value) {
      if (this.FindField(Value) !== null) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SDuplicateFieldName"),pas.System.VarRecs(18,Value),this.FDataset);
    };
    this.CheckFieldNames = function (Value) {
      var N = "";
      var StrPos = 0;
      if (Value === "") return;
      StrPos = 1;
      do {
        N = $mod.ExtractFieldName(Value,{get: function () {
            return StrPos;
          }, set: function (v) {
            StrPos = v;
          }});
        this.FieldByName(N);
      } while (!(StrPos > Value.length));
    };
    this.Clear = function () {
      var AField = null;
      while (this.FFieldList.FCount > 0) {
        AField = rtl.getObject(this.FFieldList.Last());
        AField.FDataSet = null;
        AField = rtl.freeLoc(AField);
        this.FFieldList.Delete(this.FFieldList.FCount - 1);
      };
      this.Changed();
    };
    this.FindField = function (Value) {
      var Result = null;
      var S = "";
      var I = 0;
      S = pas.SysUtils.UpperCase(Value);
      for (var $l = 0, $end = this.FFieldList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        Result = rtl.getObject(this.FFieldList.Get(I));
        if (S === pas.SysUtils.UpperCase(Result.FFieldName)) {
          return Result;
        };
      };
      Result = null;
      return Result;
    };
    this.FieldByName = function (Value) {
      var Result = null;
      Result = this.FindField(Value);
      if (Result === null) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SFieldNotFound"),pas.System.VarRecs(18,Value),this.FDataset);
      return Result;
    };
    this.FieldByNumber = function (FieldNo) {
      var Result = null;
      var i = 0;
      for (var $l = 0, $end = this.FFieldList.FCount - 1; $l <= $end; $l++) {
        i = $l;
        Result = rtl.getObject(this.FFieldList.Get(i));
        if (FieldNo === Result.FFieldNo) return Result;
      };
      Result = null;
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TFieldsEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.GetFieldNames = function (Values) {
      var i = 0;
      Values.Clear();
      for (var $l = 0, $end = this.FFieldList.FCount - 1; $l <= $end; $l++) {
        i = $l;
        Values.Add(rtl.getObject(this.FFieldList.Get(i)).FFieldName);
      };
    };
    this.IndexOf = function (Field) {
      var Result = 0;
      Result = this.FFieldList.IndexOf(Field);
      return Result;
    };
    this.Remove = function (Value) {
      this.FFieldList.Remove(Value);
      Value.FFields = null;
      this.Changed();
    };
  });
  this.$rtti.$ClassRef("TFieldsClass",{instancetype: this.$rtti["TFields"]});
  this.$rtti.$DynArray("TParamBinding",{eltype: rtl.longint});
  this.TParamType = {"0": "ptUnknown", ptUnknown: 0, "1": "ptInput", ptInput: 1, "2": "ptOutput", ptOutput: 2, "3": "ptInputOutput", ptInputOutput: 3, "4": "ptResult", ptResult: 4};
  this.$rtti.$Enum("TParamType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TParamType});
  this.$rtti.$Set("TParamTypes",{comptype: this.$rtti["TParamType"]});
  this.TParamStyle = {"0": "psInterbase", psInterbase: 0, "1": "psPostgreSQL", psPostgreSQL: 1, "2": "psSimulated", psSimulated: 2};
  this.$rtti.$Enum("TParamStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TParamStyle});
  this.$rtti.$Class("TParams");
  rtl.createClass(this,"TParam",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FValue = undefined;
      this.FPrecision = 0;
      this.FNumericScale = 0;
      this.FName = "";
      this.FDataType = 0;
      this.FBound = false;
      this.FParamType = 0;
      this.FSize = 0;
    };
    this.GetDataSet = function () {
      var Result = null;
      if ((this.FCollection != null) && $mod.TParams.isPrototypeOf(this.FCollection)) {
        Result = this.FCollection.GetDataSet()}
       else Result = null;
      return Result;
    };
    this.IsParamStored = function () {
      var Result = false;
      Result = this.FBound;
      return Result;
    };
    this.AssignParam = function (Param) {
      if (!(Param != null)) {
        this.Clear();
        this.FDataType = $mod.TFieldType.ftUnknown;
        this.FParamType = $mod.TParamType.ptUnknown;
        this.FName = "";
        this.FSize = 0;
        this.FPrecision = 0;
        this.FNumericScale = 0;
      } else {
        this.FDataType = Param.FDataType;
        if (Param.GetIsNull()) {
          this.Clear()}
         else this.FValue = Param.FValue;
        this.FBound = Param.FBound;
        this.FName = Param.FName;
        if (this.FParamType === $mod.TParamType.ptUnknown) this.FParamType = Param.FParamType;
        this.FSize = Param.FSize;
        this.FPrecision = Param.FPrecision;
        this.FNumericScale = Param.FNumericScale;
      };
    };
    this.AssignTo = function (Dest) {
      if ($mod.TField.isPrototypeOf(Dest)) {
        this.AssignToField(Dest)}
       else pas.Classes.TPersistent.AssignTo.call(this,Dest);
    };
    this.GetAsBoolean = function () {
      var Result = false;
      if (!this.GetIsNull() && (this.FDataType === $mod.TFieldType.ftString)) {
        Result = pas.SysUtils.StrToBool("" + this.FValue);
      } else {
        if (this.GetIsNull()) {
          Result = false}
         else Result = this.FValue == true;
      };
      return Result;
    };
    this.GetAsBytes = function () {
      var Result = [];
      if (this.GetIsNull()) {
        Result = []}
       else if (rtl.isArray(this.FValue)) Result = this.FValue;
      return Result;
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      if (!this.GetIsNull() && (this.FDataType === $mod.TFieldType.ftString)) {
        Result = pas.SysUtils.StrToDateTime("" + this.FValue);
      } else {
        if (this.GetIsNull()) {
          Result = 0.0}
         else Result = rtl.getNumber(this.FValue);
      };
      return Result;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      if (!this.GetIsNull() && (this.FDataType === $mod.TFieldType.ftString)) {
        Result = pas.SysUtils.StrToFloat("" + this.FValue);
      } else {
        if (this.GetIsNull()) {
          Result = 0.0}
         else Result = rtl.getNumber(this.FValue);
      };
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      if (!this.GetIsNull() && (this.FDataType === $mod.TFieldType.ftString)) {
        Result = pas.SysUtils.StrToInt("" + this.FValue);
      } else {
        if (this.GetIsNull() || !pas.JS.isInteger(this.FValue)) {
          Result = 0}
         else Result = rtl.trunc(this.FValue);
      };
      return Result;
    };
    this.GetAsLargeInt = function () {
      var Result = 0;
      if (!this.GetIsNull() && (this.FDataType === $mod.TFieldType.ftString)) {
        Result = pas.SysUtils.StrToInt("" + this.FValue);
      } else {
        if (this.GetIsNull() || !pas.JS.isInteger(this.FValue)) {
          Result = 0}
         else Result = rtl.trunc(this.FValue);
      };
      return Result;
    };
    this.GetAsMemo = function () {
      var Result = "";
      if (this.GetIsNull() || !rtl.isString(this.FValue)) {
        Result = ""}
       else Result = "" + this.FValue;
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      if (this.GetIsNull() || !rtl.isString(this.FValue)) {
        Result = ""}
       else Result = "" + this.FValue;
      return Result;
    };
    this.GetAsJSValue = function () {
      var Result = undefined;
      if (this.GetIsNull()) {
        Result = null}
       else Result = this.FValue;
      return Result;
    };
    this.GetDisplayName = function () {
      var Result = "";
      if (this.FName !== "") {
        Result = this.FName}
       else Result = pas.Classes.TCollectionItem.GetDisplayName.call(this);
      return Result;
    };
    this.GetIsNull = function () {
      var Result = false;
      Result = pas.JS.isNull(this.FValue);
      return Result;
    };
    this.IsEqual = function (AValue) {
      var Result = false;
      Result = (this.FName === AValue.FName) && (this.GetIsNull() === AValue.GetIsNull()) && (this.FBound === AValue.FBound) && (this.FDataType === AValue.FDataType) && (this.FParamType === AValue.FParamType) && (pas.JS.GetValueType(this.FValue) === pas.JS.GetValueType(AValue.FValue)) && (this.FValue == AValue.FValue);
      return Result;
    };
    this.SetAsBlob = function (AValue) {
      this.FDataType = $mod.TFieldType.ftBlob;
      this.SetAsJSValue(AValue);
    };
    this.SetAsBoolean = function (AValue) {
      this.FDataType = $mod.TFieldType.ftBoolean;
      this.SetAsJSValue(AValue);
    };
    this.SetAsBytes = function (AValue) {
    };
    this.SetAsDate = function (AValue) {
      this.FDataType = $mod.TFieldType.ftDate;
      this.SetAsJSValue(AValue);
    };
    this.SetAsDateTime = function (AValue) {
      this.FDataType = $mod.TFieldType.ftDateTime;
      this.SetAsJSValue(AValue);
    };
    this.SetAsFloat = function (AValue) {
      this.FDataType = $mod.TFieldType.ftFloat;
      this.SetAsJSValue(AValue);
    };
    this.SetAsInteger = function (AValue) {
      this.FDataType = $mod.TFieldType.ftInteger;
      this.SetAsJSValue(AValue);
    };
    this.SetAsLargeInt = function (AValue) {
      this.FDataType = $mod.TFieldType.ftLargeint;
      this.SetAsJSValue(AValue);
    };
    this.SetAsMemo = function (AValue) {
      this.FDataType = $mod.TFieldType.ftMemo;
      this.SetAsJSValue(AValue);
    };
    this.SetAsString = function (AValue) {
      if (this.FDataType !== $mod.TFieldType.ftFixedChar) this.FDataType = $mod.TFieldType.ftString;
      this.SetAsJSValue(AValue);
    };
    this.SetAsTime = function (AValue) {
      this.FDataType = $mod.TFieldType.ftTime;
      this.SetAsJSValue(AValue);
    };
    this.SetAsJSValue = function (AValue) {
      this.FValue = AValue;
      this.FBound = !pas.JS.isNull(AValue);
      if (this.FBound) {
        var $tmp = pas.JS.GetValueType(AValue);
        if ($tmp === pas.JS.TJSValueType.jvtBoolean) {
          this.FDataType = $mod.TFieldType.ftBoolean}
         else if ($tmp === pas.JS.TJSValueType.jvtInteger) {
          this.FDataType = $mod.TFieldType.ftInteger}
         else if ($tmp === pas.JS.TJSValueType.jvtFloat) {
          this.FDataType = $mod.TFieldType.ftFloat}
         else if (($tmp === pas.JS.TJSValueType.jvtObject) || ($tmp === pas.JS.TJSValueType.jvtArray)) this.FDataType = $mod.TFieldType.ftBlob;
      };
    };
    this.SetDataType = function (AValue) {
      this.FDataType = AValue;
    };
    this.SetText = function (AValue) {
      this.SetAsJSValue(AValue);
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.call(this,ACollection);
      this.FParamType = $mod.TParamType.ptUnknown;
      this.SetDataType($mod.TFieldType.ftUnknown);
      this.FValue = null;
      return this;
    };
    this.Create$3 = function (AParams, AParamType) {
      this.Create$1(AParams);
      this.FParamType = AParamType;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TParam.isPrototypeOf(Source)) {
        this.AssignParam(Source)}
       else if ($mod.TField.isPrototypeOf(Source)) {
        this.AssignField(Source)}
       else if (pas.Classes.TStrings.isPrototypeOf(Source)) {
        this.SetAsMemo(Source.GetTextStr())}
       else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.AssignField = function (Field) {
      if (Field != null) {
        this.AssignFieldValue(Field,Field.GetAsJSValue());
        this.FName = Field.FFieldName;
      } else {
        this.Clear();
        this.FName = "";
      };
    };
    this.AssignToField = function (Field) {
      if (Field != null) {
        var $tmp = this.FDataType;
        if ($tmp === $mod.TFieldType.ftUnknown) {
          $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SUnknownParamFieldType"),pas.System.VarRecs(18,this.FName),this.GetDataSet())}
         else if (($tmp === $mod.TFieldType.ftInteger) || ($tmp === $mod.TFieldType.ftAutoInc)) {
          Field.SetAsInteger(this.GetAsInteger())}
         else if ($tmp === $mod.TFieldType.ftFloat) {
          Field.SetAsFloat(this.GetAsFloat())}
         else if ($tmp === $mod.TFieldType.ftBoolean) {
          Field.SetAsBoolean(this.GetAsBoolean())}
         else if (($tmp === $mod.TFieldType.ftBlob) || ($tmp === $mod.TFieldType.ftString) || ($tmp === $mod.TFieldType.ftWideString) || ($tmp === $mod.TFieldType.ftMemo) || ($tmp === $mod.TFieldType.ftFixedChar)) {
          Field.SetAsString(this.GetAsString())}
         else if (($tmp === $mod.TFieldType.ftTime) || ($tmp === $mod.TFieldType.ftDate) || ($tmp === $mod.TFieldType.ftDateTime)) Field.SetAsDateTime(this.GetAsDateTime());
      };
    };
    this.AssignFieldValue = function (Field, AValue) {
      if (Field != null) {
        if ((Field.FDataType === $mod.TFieldType.ftString) && Field.FFixedChar) {
          this.FDataType = $mod.TFieldType.ftFixedChar}
         else if ((Field.FDataType === $mod.TFieldType.ftMemo) && (Field.FSize > 255)) {
          this.FDataType = $mod.TFieldType.ftString}
         else this.FDataType = Field.FDataType;
        if (pas.JS.isNull(AValue)) {
          this.Clear()}
         else this.SetAsJSValue(AValue);
        this.FSize = Field.GetDataSize();
        this.FBound = true;
      };
    };
    this.AssignFromField = function (Field) {
      if (Field != null) {
        this.FDataType = Field.FDataType;
        var $tmp = Field.FDataType;
        if ($tmp === $mod.TFieldType.ftUnknown) {
          $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SUnknownParamFieldType"),pas.System.VarRecs(18,this.FName),this.GetDataSet())}
         else if (($tmp === $mod.TFieldType.ftInteger) || ($tmp === $mod.TFieldType.ftAutoInc)) {
          this.SetAsInteger(Field.GetAsInteger())}
         else if ($tmp === $mod.TFieldType.ftFloat) {
          this.SetAsFloat(Field.GetAsFloat())}
         else if ($tmp === $mod.TFieldType.ftBoolean) {
          this.SetAsBoolean(Field.GetAsBoolean())}
         else if (($tmp === $mod.TFieldType.ftBlob) || ($tmp === $mod.TFieldType.ftString) || ($tmp === $mod.TFieldType.ftWideString) || ($tmp === $mod.TFieldType.ftMemo) || ($tmp === $mod.TFieldType.ftFixedChar)) {
          this.SetAsString(Field.GetAsString())}
         else if (($tmp === $mod.TFieldType.ftTime) || ($tmp === $mod.TFieldType.ftDate) || ($tmp === $mod.TFieldType.ftDateTime)) this.SetAsDateTime(Field.GetAsDateTime());
      };
    };
    this.Clear = function () {
      this.FValue = null;
    };
    var $r = this.$rtti;
    $r.addProperty("DataType",2,$mod.$rtti["TFieldType"],"FDataType","SetDataType");
    $r.addProperty("Name",0,rtl.string,"FName","FName");
    $r.addProperty("NumericScale",0,rtl.longint,"FNumericScale","FNumericScale",4,{Default: 0});
    $r.addProperty("ParamType",0,$mod.$rtti["TParamType"],"FParamType","FParamType");
    $r.addProperty("Precision",0,rtl.longint,"FPrecision","FPrecision",4,{Default: 0});
    $r.addProperty("Size",0,rtl.longint,"FSize","FSize",4,{Default: 0});
    $r.addProperty("Value",15,rtl.jsvalue,"GetAsJSValue","SetAsJSValue",4,{stored: "IsParamStored"});
  });
  this.$rtti.$ClassRef("TParamClass",{instancetype: this.$rtti["TParam"]});
  rtl.createClass(this,"TParams",pas.Classes.TCollection,function () {
    this.$init = function () {
      pas.Classes.TCollection.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = rtl.as(pas.Classes.TCollection.GetItem.call(this,Index),$mod.TParam);
      return Result;
    };
    this.GetParamValue = function (ParamName) {
      var Result = undefined;
      Result = this.ParamByName(ParamName).GetAsJSValue();
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.SetParamValue = function (ParamName, Value) {
      this.ParamByName(ParamName).SetAsJSValue(Value);
    };
    this.AssignTo = function (Dest) {
      if ($mod.TParams.isPrototypeOf(Dest)) {
        Dest.Assign(this)}
       else pas.Classes.TPersistent.AssignTo.call(this,Dest);
    };
    this.GetDataSet = function () {
      var Result = null;
      if ($mod.TDataSet.isPrototypeOf(this.FOwner)) {
        Result = this.FOwner}
       else Result = null;
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.ParamClass = function () {
      var Result = null;
      Result = $mod.TParam;
      return Result;
    };
    this.Create$2 = function (AOwner, AItemClass) {
      pas.Classes.TCollection.Create$1.call(this,AItemClass);
      this.FOwner = AOwner;
      return this;
    };
    this.Create$3 = function (AOwner) {
      this.Create$2(AOwner,this.$class.ParamClass());
      return this;
    };
    this.Create$4 = function () {
      this.Create$3(null);
      return this;
    };
    this.AddParam = function (Value) {
      Value.SetCollection(this);
    };
    this.AssignValues = function (Value) {
      var I = 0;
      var P = null;
      var PS = null;
      for (var $l = 0, $end = Value.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        PS = Value.GetItem$1(I);
        P = this.FindParam(PS.FName);
        if (P != null) P.Assign(PS);
      };
    };
    this.CreateParam = function (FldType, ParamName, ParamType) {
      var Result = null;
      Result = rtl.as(this.Add$1(),$mod.TParam);
      Result.FName = ParamName;
      Result.SetDataType(FldType);
      Result.FParamType = ParamType;
      return Result;
    };
    this.FindParam = function (Value) {
      var Result = null;
      var I = 0;
      Result = null;
      I = this.GetCount() - 1;
      while ((Result === null) && (I >= 0)) if (pas.SysUtils.CompareText(Value,this.GetItem$1(I).FName) === 0) {
        Result = this.GetItem$1(I)}
       else I -= 1;
      return Result;
    };
    this.GetParamList = function (List, ParamNames) {
      var P = null;
      var N = "";
      var StrPos = 0;
      if ((ParamNames === "") || (List === null)) return;
      StrPos = 1;
      do {
        N = $mod.ExtractFieldName(ParamNames,{get: function () {
            return StrPos;
          }, set: function (v) {
            StrPos = v;
          }});
        P = this.ParamByName(N);
        List.Add(P);
      } while (!(StrPos > ParamNames.length));
    };
    this.IsEqual = function (Value) {
      var Result = false;
      var I = 0;
      Result = Value.GetCount() === this.GetCount();
      I = this.GetCount() - 1;
      while (Result && (I >= 0)) {
        Result = this.GetItem$1(I).IsEqual(Value.GetItem$1(I));
        I -= 1;
      };
      return Result;
    };
    this.ParamByName = function (Value) {
      var Result = null;
      Result = this.FindParam(Value);
      if (Result === null) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SParameterNotFound"),pas.System.VarRecs(18,Value),this.GetDataSet());
      return Result;
    };
    this.ParseSQL = function (SQL, DoCreate) {
      var Result = "";
      var pb = [];
      var rs = "";
      Result = this.ParseSQL$3(SQL,DoCreate,true,true,$mod.TParamStyle.psInterbase,{get: function () {
          return pb;
        }, set: function (v) {
          pb = v;
        }},{get: function () {
          return rs;
        }, set: function (v) {
          rs = v;
        }});
      return Result;
    };
    this.ParseSQL$1 = function (SQL, DoCreate, EscapeSlash, EscapeRepeat, ParameterStyle) {
      var Result = "";
      var pb = [];
      var rs = "";
      Result = this.ParseSQL$3(SQL,DoCreate,EscapeSlash,EscapeRepeat,ParameterStyle,{get: function () {
          return pb;
        }, set: function (v) {
          pb = v;
        }},{get: function () {
          return rs;
        }, set: function (v) {
          rs = v;
        }});
      return Result;
    };
    this.ParseSQL$2 = function (SQL, DoCreate, EscapeSlash, EscapeRepeat, ParameterStyle, ParamBinding) {
      var Result = "";
      var rs = "";
      Result = this.ParseSQL$3(SQL,DoCreate,EscapeSlash,EscapeRepeat,ParameterStyle,ParamBinding,{get: function () {
          return rs;
        }, set: function (v) {
          rs = v;
        }});
      return Result;
    };
    var TStringPart = rtl.recNewT(null,"",function () {
      this.Start = 0;
      this.Stop = 0;
      this.$eq = function (b) {
        return (this.Start === b.Start) && (this.Stop === b.Stop);
      };
      this.$assign = function (s) {
        this.Start = s.Start;
        this.Stop = s.Stop;
        return this;
      };
    });
    var ParamAllocStepSize = 8;
    var PAramDelimiters = [";",","," ","(",")","\r","\n","\t","\x00","=","+","-","*","\\","/","[","]","|"];
    this.ParseSQL$3 = function (SQL, DoCreate, EscapeSlash, EscapeRepeat, ParameterStyle, ParamBinding, ReplaceString) {
      var Result = "";
      var IgnorePart = false;
      var p = 0;
      var ParamNameStart = 0;
      var BufStart = 0;
      var ParamName = "";
      var QuestionMarkParamCount = 0;
      var ParameterIndex = 0;
      var NewLength = 0;
      var ParamCount = 0;
      var ParamPart = [];
      var NewQueryLength = 0;
      var NewQuery = "";
      var NewQueryIndex = 0;
      var BufIndex = 0;
      var CopyLen = 0;
      var i = 0;
      var tmpParam = null;
      if (DoCreate) this.Clear();
      ParamCount = 0;
      NewQueryLength = SQL.length;
      ParamPart = rtl.arraySetLength(ParamPart,TStringPart,8);
      ParamBinding.set(rtl.arraySetLength(ParamBinding.get(),0,8));
      QuestionMarkParamCount = 0;
      ReplaceString.set("$");
      if (ParameterStyle === $mod.TParamStyle.psSimulated) while (pas.System.Pos(ReplaceString.get(),SQL) > 0) ReplaceString.set(ReplaceString.get() + "$");
      p = 1;
      BufStart = p;
      do {
        while ($impl.SkipComments(SQL,{get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }},EscapeSlash,EscapeRepeat)) {
        };
        var $tmp = SQL.charAt(p - 1);
        if (($tmp === ":") || ($tmp === "?")) {
          IgnorePart = false;
          if (SQL.charAt(p - 1) === ":") {
            p += 1;
            if (pas.SysUtils.CharInSet(SQL.charAt(p - 1),[":","="," "])) {
              IgnorePart = true;
              p += 1;
            } else {
              if (SQL.charAt(p - 1) === '"') {
                ParamNameStart = p;
                $impl.SkipQuotesString(SQL,{get: function () {
                    return p;
                  }, set: function (v) {
                    p = v;
                  }},'"',EscapeSlash,EscapeRepeat);
                ParamName = pas.System.Copy(SQL,ParamNameStart + 1,p - ParamNameStart - 2);
              } else {
                ParamNameStart = p;
                while (!pas.SysUtils.CharInSet(SQL.charAt(p - 1),PAramDelimiters)) p += 1;
                ParamName = pas.System.Copy(SQL,ParamNameStart,p - ParamNameStart);
              };
            };
          } else {
            p += 1;
            ParamNameStart = p;
            ParamName = "";
          };
          if (!IgnorePart) {
            ParamCount += 1;
            if (ParamCount > rtl.length(ParamPart)) {
              NewLength = rtl.length(ParamPart) + 8;
              ParamPart = rtl.arraySetLength(ParamPart,TStringPart,NewLength);
              ParamBinding.set(rtl.arraySetLength(ParamBinding.get(),0,NewLength));
            };
            if (DoCreate) {
              tmpParam = this.FindParam(ParamName);
              if (!(tmpParam != null)) {
                ParameterIndex = this.CreateParam($mod.TFieldType.ftUnknown,ParamName,$mod.TParamType.ptInput).GetIndex()}
               else ParameterIndex = tmpParam.GetIndex();
            } else {
              if (ParamName !== "") {
                ParameterIndex = this.ParamByName(ParamName).GetIndex()}
               else {
                ParameterIndex = QuestionMarkParamCount;
                QuestionMarkParamCount += 1;
              };
            };
            if (ParameterStyle in rtl.createSet($mod.TParamStyle.psPostgreSQL,$mod.TParamStyle.psSimulated)) {
              i = ParameterIndex + 1;
              do {
                NewQueryLength += 1;
                i = rtl.trunc(i / 10);
              } while (!(i === 0));
            };
            ParamBinding.get()[ParamCount - 1] = ParameterIndex;
            ParamPart[ParamCount - 1].Start = ParamNameStart - BufStart;
            ParamPart[ParamCount - 1].Stop = (p - BufStart) + 1;
            NewQueryLength -= p - ParamNameStart;
          };
        } else if ($tmp === "\x00") {
          break}
         else {
          p += 1;
        };
      } while (!false);
      ParamPart = rtl.arraySetLength(ParamPart,TStringPart,ParamCount);
      ParamBinding.set(rtl.arraySetLength(ParamBinding.get(),0,ParamCount));
      if (ParamCount <= 0) {
        NewQuery = SQL}
       else {
        if ((ParameterStyle === $mod.TParamStyle.psSimulated) && (ReplaceString.get().length > 1)) NewQueryLength += ParamCount * (ReplaceString.get().length - 1);
        NewQuery = rtl.strSetLength(NewQuery,NewQueryLength);
        NewQueryIndex = 1;
        BufIndex = 1;
        for (var $l = 0, $end = rtl.length(ParamPart) - 1; $l <= $end; $l++) {
          i = $l;
          CopyLen = ParamPart[i].Start - BufIndex;
          NewQuery = NewQuery + pas.System.Copy(SQL,BufIndex,CopyLen);
          NewQueryIndex += CopyLen;
          var $tmp1 = ParameterStyle;
          if ($tmp1 === $mod.TParamStyle.psInterbase) {
            NewQuery = NewQuery + "?";
            NewQueryIndex += 1;
          } else if (($tmp1 === $mod.TParamStyle.psPostgreSQL) || ($tmp1 === $mod.TParamStyle.psSimulated)) {
            ParamName = pas.SysUtils.IntToStr(ParamBinding.get()[i] + 1);
            NewQuery = pas.System.StringOfChar("$",ReplaceString.get().length);
            NewQuery = NewQuery + ParamName;
          };
          BufIndex = ParamPart[i].Stop;
        };
        CopyLen = (SQL.length + 1) - BufIndex;
        if (CopyLen > 0) NewQuery = NewQuery + pas.System.Copy(SQL,BufIndex,CopyLen);
      };
      Result = NewQuery;
      return Result;
    };
    this.RemoveParam = function (Value) {
      Value.SetCollection(null);
    };
    this.CopyParamValuesFromDataset = function (ADataset, CopyBound) {
      var I = 0;
      var P = null;
      var F = null;
      if (ADataset != null) for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        P = this.GetItem$1(I);
        if (CopyBound || !P.FBound) {
          F = ADataset.FieldByName(P.FName);
          P.AssignField(F);
          if (!CopyBound) P.FBound = false;
        };
      };
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
  });
  this.TBookmarkFlag = {"0": "bfCurrent", bfCurrent: 0, "1": "bfBOF", bfBOF: 1, "2": "bfEOF", bfEOF: 2, "3": "bfInserted", bfInserted: 3};
  this.$rtti.$Enum("TBookmarkFlag",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBookmarkFlag});
  rtl.recNewT(this,"TBookmark",function () {
    this.Data = undefined;
    this.Flag = 0;
    this.$eq = function (b) {
      return (this.Data === b.Data) && (this.Flag === b.Flag);
    };
    this.$assign = function (s) {
      this.Data = s.Data;
      this.Flag = s.Flag;
      return this;
    };
    var $r = $mod.$rtti.$Record("TBookmark",{},this);
    $r.addField("Data",rtl.jsvalue);
    $r.addField("Flag",$mod.$rtti["TBookmarkFlag"]);
  });
  this.TGetMode = {"0": "gmCurrent", gmCurrent: 0, "1": "gmNext", gmNext: 1, "2": "gmPrior", gmPrior: 2};
  this.$rtti.$Enum("TGetMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TGetMode});
  this.TGetResult = {"0": "grOK", grOK: 0, "1": "grBOF", grBOF: 1, "2": "grEOF", grEOF: 2, "3": "grError", grError: 3};
  this.$rtti.$Enum("TGetResult",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TGetResult});
  this.TResyncMode$a = {"0": "rmExact", rmExact: 0, "1": "rmCenter", rmCenter: 1};
  this.$rtti.$Enum("TResyncMode$a",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TResyncMode$a});
  this.$rtti.$Set("TResyncMode",{comptype: this.$rtti["TResyncMode$a"]});
  this.TDataAction = {"0": "daFail", daFail: 0, "1": "daAbort", daAbort: 1, "2": "daRetry", daRetry: 2};
  this.$rtti.$Enum("TDataAction",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TDataAction});
  this.TUpdateAction = {"0": "uaFail", uaFail: 0, "1": "uaAbort", uaAbort: 1, "2": "uaSkip", uaSkip: 2, "3": "uaRetry", uaRetry: 3, "4": "uaApplied", uaApplied: 4};
  this.$rtti.$Enum("TUpdateAction",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TUpdateAction});
  this.TUpdateKind = {"0": "ukModify", ukModify: 0, "1": "ukInsert", ukInsert: 1, "2": "ukDelete", ukDelete: 2};
  this.$rtti.$Enum("TUpdateKind",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TUpdateKind});
  this.TLocateOption = {"0": "loCaseInsensitive", loCaseInsensitive: 0, "1": "loPartialKey", loPartialKey: 1, "2": "loFromCurrent", loFromCurrent: 2};
  this.$rtti.$Enum("TLocateOption",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TLocateOption});
  this.$rtti.$Set("TLocateOptions",{comptype: this.$rtti["TLocateOption"]});
  this.$rtti.$MethodVar("TDataOperation",{procsig: rtl.newTIProcSig([]), methodkind: 0});
  this.$rtti.$MethodVar("TDataSetNotifyEvent",{procsig: rtl.newTIProcSig([["DataSet",this.$rtti["TDataSet"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TDataSetErrorEvent",{procsig: rtl.newTIProcSig([["DataSet",this.$rtti["TDataSet"]],["E",this.$rtti["EDatabaseError"]],["DataAction",this.$rtti["TDataAction"],1]]), methodkind: 0});
  this.TFilterOption = {"0": "foCaseInsensitive", foCaseInsensitive: 0, "1": "foNoPartialCompare", foNoPartialCompare: 1};
  this.$rtti.$Enum("TFilterOption",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFilterOption});
  this.$rtti.$Set("TFilterOptions",{comptype: this.$rtti["TFilterOption"]});
  this.TLoadOption = {"0": "loNoOpen", loNoOpen: 0, "1": "loNoEvents", loNoEvents: 1, "2": "loAtEOF", loAtEOF: 2, "3": "loCancelPending", loCancelPending: 3};
  this.$rtti.$Enum("TLoadOption",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TLoadOption});
  this.$rtti.$Set("TLoadOptions",{comptype: this.$rtti["TLoadOption"]});
  this.$rtti.$MethodVar("TDatasetLoadEvent",{procsig: rtl.newTIProcSig([["DataSet",this.$rtti["TDataSet"]],["Data",rtl.jsvalue]]), methodkind: 0});
  this.$rtti.$MethodVar("TDatasetLoadFailEvent",{procsig: rtl.newTIProcSig([["DataSet",this.$rtti["TDataSet"]],["ID",rtl.longint],["ErrorMsg",rtl.string,2]]), methodkind: 0});
  this.$rtti.$MethodVar("TFilterRecordEvent",{procsig: rtl.newTIProcSig([["DataSet",this.$rtti["TDataSet"]],["Accept",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ClassRef("TDatasetClass",{instancetype: this.$rtti["TDataSet"]});
  this.TRecordState = {"0": "rsNew", rsNew: 0, "1": "rsClean", rsClean: 1, "2": "rsUpdate", rsUpdate: 2, "3": "rsDelete", rsDelete: 3};
  this.$rtti.$Enum("TRecordState",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TRecordState});
  rtl.recNewT(this,"TDataRecord",function () {
    this.data = undefined;
    this.state = 0;
    this.bookmark = undefined;
    this.bookmarkFlag = 0;
    this.$eq = function (b) {
      return (this.data === b.data) && (this.state === b.state) && (this.bookmark === b.bookmark) && (this.bookmarkFlag === b.bookmarkFlag);
    };
    this.$assign = function (s) {
      this.data = s.data;
      this.state = s.state;
      this.bookmark = s.bookmark;
      this.bookmarkFlag = s.bookmarkFlag;
      return this;
    };
    var $r = $mod.$rtti.$Record("TDataRecord",{},this);
    $r.addField("data",rtl.jsvalue);
    $r.addField("state",$mod.$rtti["TRecordState"]);
    $r.addField("bookmark",rtl.jsvalue);
    $r.addField("bookmarkFlag",$mod.$rtti["TBookmarkFlag"]);
  });
  this.$rtti.$DynArray("TBuffers",{eltype: this.$rtti["TDataRecord"]});
  rtl.recNewT(this,"TResolveInfo",function () {
    this.Data = undefined;
    this.Status = 0;
    this.ResolveStatus = 0;
    this.Error = "";
    this._private = undefined;
    this.$new = function () {
      var r = Object.create(this);
      r.BookMark = $mod.TBookmark.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.Data === b.Data) && (this.Status === b.Status) && (this.ResolveStatus === b.ResolveStatus) && (this.Error === b.Error) && this.BookMark.$eq(b.BookMark) && (this._private === b._private);
    };
    this.$assign = function (s) {
      this.Data = s.Data;
      this.Status = s.Status;
      this.ResolveStatus = s.ResolveStatus;
      this.Error = s.Error;
      this.BookMark.$assign(s.BookMark);
      this._private = s._private;
      return this;
    };
    var $r = $mod.$rtti.$Record("TResolveInfo",{},this);
    $r.addField("Data",rtl.jsvalue);
    $r.addField("Status",$mod.$rtti["TUpdateStatus"]);
    $r.addField("ResolveStatus",$mod.$rtti["TResolveStatus"]);
    $r.addField("Error",rtl.string);
    $r.addField("BookMark",$mod.$rtti["TBookmark"]);
    $r.addField("_private",rtl.jsvalue);
  });
  this.$rtti.$DynArray("TResolveInfoArray",{eltype: this.$rtti["TResolveInfo"]});
  rtl.recNewT(this,"TResolveResults",function () {
    this.$new = function () {
      var r = Object.create(this);
      r.Records = [];
      return r;
    };
    this.$eq = function (b) {
      return this.Records === b.Records;
    };
    this.$assign = function (s) {
      this.Records = rtl.arrayRef(s.Records);
      return this;
    };
    var $r = $mod.$rtti.$Record("TResolveResults",{},this);
    $r.addField("Records",$mod.$rtti["TResolveInfoArray"]);
  });
  this.$rtti.$MethodVar("TOnRecordResolveEvent",{procsig: rtl.newTIProcSig([["Sender",this.$rtti["TDataSet"]],["info",this.$rtti["TResolveInfo"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplyUpdatesEvent",{procsig: rtl.newTIProcSig([["Sender",this.$rtti["TDataSet"]],["info",this.$rtti["TResolveResults"]]]), methodkind: 0});
  rtl.createClass(this,"TDataSet",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FAfterApplyUpdates = null;
      this.FAfterLoad = null;
      this.FBeforeApplyUpdates = null;
      this.FBeforeLoad = null;
      this.FBlockReadSize = 0;
      this.FCalcBuffer = $mod.TDataRecord.$new();
      this.FCalcFieldsCount = 0;
      this.FOnLoadFail = null;
      this.FOnRecordResolved = null;
      this.FOpenAfterRead = false;
      this.FActiveRecord = 0;
      this.FAfterCancel = null;
      this.FAfterClose = null;
      this.FAfterDelete = null;
      this.FAfterEdit = null;
      this.FAfterInsert = null;
      this.FAfterOpen = null;
      this.FAfterPost = null;
      this.FAfterRefresh = null;
      this.FAfterScroll = null;
      this.FAutoCalcFields = false;
      this.FBOF = false;
      this.FBeforeCancel = null;
      this.FBeforeClose = null;
      this.FBeforeDelete = null;
      this.FBeforeEdit = null;
      this.FBeforeInsert = null;
      this.FBeforeOpen = null;
      this.FBeforePost = null;
      this.FBeforeRefresh = null;
      this.FBeforeScroll = null;
      this.FBlobFieldCount = 0;
      this.FBuffers = [];
      this.FBufferCount = 0;
      this.FConstraints = null;
      this.FDisableControlsCount = 0;
      this.FDisableControlsState = 0;
      this.FCurrentRecord = 0;
      this.FDataSources = null;
      this.FDefaultFields = false;
      this.FEOF = false;
      this.FEnableControlsEvent = 0;
      this.FFieldList = null;
      this.FFieldDefs = null;
      this.FFilterOptions = {};
      this.FFilterText = "";
      this.FFiltered = false;
      this.FFound = false;
      this.FInternalCalcFields = false;
      this.FModified = false;
      this.FOnCalcFields = null;
      this.FOnDeleteError = null;
      this.FOnEditError = null;
      this.FOnFilterRecord = null;
      this.FOnNewRecord = null;
      this.FOnPostError = null;
      this.FRecordCount = 0;
      this.FIsUniDirectional = false;
      this.FState = 0;
      this.FInternalOpenComplete = false;
      this.FDataProxy = null;
      this.FDataRequestID = 0;
      this.FUpdateBatchID = 0;
      this.FChangeList = null;
      this.FBatchList = null;
      this.FInApplyupdates = false;
      this.FLoadCount = 0;
      this.FMinLoadID = 0;
      this.FDataSetField = null;
      this.FNestedDataSets = null;
      this.FNestedDataSetClass = null;
    };
    this.$final = function () {
      this.FAfterApplyUpdates = undefined;
      this.FAfterLoad = undefined;
      this.FBeforeApplyUpdates = undefined;
      this.FBeforeLoad = undefined;
      this.FCalcBuffer = undefined;
      this.FOnLoadFail = undefined;
      this.FOnRecordResolved = undefined;
      this.FAfterCancel = undefined;
      this.FAfterClose = undefined;
      this.FAfterDelete = undefined;
      this.FAfterEdit = undefined;
      this.FAfterInsert = undefined;
      this.FAfterOpen = undefined;
      this.FAfterPost = undefined;
      this.FAfterRefresh = undefined;
      this.FAfterScroll = undefined;
      this.FBeforeCancel = undefined;
      this.FBeforeClose = undefined;
      this.FBeforeDelete = undefined;
      this.FBeforeEdit = undefined;
      this.FBeforeInsert = undefined;
      this.FBeforeOpen = undefined;
      this.FBeforePost = undefined;
      this.FBeforeRefresh = undefined;
      this.FBeforeScroll = undefined;
      this.FBuffers = undefined;
      this.FConstraints = undefined;
      this.FDataSources = undefined;
      this.FFieldList = undefined;
      this.FFieldDefs = undefined;
      this.FFilterOptions = undefined;
      this.FOnCalcFields = undefined;
      this.FOnDeleteError = undefined;
      this.FOnEditError = undefined;
      this.FOnFilterRecord = undefined;
      this.FOnNewRecord = undefined;
      this.FOnPostError = undefined;
      this.FDataProxy = undefined;
      this.FChangeList = undefined;
      this.FBatchList = undefined;
      this.FDataSetField = undefined;
      this.FNestedDataSets = undefined;
      this.FNestedDataSetClass = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.DoInsertAppend = function (DoAppend) {
      var $Self = this;
      function DoInsert(DoAppend) {
        var BookBeforeInsert = $mod.TBookmark.$new();
        var TempBuf = $mod.TDataRecord.$new();
        var I = 0;
        if ($Self.FRecordCount > 0) BookBeforeInsert.$assign($Self.GetBookmark());
        if (!DoAppend) {
          if ($Self.FRecordCount > 0) {
            TempBuf.$assign($Self.FBuffers[$Self.FBufferCount]);
            for (var $l = $Self.FBufferCount, $end = $Self.FActiveRecord + 1; $l >= $end; $l--) {
              I = $l;
              $Self.FBuffers[I].$assign($Self.FBuffers[I - 1]);
            };
            $Self.FBuffers[$Self.FActiveRecord].$assign(TempBuf);
          };
        } else if ($Self.FRecordCount === $Self.FBufferCount) {
          $Self.ShiftBuffersBackward()}
         else {
          if ($Self.FRecordCount > 0) $Self.FActiveRecord += 1;
        };
        $Self.InitRecord($Self.FBuffers[$Self.FActiveRecord]);
        $Self.CursorPosChanged();
        if ($Self.FRecordCount === 0) {
          $Self.SetBookmarkFlag($Self.FBuffers[$Self.FActiveRecord],$mod.TBookmarkFlag.bfEOF)}
         else {
          $Self.FBOF = false;
          if ($Self.FRecordCount > 0) {
            $Self.SetBookmarkData($Self.FBuffers[$Self.FActiveRecord],$mod.TBookmark.$clone(BookBeforeInsert));
            $Self.FreeBookmark($mod.TBookmark.$clone(BookBeforeInsert));
          };
        };
        $Self.InternalInsert();
        if ($Self.FRecordCount < $Self.FBufferCount) $Self.FRecordCount += 1;
      };
      this.CheckBrowseMode();
      if (!this.GetCanModify()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SDatasetReadOnly"),$Self);
      this.DoBeforeInsert();
      this.DoBeforeScroll();
      if (!DoAppend) {
        DoInsert(false);
      } else {
        this.ClearBuffers();
        this.InternalLast();
        this.GetPriorRecords();
        if (this.FRecordCount > 0) this.FActiveRecord = this.FRecordCount - 1;
        DoInsert(true);
        this.SetBookmarkFlag(this.FBuffers[this.FActiveRecord],$mod.TBookmarkFlag.bfEOF);
        this.FBOF = false;
        this.FEOF = true;
      };
      this.SetState($mod.TDataSetState.dsInsert);
      try {
        this.DoOnNewRecord();
      } catch ($e) {
        this.SetCurrentRecord(this.FActiveRecord);
        this.Resync({});
        throw $e;
      };
      this.FModified = false;
      this.DataEvent($mod.TDataEvent.deDataSetChange,0);
      this.DoAfterInsert();
      this.DoAfterScroll();
    };
    this.DoInternalOpen = function () {
      this.InternalOpen();
      this.FInternalOpenComplete = true;
      this.FRecordCount = 0;
      this.RecalcBufListSize();
      this.FBOF = true;
      this.FEOF = this.FRecordCount === 0;
      this.InitChangeList();
    };
    this.GetBuffer = function (Index) {
      var Result = $mod.TDataRecord.$new();
      Result.$assign(this.FBuffers[Index]);
      return Result;
    };
    this.GetDataProxy = function () {
      var Result = null;
      if (this.FDataProxy === null) this.SetDataProxy(this.DoGetDataProxy());
      Result = this.FDataProxy;
      return Result;
    };
    this.GetIsLoading = function () {
      var Result = false;
      Result = this.FLoadCount > 0;
      return Result;
    };
    this.RegisterDataSource = function (ADataSource) {
      this.FDataSources.Add(ADataSource);
      this.RecalcBufListSize();
    };
    this.SetConstraints = function (Value) {
      this.FConstraints.Assign(Value);
    };
    this.SetDataProxy = function (AValue) {
      if (AValue === this.FDataProxy) return;
      if (this.FDataProxy != null) this.FDataProxy.RemoveFreeNotification(this);
      this.FDataProxy = AValue;
      if (this.FDataProxy != null) this.FDataProxy.FreeNotification(this);
    };
    this.ShiftBuffersForward = function () {
      var TempBuf = $mod.TDataRecord.$new();
      var I = 0;
      TempBuf.$assign(this.FBuffers[this.FBufferCount]);
      for (var $l = this.FBufferCount; $l >= 1; $l--) {
        I = $l;
        this.FBuffers[I].$assign(this.FBuffers[I - 1]);
      };
      this.FBuffers[0].$assign(TempBuf);
    };
    this.ShiftBuffersBackward = function () {
      var TempBuf = $mod.TDataRecord.$new();
      var I = 0;
      TempBuf.$assign(this.FBuffers[0]);
      for (var $l = 1, $end = this.FBufferCount; $l <= $end; $l++) {
        I = $l;
        this.FBuffers[I - 1].$assign(this.FBuffers[I]);
      };
      this.FBuffers[this.FBufferCount].$assign(TempBuf);
    };
    this.TryDoing = function (P, Ev) {
      var Result = false;
      var Retry = 0;
      Result = true;
      Retry = $mod.TDataAction.daRetry;
      while (Retry === $mod.TDataAction.daRetry) try {
        this.UpdateCursorPos();
        P();
        return Result;
      } catch ($e) {
        if ($mod.EDatabaseError.isPrototypeOf($e)) {
          var E = $e;
          Retry = $mod.TDataAction.daFail;
          if (Ev != null) Ev(this,E,{get: function () {
              return Retry;
            }, set: function (v) {
              Retry = v;
            }});
          var $tmp = Retry;
          if ($tmp === $mod.TDataAction.daFail) {
            throw $e}
           else if ($tmp === $mod.TDataAction.daAbort) pas.SysUtils.Abort();
        } else {
          throw $e;
        }
      };
      return Result;
    };
    this.GetActive = function () {
      var Result = false;
      Result = (this.FState !== $mod.TDataSetState.dsInactive) && (this.FState !== $mod.TDataSetState.dsOpening);
      return Result;
    };
    this.UnRegisterDataSource = function (ADataSource) {
      this.FDataSources.Remove(ADataSource);
    };
    this.SetBlockReadSize = function (AValue) {
      this.FBlockReadSize = AValue;
      if (AValue > 0) {
        this.CheckActive();
        this.SetState($mod.TDataSetState.dsBlockRead);
      } else {
        if (this.FState === $mod.TDataSetState.dsBlockRead) this.SetState($mod.TDataSetState.dsBrowse);
      };
    };
    this.SetFieldDefs = function (AFieldDefs) {
      this.FFieldList.ClearFieldDefs();
      this.FFieldDefs.Assign$2(AFieldDefs);
    };
    this.DoInsertAppendRecord = function (Values, DoAppend) {
      var i = 0;
      var ValuesSize = 0;
      ValuesSize = rtl.length(Values);
      if (ValuesSize > this.GetfieldCount()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"STooManyFields"),this);
      if (DoAppend) {
        this.Append()}
       else this.Insert$1();
      for (var $l = 0, $end = ValuesSize - 1; $l <= $end; $l++) {
        i = $l;
        this.FFieldList.GetField(i).AssignValue(Values[i]);
      };
      this.Post();
    };
    this.ResolveRecordUpdate = function (anUpdate) {
      var Result = false;
      try {
        Result = this.DoResolveRecordUpdate(anUpdate);
        if (!Result) anUpdate.SetResolveStatus($mod.TResolveStatus.rsResolveFailed);
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
          anUpdate.ResolveFailed(E.$classname + ": " + E.FMessage);
          Result = false;
        } else throw $e
      };
      this.DoOnRecordResolved(anUpdate);
      return Result;
    };
    this.HandleRequestResponse = function (ARequest) {
      var DataAdded = false;
      if (!(ARequest != null)) return;
      if (ARequest.FRequestID <= this.FMinLoadID) {
        ARequest.$destroy("Destroy");
        return;
      };
      this.FLoadCount -= 1;
      var $tmp = ARequest.FSuccess;
      if ($tmp === $mod.TDataRequestResult.rrFail) {
        if (this.FOnLoadFail != null) this.FOnLoadFail(this,ARequest.FRequestID,ARequest.FErrorMsg);
      } else if (($tmp === $mod.TDataRequestResult.rrEOF) || ($tmp === $mod.TDataRequestResult.rrOK)) {
        DataAdded = false;
        if (ARequest.FEvent != null) ARequest.FEvent(this,ARequest.FData);
        if (ARequest.FSuccess !== $mod.TDataRequestResult.rrEOF) DataAdded = this.DataPacketReceived(ARequest);
        if (!(this.GetActive() || ($mod.TLoadOption.loNoOpen in ARequest.FLoadOptions))) {
          if (!($mod.TLoadOption.loNoEvents in ARequest.FLoadOptions)) this.DoAfterLoad();
          this.Open();
        } else {
          if (($mod.TLoadOption.loAtEOF in ARequest.FLoadOptions) && DataAdded) this.FEOF = false;
          if (!($mod.TLoadOption.loNoEvents in ARequest.FLoadOptions)) this.DoAfterLoad();
        };
      };
      ARequest.$destroy("Destroy");
    };
    this.GetNestedDataSets = function () {
      var Result = null;
      if (!(this.FNestedDataSets != null)) this.FNestedDataSets = pas.Classes.TFPList.$create("Create");
      Result = this.FNestedDataSets;
      return Result;
    };
    this.DoOnRecordResolved = function (anUpdate) {
      var Info = $mod.TResolveInfo.$new();
      if (!(this.FOnRecordResolved != null)) return;
      Info.$assign(this.RecordUpdateDescriptorToResolveInfo(anUpdate));
      this.FOnRecordResolved(this,$mod.TResolveInfo.$clone(Info));
    };
    this.RecordUpdateDescriptorToResolveInfo = function (anUpdate) {
      var Result = $mod.TResolveInfo.$new();
      Result.BookMark.$assign(anUpdate.FBookmark);
      Result.Data = anUpdate.FData;
      Result.Status = anUpdate.FStatus;
      Result.ResolveStatus = anUpdate.FResolveStatus;
      Result.Error = anUpdate.FResolveError;
      return Result;
    };
    this.DoResolveRecordUpdate = function (anUpdate) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetRecordUpdates = function (AList) {
      var Result = 0;
      var I = 0;
      var MinIndex = 0;
      MinIndex = 0;
      for (var $l = MinIndex, $end = this.FChangeList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        if (rtl.getObject(this.FChangeList.Get(I)).FResolveStatus === $mod.TResolveStatus.rsUnresolved) AList.Add(this.FChangeList.Get(I));
      };
      Result = this.FChangeList.FCount;
      return Result;
    };
    this.ResolveUpdateBatch = function (Sender, aBatch) {
      var BI = 0;
      var RI = 0;
      var Idx = 0;
      var RUD = null;
      var doRemove = false;
      var Results = $mod.TResolveResults.$new();
      if ((this.FBatchList != null) && (aBatch.FDataset === this)) {
        BI = this.FBatchList.IndexOf(aBatch)}
       else BI = -1;
      if (BI === -1) return;
      this.FBatchList.Delete(BI);
      Results.Records = rtl.arraySetLength(Results.Records,$mod.TResolveInfo,aBatch.FList.FCount);
      for (var $l = 0, $end = aBatch.FList.FCount - 1; $l <= $end; $l++) {
        RI = $l;
        RUD = aBatch.FList.GetUpdate(RI);
        Results.Records[RI].$assign(this.RecordUpdateDescriptorToResolveInfo(RUD));
        aBatch.FList.Put(RI,null);
        Idx = this.IndexInChangeList($mod.TBookmark.$clone(RUD.FBookmark));
        if (Idx !== -1) {
          doRemove = false;
          if (RUD.FResolveStatus === $mod.TResolveStatus.rsResolved) {
            doRemove = this.ResolveRecordUpdate(RUD)}
           else doRemove = RUD.FResolveStatus === $mod.TResolveStatus.rsResolved;
          if (doRemove) {
            RUD = rtl.freeLoc(RUD);
            this.FChangeList.Delete(Idx);
          } else RUD.Reset();
        };
      };
      if (this.FBatchList.FCount === 0) pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FBatchList;
        }, set: function (v) {
          this.p.FBatchList = v;
        }});
      this.DoAfterApplyUpdates(Results);
    };
    this.DataPacketReceived = function (ARequest) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.DoLoad = function (aOptions, aAfterLoad) {
      var Result = false;
      var Request = null;
      if (!($mod.TLoadOption.loNoEvents in aOptions)) this.DoBeforeLoad();
      Result = this.GetDataProxy() !== null;
      if (!Result) return Result;
      Request = this.GetDataProxy().GetDataRequest(rtl.refSet(aOptions),rtl.createCallback(this,"HandleRequestResponse"),aAfterLoad);
      Request.FDataset = this;
      if (this.GetActive()) Request.FBookmark.$assign(this.GetBookmark());
      this.FDataRequestID += 1;
      Request.FRequestID = this.FDataRequestID;
      if (this.GetDataProxy().DoGetData(Request)) {
        this.FLoadCount += 1}
       else Request = rtl.freeLoc(Request);
      return Result;
    };
    this.DoGetDataProxy = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.InitChangeList = function () {
      this.DoneChangeList();
      this.FChangeList = pas.Classes.TFPList.$create("Create");
    };
    this.DoneChangeList = function () {
      this.ClearChangeList();
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FChangeList;
        }, set: function (v) {
          this.p.FChangeList = v;
        }});
    };
    this.ClearChangeList = function () {
      var I = 0;
      if (!(this.FChangeList != null)) return;
      for (var $l = 0, $end = this.FChangeList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        rtl.getObject(this.FChangeList.Get(I)).$destroy("Destroy");
        this.FChangeList.Put(I,null);
      };
    };
    this.ResetUpdateDescriptors = function () {
      var I = 0;
      for (var $l = 0, $end = this.FChangeList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        rtl.getObject(this.FChangeList.Get(I)).Reset();
      };
    };
    this.GetApplyUpdateData = function (aBuffer) {
      var Result = undefined;
      Result = aBuffer.data;
      return Result;
    };
    this.IndexInChangeList = function (aBookmark) {
      var Result = 0;
      Result = -1;
      if (!(this.FChangeList != null)) return Result;
      Result = this.FChangeList.FCount - 1;
      while ((Result >= 0) && (this.CompareBookmarks($mod.TBookmark.$clone(aBookmark),$mod.TBookmark.$clone(rtl.getObject(this.FChangeList.Get(Result)).FBookmark)) !== 0)) Result -= 1;
      return Result;
    };
    this.AddToChangeList = function (aChange) {
      var Result = null;
      var B = $mod.TBookmark.$new();
      var I = 0;
      var aData = undefined;
      Result = null;
      if (!(this.FChangeList != null)) return Result;
      B.$assign(this.GetBookmark());
      I = this.IndexInChangeList($mod.TBookmark.$clone(B));
      if (I === -1) {
        aData = this.GetApplyUpdateData($mod.TDataRecord.$clone(this.ActiveBuffer()));
        if (this.GetDataProxy() != null) {
          Result = this.GetDataProxy().GetUpdateDescriptor(this,$mod.TBookmark.$clone(B),aData,aChange)}
         else Result = $mod.TRecordUpdateDescriptor.$create("Create$1",[null,this,$mod.TBookmark.$clone(B),aData,aChange]);
        this.FChangeList.Add(Result);
      } else {
        Result = rtl.getObject(this.FChangeList.Get(I));
        var $tmp = aChange;
        if ($tmp === $mod.TUpdateStatus.usDeleted) {
          if (Result.FStatus === $mod.TUpdateStatus.usInserted) {
            this.FChangeList.Delete(I)}
           else Result.FStatus = $mod.TUpdateStatus.usDeleted;
        } else if ($tmp === $mod.TUpdateStatus.usInserted) {
          $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SErrInsertingSameRecordtwice"),this)}
         else if ($tmp === $mod.TUpdateStatus.usModified) Result.FData = this.GetApplyUpdateData($mod.TDataRecord.$clone(this.ActiveBuffer()));
      };
      return Result;
    };
    this.RemoveFromChangeList = function (R) {
      if (!((R != null) && (this.FChangeList != null))) return;
    };
    this.DoApplyUpdates = function () {
      var B = null;
      var l = null;
      var I = 0;
      if (!(this.GetDataProxy() != null)) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SErrDoApplyUpdatesNeedsProxy"),this);
      if (this.FInApplyupdates) return;
      try {
        this.FInApplyupdates = true;
        if (!((this.FChangeList != null) && (this.FChangeList.FCount > 0))) return;
        l = $mod.TRecordUpdateDescriptorList.$create("Create");
        try {
          I = this.GetRecordUpdates(l);
        } catch ($e) {
          l = rtl.freeLoc(l);
          throw $e;
        };
        this.FUpdateBatchID += 1;
        for (var $l = 0, $end = l.FCount - 1; $l <= $end; $l++) {
          I = $l;
          l.GetUpdate(I).SetResolveStatus($mod.TResolveStatus.rsResolving);
        };
        B = this.GetDataProxy().GetRecordUpdateBatch(this.FUpdateBatchID,l,true);
        B.FDataset = this;
        B.FLastChangeIndex = I;
        B.FOnResolve = rtl.createCallback(this,"ResolveUpdateBatch");
        if (!(this.FBatchList != null)) this.FBatchList = pas.Classes.TFPList.$create("Create");
        this.FBatchList.Add(B);
        this.GetDataProxy().ProcessUpdateBatch(B);
      } finally {
        this.FInApplyupdates = false;
      };
    };
    this.RecalcBufListSize = function () {
      var i = 0;
      var j = 0;
      var ABufferCount = 0;
      var DataLink = null;
      if (!this.IsCursorOpen()) return;
      if (this.FIsUniDirectional) {
        ABufferCount = 1}
       else ABufferCount = 10;
      for (var $l = 0, $end = this.FDataSources.FCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = rtl.getObject(this.FDataSources.Get(i)).FDataLinks.GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          DataLink = rtl.getObject(rtl.getObject(this.FDataSources.Get(i)).FDataLinks.Get(j));
          if (ABufferCount < DataLink.GetBufferCount()) ABufferCount = DataLink.GetBufferCount();
        };
      };
      if (this.FBufferCount === ABufferCount) return;
      this.SetBufListSize(ABufferCount);
      this.GetNextRecords();
      if ((this.FRecordCount < this.FBufferCount) && !this.FIsUniDirectional) {
        this.FActiveRecord = this.FActiveRecord + this.GetPriorRecords();
        this.CursorPosChanged();
      };
    };
    this.ActivateBuffers = function () {
      this.FBOF = false;
      this.FEOF = false;
      this.FActiveRecord = 0;
    };
    this.BindFields = function (Binding) {
      var i = 0;
      var FieldIndex = 0;
      var FieldDef = null;
      var Field = null;
      this.FCalcFieldsCount = 0;
      this.FBlobFieldCount = 0;
      for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        Field = this.FFieldList.GetField(i);
        Field.FFieldDef = null;
        if (!Binding) {
          Field.FFieldNo = 0}
         else if (Field.FFieldKind in rtl.createSet($mod.TFieldKind.fkCalculated,$mod.TFieldKind.fkLookup)) {
          Field.FFieldNo = -1;
          this.FCalcFieldsCount += 1;
        } else {
          FieldIndex = this.FFieldDefs.IndexOf(Field.FFieldName);
          if (FieldIndex === -1) {
            $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SFieldNotFound"),pas.System.VarRecs(18,Field.FFieldName),this)}
           else {
            FieldDef = this.FFieldDefs.GetItem$1(FieldIndex);
            Field.FFieldDef = FieldDef;
            Field.FFieldNo = FieldDef.FFieldNo;
            if (FieldDef.FInternalCalcField) this.FInternalCalcFields = true;
            if (Field.$class.IsBlob()) {
              Field.FSize = FieldDef.FSize;
              this.FBlobFieldCount += 1;
            };
          };
        };
        Field.Bind(Binding);
      };
    };
    this.BlockReadNext = function () {
      this.MoveBy(1);
    };
    var BookmarkStates = rtl.createSet($mod.TDataSetState.dsBrowse,$mod.TDataSetState.dsEdit,$mod.TDataSetState.dsInsert);
    this.BookmarkAvailable = function () {
      var Result = false;
      Result = !this.IsEmpty() && !this.FIsUniDirectional && (this.FState in BookmarkStates) && (this.GetBookmarkFlag($mod.TDataRecord.$clone(this.ActiveBuffer())) === $mod.TBookmarkFlag.bfCurrent);
      return Result;
    };
    this.CalculateFields = function (Buffer) {
      var i = 0;
      this.FCalcBuffer.$assign(Buffer);
      if (this.FState !== $mod.TDataSetState.dsInternalCalc) {
        this.ClearCalcFields(this.FCalcBuffer);
        if (!this.FIsUniDirectional) for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.FFieldList.GetField(i).FFieldKind === $mod.TFieldKind.fkLookup) this.FFieldList.GetField(i).CalcLookupValue();
        };
      };
      this.DoOnCalcFields();
    };
    this.CheckActive = function () {
      if (!this.GetActive()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SInactiveDataset"),this);
    };
    this.CheckInactive = function () {
      if (this.GetActive()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SActiveDataset"),this);
    };
    this.CheckBiDirectional = function () {
      if (this.FIsUniDirectional) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SUniDirectional"),this);
    };
    this.Loaded = function () {
      pas.Classes.TComponent.Loaded.call(this);
      try {
        if (this.FOpenAfterRead) this.SetActive(true);
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.InternalHandleException(E);
        } else {
          throw $e;
        }
      };
    };
    this.ClearBuffers = function () {
      this.FRecordCount = 0;
      this.FActiveRecord = 0;
      this.FCurrentRecord = -1;
      this.FBOF = true;
      this.FEOF = true;
    };
    this.ClearCalcFields = function (Buffer) {
    };
    this.CloseBlob = function (Field) {
    };
    this.CloseCursor = function () {
      this.ClearBuffers();
      this.SetBufListSize(1);
      this.FFieldList.ClearFieldDefs();
      this.InternalClose();
      this.FInternalOpenComplete = false;
    };
    this.CreateFields = function () {
      var I = 0;
      for (var $l = 0, $end = this.FFieldDefs.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FFieldDefs.GetItem$1(I).FDataType !== $mod.TFieldType.ftUnknown) {
          this.FFieldDefs.GetItem$1(I).CreateField(this);
        };
      };
    };
    this.DataEvent = function (Event, Info) {
      var $Self = this;
      function HandleFieldChange(aField) {
        if (aField.FFieldKind in rtl.createSet($mod.TFieldKind.fkData,$mod.TFieldKind.fkInternalCalc)) $Self.SetModified(true);
        if ($Self.FState !== $mod.TDataSetState.dsSetKey) {
          if (aField.FFieldKind === $mod.TFieldKind.fkData) {
            if ($Self.FInternalCalcFields) {
              $Self.RefreshInternalCalcFields($Self.FBuffers[$Self.FActiveRecord])}
             else if ($Self.FAutoCalcFields && ($Self.FCalcFieldsCount !== 0)) $Self.CalculateFields($Self.FBuffers[$Self.FActiveRecord]);
          };
          aField.Change();
        };
      };
      function HandleScrollOrChange() {
        var A = 0;
        var NestedDataSet = null;
        if ($Self.FState !== $mod.TDataSetState.dsInsert) $Self.UpdateCursorPos();
        if ($Self.FNestedDataSets != null) for (var $l = 0, $end = $Self.GetNestedDataSets().FCount - 1; $l <= $end; $l++) {
          A = $l;
          NestedDataSet = rtl.getObject($Self.GetNestedDataSets().Get(A));
          if (NestedDataSet.GetActive()) NestedDataSet.DataEvent($mod.TDataEvent.deParentScroll,0);
        };
      };
      var i = 0;
      var $tmp = Event;
      if ($tmp === $mod.TDataEvent.deFieldChange) {
        HandleFieldChange(rtl.getObject(Info))}
       else if (($tmp === $mod.TDataEvent.deDataSetChange) || ($tmp === $mod.TDataEvent.deDataSetScroll)) {
        HandleScrollOrChange()}
       else if ($tmp === $mod.TDataEvent.deLayoutChange) this.FEnableControlsEvent = $mod.TDataEvent.deLayoutChange;
      if (!this.ControlsDisabled() && (this.FState !== $mod.TDataSetState.dsBlockRead)) {
        for (var $l = 0, $end = this.FDataSources.FCount - 1; $l <= $end; $l++) {
          i = $l;
          rtl.getObject(this.FDataSources.Get(i)).ProcessEvent(Event,Info);
        };
      };
    };
    this.DestroyFields = function () {
      this.FFieldList.Clear();
    };
    this.DoAfterCancel = function () {
      if (this.FAfterCancel != null) this.FAfterCancel(this);
    };
    this.DoAfterClose = function () {
      if ((this.FAfterClose != null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.FAfterClose(this);
    };
    this.DoAfterDelete = function () {
      if (this.FAfterDelete != null) this.FAfterDelete(this);
    };
    this.DoAfterEdit = function () {
      if (this.FAfterEdit != null) this.FAfterEdit(this);
    };
    this.DoAfterInsert = function () {
      if (this.FAfterInsert != null) this.FAfterInsert(this);
    };
    this.DoAfterOpen = function () {
      if (this.FAfterOpen != null) this.FAfterOpen(this);
    };
    this.DoAfterPost = function () {
      if (this.FAfterPost != null) this.FAfterPost(this);
    };
    this.DoAfterScroll = function () {
      if (this.FAfterScroll != null) this.FAfterScroll(this);
    };
    this.DoAfterRefresh = function () {
      if (this.FAfterRefresh != null) this.FAfterRefresh(this);
    };
    this.DoBeforeCancel = function () {
      if (this.FBeforeCancel != null) this.FBeforeCancel(this);
    };
    this.DoBeforeClose = function () {
      if ((this.FBeforeClose != null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.FBeforeClose(this);
    };
    this.DoBeforeDelete = function () {
      if (this.FBeforeDelete != null) this.FBeforeDelete(this);
    };
    this.DoBeforeEdit = function () {
      if (this.FBeforeEdit != null) this.FBeforeEdit(this);
    };
    this.DoBeforeInsert = function () {
      if (this.FBeforeInsert != null) this.FBeforeInsert(this);
    };
    this.DoBeforeOpen = function () {
      if (this.FBeforeOpen != null) this.FBeforeOpen(this);
    };
    this.DoBeforePost = function () {
      if (this.FBeforePost != null) this.FBeforePost(this);
    };
    this.DoBeforeScroll = function () {
      if (this.FBeforeScroll != null) this.FBeforeScroll(this);
    };
    this.DoBeforeRefresh = function () {
      if (this.FBeforeRefresh != null) this.FBeforeRefresh(this);
    };
    this.DoOnCalcFields = function () {
      if (this.FOnCalcFields != null) this.FOnCalcFields(this);
    };
    this.DoOnNewRecord = function () {
      if (this.FOnNewRecord != null) this.FOnNewRecord(this);
    };
    this.DoBeforeLoad = function () {
      if (this.FBeforeLoad != null) this.FBeforeLoad(this);
    };
    this.DoAfterLoad = function () {
      if (this.FAfterLoad != null) this.FAfterLoad(this);
    };
    this.DoBeforeApplyUpdates = function () {
      if (this.FBeforeApplyUpdates != null) this.FBeforeApplyUpdates(this);
    };
    this.DoAfterApplyUpdates = function (ResolveInfo) {
      if (this.FAfterApplyUpdates != null) this.FAfterApplyUpdates(this,$mod.TResolveResults.$clone(ResolveInfo));
    };
    this.FieldByNumber = function (FieldNo) {
      var Result = null;
      Result = this.FFieldList.FieldByNumber(FieldNo);
      return Result;
    };
    this.FindRecord = function (Restart, GoForward) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetBookmarkStr = function () {
      var Result = "";
      var B = $mod.TBookmark.$new();
      Result = "";
      if (this.BookmarkAvailable()) {
        this.GetBookmarkData($mod.TDataRecord.$clone(this.ActiveBuffer()),B);
        Result = JSON.stringify($mod.TBookmark.$clone(B));
      };
      return Result;
    };
    this.GetCalcFields = function (Buffer) {
      var OldState = 0;
      if ((this.FCalcFieldsCount > 0) || this.FInternalCalcFields) {
        OldState = this.FState;
        this.FState = $mod.TDataSetState.dsCalcFields;
        try {
          this.CalculateFields(Buffer);
        } finally {
          this.FState = OldState;
        };
      };
    };
    this.GetCanModify = function () {
      var Result = false;
      Result = !this.FIsUniDirectional;
      return Result;
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      var Field = null;
      for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        Field = this.FFieldList.GetField(I);
        if (Field.FOwner === Root) Proc(Field);
      };
    };
    this.GetFieldClass = function (FieldType) {
      var Result = null;
      Result = $mod.DefaultFieldClasses[FieldType];
      return Result;
    };
    this.GetfieldCount = function () {
      var Result = 0;
      Result = this.FFieldList.GetCount();
      return Result;
    };
    this.GetFieldValues = function (FieldName) {
      var Result = undefined;
      var i = 0;
      var FieldList = null;
      var A = [];
      FieldList = pas.Classes.TList.$create("Create$1");
      try {
        this.GetFieldList(FieldList,FieldName);
        if (FieldList.GetCount() > 1) {
          A = rtl.arraySetLength(A,undefined,FieldList.GetCount());
          for (var $l = 0, $end = FieldList.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            A[i] = rtl.getObject(FieldList.Get(i)).GetAsJSValue();
          };
          Result = A;
        } else Result = this.FieldByName(FieldName).GetAsJSValue();
      } finally {
        FieldList = rtl.freeLoc(FieldList);
      };
      return Result;
    };
    this.GetIsIndexField = function (Field) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetIndexDefs = function (IndexDefs, IndexTypes) {
      var Result = null;
      var i = 0;
      var f = 0;
      var IndexFields = null;
      IndexDefs.Update$1();
      Result = $mod.TIndexDefs.$create("Create$4",[this]);
      Result.Assign(IndexDefs);
      i = 0;
      IndexFields = pas.Classes.TStringList.$create("Create$1");
      while (i < Result.GetCount()) {
        if (!(rtl.eqSet(IndexTypes,{}) && rtl.eqSet(Result.GetItem$1(i).FOptions,{})) && rtl.eqSet(rtl.intersectSet(IndexTypes,Result.GetItem$1(i).FOptions),{})) {
          Result.Delete(i);
          i -= 1;
        } else {
          for (var $l = 0, $end = IndexFields.GetCount() - 1; $l <= $end; $l++) {
            f = $l;
            if (this.FindField(IndexFields.Get(f)) === null) {
              Result.Delete(i);
              i -= 1;
              break;
            };
          };
        };
        i += 1;
      };
      IndexFields = rtl.freeLoc(IndexFields);
      return Result;
    };
    this.GetNextRecords = function () {
      var Result = 0;
      Result = 0;
      while ((this.FRecordCount < this.FBufferCount) && this.GetNextRecord()) Result += 1;
      return Result;
    };
    this.GetNextRecord = function () {
      var Result = false;
      var T = $mod.TDataRecord.$new();
      if (this.FRecordCount > 0) this.SetCurrentRecord(this.FRecordCount - 1);
      Result = this.GetRecord(this.FBuffers[this.FBufferCount],$mod.TGetMode.gmNext,true) === $mod.TGetResult.grOK;
      if (Result) {
        if (this.FRecordCount === 0) this.ActivateBuffers();
        if (this.FRecordCount === this.FBufferCount) {
          this.ShiftBuffersBackward()}
         else {
          this.FRecordCount += 1;
          this.FCurrentRecord = this.FRecordCount - 1;
          T.$assign(this.FBuffers[this.FCurrentRecord]);
          this.FBuffers[this.FCurrentRecord].$assign(this.FBuffers[this.FBufferCount]);
          this.FBuffers[this.FBufferCount].$assign(T);
        };
      } else this.CursorPosChanged();
      return Result;
    };
    this.GetPriorRecords = function () {
      var Result = 0;
      Result = 0;
      while ((this.FRecordCount < this.FBufferCount) && this.GetPriorRecord()) Result += 1;
      return Result;
    };
    this.GetPriorRecord = function () {
      var Result = false;
      this.CheckBiDirectional();
      if (this.FRecordCount > 0) this.SetCurrentRecord(0);
      Result = this.GetRecord(this.FBuffers[this.FBufferCount],$mod.TGetMode.gmPrior,true) === $mod.TGetResult.grOK;
      if (Result) {
        if (this.FRecordCount === 0) this.ActivateBuffers();
        this.ShiftBuffersForward();
        if (this.FRecordCount < this.FBufferCount) this.FRecordCount += 1;
      } else this.CursorPosChanged();
      return Result;
    };
    this.GetRecordCount = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.GetRecNo = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.InitFieldDefs = function () {
      if (this.IsCursorOpen()) {
        this.InternalInitFieldDefs()}
       else {
        try {
          this.OpenCursor(true);
        } finally {
          this.CloseCursor();
        };
      };
    };
    this.InitFieldDefsFromfields = function () {
      var i = 0;
      if (this.FFieldDefs.GetCount() === 0) {
        this.FFieldDefs.BeginUpdate();
        try {
          for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (!(this.FFieldList.GetField(i).FFieldKind in rtl.createSet($mod.TFieldKind.fkCalculated,$mod.TFieldKind.fkLookup))) {
              this.FFieldList.GetField(i).FFieldDef = this.FFieldDefs.$class.FieldDefClass().$create("Create$3",[this.FFieldDefs,this.FFieldList.GetField(i).FFieldName,this.FFieldList.GetField(i).FDataType,this.FFieldList.GetField(i).FSize,this.FFieldList.GetField(i).FRequired,this.FFieldDefs.GetCount() + 1]);
              if (this.FFieldList.GetField(i).FRequired) this.FFieldList.GetField(i).FFieldDef.SetAttributes(rtl.unionSet(this.FFieldList.GetField(i).FFieldDef.FAttributes,rtl.createSet($mod.TFieldAttribute.faRequired)));
              if (this.FFieldList.GetField(i).FReadOnly) this.FFieldList.GetField(i).FFieldDef.SetAttributes(rtl.unionSet(this.FFieldList.GetField(i).FFieldDef.FAttributes,rtl.createSet($mod.TFieldAttribute.faReadonly)));
            };
          };
        } finally {
          this.FFieldDefs.EndUpdate();
        };
      };
    };
    this.InitRecord = function (Buffer) {
      this.InternalInitRecord(Buffer);
      this.ClearCalcFields(Buffer);
    };
    this.InternalCancel = function () {
    };
    this.InternalEdit = function () {
    };
    this.InternalInsert = function () {
    };
    this.InternalRefresh = function () {
    };
    this.OpenCursor = function (InfoQuery) {
      if (InfoQuery) {
        this.InternalInitFieldDefs()}
       else if (this.FState !== $mod.TDataSetState.dsOpening) this.DoInternalOpen();
    };
    this.OpenCursorcomplete = function () {
      try {
        if (this.FState === $mod.TDataSetState.dsOpening) this.DoInternalOpen();
      } finally {
        if (this.FInternalOpenComplete) {
          this.SetState($mod.TDataSetState.dsBrowse);
          this.DoAfterOpen();
          if (!this.IsEmpty()) this.DoAfterScroll();
        } else {
          this.SetState($mod.TDataSetState.dsInactive);
          this.CloseCursor();
        };
      };
    };
    this.RefreshInternalCalcFields = function (Buffer) {
    };
    this.RestoreState = function (Value) {
      this.FState = Value;
      this.FDisableControlsCount -= 1;
    };
    this.SetActive = function (Value) {
      if (Value && (this.FState === $mod.TDataSetState.dsInactive)) {
        if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) {
          this.FOpenAfterRead = true;
          return;
        } else {
          this.DoBeforeOpen();
          this.FEnableControlsEvent = $mod.TDataEvent.deLayoutChange;
          this.FInternalCalcFields = false;
          try {
            this.FDefaultFields = this.GetfieldCount() === 0;
            this.OpenCursor(false);
          } finally {
            if (this.FState !== $mod.TDataSetState.dsOpening) this.OpenCursorcomplete();
          };
        };
        this.FModified = false;
      } else if (!Value && (this.FState !== $mod.TDataSetState.dsInactive)) {
        this.DoBeforeClose();
        this.SetState($mod.TDataSetState.dsInactive);
        this.FDataRequestID = 0;
        this.DoneChangeList();
        this.CloseCursor();
        this.DoAfterClose();
        this.FModified = false;
      };
    };
    this.SetBookmarkStr = function (Value) {
      var O = null;
      var B = $mod.TBookmark.$new();
      O = JSON.parse(Value);
      B.Flag = O["flag"];
      B.Data = O["Index"];
      this.GotoBookmark(B);
    };
    this.SetBufListSize = function (Value) {
      var I = 0;
      if (Value < 0) Value = 0;
      if (Value === this.FBufferCount) return;
      if (Value > this.FBufferCount) {
        this.FBuffers = rtl.arraySetLength(this.FBuffers,$mod.TDataRecord,Value + 1);
        for (var $l = this.FBufferCount, $end = Value; $l <= $end; $l++) {
          I = $l;
          this.FBuffers[I].$assign(this.AllocRecordBuffer());
        };
      } else if (Value < this.FBufferCount) if ((Value >= 0) && (this.FActiveRecord > (Value - 1))) {
        for (var $l1 = 0, $end1 = this.FActiveRecord - Value; $l1 <= $end1; $l1++) {
          I = $l1;
          this.ShiftBuffersBackward();
        };
        this.FActiveRecord = Value - 1;
      };
      this.FBuffers = rtl.arraySetLength(this.FBuffers,$mod.TDataRecord,Value + 1);
      this.FBufferCount = Value;
      if (this.FRecordCount > this.FBufferCount) this.FRecordCount = this.FBufferCount;
    };
    this.SetChildOrder = function (Child, Order) {
      var Field = null;
      Field = rtl.as(Child,$mod.TField);
      if (this.FFieldList.IndexOf(Field) >= 0) Field.SetIndex(Order);
    };
    this.SetCurrentRecord = function (Index) {
      if (this.FCurrentRecord !== Index) {
        if (!this.FIsUniDirectional) {
          var $tmp = this.GetBookmarkFlag($mod.TDataRecord.$clone(this.FBuffers[Index]));
          if ($tmp === $mod.TBookmarkFlag.bfCurrent) {
            this.InternalSetToRecord($mod.TDataRecord.$clone(this.FBuffers[Index]))}
           else if ($tmp === $mod.TBookmarkFlag.bfBOF) {
            this.InternalFirst()}
           else if ($tmp === $mod.TBookmarkFlag.bfEOF) this.InternalLast();
        };
        this.FCurrentRecord = Index;
      };
    };
    this.SetDefaultFields = function (Value) {
      this.FDefaultFields = Value;
    };
    this.SetFiltered = function (Value) {
      if (Value) this.CheckBiDirectional();
      this.FFiltered = Value;
    };
    this.SetFilterOptions = function (Value) {
      this.CheckBiDirectional();
      this.FFilterOptions = rtl.refSet(Value);
    };
    this.SetFilterText = function (Value) {
      this.FFilterText = Value;
    };
    this.SetFieldValues = function (FieldName, Value) {
      var i = 0;
      var FieldList = null;
      var A = [];
      if (rtl.isArray(Value)) {
        FieldList = pas.Classes.TList.$create("Create$1");
        try {
          this.GetFieldList(FieldList,FieldName);
          A = Value;
          if ((FieldList.GetCount() === 1) && (rtl.length(A) > 0)) {
            this.FieldByName(FieldName).SetAsJSValue(Value)}
           else for (var $l = 0, $end = FieldList.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            rtl.getObject(FieldList.Get(i)).SetAsJSValue(A[i]);
          };
        } finally {
          FieldList = rtl.freeLoc(FieldList);
        };
      } else this.FieldByName(FieldName).SetAsJSValue(Value);
    };
    this.SetFound = function (Value) {
      this.FFound = Value;
    };
    this.SetModified = function (Value) {
      this.FModified = Value;
    };
    this.SetName = function (NewName) {
      var $Self = this;
      function CheckName(FieldName) {
        var Result = "";
        var i = 0;
        var j = 0;
        Result = FieldName;
        i = 0;
        j = 0;
        while (i < $Self.FFieldList.GetCount()) {
          if (Result === $Self.FFieldList.GetField(i).FFieldName) {
            j += 1;
            Result = FieldName + pas.SysUtils.IntToStr(j);
          } else i += 1;
        };
        return Result;
      };
      var i = 0;
      var nm = "";
      var old = "";
      if ($Self.FName === NewName) return;
      old = $Self.FName;
      pas.Classes.TComponent.SetName.call(this,NewName);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        nm = old + this.FFieldList.GetField(i).FFieldName;
        if (pas.System.Copy(this.FFieldList.GetField(i).FName,1,nm.length) === nm) this.FFieldList.GetField(i).SetName(CheckName(NewName + this.FFieldList.GetField(i).FFieldName));
      };
    };
    this.SetOnFilterRecord = function (Value) {
      this.CheckBiDirectional();
      this.FOnFilterRecord = Value;
    };
    this.SetRecNo = function (Value) {
    };
    this.SetState = function (Value) {
      if (Value !== this.FState) {
        this.FState = Value;
        if (Value === $mod.TDataSetState.dsBrowse) this.FModified = false;
        this.DataEvent($mod.TDataEvent.deUpdateState,0);
      };
    };
    this.SetTempState = function (Value) {
      var Result = 0;
      Result = this.FState;
      this.FState = Value;
      this.FDisableControlsCount += 1;
      return Result;
    };
    this.TempBuffer = function () {
      var Result = $mod.TDataRecord.$new();
      Result.$assign(this.FBuffers[this.FRecordCount]);
      return Result;
    };
    this.UpdateIndexDefs = function () {
    };
    this.AllocRecordBuffer = function () {
      var Result = $mod.TDataRecord.$new();
      Result.data = null;
      Result.state = $mod.TRecordState.rsNew;
      return Result;
    };
    this.FreeRecordBuffer = function (Buffer) {
    };
    this.GetBookmarkData = function (Buffer, Data) {
    };
    this.GetBookmarkFlag = function (Buffer) {
      var Result = 0;
      Result = $mod.TBookmarkFlag.bfCurrent;
      return Result;
    };
    this.GetDataSource = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetRecordSize = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.InternalAddRecord = function (Buffer, AAppend) {
    };
    this.InternalDelete = function () {
    };
    this.InternalFirst = function () {
    };
    this.InternalGotoBookmark = function (ABookmark) {
    };
    this.InternalHandleException = function (E) {
      pas.SysUtils.ShowException(E,null);
    };
    this.InternalInitRecord = function (Buffer) {
    };
    this.InternalLast = function () {
    };
    this.InternalPost = function () {
      var $Self = this;
      function CheckRequiredFields() {
        var I = 0;
        for (var $l = 0, $end = $Self.FFieldList.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ($Self.FFieldList.GetField(I).FRequired && !$Self.FFieldList.GetField(I).FReadOnly && ($Self.FFieldList.GetField(I).FFieldKind === $mod.TFieldKind.fkData) && !($Self.FFieldList.GetField(I).FDataType === $mod.TFieldType.ftAutoInc) && $Self.FFieldList.GetField(I).GetIsNull()) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SNeedField"),pas.System.VarRecs(18,$Self.FFieldList.GetField(I).GetDisplayName()),$Self);
        };
      };
      CheckRequiredFields();
    };
    this.InternalSetToRecord = function (Buffer) {
    };
    this.SetBookmarkFlag = function (Buffer, Value) {
    };
    this.SetBookmarkData = function (Buffer, Data) {
    };
    this.SetUniDirectional = function (Value) {
      this.FIsUniDirectional = Value;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.call(this,AComponent,Operation);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FDataProxy)) this.FDataProxy = null;
    };
    this.SetDataSetField = function (Value) {
      if (Value === this.FDataSetField) return;
      if ((Value !== null) && ((Value.FDataSet === this) || ((Value.FDataSet.GetDataSource() !== null) && (Value.FDataSet.GetDataSource().FDataSet === this)))) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SCircularDataLink"),this);
      if ((Value != null) && !this.$class.InheritsFrom(Value.FDataSet.FNestedDataSetClass)) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SNestedDataSetClass"),pas.System.VarRecs(18,Value.FDataSet.FNestedDataSetClass.$classname),this);
      if (this.GetActive()) this.Close();
      if (this.FDataSetField != null) this.FDataSetField.AssignNestedDataSet(null);
      this.FDataSetField = Value;
      if (Value != null) {
        Value.AssignNestedDataSet(this);
        if (Value.FDataSet.GetActive()) this.Open();
      };
    };
    this.GetFieldData = function (Field) {
      var Result = undefined;
      Result = this.GetFieldData$1(Field,$mod.TDataRecord.$clone(this.ActiveBuffer()));
      return Result;
    };
    this.SetFieldData = function (Field, AValue) {
      this.SetFieldData$1(Field,this.FBuffers[this.FActiveRecord],AValue);
    };
    this.GetFieldData$1 = function (Field, Buffer) {
      var Result = undefined;
      Result = Buffer.data[Field.FFieldName];
      if (pas.JS.isUndefined(Result)) Result = null;
      return Result;
    };
    this.SetFieldData$1 = function (Field, Buffer, AValue) {
      Buffer.data[Field.FFieldName] = AValue;
    };
    this.FieldDefsClass = function () {
      var Result = null;
      Result = $mod.TFieldDefs;
      return Result;
    };
    this.FieldsClass = function () {
      var Result = null;
      Result = $mod.TFields;
      return Result;
    };
    this.GetBOF = function () {
      var Result = false;
      Result = this.FBOF;
      return Result;
    };
    this.GetEOF = function () {
      var Result = false;
      Result = this.FEOF;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FFieldDefs = this.$class.FieldDefsClass().$create("Create$4",[this]);
      this.FFieldList = this.$class.FieldsClass().$create("Create$1",[this]);
      this.FDataSources = pas.Classes.TFPList.$create("Create");
      this.FConstraints = $mod.TCheckConstraints.$create("Create$2",[this]);
      this.FBuffers = rtl.arraySetLength(this.FBuffers,$mod.TDataRecord,1);
      this.FActiveRecord = 0;
      this.FEOF = true;
      this.FBOF = true;
      this.FIsUniDirectional = false;
      this.FAutoCalcFields = true;
      this.FDataRequestID = 0;
      this.FNestedDataSetClass = this.$class.ClassType();
      return this;
    };
    this.Destroy = function () {
      var i = 0;
      this.SetActive(false);
      this.SetDataSetField(null);
      rtl.free(this,"FFieldDefs");
      rtl.free(this,"FFieldList");
      rtl.free(this,"FNestedDataSets");
      while (this.FDataSources.FCount > 0) rtl.getObject(this.FDataSources.Get(this.FDataSources.FCount - 1)).SetDataSet(null);
      this.FDataSources.$destroy("Destroy");
      for (var $l = 0, $end = this.FBufferCount; $l <= $end; $l++) {
        i = $l;
        this.FreeRecordBuffer(this.FBuffers[i]);
      };
      rtl.free(this,"FConstraints");
      this.FBuffers = rtl.arraySetLength(this.FBuffers,$mod.TDataRecord,1);
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.ActiveBuffer = function () {
      var Result = $mod.TDataRecord.$new();
      if (this.FActiveRecord !== -1) {
        Result.$assign(this.FBuffers[this.FActiveRecord])}
       else Result.$assign($mod.TDataRecord.$new());
      return Result;
    };
    this.Append = function () {
      this.DoInsertAppend(true);
    };
    this.AppendRecord = function (Values) {
      this.DoInsertAppendRecord(Values,true);
    };
    this.GetClonedDataSet = function (WithSettings) {
      var Result = null;
      Result = null;
      return Result;
    };
    this.BookmarkValid = function (ABookmark) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.ConvertToDateTime = function (aField, aValue, ARaiseException) {
      var Result = 0.0;
      Result = this.$class.DefaultConvertToDateTime(aField,aValue,ARaiseException);
      return Result;
    };
    this.ConvertDateTimeToNative = function (aField, aValue) {
      var Result = undefined;
      Result = this.$class.DefaultConvertDateTimeToNative(aField,aValue);
      return Result;
    };
    this.DefaultConvertToDateTime = function (aField, aValue, ARaiseException) {
      var Result = 0.0;
      Result = 0;
      if (rtl.isString(aValue)) {
        if (("" + aValue) === "") {
          Result = 0}
         else if (!pas.DateUtils.TryRFC3339ToDateTime("" + aValue,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }})) throw pas.SysUtils.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.DBConst,"SErrInvalidDateTime"),pas.System.VarRecs(18,"" + aValue)]);
      } else if (rtl.isNumber(aValue)) {
        Result = rtl.getNumber(aValue)}
       else if (pas.JS.isDate(aValue)) Result = pas.SysUtils.JSDateToDateTime(aValue);
      return Result;
    };
    this.DefaultConvertDateTimeToNative = function (aField, aValue) {
      var Result = undefined;
      Result = pas.DateUtils.DateTimeToRFC3339(aValue);
      return Result;
    };
    this.BlobDataToBytes = function (aValue) {
      var Result = [];
      Result = this.$class.DefaultBlobDataToBytes(aValue);
      return Result;
    };
    this.DefaultBlobDataToBytes = function (aValue) {
      var Result = [];
      var S = "";
      var I = 0;
      var J = 0;
      var L = 0;
      Result = rtl.arraySetLength(Result,0,0);
      if (rtl.isString(aValue)) {
        S = "" + aValue;
        L = S.length;
        Result = rtl.arraySetLength(Result,0,rtl.trunc((L + 1) / 2));
        I = 1;
        J = 0;
        while (I < L) {
          try {
            Result[J] = pas.SysUtils.StrToInt("$" + pas.System.Copy(S,I,2));
            I += 2;
            J += 1;
          } catch ($e) {
            Result[J] = S.charCodeAt(I - 1);
            I += 1;
            J += 1;
          };
        };
      };
      return Result;
    };
    this.BytesToBlobData = function (aValue) {
      var Result = undefined;
      Result = this.$class.DefaultBytesToBlobData(rtl.arrayRef(aValue));
      return Result;
    };
    this.DefaultBytesToBlobData = function (aValue) {
      var Result = undefined;
      var S = "";
      var I = 0;
      if (rtl.length(aValue) === 0) {
        Result = null}
       else {
        S = "";
        for (var $l = 0, $end = rtl.length(aValue) - 1; $l <= $end; $l++) {
          I = $l;
          S = S.concat(pas.SysUtils.IntToHex(aValue[I],2));
        };
        Result = S;
      };
      return Result;
    };
    this.Cancel = function () {
      if (this.FState in rtl.createSet($mod.TDataSetState.dsEdit,$mod.TDataSetState.dsInsert)) {
        this.DataEvent($mod.TDataEvent.deCheckBrowseMode,0);
        this.DoBeforeCancel();
        this.UpdateCursorPos();
        this.InternalCancel();
        if ((this.FState === $mod.TDataSetState.dsInsert) && (this.FRecordCount === 1)) {
          this.FEOF = true;
          this.FBOF = true;
          this.FRecordCount = 0;
          this.InitRecord(this.FBuffers[this.FActiveRecord]);
          this.SetState($mod.TDataSetState.dsBrowse);
          this.DataEvent($mod.TDataEvent.deDataSetChange,0);
        } else {
          this.SetState($mod.TDataSetState.dsBrowse);
          this.SetCurrentRecord(this.FActiveRecord);
          this.Resync({});
        };
        this.DoAfterCancel();
      };
    };
    this.CheckBrowseMode = function () {
      this.CheckActive();
      this.DataEvent($mod.TDataEvent.deCheckBrowseMode,0);
      var $tmp = this.FState;
      if (($tmp === $mod.TDataSetState.dsEdit) || ($tmp === $mod.TDataSetState.dsInsert)) {
        this.UpdateRecord();
        if (this.FModified) {
          this.Post()}
         else this.Cancel();
      } else if ($tmp === $mod.TDataSetState.dsSetKey) this.Post();
    };
    this.ClearFields = function () {
      this.DataEvent($mod.TDataEvent.deCheckBrowseMode,0);
      this.InternalInitRecord(this.FBuffers[this.FActiveRecord]);
      if (this.FState !== $mod.TDataSetState.dsSetKey) this.GetCalcFields(this.FBuffers[this.FActiveRecord]);
      this.DataEvent($mod.TDataEvent.deRecordChange,0);
    };
    this.Close = function () {
      this.SetActive(false);
    };
    this.GetUpdateCount = function (UnresolvedOnly) {
      var Result = 0;
      var I = 0;
      Result = 0;
      if (!(this.FChangeList != null)) return Result;
      if (!UnresolvedOnly) {
        Result = this.FChangeList.FCount}
       else for (var $l = 0, $end = this.FChangeList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        if (rtl.getObject(this.FChangeList.Get(I)).FResolveStatus === $mod.TResolveStatus.rsUnresolved) Result += 1;
      };
      return Result;
    };
    this.ApplyUpdates = function () {
      this.DoBeforeApplyUpdates();
      this.DoApplyUpdates();
    };
    this.ControlsDisabled = function () {
      var Result = false;
      Result = this.FDisableControlsCount > 0;
      return Result;
    };
    this.CompareBookmarks = function (Bookmark1, Bookmark2) {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.CursorPosChanged = function () {
      this.FCurrentRecord = -1;
    };
    this.Delete = function () {
      var R = null;
      if (!this.GetCanModify()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SDatasetReadOnly"),this);
      if (this.IsEmpty()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SDatasetEmpty"),this);
      if (this.FState in rtl.createSet($mod.TDataSetState.dsInsert)) {
        this.Cancel();
      } else {
        this.DataEvent($mod.TDataEvent.deCheckBrowseMode,0);
        this.DoBeforeDelete();
        this.DoBeforeScroll();
        R = this.AddToChangeList($mod.TUpdateStatus.usDeleted);
        if (!this.TryDoing(rtl.createCallback(this,"InternalDelete"),this.FOnDeleteError)) {
          if (R != null) this.RemoveFromChangeList(R);
          return;
        };
        this.SetState($mod.TDataSetState.dsBrowse);
        this.SetCurrentRecord(this.FActiveRecord);
        this.Resync({});
        this.DoAfterDelete();
        this.DoAfterScroll();
      };
    };
    this.DisableControls = function () {
      if (this.FDisableControlsCount === 0) {
        this.FDisableControlsState = this.FState;
        this.FEnableControlsEvent = $mod.TDataEvent.deDataSetChange;
      };
      this.FDisableControlsCount += 1;
    };
    this.Edit = function () {
      if (this.FState in rtl.createSet($mod.TDataSetState.dsEdit,$mod.TDataSetState.dsInsert)) return;
      this.CheckBrowseMode();
      if (!this.GetCanModify()) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SDatasetReadOnly"),this);
      if (this.FRecordCount === 0) {
        this.Append();
        return;
      };
      this.DoBeforeEdit();
      if (!this.TryDoing(rtl.createCallback(this,"InternalEdit"),this.FOnEditError)) return;
      this.GetCalcFields(this.FBuffers[this.FActiveRecord]);
      this.SetState($mod.TDataSetState.dsEdit);
      this.DataEvent($mod.TDataEvent.deRecordChange,0);
      this.DoAfterEdit();
    };
    this.EnableControls = function () {
      if (this.FDisableControlsCount > 0) this.FDisableControlsCount -= 1;
      if (this.FDisableControlsCount === 0) {
        if (this.FState !== this.FDisableControlsState) this.DataEvent($mod.TDataEvent.deUpdateState,0);
        if ((this.FState !== $mod.TDataSetState.dsInactive) && (this.FDisableControlsState !== $mod.TDataSetState.dsInactive)) this.DataEvent(this.FEnableControlsEvent,0);
      };
    };
    this.FieldByName = function (FieldName) {
      var Result = null;
      Result = this.FindField(FieldName);
      if (Result === null) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SFieldNotFound"),pas.System.VarRecs(18,FieldName),this);
      return Result;
    };
    this.FindField = function (FieldName) {
      var Result = null;
      Result = this.FFieldList.FindField(FieldName);
      return Result;
    };
    this.FindFirst = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.FindLast = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.FindNext = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.FindPrior = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.First = function () {
      this.CheckBrowseMode();
      this.DoBeforeScroll();
      if (!this.FIsUniDirectional) {
        this.ClearBuffers()}
       else if (!this.FBOF) {
        this.SetActive(false);
        this.SetActive(true);
      };
      try {
        this.InternalFirst();
        if (!this.FIsUniDirectional) this.GetNextRecords();
      } finally {
        this.FBOF = true;
        this.DataEvent($mod.TDataEvent.deDataSetChange,0);
        this.DoAfterScroll();
      };
    };
    this.FreeBookmark = function (ABookmark) {
    };
    this.GetBookmark = function () {
      var Result = $mod.TBookmark.$new();
      if (this.BookmarkAvailable()) {
        this.GetBookmarkData($mod.TDataRecord.$clone(this.ActiveBuffer()),Result)}
       else Result.Data = null;
      return Result;
    };
    this.GetCurrentRecord = function (Buffer) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetFieldList = function (List, FieldNames) {
      var F = null;
      var N = "";
      var StrPos = 0;
      if ((FieldNames === "") || (List === null)) return;
      StrPos = 1;
      do {
        N = $mod.ExtractFieldName(FieldNames,{get: function () {
            return StrPos;
          }, set: function (v) {
            StrPos = v;
          }});
        F = this.FieldByName(N);
        List.Add(F);
      } while (!(StrPos > FieldNames.length));
    };
    this.GetFieldList$1 = function (List, FieldNames) {
      var F = null;
      var N = "";
      var StrPos = 0;
      if ((FieldNames === "") || (List === null)) return;
      StrPos = 1;
      do {
        N = $mod.ExtractFieldName(FieldNames,{get: function () {
            return StrPos;
          }, set: function (v) {
            StrPos = v;
          }});
        F = this.FieldByName(N);
        List.Add(F);
      } while (!(StrPos > FieldNames.length));
    };
    this.GetFieldNames = function (List) {
      this.FFieldList.GetFieldNames(List);
    };
    this.GotoBookmark = function (ABookmark) {
      if (!pas.JS.isNull(ABookmark.Data)) {
        this.CheckBrowseMode();
        this.DoBeforeScroll();
        this.InternalGotoBookmark($mod.TBookmark.$clone(ABookmark));
        this.Resync(rtl.createSet($mod.TResyncMode$a.rmExact,$mod.TResyncMode$a.rmCenter));
        this.DoAfterScroll();
      };
    };
    this.Insert$1 = function () {
      this.DoInsertAppend(false);
    };
    this.InsertRecord = function (Values) {
      this.DoInsertAppendRecord(Values,false);
    };
    this.IsEmpty = function () {
      var Result = false;
      Result = this.FBOF && this.FEOF && !(this.FState === $mod.TDataSetState.dsInsert);
      return Result;
    };
    this.IsLinkedTo = function (ADataSource) {
      var Result = false;
      if ((ADataSource === null) || (ADataSource.FDataSet === null)) {
        Result = false;
      } else if (ADataSource.FDataSet === this) {
        Result = true;
      } else {
        Result = ADataSource.FDataSet.IsLinkedTo(ADataSource.FDataSet.GetDataSource());
      };
      return Result;
    };
    this.IsSequenced = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.Last = function () {
      this.CheckBiDirectional();
      this.CheckBrowseMode();
      this.DoBeforeScroll();
      this.ClearBuffers();
      try {
        this.InternalLast();
        this.GetPriorRecords();
        if (this.FRecordCount > 0) this.FActiveRecord = this.FRecordCount - 1;
      } finally {
        this.FEOF = true;
        this.DataEvent($mod.TDataEvent.deDataSetChange,0);
        this.DoAfterScroll();
      };
    };
    this.Load = function (aOptions, aAfterLoad) {
      var Result = false;
      if ($mod.TLoadOption.loAtEOF in aOptions) $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SatEOFInternalOnly"),this);
      if ($mod.TLoadOption.loCancelPending in aOptions) this.CancelLoading();
      Result = this.DoLoad(rtl.refSet(aOptions),aAfterLoad);
      return Result;
    };
    this.Locate = function (KeyFields, KeyValues, Options) {
      var Result = false;
      this.CheckBiDirectional();
      Result = false;
      return Result;
    };
    this.Lookup = function (KeyFields, KeyValues, ResultFields) {
      var Result = undefined;
      this.CheckBiDirectional();
      Result = null;
      return Result;
    };
    this.MoveBy = function (Distance) {
      var $Self = this;
      var Result = 0;
      var TheResult = 0;
      function ScrollForward() {
        var Result = 0;
        Result = 0;
        $Self.FBOF = false;
        while ((Distance > 0) && !$Self.FEOF) {
          if ($Self.FActiveRecord < ($Self.FRecordCount - 1)) {
            $Self.FActiveRecord += 1;
            Distance -= 1;
            TheResult += 1;
          } else {
            if ($Self.GetNextRecord()) {
              Distance -= 1;
              Result -= 1;
              TheResult += 1;
            } else {
              $Self.FEOF = true;
              $Self.DoLoad(rtl.createSet($mod.TLoadOption.loNoOpen,$mod.TLoadOption.loAtEOF),null);
            };
          };
        };
        return Result;
      };
      function ScrollBackward() {
        var Result = 0;
        $Self.CheckBiDirectional();
        Result = 0;
        $Self.FEOF = false;
        while ((Distance < 0) && !$Self.FBOF) {
          if ($Self.FActiveRecord > 0) {
            $Self.FActiveRecord -= 1;
            Distance += 1;
            TheResult -= 1;
          } else {
            if ($Self.GetPriorRecord()) {
              Distance += 1;
              Result += 1;
              TheResult -= 1;
            } else $Self.FBOF = true;
          };
        };
        return Result;
      };
      var Scrolled = 0;
      this.CheckBrowseMode();
      Result = 0;
      TheResult = 0;
      this.DoBeforeScroll();
      if ((Distance === 0) || ((Distance > 0) && this.FEOF) || ((Distance < 0) && this.FBOF)) return Result;
      try {
        Scrolled = 0;
        if (Distance > 0) {
          Scrolled = ScrollForward()}
         else Scrolled = ScrollBackward();
      } finally {
        this.DataEvent($mod.TDataEvent.deDataSetScroll,Scrolled);
        this.DoAfterScroll();
        Result = TheResult;
      };
      return Result;
    };
    this.Next = function () {
      if (this.FBlockReadSize > 0) {
        this.BlockReadNext()}
       else this.MoveBy(1);
    };
    this.Open = function () {
      this.SetActive(true);
    };
    var UpdateStates = [$mod.TUpdateStatus.usModified,$mod.TUpdateStatus.usInserted];
    this.Post = function () {
      var R = null;
      var WasInsert = false;
      this.UpdateRecord();
      if (this.FState in rtl.createSet($mod.TDataSetState.dsEdit,$mod.TDataSetState.dsInsert)) {
        this.DataEvent($mod.TDataEvent.deCheckBrowseMode,0);
        this.DoBeforePost();
        WasInsert = this.FState === $mod.TDataSetState.dsInsert;
        if (!this.TryDoing(rtl.createCallback(this,"InternalPost"),this.FOnPostError)) return;
        this.CursorPosChanged();
        this.SetState($mod.TDataSetState.dsBrowse);
        this.Resync({});
        R = this.AddToChangeList(UpdateStates[+WasInsert]);
        if (R != null) R.FBookmark.$assign(this.GetBookmark());
        this.DoAfterPost();
      } else if (this.FState !== $mod.TDataSetState.dsSetKey) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SNotEditing"),pas.System.VarRecs(18,this.FName),this);
    };
    this.Prior = function () {
      this.MoveBy(-1);
    };
    this.Refresh = function () {
      this.CheckBrowseMode();
      this.DoBeforeRefresh();
      this.UpdateCursorPos();
      this.InternalRefresh();
      this.Resync({});
      this.DoAfterRefresh();
    };
    this.Resync = function (Mode) {
      var i = 0;
      var count = 0;
      if (this.FIsUniDirectional) return;
      if (this.GetRecord(this.FBuffers[0],$mod.TGetMode.gmCurrent,false) !== $mod.TGetResult.grOK) if ($mod.TResyncMode$a.rmExact in Mode) {
        $mod.DatabaseError$1(rtl.getResStr(pas.DBConst,"SNoSuchRecord"),this)}
       else if ((this.GetRecord(this.FBuffers[0],$mod.TGetMode.gmNext,true) !== $mod.TGetResult.grOK) && (this.GetRecord(this.FBuffers[0],$mod.TGetMode.gmPrior,true) !== $mod.TGetResult.grOK)) {
        this.ClearBuffers();
        this.InternalInitRecord(this.FBuffers[this.FActiveRecord]);
        this.DataEvent($mod.TDataEvent.deDataSetChange,0);
        return;
      };
      this.FCurrentRecord = 0;
      this.FEOF = false;
      this.FBOF = false;
      if ($mod.TResyncMode$a.rmCenter in Mode) {
        count = rtl.trunc(this.FRecordCount / 2)}
       else count = this.FActiveRecord;
      i = 0;
      this.FRecordCount = 1;
      this.FActiveRecord = 0;
      while ((i < count) && this.GetPriorRecord()) i += 1;
      this.FActiveRecord = i;
      this.GetNextRecords();
      if (this.FRecordCount < this.FBufferCount) this.FActiveRecord = this.FActiveRecord + this.GetPriorRecords();
      this.DataEvent($mod.TDataEvent.deDataSetChange,0);
    };
    this.CancelLoading = function () {
      this.FMinLoadID = this.FDataRequestID;
      this.FLoadCount = 0;
    };
    this.SetFields = function (Values) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(Values) - 1; $l <= $end; $l++) {
        I = $l;
        this.FFieldList.GetField(I).AssignValue(Values[I]);
      };
    };
    this.UpdateCursorPos = function () {
      if (this.FRecordCount > 0) this.SetCurrentRecord(this.FActiveRecord);
    };
    this.UpdateRecord = function () {
      if (!(this.FState in $mod.dsEditModes)) $mod.DatabaseErrorFmt$1(rtl.getResStr(pas.DBConst,"SNotEditing"),pas.System.VarRecs(18,this.FName),this);
      this.DataEvent($mod.TDataEvent.deUpdateRecord,0);
    };
    this.GetPendingUpdates = function () {
      var Result = [];
      var L = null;
      var I = 0;
      L = $mod.TRecordUpdateDescriptorList.$create("Create");
      try {
        Result = rtl.arraySetLength(Result,$mod.TResolveInfo,this.GetRecordUpdates(L));
        for (var $l = 0, $end = L.FCount - 1; $l <= $end; $l++) {
          I = $l;
          Result[I].$assign(this.RecordUpdateDescriptorToResolveInfo(L.GetUpdate(I)));
        };
      } finally {
        L = rtl.freeLoc(L);
      };
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TDataLink",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FFirstRecord = 0;
      this.FBufferCount = 0;
      this.FActive = false;
      this.FDataSourceFixed = false;
      this.FEditing = false;
      this.FReadOnly = false;
      this.FUpdatingRecord = false;
      this.FVisualControl = false;
      this.FDataSource = null;
    };
    this.$final = function () {
      this.FDataSource = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.CalcFirstRecord = function (Index) {
      var Result = 0;
      if (this.FDataSource.FDataSet.FActiveRecord > ((this.FFirstRecord + Index + this.FBufferCount) - 1)) {
        Result = this.FDataSource.FDataSet.FActiveRecord - ((this.FFirstRecord + Index + this.FBufferCount) - 1)}
       else if (this.FDataSource.FDataSet.FActiveRecord < (this.FFirstRecord + Index)) {
        Result = this.FDataSource.FDataSet.FActiveRecord - (this.FFirstRecord + Index)}
       else Result = 0;
      this.FFirstRecord += Index + Result;
      return Result;
    };
    this.CalcRange = function () {
      var aMax = 0;
      var aMin = 0;
      aMin = (this.GetDataset().FActiveRecord - this.FBufferCount) + 1;
      if (aMin < 0) aMin = 0;
      aMax = this.GetDataset().FBufferCount - this.FBufferCount;
      if (aMax < 0) aMax = 0;
      if (aMax > this.GetDataset().FActiveRecord) aMax = this.GetDataset().FActiveRecord;
      if (this.FFirstRecord < aMin) this.FFirstRecord = aMin;
      if (this.FFirstRecord > aMax) this.FFirstRecord = aMax;
      if ((this.FFirstRecord !== 0) && ((this.GetDataset().FActiveRecord - this.FFirstRecord) < (this.FBufferCount - 1))) this.FFirstRecord -= 1;
    };
    this.CheckActiveAndEditing = function () {
      var B = false;
      B = (this.FDataSource != null) && !(this.FDataSource.FState in rtl.createSet($mod.TDataSetState.dsInactive,$mod.TDataSetState.dsOpening));
      if (B !== this.FActive) {
        this.FActive = B;
        this.ActiveChanged();
      };
      B = (this.FDataSource != null) && (this.FDataSource.FState in $mod.dsEditModes) && !this.FReadOnly;
      if (B !== this.FEditing) {
        this.FEditing = B;
        this.EditingChanged();
      };
    };
    this.GetDataset = function () {
      var Result = null;
      if (this.FDataSource != null) {
        Result = this.FDataSource.FDataSet}
       else Result = null;
      return Result;
    };
    this.SetActive = function (AActive) {
      if (this.FActive !== AActive) {
        this.FActive = AActive;
        this.ActiveChanged();
      };
    };
    this.SetDataSource = function (Value) {
      if (this.FDataSource === Value) return;
      if (!this.FDataSourceFixed) {
        if (this.FDataSource != null) {
          this.FDataSource.UnregisterDataLink(this);
          this.FDataSource = null;
          this.CheckActiveAndEditing();
        };
        this.FDataSource = Value;
        if (this.FDataSource != null) {
          this.FDataSource.RegisterDataLink(this);
          this.CheckActiveAndEditing();
        };
      };
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        this.CheckActiveAndEditing();
      };
    };
    this.ActiveChanged = function () {
      this.FFirstRecord = 0;
    };
    this.CheckBrowseMode = function () {
    };
    this.DataEvent = function (Event, Info) {
      if (Event === $mod.TDataEvent.deUpdateState) {
        this.CheckActiveAndEditing()}
       else if (this.FActive) {
        var $tmp = Event;
        if (($tmp === $mod.TDataEvent.deFieldChange) || ($tmp === $mod.TDataEvent.deRecordChange)) {
          if (!this.FUpdatingRecord) this.RecordChanged(rtl.getObject(Info))}
         else if ($tmp === $mod.TDataEvent.deDataSetChange) {
          this.SetActive(this.FDataSource.FDataSet.GetActive());
          this.CalcRange();
          this.CalcFirstRecord(rtl.trunc(Info));
          this.DataSetChanged();
        } else if ($tmp === $mod.TDataEvent.deDataSetScroll) {
          this.DataSetScrolled(this.CalcFirstRecord(rtl.trunc(Info)))}
         else if ($tmp === $mod.TDataEvent.deLayoutChange) {
          this.CalcFirstRecord(rtl.trunc(Info));
          this.LayoutChanged();
        } else if ($tmp === $mod.TDataEvent.deUpdateRecord) {
          this.UpdateRecord()}
         else if ($tmp === $mod.TDataEvent.deCheckBrowseMode) {
          this.CheckBrowseMode()}
         else if ($tmp === $mod.TDataEvent.deFocusControl) this.FocusControl(Info);
      };
    };
    this.DataSetChanged = function () {
      this.RecordChanged(null);
    };
    this.DataSetScrolled = function (Distance) {
      this.DataSetChanged();
    };
    this.EditingChanged = function () {
    };
    this.FocusControl = function (Field) {
    };
    this.GetActiveRecord = function () {
      var Result = 0;
      Result = this.GetDataset().FActiveRecord - this.FFirstRecord;
      return Result;
    };
    this.GetBOF = function () {
      var Result = false;
      Result = this.GetDataset().GetBOF();
      return Result;
    };
    this.GetBufferCount = function () {
      var Result = 0;
      Result = this.FBufferCount;
      return Result;
    };
    this.GetEOF = function () {
      var Result = false;
      Result = this.GetDataset().GetEOF();
      return Result;
    };
    this.GetRecordCount = function () {
      var Result = 0;
      Result = this.GetDataset().FRecordCount;
      if (Result > this.GetBufferCount()) Result = this.GetBufferCount();
      return Result;
    };
    this.LayoutChanged = function () {
      this.DataSetChanged();
    };
    this.MoveBy = function (Distance) {
      var Result = 0;
      Result = this.GetDataset().MoveBy(Distance);
      return Result;
    };
    this.RecordChanged = function (Field) {
    };
    this.SetActiveRecord = function (Value) {
      this.GetDataset().FActiveRecord = Value + this.FFirstRecord;
    };
    this.SetBufferCount = function (Value) {
      if (this.FBufferCount !== Value) {
        this.FBufferCount = Value;
        if (this.FActive) {
          this.GetDataset().RecalcBufListSize();
          this.CalcRange();
        };
      };
    };
    this.UpdateData = function () {
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FBufferCount = 1;
      this.FFirstRecord = 0;
      this.FDataSource = null;
      this.FDataSourceFixed = false;
      return this;
    };
    this.Destroy = function () {
      this.FActive = false;
      this.FEditing = false;
      this.FDataSourceFixed = false;
      this.SetDataSource(null);
      pas.System.TObject.Destroy.call(this);
    };
    this.Edit = function () {
      var Result = false;
      if (!this.FReadOnly) this.FDataSource.Edit();
      Result = this.FEditing;
      return Result;
    };
    this.UpdateRecord = function () {
      this.FUpdatingRecord = true;
      try {
        this.UpdateData();
      } finally {
        this.FUpdatingRecord = false;
      };
    };
  });
  rtl.createClass(this,"TDetailDataLink",this.TDataLink,function () {
    this.GetDetailDataSet = function () {
      var Result = null;
      Result = null;
      return Result;
    };
  });
  rtl.createClass(this,"TMasterDataLink",this.TDetailDataLink,function () {
    this.$init = function () {
      $mod.TDetailDataLink.$init.call(this);
      this.FDetailDataSet = null;
      this.FFieldNames = "";
      this.FFields = null;
      this.FOnMasterChange = null;
      this.FOnMasterDisable = null;
    };
    this.$final = function () {
      this.FDetailDataSet = undefined;
      this.FFields = undefined;
      this.FOnMasterChange = undefined;
      this.FOnMasterDisable = undefined;
      $mod.TDetailDataLink.$final.call(this);
    };
    this.SetFieldNames = function (Value) {
      if (this.FFieldNames !== Value) {
        this.FFieldNames = Value;
        this.ActiveChanged();
      };
    };
    this.ActiveChanged = function () {
      this.FFields.Clear();
      if (this.FActive) try {
        this.GetDataset().GetFieldList(this.FFields,this.FFieldNames);
      } catch ($e) {
        this.FFields.Clear();
        throw $e;
      };
      if (this.FDetailDataSet.GetActive() && !(pas.Classes.TComponentStateItem.csDestroying in this.FDetailDataSet.FComponentState)) if (this.FActive && (this.FFields.GetCount() > 0)) {
        this.DoMasterChange()}
       else this.DoMasterDisable();
    };
    this.CheckBrowseMode = function () {
      if (this.FDetailDataSet.GetActive()) this.FDetailDataSet.CheckBrowseMode();
    };
    this.GetDetailDataSet = function () {
      var Result = null;
      Result = this.FDetailDataSet;
      return Result;
    };
    this.LayoutChanged = function () {
      this.ActiveChanged();
    };
    this.RecordChanged = function (Field) {
      if ((this.FDataSource.FState !== $mod.TDataSetState.dsSetKey) && this.FDetailDataSet.GetActive() && (this.FFields.GetCount() > 0) && ((Field === null) || (this.FFields.IndexOf(Field) >= 0))) this.DoMasterChange();
    };
    this.DoMasterDisable = function () {
      if (this.FOnMasterDisable != null) this.FOnMasterDisable(this);
    };
    this.DoMasterChange = function () {
      if (this.FOnMasterChange != null) this.FOnMasterChange(this);
    };
    this.Create$2 = function (ADataSet) {
      $mod.TDataLink.Create$1.call(this);
      this.FDetailDataSet = ADataSet;
      this.FFields = pas.Classes.TList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFields");
      $mod.TDataLink.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TMasterParamsDataLink",this.TMasterDataLink,function () {
    this.$init = function () {
      $mod.TMasterDataLink.$init.call(this);
      this.FParams = null;
    };
    this.$final = function () {
      this.FParams = undefined;
      $mod.TMasterDataLink.$final.call(this);
    };
    this.SetParams = function (AValue) {
      this.FParams = AValue;
      if (AValue !== null) this.RefreshParamNames();
    };
    this.DoMasterDisable = function () {
      $mod.TMasterDataLink.DoMasterDisable.call(this);
    };
    this.DoMasterChange = function () {
      $mod.TMasterDataLink.DoMasterChange.call(this);
      if ((this.FParams != null) && (this.GetDetailDataSet() != null) && this.GetDetailDataSet().GetActive()) {
        this.GetDetailDataSet().CheckBrowseMode();
        this.GetDetailDataSet().Close();
        this.GetDetailDataSet().Open();
      };
    };
    this.Create$2 = function (ADataSet) {
      var P = null;
      $mod.TMasterDataLink.Create$2.call(this,ADataSet);
      if (ADataSet !== null) {
        P = pas.TypInfo.GetObjectProp$1(ADataSet,"Params",$mod.TParams);
        if (P !== null) this.SetParams(P);
      };
      return this;
    };
    this.RefreshParamNames = function () {
      var FN = "";
      var DS = null;
      var F = null;
      var I = 0;
      var P = null;
      FN = "";
      DS = this.GetDataset();
      if (this.FParams != null) {
        F = null;
        for (var $l = 0, $end = this.FParams.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          P = this.FParams.GetItem$1(I);
          if (!P.FBound) {
            if (DS != null) F = DS.FindField(P.FName);
            if (!(DS != null) || !DS.GetActive() || (F !== null)) {
              if (FN !== "") FN = FN + ";";
              FN = FN + P.FName;
            };
          };
        };
      };
      this.SetFieldNames(FN);
    };
    this.CopyParamsFromMaster = function (CopyBound) {
      if (this.FParams != null) this.FParams.CopyParamValuesFromDataset(this.GetDataset(),CopyBound);
    };
  });
  this.$rtti.$MethodVar("TDataChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Field",this.$rtti["TField"]]]), methodkind: 0});
  rtl.createClass(this,"TDataSource",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FDataSet = null;
      this.FDataLinks = null;
      this.FEnabled = false;
      this.FAutoEdit = false;
      this.FState = 0;
      this.FOnStateChange = null;
      this.FOnDataChange = null;
      this.FOnUpdateData = null;
    };
    this.$final = function () {
      this.FDataSet = undefined;
      this.FDataLinks = undefined;
      this.FOnStateChange = undefined;
      this.FOnDataChange = undefined;
      this.FOnUpdateData = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.DistributeEvent = function (Event, Info) {
      var i = 0;
      for (var $l = 0, $end = this.FDataLinks.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (!rtl.getObject(this.FDataLinks.Get(i)).FVisualControl) {
          rtl.getObject(this.FDataLinks.Get(i)).DataEvent(Event,Info);
        };
      };
      for (var $l1 = 0, $end1 = this.FDataLinks.GetCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        if (rtl.getObject(this.FDataLinks.Get(i)).FVisualControl) {
          rtl.getObject(this.FDataLinks.Get(i)).DataEvent(Event,Info);
        };
      };
    };
    this.RegisterDataLink = function (DataLink) {
      this.FDataLinks.Add(DataLink);
      if (this.FDataSet != null) this.FDataSet.RecalcBufListSize();
    };
    var OnDataChangeEvents = rtl.createSet($mod.TDataEvent.deRecordChange,$mod.TDataEvent.deDataSetChange,$mod.TDataEvent.deDataSetScroll,$mod.TDataEvent.deLayoutChange,$mod.TDataEvent.deUpdateState);
    this.ProcessEvent = function (Event, Info) {
      var NeedDataChange = false;
      var FLastState = 0;
      if (Event === $mod.TDataEvent.deUpdateState) {
        NeedDataChange = this.FState === $mod.TDataSetState.dsInactive;
        FLastState = this.FState;
        if ((this.FDataSet != null) && this.FEnabled) {
          this.FState = this.FDataSet.FState}
         else this.FState = $mod.TDataSetState.dsInactive;
        if (this.FState === FLastState) return;
      } else NeedDataChange = true;
      this.DistributeEvent(Event,Info);
      if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (Event === $mod.TDataEvent.deUpdateState) this.DoStateChange();
        if ((Event in OnDataChangeEvents) && NeedDataChange) this.DoDataChange(null);
        if (Event === $mod.TDataEvent.deFieldChange) this.DoDataChange(Info);
        if (Event === $mod.TDataEvent.deUpdateRecord) this.DoUpdateData();
      };
    };
    this.SetDataSet = function (ADataSet) {
      if (this.FDataSet !== null) {
        this.FDataSet.UnRegisterDataSource(this);
        this.FDataSet = null;
        this.ProcessEvent($mod.TDataEvent.deUpdateState,0);
      };
      if (ADataSet !== null) {
        ADataSet.RegisterDataSource(this);
        this.FDataSet = ADataSet;
        this.ProcessEvent($mod.TDataEvent.deUpdateState,0);
      };
    };
    this.SetEnabled = function (Value) {
      this.FEnabled = Value;
      this.ProcessEvent($mod.TDataEvent.deUpdateState,0);
    };
    this.UnregisterDataLink = function (DataLink) {
      this.FDataLinks.Remove(DataLink);
      if (this.FDataSet !== null) this.FDataSet.RecalcBufListSize();
    };
    this.DoDataChange = function (Info) {
      if (this.FOnDataChange != null) if (Info != null) {
        this.FOnDataChange(this,Info)}
       else this.FOnDataChange(this,null);
    };
    this.DoStateChange = function () {
      if (this.FOnStateChange != null) this.FOnStateChange(this);
    };
    this.DoUpdateData = function () {
      if (this.FOnUpdateData != null) this.FOnUpdateData(this);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FDataLinks = pas.Classes.TList.$create("Create$1");
      this.FEnabled = true;
      this.FAutoEdit = true;
      return this;
    };
    this.Destroy = function () {
      this.FOnStateChange = null;
      this.SetDataSet(null);
      while (this.FDataLinks.GetCount() > 0) rtl.getObject(this.FDataLinks.Get(this.FDataLinks.GetCount() - 1)).SetDataSource(null);
      rtl.free(this,"FDataLinks");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Edit = function () {
      if ((this.FState === $mod.TDataSetState.dsBrowse) && this.FAutoEdit) this.FDataSet.Edit();
    };
    this.IsLinkedTo = function (ADataSet) {
      var Result = false;
      Result = false;
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AutoEdit",0,rtl.boolean,"FAutoEdit","FAutoEdit",4,{Default: true});
    $r.addProperty("DataSet",2,$mod.$rtti["TDataSet"],"FDataSet","SetDataSet");
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("OnStateChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnStateChange","FOnStateChange");
    $r.addProperty("OnDataChange",0,$mod.$rtti["TDataChangeEvent"],"FOnDataChange","FOnDataChange");
    $r.addProperty("OnUpdateData",0,pas.Classes.$rtti["TNotifyEvent"],"FOnUpdateData","FOnUpdateData");
  });
  this.TDataRequestResult = {"0": "rrFail", rrFail: 0, "1": "rrEOF", rrEOF: 1, "2": "rrOK", rrOK: 2};
  this.$rtti.$Enum("TDataRequestResult",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TDataRequestResult});
  this.$rtti.$MethodVar("TDataRequestEvent",{procsig: rtl.newTIProcSig([["ARequest",this.$rtti["TDataRequest"]]]), methodkind: 0});
  rtl.createClass(this,"TDataRequest",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBookmark = $mod.TBookmark.$new();
      this.FCurrent = $mod.TBookmark.$new();
      this.FDataset = null;
      this.FErrorMsg = "";
      this.FEvent = null;
      this.FLoadOptions = {};
      this.FRequestID = 0;
      this.FSuccess = 0;
      this.FData = undefined;
      this.FAfterRequest = null;
      this.FDataProxy = null;
    };
    this.$final = function () {
      this.FBookmark = undefined;
      this.FCurrent = undefined;
      this.FDataset = undefined;
      this.FEvent = undefined;
      this.FLoadOptions = undefined;
      this.FAfterRequest = undefined;
      this.FDataProxy = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.DoAfterRequest = function () {
      if (this.FAfterRequest != null) this.FAfterRequest(this);
    };
    this.Create$1 = function (aDataProxy, aOptions, aAfterRequest, aAfterLoad) {
      this.FDataProxy = aDataProxy;
      this.FLoadOptions = rtl.refSet(aOptions);
      this.FEvent = aAfterLoad;
      this.FAfterRequest = aAfterRequest;
      return this;
    };
  });
  this.$rtti.$ClassRef("TDataRequestClass",{instancetype: this.$rtti["TDataRequest"]});
  rtl.createClass(this,"TRecordUpdateDescriptor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBookmark = $mod.TBookmark.$new();
      this.FData = undefined;
      this.FDataset = null;
      this.FProxy = null;
      this.FResolveStatus = 0;
      this.FResolveError = "";
      this.FServerData = undefined;
      this.FStatus = 0;
    };
    this.$final = function () {
      this.FBookmark = undefined;
      this.FDataset = undefined;
      this.FProxy = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetResolveStatus = function (aValue) {
      this.FResolveStatus = aValue;
    };
    this.Reset = function () {
      this.FResolveStatus = $mod.TResolveStatus.rsUnresolved;
      this.FResolveError = "";
      this.FServerData = null;
    };
    this.Create$1 = function (aProxy, aDataset, aBookmark, AData, AStatus) {
      this.FDataset = aDataset;
      this.FBookmark.$assign(aBookmark);
      this.FData = AData;
      this.FStatus = AStatus;
      this.FProxy = aProxy;
      return this;
    };
    this.Resolve = function (aData) {
      this.SetResolveStatus($mod.TResolveStatus.rsResolved);
      this.FServerData = aData;
    };
    this.ResolveFailed = function (aError) {
      this.SetResolveStatus($mod.TResolveStatus.rsResolveFailed);
      this.FResolveError = aError;
    };
  });
  this.$rtti.$ClassRef("TRecordUpdateDescriptorClass",{instancetype: this.$rtti["TRecordUpdateDescriptor"]});
  rtl.createClass(this,"TRecordUpdateDescriptorList",pas.Classes.TFPList,function () {
    this.GetUpdate = function (AIndex) {
      var Result = null;
      Result = rtl.getObject(this.Get(AIndex));
      return Result;
    };
  });
  this.TUpdateBatchStatus = {"0": "ubsPending", ubsPending: 0, "1": "ubsProcessing", ubsProcessing: 1, "2": "ubsProcessed", ubsProcessed: 2, "3": "ubsResolved", ubsResolved: 3};
  this.$rtti.$Enum("TUpdateBatchStatus",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TUpdateBatchStatus});
  this.$rtti.$MethodVar("TResolveBatchEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARequest",this.$rtti["TRecordUpdateBatch"]]]), methodkind: 0});
  rtl.createClass(this,"TRecordUpdateBatch",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBatchID = 0;
      this.FDataset = null;
      this.FLastChangeIndex = 0;
      this.FList = null;
      this.FOnResolve = null;
      this.FOwnsList = false;
      this.FStatus = 0;
    };
    this.$final = function () {
      this.FDataset = undefined;
      this.FList = undefined;
      this.FOnResolve = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (aBatchID, AList, AOwnsList) {
      this.FBatchID = aBatchID;
      this.FList = AList;
      this.FOwnsList = AOwnsList;
      this.FStatus = $mod.TUpdateBatchStatus.ubsPending;
      return this;
    };
    this.Destroy = function () {
      if (this.FOwnsList) this.FreeList();
      pas.System.TObject.Destroy.call(this);
    };
    this.FreeList = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FList;
        }, set: function (v) {
          this.p.FList = v;
        }});
    };
  });
  this.$rtti.$ClassRef("TRecordUpdateBatchClass",{instancetype: this.$rtti["TRecordUpdateBatch"]});
  rtl.createClass(this,"TDataProxy",pas.Classes.TComponent,function () {
    this.GetDataRequestClass = function () {
      var Result = null;
      Result = $mod.TDataRequest;
      return Result;
    };
    this.GetUpdateDescriptorClass = function () {
      var Result = null;
      Result = $mod.TRecordUpdateDescriptor;
      return Result;
    };
    this.GetUpdateBatchClass = function () {
      var Result = null;
      Result = $mod.TRecordUpdateBatch;
      return Result;
    };
    this.ResolveBatch = function (aBatch) {
      try {
        if (aBatch.FOnResolve != null) aBatch.FOnResolve(this,aBatch);
      } finally {
        aBatch = rtl.freeLoc(aBatch);
      };
    };
    this.GetDataRequest = function (aOptions, aAfterRequest, aAfterLoad) {
      var Result = null;
      Result = this.GetDataRequestClass().$create("Create$1",[this,rtl.refSet(aOptions),aAfterRequest,aAfterLoad]);
      return Result;
    };
    this.GetUpdateDescriptor = function (aDataset, aBookmark, AData, AStatus) {
      var Result = null;
      Result = this.GetUpdateDescriptorClass().$create("Create$1",[this,aDataset,$mod.TBookmark.$clone(aBookmark),AData,AStatus]);
      return Result;
    };
    this.GetRecordUpdateBatch = function (aBatchID, AList, AOwnsList) {
      var Result = null;
      Result = this.GetUpdateBatchClass().$create("Create$1",[aBatchID,AList,AOwnsList]);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWideStringField",this.TStringField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWideMemoField",this.TMemoField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TShortintField",this.TIntegerField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TByteField",this.TIntegerField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSingleField",this.TFloatField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TExtendedField",this.TFloatField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCurrencyField",this.TFloatField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TBCDField",this.TFloatField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TFMTBcdField",this.TFloatField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSQLTimeStampField",this.TDateTimeField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSQLTimeStampOffsetField",this.TDateTimeField,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$StaticArray("FieldTypeNames$a",{dims: [52], eltype: rtl.string});
  this.FieldTypeNames = ["Unknown","String","SmallInt","Integer","Word","Boolean","Float","Currency","BCD","Date","Time","DateTime","Bytes","VarBytes","AutoInc","Blob","Memo","Graphic","FmtMemo","ParadoxOle","dBaseOle","TypedBinary","Cursor","FixedChar","WideString","LargeInt","ADT","Array","Reference","DataSet","OraBlob","OraClob","Variant","Interface","IDispatch","Guid","TimeStamp","FMTBcd","FixedWideChar","WideMemo","OraTimeStamp","OraInterval","LongWord","ShortInt","Byte","Extended","Connection","Params","Stream","TimeStampOffset","Object","Single"];
  this.$rtti.$StaticArray("DefaultFieldClasses$a",{dims: [52], eltype: this.$rtti["TFieldClass"]});
  this.DefaultFieldClasses = [null,this.TStringField,this.TSmallIntField,this.TIntegerField,this.TWordField,this.TBooleanField,this.TFloatField,this.TCurrencyField,this.TBCDField,this.TDateField,this.TTimeField,this.TDateTimeField,null,null,this.TAutoIncField,this.TBlobField,this.TMemoField,this.TGraphicField,this.TBlobField,this.TBlobField,this.TBlobField,this.TBlobField,null,this.TStringField,this.TWideStringField,this.TLargeintField,null,null,null,this.TDataSetField,this.TBlobField,this.TMemoField,this.TVariantField,null,null,null,this.TSQLTimeStampField,this.TFMTBcdField,this.TWideStringField,this.TWideMemoField,null,this.TStringField,null,this.TShortintField,this.TByteField,this.TExtendedField,null,null,null,this.TSQLTimeStampOffsetField,null,this.TSingleField];
  this.dsEditModes = rtl.createSet(this.TDataSetState.dsEdit,this.TDataSetState.dsInsert,this.TDataSetState.dsSetKey);
  this.dsWriteModes = rtl.createSet(this.TDataSetState.dsEdit,this.TDataSetState.dsInsert,this.TDataSetState.dsSetKey,this.TDataSetState.dsCalcFields,this.TDataSetState.dsFilter,this.TDataSetState.dsNewValue,this.TDataSetState.dsInternalCalc,this.TDataSetState.dsRefreshFields);
  this.DatabaseError = function (Msg) {
    throw $mod.EDatabaseError.$create("Create$1",[Msg]);
  };
  this.DatabaseError$1 = function (Msg, Comp) {
    if ((Comp != null) && (Comp.FName !== "")) {
      throw $mod.EDatabaseError.$create("CreateFmt",["%s : %s",pas.System.VarRecs(18,Comp.FName,18,Msg)])}
     else $mod.DatabaseError(Msg);
  };
  this.DatabaseErrorFmt = function (Fmt, Args) {
    throw $mod.EDatabaseError.$create("CreateFmt",[Fmt,Args]);
  };
  this.DatabaseErrorFmt$1 = function (Fmt, Args, Comp) {
    if (Comp != null) {
      throw $mod.EDatabaseError.$create("CreateFmt",[pas.SysUtils.Format("%s : %s",pas.System.VarRecs(18,Comp.FName,18,Fmt)),Args])}
     else $mod.DatabaseErrorFmt(Fmt,Args);
  };
  this.ExtractFieldName = function (Fields, Pos) {
    var Result = "";
    var i = 0;
    var FieldsLength = 0;
    i = Pos.get();
    FieldsLength = Fields.length;
    while ((i <= FieldsLength) && (Fields.charAt(i - 1) !== ";")) i += 1;
    Result = pas.SysUtils.Trim(pas.System.Copy(Fields,Pos.get(),i - Pos.get()));
    if ((i <= FieldsLength) && (Fields.charAt(i - 1) === ";")) i += 1;
    Pos.set(i);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.DefaultBufferCount = 10;
    $impl.SBoolean = "Boolean";
    $impl.SDateTime = "TDateTime";
    $impl.SFloat = "Float";
    $impl.SInteger = "Integer";
    $impl.SLargeInt = "NativeInt";
    $impl.SJSValue = "JSValue";
    $impl.SString = "String";
    $impl.SBytes = "Bytes";
    $impl.SkipQuotesString = function (S, p, QuoteChar, EscapeSlash, EscapeRepeat) {
      var notRepeatEscaped = false;
      p.set(p.get() + 1);
      do {
        notRepeatEscaped = true;
        while (!pas.SysUtils.CharInSet(S.charAt(p.get() - 1),["\x00",QuoteChar])) {
          if (EscapeSlash && (S.charAt(p.get() - 1) === "\\") && (p.get() < S.length)) {
            p.set(p.get() + 2)}
           else p.set(p.get() + 1);
        };
        if (S.charAt(p.get() - 1) === QuoteChar) {
          p.set(p.get() + 1);
          if ((S.charAt(p.get() - 1) === QuoteChar) && EscapeRepeat) {
            notRepeatEscaped = false;
            p.set(p.get() + 1);
          };
        };
      } while (!notRepeatEscaped);
    };
    $impl.SkipComments = function (S, p, EscapeSlash, EscapeRepeat) {
      var Result = false;
      Result = false;
      var $tmp = S.charAt(p.get() - 1);
      if (($tmp === "'") || ($tmp === '"') || ($tmp === "`")) {
        Result = true;
        $impl.SkipQuotesString(S,p,S.charAt(p.get() - 1),EscapeSlash,EscapeRepeat);
      } else if ($tmp === "-") {
        p.set(p.get() + 1);
        if (S.charAt(p.get() - 1) === "-") {
          Result = true;
          do {
            p.set(p.get() + 1);
          } while (!pas.SysUtils.CharInSet(S.charAt(p.get() - 1),["\n","\r","\x00"]));
          while (pas.SysUtils.CharInSet(S.charAt(p.get() - 1),["\n","\r"])) p.set(p.get() + 1);
        };
      } else if ($tmp === "/") {
        p.set(p.get() + 1);
        if (S.charAt(p.get() - 1) === "*") {
          Result = true;
          p.set(p.get() + 1);
          while (p.get() <= S.length) {
            if (S.charAt(p.get() - 1) === "*") {
              p.set(p.get() + 1);
              if (S.charAt(p.get() - 1) === "/") break;
            } else p.set(p.get() + 1);
          };
          if ((p.get() <= S.length) && (S.charAt(p.get() - 1) === "/")) p.set(p.get() + 1);
        };
      };
      return Result;
    };
  };
},["DBConst","TypInfo"]);
rtl.module("jsdelphisystem",["System"],function () {
  "use strict";
  var $mod = this;
});
rtl.module("StrUtils",["System","SysUtils","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.AnsiResemblesText = function (AText, AOther) {
    var Result = false;
    if ($mod.AnsiResemblesProc != null) {
      Result = $mod.AnsiResemblesProc(AText,AOther)}
     else Result = false;
    return Result;
  };
  this.AnsiContainsText = function (AText, ASubText) {
    var Result = false;
    Result = pas.System.Pos(pas.SysUtils.UpperCase(ASubText),pas.SysUtils.UpperCase(AText)) > 0;
    return Result;
  };
  this.AnsiStartsText = function (ASubText, AText) {
    var Result = false;
    if ((AText.length >= ASubText.length) && (ASubText !== "")) {
      Result = pas.SysUtils.SameText(ASubText,pas.System.Copy(AText,1,ASubText.length))}
     else Result = false;
    return Result;
  };
  this.AnsiEndsText = function (ASubText, AText) {
    var Result = false;
    if (AText.length >= ASubText.length) {
      Result = pas.SysUtils.SameText(ASubText,$mod.RightStr(AText,ASubText.length))}
     else Result = false;
    return Result;
  };
  this.AnsiReplaceText = function (AText, AFromText, AToText) {
    var Result = "";
    Result = pas.SysUtils.StringReplace(AText,AFromText,AToText,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
    return Result;
  };
  this.AnsiMatchText = function (AText, AValues) {
    var Result = false;
    Result = $mod.AnsiIndexText(AText,AValues) !== -1;
    return Result;
  };
  this.AnsiIndexText = function (AText, AValues) {
    var Result = 0;
    var i = 0;
    Result = -1;
    if (((rtl.length(AValues) - 1) === -1) || ((rtl.length(AValues) - 1) > 2147483647)) return Result;
    for (var $l = 0, $end = rtl.length(AValues) - 1; $l <= $end; $l++) {
      i = $l;
      if (pas.SysUtils.CompareText(AValues[i],AText) === 0) return i;
    };
    return Result;
  };
  this.StartsText = function (ASubText, AText) {
    var Result = false;
    Result = $mod.AnsiStartsText(ASubText,AText);
    return Result;
  };
  this.EndsText = function (ASubText, AText) {
    var Result = false;
    Result = $mod.AnsiEndsText(ASubText,AText);
    return Result;
  };
  this.ResemblesText = function (AText, AOther) {
    var Result = false;
    if ($mod.ResemblesProc != null) {
      Result = $mod.ResemblesProc(AText,AOther)}
     else Result = false;
    return Result;
  };
  this.ContainsText = function (AText, ASubText) {
    var Result = false;
    Result = $mod.AnsiContainsText(AText,ASubText);
    return Result;
  };
  this.MatchText = function (AText, AValues) {
    var Result = false;
    Result = $mod.AnsiMatchText(AText,AValues);
    return Result;
  };
  this.IndexText = function (AText, AValues) {
    var Result = 0;
    Result = $mod.AnsiIndexText(AText,AValues);
    return Result;
  };
  this.AnsiContainsStr = function (AText, ASubText) {
    var Result = false;
    Result = pas.System.Pos(ASubText,AText) > 0;
    return Result;
  };
  this.AnsiStartsStr = function (ASubText, AText) {
    var Result = false;
    if ((AText.length >= ASubText.length) && (ASubText !== "")) {
      Result = ASubText === pas.System.Copy(AText,1,ASubText.length)}
     else Result = false;
    return Result;
  };
  this.AnsiEndsStr = function (ASubText, AText) {
    var Result = false;
    if (AText.length >= ASubText.length) {
      Result = ASubText === $mod.RightStr(AText,ASubText.length)}
     else Result = false;
    return Result;
  };
  this.AnsiReplaceStr = function (AText, AFromText, AToText) {
    var Result = "";
    Result = pas.SysUtils.StringReplace(AText,AFromText,AToText,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.AnsiMatchStr = function (AText, AValues) {
    var Result = false;
    Result = $mod.AnsiIndexStr(AText,AValues) !== -1;
    return Result;
  };
  this.AnsiIndexStr = function (AText, AValues) {
    var Result = 0;
    var i = 0;
    Result = -1;
    if (((rtl.length(AValues) - 1) === -1) || ((rtl.length(AValues) - 1) > 2147483647)) return Result;
    for (var $l = 0, $end = rtl.length(AValues) - 1; $l <= $end; $l++) {
      i = $l;
      if (AValues[i] === AText) return i;
    };
    return Result;
  };
  this.MatchStr = function (AText, AValues) {
    var Result = false;
    Result = $mod.IndexStr(AText,AValues) !== -1;
    return Result;
  };
  this.IndexStr = function (AText, AValues) {
    var Result = 0;
    var i = 0;
    Result = -1;
    if (((rtl.length(AValues) - 1) === -1) || ((rtl.length(AValues) - 1) > 2147483647)) return Result;
    for (var $l = 0, $end = rtl.length(AValues) - 1; $l <= $end; $l++) {
      i = $l;
      if (AValues[i] === AText) return i;
    };
    return Result;
  };
  this.ContainsStr = function (AText, ASubText) {
    var Result = false;
    Result = $mod.AnsiContainsStr(AText,ASubText);
    return Result;
  };
  this.StartsStr = function (ASubText, AText) {
    var Result = false;
    Result = $mod.AnsiStartsStr(ASubText,AText);
    return Result;
  };
  this.EndsStr = function (ASubText, AText) {
    var Result = false;
    Result = $mod.AnsiEndsStr(ASubText,AText);
    return Result;
  };
  this.DupeString = function (AText, ACount) {
    var Result = "";
    var i = 0;
    Result = "";
    for (var $l = 1, $end = ACount; $l <= $end; $l++) {
      i = $l;
      Result = Result + AText;
    };
    return Result;
  };
  this.ReverseString = function (AText) {
    var Result = "";
    var i = 0;
    var j = 0;
    Result = rtl.strSetLength(Result,AText.length);
    i = 1;
    j = AText.length;
    while (i <= j) {
      Result = rtl.setCharAt(Result,i - 1,AText.charAt(((j - i) + 1) - 1));
      i += 1;
    };
    return Result;
  };
  this.AnsiReverseString = function (AText) {
    var Result = "";
    Result = $mod.ReverseString(AText);
    return Result;
  };
  this.StuffString = function (AText, AStart, ALength, ASubText) {
    var Result = "";
    var i = 0;
    var j = 0;
    var k = 0;
    j = ASubText.length;
    i = AText.length;
    if (AStart > i) AStart = i + 1;
    k = (i + 1) - AStart;
    if (ALength > k) ALength = k;
    Result = rtl.strSetLength(Result,(i + j) - ALength);
    Result = pas.System.Copy(AText,1,AStart - 1) + pas.System.Copy(ASubText,1,j) + pas.System.Copy(AText,AStart + ALength,(i + 1) - AStart - ALength);
    return Result;
  };
  this.RandomFrom = function (AValues) {
    var Result = "";
    if ((rtl.length(AValues) - 1) === -1) return "";
    Result = AValues[pas.System.Random((rtl.length(AValues) - 1) + 1)];
    return Result;
  };
  this.IfThen = function (AValue, ATrue, AFalse) {
    var Result = "";
    if (AValue) {
      Result = ATrue}
     else Result = AFalse;
    return Result;
  };
  this.NaturalCompareText = function (S1, S2) {
    var Result = 0;
    Result = $mod.NaturalCompareText$1(S1,S2,pas.SysUtils.FormatSettings.DecimalSeparator,pas.SysUtils.FormatSettings.ThousandSeparator);
    return Result;
  };
  this.NaturalCompareText$1 = function (Str1, Str2, ADecSeparator, AThousandSeparator) {
    var Result = 0;
    var Num1 = 0.0;
    var Num2 = 0.0;
    var pStr1 = 0;
    var pStr2 = 0;
    var Len1 = 0;
    var Len2 = 0;
    var TextLen1 = 0;
    var TextLen2 = 0;
    var TextStr1 = "";
    var TextStr2 = "";
    var i = 0;
    var j = 0;
    function Sign(AValue) {
      var Result = 0;
      if (AValue < 0) {
        Result = -1}
       else if (AValue > 0) {
        Result = 1}
       else Result = 0;
      return Result;
    };
    function IsNumber(ch) {
      var Result = false;
      Result = ch.charCodeAt() in rtl.createSet(null,48,57);
      return Result;
    };
    function GetInteger(aString, pch, Len) {
      var Result = 0.0;
      Result = 0;
      while ((pch.get() <= aString.length) && IsNumber(aString.charAt(pch.get() - 1))) {
        Result = ((Result * 10) + aString.charCodeAt(pch.get() - 1)) - 48;
        Len.set(Len.get() + 1);
        pch.set(pch.get() + 1);
      };
      return Result;
    };
    function GetChars() {
      TextLen1 = 0;
      while (!(Str1.charCodeAt((pStr1 + TextLen1) - 1) in rtl.createSet(null,48,57)) && ((pStr1 + TextLen1) <= Str1.length)) TextLen1 += 1;
      TextStr1 = "";
      i = 1;
      j = 0;
      while (i <= TextLen1) {
        TextStr1 = TextStr1 + Str1.charAt((pStr1 + j) - 1);
        i += 1;
        j += 1;
      };
      TextLen2 = 0;
      while (!(Str2.charCodeAt((pStr2 + TextLen2) - 1) in rtl.createSet(null,48,57)) && ((pStr2 + TextLen2) <= Str2.length)) TextLen2 += 1;
      i = 1;
      j = 0;
      while (i <= TextLen2) {
        TextStr2 = TextStr2 + Str2.charAt((pStr2 + j) - 1);
        i += 1;
        j += 1;
      };
    };
    if ((Str1 !== "") && (Str2 !== "")) {
      pStr1 = 1;
      pStr2 = 1;
      Result = 0;
      while ((pStr1 <= Str1.length) && (pStr2 <= Str2.length)) {
        TextLen1 = 1;
        TextLen2 = 1;
        Len1 = 0;
        Len2 = 0;
        while (Str1.charAt(pStr1 - 1) === " ") {
          pStr1 += 1;
          Len1 += 1;
        };
        while (Str2.charAt(pStr2 - 1) === " ") {
          pStr2 += 1;
          Len2 += 1;
        };
        if (IsNumber(Str1.charAt(pStr1 - 1)) && IsNumber(Str2.charAt(pStr2 - 1))) {
          Num1 = GetInteger(Str1,{get: function () {
              return pStr1;
            }, set: function (v) {
              pStr1 = v;
            }},{get: function () {
              return Len1;
            }, set: function (v) {
              Len1 = v;
            }});
          Num2 = GetInteger(Str2,{get: function () {
              return pStr2;
            }, set: function (v) {
              pStr2 = v;
            }},{get: function () {
              return Len2;
            }, set: function (v) {
              Len2 = v;
            }});
          if (Num1 < Num2) {
            Result = -1}
           else if (Num1 > Num2) {
            Result = 1}
           else {
            Result = Sign(Len1 - Len2);
          };
          pStr1 -= 1;
          pStr2 -= 1;
        } else {
          GetChars();
          if (TextStr1 !== TextStr2) {
            Result = pas.SysUtils.CompareText(TextStr1,TextStr2)}
           else Result = 0;
        };
        if (Result !== 0) break;
        pStr1 += TextLen1;
        pStr2 += TextLen2;
      };
    };
    Num1 = Str1.length;
    Num2 = Str2.length;
    if ((Result === 0) && (Num1 !== Num2)) {
      if (Num1 < Num2) {
        Result = -1}
       else Result = 1;
    };
    if (ADecSeparator === "") ;
    if (AThousandSeparator === "") ;
    return Result;
  };
  this.LeftStr = function (AText, ACount) {
    var Result = "";
    Result = pas.System.Copy(AText,1,ACount);
    return Result;
  };
  this.RightStr = function (AText, ACount) {
    var Result = "";
    var j = 0;
    var l = 0;
    l = AText.length;
    j = ACount;
    if (j > l) j = l;
    Result = pas.System.Copy(AText,(l - j) + 1,j);
    return Result;
  };
  this.MidStr = function (AText, AStart, ACount) {
    var Result = "";
    if ((ACount === 0) || (AStart > AText.length)) return "";
    Result = pas.System.Copy(AText,AStart,ACount);
    return Result;
  };
  this.RightBStr = function (AText, AByteCount) {
    var Result = "";
    Result = $mod.RightStr(AText,AByteCount);
    return Result;
  };
  this.MidBStr = function (AText, AByteStart, AByteCount) {
    var Result = "";
    Result = $mod.MidStr(AText,AByteStart,AByteCount);
    return Result;
  };
  this.AnsiLeftStr = function (AText, ACount) {
    var Result = "";
    Result = pas.System.Copy(AText,1,ACount);
    return Result;
  };
  this.AnsiRightStr = function (AText, ACount) {
    var Result = "";
    Result = pas.System.Copy(AText,(AText.length - ACount) + 1,ACount);
    return Result;
  };
  this.AnsiMidStr = function (AText, AStart, ACount) {
    var Result = "";
    Result = pas.System.Copy(AText,AStart,ACount);
    return Result;
  };
  this.LeftBStr = function (AText, AByteCount) {
    var Result = "";
    Result = $mod.LeftStr(AText,AByteCount);
    return Result;
  };
  this.$rtti.$DynArray("WordDelimiters$a",{eltype: rtl.char});
  this.WordDelimiters = [];
  this.SErrAmountStrings = "Amount of search and replace strings don't match";
  this.SInvalidRomanNumeral = "%s is not a valid Roman numeral";
  this.TStringSearchOption = {"0": "soDown", soDown: 0, "1": "soMatchCase", soMatchCase: 1, "2": "soWholeWord", soWholeWord: 2};
  this.$rtti.$Enum("TStringSearchOption",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TStringSearchOption});
  this.$rtti.$Set("TStringSearchOptions",{comptype: this.$rtti["TStringSearchOption"]});
  this.PosEx = function (SubStr, S, Offset) {
    var Result = 0;
    Result = (new String(S)).indexOf(SubStr,Offset - 1) + 1;
    return Result;
  };
  this.PosEx$1 = function (SubStr, S) {
    var Result = 0;
    Result = $mod.PosEx(SubStr,S,1);
    return Result;
  };
  this.PosEx$2 = function (c, S, Offset) {
    var Result = 0;
    Result = (new String(S)).indexOf(c,Offset - 1) + 1;
    return Result;
  };
  this.StringsReplace = function (S, OldPattern, NewPattern, Flags) {
    var Result = "";
    var pc = 0;
    var pcc = 0;
    var lastpc = 0;
    var strcount = 0;
    var ResStr = "";
    var CompStr = "";
    var Found = false;
    var sc = 0;
    sc = rtl.length(OldPattern);
    if (sc !== rtl.length(NewPattern)) throw pas.SysUtils.Exception.$create("Create$1",[$mod.SErrAmountStrings]);
    sc -= 1;
    if (pas.SysUtils.TStringReplaceFlag.rfIgnoreCase in Flags) {
      CompStr = pas.SysUtils.UpperCase(S);
      for (var $l = 0, $end = sc; $l <= $end; $l++) {
        strcount = $l;
        OldPattern[strcount] = pas.SysUtils.UpperCase(OldPattern[strcount]);
      };
    } else CompStr = S;
    ResStr = "";
    pc = 1;
    pcc = 1;
    lastpc = pc + S.length;
    while (pc < lastpc) {
      Found = false;
      for (var $l1 = 0, $end1 = sc; $l1 <= $end1; $l1++) {
        strcount = $l1;
        if (pas.System.Copy(CompStr,pc,OldPattern[strcount].length) === OldPattern[strcount]) {
          ResStr = ResStr + NewPattern[strcount];
          pc = pc + OldPattern[strcount].length;
          pcc = pcc + OldPattern[strcount].length;
          Found = true;
        };
      };
      if (!Found) {
        ResStr = ResStr + S.charAt(pcc - 1);
        pc += 1;
        pcc += 1;
      } else if (!(pas.SysUtils.TStringReplaceFlag.rfReplaceAll in Flags)) {
        ResStr = ResStr + pas.System.Copy(S,pcc,(S.length - pcc) + 1);
        break;
      };
    };
    Result = ResStr;
    return Result;
  };
  this.ReplaceStr = function (AText, AFromText, AToText) {
    var Result = "";
    Result = $mod.AnsiReplaceStr(AText,AFromText,AToText);
    return Result;
  };
  this.ReplaceText = function (AText, AFromText, AToText) {
    var Result = "";
    Result = $mod.AnsiReplaceText(AText,AFromText,AToText);
    return Result;
  };
  this.$rtti.$Int("TSoundexLength",{minvalue: 1, maxvalue: 2147483647, ordtype: 5});
  this.Soundex = function (AText, ALength) {
    var Result = "";
    var S = "\x00";
    var PS = "\x00";
    var I = 0;
    var L = 0;
    Result = "";
    PS = "\x00";
    if (AText.length > 0) {
      Result = pas.System.upcase(AText.charAt(0));
      I = 2;
      L = AText.length;
      while ((I <= L) && (Result.length < ALength)) {
        S = $impl.SScore.charAt(AText.charCodeAt(I - 1) - 1);
        if (!(S.charCodeAt() in rtl.createSet(48,105,PS.charCodeAt()))) Result = Result + S;
        if (S !== "i") PS = S;
        I += 1;
      };
    };
    L = Result.length;
    if (L < ALength) Result = Result + pas.System.StringOfChar("0",ALength - L);
    return Result;
  };
  this.Soundex$1 = function (AText) {
    var Result = "";
    Result = $mod.Soundex(AText,4);
    return Result;
  };
  this.$rtti.$Int("TSoundexIntLength",{minvalue: 1, maxvalue: 8, ordtype: 1});
  this.SoundexInt = function (AText, ALength) {
    var Result = 0;
    var SE = "";
    var I = 0;
    Result = -1;
    SE = $mod.Soundex(AText,ALength);
    if (SE.length > 0) {
      Result = SE.charCodeAt(1 - 1) - 65;
      if (ALength > 1) {
        Result = (Result * 26) + (SE.charCodeAt(2 - 1) - 48);
        for (var $l = 3, $end = ALength; $l <= $end; $l++) {
          I = $l;
          Result = (SE.charCodeAt(I - 1) - 48) + (Result * 7);
        };
      };
      Result = ALength + (Result * 9);
    };
    return Result;
  };
  this.SoundexInt$1 = function (AText) {
    var Result = 0;
    Result = $mod.SoundexInt(AText,4);
    return Result;
  };
  this.DecodeSoundexInt = function (AValue) {
    var Result = "";
    var I = 0;
    var Len = 0;
    Result = "";
    Len = AValue % 9;
    AValue = rtl.trunc(AValue / 9);
    for (var $l = Len; $l >= 3; $l--) {
      I = $l;
      Result = String.fromCharCode(48 + (AValue % 7)) + Result;
      AValue = rtl.trunc(AValue / 7);
    };
    if (Len > 1) {
      Result = String.fromCharCode(48 + (AValue % 26)) + Result;
      AValue = rtl.trunc(AValue / 26);
    };
    Result = String.fromCharCode(65 + AValue) + Result;
    return Result;
  };
  this.SoundexWord = function (AText) {
    var Result = 0;
    var S = "";
    S = $mod.Soundex(AText,4);
    Result = S.charCodeAt(1 - 1) - 65;
    Result = ((Result * 26) + S.charCodeAt(2 - 1)) - 48;
    Result = ((Result * 7) + S.charCodeAt(3 - 1)) - 48;
    Result = ((Result * 7) + S.charCodeAt(4 - 1)) - 48;
    return Result;
  };
  this.DecodeSoundexWord = function (AValue) {
    var Result = "";
    Result = String.fromCharCode(48 + (AValue % 7));
    AValue = rtl.trunc(AValue / 7);
    Result = String.fromCharCode(48 + (AValue % 7)) + Result;
    AValue = rtl.trunc(AValue / 7);
    Result = pas.SysUtils.IntToStr(AValue % 26) + Result;
    AValue = rtl.trunc(AValue / 26);
    Result = String.fromCharCode(65 + AValue) + Result;
    return Result;
  };
  this.SoundexSimilar = function (AText, AOther, ALength) {
    var Result = false;
    Result = $mod.Soundex(AText,ALength) === $mod.Soundex(AOther,ALength);
    return Result;
  };
  this.SoundexSimilar$1 = function (AText, AOther) {
    var Result = false;
    Result = $mod.SoundexSimilar(AText,AOther,4);
    return Result;
  };
  this.SoundexCompare = function (AText, AOther, ALength) {
    var Result = 0;
    Result = pas.SysUtils.AnsiCompareStr($mod.Soundex(AText,ALength),$mod.Soundex(AOther,ALength));
    return Result;
  };
  this.SoundexCompare$1 = function (AText, AOther) {
    var Result = 0;
    Result = $mod.SoundexCompare(AText,AOther,4);
    return Result;
  };
  this.SoundexProc = function (AText, AOther) {
    var Result = false;
    Result = $mod.SoundexSimilar$1(AText,AOther);
    return Result;
  };
  this.$rtti.$ProcVar("TCompareTextProc",{procsig: rtl.newTIProcSig([["AText",rtl.string,2],["AOther",rtl.string,2]],rtl.boolean)});
  this.AnsiResemblesProc = null;
  this.ResemblesProc = null;
  this.TRomanConversionStrictness = {"0": "rcsStrict", rcsStrict: 0, "1": "rcsRelaxed", rcsRelaxed: 1, "2": "rcsDontCare", rcsDontCare: 2};
  this.$rtti.$Enum("TRomanConversionStrictness",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TRomanConversionStrictness});
  this.IsEmptyStr = function (S, EmptyChars) {
    var Result = false;
    var i = 0;
    var l = 0;
    l = S.length;
    i = 1;
    Result = true;
    while (Result && (i <= l)) {
      Result = pas.SysUtils.CharInSet(S.charAt(i - 1),EmptyChars);
      i += 1;
    };
    return Result;
  };
  this.DelSpace = function (S) {
    var Result = "";
    Result = $mod.DelChars(S," ");
    return Result;
  };
  this.DelChars = function (S, Chr) {
    var Result = "";
    var I = 0;
    var J = 0;
    Result = S;
    I = Result.length;
    while (I > 0) {
      if (Result.charAt(I - 1) === Chr) {
        J = I - 1;
        while ((J > 0) && (Result.charAt(J - 1) === Chr)) J -= 1;
        pas.System.Delete({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},J + 1,I - J);
        I = J + 1;
      };
      I -= 1;
    };
    return Result;
  };
  this.DelSpace1 = function (S) {
    var Result = "";
    var I = 0;
    Result = S;
    for (var $l = Result.length; $l >= 2; $l--) {
      I = $l;
      if ((Result.charAt(I - 1) === " ") && (Result.charAt(I - 1 - 1) === " ")) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},I,1);
    };
    return Result;
  };
  this.Tab2Space = function (S, Numb) {
    var Result = "";
    var I = 0;
    I = 1;
    Result = S;
    while (I <= Result.length) if (Result.charAt(I - 1) !== String.fromCharCode(9)) {
      I += 1}
     else {
      Result = rtl.setCharAt(Result,I - 1," ");
      if (Numb > 1) pas.System.Insert(pas.System.StringOfChar(" ",Numb - 1),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},I);
      I += Numb;
    };
    return Result;
  };
  this.NPos = function (C, S, N) {
    var Result = 0;
    var i = 0;
    var p = 0;
    var k = 0;
    Result = 0;
    if (N < 1) return Result;
    k = 0;
    i = 1;
    do {
      p = pas.System.Pos(C,S);
      k += p;
      if (p > 0) pas.System.Delete({get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},1,p);
      i += 1;
    } while (!((i > N) || (p === 0)));
    if (p > 0) Result = k;
    return Result;
  };
  this.RPosEX = function (C, S, offs) {
    var Result = 0;
    Result = (new String(S)).lastIndexOf(C,offs - 1) + 1;
    return Result;
  };
  this.RPosex$1 = function (Substr, Source, offs) {
    var Result = 0;
    Result = (new String(Source)).lastIndexOf(Substr,offs - 1) + 1;
    return Result;
  };
  this.RPos = function (c, S) {
    var Result = 0;
    Result = $mod.RPosex$1(c,S,S.length);
    return Result;
  };
  this.RPos$1 = function (Substr, Source) {
    var Result = 0;
    Result = $mod.RPosex$1(Substr,Source,Source.length);
    return Result;
  };
  this.AddChar = function (C, S, N) {
    var Result = "";
    var l = 0;
    Result = S;
    l = Result.length;
    if (l < N) Result = pas.System.StringOfChar(C,N - l) + Result;
    return Result;
  };
  this.AddCharR = function (C, S, N) {
    var Result = "";
    var l = 0;
    Result = S;
    l = Result.length;
    if (l < N) Result = Result + pas.System.StringOfChar(C,N - l);
    return Result;
  };
  this.PadLeft = function (S, N) {
    var Result = "";
    Result = $mod.AddChar(" ",S,N);
    return Result;
  };
  this.PadRight = function (S, N) {
    var Result = "";
    Result = $mod.AddCharR(" ",S,N);
    return Result;
  };
  this.PadCenter = function (S, Len) {
    var Result = "";
    if (S.length < Len) {
      Result = pas.System.StringOfChar(" ",rtl.trunc(Len / 2) - rtl.trunc(S.length / 2)) + S;
      Result = Result + pas.System.StringOfChar(" ",Len - Result.length);
    } else Result = S;
    return Result;
  };
  this.Copy2Symb = function (S, Symb) {
    var Result = "";
    var p = 0;
    p = pas.System.Pos(Symb,S);
    if (p === 0) p = S.length + 1;
    Result = pas.System.Copy(S,1,p - 1);
    return Result;
  };
  this.Copy2SymbDel = function (S, Symb) {
    var Result = "";
    var p = 0;
    p = pas.System.Pos(Symb,S.get());
    if (p === 0) {
      Result = S.get();
      S.set("");
    } else {
      Result = pas.System.Copy(S.get(),1,p - 1);
      pas.System.Delete(S,1,p);
    };
    return Result;
  };
  this.Copy2Space = function (S) {
    var Result = "";
    Result = $mod.Copy2Symb(S," ");
    return Result;
  };
  this.Copy2SpaceDel = function (S) {
    var Result = "";
    Result = $mod.Copy2SymbDel(S," ");
    return Result;
  };
  this.AnsiProperCase = function (S, WordDelims) {
    var Result = "";
    var P = 0;
    var L = 0;
    Result = pas.SysUtils.LowerCase(S);
    P = 1;
    L = Result.length;
    while (P <= L) {
      while ((P <= L) && pas.SysUtils.CharInSet(Result.charAt(P - 1),WordDelims)) P += 1;
      if (P <= L) Result = rtl.setCharAt(Result,P - 1,pas.System.upcase(Result.charAt(P - 1)));
      while ((P <= L) && !pas.SysUtils.CharInSet(Result.charAt(P - 1),WordDelims)) P += 1;
    };
    return Result;
  };
  this.WordCount = function (S, WordDelims) {
    var Result = 0;
    var P = 0;
    var L = 0;
    Result = 0;
    P = 1;
    L = S.length;
    while (P <= L) {
      while ((P <= L) && pas.SysUtils.CharInSet(S.charAt(P - 1),WordDelims)) P += 1;
      if (P <= L) Result += 1;
      while ((P <= L) && !pas.SysUtils.CharInSet(S.charAt(P - 1),WordDelims)) P += 1;
    };
    return Result;
  };
  this.WordPosition = function (N, S, WordDelims) {
    var Result = 0;
    var PS = 0;
    var P = 0;
    var PE = 0;
    var Count = 0;
    Result = 0;
    Count = 0;
    PS = 1;
    PE = S.length;
    P = PS;
    while ((P <= PE) && (Count !== N)) {
      while ((P <= PE) && pas.SysUtils.CharInSet(S.charAt(P - 1),WordDelims)) P += 1;
      if (P <= PE) Count += 1;
      if (Count !== N) {
        while ((P <= PE) && !pas.SysUtils.CharInSet(S.charAt(P - 1),WordDelims)) P += 1}
       else Result = (P - PS) + 1;
    };
    return Result;
  };
  this.ExtractWord = function (N, S, WordDelims) {
    var Result = "";
    var i = 0;
    Result = $mod.ExtractWordPos(N,S,WordDelims,{get: function () {
        return i;
      }, set: function (v) {
        i = v;
      }});
    return Result;
  };
  this.ExtractWordPos = function (N, S, WordDelims, Pos) {
    var Result = "";
    var i = 0;
    var j = 0;
    var l = 0;
    j = 0;
    i = $mod.WordPosition(N,S,WordDelims);
    if (i > 2147483647) {
      Result = "";
      Pos.set(-1);
      return Result;
    };
    Pos.set(i);
    if (i !== 0) {
      j = i;
      l = S.length;
      while ((j <= l) && !pas.SysUtils.CharInSet(S.charAt(j - 1),WordDelims)) j += 1;
    };
    Result = pas.System.Copy(S,i,j - i);
    return Result;
  };
  this.ExtractDelimited = function (N, S, Delims) {
    var Result = "";
    var w = 0;
    var i = 0;
    var l = 0;
    var len = 0;
    w = 0;
    i = 1;
    l = 0;
    len = S.length;
    Result = rtl.strSetLength(Result,0);
    while ((i <= len) && (w !== N)) {
      if (pas.SysUtils.CharInSet(S.charAt(i - 1),Delims)) {
        w += 1}
       else {
        if ((N - 1) === w) {
          l += 1;
          Result = Result + S.charAt(i - 1);
        };
      };
      i += 1;
    };
    return Result;
  };
  this.ExtractSubstr = function (S, Pos, Delims) {
    var Result = "";
    var i = 0;
    var l = 0;
    i = Pos.get();
    l = S.length;
    while ((i <= l) && !pas.SysUtils.CharInSet(S.charAt(i - 1),Delims)) i += 1;
    Result = pas.System.Copy(S,Pos.get(),i - Pos.get());
    while ((i <= l) && pas.SysUtils.CharInSet(S.charAt(i - 1),Delims)) i += 1;
    if (i > 2147483647) {
      Pos.set(2147483647)}
     else Pos.set(i);
    return Result;
  };
  this.IsWordPresent = function (W, S, WordDelims) {
    var Result = false;
    var i = 0;
    var Count = 0;
    Result = false;
    Count = $mod.WordCount(S,WordDelims);
    i = 1;
    while (!Result && (i <= Count)) {
      Result = $mod.ExtractWord(i,S,WordDelims) === W;
      i += 1;
    };
    return Result;
  };
  this.FindPart = function (HelpWilds, InputStr) {
    var Result = 0;
    var Diff = 0;
    var i = 0;
    var J = 0;
    Result = 0;
    i = pas.System.Pos("?",HelpWilds);
    if (i === 0) {
      Result = pas.System.Pos(HelpWilds,InputStr)}
     else {
      Diff = InputStr.length - HelpWilds.length;
      for (var $l = 0, $end = Diff; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 1, $end1 = HelpWilds.length; $l1 <= $end1; $l1++) {
          J = $l1;
          if ((InputStr.charAt((i + J) - 1) === HelpWilds.charAt(J - 1)) || (HelpWilds.charAt(J - 1) === "?")) {
            if (J === HelpWilds.length) {
              Result = i + 1;
              return Result;
            };
          } else break;
        };
      };
    };
    return Result;
  };
  this.IsWild = function (InputStr, Wilds, IgnoreCase) {
    var Result = false;
    var i = 0;
    var MaxinputWord = 0;
    var MaxWilds = 0;
    var eos = false;
    Result = true;
    if (Wilds === InputStr) return Result;
    i = pas.System.Pos("**",Wilds);
    while (i > 0) {
      pas.System.Delete({get: function () {
          return Wilds;
        }, set: function (v) {
          Wilds = v;
        }},i,1);
      i = pas.System.Pos("**",Wilds);
    };
    if (Wilds === "*") return Result;
    MaxinputWord = InputStr.length;
    MaxWilds = Wilds.length;
    if ((MaxWilds === 0) || (MaxinputWord === 0)) {
      Result = false;
      return Result;
    };
    if (IgnoreCase) {
      InputStr = pas.SysUtils.UpperCase(InputStr);
      Wilds = pas.SysUtils.UpperCase(Wilds);
    };
    Result = $impl.isMatch(1,InputStr,Wilds,1,1,MaxinputWord,MaxWilds,{get: function () {
        return eos;
      }, set: function (v) {
        eos = v;
      }});
    return Result;
  };
  this.XorString = function (Key, Src) {
    var Result = "";
    var i = 0;
    Result = Src;
    if (Key.length > 0) for (var $l = 1, $end = Src.length; $l <= $end; $l++) {
      i = $l;
      Result = rtl.setCharAt(Result,i - 1,String.fromCharCode(Key.charCodeAt((1 + ((i - 1) % Key.length)) - 1) ^ Src.charCodeAt(i - 1)));
    };
    return Result;
  };
  this.XorEncode = function (Key, Source) {
    var Result = "";
    var i = 0;
    var C = 0;
    Result = "";
    for (var $l = 1, $end = Source.length; $l <= $end; $l++) {
      i = $l;
      if (Key.length > 0) {
        C = Key.charCodeAt((1 + ((i - 1) % Key.length)) - 1) ^ Source.charCodeAt(i - 1)}
       else C = Source.charCodeAt(i - 1);
      Result = Result + pas.SysUtils.LowerCase(pas.SysUtils.IntToHex(C,2));
    };
    return Result;
  };
  this.XorDecode = function (Key, Source) {
    var Result = "";
    var i = 0;
    var C = "\x00";
    Result = "";
    for (var $l = 0, $end = rtl.trunc(Source.length / 2) - 1; $l <= $end; $l++) {
      i = $l;
      C = String.fromCharCode(pas.SysUtils.StrToIntDef("$" + pas.System.Copy(Source,(i * 2) + 1,2),32));
      if (Key.length > 0) C = String.fromCharCode(Key.charCodeAt((1 + (i % Key.length)) - 1) ^ C.charCodeAt());
      Result = Result + C;
    };
    return Result;
  };
  this.GetCmdLineArg = function (Switch, SwitchChars) {
    var Result = "";
    var i = 0;
    var S = "";
    i = 1;
    Result = "";
    while ((Result === "") && (i <= pas.System.ParamCount())) {
      S = pas.System.ParamStr(i);
      if ((rtl.length(SwitchChars) === 0) || (pas.SysUtils.CharInSet(S.charAt(0),SwitchChars) && (S.length > 1) && (pas.SysUtils.CompareText(pas.System.Copy(S,2,S.length - 1),Switch) === 0))) {
        i += 1;
        if (i <= pas.System.ParamCount()) Result = pas.System.ParamStr(i);
      };
      i += 1;
    };
    return Result;
  };
  this.Numb2USA = function (S) {
    var Result = "";
    var i = 0;
    var NA = 0;
    i = S.length;
    Result = S;
    NA = 0;
    while (i > 0) {
      if ((((((Result.length - i) + 1) - NA) % 3) === 0) && (i !== 1)) {
        pas.System.Insert(",",{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},i);
        NA += 1;
      };
      i -= 1;
    };
    return Result;
  };
  this.Hex2Dec = function (S) {
    var Result = 0;
    var HexStr = "";
    if (pas.System.Pos("$",S) === 0) {
      HexStr = "$" + S}
     else HexStr = S;
    Result = pas.SysUtils.StrToInt(HexStr);
    return Result;
  };
  this.Dec2Numb = function (N, Len, Base) {
    var Result = "";
    var C = 0;
    var number = 0;
    if (N === 0) {
      Result = "0"}
     else {
      number = N;
      Result = "";
      while (number > 0) {
        C = number % Base;
        if (C > 9) {
          C = C + 55}
         else C = C + 48;
        Result = String.fromCharCode(C) + Result;
        number = rtl.trunc(number / Base);
      };
    };
    if (Result !== "") Result = $mod.AddChar("0",Result,Len);
    return Result;
  };
  this.Numb2Dec = function (S, Base) {
    var Result = 0;
    var i = 0;
    var P = 0;
    i = S.length;
    Result = 0;
    S = pas.SysUtils.UpperCase(S);
    P = 1;
    while (i >= 1) {
      if (S.charAt(i - 1) > "@") {
        Result = Result + ((S.charCodeAt(i - 1) - 55) * P)}
       else Result = Result + ((S.charCodeAt(i - 1) - 48) * P);
      i -= 1;
      P = P * Base;
    };
    return Result;
  };
  this.IntToBin = function (Value, Digits, Spaces) {
    var Result = "";
    var endpos = 0;
    var p = 0;
    var p2 = 0;
    var k = 0;
    Result = "";
    if (Digits > 32) Digits = 32;
    if (Spaces === 0) {
      Result = $mod.IntToBin$1(Value,Digits);
      return Result;
    };
    endpos = Digits + rtl.trunc((Digits - 1) / Spaces);
    Result = rtl.strSetLength(Result,endpos);
    p = endpos;
    p2 = 1;
    k = Spaces;
    while (p >= p2) {
      if (k === 0) {
        Result = rtl.setCharAt(Result,p - 1," ");
        p -= 1;
        k = Spaces;
      };
      Result = rtl.setCharAt(Result,p - 1,String.fromCharCode(48 + ((Value >>> 0) & 1)));
      Value = rtl.lw((Value >>> 0) >>> 1);
      p -= 1;
      k -= 1;
    };
    return Result;
  };
  this.IntToBin$1 = function (Value, Digits) {
    var Result = "";
    var p = 0;
    var p2 = 0;
    Result = "";
    if (Digits <= 0) return Result;
    Result = rtl.strSetLength(Result,Digits);
    p = Digits;
    p2 = 1;
    while ((p >= p2) && ((Value >>> 0) > 0)) {
      Result = rtl.setCharAt(Result,p - 1,String.fromCharCode(48 + ((Value >>> 0) & 1)));
      Value = rtl.lw((Value >>> 0) >>> 1);
      p -= 1;
    };
    Digits = (p - p2) + 1;
    while (Digits > 0) {
      Result = rtl.setCharAt(Result,Digits - 1,String.fromCharCode(48));
      Digits -= 1;
    };
    return Result;
  };
  this.IntToBin$2 = function (Value, Digits) {
    var Result = "";
    var p = 0;
    var p2 = 0;
    Result = "";
    if (Digits <= 0) return Result;
    Result = rtl.strSetLength(Result,Digits);
    p = Digits;
    p2 = 1;
    while ((p >= p2) && (Value > 0)) {
      Result = rtl.setCharAt(Result,p - 1,String.fromCharCode(48 + ((Value >>> 0) & 1)));
      Value = rtl.trunc(Value / 2);
      p -= 1;
    };
    Digits = (p - p2) + 1;
    while (Digits > 0) Result = rtl.setCharAt(Result,Digits - 1,"0");
    return Result;
  };
  var Arabics = [1,4,5,9,10,40,50,90,100,400,500,900,1000];
  var Romans = ["I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"];
  this.IntToRoman = function (Value) {
    var Result = "";
    var i = 0;
    Result = "";
    for (var $l = 13; $l >= 1; $l--) {
      i = $l;
      while (Value >= Arabics[i - 1]) {
        Value = Value - Arabics[i - 1];
        Result = Result + Romans[i - 1];
      };
    };
    return Result;
  };
  this.TryRomanToInt = function (S, N, Strictness) {
    var Result = false;
    var i = 0;
    var Len = 0;
    var Terminated = false;
    Result = false;
    S = pas.SysUtils.UpperCase(S);
    Len = S.length;
    if (Strictness === $mod.TRomanConversionStrictness.rcsDontCare) {
      N.set($impl.RomanToIntDontCare(S));
      if (N.get() === 0) {
        Result = Len === 0;
      } else Result = true;
      return Result;
    };
    if (Len === 0) return Result;
    i = 1;
    N.set(0);
    Terminated = false;
    while ((i <= Len) && ((Strictness !== $mod.TRomanConversionStrictness.rcsStrict) || (i < 4)) && (S.charAt(i - 1) === "M")) {
      i += 1;
      N.set(N.get() + 1000);
    };
    if ((i <= Len) && (S.charAt(i - 1) === "D")) {
      i += 1;
      N.set(N.get() + 500);
    } else if (((i + 1) <= Len) && (S.charAt(i - 1) === "C")) {
      if (S.charAt((i + 1) - 1) === "M") {
        i += 2;
        N.set(N.get() + 900);
      } else if (S.charAt((i + 1) - 1) === "D") {
        i += 2;
        N.set(N.get() + 400);
      };
    };
    if ((i <= Len) && (S.charAt(i - 1) === "C")) {
      i += 1;
      N.set(N.get() + 100);
      if ((i <= Len) && (S.charAt(i - 1) === "C")) {
        i += 1;
        N.set(N.get() + 100);
      };
      if ((i <= Len) && (S.charAt(i - 1) === "C")) {
        i += 1;
        N.set(N.get() + 100);
      };
      if ((Strictness !== $mod.TRomanConversionStrictness.rcsStrict) && (i <= Len) && (S.charAt(i - 1) === "C")) {
        i += 1;
        N.set(N.get() + 100);
      };
    };
    if (((i + 1) <= Len) && (S.charAt(i - 1) === "X")) {
      if (S.charAt((i + 1) - 1) === "C") {
        i += 2;
        N.set(N.get() + 90);
      } else if (S.charAt((i + 1) - 1) === "L") {
        i += 2;
        N.set(N.get() + 40);
      };
    };
    if ((i <= Len) && (S.charAt(i - 1) === "L")) {
      i += 1;
      N.set(N.get() + 50);
    };
    if ((i <= Len) && (S.charAt(i - 1) === "X")) {
      i += 1;
      N.set(N.get() + 10);
      if ((i <= Len) && (S.charAt(i - 1) === "X")) {
        i += 1;
        N.set(N.get() + 10);
      };
      if ((i <= Len) && (S.charAt(i - 1) === "X")) {
        i += 1;
        N.set(N.get() + 10);
      };
      if ((Strictness !== $mod.TRomanConversionStrictness.rcsStrict) && (i <= Len) && (S.charAt(i - 1) === "X")) {
        i += 1;
        N.set(N.get() + 10);
      };
    };
    if (((i + 1) <= Len) && (S.charAt(i - 1) === "I")) {
      if (S.charAt((i + 1) - 1) === "X") {
        Terminated = true;
        i += 2;
        N.set(N.get() + 9);
      } else if (S.charAt((i + 1) - 1) === "V") {
        Terminated = true;
        i += 2;
        N.set(N.get() + 4);
      };
    };
    if (!Terminated && (i <= Len) && (S.charAt(i - 1) === "V")) {
      i += 1;
      N.set(N.get() + 5);
    };
    if (!Terminated && (i <= Len) && (S.charAt(i - 1) === "I")) {
      Terminated = true;
      i += 1;
      N.set(N.get() + 1);
      if ((i <= Len) && (S.charAt(i - 1) === "I")) {
        i += 1;
        N.set(N.get() + 1);
      };
      if ((i <= Len) && (S.charAt(i - 1) === "I")) {
        i += 1;
        N.set(N.get() + 1);
      };
      if ((Strictness !== $mod.TRomanConversionStrictness.rcsStrict) && (i <= Len) && (S.charAt(i - 1) === "I")) {
        i += 1;
        N.set(N.get() + 1);
      };
    };
    Result = i > Len;
    return Result;
  };
  this.RomanToInt = function (S, Strictness) {
    var Result = 0;
    if (!$mod.TryRomanToInt(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},Strictness)) throw pas.SysUtils.EConvertError.$create("CreateFmt",[$mod.SInvalidRomanNumeral,pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.RomanToIntDef = function (S, ADefault, Strictness) {
    var Result = 0;
    if (!$mod.TryRomanToInt(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},Strictness)) Result = ADefault;
    return Result;
  };
  this.DigitChars = rtl.createSet(null,48,57);
  this.Brackets = rtl.createSet(40,41,91,93,123,125);
  this.StdWordDelims = rtl.unionSet(rtl.createSet(null,0,32,44,46,59,47,92,58,39,34,96),this.Brackets);
  this.StdSwitchChars = rtl.createSet(45,47);
  this.PosSet = function (c, s) {
    var Result = 0;
    Result = $mod.PosSetEx(c,s,1);
    return Result;
  };
  this.PosSet$1 = function (c, s) {
    var Result = 0;
    Result = $mod.PosSetEx$1(c,s,1);
    return Result;
  };
  this.PosSetEx = function (c, s, count) {
    var Result = 0;
    var i = 0;
    var j = 0;
    if (s === "") {
      j = 0}
     else {
      i = s.length;
      j = count;
      if (j > i) {
        Result = 0;
        return Result;
      };
      while ((j <= i) && !pas.SysUtils.CharInSet(s.charAt(j - 1),c)) j += 1;
      if (j > i) j = 0;
    };
    Result = j;
    return Result;
  };
  this.PosSetEx$1 = function (c, s, count) {
    var Result = 0;
    var cset = [];
    var i = 0;
    var l = 0;
    l = c.length;
    cset = rtl.arraySetLength(cset,"\x00",l);
    if (l > 0) for (var $l = 1, $end = l; $l <= $end; $l++) {
      i = $l;
      cset[i - 1] = c.charAt(i - 1);
    };
    Result = $mod.PosSetEx(cset,s,count);
    return Result;
  };
  this.Removeleadingchars = function (S, CSet) {
    var I = 0;
    var J = 0;
    I = S.get().length;
    if (I > 0) {
      J = 1;
      while ((J <= I) && pas.SysUtils.CharInSet(S.get().charAt(J - 1),CSet)) J += 1;
      if (J > 1) pas.System.Delete(S,1,J - 1);
    };
  };
  this.RemoveTrailingChars = function (S, CSet) {
    var i = 0;
    var j = 0;
    i = S.get().length;
    if (i > 0) {
      j = i;
      while ((j > 0) && pas.SysUtils.CharInSet(S.get().charAt(j - 1),CSet)) j -= 1;
      if (j !== i) S.set(rtl.strSetLength(S.get(),j));
    };
  };
  this.RemovePadChars = function (S, CSet) {
    var I = 0;
    var J = 0;
    var K = 0;
    I = S.get().length;
    if (I === 0) return;
    J = I;
    while ((J > 0) && pas.SysUtils.CharInSet(S.get().charAt(J - 1),CSet)) J -= 1;
    if (J === 0) {
      S.set("");
      return;
    };
    S.set(rtl.strSetLength(S.get(),J));
    I = J;
    K = 1;
    while ((K <= I) && pas.SysUtils.CharInSet(S.get().charAt(K - 1),CSet)) K += 1;
    if (K > 1) pas.System.Delete(S,1,K - 1);
  };
  this.TrimLeftSet = function (S, CSet) {
    var Result = "";
    Result = S;
    $mod.Removeleadingchars({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},CSet);
    return Result;
  };
  this.TrimRightSet = function (S, CSet) {
    var Result = "";
    Result = S;
    $mod.RemoveTrailingChars({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},CSet);
    return Result;
  };
  this.TrimSet = function (S, CSet) {
    var Result = "";
    Result = S;
    $mod.RemovePadChars({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},CSet);
    return Result;
  };
  this.SplitString = function (S, Delimiters) {
    var Result = [];
    Result = pas.SysUtils.TStringHelper.Split.call({get: function () {
        return S;
      }, set: function (v) {
        rtl.raiseE("EPropReadOnly");
      }},Delimiters);
    return Result;
  };
  this.$rtti.$DynArray("SizeIntArray",{eltype: rtl.nativeint});
  $mod.$implcode = function () {
    $impl.SScore = "00000000000000000000000000000000" + "00000000000000000000000000000000" + "0123012i02245501262301i2i2" + "000000" + "0123012i02245501262301i2i2" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000";
    $impl.Ord0 = 48;
    $impl.OrdA = 65;
    $impl.RomanValues = function (C) {
      var Result = 0;
      var $tmp = C;
      if ($tmp === "C") {
        Result = 100}
       else if ($tmp === "D") {
        Result = 500}
       else if ($tmp === "I") {
        Result = 1}
       else if ($tmp === "L") {
        Result = 50}
       else if ($tmp === "M") {
        Result = 1000}
       else if ($tmp === "V") {
        Result = 5}
       else if ($tmp === "X") {
        Result = 10}
       else {
        Result = 0;
      };
      return Result;
    };
    var RomanChars = rtl.createSet(67,68,73,76,77,86,88);
    $impl.RomanToIntDontCare = function (S) {
      var Result = 0;
      var index = "\x00";
      var Next = "\x00";
      var i = 0;
      var l = 0;
      var Negative = false;
      Result = 0;
      i = 0;
      Negative = (S.length > 0) && (S.charAt(0) === "-");
      if (Negative) i += 1;
      l = S.length;
      while (i < l) {
        i += 1;
        index = pas.System.upcase(S.charAt(i - 1));
        if (index.charCodeAt() in RomanChars) {
          if ((i + 1) <= l) {
            Next = pas.System.upcase(S.charAt((i + 1) - 1))}
           else Next = "\x00";
          if ((Next.charCodeAt() in RomanChars) && ($impl.RomanValues(index) < $impl.RomanValues(Next))) {
            Result += $impl.RomanValues(Next);
            Result -= $impl.RomanValues(index);
            i += 1;
          } else Result += $impl.RomanValues(index);
        } else {
          Result = 0;
          return Result;
        };
      };
      if (Negative) Result = -Result;
      return Result;
    };
    $impl.isMatch = function (level, inputstr, wilds, CWild, CinputWord, MaxInputword, maxwilds, EOS) {
      var Result = false;
      EOS.set(false);
      Result = true;
      do {
        if (wilds.charAt(CWild - 1) === "*") {
          CWild += 1;
          while (wilds.charAt(CWild - 1) === "?") {
            CWild += 1;
            CinputWord += 1;
          };
          do {
            while ((inputstr.charAt(CinputWord - 1) !== wilds.charAt(CWild - 1)) && (CinputWord <= MaxInputword)) CinputWord += 1;
            Result = $impl.isMatch(level + 1,inputstr,wilds,CWild,CinputWord,MaxInputword,maxwilds,EOS);
            if (!Result) CinputWord += 1;
          } while (!(Result || (CinputWord >= MaxInputword)));
          if (Result && EOS.get()) return Result;
          continue;
        };
        if (wilds.charAt(CWild - 1) === "?") {
          CWild += 1;
          CinputWord += 1;
          continue;
        };
        if (inputstr.charAt(CinputWord - 1) === wilds.charAt(CWild - 1)) {
          CWild += 1;
          CinputWord += 1;
          continue;
        };
        Result = false;
        return Result;
      } while (!((CinputWord > MaxInputword) || (CWild > maxwilds)));
      if ((CinputWord <= MaxInputword) || (CWild < maxwilds)) {
        Result = false}
       else if (CWild > maxwilds) {
        EOS.set(false)}
       else {
        EOS.set(wilds.charAt(CWild - 1) === "*");
        if (!EOS.get()) Result = false;
      };
      return Result;
    };
  };
  $mod.$init = function () {
    $mod.AnsiResemblesProc = $mod.SoundexProc;
    $mod.ResemblesProc = $mod.SoundexProc;
  };
},["JS"]);
rtl.module("WEBLib.Mask",["System","Classes","SysUtils","StrUtils","WEBLib.Controls","WEBLib.StdCtrls","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TMaskedState$a = {"0": "mStateMasked", mStateMasked: 0, "1": "mStateReEnter", mStateReEnter: 1, "2": "mStateDBSetText", mStateDBSetText: 2};
  this.$rtti.$Enum("TMaskedState$a",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMaskedState$a});
  this.$rtti.$Set("TMaskedState",{comptype: this.$rtti["TMaskedState$a"]});
  this.$rtti.$inherited("TMaskedText",rtl.string,{});
  this.$rtti.$inherited("TEditMask",rtl.string,{});
  rtl.createClass(this,"TCustomMaskEdit",pas["WEBLib.StdCtrls"].TEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TEdit.$init.call(this);
      this.FEditMask = "";
      this.FMaskBlank = "\x00";
      this.FMaxChars = 0;
      this.FMaskState = {};
      this.FCaretPos = 0;
      this.FOldValue = "";
      this.FEditText = "";
    };
    this.$final = function () {
      this.FMaskState = undefined;
      pas["WEBLib.StdCtrls"].TEdit.$final.call(this);
    };
    this.GetEditText = function () {
      var Result = "";
      Result = this.RemoveEditFormat(this.GetText());
      return Result;
    };
    this.SetEditText = function (Value) {
      this.FEditText = this.AddEditFormat(Value,true);
      this.SetText(this.FEditText);
    };
    this.AddEditFormat = function (Value, Active) {
      var Result = "";
      if (!Active) {
        Result = $impl.FormatMaskedText(this.FEditMask,Value," ")}
       else Result = $impl.FormatMaskedText(this.FEditMask,Value,this.FMaskBlank);
      return Result;
    };
    this.RemoveEditFormat = function (Value) {
      var Result = "";
      var I = 0;
      var OldLen = 0;
      var Offset = 0;
      var MaskOffset = 0;
      var CType = 0;
      var Dir = {};
      Offset = 1;
      Result = Value;
      for (var $l = 1, $end = this.FEditMask.length; $l <= $end; $l++) {
        MaskOffset = $l;
        CType = $impl.GetMaskCharType(this.FEditMask,MaskOffset);
        if (CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral)) Result = pas.System.Copy(Result,1,Offset - 1) + pas.System.Copy(Result,Offset + 1,Result.length - Offset);
        if (CType in rtl.createSet($impl.TMaskCharType.mcMask,$impl.TMaskCharType.mcMaskOpt)) Offset += 1;
      };
      Dir = rtl.refSet($impl.GetMaskInstructions(this.FEditMask,1));
      if ($impl.TMaskInstructions$a.miReverseDir in Dir) {
        Offset = 1;
        for (var $l1 = 1, $end1 = Result.length; $l1 <= $end1; $l1++) {
          I = $l1;
          if (Result.charAt(I - 1) === this.FMaskBlank) {
            Offset += 1}
           else break;
        };
        if (Offset !== 1) Result = pas.System.Copy(Result,Offset,(Result.length - Offset) + 1);
      } else {
        OldLen = Result.length;
        for (var $l2 = 1, $end2 = OldLen; $l2 <= $end2; $l2++) {
          I = $l2;
          if (Result.charAt(((OldLen - I) + 1) - 1) === this.FMaskBlank) {
            Result = rtl.strSetLength(Result,Result.length - 1)}
           else break;
        };
      };
      if (this.FMaskBlank !== " ") {
        OldLen = Result.length;
        for (var $l3 = 1, $end3 = OldLen; $l3 <= $end3; $l3++) {
          I = $l3;
          if (Result.charAt(I - 1) === this.FMaskBlank) Result = rtl.setCharAt(Result,I - 1," ");
          if (I > OldLen) break;
        };
      };
      return Result;
    };
    this.ArrowKeys = function (CharCode, Shift) {
      var ASelStart = 0;
      var ASelStop = 0;
      if (pas.Classes.TShiftState$a.ssCtrl in Shift) return;
      this.GetSel({get: function () {
          return ASelStart;
        }, set: function (v) {
          ASelStart = v;
        }},{get: function () {
          return ASelStop;
        }, set: function (v) {
          ASelStop = v;
        }});
      if (pas.Classes.TShiftState$a.ssShift in Shift) {
        if (CharCode === 39) {
          this.FCaretPos += 1;
          if (ASelStop === (ASelStart + 1)) {
            this.SetSel(ASelStart,ASelStop);
            this.FCaretPos += 1;
          };
          if (this.FCaretPos > this.FMaxChars) this.FCaretPos = this.FMaxChars;
        } else {
          this.FCaretPos -= 1;
          if ((ASelStop === (ASelStart + 2)) && (this.FCaretPos > ASelStart)) {
            this.SetSel(ASelStart + 1,ASelStart + 1);
            this.FCaretPos -= 1;
          };
          if (this.FCaretPos < 0) this.FCaretPos = 0;
        };
      } else {
        if ((ASelStop - ASelStart) > 1) {
          if (ASelStop === this.FCaretPos) this.FCaretPos -= 1;
          this.SetCursor(this.FCaretPos);
        } else if (CharCode === 37) {
          this.CursorDec(ASelStart)}
         else {
          if (ASelStop === ASelStart) {
            this.SetCursor(ASelStart)}
           else this.CursorInc(ASelStart,1);
        };
      };
    };
    this.CursorInc = function (CursorPos, Incr) {
      var NuPos = 0;
      if (CursorPos < this.GetText().length) {
        NuPos = CursorPos + Incr;
        NuPos = this.GetNextEditChar(NuPos);
        if ($impl.IsLiteralChar(this.FEditMask,NuPos)) NuPos = CursorPos;
        this.SetCursor(NuPos);
      };
    };
    this.CursorDec = function (CursorPos) {
      var Result = 0;
      var nuPos = 0;
      Result = 0;
      if (CursorPos > 0) {
        nuPos = CursorPos;
        nuPos -= 1;
        nuPos = this.GetPriorEditChar(nuPos);
        this.SetCursor(nuPos);
        Result = nuPos;
      };
      return Result;
    };
    this.DeleteKeys = function (CharCode) {
      var ASelStart = 0;
      var ASelStop = 0;
      var Str = "";
      var Orig = "";
      this.GetSel({get: function () {
          return ASelStart;
        }, set: function (v) {
          ASelStart = v;
        }},{get: function () {
          return ASelStop;
        }, set: function (v) {
          ASelStop = v;
        }});
      if ((ASelStop - ASelStart) < 1) return;
      Str = this.GetText();
      Orig = this.GetText();
      this.DeleteSelection({get: function () {
          return Str;
        }, set: function (v) {
          Str = v;
        }},ASelStart,ASelStop - ASelStart);
      Str = pas.System.Copy(Str,ASelStart + 1,ASelStop - ASelStart);
      Str = pas.System.Copy(Orig,1,ASelStart) + Str + pas.System.Copy(Orig,ASelStop + 1,Orig.length);
      this.SetText(Str);
      this.SetCursor(ASelStart);
      this.Change();
    };
    this.DeleteSelection = function (Value, Offset, Len) {
      var Result = false;
      var EndDel = 0;
      var StrOffset = 0;
      var MaskOffset = 0;
      var Temp = 0;
      var CType = 0;
      Result = true;
      if (Len === 0) return Result;
      StrOffset = Offset + 1;
      EndDel = StrOffset + Len;
      Temp = $impl.OffsetToMaskOffset(this.FEditMask,Offset);
      if (Temp < 0) return Result;
      for (var $l = Temp, $end = this.FEditMask.length; $l <= $end; $l++) {
        MaskOffset = $l;
        CType = $impl.GetMaskCharType(this.FEditMask,MaskOffset);
        if (CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral)) {
          StrOffset += 1}
         else if (CType in rtl.createSet($impl.TMaskCharType.mcMask,$impl.TMaskCharType.mcMaskOpt)) {
          Value.set(rtl.setCharAt(Value.get(),StrOffset - 1,this.FMaskBlank));
          StrOffset += 1;
        };
        if (StrOffset >= EndDel) break;
      };
      return Result;
    };
    this.HomeEndKeys = function (CharCode, Shift) {
      var ASelStart = 0;
      var ASelStop = 0;
      this.GetSel({get: function () {
          return ASelStart;
        }, set: function (v) {
          ASelStart = v;
        }},{get: function () {
          return ASelStop;
        }, set: function (v) {
          ASelStop = v;
        }});
      if (CharCode === 36) {
        if (pas.Classes.TShiftState$a.ssShift in Shift) {
          if ((ASelStart !== this.FCaretPos) && (ASelStop !== (ASelStart + 1))) ASelStop = ASelStart + 1;
          this.SetSel(0,ASelStop);
          this.CheckCursor();
        } else this.SetCursor(0);
        this.FCaretPos = 0;
      } else {
        if (pas.Classes.TShiftState$a.ssShift in Shift) {
          if ((ASelStop !== this.FCaretPos) && (ASelStop !== (ASelStart + 1))) ASelStart = ASelStop - 1;
          this.SetSel(ASelStart,this.FMaxChars);
          this.CheckCursor();
        } else this.SetCursor(this.FMaxChars - 1);
        this.FCaretPos = this.FMaxChars;
      };
    };
    this.CharKeys = function (CharCode) {
      var Result = false;
      var ASelStart = 0;
      var ASelStop = 0;
      var Txt = "";
      Result = false;
      this.GetSel({get: function () {
          return ASelStart;
        }, set: function (v) {
          ASelStart = v;
        }},{get: function () {
          return ASelStop;
        }, set: function (v) {
          ASelStop = v;
        }});
      if ((ASelStop - ASelStart) > 1) {
        this.DeleteKeys(46);
        ASelStart = this.GetNextEditChar(ASelStart);
        this.SetCursor(ASelStart);
      };
      Result = this.InputChar(CharCode,ASelStart);
      if (Result) {
        Txt = CharCode.get();
        this.SetText(pas.System.Copy(this.GetText(),1,ASelStart) + Txt + pas.System.Copy(this.GetText(),ASelStop + 1,this.GetText().length));
        this.CursorInc(ASelStart,1);
      };
      return Result;
    };
    this.InputChar = function (NewChar, Offset) {
      var Result = false;
      var MaskOffset = 0;
      var CType = 0;
      var InChar = "\x00";
      Result = true;
      if (this.FEditMask !== "") {
        Result = false;
        if (Offset < this.FMaxChars) {
          MaskOffset = $impl.OffsetToMaskOffset(this.FEditMask,Offset);
          if (MaskOffset >= 0) {
            CType = $impl.GetMaskCharType(this.FEditMask,MaskOffset);
            InChar = NewChar.get();
            Result = this.DoInputChar(NewChar,MaskOffset);
            if (!Result && (CType in rtl.createSet($impl.TMaskCharType.mcMask,$impl.TMaskCharType.mcMaskOpt))) {
              MaskOffset = this.FindLiteralChar(MaskOffset,InChar);
              if (MaskOffset > 0) {
                MaskOffset = $impl.MaskOffsetToOffset(this.FEditMask,MaskOffset);
                this.SetCursor(MaskOffset);
                return Result;
              };
            };
          };
        };
      };
      if (!Result && (NewChar.get() !== "\r") && (NewChar.get() !== "\x1B")) {
        pas["WEBLib.WebTools"].MessageBeep(0);
      } else this.Change();
      return Result;
    };
    this.DoInputChar = function (NewChar, MaskOffset) {
      var Result = false;
      var Instr = {};
      var Str = "";
      var CType = 0;
      Result = true;
      CType = $impl.GetMaskCharType(this.FEditMask,MaskOffset);
      if (CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral)) {
        NewChar.set($impl.GetFormatSettingsChar(this.FEditMask.charAt(MaskOffset - 1)))}
       else {
        Instr = rtl.refSet($impl.GetMaskInstructions(this.FEditMask,MaskOffset));
        var $tmp = this.FEditMask.charAt(MaskOffset - 1);
        if (($tmp === $impl.cMaskNumeric) || ($tmp === $impl.cMaskNumericOpt)) {
          if (!((NewChar.get() >= "0") && (NewChar.get() <= "9"))) Result = false;
        } else if ($tmp === $impl.cMaskNumSymOpt) {
          if (!(((NewChar.get() >= "0") && (NewChar.get() <= "9")) || (NewChar.get() === " ") || (NewChar.get() === "+") || (NewChar.get() === "-"))) Result = false;
        } else if (($tmp === $impl.cMaskAscii) || ($tmp === $impl.cMaskAsciiOpt)) {
          if ($impl.IsCharAlpha(NewChar.get())) {
            Str = " ";
            Str = rtl.setCharAt(Str,0,NewChar.get());
            if ($impl.TMaskInstructions$a.miUpperCase in Instr) {
              Str = pas.SysUtils.UpperCase(Str)}
             else if ($impl.TMaskInstructions$a.miLowerCase in Instr) Str = pas.SysUtils.LowerCase(Str);
            NewChar.set(Str.charAt(0));
          };
        } else if (($tmp === $impl.cMaskAlpha) || ($tmp === $impl.cMaskAlphaOpt) || ($tmp === $impl.cMaskAlphaNum) || ($tmp === $impl.cMaskAlphaNumOpt)) {
          Str = " ";
          Str = rtl.setCharAt(Str,0,NewChar.get());
          if (!$impl.IsCharAlpha(NewChar.get())) {
            Result = false;
            if (((this.FEditMask.charAt(MaskOffset - 1) === $impl.cMaskAlphaNum) || (this.FEditMask.charAt(MaskOffset - 1) === $impl.cMaskAlphaNumOpt)) && $impl.IsCharAlphaNumeric(NewChar.get())) Result = true;
          } else if ($impl.TMaskInstructions$a.miUpperCase in Instr) {
            Str = pas.SysUtils.UpperCase(Str)}
           else if ($impl.TMaskInstructions$a.miLowerCase in Instr) Str = pas.SysUtils.LowerCase(Str);
          NewChar.set(Str.charAt(0));
        };
      };
      return Result;
    };
    this.FindLiteralChar = function (MaskOffset, InChar) {
      var Result = 0;
      var CType = 0;
      var LitChar = "\x00";
      Result = -1;
      while (MaskOffset < this.FEditMask.length) {
        MaskOffset += 1;
        CType = $impl.GetMaskCharType(this.FEditMask,MaskOffset);
        if (CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral)) {
          LitChar = this.FEditMask.charAt(MaskOffset - 1);
          if (CType === $impl.TMaskCharType.mcIntlLiteral) LitChar = $impl.GetFormatSettingsChar(LitChar);
          if (LitChar === InChar) Result = MaskOffset;
          return Result;
        };
      };
      return Result;
    };
    this.SetEditMask = function (Value) {
      var SelStart = 0;
      var SelStop = 0;
      if (Value !== this.FEditMask) {
        if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (Value !== "") && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.SetEditText("");
        if (this.HandleAllocated()) this.GetSel({get: function () {
            return SelStart;
          }, set: function (v) {
            SelStart = v;
          }},{get: function () {
            return SelStop;
          }, set: function (v) {
            SelStop = v;
          }});
        this.ReformatText(Value);
        this.FMaskState = rtl.excludeSet(this.FMaskState,$mod.TMaskedState$a.mStateMasked);
        if (this.FEditMask !== "") this.FMaskState = rtl.includeSet(this.FMaskState,$mod.TMaskedState$a.mStateMasked);
        this.SetMaxLength(0);
        if (this.GetMasked() && (this.FMaxChars > 0)) {
          this.SetMaxLength(this.FMaxChars);
        };
        if (this.HandleAllocated() && this.Focused() && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.SetCursor(SelStart);
      };
    };
    this.GetMasked = function () {
      var Result = false;
      Result = this.FEditMask !== "";
      return Result;
    };
    this.GetTextLen = function () {
      var Result = 0;
      Result = this.GetText().length;
      return Result;
    };
    this.EditCanModify = function () {
      var Result = false;
      Result = !this.FReadOnly;
      return Result;
    };
    this.ReformatText = function (NewMask) {
      var OldText = "";
      OldText = this.RemoveEditFormat(this.GetEditText());
      this.FEditMask = NewMask;
      this.FMaxChars = $impl.MaskOffsetToOffset(this.FEditMask,NewMask.length);
      this.FMaskBlank = $impl.GetMaskBlank(NewMask);
      this.SetEditText(OldText);
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.call(this,Key,rtl.refSet(Shift));
      if (Key.get() in rtl.createSet(37,39,36,35)) {
        this.PreventDefault();
        this.StopPropagation();
      };
      if (this.GetMasked() && (Key.get() !== 0) && !(pas.Classes.TShiftState$a.ssAlt in Shift)) {
        if (!(Key.get() in rtl.createSet(37,39,36,35))) {
          if (this.GetSelLength() > 1) {
            this.SetSelStart(0);
            this.SetSelLength(1);
          };
        };
        if ((Key.get() === 37) || (Key.get() === 39)) {
          this.ArrowKeys(Key.get(),rtl.refSet(Shift));
          if (!((pas.Classes.TShiftState$a.ssShift in Shift) || (pas.Classes.TShiftState$a.ssCtrl in Shift))) Key.set(0);
          return;
        } else if ((Key.get() === 38) || (Key.get() === 40)) {
          Key.set(0);
          return;
        } else if ((Key.get() === 36) || (Key.get() === 35)) {
          this.HomeEndKeys(Key.get(),rtl.refSet(Shift));
          Key.set(0);
          return;
        } else if (((Key.get() === 46) && !(pas.Classes.TShiftState$a.ssShift in Shift)) || (Key.get() === 8)) {
          if (this.EditCanModify()) this.DeleteKeys(Key.get());
          if (!(Key.get() === 8)) {
            Key.set(0);
            this.PreventDefault();
            this.StopPropagation();
          };
          return;
        };
        this.CheckCursor();
      };
    };
    this.KeyUp = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyUp.call(this,Key,rtl.refSet(Shift));
      if (this.GetMasked() && (Key.get() !== 0)) {
        if (((Key.get() === 37) || (Key.get() === 39)) && (pas.Classes.TShiftState$a.ssCtrl in Shift)) this.CheckCursor();
      };
    };
    this.KeyPress = function (Key) {
      pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.call(this,Key);
      if (this.GetMasked() && (Key.get() !== "\x00") && !pas.SysUtils.CharInSet(Key.get(),["\x16","\x18","\x03","\b"])) {
        this.CharKeys(Key);
        Key.set("\x00");
        this.PreventDefault();
        this.StopPropagation();
      };
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseUp.apply(this,arguments);
    };
    this.CheckCursor = function () {
      var ASelStart = 0;
      var ASelStop = 0;
      if (!this.HandleAllocated()) return;
      if (this.GetMasked()) {
        this.GetSel({get: function () {
            return ASelStart;
          }, set: function (v) {
            ASelStart = v;
          }},{get: function () {
            return ASelStop;
          }, set: function (v) {
            ASelStop = v;
          }});
        if (ASelStart === ASelStop) this.SetCursor(ASelStart);
      };
    };
    this.Reset = function () {
      this.SetEditText(this.FOldValue);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.DoEnter = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.DoEnter.call(this);
      this.SetSelStart(0);
      this.SetSelLength(1);
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("form-control");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.CreateInitialize.call(this);
      this.SetHeight(25);
    };
    this.GetSel = function (ASelStart, ASelStop) {
      ASelStart.set(this.GetSelStart());
      ASelStop.set(this.GetSelStart() + this.GetSelLength());
    };
    this.SetSel = function (ASelStart, ASelStop) {
      this.SetSelStart(ASelStart);
      this.SetSelLength(Math.max(1,ASelStop - ASelStart));
    };
    this.SetCursor = function (Pos) {
      this.SetSel(Pos,Pos + 1);
    };
    this.GetFirstEditChar = function () {
      var Result = 0;
      Result = 0;
      if (this.GetMasked()) Result = this.GetNextEditChar(0);
      return Result;
    };
    this.GetLastEditChar = function () {
      var Result = 0;
      Result = this.GetMaxChars();
      if (this.GetMasked()) Result = this.GetPriorEditChar(Result - 1);
      return Result;
    };
    this.GetNextEditChar = function (Offset) {
      var Result = 0;
      Result = Offset;
      while ((Result < this.FMaxChars) && $impl.IsLiteralChar(this.FEditMask,Result)) Result += 1;
      return Result;
    };
    this.GetPriorEditChar = function (Offset) {
      var Result = 0;
      Result = Offset;
      while ((Result >= 0) && $impl.IsLiteralChar(this.FEditMask,Result)) Result -= 1;
      if (Result < 0) Result = this.GetNextEditChar(Result);
      return Result;
    };
    this.GetMaxChars = function () {
      var Result = 0;
      if (this.GetMasked()) {
        Result = this.FMaxChars}
       else Result = this.GetTextLen();
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TMaskEdit",this.TCustomMaskEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("EditMask",2,$mod.$rtti["TEditMask"],"FEditMask","SetEditMask");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
  });
  rtl.createClass(this,"TWebMaskEdit",this.TMaskEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    $impl.TMaskCharType = {"0": "mcNone", mcNone: 0, "1": "mcLiteral", mcLiteral: 1, "2": "mcIntlLiteral", mcIntlLiteral: 2, "3": "mcDirective", mcDirective: 3, "4": "mcMask", mcMask: 4, "5": "mcMaskOpt", mcMaskOpt: 5, "6": "mcFieldSeparator", mcFieldSeparator: 6, "7": "mcField", mcField: 7, "8": "mcDigitSeparator", mcDigitSeparator: 8};
    $mod.$rtti.$Enum("TMaskCharType",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: $impl.TMaskCharType});
    $impl.TMaskInstructions$a = {"0": "miReverseDir", miReverseDir: 0, "1": "miUpperCase", miUpperCase: 1, "2": "miLowerCase", miLowerCase: 2, "3": "miLiteralChar", miLiteralChar: 3};
    $mod.$rtti.$Enum("TMaskInstructions$a",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: $impl.TMaskInstructions$a});
    $mod.$rtti.$Set("TMaskInstructions",{comptype: $mod.$rtti["TMaskInstructions$a"]});
    $impl.dMaskReverse = "!";
    $impl.dMaskUpperCase = ">";
    $impl.dMaskLowerCase = "<";
    $impl.dMaskLiteral = "\\";
    $impl.cMaskAlpha = "L";
    $impl.cMaskAlphaOpt = "l";
    $impl.cMaskAlphaNum = "A";
    $impl.cMaskAlphaNumOpt = "a";
    $impl.cMaskAscii = "C";
    $impl.cMaskAsciiOpt = "c";
    $impl.cMaskNumeric = "0";
    $impl.cMaskNumericOpt = "9";
    $impl.cMaskNumSymOpt = "#";
    $impl.cMaskTimeSeparator = ":";
    $impl.cMaskDateSeparator = "/";
    $impl.cMaskComma = ",";
    $impl.cMaskDot = ".";
    $impl.cMaskDash = "-";
    $impl.mskSeparator = ";";
    $impl.mskBlank = "_";
    $impl.IsCharAlpha = function (IChar) {
      var Result = false;
      Result = ((IChar >= "a") && (IChar <= "z")) || ((IChar >= "A") && (IChar <= "Z"));
      return Result;
    };
    $impl.IsCharAlphaNumeric = function (IChar) {
      var Result = false;
      Result = ((IChar >= "a") && (IChar <= "z")) || ((IChar >= "A") && (IChar <= "Z")) || ((IChar >= "0") && (IChar <= "9"));
      return Result;
    };
    $impl.GetMaskCharType = function (EditMask, MaskOffset) {
      var Result = 0;
      var MaskChar = "\x00";
      Result = $impl.TMaskCharType.mcLiteral;
      MaskChar = "\x00";
      if (MaskOffset <= EditMask.length) MaskChar = EditMask.charAt(MaskOffset - 1);
      if (MaskOffset > EditMask.length) {
        Result = $impl.TMaskCharType.mcNone}
       else if ((MaskOffset > 1) && (EditMask.charAt(MaskOffset - 1 - 1) === $impl.dMaskLiteral) && !((MaskOffset > 2) && (EditMask.charAt(MaskOffset - 2 - 1) === $impl.dMaskLiteral))) {
        Result = $impl.TMaskCharType.mcLiteral}
       else if ((MaskChar === $impl.mskSeparator) && (EditMask.length >= 4) && (MaskOffset > (EditMask.length - 4))) {
        Result = $impl.TMaskCharType.mcFieldSeparator}
       else if ((EditMask.length >= 4) && (MaskOffset > (EditMask.length - 4)) && (EditMask.charAt(MaskOffset - 1 - 1) === $impl.mskSeparator) && !((MaskOffset > 2) && (EditMask.charAt(MaskOffset - 2 - 1) === $impl.dMaskLiteral))) {
        Result = $impl.TMaskCharType.mcField}
       else if (MaskChar.charCodeAt() in rtl.createSet($impl.cMaskTimeSeparator.charCodeAt(),$impl.cMaskDateSeparator.charCodeAt())) {
        Result = $impl.TMaskCharType.mcIntlLiteral}
       else if (MaskChar.charCodeAt() in rtl.createSet($impl.cMaskDash.charCodeAt(),$impl.cMaskDot.charCodeAt(),$impl.cMaskComma.charCodeAt())) {
        Result = $impl.TMaskCharType.mcDigitSeparator}
       else if (MaskChar.charCodeAt() in rtl.createSet($impl.dMaskReverse.charCodeAt(),$impl.dMaskUpperCase.charCodeAt(),$impl.dMaskLowerCase.charCodeAt(),$impl.dMaskLiteral.charCodeAt())) {
        Result = $impl.TMaskCharType.mcDirective}
       else if (MaskChar.charCodeAt() in rtl.createSet($impl.cMaskAlphaOpt.charCodeAt(),$impl.cMaskAlphaNumOpt.charCodeAt(),$impl.cMaskAsciiOpt.charCodeAt(),$impl.cMaskNumSymOpt.charCodeAt(),$impl.cMaskNumericOpt.charCodeAt())) {
        Result = $impl.TMaskCharType.mcMaskOpt}
       else if (MaskChar.charCodeAt() in rtl.createSet($impl.cMaskAlpha.charCodeAt(),$impl.cMaskAlphaNum.charCodeAt(),$impl.cMaskAscii.charCodeAt(),$impl.cMaskNumeric.charCodeAt())) Result = $impl.TMaskCharType.mcMask;
      return Result;
    };
    $impl.GetMaskInstructions = function (EditMask, MaskOffset) {
      var Result = {};
      var I = 0;
      var MaskChar = "\x00";
      Result = {};
      for (var $l = 0, $end = EditMask.length - 1; $l <= $end; $l++) {
        I = $l;
        MaskChar = EditMask.charAt((I + 1) - 1);
        if (MaskChar === $impl.dMaskReverse) {
          Result = rtl.unionSet(Result,rtl.createSet($impl.TMaskInstructions$a.miReverseDir))}
         else if ((MaskChar === $impl.dMaskLowerCase) && (I < (MaskOffset - 1))) {
          Result = rtl.unionSet(rtl.diffSet(Result,rtl.createSet($impl.TMaskInstructions$a.miUpperCase)),rtl.createSet($impl.TMaskInstructions$a.miLowerCase));
        } else if ((MaskChar === $impl.dMaskUpperCase) && (I < (MaskOffset - 1))) {
          Result = rtl.diffSet(Result,rtl.createSet($impl.TMaskInstructions$a.miLowerCase));
          if (!((I > 0) && (EditMask.charAt(I - 1) === $impl.dMaskLowerCase))) Result = rtl.unionSet(Result,rtl.createSet($impl.TMaskInstructions$a.miUpperCase));
        };
      };
      if ($impl.GetMaskCharType(EditMask,MaskOffset) === $impl.TMaskCharType.mcLiteral) Result = rtl.unionSet(Result,rtl.createSet($impl.TMaskInstructions$a.miLiteralChar));
      return Result;
    };
    $impl.GetFormatSettingsChar = function (IChar) {
      var Result = "\x00";
      Result = IChar;
      var $tmp = IChar;
      if ($tmp === $impl.cMaskTimeSeparator) {
        Result = pas.SysUtils.FormatSettings.TimeSeparator}
       else if ($tmp === $impl.cMaskDateSeparator) Result = pas.SysUtils.FormatSettings.DateSeparator;
      return Result;
    };
    $impl.MaskOffsetToString = function (EditMask, MaskOffset) {
      var Result = "";
      var I = 0;
      var CType = 0;
      Result = "";
      for (var $l = 1, $end = MaskOffset; $l <= $end; $l++) {
        I = $l;
        CType = $impl.GetMaskCharType(EditMask,I);
        if (!(CType in rtl.createSet($impl.TMaskCharType.mcDirective,$impl.TMaskCharType.mcField,$impl.TMaskCharType.mcFieldSeparator))) Result = Result + EditMask.charAt(I - 1);
      };
      return Result;
    };
    $impl.MaskOffsetToOffset = function (EditMask, MaskOffset) {
      var Result = 0;
      Result = $impl.MaskOffsetToString(EditMask,MaskOffset).length;
      return Result;
    };
    $impl.OffsetToMaskOffset = function (EditMask, Offset) {
      var Result = 0;
      var I = 0;
      var Count = 0;
      var MaxChars = 0;
      MaxChars = $impl.MaskOffsetToOffset(EditMask,EditMask.length);
      if (Offset > MaxChars) {
        Result = -1;
        return Result;
      };
      Result = 0;
      Count = Offset;
      for (var $l = 1, $end = EditMask.length; $l <= $end; $l++) {
        I = $l;
        Result += 1;
        if (!($impl.TMaskCharType.mcDirective === $impl.GetMaskCharType(EditMask,I))) {
          Count -= 1;
          if (Count < 0) return Result;
        };
      };
      return Result;
    };
    $impl.FormatMaskedText = function (EditMask, Value, Blank) {
      var Result = "";
      var I = 0;
      var Dig = 0;
      var Offset = 0;
      var MaskOffset = 0;
      var CType = 0;
      var Dir = {};
      Result = Value;
      Dir = rtl.refSet($impl.GetMaskInstructions(EditMask,1));
      if (!($impl.TMaskInstructions$a.miReverseDir in Dir)) {
        Offset = 1;
        for (var $l = 1, $end = EditMask.length; $l <= $end; $l++) {
          MaskOffset = $l;
          CType = $impl.GetMaskCharType(EditMask,MaskOffset);
          if (CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral,$impl.TMaskCharType.mcDigitSeparator)) {
            Dig = 0;
            if (CType === $impl.TMaskCharType.mcDigitSeparator) Dig = 1;
            Result = pas.System.Copy(Result,1,Offset - 1) + $impl.GetFormatSettingsChar(EditMask.charAt(MaskOffset - 1)) + pas.System.Copy(Result,Offset + Dig,(Result.length - Offset) + 1);
            Offset += 1;
          } else if (CType in rtl.createSet($impl.TMaskCharType.mcMask,$impl.TMaskCharType.mcMaskOpt)) {
            if (Offset > Result.length) Result = Result + Blank;
            Offset += 1;
          };
        };
      } else {
        Offset = Result.length;
        for (var $l1 = 0, $end1 = EditMask.length - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          MaskOffset = EditMask.length - I;
          CType = $impl.GetMaskCharType(EditMask,MaskOffset);
          if (CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral)) {
            Result = pas.System.Copy(Result,1,Offset) + $impl.GetFormatSettingsChar(EditMask.charAt(MaskOffset - 1)) + pas.System.Copy(Result,Offset + 1,Result.length - Offset);
          } else if (CType in rtl.createSet($impl.TMaskCharType.mcMask,$impl.TMaskCharType.mcMaskOpt)) {
            if (Offset < 1) {
              Result = Blank + Result}
             else Offset -= 1;
          };
        };
      };
      return Result;
    };
    $impl.IsLiteralChar = function (EditMask, Offset) {
      var Result = false;
      var MaskOffset = 0;
      var CType = 0;
      Result = false;
      MaskOffset = $impl.OffsetToMaskOffset(EditMask,Offset);
      if (MaskOffset >= 0) {
        CType = $impl.GetMaskCharType(EditMask,MaskOffset);
        Result = CType in rtl.createSet($impl.TMaskCharType.mcLiteral,$impl.TMaskCharType.mcIntlLiteral);
      };
      return Result;
    };
    $impl.GetMaskBlank = function (EditMask) {
      var Result = "\x00";
      Result = $impl.mskBlank;
      if (EditMask.length >= 4) {
        if ($impl.GetMaskCharType(EditMask,EditMask.length - 1) === $impl.TMaskCharType.mcFieldSeparator) {
          if (($impl.GetMaskCharType(EditMask,EditMask.length - 2) === $impl.TMaskCharType.mcFieldSeparator) || ($impl.GetMaskCharType(EditMask,EditMask.length - 3) === $impl.TMaskCharType.mcFieldSeparator)) {
            Result = EditMask.charAt(EditMask.length - 1);
          };
        };
      };
      return Result;
    };
  };
},["Math","WEBLib.WebTools"]);
rtl.module("WEBLib.Ctrls.SVG",["System"],function () {
  "use strict";
  var $mod = this;
  this.ICON_SEARCH = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAPJJREFUOE+l0i0sR1EUAPDfv0ka0UemEhUzhU0yjea" + "j0YxJiCrDRqFoPpqPbjRTbHRVQLO73bfd//Mue3s3nt3zO+eee1oanlbDfFXAJFYwFPF77OCyqlgZ2MYqXnEdE8bQjy2sl5EUCJXPcYQlfMXLHdjFHMKdtk5S4A49GEiSi4IBecYbRtMu" + "UuADJ1jIDHYfM+j8CzjFfAY4wBS6csAtev95wgvGc8AELnCMxdIQ9zCLaZzlgBDfxFocVvqNfTHpKQ7xvUCqFil0soxhfOMRh9jAINqQOqvcjZuIPBSbWgcIXQfkCp8YCYG6wK8fbgz8A" + "H9+LhG4lkRRAAAAAElFTkSuQmCC";
  this.ICON_SEARCH_SVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzIgMzIiIGlkPSJHbHlwaCIgdmV" + "yc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMzIgMzIiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6" + "Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxwYXRoIGQ9Ik0yNy40MTQsMjQuNTg2bC01LjA3Ny01LjA3N0MyMy4zODYsMTcuOTI4LDI0LDE2LjAzNSwyNCwxNGMwLTUuNTE0LTQuNDg2L" + "TEwLTEwLTEwUzQsOC40ODYsNCwxNCAgczQuNDg2LDEwLDEwLDEwYzIuMDM1LDAsMy45MjgtMC42MTQsNS41MDktMS42NjNsNS4wNzcsNS4wNzdjMC43OCwwLjc4MSwyLjA0OCwwLjc4MS" + "wyLjgyOCwwICBDMjguMTk1LDI2LjYzMywyOC4xOTUsMjUuMzY3LDI3LjQxNCwyNC41ODZ6IE03LDE0YzAtMy44NiwzLjE0LTcsNy03czcsMy4xNCw3LDdzLTMuMTQsNy03LDdTNywxNy4" + "4Niw3LDE0eiIgaWQ9IlhNTElEXzIyM18iLz48L3N2Zz4=";
  this.ICON_FILTER = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAPhJREFUOE/N078rxWEUx/HXpYz+ABN2A4q6ZTBZkCy" + "3rMomm7qDukWxir9BpKRYLW7Rne5kpvwHRj+io+dbt2/fr68fi7M9z/mcd+d8zvPU/DFqGMYu+n/IekMzAKPoYgAX34Qs4BnjAYiYwyW2sFcBaWIbS1GTAaJmHftYwXEJZBmn2MBhaHoB" + "cT7AKmbRyUEmcI0jrGW5PCCMPMckpvGYhEMJeId5vJYB4n4QN8mkmSRsJ5PreOrtLN9BlovV3iNmjjjDCB7y3pQBQveORio4KfDrM/W/AS+4wi1avxlhETsYSz4UjvuVB1HXlzYxhc2i1" + "1kFqPxbH57RKFOftCADAAAAAElFTkSuQmCC";
  this.ICON_FILTER_SVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaWQ9IkxheWVyXzEiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDI0" + "IDI0OyIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpb" + "ms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6bm9uZTtzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MS42Nz" + "I0O3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9Cgkuc3Qxe2ZpbGw6bm9uZTtzdHJva2U6IzAwMDAwMDtzdHJva2U" + "td2lkdGg6MS41O3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9Cgkuc3Qye2ZpbGw6bm9uZTtzdHJva2U6IzAwMDAw" + "MDtzdHJva2Utd2lkdGg6MS41O3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9Cjwvc3R5bGU+PGc+PGc+PGc+PHBhdGggZD0iTTIyLjIsMS41bC04LjUsM" + "TEuMmMtMC4yLDAuMy0wLjMsMC42LTAuMywwLjl2Ny44bC0yLjcsMC44di04LjZjMC0wLjMtMC4xLTAuNi0wLjMtMC45TDEuOCwxLjVIMjIuMiBNMjIuOCwwSDEuMiAgICAgYy0xLDAtMS" + "41LDEuMS0wLjksMS45bDguOSwxMS44djkuNmMwLDAuNCwwLjMsMC43LDAuNywwLjdjMC4xLDAsMC4xLDAsMC4yLDBsNC4zLTEuM2MwLjMtMC4xLDAuNS0wLjQsMC41LTAuN3YtOC4zbDg" + "uOS0xMS44ICAgICBDMjQuMywxLjEsMjMuOCwwLDIyLjgsMEwyMi44LDB6Ii8+PC9nPjwvZz48L2c+PC9zdmc+";
  this.ICON_EYE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAQJJREFUOE+1080qxVEUBfDfnZABGWNCyUDJSDyCJ2BiJu" + "V7aoKYMJCirq8p5QV4CMxkyIjyBsiEto7a3e4tt5sz+f/P3uuss9Y651S0OCotrvcvBN1YwBQG8YUnXOEYz1l1rYJZ7KOzgbU3rBfMDyQTbGCrLPwswIsyn8E22sr8EKuZYBqXadc1POC" + "0WJjDCHYTZhFHoWAIt+hKzZ5S6yu18D2G14T5wHgQDOMOHanZixtkggm81COI2goOaizc4yxZGMVOwiyh+htifE8QXmNEiBHqeYMQq1gO8nwK8R/hbaK9wTG+l/5eUVb3JvZjHpMYKESP" + "uP7LRWr6afzLW2hKxTf9UTFvsYQFoAAAAABJRU5ErkJggg==";
  this.ICON_EYE_SVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cD" + "ovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI0IDI0IiBoZWlnaHQ9IjI0cHgiIGlkPSJMYXl" + "lcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0cHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2" + "ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxnPjxnPjxwYXRoIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyLDRDNC4wNjMsNC0wLjAxMiwxMi0wL" + "jAxMiwxMlMzLjA2MywyMCwxMiwyMCAgICBjOC4wOTMsMCwxMi4wMTEtNy45NjksMTIuMDExLTcuOTY5UzIwLjA2Miw0LDEyLDR6IE0xMi4wMTgsMTdjLTIuOTAyLDAtNS0yLjE4OC01LT" + "VjMC0yLjgxMywyLjA5OC01LDUtNWMyLjkwMiwwLDUsMi4xODcsNSw1ICAgIEMxNy4wMTgsMTQuODEyLDE0LjkyLDE3LDEyLjAxOCwxN3ogTTEyLjAxOCw5Yy0xLjY1OCwwLjAwMy0zLDE" + "uMzkzLTMsM2MwLDEuNjA2LDEuMzQyLDMsMywzYzEuNjU4LDAsMy0xLjM5NSwzLTMgICAgQzE1LjAxOCwxMC4zOTIsMTMuNjc2LDguOTk3LDEyLjAxOCw5eiIgZmlsbC1ydWxlPSJldmVu" + "b2RkIi8+PC9nPjwvZz48L3N2Zz4=";
});
rtl.module("WEBLib.Grids",["System","Classes","JS","WEBLib.Controls","WEBLib.Graphics","Web","DB","jsdelphisystem","WEBLib.Menus","WEBLib.StdCtrls","WEBLib.Mask","WEBLib.Ctrls.SVG","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TInitMethod = {"0": "imRandom", imRandom: 0, "1": "imLinear", imLinear: 1};
  this.$rtti.$Enum("TInitMethod",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TInitMethod});
  rtl.recNewT(this,"TGridRect",function () {
    this.Left = 0;
    this.Top = 0;
    this.Right = 0;
    this.Bottom = 0;
    this.$eq = function (b) {
      return (this.Left === b.Left) && (this.Top === b.Top) && (this.Right === b.Right) && (this.Bottom === b.Bottom);
    };
    this.$assign = function (s) {
      this.Left = s.Left;
      this.Top = s.Top;
      this.Right = s.Right;
      this.Bottom = s.Bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TGridRect",{},this);
    $r.addField("Left",rtl.longint);
    $r.addField("Top",rtl.longint);
    $r.addField("Right",rtl.longint);
    $r.addField("Bottom",rtl.longint);
  });
  rtl.recNewT(this,"TGridCoord",function () {
    this.X = 0;
    this.Y = 0;
    this.$eq = function (b) {
      return (this.X === b.X) && (this.Y === b.Y);
    };
    this.$assign = function (s) {
      this.X = s.X;
      this.Y = s.Y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TGridCoord",{},this);
    $r.addField("X",rtl.longint);
    $r.addField("Y",rtl.longint);
  });
  this.TGridOption = {"0": "goFixedVertLine", goFixedVertLine: 0, "1": "goFixedHorzLine", goFixedHorzLine: 1, "2": "goVertLine", goVertLine: 2, "3": "goHorzLine", goHorzLine: 3, "4": "goRangeSelect", goRangeSelect: 4, "5": "goDrawFocusSelected", goDrawFocusSelected: 5, "6": "goRowSizing", goRowSizing: 6, "7": "goColSizing", goColSizing: 7, "8": "goRowMoving", goRowMoving: 8, "9": "goColMoving", goColMoving: 9, "10": "goEditing", goEditing: 10, "11": "goTabs", goTabs: 11, "12": "goRowSelect", goRowSelect: 12, "13": "goAlwaysShowEditor", goAlwaysShowEditor: 13, "14": "goThumbTracking", goThumbTracking: 14, "15": "goFixedColClick", goFixedColClick: 15, "16": "goFixedRowClick", goFixedRowClick: 16, "17": "goFixedHotTrack", goFixedHotTrack: 17, "18": "goFixedRowDefAlign", goFixedRowDefAlign: 18};
  this.$rtti.$Enum("TGridOption",{minvalue: 0, maxvalue: 18, ordtype: 1, enumtype: this.TGridOption});
  this.TGridDrawState$a = {"0": "gdSelected", gdSelected: 0, "1": "gdFocused", gdFocused: 1, "2": "gdFixed", gdFixed: 2, "3": "gdRowSelected", gdRowSelected: 3, "4": "gdHotTrack", gdHotTrack: 4, "5": "gdPressed", gdPressed: 5};
  this.$rtti.$Enum("TGridDrawState$a",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TGridDrawState$a});
  this.$rtti.$Set("TGridDrawState",{comptype: this.$rtti["TGridDrawState$a"]});
  this.TGridSortIndicator = {"0": "siNone", siNone: 0, "1": "siAscending", siAscending: 1, "2": "siDescending", siDescending: 2};
  this.$rtti.$Enum("TGridSortIndicator",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TGridSortIndicator});
  this.TGridCellEditor = {"0": "geText", geText: 0, "1": "geNumber", geNumber: 1, "2": "geDate", geDate: 2, "3": "geTime", geTime: 3, "4": "geRange", geRange: 4, "5": "geColor", geColor: 5, "6": "geWeek", geWeek: 6, "7": "geMonth", geMonth: 7, "8": "geURL", geURL: 8, "9": "geEmail", geEmail: 9, "10": "geTel", geTel: 10, "11": "geMask", geMask: 11, "12": "geCombo", geCombo: 12, "13": "geMemo", geMemo: 13, "14": "geNone", geNone: 14, "15": "geCustom", geCustom: 15};
  this.$rtti.$Enum("TGridCellEditor",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TGridCellEditor});
  this.$rtti.$Set("TGridOptions",{comptype: this.$rtti["TGridOption"]});
  this.$rtti.$MethodVar("TGridGetCellDataEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AField",pas.DB.$rtti["TField"]],["AValue",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGridGetCellClassEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AField",pas.DB.$rtti["TField"]],["AValue",rtl.string],["AClassName",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGridGetCellChildrenEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AField",pas.DB.$rtti["TField"]],["AValue",rtl.string],["AElement",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TGridGetCellEditorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AEditor",this.$rtti["TGridCellEditor"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGridRequestEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARequest",pas["WEBLib.Controls"].$rtti["TJSXMLHttpRequestRecord"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TGridSortClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["ASortIndicator",this.$rtti["TGridSortIndicator"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TDrawCellEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Rect",pas.Types.$rtti["TRect"]],["State",this.$rtti["TGridDrawState"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TGetEditEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Value",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TSetEditEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Value",rtl.string,2]]), methodkind: 0});
  this.$rtti.$MethodVar("TSetEditControlValueEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AControl",pas["WEBLib.Controls"].$rtti["TControl"]],["Value",rtl.string,2]]), methodkind: 0});
  this.$rtti.$MethodVar("TGetEditControlValueEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AControl",pas["WEBLib.Controls"].$rtti["TControl"]],["Value",rtl.string,1]]), methodkind: 0});
  rtl.createClass(this,"TCustomGrid",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FRowCount = 0;
      this.FColCount = 0;
    };
    this.GetCells = function (ACol, ARow) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.SetCells = function (ACol, ARow, Value) {
    };
    this.GetCellsArray = function () {
      var Result = null;
      var i = 0;
      var j = 0;
      var row = null;
      var s = "";
      Result = new Array();
      for (var $l = this.RowOffset(), $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        row = new Array();
        for (var $l1 = this.ColOffset(), $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          s = this.GetCells(j,i);
          row.push(s);
        };
        Result.push(row);
      };
      return Result;
    };
    this.SetCellsArray = function (Value) {
      var i = 0;
      var j = 0;
      var ja = null;
      var jv = undefined;
      if ((Value.length + this.RowOffset()) > this.FRowCount) this.SetRowCount(Value.length + this.RowOffset());
      for (var $l = 0, $end = Value.length - 1; $l <= $end; $l++) {
        i = $l;
        ja = Value[i];
        if (rtl.isExt(ja,Array)) {
          if ((ja.length + this.ColOffset()) > this.FColCount) this.SetColCount(ja.length + this.ColOffset());
          for (var $l1 = 0, $end1 = ja.length - 1; $l1 <= $end1; $l1++) {
            j = $l1;
            jv = ja[j];
            this.SetCells(j + this.ColOffset(),i + this.RowOffset(),pas.JS.ToString(jv));
          };
        };
      };
    };
    this.ColOffset = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.RowOffset = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.SetColCount = function (Value) {
      var delta = 0;
      if ((this.FColCount !== Value) && (Value >= 0)) {
        delta = Value - this.FColCount;
        this.FColCount = Value;
        if (this.GetElementHandle() != null) {
          this.ColCountChanged(delta);
          this.GridChanged();
        };
      };
    };
    this.SetRowCount = function (Value) {
      var delta = 0;
      if ((this.FRowCount !== Value) && (Value >= 0)) {
        delta = Value - this.FRowCount;
        this.FRowCount = Value;
        if (this.GetElementHandle() != null) {
          this.RowCountChanged(delta);
          this.GridChanged();
        };
      };
    };
    this.GridChanged = function () {
    };
    this.RowCountChanged = function (delta) {
    };
    this.ColCountChanged = function (delta) {
    };
    this.Clear = function () {
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TGridDrawingStyle = {"0": "gdsClassic", gdsClassic: 0, "1": "gdsThemed", gdsThemed: 1, "2": "gdsGradient", gdsGradient: 2};
  this.$rtti.$Enum("TGridDrawingStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TGridDrawingStyle});
  this.$rtti.$MethodVar("TCellEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TCellCheckEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Checked",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TCellCanEditEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CanEdit",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TSelectCellEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CanSelect",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TColumnSizedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint]]), methodkind: 0});
  rtl.createClass(this,"TGridRange",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMax = 0.0;
      this.FMin = 0.0;
      this.FStep = 0.0;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FMin = 0;
      this.FMax = 100;
      this.FStep = 1;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TGridRange.isPrototypeOf(Source)) {
        this.FMax = rtl.as(Source,$mod.TGridRange).FMax;
        this.FMin = rtl.as(Source,$mod.TGridRange).FMin;
        this.FStep = rtl.as(Source,$mod.TGridRange).FStep;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Min",0,rtl.double,"FMin","FMin",4,{Default: 0});
    $r.addProperty("Max",0,rtl.double,"FMax","FMax",4,{Default: 100});
    $r.addProperty("Step",0,rtl.double,"FStep","FStep",4,{Default: 1});
  });
  rtl.createClass(this,"TCustomStringGrid",this.TCustomGrid,function () {
    this.$init = function () {
      $mod.TCustomGrid.$init.call(this);
      this.FReq = null;
      this.FDataNode = "";
      this.FOrigVal = "";
      this.FGrid = null;
      this.FFixedColor = 0;
      this.FFixedColRow = null;
      this.FFixedRow = null;
      this.FFixedCol = null;
      this.FNormalCells = null;
      this.FDefaultColAlignment = 0;
      this.FDefaultRowHeight = 0;
      this.FDefaultColWidth = 0;
      this.FColWidths = null;
      this.FRowHeights = null;
      this.FColAlignments = null;
      this.FSelectedCell = null;
      this.FEdit = null;
      this.FFixedCols = 0;
      this.FFixedRows = 0;
      this.FEditMode = false;
      this.FBlockFocus = false;
      this.FOnSelectCell = null;
      this.FOnTopLeftChanged = null;
      this.FOptions = {};
      this.FDelimiter = "\x00";
      this.FLoadFixed = false;
      this.FSelection = $mod.TGridRect.$new();
      this.FStartCell = $mod.TGridCoord.$new();
      this.FOnHttpRequestError = null;
      this.FOnHttpRequestSuccess = null;
      this.FOnGetCellClass = null;
      this.FOnGetCellData = null;
      this.FOnGetCellChildren = null;
      this.FScrollBars = 0;
      this.FSelMouseDown = false;
      this.FStyleElements = {};
      this.FDefaultDrawing = false;
      this.FDragCursor = 0;
      this.FDragKind = 0;
      this.FGradientStartColor = 0;
      this.FGradientEndColor = 0;
      this.FEditCol = 0;
      this.FEditRow = 0;
      this.FEditType = 0;
      this.FFixedFont = null;
      this.FCtl3D$1 = false;
      this.FParentCtl3D$1 = false;
      this.FOnGetEditText = null;
      this.FOnSetEditText = null;
      this.FOnHttpRequest = null;
      this.FOnCheckClick = null;
      this.FOnFixedCellClick = null;
      this.FOnValidateEdit = null;
      this.FHandleEditBlurPtr = null;
      this.FHandleEditKeypressPtr = null;
      this.FHandleCheckClickPtr = null;
      this.FHandleButtonClickPtr = null;
      this.FHandleMouseDownPtr = null;
      this.FHandleMouseMovePtr = null;
      this.FHandleMouseUpPtr = null;
      this.FHandleFocusPtr = null;
      this.FHandleBlurPtr = null;
      this.FHandleFixedClickPtr = null;
      this.FHandleClickPtr = null;
      this.FDrawingStyle = 0;
      this.FOnCanEditCell = null;
      this.FOnColumnSized = null;
      this.FRows = null;
      this.FRowsIndex = 0;
      this.FOnGetCellEditor = null;
      this.FCombo = null;
      this.FMemo = null;
      this.FMask = null;
      this.FEditMask = "";
      this.FComboBoxItems = null;
      this.FRange = null;
      this.FShowSelection = false;
      this.FOnClickCell = null;
      this.FElementTableClassName = "";
      this.FGridLineColor = 0;
      this.FSelectionTextColor = 0;
      this.FSelectionColor = 0;
      this.FWordWrap = false;
      this.FOnButtonClick = null;
      this.FSortIndex = 0;
      this.FSortDirection = 0;
      this.FOnSortClick = null;
      this.FHasMergedCells = false;
      this.FObjectRows = null;
      this.FEditAdvance = false;
      this.FEditControl = null;
      this.FOrigID = "";
      this.FOnSetEditControlValue = null;
      this.FOnGetEditControlValue = null;
      this.FOnDblClickCell = null;
      this.FEditorMode = false;
    };
    this.$final = function () {
      this.FReq = undefined;
      this.FGrid = undefined;
      this.FFixedColRow = undefined;
      this.FFixedRow = undefined;
      this.FFixedCol = undefined;
      this.FNormalCells = undefined;
      this.FColWidths = undefined;
      this.FRowHeights = undefined;
      this.FColAlignments = undefined;
      this.FSelectedCell = undefined;
      this.FEdit = undefined;
      this.FOnSelectCell = undefined;
      this.FOnTopLeftChanged = undefined;
      this.FOptions = undefined;
      this.FSelection = undefined;
      this.FStartCell = undefined;
      this.FOnHttpRequestError = undefined;
      this.FOnHttpRequestSuccess = undefined;
      this.FOnGetCellClass = undefined;
      this.FOnGetCellData = undefined;
      this.FOnGetCellChildren = undefined;
      this.FStyleElements = undefined;
      this.FFixedFont = undefined;
      this.FOnGetEditText = undefined;
      this.FOnSetEditText = undefined;
      this.FOnHttpRequest = undefined;
      this.FOnCheckClick = undefined;
      this.FOnFixedCellClick = undefined;
      this.FOnValidateEdit = undefined;
      this.FOnCanEditCell = undefined;
      this.FOnColumnSized = undefined;
      this.FRows = undefined;
      this.FOnGetCellEditor = undefined;
      this.FCombo = undefined;
      this.FMemo = undefined;
      this.FMask = undefined;
      this.FComboBoxItems = undefined;
      this.FRange = undefined;
      this.FOnClickCell = undefined;
      this.FOnButtonClick = undefined;
      this.FOnSortClick = undefined;
      this.FObjectRows = undefined;
      this.FEditControl = undefined;
      this.FOnSetEditControlValue = undefined;
      this.FOnGetEditControlValue = undefined;
      this.FOnDblClickCell = undefined;
      $mod.TCustomGrid.$final.call(this);
    };
    this.GetCells = function (ACol, ARow) {
      var Result = "";
      var td = null;
      td = this.CellRealElement(ACol,ARow);
      if (!(td != null)) {
        Result = "";
        return Result;
      };
      if (this.FWordWrap) {
        if (td.firstChild != null) td = td.firstChild;
      };
      Result = td.textContent;
      return Result;
    };
    this.SetCells = function (ACol, ARow, Value) {
      var rc = 0;
      var rr = 0;
      var rh = 0;
      var StrVal = "";
      var cn = "";
      var el = null;
      if ((ARow < 0) || (ACol < 0)) return;
      StrVal = Value;
      if (pas.System.Pos("\r",Value) > 0) {
        StrVal = pas.SysUtils.StringReplace(StrVal,"\r","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        StrVal = pas.SysUtils.StringReplace(StrVal,"\n","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      } else if (pas.System.Pos("\n",Value) > 0) {
        StrVal = pas.SysUtils.StringReplace(StrVal,"\n","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      };
      if (this.FWordWrap) {
        rh = this.GetRowHeights(ARow) - 2;
        StrVal = '<DIV class="cell" style="height:' + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return rh;
          }, set: function (v) {
            rh = v;
          }}) + "px;max-height:" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return rh;
          }, set: function (v) {
            rh = v;
          }}) + 'px">' + StrVal + "</DIV>";
      };
      el = this.CellRealElement(ACol,ARow);
      if (el != null) {
        el.innerHTML = StrVal;
        cn = "";
        this.GetCellClassName(ACol,ARow,null,StrVal,{get: function () {
            return cn;
          }, set: function (v) {
            cn = v;
          }});
        if (cn !== "") el.setAttribute("class",cn);
      };
      if (ARow === 0) this.EnableColResize();
    };
    this.SetFixedCols = function (Value) {
      if (this.FFixedCols !== Value) {
        this.FFixedCols = Value;
        if (!this.IsUpdating()) this.ReRenderGrid();
      };
    };
    this.SetFixedRows = function (Value) {
      if (this.FFixedRows !== Value) {
        this.FFixedRows = Value;
        if (!this.IsUpdating()) this.ReRenderGrid();
      };
    };
    this.SetColor = function (AValue) {
      if (this.FColor !== AValue) {
        this.FColor = AValue;
        this.UpdateElement();
      };
    };
    this.GetColWidths = function (ACol) {
      var Result = 0;
      if (ACol < this.FColWidths.GetCount()) {
        Result = rtl.trunc(this.FColWidths.Get(ACol))}
       else Result = this.FDefaultColWidth;
      return Result;
    };
    this.GetRowHeights = function (ARow) {
      var Result = 0;
      if (ARow < this.FRowHeights.GetCount()) {
        Result = rtl.trunc(this.FRowHeights.Get(ARow))}
       else Result = this.FDefaultRowHeight;
      return Result;
    };
    this.SetColWidths = function (ACol, Value) {
      var fcw = 0;
      var nw = 0;
      var nwvis = 0;
      var nwvisnoscroll = 0;
      var LAutoSizeW = false;
      var el = null;
      var RCol = 0;
      var RRow = 0;
      while (this.FColWidths.GetCount() <= ACol) this.FColWidths.Add(this.FDefaultColWidth);
      this.FColWidths.Put(ACol,Value);
      if (this.IsUpdating()) return;
      if (!(this.FGrid != null)) return;
      el = this.CellRealElement(ACol,0);
      this.CellRealCoords(el,{get: function () {
          return RCol;
        }, set: function (v) {
          RCol = v;
        }},{get: function () {
          return RRow;
        }, set: function (v) {
          RRow = v;
        }});
      LAutoSizeW = this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAuto;
      nw = this.NormalColWidth();
      nwvis = this.GetWidth() - this.FixedColWidth();
      nwvisnoscroll = nwvis - pas["WEBLib.Controls"].GetScrollBarWidth();
      if (RCol < this.FFixedCols) {
        fcw = this.FixedColWidth();
        var tr = this.FGrid.rows[0];
              if (tr != undefined) {
              var td = tr.cells[0];
              if (td != undefined) {
                td.style.width = fcw + "px";
                if (td.firstChild != undefined) {
                td.firstChild.style.width = fcw + "px"; }
                }
              }
        
              tr = this.FGrid.rows[1];
              if (tr != undefined) {
              td = tr.cells[0];
              if (td != undefined) {
                td.style.width = fcw + "px";
                if (td.firstChild != undefined) {
                td.firstChild.style.width = fcw + "px"; }
                }
        
              tr = this.FFixedColRow.rows[0];
              if (tr != undefined) {
        
              td = tr.cells[0];
              if (td != undefined) {
                td.style.width = fcw + "px";
                }
                }
              }
              tr = this.FFixedCol.rows[0];
              if (tr != undefined) {
        
              td = tr.cells[0];
              if (td != undefined) {
                td.style.width = fcw + "px";
                }
              };
      };
      if (RCol >= this.FFixedCols) {
        RCol = RCol - this.FFixedCols;
        var tr = this.FFixedRow.rows[0];
              if (tr != undefined) {
                var td = tr.cells[RCol];
                td.style.width = Value + "px";
                td.style.maxwidth = Value + "px";
        
                if (this.FNormalCells.rows.length > 0)
                {
                var td = this.FNormalCells.rows[0].cells[RCol];
                td.style.width = Value + "px";
                td.style.maxwidth = Value + "px";
                }
              };
      };
      var tr = this.FGrid.rows[0];
      if (tr != undefined) {
        var td = tr.cells[1];
        if ((td.firstChild != undefined) && (!LAutoSizeW)) {
        td.firstChild.style.width = nwvisnoscroll + "px";
        td.firstChild.firstChild.style.width = nw + "px";
        }
      }
      tr = this.FGrid.rows[1];
      if (tr != undefined) {
        td = tr.cells[1];
        if ((td.firstChild != undefined) && (!LAutoSizeW)) {
        td.firstChild.style.width = nwvis + "px";
        td.firstChild.firstChild.style.width = nw + "px";
        }
      };
      this.UpdateGridSize();
    };
    this.SetRowHeights = function (ARow, Value) {
      var frh = 0;
      var rh = 0;
      var fh = 0;
      var nh = 0;
      var nhvis = 0;
      var nhvisnoscroll = 0;
      while (this.FRowHeights.GetCount() <= ARow) this.FRowHeights.Add(this.FDefaultRowHeight);
      this.FRowHeights.Put(ARow,Value);
      if (this.IsUpdating()) return;
      if (!(this.FGrid != null)) return;
      fh = this.FixedRowHeight();
      nh = this.NormalRowHeight();
      nhvis = this.GetHeight() - this.FixedRowHeight();
      if ((this.FixedColWidth() + this.NormalColWidth()) < this.GetWidth()) {
        nhvisnoscroll = nhvis}
       else nhvisnoscroll = nhvis - pas["WEBLib.Controls"].GetScrollBarHeight();
      if (ARow < this.FFixedRows) {
        frh = this.FixedRowHeight();
        var tr = this.FGrid.rows[0];
              if (tr != undefined) {
                tr.style.height = frh + "px";
                var td = tr.cells[0];
                if (td != undefined) {
                  var fc = td.firstChild;
                  if (fc != undefined) {
                    fc.style.height = frh + "px";
                  }
                  td = tr.cells[1];
                  fc = td.firstChild;
                  if (fc != undefined) {
                    fc.style.height = frh + "px";
                  }
                  }
                }
        
              tr = this.FFixedColRow.rows[0];
              if (tr != undefined) {
                 tr = tr.cells[0];
                 if (tr != undefined) {
                 tr.style.height = Value + "px";
                 tr = this.FFixedRow.rows[ARow].cells[0];
                 if (tr != undefined) {
                 tr.style.height = Value + "px"; }
                 }
              };
      };
      if (ARow >= this.FFixedRows) {
        ARow = ARow - this.FFixedRows;
        rh = Value;
        if (this.HasHorzScrollBar() && this.HasVertScrollBar() && (ARow === (this.FRowCount - 1))) rh = Value + this.FNormalCells.parentElement.scrollHeight;
        var tr = this.FFixedCol.rows[ARow];
              if (tr != undefined) {
              tr.style.height = Value + "px";
              var tr = this.FNormalCells.rows[ARow];
        
              if (tr != undefined) {
              tr.style.height = rh + "px"; }
              };
      };
      var td = this.FGrid.rows[1].cells[0];
          if (td.firstChild) {
          td.firstChild.style.height = nhvisnoscroll + "px";
          td.firstChild.firstChild.style.height = nh + "px";
          }
      
          td = this.FGrid.rows[1].cells[1];
          if (td.firstChild) {
          td.firstChild.style.height = nhvis + "px";
          td.firstChild.firstChild.style.height = nh + "px";
          };
    };
    this.SetDefaultColWidth = function (Value) {
      var i = 0;
      this.FDefaultColWidth = Value;
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        this.SetColWidths(i,Value);
      };
    };
    this.SetDefaultRowHeight = function (Value) {
      var i = 0;
      this.FDefaultRowHeight = Value;
      for (var $l = 0, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        this.SetRowHeights(i,Value);
      };
    };
    this.GetCol = function () {
      var Result = 0;
      var res = 0;
      res = -1;
      if (this.FSelectedCell != null) {
        res = this.FSelectedCell.cellIndex;
        res = res + this.FFixedCols;
      };
      Result = res;
      return Result;
    };
    this.GetRow = function () {
      var Result = 0;
      var res = 0;
      res = -1;
      if (this.FSelectedCell != null) {
        res = this.FSelectedCell.parentElement.rowIndex;
        res = res + this.FFixedRows;
      };
      Result = res;
      return Result;
    };
    this.SetCol = function (Value) {
      var r = 0;
      var c = 0;
      var td = null;
      if ((Value < this.FColCount) && (Value >= this.FFixedCols)) {
        if (this.FSelectedCell != null) {
          this.RemoveSelection(this.FSelectedCell);
        };
        c = Value - this.FFixedCols;
        r = this.GetRow() - this.FFixedRows;
        if (r < 0) r = 0;
        var tr = this.FNormalCells.rows[r];
        td = tr.cells[c];
        this.AddSelection(td);
        this.FSelectedCell = td;
        var pardiv = this.FNormalCells.parentElement.parentElement;
        
               if (td.offsetLeft < pardiv.scrollLeft) {
                 pardiv.scrollLeft = td.offsetLeft;
               }
        
               if (td.offsetLeft + td.offsetWidth - pardiv.scrollLeft > pardiv.offsetWidth) {
                 pardiv.scrollLeft = pardiv.scrollLeft + td.offsetWidth;
               };
      };
    };
    this.SetRow = function (Value) {
      var r = 0;
      var c = 0;
      var sh = 0;
      var rselect = false;
      var tr = null;
      var td = null;
      if ((Value < this.FRowCount) && (Value >= this.FFixedRows)) {
        rselect = $mod.TGridOption.goRowSelect in this.FOptions;
        if ((this.FSelectedCell != null) && rselect) {
          tr = this.FSelectedCell.parentElement;
          this.RemoveSelection(tr);
        };
        if (this.FSelectedCell != null) {
          this.RemoveSelection(this.FSelectedCell);
        };
        c = this.GetCol() - this.FFixedCols;
        if (c < 0) c = 0;
        r = Value - this.FFixedRows;
        if ((this.FixedColWidth() + this.NormalColWidth()) < this.GetWidth()) {
          sh = 0}
         else sh = pas["WEBLib.Controls"].GetScrollBarHeight();
        tr = this.FNormalCells.rows[r];
        td = tr.cells[c];
        if (rselect) {
          if (!pas.JS.isUndefined(this.FSelectedCell)) this.RemoveSelection(this.FSelectedCell);
          this.AddSelection(tr);
          this.FSelectedCell = td;
        } else {
          this.FSelectedCell = td;
          this.AddSelection(this.FSelectedCell);
        };
        var pardiv = this.FNormalCells.parentElement.parentElement;
              var st = 0;
              if (td.offsetTop < pardiv.scrollTop) {
                pardiv.scrollTop = td.offsetTop;
              }
        
              if (td.offsetHeight > 0) {
                while (td.offsetTop + td.offsetHeight - pardiv.scrollTop > pardiv.offsetHeight - sh)  {
                  st = pardiv.scrollTop;
                  pardiv.scrollTop = pardiv.scrollTop + td.offsetHeight;
                  if (pardiv.scrollTop === st) {
                    break; }
                }
              };
      };
    };
    this.GetCellElements = function (ACol, ARow) {
      var Result = null;
      Result = this.CellRealElement(ACol,ARow);
      return Result;
    };
    this.GetCheckElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElements(ACol,ARow).firstChild;
        if ((el != null) && rtl.isExt(el,Element)) {
          if (el.hasAttribute("type") && (pas.SysUtils.UpperCase(el.getAttribute("type")) === "CHECKBOX")) {
            Result = el;
          };
        };
      };
      return Result;
    };
    this.GetCanvasElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElements(ACol,ARow).firstChild;
        if ((el != null) && rtl.isExt(el,Element)) {
          if (pas.SysUtils.UpperCase(el.tagName) === "CANVAS") {
            Result = el;
          };
        };
      };
      return Result;
    };
    this.GetButtonElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElements(ACol,ARow).firstChild;
        if ((el != null) && rtl.isExt(el,Element)) {
          if (pas.SysUtils.UpperCase(el.tagName) === "BUTTON") {
            Result = el;
          };
        };
      };
      return Result;
    };
    this.GetProgressElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElements(ACol,ARow).firstChild;
        if ((el != null) && rtl.isExt(el,Element)) {
          if (pas.SysUtils.UpperCase(el.tagName) === "PROGRESS") {
            Result = el;
          };
        };
      };
      return Result;
    };
    this.GetSelection = function () {
      var Result = $mod.TGridRect.$new();
      Result.$assign(this.FSelection);
      return Result;
    };
    this.SetSelection = function (Value) {
      var c = 0;
      var r = 0;
      var rc = 0;
      var rr = 0;
      var sel = false;
      var left = 0;
      var right = 0;
      var top = 0;
      var bottom = 0;
      var tr = null;
      var td = null;
      this.FSelection.$assign(Value);
      left = Value.Left;
      right = Value.Right;
      if (Value.Left > Value.Right) {
        left = Value.Right;
        right = Value.Left;
      };
      top = Value.Top;
      bottom = Value.Bottom;
      if (Value.Top > Value.Bottom) {
        top = Value.Bottom;
        bottom = Value.Top;
      };
      for (var $l = this.FFixedRows, $end = this.FRowCount - 1; $l <= $end; $l++) {
        r = $l;
        if ($mod.TGridOption.goRowSelect in this.FOptions) {
          rr = r - this.FFixedRows;
          sel = (r >= top) && (r <= bottom);
          if (sel) {
            tr = this.FNormalCells.rows[rr];
            this.AddSelection(tr);
          } else {
            tr = this.FNormalCells.rows[rr];
            this.RemoveSelection(tr);
          };
        } else for (var $l1 = this.FFixedCols, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          c = $l1;
          rc = c - this.FFixedCols;
          rr = r - this.FFixedRows;
          sel = (c >= left) && (c <= right) && (r >= top) && (r <= bottom);
          if (sel) {
            td = this.FNormalCells.rows[rr].cells[rc];
            if (td != null) this.AddSelection(td);
          } else {
            td = this.FNormalCells.rows[rr].cells[rc];
            if (td != null) this.RemoveSelection(td);
          };
        };
      };
    };
    this.GetLeftCol = function () {
      var Result = 0;
      var i = 0;
      var w = 0;
      var l = 0;
      Result = this.FFixedCols;
      if (this.FNormalCells != null) {
        l = this.FNormalCells.parentElement.parentElement.scrollLeft;
        w = 0;
        for (var $l = this.FFixedCols, $end = this.FColCount - 1; $l <= $end; $l++) {
          i = $l;
          if (l <= w) {
            Result = i;
            break;
          };
          w = (w + this.GetColWidths(i) + 1) - 0;
        };
      };
      return Result;
    };
    this.GetTopRow = function () {
      var Result = 0;
      var pixVal = 0;
      Result = this.FFixedRows;
      if ((this.FNormalCells != null) && (pixVal >= 0)) {
        pixVal = this.FNormalCells.parentElement.parentElement.scrollTop;
        Result = this.FFixedRows + rtl.trunc(pixVal / this.FDefaultRowHeight);
      };
      return Result;
    };
    this.SetLeftCol = function (Value) {
      var i = 0;
      var w = 0;
      w = 0;
      for (var $l = this.FFixedCols, $end = Value - 1; $l <= $end; $l++) {
        i = $l;
        w = (w + this.GetColWidths(i) + 1) - 0;
      };
      if (this.FNormalCells != null) {
        this.FNormalCells.parentElement.parentElement.scrollLeft = w;
        if (this.FFixedCols > 0) this.FFixedCol.parentElement.parentElement.scrollLeft = w;
      };
    };
    this.SetTopRow = function (Value) {
      var pixVal = 0;
      pixVal = (Value - this.FFixedRows) * this.FDefaultRowHeight;
      if ((this.FNormalCells != null) && (pixVal >= 0)) {
        this.FNormalCells.parentElement.parentElement.scrollTop = pixVal;
        if (this.FFixedCols > 0) this.FFixedCol.parentElement.parentElement.scrollTop = pixVal;
      };
    };
    this.SetFixedColor = function (Value) {
      if (this.FFixedColor !== Value) {
        this.FFixedColor = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetFixedTextColor = function (Value) {
      if (this.FFixedFont.FColor !== Value) {
        this.FFixedFont.SetColor(Value);
        this.UpdateElementVisual();
      };
    };
    this.GetFixedTextColor = function () {
      var Result = 0;
      Result = this.FFixedFont.FColor;
      return Result;
    };
    this.GetVisibleColCount = function () {
      var Result = 0;
      var i = 0;
      var el = null;
      var cr = null;
      var gr = null;
      i = this.GetLeftCol();
      gr = this.GetElementHandle().getBoundingClientRect();
      while (i < this.FColCount) {
        el = this.GetCellElements(i,this.FFixedRows);
        cr = el.getBoundingClientRect();
        if (cr.right > gr.right) break;
        i += 1;
      };
      Result = i - this.GetLeftCol();
      return Result;
    };
    this.GetVisibleRowCount = function () {
      var Result = 0;
      var i = 0;
      var el = null;
      var cr = null;
      var gr = null;
      i = this.GetTopRow();
      gr = this.GetElementHandle().getBoundingClientRect();
      while (i < this.FRowCount) {
        el = this.GetCellElements(this.FFixedCols,i);
        cr = el.getBoundingClientRect();
        if (cr.bottom > gr.bottom) break;
        i += 1;
      };
      Result = i - this.GetTopRow();
      return Result;
    };
    this.GetRows = function (Index) {
      var Result = null;
      var i = 0;
      if ((Index >= 0) && (Index < this.FRowCount)) {
        this.FRowsIndex = Index;
        this.FRows.Clear();
        for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
          i = $l;
          this.FRows.Add(this.GetCells(i,Index));
        };
        Result = this.FRows;
      } else throw pas.SysUtils.Exception.$create("Create$1",["Invalid row index"]);
      return Result;
    };
    this.SetRows = function (Index, Value) {
      var i = 0;
      if ((Index >= 0) && (Index < this.FRowCount)) {
        for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
          i = $l;
          if (i < Value.GetCount()) this.SetCells(i,Index,Value.Get(i));
        };
      } else throw pas.SysUtils.Exception.$create("Create$1",["Invalid row index"]);
    };
    this.RowsChanged = function (Sender) {
      this.SetRows(this.FRowsIndex,this.FRows);
    };
    this.GetCheckState = function (ACol, ARow) {
      var Result = false;
      var el = null;
      var res = false;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        if (el != null) {
          res = el.checked;
          Result = res;
        };
      };
      return Result;
    };
    this.SetCheckState = function (ACol, ARow, Value) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        el.checked = Value;
      };
    };
    this.GetCheckEnabled = function (ACol, ARow) {
      var Result = false;
      var el = null;
      var res = false;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        if (el != null) {
          res = el.disabled;
          Result = !res;
        };
      };
      return Result;
    };
    this.SetCheckEnabled = function (ACol, ARow, Value) {
      var el = null;
      var v = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        v = !Value;
        el = this.GetCheckElement(ACol,ARow);
        el.disabled = v;
      };
    };
    this.SetRange = function (Value) {
      this.FRange.Assign(Value);
    };
    this.SetElementTableClassName = function (Value) {
      if (this.FElementTableClassName !== Value) {
        this.FElementTableClassName = Value;
        if (!this.IsUpdating()) this.ReRenderGrid();
      };
    };
    this.SetGridLineColor = function (Value) {
      if (this.FGridLineColor !== Value) {
        this.FGridLineColor = Value;
        this.UpdateElement();
      };
    };
    this.SetSelectionColor = function (Value) {
      if (this.FSelectionColor !== Value) {
        this.FSelectionColor = Value;
        this.UpdateElement();
      };
    };
    this.SetSelectionTextColor = function (Value) {
      if (this.FSelectionTextColor !== Value) {
        this.FSelectionTextColor = Value;
        this.UpdateElement();
      };
    };
    this.GetColAlignments = function (ACol) {
      var Result = 0;
      if (ACol < this.FColAlignments.GetCount()) {
        Result = this.FColAlignments.Get(ACol)}
       else Result = this.FDefaultColAlignment;
      return Result;
    };
    this.SetColAlignments = function (ACol, Value) {
      while (this.FColAlignments.GetCount() <= ACol) this.FColAlignments.Add(pas.Classes.TAlignment.taLeftJustify);
      this.FColAlignments.Put(ACol,Value);
      this.UpdateGridAlignment();
    };
    this.SetAlignAttr = function (AAlign, AElement) {
      var $tmp = AAlign;
      if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
        AElement.removeAttribute("align")}
       else if ($tmp === pas.Classes.TAlignment.taCenter) {
        AElement.setAttribute("align","center")}
       else if ($tmp === pas.Classes.TAlignment.taRightJustify) AElement.setAttribute("align","right");
    };
    this.SetSortIndex = function (Value) {
      var i = 0;
      this.FSortIndex = Value;
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        this.SelectSortIndicator(i,0,i === this.FSortIndex);
      };
    };
    this.SetDefaultColAlignment = function (Value) {
      if (this.FDefaultColAlignment !== Value) {
        this.FDefaultColAlignment = Value;
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.ReRenderGrid();
      };
    };
    this.GetObjects = function (ACol, ARow) {
      var Result = null;
      var LObjr = null;
      Result = null;
      if (this.FObjectRows.GetCount() > ARow) {
        LObjr = rtl.getObject(this.FObjectRows.Get(ARow));
        if (LObjr.GetCount() > ACol) Result = rtl.getObject(LObjr.Get(ACol));
      };
      return Result;
    };
    this.SetObjects = function (ACol, ARow, Value) {
      var LObjr = null;
      while (this.FObjectRows.GetCount() <= ARow) {
        LObjr = pas.Classes.TList.$create("Create$1");
        this.FObjectRows.Add(LObjr);
      };
      LObjr = rtl.getObject(this.FObjectRows.Get(ARow));
      while (LObjr.GetCount() <= ACol) {
        LObjr.Add(null);
      };
      LObjr.Put(ACol,Value);
    };
    this.SetFixedFont = function (Value) {
      this.FFixedFont.Assign(Value);
    };
    this.GetDataRowCount = function () {
      var Result = 0;
      Result = this.FRowCount - this.FFixedRows;
      return Result;
    };
    this.ClearData = function () {
      this.Clear();
      this.SetRowCount(this.FFixedRows + 5);
      this.SetColCount(this.FFixedCols + 5);
    };
    this.SetDataColumnCount = function (AValue) {
      this.SetColCount(this.FFixedCols + AValue);
    };
    this.SetDataRowCount = function (AValue) {
      this.SetRowCount(this.FFixedRows + AValue);
    };
    this.SetDataValue = function (AColumn, ARow, AValue) {
      this.SetCells(AColumn + this.FFixedCols,ARow + this.FFixedRows,AValue);
    };
    this.SetDataHeader = function (AColumn, AValue) {
      if (this.FFixedRows > 0) this.SetCells(AColumn + this.FFixedCols,this.FFixedRows - 1,AValue);
    };
    this.DataBeginUpdate = function () {
    };
    this.DataEndUpdate = function () {
    };
    this.DataInsertRow = function (AInsertPosition) {
      this.InsertRow(AInsertPosition);
    };
    this.FontChanged = function () {
      pas["WEBLib.Controls"].TControl.FontChanged.call(this);
      this.UpdateElement();
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.FNormalCells != null) {
        this.FNormalCells.removeEventListener("mousedown",this.FHandleMouseDownPtr);
        this.FNormalCells.removeEventListener("mouseup",this.FHandleMouseUpPtr);
        this.FNormalCells.removeEventListener("mousemove",this.FHandleMouseMovePtr);
        this.FNormalCells.removeEventListener("click",this.FHandleClickPtr);
      };
      if (this.FFixedCol != null) this.FFixedCol.removeEventListener("click",this.FHandleFixedClickPtr);
      if (this.FFixedRow != null) this.FFixedRow.removeEventListener("click",this.FHandleFixedClickPtr);
      if (this.FFixedColRow != null) this.FFixedColRow.removeEventListener("click",this.FHandleFixedClickPtr);
    };
    this.FixedFontChanged = function (Sender) {
      this.$class.AddInstanceStyle$1(this.StylePrefix() + this.FOrigID,this.GetGridCSS(this.FOrigID + "tbl"));
      this.UpdateElementVisual();
    };
    this.StylePrefix = function () {
      var Result = "";
      var frm = null;
      Result = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) Result = frm.$classname;
      return Result;
    };
    this.ColOffset = function () {
      var Result = 0;
      Result = this.FFixedCols;
      return Result;
    };
    this.RowOffset = function () {
      var Result = 0;
      Result = this.FFixedRows;
      return Result;
    };
    this.CellColSpan = function (ACol, ARow) {
      var Result = 0;
      var el = null;
      var s = "";
      var e = 0;
      Result = 0;
      el = this.CellRealElement(ACol,ARow);
      if (el != null) {
        s = el.getAttribute("colspan");
        pas.System.val$6(s,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},{get: function () {
            return e;
          }, set: function (v) {
            e = v;
          }});
      };
      return Result;
    };
    this.CellRowSpan = function (ACol, ARow) {
      var Result = 0;
      var el = null;
      var s = "";
      var e = 0;
      Result = 0;
      el = this.CellRealElement(ACol,ARow);
      if (el != null) {
        s = el.getAttribute("rowspan");
        pas.System.val$6(s,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},{get: function () {
            return e;
          }, set: function (v) {
            e = v;
          }});
      };
      return Result;
    };
    this.CellRealElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      var t = null;
      var c = 0;
      var r = 0;
      Result = null;
      if ((ARow >= this.FRowCount) || (ACol >= this.FColCount)) return Result;
      if ((ACol < this.FFixedCols) && (ARow < this.FFixedRows)) {
        t = this.FFixedColRow;
        c = ACol;
        r = ARow;
      } else if ((ACol < this.FFixedCols) && (ARow >= this.FFixedRows)) {
        t = this.FFixedCol;
        c = ACol;
        r = ARow - this.FFixedRows;
      } else if ((ACol >= this.FFixedCols) && (ARow < this.FFixedRows)) {
        t = this.FFixedRow;
        c = ACol - this.FFixedCols;
        r = ARow;
      } else {
        t = this.FNormalCells;
        c = ACol - this.FFixedCols;
        r = ARow - this.FFixedRows;
      };
      el = null;
      if (this.FHasMergedCells) {
        var getTableCell = function (table, x, y) {
        var m = [], row, cell, xx, tx, ty, xxx, yyy;
        for(yyy = 0; yyy < table.rows.length; yyy++) {
            row = table.rows[yyy];
            for(xxx = 0; xxx < row.cells.length; xxx++) {
                cell = row.cells[xxx];
                xx = xxx;
                for(; m[yyy] && m[yyy][xx]; ++xx) {}
                for(tx = xx; tx < xx + cell.colSpan; ++tx) {
                    for(ty = yyy; ty < yyy + cell.rowSpan; ++ty) {
                        if (!m[ty])
                            m[ty] = [];
                        m[ty][tx] = true;
                    }
                }
                if (xx <= x && x < xx + cell.colSpan && yyy <= y && y < yyy + cell.rowSpan)
                    return cell;
            }
          }
        return null;
        };
        el = getTableCell(t, c, r);
      } else {
        el = t.rows[r].cells[c];
      };
      Result = el;
      return Result;
    };
    this.CellRealCoords = function (AElement, ACol, ARow) {
      var allcells = [];
      var el = null;
      var i = 0;
      var j = 0;
      ACol.set(-1);
      ARow.set(-1);
      allcells = rtl.arraySetLength(allcells,null,this.FColCount,this.FRowCount);
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.FRowCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          allcells[i][j] = this.CellRealElement(i,j);
        };
      };
      for (var $l2 = 0, $end2 = this.FColCount - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        for (var $l3 = 0, $end3 = this.FRowCount - 1; $l3 <= $end3; $l3++) {
          j = $l3;
          if (allcells[i][j] === AElement) {
            ACol.set(i - this.FFixedCols);
            ARow.set(j - this.FFixedRows);
            break;
          };
        };
      };
    };
    this.GetDirectCellElements = function (ACol, ARow) {
      var Result = null;
      var rc = 0;
      var rr = 0;
      var res = null;
      res = null;
      if ((ACol < this.FFixedCols) && (ARow >= this.FFixedRows)) {
        rr = ARow - this.FFixedRows;
        rc = ACol;
        res = this.FFixedCol.rows[rr].cells[rc];
      };
      if ((ARow < this.FFixedRows) && (ACol >= this.FFixedCols)) {
        rc = ACol - this.FFixedCols;
        rr = ARow;
        res = this.FFixedRow.rows[rr].cells[rc];
      };
      if ((ACol < this.FFixedCols) && (ARow < this.FFixedRows)) {
        rr = ARow;
        rc = ACol;
        res = this.FFixedColRow.rows[rr].cells[rc];
      };
      if ((ACol >= this.FFixedCols) && (ARow >= this.FFixedRows) && (ARow < this.FRowCount) && (ACol < this.FColCount)) {
        rc = ACol - this.FFixedCols;
        rr = ARow - this.FFixedRows;
        res = this.FNormalCells.rows[rr].cells[rc];
      };
      Result = res;
      return Result;
    };
    this.MouseMove = function (Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseMove.apply(this,arguments);
      if ((this.FStartCell.X !== -1) && (this.FStartCell.Y !== -1)) {
        if (Y > (this.GetHeight() - 10)) {
          this.SetTopRow(this.GetTopRow() + 1);
          this.SetSelection($mod.GridRect(this.GetSelection().Left,Math.min(this.GetSelection().Top,this.GetSelection().Bottom),this.GetSelection().Right,Math.max(this.GetSelection().Top,this.GetSelection().Bottom) + 1));
        };
        if ((this.FFixedRows > 0) && (Y < this.GetRowHeights(0)) && (this.GetTopRow() > this.FFixedRows)) {
          this.SetTopRow(this.GetTopRow() - 1);
          this.SetSelection($mod.GridRect(this.GetSelection().Left,Math.min(this.GetSelection().Top,this.GetSelection().Bottom) - 1,this.GetSelection().Right,Math.max(this.GetSelection().Top,this.GetSelection().Bottom)));
        };
        if (X > (this.GetWidth() - 10)) {
          this.SetLeftCol(this.GetLeftCol() + 1);
          this.SetSelection($mod.GridRect(Math.min(this.GetSelection().Left,this.GetSelection().Right),this.GetSelection().Top,Math.max(this.GetSelection().Left,this.GetSelection().Right) + 1,this.GetSelection().Bottom));
        };
        if ((this.FFixedCols > 0) && (X < this.GetColWidths(0)) && (this.GetLeftCol() > this.FFixedCols)) {
          this.SetLeftCol(this.GetLeftCol() - 1);
          this.SetSelection($mod.GridRect(Math.min(this.GetSelection().Left,this.GetSelection().Right) - 1,this.GetSelection().Top,Math.max(this.GetSelection().Left,this.GetSelection().Right),this.GetSelection().Bottom));
        };
      };
    };
    this.HandleClick = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var rselect = false;
      var tr = null;
      var tgt = null;
      var tag = "";
      var starttag = "";
      Result = true;
      if (!this.FEnabled) return Result;
      rselect = $mod.TGridOption.goRowSelect in this.FOptions;
      rindex = -1;
      cindex = -1;
      tgt = Event.target;
      starttag = tgt.tagName.toLowerCase();
      if ((starttag === "tr") || (starttag === "tbody")) return Result;
      do {
        tag = tgt.tagName.toLowerCase();
        if (tag != 'td')
        {
          tgt = tgt.parentElement;
        };
      } while (!((tag === "td") || (tgt === null)));
      if (tag == 'td')
      {
        cindex = tgt.cellIndex;
        var tr = tgt.parentElement;
        rindex = tr.rowIndex;
      };
      if ((tag === "td") && this.FHasMergedCells) {
        this.CellRealCoords(tgt,{get: function () {
            return cindex;
          }, set: function (v) {
            cindex = v;
          }},{get: function () {
            return rindex;
          }, set: function (v) {
            rindex = v;
          }});
      };
      if ((cindex === -1) || (rindex === -1)) return Result;
      if (!this.CanSelect(cindex + this.FFixedCols,rindex + this.FFixedRows)) {
        return Result;
      };
      this.SelectCell(cindex + this.FFixedCols,rindex + this.FFixedRows);
      if ((this.FOnClickCell != null) && this.FEnabled) {
        this.FOnClickCell(this,cindex + this.FFixedCols,rindex + this.FFixedRows);
      };
      if (this.FSelectedCell != null) {
        if (this.FSelMouseDown) {
          if (($mod.TGridOption.goEditing in this.FOptions) && this.CanEditCell(this.GetCol(),this.GetRow())) {
            this.ShowEdit();
            return Result;
          };
        } else {
          if (rselect) {
            tr = this.FSelectedCell.parentElement;
            this.RemoveSelection(tr);
          } else this.RemoveSelection(this.FSelectedCell);
        };
      };
      if (tag === "td") {
        tr = tgt.parentElement;
        this.FSelectedCell = tgt;
        if (rselect) {
          this.AddSelection(tr)}
         else this.AddSelection(tgt);
      };
      return Result;
    };
    this.HandleFixedClick = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var rselect = false;
      var tbl = null;
      var ACol = 0;
      var ARow = 0;
      var tgt = null;
      var tag = "";
      var sd = 0;
      Result = true;
      rselect = $mod.TGridOption.goRowSelect in this.FOptions;
      rindex = -1;
      cindex = -1;
      sd = $mod.TGridSortIndicator.siNone;
      tgt = Event.target;
      if (tgt.tagName === "SPAN") {
        if (tgt.getAttribute("sort") === "up") {
          sd = $mod.TGridSortIndicator.siAscending;
        } else if (tgt.getAttribute("sort") === "dn") {
          sd = $mod.TGridSortIndicator.siDescending;
        };
      };
      do {
        tag = tgt.tagName.toLowerCase();
        if (tag != 'td')
        {
          tgt = tgt.parentElement;
        };
      } while (!((tag === "td") || (tgt === null)));
      if (tag == 'td')
      {
        cindex = tgt.cellIndex;
        var tr = tgt.parentElement;
        rindex = tr.rowIndex;
        tbl = tr.parentElement;
        tbl = tbl.parentElement;
      };
      if ((cindex === -1) || (rindex === -1)) return Result;
      ACol = cindex;
      ARow = rindex;
      if (tbl === this.FFixedCol) {
        ARow = rindex + this.FFixedRows;
      };
      if (tbl === this.FFixedRow) {
        ACol = cindex + this.FFixedCols;
      };
      if (sd === $mod.TGridSortIndicator.siAscending) {
        this.DoSortClick(ACol,ARow,$mod.TGridSortIndicator.siDescending);
        this.SetSortIndicator(ACol,ARow,$mod.TGridSortIndicator.siDescending);
      } else if (sd === $mod.TGridSortIndicator.siDescending) {
        this.DoSortClick(ACol,ARow,$mod.TGridSortIndicator.siAscending);
        this.SetSortIndicator(ACol,ARow,$mod.TGridSortIndicator.siAscending);
      };
      if (this.FOnFixedCellClick != null) this.FOnFixedCellClick(this,ACol,ARow);
      return Result;
    };
    this.HandleMouseDown = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var mb = 0;
      var el = null;
      var ww = false;
      Result = true;
      if (!this.FEnabled) return Result;
      mb = this.GetMouseEventButton(Event);
      if (mb !== pas["WEBLib.Controls"].TMouseButton.mbLeft) return Result;
      rindex = -1;
      cindex = -1;
      el = Event.target;
      ww = this.FWordWrap;
      if (ww && (pas.SysUtils.LowerCase(el.tagName) === "div")) {
        el = el.parentElement;
      };
      if (el.tagName.toLowerCase() == 'td')
      {
        cindex = el.cellIndex;
        var tr = el.parentElement;
        rindex = tr.rowIndex;
      };
      this.FSelMouseDown = el === this.FSelectedCell;
      if ((this.FSelectedCell != null) && !this.FSelMouseDown && (cindex !== -1) && (rindex !== -1)) {
        this.HideEdit(false);
      };
      if (!this.CanSelect(cindex + this.FFixedCols,rindex + this.FFixedRows)) return Result;
      if ((cindex >= 0) && (rindex >= 0)) {
        if ($mod.TGridOption.goRowSelect in this.FOptions) {
          this.SetSelection($mod.GridRect(this.FFixedCols,rindex + this.FFixedRows,this.FColCount - 1,rindex + this.FFixedRows))}
         else this.SetSelection($mod.GridRect(cindex + this.FFixedCols,rindex + this.FFixedRows,cindex + this.FFixedCols,rindex + this.FFixedRows));
        if ($mod.TGridOption.goRangeSelect in this.FOptions) {
          this.FStartCell.X = cindex + this.FFixedCols;
          this.FStartCell.Y = rindex + this.FFixedRows;
        } else {
          this.FStartCell.X = -1;
          this.FStartCell.Y = -1;
        };
      };
      this.XYToClient(Event.clientX,Event.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      ss = rtl.refSet(this.GetMouseEventShiftState(Event));
      this.MouseDown(mb,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      return Result;
    };
    this.HandleMouseMove = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      rindex = -1;
      cindex = -1;
      if (Event.target.tagName.toLowerCase() == 'td')
      {
        cindex = Event.target.cellIndex;
        var tr = Event.target.parentElement;
        rindex = tr.rowIndex;
      };
      if ((cindex >= 0) && (rindex >= 0) && (this.FStartCell.X >= 0) && (this.FStartCell.Y >= 0)) this.SetSelection($mod.GridRect(this.FStartCell.X,this.FStartCell.Y,cindex + this.FFixedCols,rindex + this.FFixedRows));
      Result = true;
      this.XYToClient(Event.clientX,Event.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      ss = rtl.refSet(this.GetMouseEventShiftState(Event));
      this.MouseMove(rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      return Result;
    };
    this.HandleMouseUp = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var mb = 0;
      TMSStringGridresetResize();
      this.FStartCell.X = -1;
      this.FStartCell.Y = -1;
      Result = false;
      Event.stopPropagation();
      Event.cancelBubble = true;
      this.XYToClient(Event.clientX,Event.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      ss = rtl.refSet(this.GetMouseEventShiftState(Event));
      mb = this.GetMouseEventButton(Event);
      this.MouseUp(mb,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      return Result;
    };
    this.HandleKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      var newcol = 0;
      var newrow = 0;
      var ss = {};
      var undef = false;
      var ischar = false;
      Result = true;
      if (!this.FEnabled) return Result;
      Event.cancelBubble = true;
      Event.stopPropagation();
      k = 0;
      ischar = false;
      undef = (Event.key == undefined);
      if (pas.SysUtils.UpperCase(Event.key) === "UNIDENTIFIED") return Result;
      if (!undef) {
        k = this.GetKeyCode(Event.key,true);
        ischar = Event.key.length === 1;
        ss = rtl.refSet(this.GetKeyBoardEventShiftState(Event));
        if (this.FOnKeyDown != null) this.FOnKeyDown(this,{get: function () {
            return k;
          }, set: function (v) {
            k = v;
          }},rtl.refSet(ss));
      };
      newrow = this.GetRow();
      newcol = this.GetCol();
      if ((newrow === -1) && (newcol === -1) && (this.FColCount > this.FFixedCols) && (this.FRowCount > this.FFixedRows)) {
        newcol = this.FFixedCols;
        newrow = this.FFixedRows;
        this.SetCol(this.FFixedCols);
        this.SetRow(this.FFixedRows);
        this.FNormalCells.focus();
      };
      if ((k in rtl.createSet(38,40,33,34)) && !ischar) {
        Event.preventDefault();
        this.HideEdit(false);
        this.ChangeRow();
      };
      if (!this.FEditMode && (k in rtl.createSet(35,36,37,39)) && !ischar) {
        Event.preventDefault();
        this.HideEdit(false);
      };
      if ((k === 27) && !ischar) {
        this.CancelEdit();
      };
      if (!this.FEditMode && !ischar && Event.shiftKey && !((k >= 48) && (k <= 122)) && ($mod.TGridOption.goRangeSelect in this.FOptions)) {
        if (k === 35) {
          this.SetRow(this.FRowCount - 1);
          this.SetSelection($mod.GridRect(this.GetCol(),newrow,this.GetCol(),this.GetRow()));
          if (this.GetRow() >= (this.GetTopRow() + this.GetVisibleRowCount())) this.SetTopRow(this.GetRow() - this.GetVisibleRowCount());
        };
        if (k === 36) {
          this.SetRow(this.FFixedRows);
          this.SetSelection($mod.GridRect(this.GetCol(),newrow,this.GetCol(),this.GetRow()));
          if (this.GetRow() < this.GetTopRow()) this.SetTopRow(this.FFixedRows);
        };
        if ((k === 38) && (this.GetRow() > this.FFixedRows)) {
          if (this.GetRow() === Math.min(this.GetSelection().Top,this.GetSelection().Bottom)) {
            newrow = Math.max(this.GetSelection().Top,this.GetSelection().Bottom)}
           else newrow = Math.min(this.GetSelection().Top,this.GetSelection().Bottom);
          this.SetRow(this.GetRow() - 1);
          this.SetSelection($mod.GridRect(this.GetSelection().Left,newrow,this.GetSelection().Right,this.GetRow()));
          if (this.GetRow() < this.GetTopRow()) this.SetTopRow(this.GetTopRow() - 1);
        };
        if ((k === 40) && (this.GetRow() < (this.FRowCount - 1))) {
          if (this.GetRow() === Math.max(this.GetSelection().Top,this.GetSelection().Bottom)) {
            newrow = Math.min(this.GetSelection().Top,this.GetSelection().Bottom)}
           else newrow = Math.max(this.GetSelection().Top,this.GetSelection().Bottom);
          this.SetRow(this.GetRow() + 1);
          this.SetSelection($mod.GridRect(this.GetSelection().Left,newrow,this.GetSelection().Right,this.GetRow()));
          if (this.GetRow() > (this.GetTopRow() + this.GetVisibleRowCount())) this.SetTopRow(this.GetTopRow() + 1);
        };
        if ((k === 37) && (this.GetCol() > this.FFixedCols)) {
          if (this.GetCol() === Math.min(this.GetSelection().Left,this.GetSelection().Right)) {
            newcol = Math.max(this.GetSelection().Left,this.GetSelection().Right)}
           else newcol = Math.min(this.GetSelection().Left,this.GetSelection().Right);
          this.SetCol(this.GetCol() - 1);
          this.SetSelection($mod.GridRect(newcol,this.GetSelection().Top,this.GetCol(),this.GetSelection().Bottom));
          if (this.GetCol() < this.GetLeftCol()) this.SetLeftCol(this.GetLeftCol() - 1);
        };
        if ((k === 39) && (this.GetCol() < (this.FColCount - 1))) {
          if (this.GetCol() === Math.max(this.GetSelection().Left,this.GetSelection().Right)) {
            newcol = Math.min(this.GetSelection().Left,this.GetSelection().Right)}
           else newcol = Math.max(this.GetSelection().Left,this.GetSelection().Right);
          this.SetCol(this.GetCol() + 1);
          this.SetSelection($mod.GridRect(newcol,this.GetSelection().Top,this.GetCol(),this.GetSelection().Bottom));
          if (this.GetCol() >= (this.GetLeftCol() + this.GetVisibleColCount())) this.SetLeftCol(this.GetLeftCol() + 1);
        };
      } else {
        if ((k === 35) && !ischar) {
          newrow = this.FRowCount - 1;
        };
        if ((k === 36) && !ischar) {
          newrow = this.FFixedRows;
        };
        if ((k === 34) && !ischar) {
          if ((this.GetRow() + 4) <= (this.FRowCount - 1)) {
            newrow = this.GetRow() + 4;
          } else {
            newrow = this.FRowCount - 1;
          };
        };
        if ((k === 33) && !ischar) {
          if ((this.GetRow() - 4) > this.FFixedRows) {
            newrow = this.GetRow() - 4;
          } else {
            newrow = this.FFixedRows;
          };
        };
        if (!this.FEditMode && (k === 38) && (this.GetRow() > this.FFixedRows) && !ischar) {
          newrow = this.GetRow() - 1;
        };
        if (!this.FEditMode && (k === 40) && (this.GetRow() < (this.FRowCount - 1)) && !ischar) {
          newrow = this.GetRow() + 1;
        };
        if (!this.FEditMode && (k === 37) && (this.GetCol() > this.FFixedCols) && !ischar) {
          newcol = this.GetCol() - 1;
        };
        if (!this.FEditMode && (k === 39) && (this.GetCol() < (this.FColCount - 1)) && !ischar) {
          newcol = this.GetCol() + 1;
        };
        if (!this.FEditMode && this.CanSelect(newcol,newrow) && !ischar) {
          this.SelectCell(newcol,newrow);
          if ((k === 38) && (this.GetRow() < this.GetTopRow())) this.SetTopRow(this.GetTopRow() - 1);
          if ((k === 33) && (this.GetRow() < this.GetTopRow())) this.SetTopRow(this.GetRow());
          if ((k === 34) && (this.GetRow() >= (this.GetTopRow() + this.GetVisibleRowCount()))) this.SetTopRow(this.GetRow());
          if ((k === 40) && (this.GetRow() >= (this.GetTopRow() + this.GetVisibleRowCount()))) this.SetTopRow(this.GetTopRow() + 1);
          if ((k === 37) && (this.GetCol() < this.GetLeftCol())) this.SetLeftCol(this.GetLeftCol() - 1);
          if ((k === 39) && (this.GetCol() >= (this.GetLeftCol() + this.GetVisibleColCount()))) this.SetLeftCol(this.GetLeftCol() + 1);
          if (k === 35) this.SetTopRow(this.GetRow() - this.GetVisibleRowCount());
          if (k === 36) this.SetTopRow(this.FFixedRows);
        };
        if ((k === 113) && !this.FEditMode && ($mod.TGridOption.goEditing in this.FOptions) && this.CanEditCell(this.GetCol(),this.GetRow())) {
          this.ShowEdit();
        };
        if ((k >= 32) && (k <= 112) && ischar && !this.FEditMode && ($mod.TGridOption.goEditing in this.FOptions) && this.CanEditCell(this.GetCol(),this.GetRow())) {
          this.StartEdit(Event.key);
        };
        if ((k === 13) && ($mod.TGridOption.goEditing in this.FOptions) && this.CanEditCell(this.GetCol(),this.GetRow())) {
          if (this.FEditMode) {
            this.HideEdit(this.FEditAdvance);
          } else this.ShowEdit();
        };
      };
      return Result;
    };
    this.HandleTableFocus = function (Event) {
      var Result = false;
      Result = true;
      if (!this.FEnabled) return Result;
      if ((this.FOnEnter != null) && !this.FBlockFocus) this.FOnEnter(this);
      this.FBlockFocus = false;
      if ((this.GetCol() === -1) && (this.GetRow() === -1) && !this.HasSelection() && (this.FFixedCols < this.FColCount) && (this.FFixedRows < this.FRowCount) && this.CanSelect(this.FFixedCols,this.FFixedRows)) {
        this.SelectCell(this.FFixedCols,this.FFixedRows);
      };
      return Result;
    };
    this.HandleTableBlur = function (Event) {
      var Result = false;
      Result = true;
      if ((this.FOnExit != null) && !this.FEditMode) this.FOnExit(this);
      return Result;
    };
    this.HandleScroll = function (Event) {
      var Result = false;
      if (this.FFixedCols > 0) {
        this.FFixedCol.parentElement.scrollTop = this.FNormalCells.parentElement.parentElement.scrollTop;
      };
      if (this.FFixedRows > 0) this.FFixedRow.parentElement.parentElement.scrollLeft = this.FNormalCells.parentElement.parentElement.scrollLeft;
      this.TopLeftChanged();
      Result = true;
      return Result;
    };
    this.HandleEditBlur = function (Event) {
      var Result = false;
      if (this.FEditMode) {
        this.HideEdit(false);
      };
      Result = true;
      return Result;
    };
    this.HandleEditKeyPress = function (Event) {
      var Result = false;
      var c = "\x00";
      Event.cancelBubble = true;
      Event.stopPropagation();
      Result = true;
      if (this.IsKeyCharacter(Event.key)) {
        c = String.fromCharCode(this.GetKeyCode(Event.key,false));
        if (this.FOnKeyPress != null) this.FOnKeyPress(this,{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        if (c === "\x00") {
          Event.stopPropagation();
          Event.preventDefault();
        };
      };
      return Result;
    };
    this.HandleComboExit = function (Sender) {
      if (this.FEditMode) this.HideEdit(false);
    };
    this.HandleComboKeyPress = function (Sender, Key) {
      if (this.FOnKeyPress != null) this.FOnKeyPress(this,Key);
      if (Key.get().charCodeAt() === 27) this.CancelEdit();
      if (Key.get().charCodeAt() === 13) this.HideEdit(this.FEditAdvance);
    };
    this.HandleMaskExit = function (Sender) {
      if (this.FEditMode) this.HideEdit(false);
    };
    this.HandleMaskKeyPress = function (Sender, Key) {
      if (this.FOnKeyPress != null) this.FOnKeyPress(this,Key);
      if (Key.get().charCodeAt() === 27) this.CancelEdit();
      if (Key.get().charCodeAt() === 13) this.HideEdit(this.FEditAdvance);
    };
    this.HandleMemoExit = function (Sender) {
      if (this.FEditMode) this.HideEdit(false);
    };
    this.HandleMemoKeyPress = function (Sender, Key) {
      if (this.FOnKeyPress != null) this.FOnKeyPress(this,Key);
      if (Key.get().charCodeAt() === 27) this.CancelEdit();
    };
    this.HandleCheckBoxClick = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var chk = false;
      rindex = -1;
      cindex = -1;
      var el = Event.target;
      chk = el.checked;
      var d = el.parentElement;
      if (d.tagName.toLowerCase() == 'td')
      {
        cindex = d.cellIndex;
        var tr = d.parentElement;
        rindex = tr.rowIndex;
      };
      if ((rindex !== -1) && (cindex !== -1)) {
        if (!this.CanEditCell(cindex + this.FFixedCols,rindex + this.FFixedRows)) {
          var el = Event.target;
          el.checked = (!el.checked);
        } else this.DoCheckClick(cindex + this.FFixedCols,rindex + this.FFixedRows,chk);
      };
      return Result;
    };
    this.HandleButtonClick = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var chk = false;
      rindex = -1;
      cindex = -1;
      var el = Event.target;
      var d = el.parentElement;
      if (d.tagName.toLowerCase() == 'td')
      {
        cindex = d.cellIndex;
        var tr = d.parentElement;
        rindex = tr.rowIndex;
      };
      if ((rindex !== -1) && (cindex !== -1)) {
        this.DoButtonClick(cindex + this.FFixedCols,rindex + this.FFixedRows);
      };
      return Result;
    };
    this.HandleDoMouseUp = function (Event) {
      var Result = false;
      var res = 0;
      pas["WEBLib.Controls"].TControl.HandleDoMouseUp.apply(this,arguments);
      res = TMSGridLastColSize;
      if (!res) {
        res = TMSStringGridisSizing(); }
      TMSStringGridresetResize();
      if (res >= 0) this.DoColumnSized(res);
      Result = true;
      return Result;
    };
    this.HandleDoMouseMove = function (Event) {
      var Result = false;
      var CtrlName = "";
      var IsAutoWidth = false;
      pas["WEBLib.Controls"].TControl.HandleDoMouseMove.apply(this,arguments);
      CtrlName = this.GetID() + "tbl";
      IsAutoWidth = this.FWidthStyle in rtl.createSet(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      TMSStringGridID = CtrlName;
      TMSStringGridautoWidth = IsAutoWidth;
      GridNormalCells = this.FNormalCells;
      GridFixedCells = this.FFixedRow;
      GridFixedColCells = this.FFixedCol;
      GridFixedColRows = this.FFixedColRow;
      GridColWidths = this.FColWidths;
      GridFixedCols = this.FFixedCols;
      TMSStringGridresizeColumn(Event);
      Result = true;
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      Result = pas["WEBLib.Controls"].TControl.HandleDoClick.apply(this,arguments);
      if (!this.FEditMode && (this.FNormalCells != null)) this.FNormalCells.focus();
      return Result;
    };
    this.HandleDoDblClick = function (Event) {
      var Result = false;
      var c = 0;
      var r = 0;
      var fc = 0;
      var fr = 0;
      var el = null;
      var pel = null;
      pas["WEBLib.Controls"].TControl.HandleDoDblClick.apply(this,arguments);
      el = Event.target;
      while ((el != null) && (el !== this.GetElementHandle()) && !((el.tagName === "TD") || (el.tagName === "TH"))) el = el.parentElement;
      if ((el != null) && ((el.tagName === "TD") || (el.tagName === "TH"))) {
        c = el.cellIndex;
        var tr = el.parentElement;
        r = tr.rowIndex;
        pel = el.parentElement;
        if (pel) {
          pel = pel.parentElement; }
        if (pel) {
          pel = pel.parentElement; };
        if (!el.classList.contains("fixed")) {
          fc = this.FFixedCols;
          fr = this.FFixedRows;
        };
        if (pel != null) {
          if (pas.System.Pos("ResizeRowTable",pel.id) > 0) fc = this.FFixedCols;
          if (pas.System.Pos("FixedColTable",pel.id) > 0) fr = this.FFixedRows;
        };
        if (this.FOnDblClickCell != null) this.FOnDblClickCell(this,c + fc,r + fr);
      };
      Result = true;
      return Result;
    };
    this.DoHttpLoadJson = function (Event) {
      var Result = false;
      var J = null;
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        J = JSON.parse(req.responseText);
        this.LoadFromJSON$1(J,this.FDataNode);
        if (this.FOnHttpRequestSuccess != null) this.FOnHttpRequestSuccess(this);
      };
      Result = true;
      return Result;
    };
    this.DoHttpLoadCsv = function (Event) {
      var Result = false;
      var sl = null;
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        sl = pas.Classes.TStringList.$create("Create$1");
        sl.SetTextStr(req.responseText);
        try {
          this.LoadFromStringList(sl);
        } finally {
          sl = rtl.freeLoc(sl);
        };
        if (this.FOnHttpRequestSuccess != null) this.FOnHttpRequestSuccess(this);
      };
      Result = true;
      return Result;
    };
    this.DoHttpAbort = function (Event) {
      var Result = false;
      if (this.FOnHttpRequestError != null) this.FOnHttpRequestError(this);
      Result = true;
      return Result;
    };
    this.DoHttpRequest = function (ARequest) {
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      if (this.FOnHttpRequest != null) {
        LRequestRec.req = ARequest;
        this.FOnHttpRequest(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec));
      };
    };
    this.DoCheckClick = function (ACol, ARow, Checked) {
      if (this.FOnCheckClick != null) this.FOnCheckClick(this,ACol,ARow,Checked);
    };
    this.DoButtonClick = function (ACol, ARow) {
      if (this.FOnButtonClick != null) this.FOnButtonClick(this,ACol,ARow);
    };
    this.DoSortClick = function (ACol, ARow, ASortIndicator) {
      var i = 0;
      this.FSortIndex = ACol;
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        this.SelectSortIndicator(i,ARow,i === ACol);
      };
      this.FSortDirection = ASortIndicator;
      if (this.FOnSortClick != null) this.FOnSortClick(this,ACol,ARow,ASortIndicator);
      this.Sort(ACol,ASortIndicator);
    };
    this.GetEditText = function (ACol, ARow) {
      var Result = "";
      Result = this.GetCells(ACol,ARow);
      if (this.FOnGetEditText != null) this.FOnGetEditText(this,ACol,ARow,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.SetEditText = function (ACol, ARow, AValue) {
      if (this.FOnSetEditText != null) this.FOnSetEditText(this,ACol,ARow,AValue);
    };
    this.SetEditControlValue = function (ACol, ARow, AControl, AValue) {
      if (this.FOnSetEditControlValue != null) this.FOnSetEditControlValue(this,ACol,ARow,AControl,AValue);
    };
    this.GetEditControlValue = function (ACol, ARow, AControl, AValue) {
      if (this.FOnGetEditControlValue != null) this.FOnGetEditControlValue(this,ACol,ARow,AControl,AValue);
    };
    this.DoEditControlExit = function (Sender) {
      this.HideEdit(false);
    };
    this.GetCellData = function (ACol, ARow, AField, AValue) {
      if (this.FOnGetCellData != null) this.FOnGetCellData(this,ACol,ARow,AField,AValue);
    };
    this.GetCellClassName = function (ACol, ARow, AField, AValue, AClassName) {
      if (this.FOnGetCellClass != null) this.FOnGetCellClass(this,ACol,ARow,AField,AValue,AClassName);
    };
    this.GetCellChildren = function (ACol, ARow, AField, AValue, AElement) {
      var LElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      if (this.FOnGetCellChildren != null) {
        LElementRec.element = AElement;
        this.FOnGetCellChildren(this,ACol,ARow,AField,AValue,pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LElementRec));
      };
    };
    this.GetCellEditor = function (ACol, ARow, AEditor) {
      if (this.FOnGetCellEditor != null) this.FOnGetCellEditor(this,ACol,ARow,AEditor);
    };
    this.AddSelection = function (ACell) {
      if (this.FShowSelection) {
        ACell.classList.add("selected");
      };
    };
    this.RemoveSelection = function (ACell) {
      if (this.FShowSelection) ACell.classList.remove("selected");
    };
    this.BindCellChildren = function (ACol, ARow, AElement) {
      var el = null;
      el = AElement.firstChild;
      if ((el != null) && (el.tagName === "INPUT")) {
        if (el.hasAttribute("type") && (pas.SysUtils.LowerCase(el.getAttribute("TYPE")) === "checkbox")) {
          el.addEventListener("click",this.FHandleCheckClickPtr);
        };
      };
    };
    this.UnBindCellChildren = function (ACol, ARow, AElement) {
      var el = null;
      el = AElement.firstChild;
      if ((el != null) && (el.tagName === "INPUT")) {
        if (el.hasAttribute("type") && (pas.SysUtils.LowerCase(el.getAttribute("TYPE")) === "checkbox")) {
          el.removeEventListener("click",this.FHandleCheckClickPtr);
        };
      };
    };
    this.DoBoundsChange = function () {
      var fw = 0;
      var fh = 0;
      var nwvis = 0;
      var nhvis = 0;
      pas["WEBLib.Controls"].TControl.DoBoundsChange.call(this);
      if (this.GetElementHandle() != null) {
        this.UpdateGridSize();
        fw = this.FixedColWidth();
        fh = this.FixedRowHeight();
        nwvis = this.GetWidth() - fw;
        nhvis = this.GetHeight() - fh;
        if (this.FNormalCells != null) {
          this.FNormalCells.parentElement.parentElement.style.setProperty("width",pas.SysUtils.IntToStr(nwvis) + "px");
          this.FNormalCells.parentElement.parentElement.style.setProperty("height",pas.SysUtils.IntToStr(nhvis) + "px");
        };
      };
    };
    this.DoColumnSized = function (AColumn) {
      if (this.FOnColumnSized != null) this.FOnColumnSized(this,AColumn);
    };
    this.LoadFromStringList = function (AStrings) {
      var arow = null;
      var i = 0;
      var j = 0;
      var maxcol = 0;
      var sr = 0;
      var sc = 0;
      var cd = "";
      var cn = "";
      var ce = null;
      if (this.FLoadFixed) {
        this.SetRowCount(AStrings.GetCount())}
       else this.SetRowCount(AStrings.GetCount() + this.FFixedRows);
      arow = pas.Classes.TStringList.$create("Create$1");
      sc = this.FFixedCols;
      sr = this.FFixedRows;
      if (this.FLoadFixed) {
        sr = 0;
        sc = 0;
      };
      maxcol = 0;
      try {
        for (var $l = 0, $end = AStrings.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          arow.FStrictDelimiter = true;
          arow.SetDelimiter(this.FDelimiter);
          arow.SetDelimitedText(AStrings.Get(i));
          if (arow.GetCount() > maxcol) maxcol = arow.GetCount();
          if (arow.GetCount() > (this.FColCount - sc)) this.SetColCount(arow.GetCount() + sc);
          for (var $l1 = 0, $end1 = arow.GetCount() - 1; $l1 <= $end1; $l1++) {
            j = $l1;
            cd = arow.Get(j);
            this.GetCellData(j + sc,i + sr,null,{get: function () {
                return cd;
              }, set: function (v) {
                cd = v;
              }});
            this.SetCells(j + sc,i + sr,cd);
            ce = this.GetCellElements(j + sc,i + sr);
            this.GetCellChildren(j + sc,i + sr,null,cd,ce);
            cn = "";
            this.GetCellClassName(j + sc,i + sr,null,cd,{get: function () {
                return cn;
              }, set: function (v) {
                cn = v;
              }});
            if (cn !== "") ce.setAttribute("class",cn);
          };
        };
      } finally {
        arow = rtl.freeLoc(arow);
      };
      if (maxcol < (this.FColCount - sc)) this.SetColCount(maxcol + sc);
    };
    this.GetGridCSS = function (id) {
      var Result = "";
      var ff = "";
      Result = "";
      if (this.FElementTableClassName !== "") return Result;
      if (!($mod.TGridOption.goVertLine in this.FOptions)) Result = "border-left: 0px; border-right: 0px;";
      if (!($mod.TGridOption.goHorzLine in this.FOptions)) Result = Result + "border-top: 0px; border-bottom: 0px;";
      if (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) {
        Result = Result + pas["WEBLib.Graphics"].CSSFont(this.FFont);
        ff = pas["WEBLib.Graphics"].CSSFont(this.FFixedFont);
      };
      Result = "table#" + id + " td { overflow: hidden; text-overflow: ellipsis; white-space:nowrap; border: solid 1px " + pas["WEBLib.Graphics"].ColorToHTML(this.FGridLineColor) + "; padding: 0px;" + Result + "} " + "\r" + "table#" + id + " td.fixed {" + ff + "} " + "\r" + "table#" + id + " td.selected { background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionColor) + "; color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionTextColor) + ";} " + "\r" + "table#" + id + " tr.selected { background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionColor) + "; color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionTextColor) + ";} " + "\r" + "table#" + id + " DIV.cell {word-wrap: normal; white-space: normal; text-overflow: clip; } ";
      return Result;
    };
    this.RenderGrid = function () {
      var res = null;
      var i = 0;
      var j = 0;
      var k = 0;
      var fw = 0;
      var fh = 0;
      var nw = 0;
      var nh = 0;
      var nwvis = 0;
      var nhvis = 0;
      var nwvisnoscroll = 0;
      var nhvisnoscroll = 0;
      var tr = null;
      var td = null;
      var span = null;
      var cellspan = null;
      var fixcol = "";
      var fixtxtcol = "";
      var dynstyle = "";
      var vscroll = false;
      var hscroll = false;
      var LAutoSizeW = false;
      var LAutoSizeH = false;
      var ControlName = "";
      while (this.FColWidths.GetCount() <= this.FColCount) this.FColWidths.Add(this.FDefaultColWidth);
      if (this.FOrigID === "") {
        this.FOrigID = this.GetID();
        if (this.FOrigID === "") this.FOrigID = this.FName;
      };
      if (!(this.FGrid != null)) {
        if (this.GetIsLinked() && (this.GetElementHandle().firstElementChild != null)) {
          res = this.GetElementHandle().firstElementChild;
        } else res = document.createElement("TABLE");
        res.setAttribute("id",this.FOrigID + "tbl");
        if (this.FElementTableClassName === "") {
          res.setAttribute("class","table." + this.StylePrefix() + this.FName);
          res.style.setProperty("border-collapse","collapse");
          res.style.setProperty("border-spacing","0px");
          res.style.setProperty("border","0px");
        } else res.setAttribute("class",this.FElementTableClassName);
        this.FGrid = res;
        pas["WEBLib.Controls"].SetHTMLElementFont(res,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        this.$class.AddInstanceStyle$1(this.StylePrefix() + this.FOrigID,this.GetGridCSS(this.FOrigID + "tbl"));
      } else return;
      LAutoSizeW = this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAuto;
      LAutoSizeH = this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAuto;
      ControlName = this.FOrigID + "tbl";
      var td = undefined;
          var tr = undefined;
          var span = undefined;
          var cellspan = undefined;
          this.FFixedColRow = document.createElement('TABLE');
          this.FFixedColRow.setAttribute('id', ControlName + 'ResizeFixedRowTable');
          this.FFixedColRow.style.setProperty('border-collapse','collapse');
          this.FFixedColRow.style.setProperty('border-spacing','0px');
      
          this.FFixedCol = document.createElement('TABLE');
          this.FFixedCol.setAttribute('id', ControlName + 'ResizeFixedColTable');
          this.FFixedCol.style.setProperty('border-collapse','collapse');
          this.FFixedCol.style.setProperty('border-spacing','0px');
      
          this.FFixedRow = document.createElement('TABLE');
          this.FFixedRow.setAttribute('id', ControlName + 'ResizeRowTable');
          this.FFixedRow.style.setProperty('border-collapse','collapse');
          this.FFixedRow.style.setProperty('border-spacing','0px');
          this.FFixedRow.style.setProperty('border','0px');
      
          this.FNormalCells = document.createElement('TABLE');
          this.FNormalCells.setAttribute('id', ControlName + 'NormalCellTable');
          this.FNormalCells.style.setProperty('border-collapse','collapse');
          this.FNormalCells.style.setProperty('border-spacing','0px');
      this.FNormalCells.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder));
      this.FNormalCells.style.setProperty("outline","none");
      this.FNormalCells.addEventListener("click",this.FHandleClickPtr);
      this.FNormalCells.addEventListener("mousedown",this.FHandleMouseDownPtr);
      this.FNormalCells.addEventListener("mousemove",this.FHandleMouseMovePtr);
      this.FNormalCells.addEventListener("mouseup",this.FHandleMouseUpPtr);
      this.FFixedCol.addEventListener("click",this.FHandleFixedClickPtr);
      this.FFixedRow.addEventListener("click",this.FHandleFixedClickPtr);
      this.FFixedColRow.addEventListener("click",this.FHandleFixedClickPtr);
      this.GetElementHandle().appendChild(res);
      fw = this.FixedColWidth();
      fh = this.FixedRowHeight();
      nw = this.NormalColWidth();
      nh = this.NormalRowHeight();
      nwvis = this.GetWidth() - this.FixedColWidth();
      nhvis = this.GetHeight() - this.FixedRowHeight();
      if (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) {
        nwvis = nwvis - 2;
        nhvis = nhvis - 2;
      };
      nwvisnoscroll = nwvis - pas["WEBLib.Controls"].GetScrollBarWidth();
      if ((this.FixedColWidth() + this.NormalColWidth()) < this.GetWidth()) {
        nhvisnoscroll = nhvis}
       else nhvisnoscroll = nhvis - pas["WEBLib.Controls"].GetScrollBarHeight();
      if (this.FFixedColor !== -1) fixcol = pas["WEBLib.Graphics"].ColorToHTML(this.FFixedColor);
      if (this.GetFixedTextColor() !== -1) fixtxtcol = pas["WEBLib.Graphics"].ColorToHTML(this.GetFixedTextColor());
      tr = res.insertRow(0);
      td = tr.insertCell(0);
      td.style.border = "0px";
      td = tr.insertCell(1);
      td.style.border = "0px";
      tr = res.insertRow(1);
      td = tr.insertCell(0);
      td.style.border = "0px";
      td = tr.insertCell(1);
      td.style.border = "0px";
      if (this.FFixedRows > 0) {
        k = 0;
        if (this.FFixedCols > 0) {
          k = 1;
          td = res.rows[0].cells[0];
                  span = document.createElement('DIV');
          //        span.style.width = fw + "px";
                  span.style.height = fh + "px";
                  span.style.overflow = "hidden";
                  span.style.backgroundColor = fixcol;
                  span.style.color = fixtxtcol;
                  td.appendChild(span);
                  span.appendChild(this.FFixedColRow);
        } else {
          td = res.rows[0].cells[0];
          td.style.border = "0px";
          td = res.rows[1].cells[0];
          td.style.border = "0px";
        };
        td = res.rows[0].cells[1];
              td.style.backgroundColor = fixcol;
              td.style.color = fixtxtcol;
        
              span = document.createElement('DIV');
              span.style.height = fh + "px";
              if (!LAutoSizeW) {
                span.style.width = nwvis + "px";
              }
        
              span.style.overflow = "hidden";
              span.style.backgroundColor = fixcol;
              span.style.color = fixtxtcol;
        
              td.appendChild(span);
        
              cellspan = document.createElement('DIV');
              cellspan.style.height = fh + "px";
              if (!LAutoSizeW) {
                cellspan.style.width = nw + "px";
              }
        
              span.appendChild(cellspan);
              cellspan.appendChild(this.FFixedRow);
        if (this.FFixedCols > 0) {
          for (var $l = 0, $end = this.FFixedRows - 1; $l <= $end; $l++) {
            i = $l;
            tr = this.FFixedColRow.insertRow(i);
            for (var $l1 = 0, $end1 = this.FFixedCols - 1; $l1 <= $end1; $l1++) {
              j = $l1;
              td = tr.insertCell(j);
              td.setAttribute('class','fixed');
              this.SetAlignAttr(this.GetColAlignments(j),td);
            };
          };
        };
        for (var $l2 = 0, $end2 = this.FFixedRows - 1; $l2 <= $end2; $l2++) {
          i = $l2;
          tr = this.FFixedRow.insertRow(i);
          for (var $l3 = this.FFixedCols, $end3 = this.FColCount - 1; $l3 <= $end3; $l3++) {
            j = $l3;
            k = j - this.FFixedCols;
            td = tr.insertCell(k);
            td.setAttribute('class','fixed');
            this.SetAlignAttr(this.GetColAlignments(j),td);
          };
        };
      };
      k = 0;
      if (this.FFixedCols > 0) {
        k = 1;
        //tr = res.insertRow(res.rows.length);
              //td = tr.insertCell(0);
        
              td = res.rows[1].cells[0];
        
              td.style.backgroundColor = fixcol;
              td.style.color = fixtxtcol;
              td.setAttribute('class','fixed');
        
              span = document.createElement('DIV');
              if (!LAutoSizeW) {
              //span.style.width = fw + "px";
              }
              span.style.height = nhvisnoscroll + "px";
              span.style.overflow = "hidden";
              span.style.backgroundColor = fixcol;
              span.style.color = fixtxtcol;
        
              td.setAttribute('valign','top');
        
              td.appendChild(span);
              span.appendChild(this.FFixedCol);
        this.SetAlignAttr(this.GetColAlignments(0),td);
        for (var $l4 = this.FFixedRows, $end4 = this.FRowCount - 1; $l4 <= $end4; $l4++) {
          i = $l4;
          j = i - this.FFixedRows;
          tr = this.FFixedCol.insertRow(j);
          for (var $l5 = 0, $end5 = this.FFixedCols - 1; $l5 <= $end5; $l5++) {
            j = $l5;
            td = tr.insertCell(j);
            td.setAttribute('class','fixed');
            this.SetAlignAttr(this.GetColAlignments(j),td);
          };
        };
      };
      if (this.FFixedCols === 0) {
        //tr = res.insertRow(res.rows.length);
        //td = tr.insertCell(0);
        td = res.rows[1].cells[1];
      } else {
        //tr = res.rows[1];
        //td = tr.insertCell(1);
        td = res.rows[1].cells[1];
      };
      vscroll = (pas["WEBLib.Controls"].TScrollStyle.ssVertical === this.FScrollBars) || (pas["WEBLib.Controls"].TScrollStyle.ssBoth === this.FScrollBars);
      hscroll = (pas["WEBLib.Controls"].TScrollStyle.ssHorizontal === this.FScrollBars) || (pas["WEBLib.Controls"].TScrollStyle.ssBoth === this.FScrollBars);
      span = document.createElement('DIV');
          // span.style.backgroundColor = "#FFFFFF";
      
          if (vscroll) {
            span.style.overflowY = "auto";
          }
          else
          {
            span.style.overflowY = "hidden";
          }
      
          if (hscroll) {
            span.style.overflowX = "auto";
          }
          else {
            span.style.overflowX = "hidden";
          }
      
          if (!LAutoSizeW) {
            span.style.width = nwvis + "px";
          }
      
          if (LAutoSizeH) {
            span.style.overflow = "";
          }
      
          span.style.height = nhvis + "px";
          td.appendChild(span);
      
          cellspan = document.createElement('DIV');
            if (!LAutoSizeW) {
              cellspan.style.width = nw + "px"; }
          cellspan.style.height = nh + "px";
          span.parentElement.style.verticalAlign = "top";
          span.appendChild(cellspan);
          cellspan.appendChild(this.FNormalCells);
      span.addEventListener("scroll",rtl.createSafeCallback(this,"HandleScroll"));
      for (var $l6 = this.FFixedRows, $end6 = this.FRowCount - 1; $l6 <= $end6; $l6++) {
        i = $l6;
        k = i - this.FFixedRows;
        tr = this.FNormalCells.insertRow(k);
        for (var $l7 = this.FFixedCols, $end7 = this.FColCount - 1; $l7 <= $end7; $l7++) {
          j = $l7;
          k = j - this.FFixedCols;
          td = tr.insertCell(k);
          this.SetAlignAttr(this.GetColAlignments(j),td);
        };
      };
      this.FNormalCells.parentElement.parentElement.addEventListener("keydown",rtl.createCallback(this,"HandleKeyDown"));
      this.FNormalCells.addEventListener("focus",this.FHandleFocusPtr);
      this.FNormalCells.addEventListener("blur",this.FHandleBlurPtr);
      this.EnableColResize();
      if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) this.EnableDrag();
    };
    this.ReRenderGrid = function () {
      if (!this.GetIsLinked() && (this.FGrid != null) && (this.FGrid.firstElementChild != null)) {
        this.FGrid.removeChild(this.FGrid.firstChild);
      };
      this.FGrid = null;
      this.RenderGrid();
      this.UpdateGridSize();
      this.UpdateGridAlignment();
    };
    this.RenderGridSize = function () {
      var fw = 0;
      var fh = 0;
      var nw = 0;
      var nh = 0;
      var nwvis = 0;
      var nhvis = 0;
      var nwvisnoscroll = 0;
      var nhvisnoscroll = 0;
      if (!(this.FGrid != null)) return;
      fw = this.FixedColWidth();
      fh = this.FixedRowHeight();
      nw = this.NormalColWidth();
      nh = this.NormalRowHeight();
      nwvis = this.GetWidth() - this.FixedColWidth();
      nhvis = this.GetHeight() - this.FixedRowHeight();
      if (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) {
        nwvis = nwvis - 2;
        nhvis = nhvis - 2;
      };
      nwvisnoscroll = nwvis - pas["WEBLib.Controls"].GetScrollBarWidth();
      if ((this.FixedColWidth() + this.NormalColWidth()) < this.GetWidth()) {
        nhvisnoscroll = nhvis}
       else nhvisnoscroll = nhvis - pas["WEBLib.Controls"].GetScrollBarHeight();
      if ((this.FFixedRows > 0) && (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute)) {
        var td = this.FGrid.rows[0].cells[1];
        if (td!=null) {
        var span = td.firstChild;
        span.style.width = nwvisnoscroll + "px";
        span.style.overflow = "hidden";
        };
      };
      if ((this.FFixedCols > 0) && (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute)) {
        var td = this.FGrid.rows[1].cells[0];
        if (td!=null) {
        var span = td.firstChild;
        span.style.height = nhvisnoscroll + "px";
        span.style.overflow = "hidden";
        };
      };
    };
    this.RenderGridScript = function () {
      this.AddControlScriptSource("var TMSStringGridpageX,TMSStringGridcurCol,TMSStringGridnxtCol,TMSStringGridcurColWidth,TMSStringGridnxtColWidth,TMSStringGridautoWidth,GridNormalCells,GridFixedCells,GridFixedColCells,GridFixedColRows,GridColWidths,GridFixedCols,TMSStringGridCurID;" + "var TMSStringGridTable,TMSStringGridcurTableWidth,TMSStringGridID,TMSStringGridFullWidth,TMSGridLastColSize;" + "TMSStringGridautoWidth = false;" + 'TMSStringGridCurID = "";' + "ResizeMainGrid = true;" + "function TMSStringGridupdateColSize(Cells, Col) {" + "    if (Cells){" + "     for (i = 0; i < Cells.rows.length; i++){" + "       td = Cells.rows[i].cells[Col.cellIndex];" + '       td.style.position = "relative";' + "       td.style.width = Col.style.width;" + "       td.style.maxWidth = Col.style.width;" + "      }" + "    }" + "}" + "function TMSStringGridresizeColumn(e) {" + "   if ((TMSStringGridcurCol) && (TMSStringGridCurID.indexOf(TMSStringGridID) == 0)) {" + "    var diffX = e.pageX - TMSStringGridpageX;" + "    newColWidth = (TMSStringGridcurColWidth + diffX);" + "    if (newColWidth < 10)" + "      newColWidth = 10;" + '    if (TMSStringGridCurID.indexOf("ResizeRow") > 0) {' + '\t    TMSStringGridcurCol.style.width = newColWidth + "px";' + "\t    TMSStringGridcurCol.style.maxWidth = TMSStringGridcurCol.style.width;" + "     GridColWidths.Put(TMSStringGridcurCol.cellIndex + GridFixedCols, parseInt(TMSStringGridcurCol.style.width));" + "     TMSStringGridupdateColSize(GridFixedCells, TMSStringGridcurCol);" + "     TMSStringGridupdateColSize(GridNormalCells, TMSStringGridcurCol);" + '     TMSStringGridcurTable.style.width = (TMSStringGridcurTableWidth + diffX) + "px";' + '     GridNormalCells.style.width = (TMSStringGridcurTableWidth + diffX) + "px";' + "    } else {" + "     TMSStringGridfullWidth = document.getElementById(TMSStringGridID).offsetWidth;" + "     newCellsWidth = (TMSStringGridfullWidth - (TMSStringGridcurTableWidth + diffX));" + "     if ((newCellsWidth > 10) && (newColWidth > 10)) {" + '\t     TMSStringGridcurCol.style.width = newColWidth + "px";' + "\t     TMSStringGridcurCol.style.maxWidth = TMSStringGridcurCol.style.width;" + "      TMSStringGridupdateColSize(GridFixedColRows, TMSStringGridcurCol);" + "      TMSStringGridupdateColSize(GridFixedColCells, TMSStringGridcurCol);" + "      GridColWidths.Put(TMSStringGridcurCol.cellIndex, parseInt(TMSStringGridcurCol.style.width));" + '      TMSStringGridcurTable.style.width = (TMSStringGridcurTableWidth + diffX) + "px";' + '      GridFixedColCells.style.width = (TMSStringGridcurTableWidth + diffX) + "px";' + "      if ((!TMSStringGridautoWidth) && (newColWidth > 10)){" + '       GridFixedCells.parentElement.style.width = newCellsWidth + "px";' + '       GridFixedCells.parentElement.parentElement.style.width = newCellsWidth + "px";' + '       GridNormalCells.parentElement.style.width = newCellsWidth + "px";' + '       GridNormalCells.parentElement.parentElement.style.width = newCellsWidth + "px";' + "      }" + "     }" + "    }" + "   }" + " }" + "function TMSStringGridisSizing() {" + "   if ((TMSStringGridcurCol) && (TMSStringGridCurID.indexOf(TMSStringGridID) == 0))" + "   {" + '     if (TMSStringGridCurID.indexOf("ResizeRow") > 0)' + "     {" + "       return(TMSStringGridcurCol.cellIndex + GridFixedCols)" + "     }" + "     else" + "     {" + "      return(TMSStringGridcurCol.cellIndex)" + "     }" + "   }" + "  else  { return -1; }" + "   }" + "function TMSStringGridresetResize() {" + '   TMSStringGridID = "";' + "   TMSStringGridFullWidth = undefined;" + '   TMSStringGridCurID = "";' + "   TMSStringGridcurCol = undefined;" + "   TMSStringGridnxtCol = undefined;" + "   TMSStringGridpageX = undefined;" + "   TMSStringGridnxtColWidth = undefined;" + "   TMSStringGridcurColWidth = undefined;" + "   TMSStringGridautoWidth = false;" + "   GridFixedCells = undefined;" + "   GridFixedColCells = undefined;" + "   GridFixedColRows = undefined;" + "   GridNormalCells = undefined;" + "   GridColWidths = undefined;" + "   GridFixedCols = undefined;" + " }" + " function divmousedown(e) {" + "   TMSStringGridCurID = e.target.id;" + "   TMSStringGridcurCol = e.target.parentElement;" + "   TMSStringGridnxtCol = TMSStringGridcurCol.nextElementSibling;" + "   TMSStringGridpageX = e.pageX;" + "   TMSStringGridcurTable = TMSStringGridcurCol.parentElement.parentElement.parentElement;" + "   TMSStringGridcurTableWidth = TMSStringGridcurTable.offsetWidth;" + "   TMSStringGridcurColWidth = TMSStringGridcurCol.offsetWidth;" + "   if (TMSStringGridnxtCol)" + "    TMSStringGridnxtColWidth = TMSStringGridnxtCol.offsetWidth;" + " }" + "\r\n" + " function divmouseover(e) {" + '   e.target.style.borderRight = "2px solid #0000ff";}' + "\r\n" + " function divmouseout(e) {" + '   e.target.style.borderRight = "";}' + "\r\n" + " function divmouseup(e) {" + "   TMSGridLastColSize = TMSStringGridisSizing();" + "\r\n" + "   TMSStringGridresetResize();}" + "\r\n" + "function TMSStringGridresizableGrid(tablename, enabled) {" + ' var table = document.getElementById(tablename + "Table");' + " if (!table) return;" + ' var row = table.getElementsByTagName("tr")[0],' + " cols = row ? row.children : undefined;" + " if (!cols) return;" + " for (var i=0;i<cols.length;i++){" + '  var coldiv = document.getElementById(tablename + "Div" + i);' + "  if (coldiv) {" + '    coldiv.removeEventListener("mousedown",divmousedown);' + '    coldiv.removeEventListener("mouseover",divmouseover);' + '    coldiv.removeEventListener("mouseout",divmouseout);' + '    coldiv.removeEventListener("mouseup",divmouseup);' + "    coldiv.remove(); coldiv = null; }" + "  if (enabled) {" + "    var div = createDiv();" + "    cols[i].appendChild(div);" + '    cols[i].style.position = "relative";' + '    div.id = tablename + "Div" + i;' + "    setListeners(div);" + "  }" + " }" + " function setListeners(div){" + '  div.addEventListener("mousedown", divmousedown);' + '  div.addEventListener("mouseover", divmouseover);' + '  div.addEventListener("mouseout", divmouseout);' + '  div.addEventListener("mouseup", divmouseup);' + " }" + " function createDiv(){" + '  var div = document.createElement("div");' + "  div.style.top = 0;" + "  div.style.right = 0;" + '  div.style.width = "10px";' + '  div.style.position = "absolute";' + '  div.style.cursor = "col-resize";' + '  div.style.userSelect = "none";' + '  div.style.height = "100%";' + '  div.innerHTML = "&nbsp;";' + "  return div;" + " }" + "};");
    };
    this.UpdateGridSize = function () {
      var i = 0;
      var j = 0;
      var k = 0;
      var l = 0;
      var cw = 0;
      var rh = 0;
      var frh = 0;
      if (!(this.GetElementHandle() != null)) return;
      if (!(this.FParent != null)) return;
      if (this.IsUpdating()) return;
      if ((this.FRowCount === 0) || (this.FColCount === 0)) return;
      for (var $l = 0, $end = this.FFixedCols - 1; $l <= $end; $l++) {
        i = $l;
        cw = this.GetColWidths(i) - 0;
        if ((this.FFixedRows > 0) && (this.FFixedCols > 0)) {
          for (j = 0; j < this.FFixedColRow.rows.length; j ++){
           var tr = this.FFixedColRow.rows[j];
           if (tr) {
           var td = tr.cells[i];
           if (td) {
           td.style.width = cw + "px";
           td.style.maxWidth = cw + "px";
           }
           }
          };
        };
        if (this.FFixedCols > 0) {
          for (j = 0; j < this.FFixedCol.rows.length; j ++){
           var tr = this.FFixedCol.rows[j];
           if (tr) {
           var td = tr.cells[i];
           if (td) {
           td.style.width = cw + "px";
           td.style.maxWidth = cw + "px";
           }
           }
          };
        };
      };
      for (var $l1 = 0, $end1 = this.FFixedRows - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        rh = this.GetRowHeights(i);
        if (this.FFixedCols > 0) {
          var tr = this.FFixedColRow.rows[i];
          if (tr) {
            tr.style.height = rh + "px";
          };
        };
        var tr = this.FFixedRow.rows[i];
        if (tr) {
          tr.style.height = rh + "px";
        };
      };
      for (var $l2 = this.FFixedCols, $end2 = this.FColCount - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        cw = this.GetColWidths(i) - 0;
        k = i - this.FFixedCols;
        if (this.FFixedRows > 0) {
          //if (this.FFixedRow.rows.length > 0) {
          for (i = 0; i < this.FFixedRow.rows.length; i++) {
            var tr = this.FFixedRow.rows[i];
            if (tr) {
            var td = tr.cells[k];
            if (td) {
            td.style.width = cw + "px";
            td.style.maxWidth = cw + "px";
            }
            }
          };
        };
        if (this.FNormalCells.rows.length > 0) {
          var tr = this.FNormalCells.rows[0];
          if (tr) {
          var td = tr.cells[k];
          if (td) {
          td.style.width = cw + "px";
          td.style.maxWidth = cw + "px";
          }
          }
        };
      };
      for (var $l3 = this.FFixedRows, $end3 = this.FRowCount - 1; $l3 <= $end3; $l3++) {
        i = $l3;
        k = i - this.FFixedRows;
        rh = this.GetRowHeights(i);
        for (var $l4 = this.FFixedCols, $end4 = this.FColCount - 1; $l4 <= $end4; $l4++) {
          j = $l4;
          l = j - this.FFixedCols;
          cw = this.GetColWidths(j) - 0;
          frh = rh;
          if ((i === (this.FRowCount - 1)) && this.HasHorzScrollBar() && this.HasVertScrollBar()) {
            frh = rh + 20;
          };
          if (this.FFixedCols > 0) {
            var tr = this.FFixedCol.rows[k];
            if (tr) {
              tr.style.height = frh + "px";
            };
            if ((i === (this.FRowCount - 1)) && this.HasHorzScrollBar() && this.HasVertScrollBar()) {
              var td = this.FFixedCol.rows[k].cells[0];
              if (td) {
                td.style.setProperty("vertical-align","top");
              };
            };
          };
          var tr = this.FNormalCells.rows[k];
                  if (tr) {
                  tr.style.height = rh + "px";
          
                  td = tr.cells[l];
                  if (td) {
                  td.style.maxWidth = cw + "px";
                  }
                  };
        };
      };
    };
    this.UpdateGridAlignment = function () {
      var i = 0;
      var j = 0;
      var k = 0;
      var l = 0;
      var cw = 0;
      var rh = 0;
      var al = 0;
      if (!(this.GetElementHandle() != null)) return;
      if (this.IsUpdating()) return;
      if ((this.FRowCount === 0) || (this.FColCount === 0)) return;
      if (this.FColAlignments.GetCount() === 0) return;
      for (var $l = 0, $end = this.FFixedCols - 1; $l <= $end; $l++) {
        i = $l;
        al = this.GetColAlignments(i);
        j = i;
        if ((this.FFixedRows > 0) && (this.FFixedCols > 0)) {
          for (j = 0; j < this.FFixedColRow.rows.length; j ++){
           var tr = this.FFixedColRow.rows[j];
           if (tr) {
           var td = tr.cells[i];
           if (td) {
             this.SetAlignAttr(al, td);
             }
          }
          };
        };
        if (this.FFixedCols > 0) {
          for (j = 0; j < this.FFixedCol.rows.length; j ++){
           var tr = this.FFixedCol.rows[j];
           if (tr) {
             var td = tr.cells[i];
             if (td) {
             this.SetAlignAttr(al, td);
             }
           }
          };
        };
      };
      for (var $l1 = this.FFixedCols, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        al = this.GetColAlignments(i);
        k = i - this.FFixedCols;
        j = i;
        if (this.FFixedRows > 0) {
          //if (this.FFixedRow.rows.length > 0) {
          for (j = 0; j < this.FFixedRow.rows.length; j++) {
            var tr = this.FFixedRow.rows[j];
            if (tr) {
            var td = tr.cells[k];
            if (td) {
              this.SetAlignAttr(al, td);
             }
            }
          };
        };
        for (j = 0; j < this.FNormalCells.rows.length; j++) {
          var tr = this.FNormalCells.rows[j];
          if (tr) {
            var td = tr.cells[k];
            if (td) {
            this.SetAlignAttr(al, td);
            }
          }
        };
      };
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.RenderGridScript();
    };
    this.Resize = function () {
      pas["WEBLib.Controls"].TCustomControl.Resize.call(this);
      this.RenderGridSize();
    };
    this.DoEnter = function () {
    };
    this.DoExit = function () {
    };
    this.GridChanged = function () {
      $mod.TCustomGrid.GridChanged.call(this);
      if (this.FSelectedCell != null) this.RemoveSelection(this.FSelectedCell);
      if ((this.GetCol() >= 0) && (this.GetRow() >= 0)) {
        this.FSelectedCell = this.GetCellElements(this.GetCol(),this.GetRow())}
       else this.FSelectedCell = null;
      this.UpdateGridSize();
      this.UpdateGridAlignment();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      this.FGrid = null;
      return Result;
    };
    this.UpdateElement = function () {
      var clr = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if (this.GetElementHandle() != null) {
        if ((this.FColor !== 16711422) && (this.FColor !== -1)) this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
        if (this.FGrid != null) {
          pas["WEBLib.Controls"].SetHTMLElementFont(this.FGrid,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        };
        this.GetElementHandle().style.setProperty("overflow","hidden");
        if ((this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) && !(this.FBorderColor === -1) && (this.FElementClassName === "") && !this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("border","1px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FBorderColor));
        } else {
          this.GetElementHandle().style.setProperty("border","");
        };
        this.RenderGrid();
        clr = pas["WEBLib.Graphics"].ColorToHTML(this.FColor);
        if (this.FColor !== 16711422) {
          var bd = this.FNormalCells.tBodies[0];
          if (bd != undefined) {
            this.FNormalCells.tBodies[0].style.setProperty('background-color', clr);
            }
          this.FNormalCells.parentElement.parentElement.style.setProperty('background-color', clr);
        };
        if (this.FOrigID === "") {
          this.FOrigID = this.GetID();
          if (this.FOrigID === "") this.FOrigID = this.FName;
        };
        this.$class.AddInstanceStyle$1(this.StylePrefix() + this.FOrigID,this.GetGridCSS(this.FOrigID + "tbl"));
        if (this.FFixedCols < this.FColCount) this.SetColWidths(this.FFixedCols,this.GetColWidths(this.FFixedCols));
        this.UpdateGridSize();
        this.UpdateGridAlignment();
      };
    };
    this.UpdateElementVisual = function () {
      var fixcol = "";
      var fixtxtcol = "";
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.IsUpdating()) return;
      if ((this.GetElementHandle() != null) && (this.FGrid != null)) {
        fixcol = pas["WEBLib.Graphics"].ColorToHTML(this.FFixedColor);
        fixtxtcol = pas["WEBLib.Graphics"].ColorToHTML(this.GetFixedTextColor());
        if ((this.FFixedCols > 0) && (this.FFixedRows > 0)) {
          this.FFixedColRow.parentElement.style.setProperty('background-color',fixcol);
          this.FFixedColRow.parentElement.style.setProperty('color',fixtxtcol);
        };
        if (this.FFixedCols > 0) {
          this.FFixedCol.parentElement.style.setProperty('background-color',fixcol);
                  this.FFixedCol.parentElement.style.setProperty('color',fixtxtcol);
          
                  if (this.FFixedCol.parentElement.parentElement) {
                    this.FFixedCol.parentElement.parentElement.style.setProperty('background-color',fixcol);
                    this.FFixedCol.parentElement.parentElement.style.setProperty('color',fixtxtcol);
                  };
        };
        if (this.FFixedRows > 0) {
          this.FFixedRow.parentElement.style.setProperty('background-color',fixcol);
          this.FFixedRow.parentElement.style.setProperty('color',fixtxtcol);
          this.FFixedRow.parentElement.parentElement.style.setProperty('background-color',fixcol);
          this.FFixedRow.parentElement.parentElement.style.setProperty('color',fixtxtcol);
          if (this.FFixedRow.parentElement.parentElement.parentElement) {
            this.FFixedRow.parentElement.parentElement.parentElement.style.setProperty('background-color',fixcol);
            this.FFixedRow.parentElement.parentElement.parentElement.style.setProperty('color',fixtxtcol);
          };
        };
      };
    };
    this.FixedColWidth = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      for (var $l = 0, $end = this.FFixedCols - 1; $l <= $end; $l++) {
        i = $l;
        Result = (Result + this.GetColWidths(i)) - 0;
      };
      return Result;
    };
    this.FixedRowHeight = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      for (var $l = 0, $end = this.FFixedRows - 1; $l <= $end; $l++) {
        i = $l;
        Result = Result + this.GetRowHeights(i);
      };
      return Result;
    };
    this.NormalColWidth = function () {
      var Result = 0;
      var i = 0;
      Result = 1;
      for (var $l = this.FFixedCols, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        Result = (Result + this.GetColWidths(i) + 1) - 0;
      };
      return Result;
    };
    this.NormalRowHeight = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      for (var $l = this.FFixedRows, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        Result = Result + this.GetRowHeights(i);
      };
      return Result;
    };
    this.FocusedCell = function () {
      var Result = null;
      Result = this.FSelectedCell;
      return Result;
    };
    this.CanSelect = function (ACol, ARow) {
      var Result = false;
      Result = true;
      if (this.FOnSelectCell != null) this.FOnSelectCell(this,ACol,ARow,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.CanRowAdvance = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.HasSelection = function () {
      var Result = false;
      Result = !((this.GetSelection().Left === 0) && (this.GetSelection().Top === 0) && (this.GetSelection().Right === 0) && (this.GetSelection().Bottom === 0));
      return Result;
    };
    this.UpdateCell = function (ACol, ARow, AValue) {
    };
    this.ValidateCell = function (ACol, ARow, AValue) {
      if (this.FOnValidateEdit != null) this.FOnValidateEdit(this,ACol,ARow,AValue);
    };
    this.TopLeftChanged = function () {
      if (this.FOnTopLeftChanged != null) this.FOnTopLeftChanged(this);
    };
    this.RowCountChanged = function (delta) {
      var $Self = this;
      var r = 0;
      var fr = 0;
      var fc = 0;
      var nh = 0;
      function SetColAlign(column, td) {
        $Self.SetAlignAttr($Self.GetColAlignments(column),td);
      };
      if (this.IsUpdating() && (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      if (!(this.FNormalCells != null)) return;
      fr = this.FFixedRows;
      fc = this.FFixedCols;
      nh = this.NormalRowHeight();
      if (1 < 0) SetColAlign(0,null);
      if (delta > 0) {
        var i = 0;
              var j = 0;
              var tr = undefined;
              var td = undefined;
              var l = this.FNormalCells.rows.length;
        
              this.FNormalCells.parentElement.style.setProperty('height', nh + 'px');
        
              for(i = 0;i < delta; i++)
              {
                 tr = this.FNormalCells.insertRow(l);
                 for(j = this.FFixedCols; j < this.FColCount; j++)
                 {
                    td = tr.insertCell(0);
                    SetColAlign(j, td);
                 }
        
                 if (fc > 0) {
                   tr = this.FFixedCol.insertRow(l);
                   for(j = 0; j < this.FFixedCols; j++)
                   {
                     td = tr.insertCell(0);
                     td.setAttribute('class','fixed');
                     SetColAlign(j, td);
                   }
                 }
              };
        this.BeginUpdate();
        for (var $l = 1, $end = delta; $l <= $end; $l++) {
          r = $l;
          this.SetRowHeights(this.FRowCount - r,this.FDefaultRowHeight);
        };
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) this.EnableDrag();
        this.EndUpdate();
      };
      if (delta < 0) {
        var i = 0;
              var l = this.FNormalCells.rows.length;
        
              if (l > 0) {
        
              for(i = 0;i < -delta; i++)
              {
                this.FNormalCells.deleteRow(l - i - 1);
        
                if (fc > 0) {
                  this.FFixedCol.deleteRow(l - i - 1);
                }
              }
              };
        if (this.FRowCount > 0) this.SetRowHeights(this.FRowCount - 1,this.GetRowHeights(this.FRowCount - 1));
      };
    };
    this.ColCountChanged = function (delta) {
      var c = 0;
      if (this.IsUpdating() && (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      if (!(this.FNormalCells != null)) return;
      if (delta > 0) {
        var i = 0;
              var j = 0;
              var k = 0;
              var tr = undefined;
              var td = undefined;
              var sizediv,div = undefined;
        
              var l = this.FNormalCells.rows.length;
        
              for(j = 0; j < l; j++)
              {
                tr = this.FNormalCells.rows[j];
        
                k = tr.cells.length;
        
                 for(i = 0; i < delta; i++)
                 {
                   tr.insertCell(k);
                 }
              }
        
              for(j = 0; j < this.FFixedRows; j++)
              {
                k = this.FFixedRow.rows[j].cells.length;
        
                for(i = 0; i < delta; i++)
                {
                  td = this.FFixedRow.rows[j].insertCell(k);
                  td.setAttribute('class','fixed');
                  div = document.createElement("DIV");
                  div.style = 'position:relative;height:100%;width:100%';
                  td.appendChild(div);
                  sizediv = document.createElement("DIV");
                  sizediv.style = 'position:absolute;height:100%;width:5px;margin-right:-5px;left:100%;top:0px;cursor:w-resize;z-index:999;';
                  div.appendChild(sizediv);
                }
              };
        for (var $l = 1, $end = delta; $l <= $end; $l++) {
          c = $l;
          this.SetColWidths(this.FColCount - c,this.FDefaultColWidth);
        };
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) this.EnableDrag();
      };
      if (delta < 0) {
        var i = 0;
              var j = 0;
              var k = 0;
              var tr = undefined;
        
              var l = this.FNormalCells.rows.length;
        
              for(j = 0; j < l; j++)
              {
                tr = this.FNormalCells.rows[j];
        
                k = tr.cells.length;
        
                 for(i = 0; i < -delta; i++)
                 {
                   tr.deleteCell(k - i - 1);
                 }
              }
        
              if (this.FFixedRows > 0) {
        
              k = this.FFixedRow.rows[0].cells.length;
        
              for(i = 0; i < -delta; i++)
              {
                this.FFixedRow.rows[0].deleteCell(k- i - 1);
              }
              };
        if (this.FColCount > 0) this.SetColWidths(this.FColCount - 1,this.GetColWidths(this.FColCount - 1));
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleEditBlurPtr = null;
      this.FHandleEditKeypressPtr = null;
      this.FHandleCheckClickPtr = null;
      this.FHandleButtonClickPtr = null;
      this.FHandleMouseDownPtr = null;
      this.FHandleMouseUpPtr = null;
      this.FHandleMouseMovePtr = null;
      this.FHandleFixedClickPtr = null;
      this.FHandleBlurPtr = null;
      this.FHandleFocusPtr = null;
      this.FHandleClickPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleEditBlurPtr = rtl.createCallback(this,"HandleEditBlur");
      this.FHandleEditKeypressPtr = rtl.createCallback(this,"HandleEditKeyPress");
      this.FHandleCheckClickPtr = rtl.createCallback(this,"HandleCheckBoxClick");
      this.FHandleButtonClickPtr = rtl.createCallback(this,"HandleButtonClick");
      this.FHandleMouseDownPtr = rtl.createCallback(this,"HandleMouseDown");
      this.FHandleMouseUpPtr = rtl.createCallback(this,"HandleMouseUp");
      this.FHandleMouseMovePtr = rtl.createCallback(this,"HandleMouseMove");
      this.FHandleFixedClickPtr = rtl.createCallback(this,"HandleFixedClick");
      this.FHandleFocusPtr = rtl.createCallback(this,"HandleTableFocus");
      this.FHandleBlurPtr = rtl.createCallback(this,"HandleTableBlur");
      this.FHandleClickPtr = rtl.createCallback(this,"HandleClick");
    };
    this.StartEdit = function (ch) {
      var created = false;
      var eh = null;
      var s = "";
      var dorange = false;
      this.FEditorMode = true;
      if (this.FWordWrap) {
        this.FEditType = $mod.TGridCellEditor.geMemo}
       else this.FEditType = $mod.TGridCellEditor.geText;
      this.GetCellEditor(this.GetCol(),this.GetRow(),{p: this, get: function () {
          return this.p.FEditType;
        }, set: function (v) {
          this.p.FEditType = v;
        }});
      if (this.FEditType === $mod.TGridCellEditor.geNone) return;
      eh = this.GetElementHandle();
      this.FEditRow = this.GetRow();
      this.FEditCol = this.GetCol();
      this.FEditMode = true;
      s = this.GetEditText(this.GetCol(),this.GetRow());
      this.FOrigVal = s;
      if (this.FEditType === $mod.TGridCellEditor.geCombo) {
        if (!(this.FCombo != null)) {
          this.FCombo = pas["WEBLib.StdCtrls"].TWebComboBox.$create("Create$1",[this]);
          this.FCombo.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          this.FCombo.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
          this.FCombo.SetWidthPercent(100);
          this.FCombo.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
          this.FCombo.SetHeightPercent(100);
          this.FCombo.SetParent(this);
          this.FCombo.FOnExit = rtl.createCallback(this,"HandleComboExit");
          this.FCombo.FOnKeyPress = rtl.createCallback(this,"HandleComboKeyPress");
        };
        this.FCombo.FItems.Assign(this.FComboBoxItems);
        this.FCombo.SetText(s);
        this.FSelectedCell.innerHTML = "";
        this.FSelectedCell.appendChild(this.FCombo.GetElementHandle());
        this.FCombo.SetFocus();
        this.RemoveSelection(this.FSelectedCell);
        return;
      };
      if (this.FEditType === $mod.TGridCellEditor.geMemo) {
        if (!(this.FMemo != null)) {
          this.FMemo = pas["WEBLib.StdCtrls"].TWebMemo.$create("Create$1",[this]);
          this.FMemo.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          this.FMemo.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
          this.FMemo.SetWidthPercent(100);
          this.FMemo.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
          this.FMemo.SetParent(this);
          this.FMemo.GetElementHandle().style.setProperty("outline","none");
          this.FMemo.FOnExit = rtl.createCallback(this,"HandleMemoExit");
          this.FMemo.FOnKeyPress = rtl.createCallback(this,"HandleMemoKeyPress");
        };
        this.FMemo.SetHeight(this.GetRowHeights(this.FEditRow) - 3);
        this.FMemo.FLines.SetTextStr(s);
        this.FSelectedCell.innerHTML = "";
        this.FSelectedCell.style.setProperty("justify-content","top");
        this.FSelectedCell.style.setProperty("vertical-align","top");
        this.FSelectedCell.appendChild(this.FMemo.GetElementHandle());
        this.FMemo.SetFocus();
        this.RemoveSelection(this.FSelectedCell);
        return;
      };
      if (this.FEditType === $mod.TGridCellEditor.geCustom) {
        this.FEditControl.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        this.FEditControl.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
        this.FEditControl.SetWidthPercent(100);
        this.FEditControl.SetParent(this);
        this.FEditControl.FOnExit = rtl.createCallback(this,"DoEditControlExit");
        this.SetEditControlValue(this.FEditCol,this.FEditRow,this.FEditControl,s);
        this.FSelectedCell.innerHTML = "";
        this.FSelectedCell.style.setProperty("justify-content","top");
        this.FSelectedCell.style.setProperty("vertical-align","top");
        this.FSelectedCell.appendChild(this.FEditControl.GetElementHandle());
        this.RemoveSelection(this.FSelectedCell);
        return;
      };
      if (this.FEditType === $mod.TGridCellEditor.geMask) {
        if (!(this.FMask != null)) {
          this.FMask = pas["WEBLib.Mask"].TWebMaskEdit.$create("Create$1",[this]);
          this.FMask.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          this.FMask.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
          this.FMask.SetWidthPercent(100);
          this.FMask.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
          this.FMask.SetHeightPercent(100);
          this.FMask.SetParent(this);
          this.FMask.FOnExit = rtl.createCallback(this,"HandleMaskExit");
          this.FMask.FOnKeyPress = rtl.createCallback(this,"HandleMaskKeyPress");
        };
        this.FMask.SetEditMask(this.FEditMask);
        this.FMask.SetText(s);
        this.FSelectedCell.innerHTML = "";
        this.FSelectedCell.appendChild(this.FMask.GetElementHandle());
        this.FMask.SetFocus();
        this.FMask.SetSelection(0,s.length);
        this.RemoveSelection(this.FSelectedCell);
        return;
      };
      created = false;
      if (this.FEdit == undefined) {
            this.FEdit = document.createElement('INPUT');
            this.FEdit.style.setProperty('box-sizing','border-box');
            this.FEdit.style.setProperty('-webkit-box-sizing','border-box');
            this.FEdit.style.setProperty('-moz-box-sizing','border-box');
            this.FEdit.style.setProperty('outline', 'none');
            this.FEdit.style.setProperty('border-style', 'none');
      
            created = true;
          }
          this.FEdit.removeAttribute("type");
      var $tmp = this.FEditType;
      if ($tmp === $mod.TGridCellEditor.geURL) {
        this.FEdit.setAttribute("type","URL")}
       else if ($tmp === $mod.TGridCellEditor.geDate) {
        this.FEdit.setAttribute("type","DATE")}
       else if ($tmp === $mod.TGridCellEditor.geTime) {
        this.FEdit.setAttribute("type","TIME")}
       else if ($tmp === $mod.TGridCellEditor.geRange) {
        this.FEdit.setAttribute("type","RANGE");
        this.FEdit.setAttribute("min",pas["WEBLib.WebTools"].NumAttribute(this.FRange.FMin));
        this.FEdit.setAttribute("max",pas["WEBLib.WebTools"].NumAttribute(this.FRange.FMax));
        this.FEdit.setAttribute("step",pas["WEBLib.WebTools"].NumAttribute(this.FRange.FStep));
      } else if ($tmp === $mod.TGridCellEditor.geEmail) {
        this.FEdit.setAttribute("type","EMAIL")}
       else if ($tmp === $mod.TGridCellEditor.geNumber) {
        this.FEdit.setAttribute("type","NUMBER")}
       else if ($tmp === $mod.TGridCellEditor.geTel) {
        this.FEdit.setAttribute("type","TEL")}
       else if ($tmp === $mod.TGridCellEditor.geColor) this.FEdit.setAttribute("type","COLOR");
      dorange = this.FEditType === $mod.TGridCellEditor.geText;
      this.FEdit.removeAttribute("min");
          this.FEdit.removeAttribute("max");
          this.FEdit.removeAttribute("step");
      
          if (ch != '') {
            this.FEdit.value = "";
            }
          else {
            this.FEdit.value = s;
          }
      
          this.FEdit.style.width = "100%";
          this.FEdit.style.height = "100%";
          this.FEdit.style.fontFamily = eh.style.fontFamily;
          this.FEdit.style.fontSize = eh.style.fontSize;
      
          if (dorange) {
          this.FEdit.setSelectionRange(0, this.FEdit.value.length)
          }
      
          this.FSelectedCell.innerHTML = "";
          this.FSelectedCell.appendChild(this.FEdit);
      this.FEdit.focus();
      this.RemoveSelection(this.FSelectedCell);
      if (created) {
        this.FEdit.addEventListener("blur",this.FHandleEditBlurPtr);
        this.FEdit.addEventListener("keypress",this.FHandleEditKeypressPtr);
      };
    };
    this.StopEdit = function () {
      var Result = "";
      var val = "";
      var eh = null;
      this.FEditorMode = false;
      Result = "";
      if (this.FEditMode) {
        this.FEditMode = false;
        if (this.FEditType === $mod.TGridCellEditor.geCombo) {
          val = this.FCombo.GetText();
          eh = this.FCombo.GetElementHandle();
        } else if (this.FEditType === $mod.TGridCellEditor.geMask) {
          val = this.FMask.GetText();
          eh = this.FMask.GetElementHandle();
        } else {
          val = rtl.asExt(this.FEdit,HTMLInputElement).value;
          eh = this.FEdit;
        };
        this.ValidateCell(this.FEditCol,this.FEditRow,{get: function () {
            return val;
          }, set: function (v) {
            val = v;
          }});
        if (this.FSelectedCell.contains(eh)) this.FSelectedCell.removeChild(eh);
        this.FSelectedCell.innerHTML = val;
        Result = val;
        this.UpdateCell(this.FEditCol,this.FEditRow,{get: function () {
            return val;
          }, set: function (v) {
            val = v;
          }});
        if (!($mod.TGridOption.goRowSelect in this.FOptions)) {
          this.AddSelection(this.FSelectedCell);
        };
      };
      return Result;
    };
    this.CanEditCell = function (ACol, ARow) {
      var Result = false;
      var CanEdit = false;
      CanEdit = true;
      if (this.FOnCanEditCell != null) this.FOnCanEditCell(this,ACol,ARow,{get: function () {
          return CanEdit;
        }, set: function (v) {
          CanEdit = v;
        }});
      Result = CanEdit;
      return Result;
    };
    this.ChangeRow = function () {
    };
    this.EnableColResize = function () {
      var TableName = "";
      var ResizeEnabled = false;
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
        TableName = this.GetID() + "tblResizeRow";
        ResizeEnabled = $mod.TGridOption.goColSizing in this.FOptions;
        TMSStringGridresizableGrid(TableName, ResizeEnabled);
        TableName = this.GetID() + "tblResizeFixedRow";
        ResizeEnabled = $mod.TGridOption.goColSizing in this.FOptions;
        TMSStringGridresizableGrid(TableName, ResizeEnabled);
      };
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "TD") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "TD") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.BindCellButton = function (ACol, ARow, AElement) {
      var el = null;
      el = AElement.firstChild;
      if ((el != null) && (el.tagName === "BUTTON")) {
        el.addEventListener("click",this.FHandleButtonClickPtr);
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FDrawingStyle = $mod.TGridDrawingStyle.gdsThemed;
      return this;
    };
    this.Destroy = function () {
      var i = 0;
      var LObjr = null;
      rtl.free(this,"FRange");
      rtl.free(this,"FColWidths");
      rtl.free(this,"FColAlignments");
      rtl.free(this,"FRowHeights");
      rtl.free(this,"FRows");
      rtl.free(this,"FFixedFont");
      for (var $l = 0, $end = this.FObjectRows.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        LObjr = rtl.getObject(this.FObjectRows.Get(i));
        LObjr = rtl.freeLoc(LObjr);
      };
      this.FObjectRows.Clear();
      rtl.free(this,"FObjectRows");
      rtl.free(this,"FComboBoxItems");
      if (this.FCombo != null) rtl.free(this,"FCombo");
      if (this.FMask != null) rtl.free(this,"FMask");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FEditAdvance = false;
      this.FColWidths = pas.Classes.TList.$create("Create$1");
      this.FRowHeights = pas.Classes.TList.$create("Create$1");
      this.FColAlignments = pas.Classes.TList.$create("Create$1");
      this.FObjectRows = pas.Classes.TList.$create("Create$1");
      this.FRows = pas.Classes.TStringList.$create("Create$1");
      this.FRows.FOnChange = rtl.createCallback(this,"RowsChanged");
      this.FComboBoxItems = pas.Classes.TStringList.$create("Create$1");
      this.FRange = $mod.TGridRange.$create("Create$1");
      this.FHasMergedCells = false;
      this.FDefaultColAlignment = pas.Classes.TAlignment.taLeftJustify;
      this.FStartCell.X = -1;
      this.FStartCell.Y = -1;
      this.FFixedColor = 15790320;
      this.FRowCount = 5;
      this.FColCount = 5;
      this.FColor = 16711422;
      this.FFixedCols = 1;
      this.FFixedRows = 1;
      this.FDefaultColWidth = 64;
      this.FDefaultRowHeight = 22;
      this.FShowSelection = true;
      this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efProperty);
      this.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epAbsolute);
      this.FScrollBars = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      this.FGridLineColor = 12632256;
      this.FSelectionColor = 0xFF8F5B;
      this.FSelectionTextColor = 0xFFFFFF;
      this.FOptions = rtl.createSet($mod.TGridOption.goHorzLine,$mod.TGridOption.goVertLine,$mod.TGridOption.goRangeSelect);
      this.FFixedFont = pas["WEBLib.Graphics"].TFont.$create("Create$1");
      this.FFixedFont.FOnChange = rtl.createCallback(this,"FixedFontChanged");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.SetFocus = function () {
      if (this.FNormalCells != null) this.FNormalCells.focus();
    };
    this.ShowEdit = function () {
      this.StartEdit("");
    };
    this.HideEdit = function (Advance) {
      var val = "";
      var cval = "";
      var eh = null;
      var rh = 0;
      if (this.FEditMode) {
        this.FEditMode = false;
        if (this.FEditType === $mod.TGridCellEditor.geCombo) {
          val = this.FCombo.GetText();
          eh = this.FCombo.GetElementHandle();
        } else if (this.FEditType === $mod.TGridCellEditor.geMemo) {
          val = this.FMemo.FLines.GetTextStr();
          eh = this.FMemo.GetElementHandle();
        } else if (this.FEditType === $mod.TGridCellEditor.geMask) {
          val = this.FMask.GetText();
          eh = this.FMask.GetElementHandle();
        } else if (this.FEditType === $mod.TGridCellEditor.geCustom) {
          this.GetEditControlValue(this.FEditCol,this.FEditRow,this.FEditControl,{get: function () {
              return val;
            }, set: function (v) {
              val = v;
            }});
          eh = this.FEditControl.GetElementHandle();
          this.FSelectedCell.style.removeProperty("vertical-align");
        } else {
          val = rtl.asExt(this.FEdit,HTMLInputElement).value;
          eh = this.FEdit;
        };
        this.ValidateCell(this.FEditCol,this.FEditRow,{get: function () {
            return val;
          }, set: function (v) {
            val = v;
          }});
        if (this.FSelectedCell.contains(eh)) this.FSelectedCell.removeChild(eh);
        cval = val;
        if (this.FWordWrap) {
          rh = this.GetRowHeights(this.FEditRow) - 2;
          cval = '<DIV class="cell" style="height:' + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return rh;
            }, set: function (v) {
              rh = v;
            }}) + "px;max-height:" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return rh;
            }, set: function (v) {
              rh = v;
            }}) + 'px">' + cval + "</DIV>";
        };
        this.FSelectedCell.innerHTML = cval;
        this.UpdateCell(this.FEditCol,this.FEditRow,{get: function () {
            return val;
          }, set: function (v) {
            val = v;
          }});
        if (!($mod.TGridOption.goRowSelect in this.FOptions)) this.AddSelection(this.FSelectedCell);
        this.SetEditText(this.FEditCol,this.FEditRow,val);
        this.FBlockFocus = true;
        this.FNormalCells.focus();
        if (Advance) {
          this.RemoveSelection(this.FSelectedCell);
          if (this.GetCol() < (this.FColCount - 1)) {
            this.SetCol(this.GetCol() + 1)}
           else {
            if (this.CanRowAdvance()) {
              if (this.GetRow() < (this.FRowCount - 1)) {
                this.SetCol(this.FFixedCols);
                this.SetRow(this.GetRow() + 1);
              } else {
                this.SetCol(this.FFixedCols);
                this.SetRow(this.FFixedRows);
              };
            } else return;
          };
          if (this.CanEditCell(this.GetCol(),this.GetRow())) this.StartEdit("");
        };
      };
    };
    this.CancelEdit = function () {
      var eh = null;
      if (this.FEditMode) {
        if (this.FEditType === $mod.TGridCellEditor.geCombo) {
          eh = this.FCombo.GetElementHandle();
        } else if (this.FEditType === $mod.TGridCellEditor.geMemo) {
          eh = this.FMemo.GetElementHandle();
        } else if (this.FEditType === $mod.TGridCellEditor.geMask) {
          eh = this.FMask.GetElementHandle();
        } else {
          eh = this.FEdit;
        };
        this.FEditMode = false;
        this.ValidateCell(this.FEditCol,this.FEditRow,{p: this, get: function () {
            return this.p.FOrigVal;
          }, set: function (v) {
            this.p.FOrigVal = v;
          }});
        if (this.FSelectedCell.contains(eh)) this.FSelectedCell.removeChild(eh);
        this.FSelectedCell.innerHTML = this.FOrigVal;
        this.UpdateCell(this.FEditCol,this.FEditRow,{p: this, get: function () {
            return this.p.FOrigVal;
          }, set: function (v) {
            this.p.FOrigVal = v;
          }});
        if (!($mod.TGridOption.goRowSelect in this.FOptions)) {
          this.AddSelection(this.FSelectedCell);
        };
        this.SetEditText(this.FEditCol,this.FEditRow,this.FOrigVal);
        this.FBlockFocus = true;
        this.FNormalCells.focus();
      };
    };
    this.Clear = function () {
      var c = 0;
      var r = 0;
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        c = $l;
        for (var $l1 = 0, $end1 = this.FRowCount - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (this.HasButton(c,r)) this.RemoveButton(c,r);
          if (this.HasCheckBox(c,r)) this.RemoveCheckBox(c,r);
          this.SetCells(c,r,"");
        };
      };
    };
    this.ClearSelection = function () {
      var rselect = false;
      var tr = null;
      rselect = $mod.TGridOption.goRowSelect in this.FOptions;
      if ((this.FSelectedCell != null) && rselect) {
        tr = this.FSelectedCell.parentElement;
        this.RemoveSelection(tr);
      };
      this.SetSelection($mod.GridRect(0,0,0,0));
      if (this.FSelectedCell != null) {
        this.RemoveSelection(this.FSelectedCell);
      };
    };
    this.Invalidate = function () {
      pas["WEBLib.Controls"].TCustomControl.Invalidate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.ReRenderGrid();
    };
    this.InitSample = function (AInitMethod) {
      var i = 0;
      var j = 0;
      for (var $l = 0, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          var $tmp = AInitMethod;
          if ($tmp === $mod.TInitMethod.imRandom) {
            this.SetCells(j,i,pas.SysUtils.IntToStr(pas.System.Random(100)))}
           else if ($tmp === $mod.TInitMethod.imLinear) this.SetCells(j,i,pas.SysUtils.IntToStr(j) + ":" + pas.SysUtils.IntToStr(i));
        };
      };
    };
    this.Sort = function (AColumn, ADirection) {
      var colidx = 0;
      var grid = null;
      var asc = false;
      grid = this.FNormalCells;
      asc = ADirection === $mod.TGridSortIndicator.siAscending;
      colidx = AColumn - this.FFixedCols;
      if (colidx < 0) return;
      const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
          const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
            v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
            )(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
      
          const table = grid;
          Array.from(table.querySelectorAll('tr:nth-child(n+1)'))
              .sort(comparer(colidx, asc))
              .forEach(tr => table.appendChild(tr) );
    };
    this.MouseToCell = function (X, Y, C, R) {
      var DocX = 0.0;
      var DocY = 0.0;
      var el = null;
      var cindex = 0;
      var rindex = 0;
      var frm = null;
      cindex = -1;
      rindex = -1;
      this.ClientToXY(X,Y,{get: function () {
          return DocX;
        }, set: function (v) {
          DocX = v;
        }},{get: function () {
          return DocY;
        }, set: function (v) {
          DocY = v;
        }});
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm.FPopup) {
        DocX = DocX - frm.GetLeft();
        DocY = DocY - frm.GetTop();
      };
      el = document.elementFromPoint(Math.round(DocX),Math.round(DocY));
      if (el != null) {
        if (el.tagName.toLowerCase() == 'td')
              {
                cindex = el.cellIndex;
                var tr = el.parentElement;
                rindex = tr.rowIndex;
        
                if (tr.parentElement.parentElement == this.FNormalCells)
                {
                  rindex = rindex + this.FFixedRows;
                  cindex = cindex + this.FFixedCols;
                }
                if (tr.parentElement.parentElement == this.FFixedCol)
                {
                  rindex = rindex + this.FFixedRows;
                }
                if (tr.parentElement.parentElement == this.FFixedRow)
                {
                  cindex = cindex + this.FFixedCols;
                }
              };
      };
      R.set(rindex);
      C.set(cindex);
    };
    this.LoadFromJSON = function (AURL, ADataNode) {
      this.FDataNode = ADataNode;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadJson"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.LoadFromJSON$1 = function (AJSON, ADataNode) {
      var JO = undefined;
      var JA = null;
      var r = 0;
      var c = 0;
      var arow = "";
      var sl = null;
      var ce = null;
      var cd = "";
      var cn = "";
      if (ADataNode !== "") {
        JA = AJSON[ADataNode]}
       else JA = AJSON;
      if (JA != null) {
        sl = pas.Classes.TStringList.$create("Create$1");
        this.Clear();
        this.SetRowCount(JA.length + this.FFixedRows);
        for (var $l = 0, $end = JA.length - 1; $l <= $end; $l++) {
          r = $l;
          JO = JA[r];
          c = 0;
          arow = "";
          var x = undefined;
          for (x in JO) {
            arow += "|" + JO[x];
            c++;
          };
          pas.System.Delete({get: function () {
              return arow;
            }, set: function (v) {
              arow = v;
            }},1,1);
          sl.FStrictDelimiter = true;
          sl.SetDelimiter("|");
          sl.SetDelimitedText(arow);
          if (this.FColCount < sl.GetCount()) this.SetColCount(sl.GetCount() + this.FFixedCols);
          for (var $l1 = 0, $end1 = sl.GetCount() - 1; $l1 <= $end1; $l1++) {
            c = $l1;
            cd = sl.Get(c);
            this.GetCellData(this.FFixedCols + c,this.FFixedRows + r,null,{get: function () {
                return cd;
              }, set: function (v) {
                cd = v;
              }});
            this.SetCells(this.FFixedCols + c,this.FFixedRows + r,cd);
            cn = "";
            ce = this.GetCellElements(this.FFixedCols + c,this.FFixedRows + r);
            this.GetCellChildren(this.FFixedCols + c,this.FFixedRows + r,null,cd,ce);
            this.GetCellClassName(this.FFixedCols + c,this.FFixedRows + r,null,cd,{get: function () {
                return cn;
              }, set: function (v) {
                cn = v;
              }});
            if (cn !== "") ce.setAttribute("class",cn);
          };
        };
        sl = rtl.freeLoc(sl);
      };
      this.UpdateGridSize();
      this.UpdateGridAlignment();
    };
    this.LoadFromJSONAsync = function (AURL, ADataNode) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function DoLoad(Event) {
          var Result = false;
          if ($Self.DoHttpLoadJson(Event)) {
            ASuccess(Event.target)}
           else AFailed(Event.target);
          Result = true;
          return Result;
        };
        function DoError(Event) {
          var Result = false;
          AFailed(Event.target);
          Result = true;
          return Result;
        };
        $Self.FDataNode = ADataNode;
        $Self.FReq = new XMLHttpRequest();
        $Self.FReq.addEventListener("load",rtl.createSafeCallback(null,DoLoad));
        $Self.FReq.addEventListener("abort",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("timeout",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("error",rtl.createSafeCallback(null,DoError));
        $Self.FReq.open("GET",AURL);
        $Self.DoHttpRequest($Self.FReq);
        $Self.FReq.send();
      });
      return Result;
    };
    this.LoadFromCSV = function (AURL, Delimiter, LoadFixed) {
      this.FDelimiter = Delimiter;
      this.FLoadFixed = LoadFixed;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadCsv"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.LoadFromCSVAsync = function (AURL, Delimiter, LoadFixed) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function DoLoad(Event) {
          var Result = false;
          if ($Self.DoHttpLoadCsv(Event)) {
            ASuccess(Event.target)}
           else AFailed(Event.target);
          Result = true;
          return Result;
        };
        function DoError(Event) {
          var Result = false;
          AFailed(Event.target);
          Result = true;
          return Result;
        };
        $Self.FDelimiter = Delimiter;
        $Self.FLoadFixed = LoadFixed;
        $Self.FReq = new XMLHttpRequest();
        $Self.FReq.addEventListener("load",rtl.createSafeCallback(null,DoLoad));
        $Self.FReq.addEventListener("abort",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("timeout",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("error",rtl.createSafeCallback(null,DoError));
        $Self.FReq.open("GET",AURL);
        $Self.DoHttpRequest($Self.FReq);
        $Self.FReq.send();
      });
      return Result;
    };
    this.LoadFromStrings = function (AStrings, Delimiter, LoadFixed) {
      this.FDelimiter = Delimiter;
      this.FLoadFixed = LoadFixed;
      this.LoadFromStringList(AStrings);
    };
    this.SaveToCSV = function (AFileName, Delimiter, SaveFixed) {
      var sl = null;
      sl = pas.Classes.TStringList.$create("Create$1");
      try {
        this.SaveToStrings(sl,Delimiter,SaveFixed);
        sl.SaveToFile(AFileName);
      } finally {
        sl = rtl.freeLoc(sl);
      };
    };
    this.SaveToStrings = function (AStrings, Delimiter, SaveFixed) {
      var r = 0;
      var c = 0;
      var fr = 0;
      var fc = 0;
      var s = "";
      var rowstr = "";
      fr = 0;
      fc = 0;
      if (!SaveFixed) fc = this.FFixedCols;
      if (!SaveFixed) fr = this.FFixedRows;
      for (var $l = fr, $end = this.FRowCount - 1; $l <= $end; $l++) {
        r = $l;
        rowstr = "";
        for (var $l1 = fc, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          c = $l1;
          s = this.GetCells(c,r);
          s = pas.SysUtils.StringReplace(s,'"','""',rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
          if ((pas.System.Pos(Delimiter,s) > 0) || (pas.System.Pos("\r",s) > 0)) {
            s = '"' + s + '"';
          };
          if (s === "") s = '""';
          if (rowstr === "") {
            rowstr = s}
           else rowstr = rowstr + Delimiter + s;
        };
        AStrings.Add(rowstr);
      };
    };
    this.SelectCell = function (ACol, ARow) {
      var rc = 0;
      var rr = 0;
      this.SetSelection($mod.GridRect(ACol,ARow,ACol,ARow));
      rc = ACol - this.FFixedCols;
      rr = ARow - this.FFixedRows;
      if ((rc >= 0) && (rr >= 0)) {
        //if all rows are deleted then no indicator is displayed
        if (this.FNormalCells.rows.length <= 0)
        {
          this.FSelectedCell = null;
          this.UpdateIndicator(this.FFixedRows);
          return;
        }
        this.FSelectedCell = this.FNormalCells.rows[rr].cells[rc];
      } else {
        this.FSelectedCell = null;
      };
    };
    this.InsertRow = function (Index) {
      var i = 0;
      var fr = 0;
      fr = this.FFixedRows;
      var tr;
      var td;
      if (Index < this.FFixedRows) {
        if (this.FFixedCols > 0) {
          tr = this.FFixedColRow.insertRow(Index-fr);
          td = tr.insertCell(i-1);
          for (var $l = 0, $end = this.FFixedCols - 1; $l <= $end; $l++) {
            i = $l;
            td = tr.insertCell(i-1);
          };
        };
        tr = this.FFixedRow.insertRow(Index);
        for (var $l1 = this.FFixedCols, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          tr.insertCell(i-1);
        };
        this.FFixedRows = this.FFixedRows + 1;
      } else if (Index >= this.FFixedRows) {
        if (this.FFixedCols > 0) {
          tr = this.FFixedCol.insertRow(Index-fr);
          for (var $l2 = 0, $end2 = this.FFixedCols - 1; $l2 <= $end2; $l2++) {
            i = $l2;
            td = tr.insertCell(i-1);
          };
        };
        tr = this.FNormalCells.insertRow(Index-fr);
        for (var $l3 = this.FFixedCols, $end3 = this.FColCount - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          tr.insertCell(i-1);
        };
      };
      this.FRowCount = this.FRowCount + 1;
      this.SetRowHeights(Index,this.FDefaultRowHeight);
      this.UpdateGridSize();
      this.UpdateGridAlignment();
    };
    this.RemoveRow = function (Index) {
      var td = null;
      var tr = null;
      var fr = 0;
      var i = 0;
      if (Index >= this.FRowCount) throw pas.SysUtils.Exception.$create("Create$1",["Invalid row index"]);
      fr = this.FFixedRows;
      if (Index < this.FFixedRows) {
        if (this.FFixedCols > 0) {
          this.FFixedColRow.deleteRow(Index);
        };
        this.FFixedRow.deleteRow(Index);
      } else {
        if (this.FFixedCols > 0) {
          this.FFixedCol.deleteRow(Index -fr);
        };
        this.FNormalCells.deleteRow(Index - fr);
      };
      if (this.FRowHeights.GetCount() === this.FRowCount) this.FRowHeights.Delete(Index);
      this.FRowCount = this.FRowCount - 1;
      this.SetRowHeights(0,this.GetRowHeights(0));
      this.UpdateGridSize();
      this.UpdateGridAlignment();
    };
    this.InsertColumn = function (Index) {
      var i = 0;
      var fc = 0;
      fc = this.FFixedCols;
      var tr;
      var td;
      if (Index < this.FFixedCols) {
        if (this.FFixedRows > 0) {
          for (var $l = 0, $end = this.FFixedRows - 1; $l <= $end; $l++) {
            i = $l;
            tr = this.FFixedColRow.rows[i];
            td = tr.insertCell(Index);
          };
        };
        for (var $l1 = 0, $end1 = this.FRowCount - 1 - this.FFixedRows; $l1 <= $end1; $l1++) {
          i = $l1;
          tr = this.FFixedCol.rows[i];
          td = tr.insertCell(Index);
        };
        this.FFixedCols = this.FFixedCols + 1;
      } else {
        if (this.FFixedRows > 0) {
          for (var $l2 = 0, $end2 = this.FFixedRows - 1; $l2 <= $end2; $l2++) {
            i = $l2;
            tr = this.FFixedRow.rows[i];
            td = tr.insertCell(Index - fc);
          };
        };
        for (var $l3 = 0, $end3 = this.FRowCount - 1 - this.FFixedRows; $l3 <= $end3; $l3++) {
          i = $l3;
          tr = this.FNormalCells.rows[i];
          td = tr.insertCell(Index - fc);
        };
      };
      this.FColCount = this.FColCount + 1;
      for (var $l4 = this.FColCount - 1, $end4 = Index; $l4 >= $end4; $l4--) {
        i = $l4;
        if (Index > 0) this.SetColWidths(i,this.GetColWidths(i - 1));
      };
      this.SetColWidths(Index,this.FDefaultColWidth);
    };
    this.RemoveColumn = function (Index) {
      var i = 0;
      var fc = 0;
      fc = this.FFixedCols;
      var tr;
      var td;
      if (Index < this.FFixedCols) {
        if (this.FFixedRows > 0) {
          for (var $l = 0, $end = this.FFixedRows - 1; $l <= $end; $l++) {
            i = $l;
            tr = this.FFixedColRow.rows[i];
            td = tr.deleteCell(Index);
          };
        };
        for (var $l1 = 0, $end1 = this.FRowCount - 1 - this.FFixedRows; $l1 <= $end1; $l1++) {
          i = $l1;
          tr = this.FFixedCol.rows[i];
          td = tr.deleteCell(Index);
        };
        this.FFixedCols = this.FFixedCols - 1;
      } else {
        if (this.FFixedRows > 0) {
          for (var $l2 = 0, $end2 = this.FFixedRows - 1; $l2 <= $end2; $l2++) {
            i = $l2;
            tr = this.FFixedRow.rows[i];
            td = tr.deleteCell(Index - fc);
          };
        };
        for (var $l3 = 0, $end3 = this.FRowCount - 1 - this.FFixedRows; $l3 <= $end3; $l3++) {
          i = $l3;
          tr = this.FNormalCells.rows[i];
          td = tr.deleteCell(Index - fc);
        };
      };
      this.FColCount = this.FColCount - 1;
      for (var $l4 = Index, $end4 = this.FColCount - 1; $l4 <= $end4; $l4++) {
        i = $l4;
        this.SetColWidths(i,this.GetColWidths(i + 1));
      };
    };
    this.AddCheckBox = function (ACol, ARow, AState) {
      var chk = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        if (!this.HasCheckBox(ACol,ARow)) {
          chk = document.createElement("INPUT");
          chk.setAttribute("type","checkbox");
          chk.checked = AState;
          this.GetCellElements(ACol,ARow).insertBefore(chk,this.GetCellElements(ACol,ARow).firstChild);
          chk.addEventListener("click",this.FHandleCheckClickPtr);
        };
      };
    };
    this.RemoveCheckBox = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        if (el != null) {
          el.removeEventListener("click",this.FHandleCheckClickPtr);
          el.remove();
        };
      };
    };
    this.HasCheckBox = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        Result = el != null;
      };
      return Result;
    };
    this.AddButton = function (ACol, ARow, AText, AStyle) {
      var s = "";
      var ct = "";
      var el = null;
      if ((ARow >= 0) && (ACol >= 0) && !this.HasCheckBox(ACol,ARow)) {
        ct = this.GetCells(ACol,ARow);
        if (ct !== "") ct = "&nbsp;" + ct;
        s = '<BUTTON type="button" style="vertical-align:middle"';
        if (AStyle !== "") s = s + ' class="' + AStyle + '"';
        s = s + ">" + AText + "</BUTTON>";
        this.SetCells(ACol,ARow,s + ct);
        el = this.GetCellElements(ACol,ARow);
        this.BindCellButton(ACol,ARow,el);
      };
    };
    this.RemoveButton = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetButtonElement(ACol,ARow);
        if (el != null) {
          el.removeEventListener("click",this.FHandleCheckClickPtr);
          el.remove();
        };
      };
    };
    this.HasButton = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetButtonElement(ACol,ARow);
        Result = el != null;
      };
      return Result;
    };
    this.AddCanvas = function (ACol, ARow) {
      var el = null;
      var w = 0;
      var h = 0;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        if (!this.HasCanvas(ACol,ARow)) {
          w = this.GetColWidths(ACol);
          h = this.GetRowHeights(ARow);
          el = document.createElement("CANVAS");
          el.setAttribute("width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return w;
            }, set: function (v) {
              w = v;
            }}) + "px");
          el.setAttribute("height",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({a: h - 1, get: function () {
              return this.a;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }}) + "px");
          el.style.setProperty("display","block");
          this.GetCellElements(ACol,ARow).insertBefore(el,this.GetCellElements(ACol,ARow).firstChild);
        };
      };
    };
    this.RemoveCanvas = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCanvasElement(ACol,ARow);
        if (el != null) {
          el.remove();
        };
      };
    };
    this.HasCanvas = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCanvasElement(ACol,ARow);
        Result = el != null;
      };
      return Result;
    };
    this.GetCanvas$1 = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCanvasElement(ACol,ARow);
        if (el != null) Result = el;
      };
      return Result;
    };
    this.AddSortIndicator = function (ACol, ARow, AIndicator) {
      var s = "";
      var sid = "";
      var sp = 0;
      s = this.GetCells(ACol,ARow);
      sp = pas.System.Pos("<span",s);
      if (sp > 0) s = pas.System.Copy(s,1,sp - 1);
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      var $tmp = AIndicator;
      if ($tmp === $mod.TGridSortIndicator.siNone) {
        this.SetCells(ACol,ARow,s)}
       else if ($tmp === $mod.TGridSortIndicator.siAscending) {
        this.SetCells(ACol,ARow,s + '<span style="cursor:pointer;float:right" id="' + sid + '" sort="up">' + $impl.GlyphAscending + "</span>")}
       else if ($tmp === $mod.TGridSortIndicator.siDescending) this.SetCells(ACol,ARow,s + '<span style="cursor:pointer;float:right" id="' + sid + '" sort="dn">' + $impl.GlyphDescending + "</span>");
    };
    this.SelectSortIndicator = function (ACol, ARow, ASelect) {
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      if (el != null) {
        if (ASelect) {
          el.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionColor))}
         else el.style.removeProperty("color");
      };
    };
    this.SetSortIndicator = function (ACol, ARow, AIndicator) {
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      if (el != null) {
        if (AIndicator === $mod.TGridSortIndicator.siAscending) {
          el.innerHTML = $impl.GlyphAscending;
          el.setAttribute("sort","up");
        } else {
          el.innerHTML = $impl.GlyphDescending;
          el.setAttribute("sort","dn");
        };
      };
    };
    this.HasSortIndicator = function (ACol, ARow) {
      var Result = false;
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      Result = el != null;
      return Result;
    };
    this.RemoveSortIndicator = function (ACol, ARow) {
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      if (el != null) el.parentElement.removeChild(el);
    };
    this.AddProgress = function (ACol, ARow, APosition, AStyle) {
      var prog = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        if (!this.HasProgress(ACol,ARow)) {
          prog = document.createElement("PROGRESS");
          prog.setAttribute("max","100");
          prog.setAttribute("value",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return APosition;
            }, set: function (v) {
              APosition = v;
            }}));
          prog.style.setProperty("width","100%");
          if (AStyle !== "") prog.setAttribute("class",AStyle);
          this.GetCellElements(ACol,ARow).insertBefore(prog,this.GetCellElements(ACol,ARow).firstChild);
        };
      };
    };
    this.SetProgress = function (ACol, ARow, APosition) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetProgressElement(ACol,ARow);
        if (el != null) {
          el.setAttribute("value",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return APosition;
            }, set: function (v) {
              APosition = v;
            }}));
        };
      };
    };
    this.RemoveProgress = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetProgressElement(ACol,ARow);
        el.remove();
      };
    };
    this.HasProgress = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetProgressElement(ACol,ARow);
        Result = el != null;
      };
      return Result;
    };
    this.HasVertScrollBar = function () {
      var Result = false;
      Result = false;
      if (this.FNormalCells.parentElement != null) {
        Result = this.FNormalCells.parentElement.parentElement.clientHeight < this.FNormalCells.parentElement.scrollHeight;
      };
      return Result;
    };
    this.HasHorzScrollBar = function () {
      var Result = false;
      Result = false;
      if (this.FNormalCells.parentElement != null) {
        Result = this.FNormalCells.parentElement.parentElement.clientWidth < this.FNormalCells.parentElement.scrollWidth;
      };
      return Result;
    };
    this.MergeCells = function (ACol, ARow, NumCol, NumRow) {
      var i = 0;
      var j = 0;
      var el = null;
      var mel = null;
      var cw = 0;
      this.FHasMergedCells = true;
      mel = this.CellRealElement(ACol,ARow);
      for (var $l = NumCol; $l >= 1; $l--) {
        i = $l;
        for (var $l1 = NumRow; $l1 >= 1; $l1--) {
          j = $l1;
          if ((i > 1) || (j > 1)) {
            el = this.CellRealElement((ACol + i) - 1,(ARow + j) - 1);
            el.remove();
          };
        };
      };
      if (NumCol > 1) mel.setAttribute("colspan",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return NumCol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      if (NumRow > 1) mel.setAttribute("rowspan",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return NumRow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      if (ARow in rtl.createSet(0,1)) {
        cw = 0;
        for (var $l2 = ACol, $end = (ACol + NumCol) - 1; $l2 <= $end; $l2++) {
          i = $l2;
          cw = (cw + this.GetColWidths(i)) - 0;
          if (((ARow === 0) && ($mod.TGridOption.goFixedVertLine in this.FOptions)) || ((ARow === 1) && ($mod.TGridOption.goVertLine in this.FOptions))) if (NumCol > 1) cw += 1;
        };
        mel.style.setProperty("width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return cw;
          }, set: function (v) {
            cw = v;
          }}) + "px");
        mel.style.setProperty("max-width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return cw;
          }, set: function (v) {
            cw = v;
          }}) + "px");
      };
    };
    this.SplitCells = function (ACol, ARow) {
      var el = null;
      var td = null;
      var split = null;
      var i = 0;
      var j = 0;
      var NumRow = 0;
      var NumCol = 0;
      if (this.IsMergedCell(ACol,ARow,{get: function () {
          return NumCol;
        }, set: function (v) {
          NumCol = v;
        }},{get: function () {
          return NumRow;
        }, set: function (v) {
          NumRow = v;
        }})) {
        split = this.CellRealElement(ACol,ARow);
        for (var $l = 1, $end = Math.max(1,NumRow); $l <= $end; $l++) {
          i = $l;
          el = this.CellRealElement(ACol + Math.max(1,NumCol),(ARow + i) - 1);
          for (var $l1 = 1, $end1 = Math.max(1,NumCol); $l1 <= $end1; $l1++) {
            j = $l1;
            if ((j === 1) && (i === 1)) continue;
            td = document.createElement("TD");
            el.parentNode.insertBefore(td,el);
          };
        };
        split.setAttribute("colspan","");
        split.setAttribute("rowspan","");
        if (ARow === 0) {
          for (var $l2 = ACol, $end2 = (ACol + NumCol) - 1; $l2 <= $end2; $l2++) {
            i = $l2;
            this.SetColWidths(i,this.GetColWidths(i));
          };
        };
      };
    };
    this.IsMergedCell = function (ACol, ARow, NumCol, NumRow) {
      var Result = false;
      NumCol.set(this.CellColSpan(ACol,ARow));
      NumRow.set(this.CellRowSpan(ACol,ARow));
      Result = (NumCol.get() > 1) || (NumRow.get() > 1);
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 16711422});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("DefaultColAlignment",2,pas.Classes.$rtti["TAlignment"],"FDefaultColAlignment","SetDefaultColAlignment",4,{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("DefaultColWidth",2,rtl.longint,"FDefaultColWidth","SetDefaultColWidth",4,{Default: 64});
    $r.addProperty("DefaultRowHeight",2,rtl.longint,"FDefaultRowHeight","SetDefaultRowHeight",4,{Default: 24});
    $r.addProperty("EditAdvance",0,rtl.boolean,"FEditAdvance","FEditAdvance",4,{Default: false});
    $r.addProperty("EditMask",0,pas["WEBLib.Mask"].$rtti["TEditMask"],"FEditMask","FEditMask");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ElementTableClassName",2,rtl.string,"FElementTableClassName","SetElementTableClassName");
    $r.addProperty("FixedRows",2,rtl.longint,"FFixedRows","SetFixedRows",4,{Default: 1});
    $r.addProperty("FixedCols",2,rtl.longint,"FFixedCols","SetFixedCols",4,{Default: 1});
    $r.addProperty("FixedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FFixedColor","SetFixedColor",4,{Default: 15790320});
    $r.addProperty("FixedFont",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFixedFont","SetFixedFont");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("GridLineColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FGridLineColor","SetGridLineColor",4,{Default: 12632256});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Options",0,$mod.$rtti["TGridOptions"],"FOptions","FOptions");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ParentBiDiMode",0,rtl.boolean,"FParentBiDiMode","FParentBiDiMode",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("RangeEdit",2,$mod.$rtti["TGridRange"],"FRange","SetRange");
    $r.addProperty("Scrollbars",0,pas["WEBLib.Controls"].$rtti["TScrollStyle"],"FScrollBars","FScrollBars",4,{Default: pas["WEBLib.Controls"].TScrollStyle.ssBoth});
    $r.addProperty("SelectionColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectionColor","SetSelectionColor",4,{Default: 16748379});
    $r.addProperty("SelectionTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectionTextColor","SetSelectionTextColor",4,{Default: 16777215});
    $r.addProperty("ShowSelection",0,rtl.boolean,"FShowSelection","FShowSelection",4,{Default: true});
    $r.addProperty("StyleElements",0,pas["WEBLib.Controls"].$rtti["TStyleElements"],"FStyleElements","FStyleElements");
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",4,{Default: false});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnClickCell",0,$mod.$rtti["TCellEvent"],"FOnClickCell","FOnClickCell");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDblClickCell",0,$mod.$rtti["TCellEvent"],"FOnDblClickCell","FOnDblClickCell");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnMouseWheelDown",0,pas["WEBLib.Controls"].$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelDown","FOnMouseWheelDown");
    $r.addProperty("OnMouseWheelUp",0,pas["WEBLib.Controls"].$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelUp","FOnMouseWheelUp");
    $r.addProperty("OnCanEditCell",0,$mod.$rtti["TCellCanEditEvent"],"FOnCanEditCell","FOnCanEditCell");
    $r.addProperty("OnColumnSized",0,$mod.$rtti["TColumnSizedEvent"],"FOnColumnSized","FOnColumnSized");
    $r.addProperty("OnGetCellData",0,$mod.$rtti["TGridGetCellDataEvent"],"FOnGetCellData","FOnGetCellData");
    $r.addProperty("OnGetCellChildren",0,$mod.$rtti["TGridGetCellChildrenEvent"],"FOnGetCellChildren","FOnGetCellChildren");
    $r.addProperty("OnGetCellClass",0,$mod.$rtti["TGridGetCellClassEvent"],"FOnGetCellClass","FOnGetCellClass");
    $r.addProperty("OnGetCellEditor",0,$mod.$rtti["TGridGetCellEditorEvent"],"FOnGetCellEditor","FOnGetCellEditor");
    $r.addProperty("OnButtonClick",0,$mod.$rtti["TCellEvent"],"FOnButtonClick","FOnButtonClick");
    $r.addProperty("OnCheckClick",0,$mod.$rtti["TCellCheckEvent"],"FOnCheckClick","FOnCheckClick");
    $r.addProperty("OnFixedCellClick",0,$mod.$rtti["TCellEvent"],"FOnFixedCellClick","FOnFixedCellClick");
    $r.addProperty("OnGetEditText",0,$mod.$rtti["TGetEditEvent"],"FOnGetEditText","FOnGetEditText");
    $r.addProperty("OnSetEditText",0,$mod.$rtti["TSetEditEvent"],"FOnSetEditText","FOnSetEditText");
    $r.addProperty("OnSetEditControlValue",0,$mod.$rtti["TSetEditControlValueEvent"],"FOnSetEditControlValue","FOnSetEditControlValue");
    $r.addProperty("OnGetEditControlValue",0,$mod.$rtti["TGetEditControlValueEvent"],"FOnGetEditControlValue","FOnGetEditControlValue");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnSelectCell",0,$mod.$rtti["TSelectCellEvent"],"FOnSelectCell","FOnSelectCell");
    $r.addProperty("OnSortClick",0,$mod.$rtti["TGridSortClickEvent"],"FOnSortClick","FOnSortClick");
    $r.addProperty("OnTopLeftChanged",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnTopLeftChanged","FOnTopLeftChanged");
    $r.addProperty("OnValidateEdit",0,$mod.$rtti["TGetEditEvent"],"FOnValidateEdit","FOnValidateEdit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TStringGrid",this.TCustomStringGrid,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("ColCount",2,rtl.longint,"FColCount","SetColCount");
    $r.addProperty("RowCount",2,rtl.longint,"FRowCount","SetRowCount");
    $r.addProperty("OnHttpRequestError",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHttpRequestError","FOnHttpRequestError");
    $r.addProperty("OnHttpRequestSuccess",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHttpRequestSuccess","FOnHttpRequestSuccess");
  });
  rtl.createClass(this,"TWebStringGrid",this.TStringGrid,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TCustomTableControl");
  this.TTablePager = {"0": "tpNone", tpNone: 0, "1": "tpDropDown", tpDropDown: 1, "2": "tpLink", tpLink: 2, "3": "tpButton", tpButton: 3, "4": "tpList", tpList: 4, "5": "tpPrevNext", tpPrevNext: 5};
  this.$rtti.$Enum("TTablePager",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTablePager});
  this.TTablePagerAlign = {"0": "paRight", paRight: 0, "1": "paCenter", paCenter: 1, "2": "paLeft", paLeft: 2};
  this.$rtti.$Enum("TTablePagerAlign",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTablePagerAlign});
  rtl.createClass(this,"TTableControlHeader",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FPageEventPtr = null;
      this.FFilterEventPtr = null;
      this.FSearchEventPtr = null;
      this.FOwner = null;
      this.FElement = null;
      this.FPagerElement = null;
      this.FSearchElement = null;
      this.FFilterElement = null;
      this.FSearchInput = null;
      this.FFilterInput = null;
      this.FVisible = false;
      this.FCaption = "";
      this.FSearchValue = "";
      this.FFilterValue = "";
      this.FOnChange = null;
      this.FPager = 0;
      this.FButtonElementClassName = "";
      this.FLinkElementClassName = "";
      this.FDropDownElementClassName = "";
      this.FListElementClassName = "";
      this.FListItemElementClassName = "";
      this.FInputElementClassName = "";
      this.FFilterColumn = 0;
      this.FSearch = false;
      this.FFilter = false;
      this.FButtonActiveElementClassName = "";
      this.FLinkActiveElementClassName = "";
      this.FListLinkElementClassName = "";
      this.FPagerAlign = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FElement = undefined;
      this.FPagerElement = undefined;
      this.FSearchElement = undefined;
      this.FFilterElement = undefined;
      this.FSearchInput = undefined;
      this.FFilterInput = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetCaption = function (Value) {
      if (this.FCaption !== Value) {
        this.FCaption = Value;
        this.FOwner.RenderGrid();
      };
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.FOwner.ReRenderGrid();
      };
    };
    this.SetPager = function (Value) {
      if (this.FPager !== Value) {
        this.FPager = Value;
        this.Update(this.FOwner.FPaging.FSize,this.FOwner.FRowCount,this.FOwner.FPaging.FActivePage);
      };
    };
    this.SetPagerAlign = function (Value) {
      if (this.FPagerAlign !== Value) {
        this.FPagerAlign = Value;
        this.FOwner.ReRenderGrid();
      };
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Update = function (PageSize, RowCount, ActivePage) {
      var opt = null;
      var lnk = null;
      var itm = null;
      var btn = null;
      var i = 0;
      var numpages = 0;
      var trc = 0;
      if (!(this.FElement != null)) return;
      if (this.FSearchElement != null) {
        this.FSearchElement.parentElement.removeChild(this.FSearchElement);
        this.FSearchElement = null;
      };
      if (this.FFilterElement != null) {
        this.FFilterElement.parentElement.removeChild(this.FFilterElement);
        this.FFilterElement = null;
      };
      if (this.FSearch) {
        this.FSearchElement = document.createElement("DIV");
        this.FSearchElement.style.setProperty("float","left");
        this.FSearchInput = document.createElement("INPUT");
        if (this.FInputElementClassName !== "") this.FSearchInput.setAttribute("class",this.FInputElementClassName);
        this.FSearchInput.style.setProperty("display","inline");
        this.FSearchInput.style.setProperty("width","auto");
        btn = document.createElement("IMG");
        btn.setAttribute("src",pas["WEBLib.Ctrls.SVG"].ICON_SEARCH);
        btn.style.setProperty("vertical-align","middle");
        btn.style.setProperty("margin-right","10px");
        this.FSearchElement.appendChild(this.FSearchInput);
        this.FSearchElement.appendChild(btn);
        this.FElement.appendChild(this.FSearchElement);
        btn.addEventListener("click",this.FSearchEventPtr);
        this.FSearchInput.value = this.FSearchValue;
      };
      if (this.FFilter) {
        this.FFilterElement = document.createElement("DIV");
        this.FFilterElement.style.setProperty("float","left");
        this.FFilterInput = document.createElement("INPUT");
        if (this.FInputElementClassName !== "") this.FFilterInput.setAttribute("class",this.FInputElementClassName);
        this.FFilterInput.style.setProperty("display","inline");
        this.FFilterInput.style.setProperty("width","auto");
        btn = document.createElement("IMG");
        btn.setAttribute("src",pas["WEBLib.Ctrls.SVG"].ICON_FILTER);
        btn.style.setProperty("vertical-align","middle");
        btn.style.setProperty("margin-right","10px");
        this.FFilterElement.appendChild(this.FFilterInput);
        this.FFilterElement.appendChild(btn);
        this.FElement.appendChild(this.FFilterElement);
        btn.addEventListener("click",this.FFilterEventPtr);
        this.FFilterInput.value = this.FFilterValue;
      };
      trc = 0;
      if (this.FOwner.FRowHeader) trc += 1;
      numpages = rtl.trunc((RowCount - trc) / PageSize);
      if (((RowCount - trc) % PageSize) > 0) numpages += 1;
      this.FOwner.FPaging.FPageCount = numpages;
      if (this.FPagerElement != null) {
        this.FPagerElement.parentElement.removeChild(this.FPagerElement);
        this.FPagerElement = null;
      };
      if (!this.FOwner.FPaging.FEnabled) return;
      if (this.FPager === $mod.TTablePager.tpDropDown) {
        this.FPagerElement = document.createElement("SELECT");
        if (this.FDropDownElementClassName !== "") this.FPagerElement.setAttribute("class",this.FDropDownElementClassName);
        this.FPagerElement.addEventListener("change",this.FPageEventPtr);
        for (var $l = 0, $end = numpages - 1; $l <= $end; $l++) {
          i = $l;
          opt = document.createElement("option");
          opt.text = pas["WEBLib.Utils"].TLongIntHelper.ToString.call({a: i + 1, get: function () {
              return this.a;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }});
          opt.setAttribute("data",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }}));
          if (i === ActivePage) opt.setAttribute("selected","selected");
          this.FPagerElement.add(opt);
        };
        var $tmp = this.FPagerAlign;
        if ($tmp === $mod.TTablePagerAlign.paRight) {
          this.FPagerElement.style.setProperty("float","right")}
         else if ($tmp === $mod.TTablePagerAlign.paLeft) {
          this.FPagerElement.style.setProperty("float","left")}
         else if ($tmp === $mod.TTablePagerAlign.paCenter) {
          this.FPagerElement.style.removeProperty("float");
          this.FPagerElement.style.setProperty("max-width","content");
          this.FPagerElement.style.setProperty("margin-left","auto");
          this.FPagerElement.style.setProperty("margin-right","auto");
        };
        this.FPagerElement.style.setProperty("display","inline");
        this.FPagerElement.style.setProperty("width","auto");
        this.FElement.appendChild(this.FPagerElement);
      };
      if (this.FPager === $mod.TTablePager.tpLink) {
        this.FPagerElement = document.createElement("DIV");
        for (var $l1 = 0, $end1 = numpages - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          lnk = document.createElement("A");
          lnk.innerHTML = pas["WEBLib.Utils"].TLongIntHelper.ToString.call({a: i + 1, get: function () {
              return this.a;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }});
          lnk.setAttribute("href","#");
          if (this.FLinkElementClassName !== "") {
            if ((i === ActivePage) && (this.FLinkActiveElementClassName !== "")) {
              lnk.setAttribute("class",this.FLinkActiveElementClassName)}
             else lnk.setAttribute("class",this.FLinkElementClassName);
          };
          lnk.style.setProperty("margin-right","4px");
          lnk.style.setProperty("display","inline");
          lnk.setAttribute("data",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }}));
          lnk.addEventListener("click",this.FPageEventPtr);
          this.FPagerElement.appendChild(lnk);
        };
        var $tmp1 = this.FPagerAlign;
        if ($tmp1 === $mod.TTablePagerAlign.paRight) {
          this.FPagerElement.style.setProperty("float","right")}
         else if ($tmp1 === $mod.TTablePagerAlign.paLeft) {
          this.FPagerElement.style.setProperty("float","left")}
         else if ($tmp1 === $mod.TTablePagerAlign.paCenter) {
          this.FPagerElement.style.removeProperty("float");
          this.FPagerElement.style.setProperty("max-width","content");
          this.FPagerElement.style.setProperty("margin-left","auto");
          this.FPagerElement.style.setProperty("margin-right","auto");
        };
        this.FElement.appendChild(this.FPagerElement);
      };
      if (this.FPager === $mod.TTablePager.tpButton) {
        this.FPagerElement = document.createElement("DIV");
        for (var $l2 = 0, $end2 = numpages - 1; $l2 <= $end2; $l2++) {
          i = $l2;
          lnk = document.createElement("BUTTON");
          lnk.innerHTML = pas["WEBLib.Utils"].TLongIntHelper.ToString.call({a: i + 1, get: function () {
              return this.a;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }});
          if (this.FButtonElementClassName !== "") {
            if ((i === ActivePage) && (this.FButtonActiveElementClassName !== "")) {
              lnk.setAttribute("class",this.FButtonActiveElementClassName)}
             else lnk.setAttribute("class",this.FButtonElementClassName);
          };
          lnk.setAttribute("data",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }}));
          lnk.addEventListener("click",this.FPageEventPtr);
          lnk.style.setProperty("margin-right","4px");
          this.FPagerElement.appendChild(lnk);
        };
        var $tmp2 = this.FPagerAlign;
        if ($tmp2 === $mod.TTablePagerAlign.paRight) {
          this.FPagerElement.style.setProperty("float","right")}
         else if ($tmp2 === $mod.TTablePagerAlign.paLeft) {
          this.FPagerElement.style.setProperty("float","left")}
         else if ($tmp2 === $mod.TTablePagerAlign.paCenter) {
          this.FPagerElement.style.removeProperty("float");
          this.FPagerElement.style.setProperty("max-width","content");
          this.FPagerElement.style.setProperty("margin-left","auto");
          this.FPagerElement.style.setProperty("margin-right","auto");
        };
        this.FElement.appendChild(this.FPagerElement);
      };
      if (this.FPager === $mod.TTablePager.tpPrevNext) {
        this.FPagerElement = document.createElement("DIV");
        lnk = document.createElement("BUTTON");
        lnk.innerHTML = "&#xab;";
        lnk.setAttribute("data","0");
        if (this.FButtonElementClassName !== "") lnk.setAttribute("class",this.FButtonElementClassName);
        lnk.addEventListener("click",this.FPageEventPtr);
        lnk.style.setProperty("margin-right","4px");
        if (this.FOwner.FPaging.FActivePage === 0) lnk.setAttribute("disabled","");
        this.FPagerElement.appendChild(lnk);
        lnk = document.createElement("BUTTON");
        lnk.innerHTML = "&#x2039";
        lnk.setAttribute("data","1");
        if (this.FButtonElementClassName !== "") lnk.setAttribute("class",this.FButtonElementClassName);
        lnk.addEventListener("click",this.FPageEventPtr);
        lnk.style.setProperty("margin-right","4px");
        if (this.FOwner.FPaging.FActivePage === 0) lnk.setAttribute("disabled","");
        this.FPagerElement.appendChild(lnk);
        lnk = document.createElement("BUTTON");
        lnk.innerHTML = "&#x203A;";
        lnk.setAttribute("data","2");
        if (this.FButtonElementClassName !== "") lnk.setAttribute("class",this.FButtonElementClassName);
        lnk.addEventListener("click",this.FPageEventPtr);
        lnk.style.setProperty("margin-right","4px");
        if (this.FOwner.FPaging.FActivePage === this.FOwner.FPaging.FPageCount) lnk.setAttribute("disabled","");
        this.FPagerElement.appendChild(lnk);
        lnk = document.createElement("BUTTON");
        lnk.innerHTML = "&#xbb;";
        lnk.setAttribute("data","3");
        lnk.addEventListener("click",this.FPageEventPtr);
        if (this.FButtonElementClassName !== "") lnk.setAttribute("class",this.FButtonElementClassName);
        lnk.style.setProperty("margin-right","4px");
        this.FPagerElement.appendChild(lnk);
        var $tmp3 = this.FPagerAlign;
        if ($tmp3 === $mod.TTablePagerAlign.paRight) {
          this.FPagerElement.style.setProperty("float","right")}
         else if ($tmp3 === $mod.TTablePagerAlign.paLeft) {
          this.FPagerElement.style.setProperty("float","left")}
         else if ($tmp3 === $mod.TTablePagerAlign.paCenter) {
          this.FPagerElement.style.removeProperty("float");
          this.FPagerElement.style.setProperty("max-width","content");
          this.FPagerElement.style.setProperty("margin-left","auto");
          this.FPagerElement.style.setProperty("margin-right","auto");
        };
        if (this.FOwner.FPaging.FActivePage === this.FOwner.FPaging.FPageCount) lnk.setAttribute("disabled","");
        this.FElement.appendChild(this.FPagerElement);
      };
      if (this.FPager === $mod.TTablePager.tpList) {
        this.FPagerElement = document.createElement("UL");
        if (this.FListElementClassName !== "") this.FPagerElement.setAttribute("class",this.FListElementClassName);
        this.FPagerElement.style.setProperty("margin","0px");
        for (var $l3 = 0, $end3 = numpages - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          itm = document.createElement("LI");
          if (this.FListItemElementClassName !== "") {
            if (i === ActivePage) {
              itm.setAttribute("class",this.FListItemElementClassName + " active")}
             else itm.setAttribute("class",this.FListItemElementClassName);
          };
          lnk = document.createElement("A");
          lnk.innerHTML = pas["WEBLib.Utils"].TLongIntHelper.ToString.call({a: i + 1, get: function () {
              return this.a;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }});
          lnk.setAttribute("href","#");
          lnk.setAttribute("data",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }}));
          lnk.addEventListener("click",this.FPageEventPtr);
          if (this.FListLinkElementClassName !== "") lnk.setAttribute("class",this.FListLinkElementClassName);
          itm.appendChild(lnk);
          this.FPagerElement.appendChild(itm);
        };
        var $tmp4 = this.FPagerAlign;
        if ($tmp4 === $mod.TTablePagerAlign.paRight) {
          this.FPagerElement.style.setProperty("float","right")}
         else if ($tmp4 === $mod.TTablePagerAlign.paLeft) {
          this.FPagerElement.style.setProperty("float","left")}
         else if ($tmp4 === $mod.TTablePagerAlign.paCenter) {
          this.FPagerElement.style.removeProperty("float");
          this.FPagerElement.style.setProperty("max-width","content");
          this.FPagerElement.style.setProperty("margin-left","auto");
          this.FPagerElement.style.setProperty("margin-right","auto");
        };
        this.FElement.appendChild(this.FPagerElement);
      };
    };
    this.HandlePagerClick = function (Event) {
      var Result = false;
      var idx = 0;
      var s = "";
      Event.preventDefault();
      Event.stopPropagation();
      Result = true;
      if (this.FPager === $mod.TTablePager.tpDropDown) {
        idx = this.FPagerElement.selectedIndex;
      } else if (this.FPager === $mod.TTablePager.tpPrevNext) {
        s = Event.target.getAttribute("data");
        idx = pas.SysUtils.StrToInt(s);
        var $tmp = idx;
        if ($tmp === 0) {
          if (this.FOwner.FPaging.FActivePage > 0) {
            idx = 0}
           else return Result}
         else if ($tmp === 1) {
          if (this.FOwner.FPaging.FActivePage > 0) {
            idx = this.FOwner.FPaging.FActivePage - 1}
           else return Result}
         else if ($tmp === 2) {
          if (this.FOwner.FPaging.FActivePage < (this.FOwner.FPaging.FPageCount - 1)) {
            idx = this.FOwner.FPaging.FActivePage + 1}
           else return Result}
         else if ($tmp === 3) if (this.FOwner.FPaging.FActivePage < (this.FOwner.FPaging.FPageCount - 1)) {
          idx = this.FOwner.FPaging.FPageCount - 1}
         else return Result;
      } else {
        s = Event.target.getAttribute("data");
        idx = pas.SysUtils.StrToInt(s);
      };
      this.FOwner.DoSelectPage(idx);
      return Result;
    };
    this.HandleSearchClick = function (Event) {
      var Result = false;
      var cond = "";
      cond = this.FSearchInput.value;
      if ((cond !== "") && (cond !== this.FSearchValue)) {
        this.FSearchValue = cond;
        this.FOwner.FindCell(this.FSearchValue,true,false);
      } else this.FOwner.FindNext();
      Result = true;
      return Result;
    };
    this.HandleFilterClick = function (Event) {
      var Result = false;
      var cond = "";
      cond = this.FFilterInput.value;
      if ((cond === "") || (cond !== this.FFilterValue)) this.FOwner.RemoveFilter();
      if (cond !== "") {
        this.FFilterValue = cond;
        this.FOwner.SetFilter(this.FFilterColumn,this.FFilterValue,true);
      };
      Result = true;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.FOwner = AOwner;
      this.FPagerElement = null;
      this.FPagerAlign = $mod.TTablePagerAlign.paRight;
      this.FPageEventPtr = rtl.createCallback(this,"HandlePagerClick");
      this.FSearchEventPtr = rtl.createCallback(this,"HandleSearchClick");
      this.FFilterEventPtr = rtl.createCallback(this,"HandleFilterClick");
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTableControlHeader.isPrototypeOf(Source)) {
        this.FCaption = rtl.as(Source,$mod.TTableControlHeader).FCaption;
        this.FVisible = rtl.as(Source,$mod.TTableControlHeader).FVisible;
        this.FPager = rtl.as(Source,$mod.TTableControlHeader).FPager;
        this.FPagerAlign = rtl.as(Source,$mod.TTableControlHeader).FPagerAlign;
        this.FButtonActiveElementClassName = rtl.as(Source,$mod.TTableControlHeader).FButtonActiveElementClassName;
        this.FButtonElementClassName = rtl.as(Source,$mod.TTableControlHeader).FButtonElementClassName;
        this.FLinkActiveElementClassName = rtl.as(Source,$mod.TTableControlHeader).FLinkActiveElementClassName;
        this.FLinkElementClassName = rtl.as(Source,$mod.TTableControlHeader).FLinkElementClassName;
        this.FDropDownElementClassName = rtl.as(Source,$mod.TTableControlHeader).FDropDownElementClassName;
        this.FInputElementClassName = rtl.as(Source,$mod.TTableControlHeader).FInputElementClassName;
        this.FFilterColumn = rtl.as(Source,$mod.TTableControlHeader).FFilterColumn;
        this.FFilter = rtl.as(Source,$mod.TTableControlHeader).FFilter;
        this.FSearch = rtl.as(Source,$mod.TTableControlHeader).FSearch;
        this.FListElementClassName = rtl.as(Source,$mod.TTableControlHeader).FListElementClassName;
        this.FListItemElementClassName = rtl.as(Source,$mod.TTableControlHeader).FListItemElementClassName;
        this.FListLinkElementClassName = rtl.as(Source,$mod.TTableControlHeader).FListLinkElementClassName;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("FilterColumn",0,rtl.longint,"FFilterColumn","FFilterColumn",4,{Default: 0});
    $r.addProperty("Filter",0,rtl.boolean,"FFilter","FFilter",4,{Default: false});
    $r.addProperty("Search",0,rtl.boolean,"FSearch","FSearch",4,{Default: false});
    $r.addProperty("ButtonActiveElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FButtonActiveElementClassName","FButtonActiveElementClassName");
    $r.addProperty("ButtonElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FButtonElementClassName","FButtonElementClassName");
    $r.addProperty("DropDownElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FDropDownElementClassName","FDropDownElementClassName");
    $r.addProperty("InputElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FInputElementClassName","FInputElementClassName");
    $r.addProperty("LinkActiveElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FLinkActiveElementClassName","FLinkActiveElementClassName");
    $r.addProperty("LinkElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FLinkElementClassName","FLinkElementClassName");
    $r.addProperty("ListElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FListElementClassName","FListElementClassName");
    $r.addProperty("ListLinkElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FListLinkElementClassName","FListLinkElementClassName");
    $r.addProperty("ListItemElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FListItemElementClassName","FListItemElementClassName");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Pager",2,$mod.$rtti["TTablePager"],"FPager","SetPager");
    $r.addProperty("PagerAlign",2,$mod.$rtti["TTablePagerAlign"],"FPagerAlign","SetPagerAlign",4,{Default: $mod.TTablePagerAlign.paRight});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: false});
  });
  rtl.createClass(this,"TTableControlPaging",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FSize = 0;
      this.FIndex = 0;
      this.FEnabled = false;
      this.FActivePage = 0;
      this.FPageCount = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetIndex = function (Value) {
      if ((this.FIndex !== Value) && (Value >= 0)) {
        if (this.FOwner.FPaging.FSize !== 0) if (!(Value < rtl.trunc(this.FOwner.FRowCount / this.FOwner.FPaging.FSize))) return;
        this.FActivePage = Value;
        this.FIndex = Value;
        this.FOwner.DoSelectPage(this.FIndex);
      };
    };
    this.SetSize = function (Value) {
      var FOldSize = 0;
      if (this.FSize !== Value) {
        FOldSize = this.FSize;
        this.FSize = Value;
        this.FOwner.RowCountChanged(this.FSize - FOldSize);
        this.FOwner.GridChanged();
      };
    };
    this.SetEnabled = function (Value) {
      var rh = 0;
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        rh = 0;
        if (this.FOwner.FRowHeader) rh = 1;
        if (this.FEnabled) {
          this.FOwner.RowCountChanged((this.FSize + rh) - this.FOwner.FRowCount)}
         else this.FOwner.RowCountChanged(this.FOwner.FRowCount - this.FSize - rh);
        this.FOwner.ReRenderGrid();
      };
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.FOwner = AOwner;
      this.FSize = 10;
      this.FIndex = 0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTableControlPaging.isPrototypeOf(Source)) {
        this.FEnabled = rtl.as(Source,$mod.TTableControlPaging).FEnabled;
        this.FSize = rtl.as(Source,$mod.TTableControlPaging).FSize;
        this.FIndex = rtl.as(Source,$mod.TTableControlPaging).FActivePage;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: false});
    $r.addProperty("Index",2,rtl.longint,"FActivePage","SetIndex",4,{Default: 0});
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",4,{Default: 10});
  });
  rtl.createClass(this,"TTableControlOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FScrollVertical = false;
      this.FResizeColumns = false;
      this.FAutoCellURL = false;
      this.FAutoCellEmail = false;
      this.FAutoCellImage = false;
      this.FCellBorderColor = 0;
      this.FCellBorders = false;
      this.FAutoNumAlign = false;
      this.FImageAlign = 0;
      this.FImageWidth = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetResizeColumns = function (Value) {
      this.FResizeColumns = Value;
      this.FOwner.EnableColResize();
    };
    this.SetCellBorderColor = function (Value) {
      this.FCellBorderColor = Value;
      this.FOwner.RenderGridBorders();
    };
    this.SetCellBorders = function (Value) {
      this.FCellBorders = Value;
      this.FOwner.RenderGridBorders();
    };
    this.SetScrollVertical = function (Value) {
      this.FScrollVertical = Value;
      this.FOwner.UpdateElement();
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FCellBorderColor = 12632256;
      this.FImageAlign = pas.Classes.TAlignment.taLeftJustify;
      this.FImageWidth = 0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTableControlOptions.isPrototypeOf(Source)) {
        this.FScrollVertical = rtl.as(Source,$mod.TTableControlOptions).FScrollVertical;
        this.FResizeColumns = rtl.as(Source,$mod.TTableControlOptions).FResizeColumns;
        this.FAutoCellURL = rtl.as(Source,$mod.TTableControlOptions).FAutoCellURL;
        this.FAutoCellEmail = rtl.as(Source,$mod.TTableControlOptions).FAutoCellEmail;
        this.FAutoCellImage = rtl.as(Source,$mod.TTableControlOptions).FAutoCellImage;
        this.FAutoNumAlign = rtl.as(Source,$mod.TTableControlOptions).FAutoNumAlign;
        this.FCellBorders = rtl.as(Source,$mod.TTableControlOptions).FCellBorders;
        this.FCellBorderColor = rtl.as(Source,$mod.TTableControlOptions).FCellBorderColor;
        this.FImageWidth = rtl.as(Source,$mod.TTableControlOptions).FImageWidth;
        this.FImageAlign = rtl.as(Source,$mod.TTableControlOptions).FImageAlign;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("AutoCellEmail",0,rtl.boolean,"FAutoCellEmail","FAutoCellEmail",4,{Default: false});
    $r.addProperty("AutoCellURL",0,rtl.boolean,"FAutoCellURL","FAutoCellURL",4,{Default: false});
    $r.addProperty("AutoCellImage",0,rtl.boolean,"FAutoCellImage","FAutoCellImage",4,{Default: false});
    $r.addProperty("AutoNumAlign",0,rtl.boolean,"FAutoNumAlign","FAutoNumAlign",4,{Default: false});
    $r.addProperty("CellBorders",2,rtl.boolean,"FCellBorders","SetCellBorders",4,{Default: false});
    $r.addProperty("CellBorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FCellBorderColor","SetCellBorderColor",4,{Default: 12632256});
    $r.addProperty("ImageAlign",0,pas.Classes.$rtti["TAlignment"],"FImageAlign","FImageAlign",4,{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("ImageWidth",0,rtl.longint,"FImageWidth","FImageWidth",4,{Default: 0});
    $r.addProperty("ScrollVertical",2,rtl.boolean,"FScrollVertical","SetScrollVertical",4,{Default: false});
    $r.addProperty("ResizeColumns",2,rtl.boolean,"FResizeColumns","SetResizeColumns",4,{Default: false});
  });
  this.$rtti.$MethodVar("TPageSelectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["NewPage",rtl.longint],["Allow",rtl.boolean,1],["DefaultSelect",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TCustomTableControl",this.TCustomGrid,function () {
    this.$init = function () {
      $mod.TCustomGrid.$init.call(this);
      this.FReq = null;
      this.FDataNode = "";
      this.FData = undefined;
      this.FUnfiltered = undefined;
      this.FTable = null;
      this.FBody = null;
      this.FRowHeader = false;
      this.FColHeader = false;
      this.FDelimiter = "\x00";
      this.FLoadFixed = false;
      this.FFindCol = 0;
      this.FFindRow = 0;
      this.FFindCase = false;
      this.FFindCondition = "";
      this.FElementHeaderClassName = "";
      this.FElementTableClassName = "";
      this.FOnHttpRequestError = null;
      this.FOnHttpRequestSuccess = null;
      this.FOnDblClickCell = null;
      this.FOnClickCell = null;
      this.FOptions = null;
      this.FOnGetCellClass = null;
      this.FOnGetCellData = null;
      this.FOnGetCellChildren = null;
      this.FOnHttpRequest = null;
      this.FOnCheckClick = null;
      this.FOnButtonClick = null;
      this.FHandleCheckClickPtr = null;
      this.FHandleButtonClickPtr = null;
      this.FOnSortClick = null;
      this.FSortIndex = 0;
      this.FSortDirection = 0;
      this.FElementSelectionClassName = "";
      this.FElementRowSelectClassName = "";
      this.FRowIndex = 0;
      this.FSelectionTextColor = 0;
      this.FSelectionColor = 0;
      this.FHeader = null;
      this.FFooter = null;
      this.FPaging = null;
      this.FOnSelectPage = null;
      this.FHiddenCols = null;
      this.FWordWrap = false;
    };
    this.$final = function () {
      this.FReq = undefined;
      this.FTable = undefined;
      this.FBody = undefined;
      this.FOnHttpRequestError = undefined;
      this.FOnHttpRequestSuccess = undefined;
      this.FOnDblClickCell = undefined;
      this.FOnClickCell = undefined;
      this.FOptions = undefined;
      this.FOnGetCellClass = undefined;
      this.FOnGetCellData = undefined;
      this.FOnGetCellChildren = undefined;
      this.FOnHttpRequest = undefined;
      this.FOnCheckClick = undefined;
      this.FOnButtonClick = undefined;
      this.FOnSortClick = undefined;
      this.FHeader = undefined;
      this.FFooter = undefined;
      this.FPaging = undefined;
      this.FOnSelectPage = undefined;
      this.FHiddenCols = undefined;
      $mod.TCustomGrid.$final.call(this);
    };
    this.GetCells = function (col, row) {
      var Result = "";
      var res = "";
      var hdr = 0;
      var trc = 0;
      Result = "";
      hdr = 0;
      if (this.FHeader.FVisible) hdr = 1;
      trc = this.RenderRowCount();
      if (this.FRowHeader) trc += 1;
      if ((col >= 0) && (row >= 0) && (col < this.FColCount) && (hdr < 2)) {
        //      res = this.FData[row][col];
        //      if (res == undefined) {
                var td = this.FTable.rows[row + hdr].cells[col];
                //res = td.innerHTML;
        
                res = td.textContent;
                if (td.childElementCount > 0) {
                  if (td.firstChild.tagName == 'DIV')
                    res = td.firstChild.textContent;
                }
        //      };
        Result = res;
      };
      return Result;
    };
    this.SetCells = function (col, row, Value) {
      var trc = 0;
      var org = 0;
      var td = null;
      if (!(this.FTable != null)) return;
      trc = this.FRowCount;
      org = row;
      if (this.FRowHeader) trc += 1;
      if ((col >= 0) && (row >= 0) && (col < this.FColCount) && (row <= trc)) {
        if (row === 0) this.EnableColResize();
        if (row < this.FData.length) {
          this.FData[row][col] = Value;
        };
        if (this.FRowHeader) row = row - 1;
        if (this.InVisiblePage({get: function () {
            return row;
          }, set: function (v) {
            row = v;
          }}) || ((row === -1) && this.FRowHeader && (org < 1))) {
          if (this.FHeader.FVisible) row += 1;
          if (this.FRowHeader) row = row + 1;
          td = this.FTable.rows[row].cells[col];
          this.SetTableCell(col,row,td,Value);
        };
      };
    };
    this.GetRowClassName = function (row) {
      var Result = "";
      var res = "";
      res = "";
      if ((row >= 0) && (row < this.FRowCount)) {
        var tr = this.FTable.rows[row];
        res = tr.getAttribute('class');
      };
      Result = res;
      return Result;
    };
    this.SetRowClassName = function (row, Value) {
      if ((row >= 0) && (row < this.FRowCount)) {
        var tr = this.FTable.rows[row];
        tr.setAttribute('class',Value);
      };
    };
    this.GetCellElement = function (col, row) {
      var Result = null;
      var res = null;
      var rh = 0;
      var fr = 0;
      res = null;
      rh = 0;
      if (this.FHeader.FVisible) rh = 1;
      fr = 0;
      if (this.FColHeader) fr = 1;
      if ((col >= 0) && (row >= 0) && (col < this.FColCount) && (row <= (this.RenderRowCount() + rh + fr)) && (this.FTable != null)) {
        if ((this.FTable.rows.length > row + rh) && (this.FTable.rows[row + rh].cells.length > col)) {
          res = this.FTable.rows[row + rh].cells[col];
        };
      };
      Result = res;
      return Result;
    };
    this.GetCheckElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      var s = "";
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElement(ACol,ARow).firstChild;
        if ((el != null) && rtl.isExt(el,Element) && (pas.SysUtils.UpperCase(el.tagName) === "DIV")) el = el.firstChild;
        if ((el != null) && rtl.isExt(el,Element)) {
          s = "";
          if (el.hasAttribute("type")) s = el.getAttribute("type");
          if ((s !== "") && (pas.SysUtils.UpperCase(s) === "CHECKBOX")) {
            Result = el;
          };
        };
      };
      return Result;
    };
    this.GetButtonElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElement(ACol,ARow);
        el = el.firstChild;
        if ((el != null) && (el.tagName === "DIV")) el = el.firstChild;
        if ((el != null) && (el.tagName === "BUTTON")) {
          Result = el;
        };
      };
      return Result;
    };
    this.GetProgressElement = function (ACol, ARow) {
      var Result = null;
      var el = null;
      Result = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCellElement(ACol,ARow).firstChild;
        if ((el != null) && rtl.isExt(el,Element)) {
          if (pas.SysUtils.UpperCase(el.tagName) === "PROGRESS") {
            Result = el;
          };
        };
      };
      return Result;
    };
    this.SetOptions = function (Value) {
      this.FOptions.Assign(Value);
    };
    this.SetElementHeaderClassName = function (Value) {
      var head = null;
      if (this.FElementHeaderClassName !== Value) {
        this.FElementHeaderClassName = Value;
        if (this.FTable != null) {
          head = this.FTable.firstChild;
          if ((head != null) && (head.tagName === "THEAD")) head.setAttribute("class",this.FElementHeaderClassName);
        };
      };
    };
    this.SetElementTableClassName = function (Value) {
      if (this.FElementTableClassName !== Value) {
        this.FElementTableClassName = Value;
        if (this.FTable != null) this.FTable.setAttribute("class",this.FElementTableClassName);
      };
    };
    this.SetColHeader = function (Value) {
      if (this.FColHeader !== Value) {
        this.FColHeader = Value;
        if (this.FTable != null) {
          if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.ReRenderGrid();
        };
      };
    };
    this.SetRowHeader = function (Value) {
      if (this.FRowHeader !== Value) {
        this.FRowHeader = Value;
        if (this.FTable != null) {
          if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.ReRenderGrid();
        };
      };
    };
    this.SetSortIndex = function (Value) {
      this.FSortIndex = Value;
    };
    this.SetRowIndex = function (Value) {
      var el = null;
      if (this.FRowIndex !== -1) {
        el = this.GetCellElement(0,this.FRowIndex);
        if (el != null) {
          if (this.FElementRowSelectClassName === "") {
            el.parentElement.style.removeProperty("color");
            el.parentElement.style.removeProperty("background-color");
          } else el.parentElement.className = "";
        };
      };
      this.FRowIndex = Value;
      if (this.FRowIndex !== -1) {
        el = this.GetCellElement(0,this.FRowIndex);
        if (el != null) {
          if (this.FElementRowSelectClassName === "") {
            if (this.FSelectionTextColor !== -1) el.parentElement.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionTextColor));
            if (this.FSelectionColor !== -1) el.parentElement.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectionColor));
          } else el.parentElement.classList.add(this.FElementRowSelectClassName);
        };
      };
    };
    this.SetSelectionColor = function (Value) {
      if (this.FSelectionColor !== Value) {
        this.FSelectionColor = Value;
        this.UpdateElement();
      };
    };
    this.SetSelectionTextColor = function (Value) {
      if (this.FSelectionTextColor !== Value) {
        this.FSelectionTextColor = Value;
        this.UpdateElement();
      };
    };
    this.SetFooter = function (Value) {
      this.FFooter.Assign(Value);
    };
    this.SetHeader = function (Value) {
      this.FHeader.Assign(Value);
    };
    this.SetPaging = function (Value) {
      this.FPaging.Assign(Value);
    };
    this.SetTableCell = function (ACol, ARow, ACell, Value) {
      var $Self = this;
      var clr = "";
      var td = "";
      var cn = "";
      var topcell = null;
      function IsEmail(s) {
        var Result = false;
        var res = false;
        var re = /\S+@\S+\.\S+/;
        res = re.test(s);
        Result = res;
        return Result;
      };
      function IsImgUrl(url) {
        var Result = false;
        var res = false;
        res = /\.(jpg|jpeg|png|webp|avif|gif)$/.test(url);
        Result = res;
        return Result;
      };
      function IsValidHttpUrl(s) {
        var Result = false;
        try {
          url = new URL(s);
        } catch (_) {
          return false;
        }
        return url.protocol === "http:" || url.protocol === "https:";
        return Result;
      };
      function IsNum(str) {
        var Result = false;
        if (typeof str != "string") return false // we only process strings!
        return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
          !isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail;
        return Result;
      };
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FElementTableClassName === "") && !this.FOptions.FCellBorders) {
        ACell.style.borderRight = "1px dashed gray";
        ACell.style.borderBottom = "1px dashed gray";
        ACell.innerHTML = "&nbsp;";
        return;
      };
      if (this.FOptions.FAutoCellEmail && IsEmail(Value)) {
        td = '<a href="mailto:' + Value + '">' + Value + "</a>"}
       else if (this.FOptions.FAutoCellImage && IsImgUrl(Value)) {
        if (this.FOptions.FImageWidth > 0) {
          td = '<img src="' + Value + '" width="' + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this.FOptions, get: function () {
              return this.p.FImageWidth;
            }, set: function (v) {
              this.p.FImageWidth = v;
            }}) + 'px">'}
         else td = '<img src="' + Value + '">';
        var $tmp = this.FOptions.FImageAlign;
        if ($tmp === pas.Classes.TAlignment.taCenter) {
          ACell.setAttribute("align","center")}
         else if ($tmp === pas.Classes.TAlignment.taRightJustify) ACell.setAttribute("align","right");
      } else if (this.FOptions.FAutoCellURL && IsValidHttpUrl(Value)) {
        td = '<a href="' + Value + '">' + Value + "</a>"}
       else {
        td = Value;
        if (this.FOptions.FAutoNumAlign && IsNum(Value)) ACell.setAttribute("align","right");
      };
      if (this.FWordWrap) {
        ACell.innerHTML = td}
       else ACell.innerHTML = '<div style="overflow: hidden; text-overflow: ellipsis; white-space:nowrap;">' + td + "</div>";
      if ((this.FElementTableClassName === "") && this.FOptions.FCellBorders) {
        clr = pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FCellBorderColor);
        ACell.style.borderRight = "1px solid " + clr;
        ACell.style.borderBottom = "1px solid " + clr;
      };
      cn = "";
      this.GetCellClassName(ACol,ARow,null,Value,{get: function () {
          return cn;
        }, set: function (v) {
          cn = v;
        }});
      if (cn !== "") ACell.setAttribute("class",cn);
    };
    this.GetColWidth = function (ACol) {
      var Result = 0;
      var td = null;
      var w = 0;
      Result = 0;
      if ((ACol < this.FColCount) && (ACol >= 0)) {
        td = this.GetCellElement(ACol,0);
        w = td.offsetWidth;
        Result = w;
      };
      return Result;
    };
    this.SetColWidth = function (ACol, AWidth) {
      var td = null;
      var el = null;
      var i = 0;
      if ((ACol < this.FColCount) && (ACol >= 0)) {
        if (AWidth > 0) {
          for (var $l = 0, $end = this.RenderRowCount(); $l <= $end; $l++) {
            i = $l;
            td = null;
            td = this.GetCellElement(ACol,i);
            if (td != null) {
              td.style.setProperty("width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
                  return AWidth;
                }, set: function (v) {
                  AWidth = v;
                }}) + "px");
              td.style.setProperty("max-width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
                  return AWidth;
                }, set: function (v) {
                  AWidth = v;
                }}) + "px");
              el = td.firstChild;
              if ((el != null) && (el.tagName === "DIV")) {
                el.style.setProperty("width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
                    return AWidth;
                  }, set: function (v) {
                    AWidth = v;
                  }}) + "px");
                el.style.setProperty("max-width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
                    return AWidth;
                  }, set: function (v) {
                    AWidth = v;
                  }}) + "px");
              };
            };
          };
        };
      };
    };
    this.SetWordWrap = function (AValue) {
      if (this.FWordWrap !== AValue) {
        this.FWordWrap = AValue;
        if (this.FTable != null) {
          if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.ReRenderGrid();
        };
      };
    };
    this.GetDataRowCount = function () {
      var Result = 0;
      if (this.FRowHeader || (this.FPaging.FEnabled === false)) {
        Result = this.FRowCount - 1}
       else Result = this.FRowCount;
      return Result;
    };
    this.ClearData = function () {
      this.Clear();
    };
    this.SetDataColumnCount = function (AValue) {
      if (this.FRowHeader) {
        this.SetColCount(AValue + 1)}
       else this.SetColCount(AValue);
    };
    this.SetDataRowCount = function (AValue) {
      if (this.FColHeader) {
        this.SetRowCount(AValue + 1)}
       else this.SetRowCount(AValue);
    };
    this.SetDataValue = function (AColumn, ARow, AValue) {
      var dc = 0;
      var dr = 0;
      dc = 0;
      dr = 0;
      if (this.FRowHeader) dc = 1;
      if (this.FColHeader) dr = 1;
      this.SetCells(AColumn + dc,ARow + dr,AValue);
    };
    this.SetDataHeader = function (AColumn, AValue) {
      var d = 0;
      if (!this.FColHeader) return;
      d = 0;
      if (this.FRowHeader) d = 1;
      this.SetCells(AColumn + d,0,AValue);
    };
    this.DataBeginUpdate = function () {
    };
    this.DataEndUpdate = function () {
    };
    this.DataInsertRow = function (AInsertPosition) {
      this.InsertRow(AInsertPosition);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleCheckClickPtr = null;
      this.FHandleButtonClickPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleCheckClickPtr = rtl.createCallback(this,"HandleCheckBoxClick");
      this.FHandleButtonClickPtr = rtl.createCallback(this,"HandleButtonClick");
    };
    this.HandleDoKeyPress = function (Event) {
      var Result = false;
      pas["WEBLib.Controls"].TControl.HandleDoKeyPress.apply(this,arguments);
      Result = true;
      return Result;
    };
    this.ColOffset = function () {
      var Result = 0;
      if (this.FColHeader) {
        Result = 1}
       else Result = 0;
      return Result;
    };
    this.RowOffset = function () {
      var Result = 0;
      if (this.FRowHeader) {
        Result = 1}
       else Result = 0;
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      var c = 0;
      var r = 0;
      var tgt = null;
      var sd = 0;
      var tag = "";
      var s = "";
      tgt = Event.target;
      if (pas.SysUtils.UpperCase(tgt.tagName) === "BUTTON") {
        return Result;
      };
      if (pas.SysUtils.UpperCase(tgt.tagName) === "INPUT") {
        s = tgt.getAttribute("type");
        if (pas.System.Assigned(s) && (pas.SysUtils.UpperCase(s) === "CHECKBOX")) {
          return Result;
        };
      };
      sd = $mod.TGridSortIndicator.siNone;
      if (tgt.tagName === "SPAN") {
        if (tgt.getAttribute("sort") === "up") {
          sd = $mod.TGridSortIndicator.siAscending;
        } else if (tgt.getAttribute("sort") === "dn") {
          sd = $mod.TGridSortIndicator.siDescending;
        };
      };
      do {
        tag = tgt.tagName.toLowerCase();
        if ((tag !== "td") && (tag !== "th")) tgt = tgt.parentElement;
      } while (!((tag === "td") || (tag === "th") || (tgt === null)));
      if ((tag === "td") || (tag === "th")) {
        c = tgt.cellIndex;
        var tr = tgt.parentElement;
        r = tr.rowIndex;
        if (this.FHeader.FVisible) r -= 1;
        if (this.FPaging.FEnabled) {
          r = r + (this.FPaging.FActivePage * this.FPaging.FSize);
        };
        if ((this.FOnClickCell != null) && (sd === $mod.TGridSortIndicator.siNone) && this.FEnabled) this.FOnClickCell(this,c,r);
      };
      if (sd === $mod.TGridSortIndicator.siAscending) {
        this.DoSortClick(c,r,$mod.TGridSortIndicator.siDescending);
        this.SetSortIndicator(c,r,$mod.TGridSortIndicator.siDescending);
      } else if (sd === $mod.TGridSortIndicator.siDescending) {
        this.DoSortClick(c,r,$mod.TGridSortIndicator.siAscending);
        this.SetSortIndicator(c,r,$mod.TGridSortIndicator.siAscending);
      };
      if (this.FOnClick != null) this.FOnClick(this);
      Result = true;
      return Result;
    };
    this.HandleDoDblClick = function (Event) {
      var Result = false;
      var c = 0;
      var r = 0;
      var el = null;
      el = Event.target;
      if (el.tagName === "DIV") el = el.parentElement;
      if ((el.tagName === "TD") || (el.tagName === "TH")) {
        c = el.cellIndex;
        var tr = el.parentElement;
        r = tr.rowIndex;
        if (this.FPaging.FEnabled) {
          r = r + (this.FPaging.FActivePage * this.FPaging.FSize);
        };
        if (this.FOnDblClickCell != null) this.FOnDblClickCell(this,c,r);
      };
      Result = true;
      return Result;
    };
    this.HandleCheckBoxClick = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      var chk = false;
      Result = true;
      rindex = -1;
      cindex = -1;
      var el = Event.target;
      chk = el.checked;
      var d = el.parentElement;
      if (d.tagName.toLowerCase() == 'div')
      {
        d = d.parentElement;
      }
      if (d.tagName.toLowerCase() == 'td')
      {
        cindex = d.cellIndex;
        var tr = d.parentElement;
        rindex = tr.rowIndex;
      }
      if (d.tagName.toLowerCase() == 'th')
      {
        cindex = d.cellIndex;
        var tr = d.parentElement;
        rindex = tr.rowIndex;
      };
      if (this.FPaging.FEnabled) {
        rindex = rindex + (this.FPaging.FActivePage * this.FPaging.FSize);
      };
      if ((rindex !== -1) && (cindex !== -1)) {
        this.DoCheckClick(cindex,rindex,chk);
      };
      return Result;
    };
    this.HandleButtonClick = function (Event) {
      var Result = false;
      var rindex = 0;
      var cindex = 0;
      Result = true;
      rindex = -1;
      cindex = -1;
      var el = Event.target;
          var d = el.parentElement;
          if (d.tagName.toLowerCase() == 'div') {
            d = d.parentElement;
          }
      
          if (d.tagName.toLowerCase() == 'td') {
            cindex = d.cellIndex;
            var tr = d.parentElement;
            rindex = tr.rowIndex;
          };
      if (this.FPaging.FEnabled) {
        rindex = rindex + (this.FPaging.FActivePage * this.FPaging.FSize);
      };
      if ((rindex !== -1) && (cindex !== -1)) {
        this.DoButtonClick(cindex,rindex);
      };
      return Result;
    };
    this.HandleDoMouseUp = function (Event) {
      var Result = false;
      pas["WEBLib.Controls"].TControl.HandleDoMouseUp.apply(this,arguments);
      resetResize();
      Result = true;
      return Result;
    };
    this.HandleDoMouseMove = function (Event) {
      var Result = false;
      var IsAutoWidth = false;
      pas["WEBLib.Controls"].TControl.HandleDoMouseMove.apply(this,arguments);
      IsAutoWidth = this.FWidthStyle in rtl.createSet(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      autoWidth = IsAutoWidth;
      resizeColumn(Event);
      Result = true;
      return Result;
    };
    this.HandleDoMouseDown = function (Event) {
      var Result = false;
      var r = 0;
      var maxr = 0;
      var tgt = null;
      var tr = null;
      var sd = 0;
      var tag = "";
      Result = true;
      if (!this.FEnabled) return Result;
      tgt = Event.target;
      tag = "";
      sd = $mod.TGridSortIndicator.siNone;
      tr = null;
      do {
        tag = tgt.tagName.toLowerCase();
        if ((tag !== "td") && (tag !== "th")) tgt = tgt.parentElement;
      } while (!((tag === "td") || (tag === "th") || (tgt === null)));
      if ((tag === "td") || (tag === "th")) {
        tr = tgt.parentElement;
        r = tr.rowIndex;
        if (this.FHeader.FVisible) r -= 1;
        if (this.FPaging.FEnabled) {
          maxr = this.FPaging.FSize}
         else maxr = this.FRowCount;
        if (r > maxr) return Result;
        if ((tag === "td") || ((tag === "th") && this.FEnabled)) {
          tag = tr.parentElement.tagName.toLowerCase();
          if (tag !== "thead") this.SetRowIndex(r);
        };
      };
      return Result;
    };
    this.DoCheckClick = function (ACol, ARow, Checked) {
      if (this.FOnCheckClick != null) this.FOnCheckClick(this,ACol,ARow,Checked);
    };
    this.DoButtonClick = function (ACol, ARow) {
      if (this.FOnButtonClick != null) this.FOnButtonClick(this,ACol,ARow);
    };
    this.DoSortClick = function (ACol, ARow, ASortIndicator) {
      var i = 0;
      this.FSortIndex = ACol;
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        this.SelectSortIndicator(i,ARow,i === ACol);
      };
      this.FSortDirection = ASortIndicator;
      if (this.FOnSortClick != null) this.FOnSortClick(this,ACol,ARow,ASortIndicator);
      this.Sort(ACol,ASortIndicator);
    };
    this.DoHttpLoadJson = function (Event) {
      var Result = false;
      var J = null;
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        J = JSON.parse(req.responseText);
        this.LoadFromJSON$1(J,this.FDataNode);
        if (this.FOnHttpRequestSuccess != null) this.FOnHttpRequestSuccess(this);
      };
      Result = true;
      return Result;
    };
    this.DoHttpLoadPageJson = function (Event) {
      var Result = false;
      var J = null;
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        J = JSON.parse(req.responseText);
        this.LoadPageFromJSON$1(J,this.FDataNode);
        if (this.FOnHttpRequestSuccess != null) this.FOnHttpRequestSuccess(this);
      };
      Result = true;
      return Result;
    };
    this.DoHttpLoadCsv = function (Event) {
      var Result = false;
      var sl = null;
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        sl = pas.Classes.TStringList.$create("Create$1");
        sl.SetTextStr(req.responseText);
        try {
          this.LoadFromStringList(sl);
        } finally {
          sl = rtl.freeLoc(sl);
        };
        if (this.FOnHttpRequestSuccess != null) this.FOnHttpRequestSuccess(this);
      };
      Result = true;
      return Result;
    };
    this.DoHttpAbort = function (Event) {
      var Result = false;
      if (this.FOnHttpRequestError != null) this.FOnHttpRequestError(this);
      Result = true;
      return Result;
    };
    this.DoHttpRequest = function (ARequest) {
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      if (this.FOnHttpRequest != null) {
        LRequestRec.req = ARequest;
        this.FOnHttpRequest(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec));
      };
    };
    this.GetCellData = function (ACol, ARow, AField, AValue) {
      if (this.FOnGetCellData != null) this.FOnGetCellData(this,ACol,ARow,AField,AValue);
    };
    this.GetCellClassName = function (ACol, ARow, AField, AValue, AClassName) {
      if (this.FOnGetCellClass != null) this.FOnGetCellClass(this,ACol,ARow,AField,AValue,AClassName);
    };
    this.GetCellChildren = function (ACol, ARow, AField, AValue, AElement) {
      var LElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      if (this.FOnGetCellChildren != null) {
        LElementRec.element = AElement;
        this.FOnGetCellChildren(this,ACol,ARow,AField,AValue,pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LElementRec));
      };
    };
    this.BindCellCheckBox = function (ACol, ARow, AElement) {
      var el = null;
      el = AElement.firstChild;
      if ((el != null) && (el.tagName === "DIV")) el = el.firstChild;
      if ((el != null) && (el.tagName === "INPUT")) {
        if (pas.SysUtils.LowerCase(el.getAttribute("TYPE")) === "checkbox") {
          el.addEventListener("click",this.FHandleCheckClickPtr);
        };
      };
    };
    this.BindCellButton = function (ACol, ARow, AElement) {
      var el = null;
      el = AElement.firstChild;
      if ((el != null) && (el.tagName === "DIV")) el = el.firstChild;
      if ((el != null) && (el.tagName === "BUTTON")) {
        el.addEventListener("click",this.FHandleButtonClickPtr);
      };
    };
    this.RenderGrid = function () {
      var i = 0;
      var table = null;
      var tbody = null;
      var th = null;
      var frows = 0;
      var fcols = 0;
      var fhc = 0;
      var rc = 0;
      var rh = false;
      var ch = false;
      var headclass = "";
      var cc = "";
      var headcaption = "";
      var ridx = 0;
      if (!(this.FTable != null)) {
        this.FTable = document.createElement("TABLE");
        this.GetElementHandle().appendChild(this.FTable);
        pas["WEBLib.Controls"].SetHTMLElementFont(this.FTable,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        table = this.FTable;
        table.setAttribute("id",this.FName + "Table");
        table.style.setProperty("vertical-align","middle");
        frows = this.RenderRowCount();
        fcols = this.FColCount;
        rh = this.FRowHeader;
        ch = this.FColHeader;
        rc = this.FRowCount;
        cc = "";
        ridx = 0;
        fhc = 0;
        if (this.FElementTableClassName === "") {
          table.style.setProperty("border-collapse","collapse");
          table.setAttribute("border","0");
          table.setAttribute("cellpadding","0");
          table.setAttribute("cellspacing","0");
          table.setAttribute("width","100%");
          table.setAttribute("table-layout","fixed");
          table.setAttribute("height","100%");
        } else {
          table.setAttribute("class",this.FElementTableClassName);
        };
        headclass = this.FElementHeaderClassName;
        while (table.firstChild) {
          table.removeChild(table.firstChild);
        };
        this.FHeader.FElement = null;
        if (this.FHeader.FVisible) {
          ridx += 1;
          headcaption = this.FHeader.FCaption;
          var theader = table.createTHead();
          
                  if (headclass != "")
                  {
                    theader.setAttribute("class", headclass);
                  }
          
                  var tr = theader.insertRow(0);
                  th = document.createElement('th');
                  tr.appendChild(th);
                  th.setAttribute('colspan',fcols);
                  th.setAttribute('vertical-align','middle');
                  if (headcaption != '') {
                    th.innerHTML = '<div style="float:left;margin-right:10px;vertical-align:middle">'+headcaption+'</div>'; };
          this.FHeader.FElement = th;
        };
        var i = 0;
              var j = 0;
        
              if (rh)
              {
                fhc++;
        
                var theader = table.createTHead();
        
                if (headclass != "")
                {
                  theader.setAttribute("class", headclass);
                }
        
                var tr = theader.insertRow(ridx);
        
                for(i=0; i < fcols; i++)
                {
                  if (rc > 0) {
                  cc = this.FData[0][i];
                  if (cc == undefined) { cc = "";}
                  }
                  else
                  {
                    cc = "";
                  }
                  var th = document.createElement('th');
                  th.setAttribute('scope','col');
                  this.SetTableCell(i,0, th, cc);
                  tr.appendChild(th);
                }
              }
        
              tbody = table.appendChild(document.createElement('tbody'));
        
              for(i=0; i < frows; i++)
              {
                if (i + fhc >= this.FData.length) { break; }
        
                var tr = tbody.insertRow(tbody.length);
        
                for(j=0; j < fcols; j++)
                {
                  cc = this.FData[i+fhc][j];
                  if (cc == undefined) { cc = "";}
        
                  if ((j == 0) && (ch))
                  {
                    var th = document.createElement('th');
                    th.setAttribute('scope','row');
                    tr.appendChild(th);
                    this.SetTableCell(j,i + fhc,th, cc);
                  }
                  else
                  {
                    tr.insertCell();
                    var td = tr.cells[j];
                    this.SetTableCell(j,i + fhc,td, cc);
                  }
                }
              };
        this.FBody = tbody;
        this.FFooter.FElement = null;
        if (this.FFooter.FVisible) {
          ridx += 1;
          headcaption = this.FFooter.FCaption;
          var theader = table.createTFoot();
          
                  if (headclass != "")
                  {
                    theader.setAttribute("class", headclass);
                  }
          
                  var tr = theader.insertRow(0);
                  th = document.createElement('th');
                  tr.appendChild(th);
                  th.setAttribute('colspan',fcols);
          //        th['colspan'] = fcols;
                  th.innerHTML = headcaption;
          this.FFooter.FElement = th;
        };
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) this.EnableDrag();
      };
      if (!this.FOptions.FResizeColumns) ;
      this.EnableColResize();
      if (this.FHiddenCols.GetCount() > 0) {
        for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
          i = $l;
          if (this.IsHiddenColumn(i)) this.HideColumn(i);
        };
      };
    };
    this.ReRenderGrid = function () {
      if (!(this.GetElementHandle() != null) || this.IsUpdating()) return;
      if (this.FTable != null) this.FTable.parentElement.removeChild(this.FTable);
      this.FTable = null;
      this.RenderGrid();
      this.RenderHeaderFooter();
    };
    this.RenderGridBorders = function () {
      var i = 0;
      var j = 0;
      var td = null;
      var clr = "";
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.RenderRowCount(); $l1 <= $end1; $l1++) {
          j = $l1;
          td = this.GetCellElement(i,j);
          if (td != null) {
            if (this.FOptions.FCellBorders) {
              clr = pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FCellBorderColor);
              td.style.borderRight = "1px solid " + clr;
              td.style.borderBottom = "1px solid " + clr;
            } else {
              td.style.borderRight = "";
              td.style.borderBottom = "";
            };
          };
        };
      };
    };
    this.RenderGridData = function () {
      var i = 0;
      var j = 0;
      for (var $l = 0, $end = this.FColCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.FRowCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          this.SetCells(i,j,this.GetCells(i,j));
        };
      };
    };
    this.RenderGridScript = function () {
      this.AddControlScriptSource("var pageX,curCol,nxtCol,curColWidth,nxtColWidth,autoWidth,curTable,curTableWidth;" + "autoWidth = false;" + "function resizeColumn(e) {" + "   if (curCol) {" + "    var diffX = e.pageX - pageX;" + "\t\tif ((nxtCol) && (!autoWidth)){" + '\t\t nxtCol.style.width = (nxtColWidth - diffX)+"px";' + "   } else {" + "   }" + "   newColWidth = (curColWidth + diffX);" + "   if (newColWidth < 10)" + "    newColWidth = 10;" + '\t  curCol.style.width = newColWidth + "px";' + "   }" + " }" + "function resetResize() {" + "   curCol = undefined;" + "   nxtCol = undefined;" + "   pageX = undefined;" + "   nxtColWidth = undefined;" + "   curColWidth = undefined;" + "   curTable = undefined;" + "   curTableWidth = undefined;" + " }" + "function resizableGrid(tablename, enabled,ridx) {" + ' var table = document.getElementById(tablename + "Table");' + " if (!table) return;" + ' var row = table.getElementsByTagName("tr")[ridx],' + " cols = row ? row.children : undefined;" + " if (!cols) return;" + " for (var i=0;i<cols.length;i++){" + '  var coldiv = document.getElementById(tablename + "Div" + i);' + "  if (coldiv)" + "    coldiv.remove();" + "  if (enabled) {" + "    var div = createDiv();" + "    cols[i].appendChild(div);" + '    cols[i].style.position = "relative";' + '    div.id = tablename + "Div" + i;' + "    setListeners(div);" + "  }" + " }" + " function setListeners(div){" + '  div.addEventListener("mousedown", function (e) {' + "   curCol = e.target.parentElement;" + "   nxtCol = curCol.nextElementSibling;" + "   pageX = e.pageX;" + "   curColWidth = curCol.offsetWidth;" + "   curTable = curCol.parentElement.parentElement.parentElement;" + "   curTableWidth = curTable.offsetWidth;" + "   if (nxtCol)" + "    nxtColWidth = nxtCol.offsetWidth;" + "  });" + '  div.addEventListener("mouseover", function (e) {' + '   e.target.style.borderRight = "2px solid #0000ff";' + "  });" + '  div.addEventListener("mouseout", function (e) {' + '   e.target.style.borderRight = "";' + "  });" + '  document.addEventListener("mousemove", function (e) {' + "   resizeColumn(e);" + "  });" + '  document.addEventListener("mouseup", function (e) {' + "   resetResize(e);" + "  });" + " }" + " function createDiv(){" + '  var div = document.createElement("div");' + "  div.style.top = 0;" + "  div.style.right = 0;" + '  div.style.width = "10px";' + '  div.style.position = "absolute";' + '  div.style.cursor = "col-resize";' + '  div.style.userSelect = "none";' + '  div.style.height = "100%";' + '  div.innerHTML = "&nbsp;";' + "  return div;" + " }" + "};");
    };
    this.RenderHeaderFooter = function () {
      if (this.FHeader.FVisible) this.FHeader.Update(this.FPaging.FSize,this.FRowCount,this.FPaging.FActivePage);
      if (this.FFooter.FVisible) this.FFooter.Update(this.FPaging.FSize,this.FRowCount,this.FPaging.FActivePage);
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.RenderGridScript();
    };
    this.KeyDown = function (Key, Shift) {
      var fr = 0;
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      if (!this.FEnabled) return;
      fr = 0;
      if (this.FRowHeader) fr = 1;
      if (Key.get() === 38) this.SetRowIndex(Math.max(fr,this.FRowIndex - 1));
      if (Key.get() === 40) this.SetRowIndex(Math.min(this.FRowCount - 1,this.FRowIndex + 1));
      if (Key.get() === 36) this.SetRowIndex(fr);
      if (Key.get() === 35) this.SetRowIndex(this.FRowCount - 1);
      if (Key.get() === 34) this.SetRowIndex(Math.min(this.FRowCount - 1,this.FRowIndex + 4));
      if (Key.get() === 33) this.SetRowIndex(Math.max(fr,this.FRowIndex - 4));
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FTable = null;
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if (this.GetElementHandle() != null) {
        if (this.FOptions.FScrollVertical) {
          this.GetElementHandle().style.setProperty("overflow-y","scroll")}
         else this.GetElementHandle().style.setProperty("height","");
        if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
          this.GetElementHandle().style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()) + "px");
          this.GetElementHandle().style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()) + "px");
        };
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
        if ((this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) && (this.FBorderColor !== -1) && (this.FElementClassName === "") && (this.FElementTableClassName === "") && !this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("border","1px " + pas["WEBLib.Graphics"].ColorToHTML(this.FBorderColor) + " solid")}
         else this.GetElementHandle().style.setProperty("border","");
        if ((this.FColor !== -1) && (this.FColor !== 16711422)) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.GetElementHandle().style.setProperty("background-color","");
        this.RenderGrid();
      };
    };
    this.SetRowCount = function (Value) {
      var delta = 0;
      var trc = 0;
      var trh = 0;
      var i = 0;
      if ((this.FRowCount !== Value) && (Value >= 0)) {
        trc = Value;
        this.FData.length = trc;
              var i;
        
              for(i = 0; i < this.FData.length; i++) {
                if (this.FData[i] == null) {
                  this.FData[i] = [];
                  this.FData[i].length = this.FColCount;
                }
              };
        delta = Value - this.FRowCount;
        if ((this.FRowCount === 0) && this.FRowHeader) delta = Value - 1;
        this.FRowCount = Value;
        this.RowCountChanged(delta);
        this.GridChanged();
        if (this.FPaging.FEnabled) {
          trc = 0;
          trh = 0;
          if (this.FRowHeader) trc += 1;
          if (this.FHeader.FVisible) trh += 1;
          for (var $l = this.FPaging.FSize + trc + trh, $end = (this.FRowCount - 1) + trh; $l <= $end; $l++) {
            i = $l;
            this.HideRow(i);
          };
        };
        if (this.FHeader.FPager !== $mod.TTablePager.tpNone) this.FHeader.Update(this.FPaging.FSize,this.FRowCount,this.FPaging.FActivePage);
        if (this.FFooter.FPager !== $mod.TTablePager.tpNone) this.FFooter.Update(this.FPaging.FSize,this.FRowCount,this.FPaging.FActivePage);
      };
    };
    this.SetColCount = function (Value) {
      $mod.TCustomGrid.SetColCount.apply(this,arguments);
      var i;
          for(i=0; i < this.FData.length; i++)
          {
            if (this.FData[i] == null) this.FData[i] = [];
      
            this.FData[i].length = Value;
          };
    };
    this.RowCountChanged = function (delta) {
      var r = 0;
      var tbody = null;
      if (!(this.FTable != null)) return;
      tbody = this.FBody;
      if (delta > 0) {
        var i = 0;
              var j = 0;
              var tr = undefined;
              var l = tbody.rows.length;
        
              for(i = 0;i < delta; i++)
              {
                 tr = tbody.insertRow(l);
                 for(j = 0; j < this.FColCount; j++)
                 {
        
                  if ((j == 0) && (this.FColHeader))
                  {
                    var th = document.createElement('th');
                    th.setAttribute('scope','row');
                    tr.appendChild(th);
                  }
                  else
                  {
                    tr.insertCell();
                  }
                 }
              };
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) this.EnableDrag();
      };
      if (delta < 0) {
        var i = 0;
        var l = this.FBody.rows.length;
        if (l < -delta) return;
        for(i = 0;i < -delta; i++) {
          this.FBody.deleteRow(l - i - 1);
        };
      };
    };
    this.ColCountChanged = function (delta) {
      var c = 0;
      var fromrow = 0;
      var torow = 0;
      var dtb = "";
      var cc = "";
      if (this.IsUpdating() || !(this.FTable != null)) return;
      cc = "";
      dtb = "";
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        dtb = "1px dashed gray";
        cc = "&nbsp;";
      };
      fromrow = 0;
      torow = this.RenderRowCount();
      if (this.FRowHeader) torow = torow + 1;
      if (this.FHeader.FVisible) {
        this.FHeader.FElement.setAttribute("colspan",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this, get: function () {
            return this.p.FColCount;
          }, set: function (v) {
            this.p.FColCount = v;
          }}));
        fromrow = 1;
        torow = torow + 1;
      };
      if (this.FFooter.FVisible) {
        this.FFooter.FElement.setAttribute("colspan",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this, get: function () {
            return this.p.FColCount;
          }, set: function (v) {
            this.p.FColCount = v;
          }}));
      };
      if (delta > 0) {
        var i = 0;
              var j = 0;
              var k = 0;
              var tr = undefined;
              var td = undefined;
        
              for(j = fromrow; j < torow; j++)
              {
                tr = this.FTable.rows[j];
        
                if (tr == undefined) { continue; }
        
                k = tr.cells.length;
        
                 for(i = 0; i < delta; i++)
                 {
                   if ((j == fromrow) && (this.FRowHeader))
                   {
                     var th = document.createElement('th');
                     th.setAttribute('scope','col');
                     tr.appendChild(th);
                     this.SetTableCell(i,j,th,cc);
                   }
                   else
                   {
                     if ((tr.cells.length == 0) && (this.FColHeader))
                     {
                       var th = document.createElement('th');
                       th.setAttribute('scope','row');
                       this.SetTableCell(i,j,th, cc);
                       tr.appendChild(th);
                     }
                     else
                     {
                       td = tr.insertCell();
                       td = tr.cells[k];
                       this.SetTableCell(i,j,td, cc);
                     }
                   }
                 }
              };
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) this.EnableDrag();
      };
      if (delta < 0) {
        var i = 0;
              var j = 0;
              var k = 0;
              var tr = undefined;
        
              for(j = fromrow; j < torow; j++)
              {
                tr = this.FTable.rows[j];
        
                if (tr == undefined) { continue; }
        
                k = tr.cells.length;
        
                for(i = 0; i < -delta; i++)
                {
                  if ((k - i - 1 < k) && (k - i - 1 >= 0))  {
                    tr.deleteCell(k - i - 1);
                }
               }
              };
      };
    };
    this.LoadFromStringList = function (AStrings) {
      var firstrow = 0;
      var arow = null;
      var i = 0;
      var j = 0;
      var cr = 0;
      var cd = "";
      var cn = "";
      var ce = null;
      if (this.FRowHeader && !this.FLoadFixed) {
        firstrow = 1}
       else firstrow = 0;
      this.SetRowCount(AStrings.GetCount() + firstrow);
      arow = pas.Classes.TStringList.$create("Create$1");
      try {
        for (var $l = 0, $end = AStrings.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          arow.FStrictDelimiter = true;
          arow.SetDelimiter(this.FDelimiter);
          arow.SetDelimitedText(AStrings.Get(i));
          if (arow.GetCount() > this.FColCount) this.SetColCount(arow.GetCount());
          for (var $l1 = 0, $end1 = arow.GetCount() - 1; $l1 <= $end1; $l1++) {
            j = $l1;
            cd = arow.Get(j);
            this.GetCellData(j,i + firstrow,null,{get: function () {
                return cd;
              }, set: function (v) {
                cd = v;
              }});
            this.SetCells(j,i + firstrow,cd);
            cr = i + firstrow;
            if (this.InVisiblePage({get: function () {
                return cr;
              }, set: function (v) {
                cr = v;
              }})) {
              ce = this.GetCellElement(j,cr);
              this.GetCellChildren(j,cr,null,cd,ce);
              cn = "";
              this.GetCellClassName(j,cr,null,cd,{get: function () {
                  return cn;
                }, set: function (v) {
                  cn = v;
                }});
              if (cn !== "") ce.setAttribute("class",cn);
            };
          };
        };
      } finally {
        arow = rtl.freeLoc(arow);
      };
    };
    this.EnableColResize = function () {
      var TableName = "";
      var ResizeEnabled = false;
      var ridx = 0;
      TableName = this.FName;
      ResizeEnabled = this.FOptions.FResizeColumns;
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
        if (this.FHeader.FVisible) {
          ridx = 1}
         else ridx = 0;
        resizableGrid(TableName, ResizeEnabled, ridx);
      };
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "TD") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "TD") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.FindFrom = function (ACol, ARow, Condition, CaseSensitive, AllCells) {
      var Result = $mod.TGridCoord.$new();
      var i = 0;
      var j = 0;
      var r = 0;
      var pg = 0;
      var sr = 0;
      var sc = 0;
      var cd = "";
      var found = false;
      sc = ACol;
      Result.X = -1;
      Result.Y = -1;
      for (var $l = ARow, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = sc, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          cd = this.FData[i][j];
          found = (cd != undefined);
          if (found && pas["WEBLib.Utils"].MatchStr("*" + Condition + "*",cd,CaseSensitive)) {
            Result.X = j;
            Result.Y = i;
            this.FFindCol = j;
            this.FFindRow = i;
            if (this.FPaging.FEnabled) {
              pg = rtl.trunc((i - ARow) / this.FPaging.FSize);
              this.SelectPage(pg,true);
              this.FFindRow = i % this.FPaging.FSize;
              if (this.FFindRow < ARow) this.FFindRow = this.FPaging.FSize;
              Result.Y = this.FFindRow;
            };
            this.ScrollRowInView(this.FFindRow);
            this.SelectCell(j,this.FFindRow);
            return Result;
          };
        };
        if (this.FColHeader && !AllCells) {
          sc = 1}
         else sc = 0;
      };
      return Result;
    };
    this.RenderRowCount = function () {
      var Result = 0;
      if (this.FPaging.FEnabled && (this.FPaging.FSize > 0)) {
        Result = this.FPaging.FSize}
       else {
        if (this.FRowHeader) {
          Result = this.FRowCount - 1}
         else Result = this.FRowCount;
      };
      return Result;
    };
    this.InVisiblePage = function (ARow) {
      var Result = false;
      if (this.FPaging.FEnabled) {
        Result = (ARow.get() >= (this.FPaging.FSize * this.FPaging.FActivePage)) && (ARow.get() < (this.FPaging.FSize * (this.FPaging.FActivePage + 1)));
        ARow.set(ARow.get() - (this.FPaging.FSize * this.FPaging.FActivePage));
      } else Result = ARow.get() <= this.FRowCount;
      return Result;
    };
    this.DoSelectPage = function (AIndex) {
      var Allow = false;
      var DoDefault = false;
      Allow = true;
      DoDefault = true;
      if (this.FOnSelectPage != null) this.FOnSelectPage(this,AIndex,{get: function () {
          return Allow;
        }, set: function (v) {
          Allow = v;
        }},{get: function () {
          return DoDefault;
        }, set: function (v) {
          DoDefault = v;
        }});
      if (Allow) this.SelectPage(AIndex,DoDefault);
    };
    this.SelectPage = function (AIndex, DoDefault) {
      var i = 0;
      var j = 0;
      var delta = 0;
      var offset = 0;
      var hdr = 0;
      var tr = null;
      var td = null;
      var s = "";
      if (this.FPaging.FEnabled) {
        this.FPaging.FActivePage = AIndex;
        td = null;
        this.RenderHeaderFooter();
        if (DoDefault) {
          if (this.FRowHeader) {
            delta = 1}
           else delta = 0;
          if (this.FHeader.FVisible) {
            hdr = 1}
           else hdr = 0;
          offset = AIndex * this.FPaging.FSize;
          for (var $l = 0, $end = this.FPaging.FSize - 1; $l <= $end; $l++) {
            i = $l;
            tr = this.FTable.rows[i + delta + hdr];
            if (tr != null) {
              if ((offset + i + delta) >= this.FRowCount) {
                tr.style.setProperty('display','none');
                continue;
              };
              s = "";
              for (var $l1 = 0, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
                j = $l1;
                s = this.FData[offset + i + delta][j];
                if (s != undefined) {
                  td = tr.cells[j];
                  this.SetTableCell(j,i+delta,td,s);
                }
                tr.style.removeProperty('display');
              };
            };
          };
        };
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementHeaderClassName("thead-light");
        this.SetElementTableClassName("table table-striped table-bordered  table-hover");
        if (!(this.FHeader != null)) this.FHeader = $mod.TTableControlHeader.$create("Create$1",[this]);
        this.FHeader.FButtonActiveElementClassName = "btn btn-primary";
        this.FHeader.FButtonElementClassName = "btn btn-light";
        this.FHeader.FLinkActiveElementClassName = "link-primary";
        this.FHeader.FLinkElementClassName = "link-secondary";
        this.FHeader.FListElementClassName = "pagination";
        this.FHeader.FListLinkElementClassName = "page-link";
        this.FHeader.FListItemElementClassName = "page-item";
        this.FHeader.FDropDownElementClassName = "form-control";
        this.FHeader.FInputElementClassName = "form-control";
        if (!(this.FFooter != null)) this.FFooter = $mod.TTableControlHeader.$create("Create$1",[this]);
        this.FFooter.FButtonActiveElementClassName = "btn btn-primary";
        this.FFooter.FButtonElementClassName = "btn btn-light";
        this.FFooter.FLinkActiveElementClassName = "link-primary";
        this.FFooter.FLinkElementClassName = "link-secondary";
        this.FFooter.FListElementClassName = "pagination";
        this.FFooter.FListLinkElementClassName = "page-link";
        this.FFooter.FListItemElementClassName = "page-item";
        this.FFooter.FDropDownElementClassName = "form-control";
        this.FFooter.FInputElementClassName = "form-control";
      };
    };
    this.Create$1 = function (AOwner) {
      this.FHeader = null;
      this.FFooter = null;
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.SetTabStop(false);
      return this;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FOptions = $mod.TTableControlOptions.$create("Create$1",[this]);
      this.FData = null;
      this.FUnfiltered = null;
      if (this.FData == null) {
        if (!(this.FHeader != null)) this.FHeader = $mod.TTableControlHeader.$create("Create$1",[this]);
        if (!(this.FFooter != null)) this.FFooter = $mod.TTableControlHeader.$create("Create$1",[this]);
        this.FPaging = $mod.TTableControlPaging.$create("Create$1",[this]);
        this.FHiddenCols = pas.Classes.TStringList.$create("Create$1");
        this.FHiddenCols.FDuplicates = pas.Types.TDuplicates.dupIgnore;
      };
      this.FData = [];
          this.FData.length = 11;
          var i;
          for(i=0;i<11;i++) {
            if (this.FData[i] == null) this.FData[i] = [];
      
            this.FData[i].length = 5;
          };
      this.FColCount = 5;
      this.FRowCount = 10;
      this.FRowHeader = true;
      this.FColHeader = true;
      this.FRowIndex = -1;
      this.FSelectionColor = 0xFF8F5B;
      this.FSelectionTextColor = 0xFFFFFF;
      this.SetEnabled(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FHiddenCols");
      rtl.free(this,"FOptions");
      rtl.free(this,"FHeader");
      rtl.free(this,"FFooter");
      rtl.free(this,"FPaging");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Invalidate = function () {
      pas["WEBLib.Controls"].TCustomControl.Invalidate.call(this);
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.ReRenderGrid();
      if (this.FHeader.FVisible) this.FHeader.Update(this.FPaging.FSize,this.FRowCount,this.FPaging.FActivePage);
      if (this.FFooter.FVisible) this.FFooter.Update(this.FPaging.FSize,this.FRowCount,this.FPaging.FActivePage);
    };
    this.LogData = function () {
      window.console.log(this.FData);
    };
    this.InitSample = function (AInitMethod) {
      var i = 0;
      var j = 0;
      var trc = 0;
      trc = this.RenderRowCount();
      if (this.FRowHeader) trc += 1;
      for (var $l = 0, $end = trc - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          var $tmp = AInitMethod;
          if ($tmp === $mod.TInitMethod.imRandom) {
            this.SetCells(j,i,pas.SysUtils.IntToStr(pas.System.Random(100)))}
           else if ($tmp === $mod.TInitMethod.imLinear) this.SetCells(j,i,pas.SysUtils.IntToStr(j) + ":" + pas.SysUtils.IntToStr(i));
        };
      };
    };
    this.LoadFromJSON = function (AURL, ADataNode) {
      this.FDataNode = ADataNode;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadJson"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.LoadFromJSON$1 = function (AJSON, ADataNode) {
      var JO = undefined;
      var JA = null;
      var r = 0;
      var c = 0;
      var cr = 0;
      var firstrow = 0;
      var arow = "";
      var sl = null;
      var cd = "";
      var cn = "";
      var ce = null;
      var p = false;
      if (ADataNode !== "") {
        JA = AJSON[ADataNode]}
       else JA = AJSON;
      if (JA != null) {
        p = this.FPaging.FEnabled;
        this.FPaging.SetEnabled(false);
        sl = pas.Classes.TStringList.$create("Create$1");
        firstrow = 0;
        if (this.FRowHeader) firstrow = 1;
        this.SetRowCount(JA.length + firstrow);
        for (var $l = 0, $end = JA.length - 1; $l <= $end; $l++) {
          r = $l;
          JO = JA[r];
          c = 0;
          arow = "";
          var x = undefined;
          for (x in JO) {
            arow += "|" + JO[x];
            c++;
          };
          pas.System.Delete({get: function () {
              return arow;
            }, set: function (v) {
              arow = v;
            }},1,1);
          sl.FStrictDelimiter = true;
          sl.SetDelimiter("|");
          sl.SetDelimitedText(arow);
          if (this.FColCount < sl.GetCount()) this.SetColCount(sl.GetCount());
          for (var $l1 = 0, $end1 = sl.GetCount() - 1; $l1 <= $end1; $l1++) {
            c = $l1;
            cd = sl.Get(c);
            this.GetCellData(c,r + firstrow,null,{get: function () {
                return cd;
              }, set: function (v) {
                cd = v;
              }});
            this.SetCells(c,r + firstrow,cd);
            cr = r;
            if (this.InVisiblePage({get: function () {
                return cr;
              }, set: function (v) {
                cr = v;
              }})) {
              cr = cr + firstrow;
              ce = this.GetCellElement(c,cr);
              this.GetCellChildren(c,cr,null,cd,ce);
              cn = "";
              this.GetCellClassName(c,cr,null,cd,{get: function () {
                  return cn;
                }, set: function (v) {
                  cn = v;
                }});
              if (cn !== "") ce.setAttribute("class",cn);
            };
          };
          this.FPaging.SetEnabled(p);
        };
        sl = rtl.freeLoc(sl);
      };
    };
    this.LoadFromJSONAsync = function (AURL, ADataNode) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function DoLoad(Event) {
          var Result = false;
          if ($Self.DoHttpLoadJson(Event)) {
            ASuccess(Event.target)}
           else AFailed(Event.target);
          Result = true;
          return Result;
        };
        function DoError(Event) {
          var Result = false;
          AFailed(Event.target);
          Result = true;
          return Result;
        };
        $Self.FDataNode = ADataNode;
        $Self.FReq = new XMLHttpRequest();
        $Self.FReq.addEventListener("load",rtl.createSafeCallback(null,DoLoad));
        $Self.FReq.addEventListener("abort",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("timeout",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("error",rtl.createSafeCallback(null,DoError));
        $Self.FReq.open("GET",AURL);
        $Self.DoHttpRequest($Self.FReq);
        $Self.FReq.send();
      });
      return Result;
    };
    this.LoadPageFromJSON = function (AURL, ADataNode) {
      this.FDataNode = ADataNode;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadPageJson"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.LoadPageFromJSON$1 = function (AJSON, ADataNode) {
      var JO = undefined;
      var JA = null;
      var r = 0;
      var c = 0;
      var cr = 0;
      var firstrow = 0;
      var arow = "";
      var sl = null;
      var cd = "";
      var cn = "";
      var ce = null;
      var p = false;
      if (ADataNode !== "") {
        JA = AJSON[ADataNode]}
       else JA = AJSON;
      if (JA != null) {
        sl = pas.Classes.TStringList.$create("Create$1");
        firstrow = this.FPaging.FActivePage * this.FPaging.FSize;
        if (this.FRowHeader) firstrow = firstrow + 1;
        for (var $l = 0, $end = JA.length - 1; $l <= $end; $l++) {
          r = $l;
          JO = JA[r];
          c = 0;
          arow = "";
          var x = undefined;
          for (x in JO) {
            arow += "|" + JO[x];
            c++;
          };
          pas.System.Delete({get: function () {
              return arow;
            }, set: function (v) {
              arow = v;
            }},1,1);
          sl.FStrictDelimiter = true;
          sl.SetDelimiter("|");
          sl.SetDelimitedText(arow);
          if (this.FColCount < sl.GetCount()) this.SetColCount(sl.GetCount());
          for (var $l1 = 0, $end1 = sl.GetCount() - 1; $l1 <= $end1; $l1++) {
            c = $l1;
            cd = sl.Get(c);
            this.GetCellData(c,r + firstrow,null,{get: function () {
                return cd;
              }, set: function (v) {
                cd = v;
              }});
            this.SetCells(c,r + firstrow,cd);
            cr = r;
            if (this.InVisiblePage({get: function () {
                return cr;
              }, set: function (v) {
                cr = v;
              }})) {
              cr = cr + firstrow;
              ce = this.GetCellElement(c,cr);
              this.GetCellChildren(c,cr,null,cd,ce);
              cn = "";
              this.GetCellClassName(c,cr,null,cd,{get: function () {
                  return cn;
                }, set: function (v) {
                  cn = v;
                }});
              if (cn !== "") ce.setAttribute("class",cn);
            };
          };
        };
        sl = rtl.freeLoc(sl);
      };
    };
    this.LoadPageFromJSONAsync = function (AURL, ADataNode) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function DoLoad(Event) {
          var Result = false;
          if ($Self.DoHttpLoadPageJson(Event)) {
            ASuccess(Event.target)}
           else AFailed(Event.target);
          Result = true;
          return Result;
        };
        function DoError(Event) {
          var Result = false;
          AFailed(Event.target);
          Result = true;
          return Result;
        };
        $Self.FDataNode = ADataNode;
        $Self.FReq = new XMLHttpRequest();
        $Self.FReq.addEventListener("load",rtl.createSafeCallback(null,DoLoad));
        $Self.FReq.addEventListener("abort",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("timeout",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("error",rtl.createSafeCallback(null,DoError));
        $Self.FReq.open("GET",AURL);
        $Self.DoHttpRequest($Self.FReq);
        $Self.FReq.send();
      });
      return Result;
    };
    this.LoadFromCSV = function (AURL, Delimiter, LoadFixed) {
      this.FDelimiter = Delimiter;
      this.FLoadFixed = LoadFixed;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadCsv"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.LoadFromCSVAsync = function (AURL, Delimiter, LoadFixed) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function DoLoad(Event) {
          var Result = false;
          if ($Self.DoHttpLoadCsv(Event)) {
            ASuccess(Event.target)}
           else AFailed(Event.target);
          Result = true;
          return Result;
        };
        function DoError(Event) {
          var Result = false;
          AFailed(Event.target);
          Result = true;
          return Result;
        };
        $Self.FDelimiter = Delimiter;
        $Self.FLoadFixed = LoadFixed;
        $Self.FReq = new XMLHttpRequest();
        $Self.FReq.addEventListener("load",rtl.createSafeCallback(null,DoLoad));
        $Self.FReq.addEventListener("abort",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("timeout",rtl.createSafeCallback(null,DoError));
        $Self.FReq.addEventListener("error",rtl.createSafeCallback(null,DoError));
        $Self.FReq.open("GET",AURL);
        $Self.DoHttpRequest($Self.FReq);
        $Self.FReq.send();
      });
      return Result;
    };
    this.LoadFromStrings = function (AStrings, Delimiter, LoadFixed) {
      this.FDelimiter = Delimiter;
      this.FLoadFixed = LoadFixed;
      this.LoadFromStringList(AStrings);
    };
    this.SaveToCSV = function (AFileName, Delimiter, SaveFixed) {
      var sl = null;
      sl = pas.Classes.TStringList.$create("Create$1");
      try {
        this.SaveToStrings(sl,Delimiter,SaveFixed);
        sl.SaveToFile(AFileName);
      } finally {
        sl = rtl.freeLoc(sl);
      };
    };
    this.SaveToStrings = function (AStrings, Delimiter, SaveFixed) {
      var r = 0;
      var c = 0;
      var fr = 0;
      var fc = 0;
      var s = "";
      var rowstr = "";
      fr = 0;
      fc = 0;
      if (!SaveFixed && this.FColHeader) fc = 1;
      if (!SaveFixed && this.FRowHeader) fr = 1;
      for (var $l = fr, $end = this.FRowCount - 1; $l <= $end; $l++) {
        r = $l;
        rowstr = "";
        for (var $l1 = fc, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          c = $l1;
          s = this.GetCells(c,r);
          s = pas.SysUtils.StringReplace(s,'"','""',rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
          if ((pas.System.Pos(Delimiter,s) > 0) || (pas.System.Pos("\r",s) > 0)) {
            s = '"' + s + '"';
          };
          if (s === "") s = '""';
          if (rowstr === "") {
            rowstr = s}
           else rowstr = rowstr + Delimiter + s;
        };
        AStrings.Add(rowstr);
      };
    };
    this.AddCheckBox = function (ACol, ARow, Checked) {
      var s = "";
      var ct = "";
      var el = null;
      if ((ARow >= 0) && (ACol >= 0) && !this.HasCheckBox(ACol,ARow)) {
        ct = this.GetCells(ACol,ARow);
        if (ct !== "") ct = "&nbsp;" + ct;
        s = '<INPUT TYPE="CHECKBOX" style="vertical-align:middle"';
        if (Checked) s = s + " CHECKED";
        s = s + ">";
        this.SetCells(ACol,ARow,s + ct);
        el = this.GetCellElement(ACol,ARow);
        this.BindCellCheckBox(ACol,ARow,el);
      };
    };
    this.RemoveCheckBox = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        if (el != null) {
          el.removeEventListener("click",this.FHandleCheckClickPtr);
          el.remove();
        };
      };
    };
    this.AddCheckBoxColumn = function (ACol, Checked) {
      var i = 0;
      var s = 0;
      s = 0;
      if (this.FRowHeader) s = 1;
      for (var $l = s, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        this.AddCheckBox(ACol,i,Checked);
      };
    };
    this.HasCheckBox = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetCheckElement(ACol,ARow);
        Result = el != null;
      };
      return Result;
    };
    this.AddButton = function (ACol, ARow, AText, AStyle) {
      var s = "";
      var ct = "";
      var el = null;
      if ((ARow >= 0) && (ACol >= 0) && !this.HasCheckBox(ACol,ARow)) {
        ct = this.GetCells(ACol,ARow);
        if (ct !== "") ct = "&nbsp;" + ct;
        s = '<BUTTON type="button" style="vertical-align:middle"';
        if (AStyle !== "") s = s + ' class="' + AStyle + '"';
        s = s + ">" + AText + "</BUTTON>";
        this.SetCells(ACol,ARow,s + ct);
        el = this.GetCellElement(ACol,ARow);
        this.BindCellButton(ACol,ARow,el);
      };
    };
    this.AddButtonColumn = function (ACol, AText, AStyle) {
      var i = 0;
      var s = 0;
      s = 0;
      if (this.FRowHeader) s = 1;
      for (var $l = s, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        this.AddButton(ACol,i,AText,AStyle);
      };
    };
    this.RemoveButton = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetButtonElement(ACol,ARow);
        if (el != null) {
          el.removeEventListener("click",this.FHandleCheckClickPtr);
          el.remove();
        };
      };
    };
    this.HasButton = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetButtonElement(ACol,ARow);
        if (el != null) {
          Result = true;
        };
      };
      return Result;
    };
    this.AddSortIndicator = function (ACol, ARow, AIndicator) {
      var s = "";
      var sid = "";
      var sp = 0;
      s = this.GetCells(ACol,ARow);
      sp = pas.System.Pos("<span",s);
      if (sp > 0) s = pas.System.Copy(s,1,sp - 1);
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      var $tmp = AIndicator;
      if ($tmp === $mod.TGridSortIndicator.siNone) {
        this.SetCells(ACol,ARow,s)}
       else if ($tmp === $mod.TGridSortIndicator.siAscending) {
        this.SetCells(ACol,ARow,s + '<span style="cursor:pointer;float:right" id="' + sid + '" sort="up">' + $impl.GlyphAscending + "</span>")}
       else if ($tmp === $mod.TGridSortIndicator.siDescending) this.SetCells(ACol,ARow,s + '<span style="cursor:pointer;float:right" id="' + sid + '" sort="dn">' + $impl.GlyphDescending + "</span>");
    };
    this.SelectSortIndicator = function (ACol, ARow, ASelect) {
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      if (el != null) {
        if (this.FElementSelectionClassName === "") {
          if (ASelect) {
            el.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(0xFF8F5B))}
           else el.style.removeProperty("color");
        } else {
          if (ASelect) {
            el.classList.add(this.FElementSelectionClassName)}
           else el.classList.remove(this.FElementSelectionClassName);
        };
      };
    };
    this.SetSortIndicator = function (ACol, ARow, AIndicator) {
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      if (el != null) {
        if (AIndicator === $mod.TGridSortIndicator.siAscending) {
          el.innerHTML = $impl.GlyphAscending;
          el.setAttribute("sort","up");
        } else {
          el.innerHTML = $impl.GlyphDescending;
          el.setAttribute("sort","dn");
        };
      };
    };
    this.HasSortIndicator = function (ACol, ARow) {
      var Result = false;
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      Result = el != null;
      return Result;
    };
    this.RemoveSortIndicator = function (ACol, ARow) {
      var el = null;
      var sid = "";
      sid = this.FName + "si" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ACol;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "_" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return ARow;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      el = document.getElementById(sid);
      if (el != null) el.parentElement.removeChild(el);
    };
    this.AddProgress = function (ACol, ARow, APosition, AStyle) {
      var prog = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        if (!this.HasProgress(ACol,ARow)) {
          prog = document.createElement("PROGRESS");
          prog.setAttribute("max","100");
          prog.setAttribute("value",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return APosition;
            }, set: function (v) {
              APosition = v;
            }}));
          prog.style.setProperty("width","100%");
          if (AStyle !== "") prog.setAttribute("class",AStyle);
          this.GetCellElement(ACol,ARow).insertBefore(prog,this.GetCellElement(ACol,ARow).firstChild);
        };
      };
    };
    this.SetProgress = function (ACol, ARow, APosition) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetProgressElement(ACol,ARow);
        if (el != null) {
          el.setAttribute("value",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
              return APosition;
            }, set: function (v) {
              APosition = v;
            }}));
        };
      };
    };
    this.RemoveProgress = function (ACol, ARow) {
      var el = null;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetProgressElement(ACol,ARow);
        el.remove();
      };
    };
    this.HasProgress = function (ACol, ARow) {
      var Result = false;
      var el = null;
      Result = false;
      if ((ACol < this.FColCount) && (ARow < this.FRowCount)) {
        el = this.GetProgressElement(ACol,ARow);
        Result = el != null;
      };
      return Result;
    };
    this.Clear = function () {
      var i = 0;
      var j = 0;
      for (var $l = 0, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.FColCount - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          this.SetCells(j,i,"");
        };
      };
    };
    this.InsertRow = function (Index) {
      var i = 0;
      var cnt = 0;
      var ch = false;
      if ((Index < 0) || (Index > this.FRowCount)) return;
      cnt = this.FColCount;
      ch = this.FColHeader;
      var tr = this.FTable.insertRow(Index);
      
          for(i = 0; i < cnt; i++)
          {
            if ((i == 0) && (ch)) {
              var th = document.createElement('th');
              th.setAttribute('scope','row');
              tr.appendChild(th);
              }
            else
            {
              tr.insertCell();
            }
          };
    };
    this.RemoveRow = function (Index) {
      if ((Index < 0) || (Index >= this.FRowCount)) return;
      var tr = this.FTable.deleteRow(Index);
    };
    this.SetFilter = function (Column, Condition, CaseSensitive) {
      var r = 0;
      var rs = 0;
      var hdr = 0;
      var l = 0;
      var tr = null;
      var s = "";
      if (this.FTable != null) {
        if (Condition === "") {
          this.RemoveFilter();
          return;
        };
        hdr = 0;
        rs = 0;
        if (this.FRowHeader) rs = 1;
        if (this.FHeader.FVisible) hdr = 1;
        if (this.FPaging.FEnabled) {
          if (!pas.System.Assigned(this.FUnfiltered)) {
            this.FUnfiltered  = Array.from(this.FData);
          };
          for (var $l = this.FRowCount - 1, $end = rs; $l >= $end; $l--) {
            r = $l;
            s = this.FData[r][Column];
            if (!pas["WEBLib.Utils"].MatchStr(Condition,s,CaseSensitive) && (hdr < 2)) {
              this.FData.splice(r,1);
            };
          };
          l = this.FData.length;
          this.SetRowCount(l);
          this.SelectPage(this.FPaging.FActivePage,true);
        } else {
          for (var $l1 = rs, $end1 = this.FRowCount - 1; $l1 <= $end1; $l1++) {
            r = $l1;
            if (!pas["WEBLib.Utils"].MatchStr(Condition,this.GetCells(Column,r),CaseSensitive) && (hdr < 2)) {
              tr = this.FTable.rows[r + hdr];
              tr.style.setProperty("display","none");
            };
          };
        };
      };
    };
    this.RemoveFilter = function () {
      var r = 0;
      var rs = 0;
      var l = 0;
      var tr = null;
      if (this.FTable != null) {
        if (this.FColHeader) {
          rs = 1}
         else rs = 0;
        if (this.FPaging.FEnabled) {
          if (pas.System.Assigned(this.FUnfiltered)) {
            this.FData = Array.from(this.FUnfiltered);
            this.FUnfiltered = null;
          };
          l = this.FData.length;
          this.SetRowCount(l);
          this.SelectPage(this.FPaging.FActivePage,true);
        } else {
          for (var $l = rs, $end = this.FRowCount - 1; $l <= $end; $l++) {
            r = $l;
            tr = this.FTable.rows[r];
            tr.style.removeProperty("display");
          };
        };
      };
    };
    this.ScrollRowInView = function (ARow) {
      if ((ARow < this.FRowCount) && (this.FTable != null)) {
        this.FTable.rows[ARow].scrollIntoView({
        behavior: 'smooth',
        block: 'center'
        });
      };
    };
    this.SelectCell = function (ACol, ARow) {
      var el = null;
      if ((ARow < this.FRowCount) && (ACol < this.FColCount)) {
        el = this.GetCellElement(ACol,ARow);
        if (el != null) pas["WEBLib.Utils"].SelectElementContents(el);
      };
    };
    this.FindCell = function (Condition, CaseSensitive, AllCells) {
      var Result = $mod.TGridCoord.$new();
      var i = 0;
      var j = 0;
      if (this.FColHeader && !AllCells) {
        i = 1}
       else i = 0;
      if (this.FRowHeader) {
        j = 1}
       else j = 0;
      this.FFindCase = CaseSensitive;
      this.FFindCondition = Condition;
      Result.$assign(this.FindFrom(i,j,Condition,CaseSensitive,AllCells));
      return Result;
    };
    this.FindNext = function () {
      var Result = $mod.TGridCoord.$new();
      if ((this.FFindCol + 1) === this.FRowCount) {
        if (this.FColHeader) {
          this.FFindCol = 1}
         else this.FFindCol = 0;
        this.FFindRow = this.FFindRow + 1;
      } else this.FFindCol = this.FFindCol + 1;
      Result.$assign(this.FindFrom(this.FFindCol,this.FFindRow,this.FFindCondition,this.FFindCase,false));
      return Result;
    };
    this.HideColumn = function (Index) {
      var i = 0;
      var fr = 0;
      var tr = null;
      var td = null;
      if ((Index < 0) || (Index > this.FColCount)) return;
      if (this.FFooter.FVisible) {
        fr = 1}
       else fr = 0;
      for(i=0; i < this.FTable.rows.length - fr; i++)
      {
        tr = this.FTable.rows[i];
        td = tr.cells[Index];
        td.style.setProperty('display','none');
      };
      this.FHiddenCols.Add(pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return Index;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
    };
    this.UnHideColumn = function (Index) {
      var i = 0;
      var idx = 0;
      var tr = null;
      var td = null;
      if ((Index < 0) || (Index > this.FColCount)) return;
      idx = this.FHiddenCols.IndexOf(pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return Index;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      if (idx === -1) return;
      this.FHiddenCols.Delete(idx);
      for(i=0; i<this.FTable.rows.length;i++)
      {
        tr = this.FTable.rows[i];
        td = tr.cells[Index];
        td.style.removeProperty('display');
      };
    };
    this.IsHiddenColumn = function (Index) {
      var Result = false;
      Result = this.FHiddenCols.IndexOf(pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
          return Index;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) !== -1;
      return Result;
    };
    this.HideRow = function (Index) {
      if ((Index < 0) || (Index > this.FRowCount)) return;
      if (!(this.FTable != null)) return;
      var tr = this.FTable.rows[Index];
      tr.style.setProperty('display','none');
    };
    this.UnHideRow = function (Index) {
      if ((Index < 0) || (Index > this.FRowCount)) return;
      var tr = this.FTable.rows[Index];
      tr.style.removeProperty('display');
    };
    this.Sort = function (AColumn, ADirection) {
      var colidx = 0;
      var grid = null;
      var asc = false;
      var rh = false;
      var fixrow = undefined;
      if (!(this.FTable != null)) return;
      grid = this.FTable.children.item(1);
      asc = ADirection === $mod.TGridSortIndicator.siAscending;
      colidx = AColumn;
      if (this.FPaging.FEnabled) {
        rh = this.FRowHeader;
        if (rh) fixrow = this.FData[0];
        
              const getCellValue = (tr, idx) => tr[idx];
              const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
                v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
                )(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
        
              var arr = Array.from(this.FData);
              if (rh) arr.shift();
              arr.sort(comparer(colidx, asc));
              if (rh) arr.splice(0,0,fixrow);
              this.FData = arr;
        this.SelectPage(this.FPaging.FActivePage,true);
      } else {
        const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
              const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
                v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
                )(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
        
              const table = grid;
        
              Array.from(table.querySelectorAll('tr'))
                  .sort(comparer(colidx, asc))
                  .forEach(tr => table.appendChild(tr) );
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ElementHeaderClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementHeaderClassName","SetElementHeaderClassName");
    $r.addProperty("ElementRowSelectClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementRowSelectClassName","FElementRowSelectClassName");
    $r.addProperty("ElementSelectionClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementSelectionClassName","FElementSelectionClassName");
    $r.addProperty("ElementTableClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTableClassName","SetElementTableClassName");
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: false});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Footer",2,$mod.$rtti["TTableControlHeader"],"FFooter","SetFooter");
    $r.addProperty("Header",2,$mod.$rtti["TTableControlHeader"],"FHeader","SetHeader");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("RowHeader",2,rtl.boolean,"FRowHeader","SetRowHeader",4,{Default: true});
    $r.addProperty("ColHeader",2,rtl.boolean,"FColHeader","SetColHeader",4,{Default: true});
    $r.addProperty("Options",2,$mod.$rtti["TTableControlOptions"],"FOptions","SetOptions");
    $r.addProperty("Paging",2,$mod.$rtti["TTableControlPaging"],"FPaging","SetPaging");
    $r.addProperty("ParentBiDiMode",0,rtl.boolean,"FParentBiDiMode","FParentBiDiMode",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("SelectionColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectionColor","SetSelectionColor",4,{Default: 16748379});
    $r.addProperty("SelectionTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectionTextColor","SetSelectionTextColor",4,{Default: 16777215});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WordWrap",2,rtl.boolean,"FWordWrap","SetWordWrap",4,{Default: false});
    $r.addProperty("OnButtonClick",0,$mod.$rtti["TCellEvent"],"FOnButtonClick","FOnButtonClick");
    $r.addProperty("OnCheckClick",0,$mod.$rtti["TCellCheckEvent"],"FOnCheckClick","FOnCheckClick");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnClickCell",0,$mod.$rtti["TCellEvent"],"FOnClickCell","FOnClickCell");
    $r.addProperty("OnDblClickCell",0,$mod.$rtti["TCellEvent"],"FOnDblClickCell","FOnDblClickCell");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnGetCellData",0,$mod.$rtti["TGridGetCellDataEvent"],"FOnGetCellData","FOnGetCellData");
    $r.addProperty("OnGetCellChildren",0,$mod.$rtti["TGridGetCellChildrenEvent"],"FOnGetCellChildren","FOnGetCellChildren");
    $r.addProperty("OnGetCellClass",0,$mod.$rtti["TGridGetCellClassEvent"],"FOnGetCellClass","FOnGetCellClass");
    $r.addProperty("OnSortClick",0,$mod.$rtti["TGridSortClickEvent"],"FOnSortClick","FOnSortClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnSelectPage",0,$mod.$rtti["TPageSelectEvent"],"FOnSelectPage","FOnSelectPage");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TTableControl",this.TCustomTableControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("RowCount",2,rtl.longint,"FRowCount","SetRowCount");
    $r.addProperty("ColCount",2,rtl.longint,"FColCount","SetColCount");
    $r.addProperty("OnHttpRequestError",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHttpRequestError","FOnHttpRequestError");
    $r.addProperty("OnHttpRequestSuccess",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHttpRequestSuccess","FOnHttpRequestSuccess");
  });
  rtl.createClass(this,"TWebTableControl",this.TTableControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TResponsiveGridItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FHTML = "";
      this.FElementHandle = null;
      this.FTag = 0;
      this.FItemObject = null;
      this.FVisible = false;
      this.FJSONObject = undefined;
      this.FSelected = false;
      this.FRecNo = 0;
    };
    this.$final = function () {
      this.FElementHandle = undefined;
      this.FItemObject = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetHTML = function (Value) {
      this.FHTML = Value;
      this.Changed(false);
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        if (this.FElementHandle != null) {
          if (this.FVisible) {
            this.FElementHandle.style.removeProperty("display")}
           else this.FElementHandle.style.setProperty("display","none");
        };
      };
    };
    this.GetJSONElementValue = function (id) {
      var Result = "";
      var res = "";
      var JO = undefined;
      JO = this.FJSONObject;
      res = JO[id];
      Result = res;
      return Result;
    };
    this.SetSelected = function (Value) {
      var LStyleName = "";
      this.FSelected = Value;
      LStyleName = rtl.as(this.FCollection,$mod.TResponsiveGridItems).FGrid.GetStyleName();
      if (this.FSelected) {
        this.FElementHandle.classList.add(LStyleName + "_Selected")}
       else this.FElementHandle.classList.remove(LStyleName + "_Selected");
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FVisible = true;
      return this;
    };
    this.Destroy = function () {
      rtl.as(this.FCollection,$mod.TResponsiveGridItems).DoItemDelete(this.GetIndex());
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("HTML",2,rtl.string,"FHTML","SetHTML");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag",4,{Default: 0});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
  });
  this.$rtti.$MethodVar("TResponsiveGridItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Index",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TResponsiveGridItemAllowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Index",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TResponsiveGridItemTemplateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Index",rtl.longint],["ItemData",rtl.string],["ATemplate",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TResponsiveGridItemFieldValueEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Index",rtl.longint],["AFieldName",rtl.string],["AValue",rtl.string,1]]), methodkind: 0});
  this.$rtti.$Class("TResponsiveGrid");
  rtl.createClass(this,"TResponsiveGridItems",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnItemDelete = null;
      this.FOnItemUpdate = null;
      this.FOnItemInsert = null;
      this.FOnItemAdd = null;
      this.FOnItemClear = null;
      this.FGrid = null;
    };
    this.$final = function () {
      this.FOnItemDelete = undefined;
      this.FOnItemUpdate = undefined;
      this.FOnItemInsert = undefined;
      this.FOnItemAdd = undefined;
      this.FOnItemClear = undefined;
      this.FGrid = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.DoItemClear = function () {
      if (this.FOnItemClear != null) this.FOnItemClear(this);
    };
    this.DoItemAdd = function (Index) {
      if (this.FOnItemAdd != null) this.FOnItemAdd(this,Index);
    };
    this.DoItemDelete = function (Index) {
      if (this.FOnItemDelete != null) this.FOnItemDelete(this,Index);
    };
    this.DoItemInsert = function (Index) {
      if (this.FOnItemInsert != null) this.FOnItemInsert(this,Index);
    };
    this.DoItemUpdate = function (Index) {
      if (this.FOnItemUpdate != null) this.FOnItemUpdate(this,Index);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (Item != null) this.DoItemUpdate(Item.GetIndex());
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TResponsiveGridItem);
      this.FGrid = AOwner;
      return this;
    };
    this.Clear$1 = function () {
      pas.Classes.TCollection.Clear.call(this);
      this.DoItemClear();
    };
    this.Delete$1 = function (Index) {
      pas.Classes.TCollection.Delete.call(this,Index);
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      this.DoItemAdd(Result.GetIndex());
      return Result;
    };
    this.Add$2 = function (HTML) {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      Result.FHTML = HTML;
      this.DoItemAdd(Result.GetIndex());
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      this.DoItemInsert(Result.GetIndex());
      return Result;
    };
  });
  this.TResponsiveGridTemplateOrder = {"0": "toColumn", toColumn: 0, "1": "toRow", toRow: 1};
  this.$rtti.$Enum("TResponsiveGridTemplateOrder",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TResponsiveGridTemplateOrder});
  rtl.createClass(this,"TResponsiveGridOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FItemWidthMin = 0;
      this.FItemHeight = 0;
      this.FItemGap = 0;
      this.FScrollVertical = false;
      this.FItemClassName = "";
      this.FItemColor = 0;
      this.FItemBorderColor = 0;
      this.FItemHoverColor = 0;
      this.FItemHoverBorderColor = 0;
      this.FOnChange = null;
      this.FItemPadding = 0;
      this.FItemTemplate = "";
      this.FItemSelectedBorderColor = 0;
      this.FItemSelectedTextColor = 0;
      this.FItemSelectedColor = 0;
      this.FMultiSelect = false;
      this.FOrder = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetItemBorderColor = function (Value) {
      if (this.FItemBorderColor !== Value) {
        this.FItemBorderColor = Value;
        this.Changed();
      };
    };
    this.SetItemColor = function (Value) {
      if (this.FItemColor !== Value) {
        this.FItemColor = Value;
        this.Changed();
      };
    };
    this.SetItemGap = function (Value) {
      if (this.FItemGap !== Value) {
        this.FItemGap = Value;
        this.Changed();
      };
    };
    this.SetItemHeight = function (Value) {
      if (this.FItemHeight !== Value) {
        this.FItemHeight = Value;
        this.Changed();
      };
    };
    this.SetItemHoverBorderColor = function (Value) {
      if (this.FItemHoverBorderColor !== Value) {
        this.FItemHoverBorderColor = Value;
        this.Changed();
      };
    };
    this.SetItemHoverColor = function (Value) {
      if (this.FItemHoverColor !== Value) {
        this.FItemHoverColor = Value;
        this.Changed();
      };
    };
    this.SetItemWidthMin = function (Value) {
      if (this.FItemWidthMin !== Value) {
        this.FItemWidthMin = Value;
        this.Changed();
      };
    };
    this.SetScrollVertical = function (Value) {
      if (this.FScrollVertical !== Value) {
        this.FScrollVertical = Value;
        this.Changed();
      };
    };
    this.SetItemPadding = function (Value) {
      if (this.FItemPadding !== Value) {
        this.FItemPadding = Value;
        this.Changed();
      };
    };
    this.SetItemTemplate = function (Value) {
      if (this.FItemTemplate !== Value) {
        this.FItemTemplate = Value;
        this.Changed();
      };
    };
    this.SetItemSelectedBorderColor = function (Value) {
      if (this.FItemSelectedBorderColor !== Value) {
        this.FItemSelectedBorderColor = Value;
        this.Changed();
      };
    };
    this.SetItemSelectedColor = function (Value) {
      if (this.FItemSelectedColor !== Value) {
        this.FItemSelectedColor = Value;
        this.Changed();
      };
    };
    this.SetItemSelectedTextColor = function (Value) {
      if (this.FItemSelectedTextColor !== Value) {
        this.FItemSelectedTextColor = Value;
        this.Changed();
      };
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FItemWidthMin = 100;
      this.FItemHeight = 100;
      this.FItemGap = 10;
      this.FScrollVertical = true;
      this.FItemColor = -1;
      this.FItemBorderColor = -1;
      this.FItemHoverColor = -1;
      this.FItemHoverBorderColor = -1;
      this.FItemSelectedColor = -1;
      this.FItemSelectedBorderColor = -1;
      this.FItemSelectedTextColor = -1;
      this.FOrder = $mod.TResponsiveGridTemplateOrder.toColumn;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TResponsiveGridOptions.isPrototypeOf(Source)) {
        this.FItemWidthMin = rtl.as(Source,$mod.TResponsiveGridOptions).FItemWidthMin;
        this.FItemHeight = rtl.as(Source,$mod.TResponsiveGridOptions).FItemHeight;
        this.FMultiSelect = rtl.as(Source,$mod.TResponsiveGridOptions).FMultiSelect;
        this.FOrder = rtl.as(Source,$mod.TResponsiveGridOptions).FOrder;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("ItemClassName",0,rtl.string,"FItemClassName","FItemClassName");
    $r.addProperty("ItemColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemColor","SetItemColor",4,{Default: -1});
    $r.addProperty("ItemBorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemBorderColor","SetItemBorderColor",4,{Default: -1});
    $r.addProperty("ItemGap",2,rtl.longint,"FItemGap","SetItemGap",4,{Default: 10});
    $r.addProperty("ItemHeight",2,rtl.longint,"FItemHeight","SetItemHeight",4,{Default: 100});
    $r.addProperty("ItemHoverColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemHoverColor","SetItemHoverColor",4,{Default: -1});
    $r.addProperty("ItemHoverBorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemHoverBorderColor","SetItemHoverBorderColor",4,{Default: -1});
    $r.addProperty("ItemSelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemSelectedColor","SetItemSelectedColor",4,{Default: -1});
    $r.addProperty("ItemSelectedBorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemSelectedBorderColor","SetItemSelectedBorderColor",4,{Default: -1});
    $r.addProperty("ItemSelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FItemSelectedTextColor","SetItemSelectedTextColor",4,{Default: -1});
    $r.addProperty("ItemPadding",2,rtl.longint,"FItemPadding","SetItemPadding",4,{Default: 0});
    $r.addProperty("ItemTemplate",2,rtl.string,"FItemTemplate","SetItemTemplate");
    $r.addProperty("ItemWidthMin",2,rtl.longint,"FItemWidthMin","SetItemWidthMin",4,{Default: 100});
    $r.addProperty("MultiSelect",0,rtl.boolean,"FMultiSelect","FMultiSelect",4,{Default: false});
    $r.addProperty("Order",0,$mod.$rtti["TResponsiveGridTemplateOrder"],"FOrder","FOrder",4,{Default: $mod.TResponsiveGridTemplateOrder.toColumn});
    $r.addProperty("ScrollVertical",2,rtl.boolean,"FScrollVertical","SetScrollVertical",4,{Default: true});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TResponsiveGrid",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FReq = null;
      this.FDataNode = "";
      this.FOptions = null;
      this.FItems = null;
      this.FOnItemDblClick = null;
      this.FOnItemClick = null;
      this.FOnBeforeItemClick = null;
      this.FOnHttpRequestError = null;
      this.FOnHttpRequestSuccess = null;
      this.FOnItemCreated = null;
      this.FOnItemGetFieldValue = null;
      this.FItemIndex = 0;
      this.FDelimiter = "\x00";
      this.FOnHttpRequest = null;
      this.FListElement = null;
      this.FOnItemGetTemplate = null;
    };
    this.$final = function () {
      this.FReq = undefined;
      this.FOptions = undefined;
      this.FItems = undefined;
      this.FOnItemDblClick = undefined;
      this.FOnItemClick = undefined;
      this.FOnBeforeItemClick = undefined;
      this.FOnHttpRequestError = undefined;
      this.FOnHttpRequestSuccess = undefined;
      this.FOnItemCreated = undefined;
      this.FOnItemGetFieldValue = undefined;
      this.FOnHttpRequest = undefined;
      this.FListElement = undefined;
      this.FOnItemGetTemplate = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetOptions = function (Value) {
      this.FOptions.Assign(Value);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.SetItemIndex = function (Value) {
      var el = null;
      var i = 0;
      var LStyleName = "";
      this.FItemIndex = Value;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      LStyleName = this.GetStyleName();
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        el = this.ListElementHandle().children.item(i);
        if (i === this.FItemIndex) {
          el.setAttribute("class",this.FOptions.FItemClassName + " " + LStyleName + "_Selected");
        } else el.setAttribute("class",this.FOptions.FItemClassName);
      };
    };
    this.DoHttpLoadJson = function (Event) {
      var Result = false;
      var J = null;
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        this.FItems.Clear$1();
        J = JSON.parse(req.responseText);
        this.LoadFromJSON$1(J,this.FDataNode);
        if (this.FOnHttpRequestSuccess != null) this.FOnHttpRequestSuccess(this);
      };
      Result = true;
      return Result;
    };
    this.DoHttpLoadCsv = function (Event) {
      var Result = false;
      var sl = null;
      var arow = null;
      var columns = null;
      var i = 0;
      var c = 0;
      var itm = null;
      var ident = "";
      var html = "";
      var htmlvalue = "";
      var req = null;
      req = Event.target;
      if ((req.status >= 200) && (req.status <= 208)) {
        sl = pas.Classes.TStringList.$create("Create$1");
        sl.SetTextStr(req.responseText);
        arow = pas.Classes.TStringList.$create("Create$1");
        arow.FStrictDelimiter = true;
        arow.SetDelimiter(this.FDelimiter);
        if (sl.GetCount() > 0) {
          columns = pas.Classes.TStringList.$create("Create$1");
          columns.FStrictDelimiter = true;
          columns.SetDelimiter(this.FDelimiter);
          columns.SetDelimitedText(sl.Get(0));
          for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            arow.SetDelimitedText(sl.Get(i));
            if (this.FOptions.FItemTemplate === "") {
              this.FItems.Add$1().SetHTML(arow.GetCommaText());
            } else {
              itm = this.FItems.Add$2("&nbsp;");
              html = this.FOptions.FItemTemplate;
              this.DoItemGetTemplate(i,arow.GetCommaText(),{get: function () {
                  return html;
                }, set: function (v) {
                  html = v;
                }});
              ident = "(%ITEMINDEX%)";
              if (pas.System.Pos(ident,html) > 0) {
                html = pas.SysUtils.StringReplace(html,ident,pas.SysUtils.IntToStr(itm.GetIndex()),rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
              };
              for (var $l1 = 0, $end1 = arow.GetCount() - 1; $l1 <= $end1; $l1++) {
                c = $l1;
                ident = "(%" + columns.Get(c) + "%)";
                if (pas.System.Pos(ident,html) > 0) {
                  htmlvalue = "";
                  if (c < arow.GetCount()) htmlvalue = arow.Get(c);
                  this.DoItemGetFieldValue(itm.GetIndex(),columns.Get(c),{get: function () {
                      return htmlvalue;
                    }, set: function (v) {
                      htmlvalue = v;
                    }});
                  html = pas.SysUtils.StringReplace(html,ident,htmlvalue,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
                };
              };
              itm.SetHTML(html);
              this.DoItemCreated(itm.GetIndex());
            };
          };
          columns = rtl.freeLoc(columns);
        };
        arow = rtl.freeLoc(arow);
        sl = rtl.freeLoc(sl);
      };
      Result = true;
      return Result;
    };
    this.DoHttpAbort = function (Event) {
      var Result = false;
      if (this.FOnHttpRequestError != null) this.FOnHttpRequestError(this);
      Result = true;
      return Result;
    };
    this.DoHttpRequest = function (ARequest) {
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      if (this.FOnHttpRequest != null) {
        LRequestRec.req = ARequest;
        this.FOnHttpRequest(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec));
      };
    };
    this.DoItemCreated = function (Index) {
      if (this.FOnItemCreated != null) this.FOnItemCreated(this,Index);
    };
    this.DoItemGetFieldValue = function (Index, AFieldName, AValue) {
      if (this.FOnItemGetFieldValue != null) this.FOnItemGetFieldValue(this,Index,AFieldName,AValue);
    };
    this.DoItemGetTemplate = function (Index, ItemData, ATemplate) {
      if (this.FOnItemGetTemplate != null) this.FOnItemGetTemplate(this,Index,ItemData,ATemplate);
    };
    this.HandleDoItemClick = function (Index) {
      if (this.FOnItemClick != null) this.FOnItemClick(this,Index);
    };
    this.HandleDoBeforeItemClick = function (Index, Allow) {
      if (this.FOnBeforeItemClick != null) this.FOnBeforeItemClick(this,Index,Allow);
    };
    this.HandleDoItemDblClick = function (Index) {
      if (this.FOnItemDblClick != null) this.FOnItemDblClick(this,Index);
    };
    this.TargetIsParent = function (tgt, el) {
      var Result = false;
      var pe = null;
      Result = false;
      pe = tgt;
      do {
        if (el === pe) {
          Result = true;
          break;
        };
        pe = pe.parentElement;
      } while (pe != null);
      return Result;
    };
    this.HandleDoMouseEnter = function (Event) {
      var Result = false;
      Result = pas["WEBLib.Controls"].TControl.HandleDoMouseEnter.call(this,Event);
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      var i = 0;
      var el = null;
      var LStyleName = "";
      var Allow = false;
      Result = pas["WEBLib.Controls"].TControl.HandleDoClick.call(this,Event);
      LStyleName = this.GetStyleName();
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        el = this.ListElementHandle().children.item(i);
        if (el != null) {
          if (this.TargetIsParent(Event.target,el)) {
            Allow = true;
            this.HandleDoBeforeItemClick(i,{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (!Allow) continue;
            if (this.FOptions.FMultiSelect) {
              if (this.FItems.GetItem$1(i).FSelected) {
                el.classList.remove(LStyleName + "_Selected");
              } else {
                el.classList.add(LStyleName + "_Selected");
              };
              this.FItems.GetItem$1(i).FSelected = !this.FItems.GetItem$1(i).FSelected;
            } else {
              this.FItemIndex = i;
              el.classList.add(LStyleName + "_Selected");
            };
            this.HandleDoItemClick(i);
          } else if (!this.FOptions.FMultiSelect) el.classList.remove(LStyleName + "_Selected");
        };
      };
      return Result;
    };
    this.HandleDoDblClick = function (Event) {
      var Result = false;
      var i = 0;
      var el = null;
      Result = pas["WEBLib.Controls"].TControl.HandleDoClick.call(this,Event);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        el = this.ListElementHandle().children.item(i);
        if (this.TargetIsParent(Event.target,el)) {
          this.HandleDoItemDblClick(i);
        };
      };
      return Result;
    };
    this.HandleItemAdd = function (Sender, Index) {
      var el = null;
      if (this.FItems.GetItem$1(Index).FHTML === "") this.FItems.GetItem$1(Index).FHTML = this.FOptions.FItemTemplate;
      el = document.createElement("DIV");
      this.FItems.GetItem$1(Index).FElementHandle = el;
      this.ListElementHandle().appendChild(el);
      if (pas.System.Pos("(%",this.FItems.GetItem$1(Index).FHTML) === 0) el.innerHTML = this.FItems.GetItem$1(Index).FHTML;
      if (this.FOptions.FItemClassName !== "") el.setAttribute("class",this.FOptions.FItemClassName);
    };
    this.HandleItemUpdate = function (Sender, Index) {
      var el = null;
      if (this.ListElementHandle() != null) {
        el = this.ListElementHandle().children.item(Index);
        if (!(el != null)) {
          this.HandleItemInsert(this,Index);
        } else el.innerHTML = this.FItems.GetItem$1(Index).FHTML;
      };
    };
    this.HandleItemDelete = function (Sender, Index) {
      if (this.ListElementHandle() != null) {
        this.ListElementHandle().removeChild(this.ListElementHandle().children.item(Index));
      };
    };
    this.HandleItemInsert = function (Sender, Index) {
      var el = null;
      this.FItems.GetItem$1(Index).FHTML = this.FOptions.FItemTemplate;
      el = document.createElement("DIV");
      this.FItems.GetItem$1(Index).FElementHandle = el;
      if (this.FItems.GetCount() <= 1) {
        this.ListElementHandle().appendChild(el)}
       else this.ListElementHandle().insertBefore(el,this.ListElementHandle().children.item(Index));
      el.innerHTML = this.FItems.GetItem$1(Index).FHTML;
      if (this.FOptions.FItemClassName !== "") el.setAttribute("class",this.FOptions.FItemClassName);
    };
    this.HandleItemClear = function (Sender) {
      var i = 0;
      for (var $l = this.ListElementHandle().childElementCount - 1; $l >= 0; $l--) {
        i = $l;
        this.ListElementHandle().removeChild(this.ListElementHandle().children.item(0));
      };
    };
    this.OptionsChanged = function (Sender) {
      this.UpdateElement();
    };
    this.FontChanged = function () {
      pas["WEBLib.Controls"].TControl.FontChanged.call(this);
      this.UpdateElement();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.CreateControl = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateControl.call(this);
    };
    this.BindElement = function () {
      pas["WEBLib.Controls"].TCustomControl.BindElement.call(this);
    };
    var cssimportant = " !important; ";
    this.UpdateElement = function () {
      var s = "";
      var fs = "";
      var ITMWIDTHMIN = "";
      var ITMGAP = "";
      var ITMHEIGHT = "";
      var itemstyle = "";
      var itemstylehover = "";
      var itemstyleselected = "";
      var LStyleName = "";
      var LTemplate = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if (this.GetElementHandle() != null) {
        ITMWIDTHMIN = pas.SysUtils.IntToStr(this.FOptions.FItemWidthMin);
        ITMHEIGHT = pas.SysUtils.IntToStr(this.FOptions.FItemHeight);
        ITMGAP = pas.SysUtils.IntToStr(this.FOptions.FItemGap);
        LStyleName = this.GetStyleName();
        this.ListElementHandle().setAttribute("class",LStyleName);
        fs = "";
        if ((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)) fs = pas["WEBLib.Graphics"].CSSFont(this.FFont);
        itemstyle = "";
        itemstylehover = "";
        itemstyleselected = "";
        if (this.FOptions.FItemColor !== -1) {
          itemstyle = "background-color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemColor) + ";";
        };
        if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FOptions.FItemBorderColor === -1)) {
          itemstyle = itemstyle + "border: 1px dotted silver;"}
         else if (this.FOptions.FItemBorderColor !== -1) itemstyle = itemstyle + "border: 1px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemBorderColor) + ";";
        if (this.FOptions.FItemPadding !== 0) itemstyle = itemstyle + "padding:" + pas.SysUtils.IntToStr(this.FOptions.FItemPadding) + "px;";
        if (this.FOptions.FItemHoverColor !== -1) itemstylehover = "background-color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemHoverColor) + cssimportant;
        if (this.FOptions.FItemHoverBorderColor !== -1) itemstylehover = itemstylehover + "border: 1px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemHoverBorderColor) + cssimportant;
        if (this.FOptions.FItemSelectedColor !== -1) itemstyleselected = "background-color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemSelectedColor) + cssimportant;
        if (this.FOptions.FItemSelectedBorderColor !== -1) itemstyleselected = itemstyleselected + "border: 1px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemSelectedBorderColor) + ";";
        if (this.FOptions.FItemSelectedTextColor !== -1) itemstyleselected = itemstyleselected + "color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FOptions.FItemSelectedTextColor) + ";";
        if (this.FOptions.FScrollVertical) {
          this.GetElementHandle().style.removeProperty("overflow-y")}
         else this.GetElementHandle().style.setProperty("overflow-y","hidden");
        if (this.FOptions.FOrder === $mod.TResponsiveGridTemplateOrder.toColumn) {
          LTemplate = "grid-template-columns"}
         else {
          LTemplate = "grid-auto-flow: column; height: " + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this.GetHeight(), get: function () {
              return this.p;
            }, set: function (v) {
              this.p = v;
            }}) + "px; grid-template-rows";
          ITMWIDTHMIN = pas.SysUtils.IntToStr(this.FOptions.FItemHeight);
          this.GetElementHandle().style.setProperty("overflow-x","auto");
        };
        s = "." + LStyleName + " {" + "display: grid; " + LTemplate + ": repeat(auto-fill, minmax(" + ITMWIDTHMIN + "px, 1fr));" + " grid-gap: " + ITMGAP + "px;" + "}" + "\r" + "." + LStyleName + " > div { " + itemstyle + "height: " + ITMHEIGHT + "px; " + fs + " }" + "\r" + "." + LStyleName + " > div:hover {" + itemstylehover + " " + fs + " }" + "\r" + "." + LStyleName + "_Selected {" + itemstyleselected + "height: " + ITMHEIGHT + "px;" + fs + "}" + "\r";
        this.$class.AddInstanceStyle$1(LStyleName + "_style",s);
      };
      this.RenderGrid();
    };
    this.RenderGrid = function () {
      var i = 0;
      var el = null;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if (!(this.GetElementHandle() != null)) return;
      if (!(this.ListElementHandle() != null)) return;
      while (this.ListElementHandle().childElementCount > 0) {
        this.ListElementHandle().removeChild(this.ListElementHandle().firstChild);
      };
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        el = document.createElement("DIV");
        el.style.setProperty("position","relative");
        this.FItems.GetItem$1(i).FElementHandle = el;
        this.ListElementHandle().appendChild(el);
        el.innerHTML = this.FItems.GetItem$1(i).FHTML;
        if (this.FOptions.FItemClassName !== "") el.setAttribute("class",this.FOptions.FItemClassName);
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.RenderGrid();
    };
    this.GetStyleName = function () {
      var Result = "";
      if (this.FParent != null) {
        Result = this.FParent.FName + "_" + this.FName}
       else Result = this.FName;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      return this;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FListElement = null;
      this.FItemIndex = -1;
      this.FOptions = $mod.TResponsiveGridOptions.$create("Create$1");
      this.FOptions.FOnChange = rtl.createCallback(this,"OptionsChanged");
      this.FItems = $mod.TResponsiveGridItems.$create("Create$3",[this]);
      this.FItems.FPropName = "Items";
      if (this.FDesignTime$1) {
        this.FItems.Clear$1();
        this.FItems.Add$1();
        this.FItems.Add$1();
        this.FItems.Add$1();
      };
      this.FItems.FOnItemAdd = rtl.createCallback(this,"HandleItemAdd");
      this.FItems.FOnItemUpdate = rtl.createCallback(this,"HandleItemUpdate");
      this.FItems.FOnItemDelete = rtl.createCallback(this,"HandleItemDelete");
      this.FItems.FOnItemInsert = rtl.createCallback(this,"HandleItemInsert");
      this.FItems.FOnItemClear = rtl.createCallback(this,"HandleItemClear");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FOptions");
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.LoadFromJSON = function (AURL, ADataNode) {
      this.FDataNode = ADataNode;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadJson"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.LoadFromJSON$1 = function (ASJON, ADataNode) {
      var JO = undefined;
      var JA = null;
      var r = 0;
      var c = 0;
      var arow = "";
      var ident = "";
      var html = "";
      var htmlvalue = "";
      var sl = null;
      var itm = null;
      if (ADataNode !== "") {
        JA = ASJON[ADataNode]}
       else JA = ASJON;
      if (JA != null) {
        sl = pas.Classes.TStringList.$create("Create$1");
        for (var $l = 0, $end = JA.length - 1; $l <= $end; $l++) {
          r = $l;
          JO = JA[r];
          c = 0;
          arow = "";
          var x = undefined;
          for (x in JO) {
            arow += "|" + x + "=" + JO[x];
            c++;
          };
          pas.System.Delete({get: function () {
              return arow;
            }, set: function (v) {
              arow = v;
            }},1,1);
          sl.FStrictDelimiter = true;
          sl.SetDelimiter("|");
          sl.SetDelimitedText(arow);
          itm = this.FItems.Add$1();
          itm.FJSONObject = JO;
          if (this.FOptions.FItemTemplate === "") {
            itm.SetHTML(sl.GetCommaText());
          } else {
            html = this.FOptions.FItemTemplate;
            this.DoItemGetTemplate(r,sl.GetCommaText(),{get: function () {
                return html;
              }, set: function (v) {
                html = v;
              }});
            ident = "(%ITEMINDEX%)";
            if (pas.System.Pos(ident,html) > 0) {
              html = pas.SysUtils.StringReplace(html,ident,pas.SysUtils.IntToStr(itm.GetIndex()),rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
            };
            for (var $l1 = 0, $end1 = sl.GetCount() - 1; $l1 <= $end1; $l1++) {
              c = $l1;
              ident = "(%" + sl.GetName(c) + "%)";
              if (pas.System.Pos(ident,html) > 0) {
                htmlvalue = sl.GetValue(sl.GetName(c));
                this.DoItemGetFieldValue(itm.GetIndex(),sl.GetName(c),{get: function () {
                    return htmlvalue;
                  }, set: function (v) {
                    htmlvalue = v;
                  }});
                html = pas.SysUtils.StringReplace(html,ident,htmlvalue,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
              };
            };
            itm.SetHTML(html);
            this.DoItemCreated(itm.GetIndex());
          };
        };
        sl = rtl.freeLoc(sl);
      };
    };
    this.LoadFromCSV = function (AURL, Delimiter) {
      this.FDelimiter = Delimiter;
      this.FReq = new XMLHttpRequest();
      this.FReq.addEventListener("load",rtl.createSafeCallback(this,"DoHttpLoadCsv"));
      this.FReq.addEventListener("abort",rtl.createSafeCallback(this,"DoHttpAbort"));
      this.FReq.open("GET",AURL);
      this.DoHttpRequest(this.FReq);
      this.FReq.send();
    };
    this.ListElementHandle = function () {
      var Result = null;
      if (!(this.FListElement != null)) {
        this.FListElement = document.createElement("DIV");
        this.FListElement.setAttribute("width","100%");
        this.GetElementHandle().appendChild(this.FListElement);
        Result = this.FListElement;
      } else Result = this.FListElement;
      return Result;
    };
    this.ItemByTag = function (ATag) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FItems.GetItem$1(i).FTag === ATag) {
          Result = this.FItems.GetItem$1(i);
          break;
        };
      };
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("ItemIndex",2,rtl.longint,"FItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Items",2,$mod.$rtti["TResponsiveGridItems"],"FItems","SetItems");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Options",2,$mod.$rtti["TResponsiveGridOptions"],"FOptions","SetOptions");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnBeforeItemClick",0,$mod.$rtti["TResponsiveGridItemAllowEvent"],"FOnBeforeItemClick","FOnBeforeItemClick");
    $r.addProperty("OnItemCreated",0,$mod.$rtti["TResponsiveGridItemEvent"],"FOnItemCreated","FOnItemCreated");
    $r.addProperty("OnItemGetFieldValue",0,$mod.$rtti["TResponsiveGridItemFieldValueEvent"],"FOnItemGetFieldValue","FOnItemGetFieldValue");
    $r.addProperty("OnItemGetTemplate",0,$mod.$rtti["TResponsiveGridItemTemplateEvent"],"FOnItemGetTemplate","FOnItemGetTemplate");
    $r.addProperty("OnItemClick",0,$mod.$rtti["TResponsiveGridItemEvent"],"FOnItemClick","FOnItemClick");
    $r.addProperty("OnItemDblClick",0,$mod.$rtti["TResponsiveGridItemEvent"],"FOnItemDblClick","FOnItemDblClick");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnHttpRequestError",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHttpRequestError","FOnHttpRequestError");
    $r.addProperty("OnHttpRequestSuccess",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHttpRequestSuccess","FOnHttpRequestSuccess");
    $r.addProperty("OnHttpRequest",0,$mod.$rtti["TGridRequestEvent"],"FOnHttpRequest","FOnHttpRequest");
  });
  rtl.createClass(this,"TWebResponsiveGrid",this.TResponsiveGrid,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.GridRect = function (Left, Top, Right, Bottom) {
    var Result = $mod.TGridRect.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Right = Right;
    Result.Bottom = Bottom;
    return Result;
  };
  $mod.$implcode = function () {
    $impl.GlyphAscending = "&#x25B2;";
    $impl.GlyphDescending = "&#x25BC;";
    $impl.CELLPADDING = 0;
  };
},["SysUtils","Math","WEBLib.Utils","WEBLib.WebTools","WEBLib.Forms"]);
rtl.module("WEBLib.TMSFNCUtils",["System","Classes","SysUtils","Types","WEBLib.TMSFNCTypes","WEBLib.Graphics","WEBLib.Controls","WEBLib.Forms","JS","WEBLib.Dialogs","WEBLib.JSON","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.PthDel = "/";
  this.FPC_FULLVERSION = 0;
  this.$rtti.$DynArray("TTMSFNCUtilsCharSet",{eltype: rtl.char});
  rtl.recNewT(this,"TTMSFNCUtilsFile",function () {
    this.Data = null;
    this.Name = "";
    this.$eq = function (b) {
      return (this.Data === b.Data) && (this.Name === b.Name);
    };
    this.$assign = function (s) {
      this.Data = s.Data;
      this.Name = s.Name;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCUtilsFile",{},this);
    $r.addField("Data",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("Name",rtl.string);
  });
  this.$rtti.$MethodVar("TTMSFNCUtilsLoadFileCompleteEvent",{procsig: rtl.newTIProcSig([["AFile",this.$rtti["TTMSFNCUtilsFile"],2]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCUtilsFileCallBackEvent",{procsig: rtl.newTIProcSig([["AFile",rtl.string,2],["AResult",rtl.boolean,2]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCUtils",pas.System.TObject,function () {
    this.GetTimeZoneInfo = function (ADateTime, ABias, ABiasDay, AIsDaylight) {
      var bias = 0;
      var biasday = 0;
      var isDaylight = false;
      Date.prototype.stdTimezoneOffset = function () {
              var jan = new Date(this.getFullYear(), 0, 1);
              var jul = new Date(this.getFullYear(), 6, 1);
              return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
          }
      
          Date.prototype.isDstObserved = function () {
              return this.getTimezoneOffset() < this.stdTimezoneOffset();
          }
          var dt = new Date();
          bias = dt.getTimezoneOffset();
          biasday = dt.stdTimezoneOffset();
          isDaylight = dt.isDstObserved();
      ABias.set(bias);
      ABiasDay.set(biasday);
      AIsDaylight.set(isDaylight);
    };
    this.OpenURL = function (AURL) {
      window.open(AURL, '_blank');
    };
    this.OpenFile = function (AFile, AControlReference) {
    };
    this.GetFonts = function (FontList) {
      FontList.BeginUpdate();
      FontList.Add("Arial");
      FontList.Add("Tahoma");
      FontList.Add("SimSun");
      FontList.Add("Arial Unicode MS");
      FontList.Add("Helvetica");
      FontList.Add("Times New Roman");
      FontList.Add("Times");
      FontList.Add("Courier New");
      FontList.Add("Courier");
      FontList.Add("Verdana");
      FontList.Add("Georgia");
      FontList.Add("Palatino");
      FontList.Add("Garamond");
      FontList.Add("Bookman");
      FontList.Add("Comic Sans MS");
      FontList.Add("Trebuchet MS");
      FontList.Add("Arial Black");
      FontList.Add("Impact");
      FontList.Add("Roboto");
      FontList.Sort();
      FontList.EndUpdate();
    };
    this.SetFontSize = function (AFont, ASize, AScaleFactor) {
      AFont.SetSize(Math.round((ASize / 96) * 72));
    };
    this.ScaleForCurrentDPI = function (AForm) {
      if (AForm != null) ;
    };
    this.ScaleForDPI = function (AControl, ADPI) {
    };
    this.GetHInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.IsHTMLUnicode = function (AValue) {
      var Result = false;
      Result = this.IsHTML(AValue);
      return Result;
    };
    this.IsHTML = function (AValue) {
      var Result = false;
      Result = (pas.System.Pos("</",AValue) > 0) || (pas.System.Pos("/>",AValue) > 0) || (pas.System.Pos("<BR>",pas.SysUtils.UpperCase(AValue)) > 0);
      return Result;
    };
    this.GetDocumentsPath = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetAppPath = function () {
      var Result = "";
      Result = "file://";
      return Result;
    };
    this.GetTempPath = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetMousePos = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var p = pas.Types.TPoint.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(-1,-1));
      p.$assign(pas["WEBLib.Controls"].GetMousePos());
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(p.x,p.y));
      return Result;
    };
    this.IsHighDPIScale = function (AOwner, ADefaultDPI) {
      var Result = false;
      Result = this.GetDPIScale(AOwner,ADefaultDPI) > 1;
      return Result;
    };
    this.GetDPIScale = function (AOwner, ADefaultDPI) {
      var Result = 0.0;
      Result = 1.0;
      return Result;
    };
    this.AddBackslash = function (AValue) {
      var Result = "";
      if ((AValue.length >= 1) && (AValue.charAt(AValue.length - 1) !== $mod.PthDel)) {
        Result = AValue + $mod.PthDel}
       else Result = AValue;
      return Result;
    };
    this.AddForwardslash = function (AValue) {
      var Result = "";
      if ((AValue.length >= 1) && (AValue.charAt(AValue.length - 1) !== "/")) {
        Result = AValue + "/"}
       else Result = AValue;
      return Result;
    };
    this.GetResourceStream = function (AResourceName) {
      var Result = null;
      Result = this.GetResourceStream$1(AResourceName,this.GetHInstance());
      return Result;
    };
    this.GetResourceStream$1 = function (AResourceName, AInstance) {
      rtl.rc(AInstance,0,9007199254740991);
      var Result = null;
      Result = null;
      return Result;
    };
    this.Clone = function (AComponent) {
      var Result = null;
      Result = null;
      throw pas.SysUtils.Exception.$create("Create$1",["Implement Clone"]);
      return Result;
    };
    this.HTMLStrip = function (AHTML) {
      var Result = "";
      var TagPos = 0;
      Result = "";
      while (pas.System.Pos("<BR>",pas.SysUtils.UpperCase(AHTML)) > 0) AHTML = pas.SysUtils.StringReplace(AHTML,"<BR>",String.fromCharCode(13) + String.fromCharCode(10),rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      while (pas.System.Pos("<HR>",pas.SysUtils.UpperCase(AHTML)) > 0) AHTML = pas.SysUtils.StringReplace(AHTML,"<HR>",String.fromCharCode(13) + String.fromCharCode(10),rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      TagPos = 0;
      while (this.VarPos("<",AHTML,{get: function () {
          return TagPos;
        }, set: function (v) {
          rtl.rc(v,-2147483648,2147483647);
          TagPos = v;
        }}) > 0) {
        Result = Result + pas.System.Copy(AHTML,1,TagPos - 1);
        if (this.VarPos(">",AHTML,{get: function () {
            return TagPos;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            TagPos = v;
          }}) > 0) {
          pas.System.Delete({get: function () {
              return AHTML;
            }, set: function (v) {
              AHTML = v;
            }},1,TagPos)}
         else break;
      };
      Result = Result + AHTML;
      return Result;
    };
    this.VarPos = function (ASubValue, AValue, AResult) {
      rtl.rc(AResult.get(),-2147483648,2147483647);
      var Result = 0;
      AResult.set(pas.System.Pos(ASubValue,AValue));
      Result = rtl.rc(AResult.get(),-2147483648,2147483647);
      return Result;
    };
    this.VarPosNoCase = function (ASubValue, AValue, AResult) {
      rtl.rc(AResult.get(),-2147483648,2147483647);
      var Result = 0;
      AResult.set(pas.System.Pos(pas.SysUtils.UpperCase(ASubValue),pas.SysUtils.UpperCase(AValue)));
      Result = rtl.rc(AResult.get(),-2147483648,2147483647);
      return Result;
    };
    this.CharInStr = function (s, Index) {
      var Result = "\x00";
      Result = "\x00";
      if ((Index > 0) && (Index <= s.length)) {
        Result = s.charAt(Index - 1);
      };
      return Result;
    };
    this.HexStrToBytes = function (AValue) {
      var Result = [];
      var il = 0;
      var idx = 0;
      var b = [];
      Result = [];
      b = rtl.arraySetLength(b,0,rtl.trunc(AValue.length / 2));
      il = 1;
      idx = 0;
      while (il <= AValue.length) {
        b[idx] = pas.SysUtils.StrToInt("$" + AValue.charAt(il - 1) + AValue.charAt((il + 1) - 1));
        il = il + 2;
        idx = idx + 1;
      };
      Result = rtl.arrayRef(b);
      return Result;
    };
    this.URLDecode = function (AURL, ATrim) {
      var Result = "";
      if (AURL === "") {
        Result = "";
        return Result;
      };
      Result = decodeURIComponent(AURL);
      return Result;
    };
    this.URLEncode = function (AURL) {
      var Result = "";
      Result = encodeURIComponent(AURL);
      return Result;
    };
    this.EnDeCrypt = function (AValue) {
      var Result = "";
      var r = "";
      var i = 0;
      var c = "\x00";
      var b = 0;
      r = "";
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        i = $l;
        b = AValue.charCodeAt(i - 1);
        b = (b & 0xE0) + ((b & 0x1F) ^ 5);
        c = String.fromCharCode(b);
        r = r + c;
      };
      Result = r;
      return Result;
    };
    this.SaveStreamToHexStr = function (AStream) {
      var Result = "";
      var s = "";
      var K = 0;
      var bt = [];
      s = "";
      AStream.SetPosition(0);
      for (var $l = 1, $end = AStream.GetSize(); $l <= $end; $l++) {
        K = $l;
        bt = rtl.arraySetLength(bt,0,1);
        AStream.Read({get: function () {
            return bt;
          }, set: function (v) {
            bt = v;
          }},1);
        s = s + pas.SysUtils.IntToHex(bt[0],2);
      };
      Result = s;
      return Result;
    };
    this.SaveStreamToBase64 = function (AStream, AURL) {
      var Result = "";
      var s = "";
      var a = [];
      s = "";
      Result = "";
      if (AStream.GetSize() < 1) return Result;
      AStream.SetPosition(0);
      a = rtl.arraySetLength(a,0,AStream.GetSize());
      AStream.Read({get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }},AStream.GetSize());
      Result = $mod.TTMSFNCUtils.Encode64$1(a,AURL);
      return Result;
    };
    this.SaveBitmapToHexStr = function (ABitmap) {
      var Result = "";
      var ms = null;
      var s = "";
      var img = null;
      var ss = null;
      ms = pas.Classes.TMemoryStream.$create("Create");
      try {
        s = "";
        if (!ABitmap.Empty()) {
          img = ABitmap.Image();
          var canvas = document.createElement("canvas");
          canvas.width = img.width;
          canvas.height = img.height;
          var ctx = canvas.getContext("2d");
          ctx.drawImage(img, 0, 0);
          var dataURL = canvas.toDataURL("image/png");
          s = dataURL;
          ss = pas.Classes.TStringStream.$create("Create$2",[s]);
          try {
            s = this.SaveStreamToHexStr(ss);
          } finally {
            ss = rtl.freeLoc(ss);
          };
        };
        Result = s;
      } finally {
        ms = rtl.freeLoc(ms);
      };
      return Result;
    };
    this.SaveBitmapToBase64 = function (ABitmap, AURL) {
      var Result = "";
      var ms = null;
      var s = "";
      var img = null;
      var ss = null;
      ms = pas.Classes.TMemoryStream.$create("Create");
      try {
        s = "";
        if (!ABitmap.Empty()) {
          img = ABitmap.Image();
          var canvas = document.createElement("canvas");
          canvas.width = img.width;
          canvas.height = img.height;
          var ctx = canvas.getContext("2d");
          ctx.drawImage(img, 0, 0);
          var dataURL = canvas.toDataURL("image/png");
          s = dataURL;
        };
        Result = s;
      } finally {
        ms = rtl.freeLoc(ms);
      };
      return Result;
    };
    this.CreateBitmapFromHexStr = function (AHexStr) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.LoadBitmapFromHexStr(AHexStr,Result);
      return Result;
    };
    this.CreateBitmapFromBase64 = function (ABase64, AURL) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.LoadBitmapFromBase64(ABase64,Result,AURL);
      return Result;
    };
    this.MulDivInt = function (nNumber, nNumerator, nDenominator) {
      var $Self = this;
      var Result = 0;
      function MathRound(AValue) {
        var Result = 0;
        if (AValue >= 0) {
          Result = pas.System.Trunc(AValue + 0.5)}
         else Result = pas.System.Trunc(AValue - 0.5);
        return Result;
      };
      if (nDenominator === 0) {
        Result = -1}
       else Result = MathRound((nNumber * nNumerator) / nDenominator);
      return Result;
    };
    this.MulDivSingle = function (nNumber, nNumerator, nDenominator) {
      var Result = 0.0;
      if (nDenominator === 0) {
        Result = -1}
       else Result = (nNumber * nNumerator) / nDenominator;
      return Result;
    };
    var Measure = ["Bytes","KB","MB","GB","TB"];
    this.FormatBytesAsString = function (ASize) {
      var Result = "";
      var NewSize = 0.0;
      var i = 0;
      Result = "";
      if (ASize > -1) {
        i = 0;
        NewSize = ASize;
        while (NewSize >= 1024) {
          NewSize = NewSize / 1024;
          i += 1;
        };
        var $tmp = i;
        if ($tmp === 0) {
          Result = pas.SysUtils.FloatToStr(NewSize)}
         else if (($tmp === 1) || ($tmp === 2) || ($tmp === 3) || ($tmp === 4)) {
          Result = pas.SysUtils.FormatFloat("0.00",NewSize)}
         else {
          Result = pas.SysUtils.FloatToStr(NewSize);
        };
        Result = Result + " " + Measure[i];
      };
      return Result;
    };
    this.GetImageType = function (AData, AResetPosition) {
      var Result = "";
      Result = "";
      throw pas.SysUtils.Exception.$create("Create$1",["Implement GetImageType"]);
      return Result;
    };
    this.LoadStreamFromHexStr = function (AHexStr, AStream) {
      var sst = null;
      var bst = null;
      var M = 0;
      var bt = [];
      sst = pas.Classes.TStringStream.$create("Create$2",[AHexStr]);
      bst = pas.Classes.TBytesStream.$create("Create");
      try {
        for (var $l = 1, $end = rtl.trunc(sst.GetSize() / 2); $l <= $end; $l++) {
          M = $l;
          bt = this.HexStrToBytes(sst.ReadString(2));
          bst.Write(bt,rtl.length(bt));
        };
        bst.SetPosition(0);
        AStream.CopyFrom(bst,bst.GetSize());
      } finally {
        sst = rtl.freeLoc(sst);
        bst = rtl.freeLoc(bst);
      };
    };
    this.LoadStreamFromBase64 = function (ABase64, AStream, AURL) {
      var b = [];
      b = $mod.TTMSFNCUtils.Decode64ToBytes(ABase64,AURL);
      AStream.Write(b,rtl.length(b));
    };
    this.LoadBitmapFromHexStr = function (AHexStr, ABitmap) {
      var sst = null;
      var sb = null;
      var bst = null;
      var M = 0;
      var bt = [];
      var hx = "";
      sst = pas.Classes.TStringStream.$create("Create$2",[AHexStr]);
      bst = pas.Classes.TBytesStream.$create("Create");
      try {
        for (var $l = 1, $end = rtl.trunc(sst.GetSize() / 2); $l <= $end; $l++) {
          M = $l;
          bt = this.HexStrToBytes(sst.ReadString(2));
          bst.Write(bt,rtl.length(bt));
        };
        bst.SetPosition(0);
        hx = "";
        sb = pas.Classes.TStringStream.$create("Create$2",[""]);
        try {
          sb.CopyFrom(bst,bst.GetSize());
          hx = sb.GetDataString();
        } finally {
          sb = rtl.freeLoc(sb);
        };
        if (!(pas.System.Pos(";base64,",hx) > 0)) {
          ABitmap.LoadFromStream(bst);
        } else {
          ABitmap.LoadFromResource(hx);
        };
      } finally {
        sst = rtl.freeLoc(sst);
        bst = rtl.freeLoc(bst);
      };
    };
    this.LoadBitmapFromBase64 = function (ABase64, ABitmap, AURL) {
      var s = "";
      s = ABase64;
      if (!(pas.System.Pos(";base64,",s) > 0)) s = "data:image/png;base64," + s;
      ABitmap.LoadFromResource(s);
    };
    this.ConvertBitmapToJPEGStream = function (ABitmap, AQuality, ABackgroundColor) {
      var Result = null;
      Result = null;
      throw pas.SysUtils.Exception.$create("Create$1",["ConvertBitmapToJPEGStream"]);
      return Result;
    };
    this.Split = function (ADelimiter, AInput, AStrings, AClearEmptyStrings) {
      rtl.rcc(ADelimiter,0,65535);
      var C = 0;
      AStrings.Clear();
      AStrings.SetDelimiter(ADelimiter);
      AStrings.FStrictDelimiter = true;
      AStrings.SetDelimitedText(AInput);
      if (AClearEmptyStrings) {
        for (var $l = AStrings.GetCount() - 1; $l >= 0; $l--) {
          C = $l;
          if (AStrings.Get(C) === "") AStrings.Delete(C);
        };
      };
    };
    this.Split$1 = function (ADelimiter, AInput, AClearEmptyStrings) {
      rtl.rcc(ADelimiter,0,65535);
      var Result = [];
      var SL = null;
      var I = 0;
      SL = pas.Classes.TStringList.$create("Create$1");
      try {
        $mod.TTMSFNCUtils.Split(ADelimiter,AInput,SL,AClearEmptyStrings);
        Result = rtl.arraySetLength(Result,"",SL.GetCount());
        for (var $l = 0, $end = SL.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          rtl.rcArrW(Result,I,SL.Get(I));
        };
      } finally {
        SL = rtl.freeLoc(SL);
      };
      return Result;
    };
    this.Log = function (AMessage) {
      var m = "";
      m = AMessage;
      console.log(m);
    };
    this.EpochToDateTime = function (AEpoch) {
      var Result = 0.0;
      var dw = 0;
      dw = pas.SysUtils.StrToInt(AEpoch);
      Result = pas.DateUtils.UnixToDateTime(dw,true);
      return Result;
    };
    this.SplitURL = function (AURL, AHost, APath, AQuery, APort) {
      rtl.rc(APort.get(),-2147483648,2147483647);
      var p = 0;
      var off = 0;
      var portVal = 0;
      p = rtl.rc(pas.System.Pos("?",AURL),-2147483648,2147483647);
      if (p > 0) {
        AQuery.set(pas.System.Copy(AURL,p + 1,AURL.length));
        AURL = pas.System.Copy(AURL,0,p - 1);
      } else AQuery.set("");
      if (pas.System.Pos("http",pas.SysUtils.LowerCase(AURL)) === 0) AURL = "https://" + AURL;
      off = 9;
      p = rtl.rc(pas.System.Pos$1("/",AURL,off),-2147483648,2147483647);
      if (p > 0) {
        APath.set(pas.System.Copy(AURL,p,AURL.length));
        AURL = pas.System.Copy(AURL,0,p - 1);
      } else APath.set("");
      p = rtl.rc(pas.System.Pos$1(":",AURL,off),-2147483648,2147483647);
      if (p > 0) {
        portVal = 0;
        pas.SysUtils.TryStrToInt(pas.System.Copy(AURL,p + 1,AURL.length),{get: function () {
            return portVal;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            portVal = v;
          }});
        APort.set(portVal);
        AURL = pas.SysUtils.TStringHelper.Substring$1.call({get: function () {
            return AURL;
          }, set: function (v) {
            AURL = v;
          }},0,p - 1);
      } else APort.set(0);
      AHost.set(AURL);
    };
    this.PlayAudio = function (AAudioBase64) {
      var b64 = "";
      try {
        b64 = AAudioBase64;
        try {
          var snd = new Audio("data:audio/wav;base64," + b64);
          snd.play();
        } finally {
        };
      } finally {
      };
    };
    this.DateTimeToISO = function (ADateTime, AAddDelimiters, AAddMilliSeconds) {
      var $Self = this;
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var dd = "";
      var td = "";
      var msec = "";
      function IntToZStr(i, l) {
        var Result = "";
        var Res = "";
        Res = pas.SysUtils.IntToStr(i);
        while (Res.length < l) Res = "0" + Res;
        Result = Res;
        return Result;
      };
      if (AAddDelimiters) {
        dd = "-";
        td = ":";
      };
      pas.SysUtils.DecodeDate(ADateTime,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      pas.SysUtils.DecodeTime(ADateTime,{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      if (AAddMilliSeconds) msec = "." + IntToZStr(ms,3) + "Z";
      Result = IntToZStr(ye,4) + dd + IntToZStr(mo,2) + dd + IntToZStr(da,2) + "T" + IntToZStr(ho,2) + td + IntToZStr(mi,2) + td + IntToZStr(se,2) + msec;
      return Result;
    };
    this.DateToISO = function (ADate, AAddDelimiters) {
      var $Self = this;
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var dd = "";
      function IntToZStr(i, l) {
        var Result = "";
        var Res = "";
        Res = pas.SysUtils.IntToStr(i);
        while (Res.length < l) Res = "0" + Res;
        Result = Res;
        return Result;
      };
      if (AAddDelimiters) dd = "-";
      pas.SysUtils.DecodeDate(ADate,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      Result = IntToZStr(ye,4) + dd + IntToZStr(mo,2) + dd + IntToZStr(da,2);
      return Result;
    };
    var STimePrefix = "T";
    this.ISOToDateTime = function (AISOString, AIsUTC) {
      var $Self = this;
      var Result = 0.0;
      var TimeString = "";
      var DateString = "";
      var TimePosition = 0;
      var SignPosition = 0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var HourOffset = 0;
      var MinuteOffset = 0;
      var err = 0;
      var sign = "";
      var s = "";
      var dt = 0.0;
      var dtt = 0.0;
      function AdjustDateTime(ADate, AHourOffset, AMinuteOffset) {
        var Result = 0.0;
        var AdjustDT = 0.0;
        var BiasLocal = 0;
        var BiasTime = 0;
        var BiasHour = 0;
        var BiasMins = 0;
        var BiasDT = 0.0;
        Result = ADate;
        if (AIsUTC) {
          if ((AHourOffset !== 0) || (AMinuteOffset !== 0)) {
            AdjustDT = pas.SysUtils.EncodeTime(Math.abs(AHourOffset),Math.abs(AMinuteOffset),0,0);
            if (((AHourOffset * 60) + AMinuteOffset) > 0) {
              Result = Result - AdjustDT}
             else Result = Result + AdjustDT;
          };
        } else {
          var dt = new Date();
          BiasLocal = dt.getTimezoneOffset();
          BiasTime = (AHourOffset * 60) + AMinuteOffset;
          if ((BiasLocal + BiasTime) === 0) return Result;
          BiasLocal = BiasLocal + BiasTime;
          BiasHour = rtl.trunc(Math.abs(BiasLocal) / 60);
          BiasMins = Math.abs(BiasLocal) % 60;
          BiasDT = pas.SysUtils.EncodeTime(BiasHour,BiasMins,0,0);
          if (BiasLocal > 0) {
            Result = Result - BiasDT}
           else Result = Result + BiasDT;
        };
        return Result;
      };
      Result = 0;
      s = AISOString;
      HourOffset = 0;
      MinuteOffset = 0;
      TimePosition = pas.System.Pos(STimePrefix,s);
      if (TimePosition >= 0) {
        DateString = pas.System.Copy(s,0,TimePosition);
        TimeString = pas.System.Copy(s,TimePosition + 1,s.length);
      };
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err > 0) return Result;
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err > 0) return Result;
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err > 0) return Result;
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err > 0) return Result;
      pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err > 0) return Result;
      pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err > 0) return Result;
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      if (pas.System.Pos(".",s) > 0) {
        SignPosition = 24}
       else SignPosition = 20;
      if (s.length > SignPosition) {
        sign = pas.System.Copy(s,SignPosition,1);
        if ((sign === "-") || (sign === "+")) {
          pas.System.val$6(pas.System.Copy(s,SignPosition + 1,2),{get: function () {
              return HourOffset;
            }, set: function (v) {
              HourOffset = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err > 0) return Result;
          pas.System.val$6(pas.System.Copy(s,SignPosition + 4,2),{get: function () {
              return MinuteOffset;
            }, set: function (v) {
              MinuteOffset = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err > 0) return Result;
          if (sign === "-") {
            HourOffset = HourOffset * -1;
            MinuteOffset = MinuteOffset * -1;
          };
        };
      };
      if (pas.SysUtils.TryEncodeDate(ye,mo,da,{get: function () {
          return dt;
        }, set: function (v) {
          dt = v;
        }}) && pas.SysUtils.TryEncodeTime(ho,mi,se,0,{get: function () {
          return dtt;
        }, set: function (v) {
          dtt = v;
        }})) {
        Result = dt + dtt;
        Result = AdjustDateTime(Result,HourOffset,MinuteOffset);
      };
      return Result;
    };
    this.ISOToDate = function (AISOString) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var err = 0;
      var s = "";
      s = AISOString;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(0,0,0,0);
      return Result;
    };
    this.DateTimeToUTC = function (ADateTime) {
      var $Self = this;
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var bias = 0;
      var biasday = 0;
      var isDayLight = false;
      function IntToZStr(i, l) {
        var Result = "";
        var Res = "";
        Res = pas.SysUtils.IntToStr(i);
        while (Res.length < l) Res = "0" + Res;
        Result = Res;
        return Result;
      };
      bias = 0;
      biasday = 0;
      isDayLight = false;
      this.GetTimeZoneInfo(ADateTime,{get: function () {
          return bias;
        }, set: function (v) {
          bias = v;
        }},{get: function () {
          return biasday;
        }, set: function (v) {
          biasday = v;
        }},{get: function () {
          return isDayLight;
        }, set: function (v) {
          isDayLight = v;
        }});
      pas.SysUtils.DecodeDate(ADateTime,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      pas.SysUtils.DecodeTime(ADateTime,{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = pas.SysUtils.IntToStr(ye) + "-" + IntToZStr(mo,2) + "-" + IntToZStr(da,2) + "T" + IntToZStr(ho,2) + ":" + IntToZStr(mi,2) + ":" + IntToZStr(se,2);
      if (isDayLight) {
        if (bias <= 0) {
          Result = Result + "+" + IntToZStr(rtl.trunc((-bias - biasday) / 60),2) + ":00"}
         else Result = Result + "-" + IntToZStr(rtl.trunc((bias + biasday) / 60),2) + ":00";
      } else {
        if (bias !== 0) {
          if (bias <= 0) {
            Result = Result + "+" + IntToZStr(rtl.trunc(-bias / 60),2) + ":00"}
           else Result = Result + "-" + IntToZStr(rtl.trunc(bias / 60),2) + ":00";
        } else Result = Result + "+00:00";
      };
      return Result;
    };
    var UnixStartDate = 25569;
    this.DateTimeToMilliSeconds = function (ADateTime) {
      var Result = 0;
      var bias = 0;
      var biasday = 0;
      var isDayLight = false;
      bias = 0;
      biasday = 0;
      isDayLight = false;
      this.GetTimeZoneInfo(ADateTime,{get: function () {
          return bias;
        }, set: function (v) {
          bias = v;
        }},{get: function () {
          return biasday;
        }, set: function (v) {
          biasday = v;
        }},{get: function () {
          return isDayLight;
        }, set: function (v) {
          isDayLight = v;
        }});
      if (isDayLight) {
        Result = pas.DateUtils.MilliSecondsBetween(pas.DateUtils.IncHour(ADateTime,rtl.trunc((bias + biasday) / 60)),UnixStartDate)}
       else Result = pas.DateUtils.MilliSecondsBetween(pas.DateUtils.IncHour(ADateTime,rtl.trunc(bias / 60)),UnixStartDate);
      return Result;
    };
    this.GetMimeType = function (AFile) {
      var Result = "";
      var e = "";
      e = pas.SysUtils.ExtractFileExt(AFile);
      e = pas.SysUtils.LowerCase(pas.SysUtils.Trim(e));
      if ((e !== "") && (e.charAt(0) === ".")) e = pas.System.Copy(e,2,e.length - 1);
      Result = "";
      if ($impl.FMimeTypes != null) Result = $impl.FMimeTypes.GetValue(e);
      if (Result === "") Result = "application/octet-stream";
      return Result;
    };
    this.GetMimeType$1 = function (AData, AResetPosition) {
      var Result = "";
      Result = "";
      throw pas.SysUtils.Exception.$create("Create$1",["Implement GetMimeType"]);
      return Result;
    };
    this.GetFileExtension = function (AMime) {
      var Result = "";
      var I = 0;
      var e = "";
      e = pas.SysUtils.LowerCase(AMime);
      Result = "";
      if ($impl.FMimeTypes != null) {
        for (var $l = 0, $end = $impl.FMimeTypes.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ($impl.FMimeTypes.GetValueFromIndex(I) === e) {
            Result = $impl.FMimeTypes.GetName(I);
            return Result;
          };
        };
      };
      return Result;
    };
    this.FileToBase64 = function (AFile) {
      var Result = "";
      var s = "";
      function uint8ToString(buf) {
        var i, length, out = '';
        for (i = 0, length = buf.length; i < length; i += 1) {
            out += String.fromCharCode(buf[i]);
        }
        return out;
      }
      s = btoa(uint8ToString(AFile.Data));
      Result = s;
      return Result;
    };
    this.LoadFile = function (AFile, ALoadFileComplete) {
      var f = null;
      var c = null;
      var ua = null;
      if (1 < 0) $mod.CreateUploadFile("file",ua);
      f = AFile;
      c = ALoadFileComplete;
      var reader = new FileReader();
      
          reader.onload = function(e) {
            var s = new Uint8Array(reader.result);
            var fn = pas["WEBLib.TMSFNCUtils"].CreateUploadFile(f.name, s);
            if (c){
              c(fn);
            }
          }
      
          reader.readAsArrayBuffer(f);
    };
    this.Decode64 = function (AValue, AURL) {
      var Result = "";
      var s = "";
      Result = "";
      if (AValue.length === 0) return Result;
      s = AValue;
      if (AURL) {
        s = s + pas.System.StringOfChar("=",s.length % 4);
        s = pas.SysUtils.StringReplace(s,"-","+",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        s = pas.SysUtils.StringReplace(s,"_","/",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      };
      function b64DecodeUnicode(str) {
        var binary_string = window.atob(str);
        return binary_string;
      }
      return b64DecodeUnicode(s);
      return Result;
    };
    this.Encode64 = function (AValue, AURL) {
      var Result = "";
      var s = "";
      var v = "";
      Result = "";
      if (AValue.length === 0) return Result;
      v = AValue;
      function b64EncodeUnicode(str) {
        return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
            function toSolidBytes(match, p1) {
                return String.fromCharCode('0x' + p1);
        }));
      }
      s = b64EncodeUnicode(v);
      if (AURL) {
        s = pas.SysUtils.StringReplace(s,"+","-",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
        s = pas.SysUtils.StringReplace(s,"/","_",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
        s = pas.SysUtils.StringReplace(s,"=","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      };
      Result = s;
      return Result;
    };
    this.Encode64$1 = function (AValue, AURL) {
      var Result = "";
      var s = "";
      var v = [];
      Result = "";
      if (rtl.length(AValue) === 0) return Result;
      v = rtl.arrayRef(AValue);
      s = "";
      function _arrayBufferToBase64( buffer ) {
              var binary = '';
              var bytes = new Uint8Array( buffer );
              var len = bytes.byteLength;
              for (var i = 0; i < len; i++) {
                  binary += String.fromCharCode( bytes[ i ] );
              }
              return window.btoa( binary );
          }
      
          s = _arrayBufferToBase64(v);
      if (AURL) {
        s = pas.SysUtils.StringReplace(s,"+","-",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
        s = pas.SysUtils.StringReplace(s,"/","_",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
        s = pas.SysUtils.StringReplace(s,"=","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      };
      Result = s;
      return Result;
    };
    this.Log$1 = function (AObject) {
      window.console.log(AObject);
    };
    this.GetJSONProp = function (AJSONValue, APropertyName) {
      var Result = "";
      var v = null;
      Result = "";
      v = this.GetJSONValue(AJSONValue,APropertyName);
      if ((v != null) && !pas["WEBLib.JSON"].TJSONNull.isPrototypeOf(v)) Result = v.GetStrValue();
      return Result;
    };
    this.GetJSONValueAsBoolean = function (AJSONValue) {
      var Result = false;
      Result = false;
      if (AJSONValue != null) {
        Result = pas["WEBLib.JSON"].TJSONTrue.isPrototypeOf(AJSONValue);
      };
      return Result;
    };
    this.GetJSONValueAsString = function (AJSONValue) {
      var Result = "";
      Result = "";
      if (AJSONValue != null) {
        Result = AJSONValue.ToString();
      };
      return Result;
    };
    this.GetJSONValue = function (AJSONValue, APropertyName) {
      var Result = null;
      Result = null;
      try {
        if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(AJSONValue)) {
          Result = rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONObject).GetValue$1(APropertyName);
        };
      } catch ($e) {
      };
      return Result;
    };
    this.FindJSONValue = function (AJSONValue, APath) {
      var Result = null;
      Result = null;
      try {
        if (AJSONValue != null) {
          Result = this.GetJSONValue(AJSONValue,APath);
        };
      } catch ($e) {
      };
      return Result;
    };
    this.GetJSONDoubleValue = function (AJSONValue, APropertyName) {
      var Result = 0.0;
      Result = this.GetJSONValueAsDouble(this.GetJSONValue(AJSONValue,APropertyName));
      return Result;
    };
    this.GetJSONValueAsDouble = function (AJSONValue) {
      var Result = 0.0;
      var v = null;
      Result = 0;
      v = AJSONValue;
      if ((v != null) && pas["WEBLib.JSON"].TJSONNumber.isPrototypeOf(v)) {
        Result = rtl.as(v,pas["WEBLib.JSON"].TJSONNumber).FDouble;
      };
      return Result;
    };
    this.GetJSONIntegerValue = function (AJSONValue, APropertyName) {
      var Result = 0;
      Result = this.GetJSONValueAsInteger(this.GetJSONValue(AJSONValue,APropertyName));
      return Result;
    };
    this.GetJSONValueAsInteger = function (AJSONValue) {
      var Result = 0;
      var v = null;
      Result = 0;
      v = AJSONValue;
      if ((v != null) && pas["WEBLib.JSON"].TJSONNumber.isPrototypeOf(v)) {
        Result = rtl.as(v,pas["WEBLib.JSON"].TJSONNumber).FInt;
      };
      return Result;
    };
    this.IsJSONTrue = function (AJSONValue) {
      var Result = false;
      Result = false;
      if (AJSONValue != null) Result = AJSONValue.GetStrValue() === "true";
      return Result;
    };
    this.IsJSONFalse = function (AJSONValue) {
      var Result = false;
      Result = false;
      if (AJSONValue != null) Result = AJSONValue.GetStrValue() === "false";
      return Result;
    };
    this.GetJSONArraySize = function (AJSONArray) {
      var Result = 0;
      Result = AJSONArray.GetCount();
      return Result;
    };
    this.GetJSONArrayItem = function (AJSONArray, AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.GetJSONArraySize(AJSONArray) - 1))) {
        Result = AJSONArray.GetItem(AIndex);
      };
      return Result;
    };
    this.GetJSONObjectSize = function (AJSONObject) {
      var Result = 0;
      Result = AJSONObject.GetCount();
      return Result;
    };
    this.GetJSONObjectItem = function (AJSONObject, AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.GetJSONObjectSize(AJSONObject) - 1))) {
        Result = AJSONObject.GetItem(AIndex);
      };
      return Result;
    };
    this.GetJSONObjectName = function (AJSONObject, AIndex) {
      var Result = "";
      var p = null;
      Result = "";
      if ((AIndex >= 0) && (AIndex <= (this.GetJSONObjectSize(AJSONObject) - 1))) {
        p = AJSONObject.Get$1(AIndex);
        if (p != null) Result = p.fjs.GetStrValue();
      };
      return Result;
    };
    this.ParseJSON = function (AJSON) {
      var Result = null;
      Result = pas["WEBLib.JSON"].TJSONObject.ParseJSONValue(AJSON);
      return Result;
    };
    this.IsJSON = function (AJSON) {
      var Result = false;
      var v = null;
      v = this.ParseJSON(AJSON);
      Result = false;
      if (v != null) {
        Result = true;
        v = rtl.freeLoc(v);
      };
      return Result;
    };
    this.StrToFloatDot = function (AValue) {
      var Result = 0.0;
      Result = pas.SysUtils.StrToFloat$1(AValue,$mod.FNCFormatSettings);
      return Result;
    };
    this.FloatToStrDot = function (AValue) {
      var Result = "";
      Result = pas.SysUtils.FloatToStr$1(AValue,$mod.FNCFormatSettings);
      return Result;
    };
    this.TryStrToFloatDot = function (AValue, AResult) {
      var Result = false;
      Result = pas.SysUtils.TryStrToFloat$3(AValue,AResult,$mod.FNCFormatSettings);
      return Result;
    };
    this.Decode64ToBytes = function (AValue, AURL) {
      var Result = [];
      var s = "";
      var ss = null;
      Result = [];
      if (AValue.length === 0) return Result;
      s = AValue;
      if (AURL) {
        s = s + pas.System.StringOfChar("=",s.length % 4);
        s = pas.SysUtils.StringReplace(s,"-","+",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        s = pas.SysUtils.StringReplace(s,"_","/",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      };
      function b64DecodeUnicode(str) {
        var binary_string = window.atob(str);
        return binary_string;
      }
      s = b64DecodeUnicode(s);
      ss = pas.Classes.TStringStream.$create("Create$3",["",pas.SysUtils.TEncoding.GetUTF8(),true]);
      try {
        ss.WriteString(s);
        Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCMemoryStream.GetBytes.call(ss);
      } finally {
        ss = rtl.freeLoc(ss);
      };
      return Result;
    };
    this.MatchStrEx = function (AValue1, AValue2, ACaseSensitive) {
      var Result = false;
      var ch = "\x00";
      var lastOp = "\x00";
      var sep = 0;
      var cp = 0;
      var res = false;
      var newRes = false;
      var CharArray = [];
      var part = "";
      if (AValue1 === '""') AValue1 = "";
      if (AValue2 === '""') AValue2 = "";
      if ((AValue1 === "") && (AValue2 === "")) {
        Result = true;
        return Result;
      };
      AValue1 = pas.SysUtils.Trim(AValue1);
      AValue1 = this.StripLogicSpaces(AValue1);
      if ((AValue2 === "") && (pas.System.Pos('""',AValue1) === 0) && (pas.System.Pos("*",AValue1) === 0)) return false;
      CharArray = rtl.arraySetLength(CharArray,"\x00",5);
      CharArray[0] = "(";
      CharArray[1] = ";";
      CharArray[2] = "^";
      CharArray[3] = "&";
      CharArray[4] = "|";
      lastOp = "\x00";
      res = true;
      do {
        ch = rtl.rcc(this.FirstChar(rtl.arrayRef(CharArray),AValue1,{get: function () {
            return sep;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            sep = v;
          }}),0,65535);
        if (ch !== "\x00") {
          if ((AValue1.length > 0) && (rtl.rcCharAt(AValue1,0) === "(")) {
            cp = rtl.rc(this.ClosingParenthesis(AValue1),-2147483648,2147483647);
            part = pas.System.Copy(AValue1,2,cp - 2);
            newRes = this.MatchStrEx(part,AValue2,ACaseSensitive);
            pas.System.Delete({get: function () {
                return AValue1;
              }, set: function (v) {
                AValue1 = v;
              }},1,cp);
          } else {
            part = pas.System.Copy(AValue1,1,sep - 1);
            newRes = this.MatchStr(part,AValue2,ACaseSensitive);
            pas.System.Delete({get: function () {
                return AValue1;
              }, set: function (v) {
                AValue1 = v;
              }},1,sep);
          };
          if (lastOp === "\x00") {
            res = newRes}
           else {
            var $tmp = lastOp;
            if ($tmp === "^") {
              res = res ^ newRes}
             else if ($tmp === "&") {
              res = res && newRes}
             else if (($tmp === "|") || ($tmp === ";")) res = res || newRes;
          };
          lastOp = rtl.rcc(ch,0,65535);
        };
      } while (!(ch === "\x00"));
      part = AValue1;
      newRes = this.MatchStr(part,AValue2,ACaseSensitive);
      if (lastOp === "\x00") {
        res = newRes}
       else {
        var $tmp1 = lastOp;
        if ($tmp1 === "^") {
          res = res ^ newRes}
         else if ($tmp1 === "&") {
          res = res && newRes}
         else if (($tmp1 === "|") || ($tmp1 === ";")) res = res || newRes;
      };
      Result = res;
      return Result;
    };
    this.MatchStrEx$1 = function (AValue, AArray, ACaseSensitive, AExpression) {
      var Result = false;
      Result = this.GetStrIdx(AValue,AArray,ACaseSensitive,AExpression) !== -1;
      return Result;
    };
    this.MatchStr = function (AValue1, AValue2, ACaseSensitive) {
      var Result = false;
      if (AValue1 === '""') AValue1 = "";
      if (AValue2 === '""') AValue2 = "";
      if ((AValue1 === "") && (AValue2 === "")) {
        Result = true;
        return Result;
      };
      AValue1 = pas.SysUtils.Trim(AValue1);
      AValue2 = pas.SysUtils.Trim(AValue2);
      if (AValue1 === "*") return true;
      if ((AValue1 === '""') || (AValue1 === "")) return AValue2 === "";
      if (AValue2 === "") return false;
      if ((AValue1.length > 1) && (rtl.rcCharAt(AValue1,0) === '"') && (rtl.rcCharAt(AValue1,AValue1.length - 1) === '"')) AValue1 = pas.System.Copy(AValue1,2,AValue1.length - 2);
      if (ACaseSensitive) {
        Result = this.Matches(AValue1,AValue2)}
       else Result = this.Matches(pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(AValue1),pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(AValue2));
      return Result;
    };
    this.GetStrIdx = function (AValue, AArray, ACaseSensitive, AExpression) {
      var Result = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = rtl.length(AArray) - 1; $l <= $end; $l++) {
        I = $l;
        if (!AExpression) {
          if ((ACaseSensitive && (AValue === AArray[I])) || ((ACaseSensitive === false) && (pas.SysUtils.UpperCase(AValue) === pas.SysUtils.UpperCase(AArray[I])))) {
            Result = I;
            break;
          };
        } else if (this.MatchStr(AValue,AArray[I],ACaseSensitive)) {
          Result = I;
          break;
        };
      };
      return Result;
    };
    this.StripLogicSpaces = function (AValue) {
      var Result = "";
      var i = 0;
      var k = 0;
      var q = 0;
      q = 0;
      i = 1;
      k = AValue.length;
      Result = "";
      while (i <= k) {
        if (AValue.charAt(i - 1) === '"') q += 1;
        if (AValue.charAt(i - 1) === " ") {
          if (pas.System.Odd(q)) Result = Result + AValue.charAt(i - 1);
        } else Result = Result + AValue.charAt(i - 1);
        i += 1;
      };
      return Result;
    };
    this.FirstChar = function (ACharset, AValue, spos) {
      var Result = "\x00";
      var i = 0;
      var q = 0;
      var j = 0;
      j = 0;
      i = 1;
      q = 0;
      spos.set(-1);
      Result = "\x00";
      while (i <= AValue.length) {
        if (AValue.charAt(i - j - 1) === '"') q += 1;
        if (this.CharInSet(AValue.charAt(i - j - 1),rtl.arrayRef(ACharset)) && !pas.System.Odd(q)) {
          spos.set(i);
          Result = AValue.charAt(i - j - 1);
          break;
        };
        i += 1;
      };
      return Result;
    };
    this.CharInSet = function (ch, ACharSet) {
      var Result = false;
      var j = 0;
      Result = false;
      for (var $l = 0, $end = rtl.length(ACharSet) - 1; $l <= $end; $l++) {
        j = $l;
        if (ch === ACharSet[j]) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.AddCharSet = function (ACharSet1, ACharSet2) {
      var Result = [];
      var l = 0;
      var j = 0;
      l = rtl.length(ACharSet1) + rtl.length(ACharSet2);
      Result = rtl.arraySetLength(Result,"\x00",l);
      l = 0;
      for (var $l = 0, $end = rtl.length(ACharSet1) - 1; $l <= $end; $l++) {
        j = $l;
        Result[l] = ACharSet1[j];
        l += 1;
      };
      for (var $l1 = 0, $end1 = rtl.length(ACharSet2) - 1; $l1 <= $end1; $l1++) {
        j = $l1;
        Result[l] = ACharSet2[j];
        l += 1;
      };
      return Result;
    };
    this.SubCharSet = function (ACharSet1, ACharSet2) {
      var Result = [];
      var i = 0;
      var j = 0;
      var l = 0;
      var found = false;
      l = 0;
      Result = rtl.arraySetLength(Result,"\x00",l);
      for (var $l = 0, $end = rtl.length(ACharSet1) - 1; $l <= $end; $l++) {
        i = $l;
        found = false;
        for (var $l1 = 0, $end1 = rtl.length(ACharSet2) - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          if (ACharSet1[i] === ACharSet2[j]) {
            found = true;
            break;
          };
        };
        if (!found) {
          l += 1;
          Result = rtl.arraySetLength(Result,"\x00",l);
          Result[l - 1] = ACharSet1[i];
        };
      };
      return Result;
    };
    this.IsLetterOrDigit = function (AChar) {
      var Result = false;
      Result = $mod.TTMSFNCUtils.CharInSet(AChar,this.NumericCharSet()) || $mod.TTMSFNCUtils.CharInSet(AChar,this.AlphaCharSet());
      return Result;
    };
    this.AlphaCharSet = function () {
      var Result = [];
      var i = 0;
      var ch = "\x00";
      Result = rtl.arraySetLength(Result,"\x00",52);
      i = 0;
      for (var $l = 97; $l <= 122; $l++) {
        ch = String.fromCharCode($l);
        Result[i] = ch;
        i += 1;
      };
      for (var $l1 = 65; $l1 <= 90; $l1++) {
        ch = String.fromCharCode($l1);
        Result[i] = ch;
        i += 1;
      };
      return Result;
    };
    this.NumericCharSet = function () {
      var Result = [];
      var ch = "\x00";
      var i = 0;
      Result = rtl.arraySetLength(Result,"\x00",10);
      i = 0;
      for (var $l = 48; $l <= 57; $l++) {
        ch = String.fromCharCode($l);
        Result[i] = ch;
        i += 1;
      };
      return Result;
    };
    this.CreateCharSet = function (AValue) {
      var Result = [];
      var i = 0;
      Result = rtl.arraySetLength(Result,"\x00",AValue.length);
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        i = $l;
        Result[i - 1] = this.CharInStr(AValue,i);
      };
      return Result;
    };
    this.IsDate = function (AValue, ADate) {
      var Result = false;
      var su = "";
      var ts = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var err = 0;
      var dp = 0;
      var mp = 0;
      var yp = 0;
      var vp = 0;
      Result = false;
      ts = "";
      su = pas.SysUtils.UpperCase(pas.SysUtils.FormatSettings.ShortDateFormat);
      dp = pas.System.Pos("D",su);
      mp = pas.System.Pos("M",su);
      yp = pas.System.Pos("Y",su);
      da = 0;
      mo = 0;
      ye = 0;
      ho = 0;
      mi = 0;
      se = 0;
      vp = -1;
      if ($mod.TTMSFNCUtils.VarPos(pas.SysUtils.FormatSettings.DateSeparator,AValue,{get: function () {
          return vp;
        }, set: function (v) {
          vp = v;
        }}) > 0) {
        su = pas.System.Copy(AValue,1,vp - 1);
        if ((dp < mp) && (dp < yp)) {
          pas.System.val$5(su,{get: function () {
              return da;
            }, set: function (v) {
              da = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }})}
         else if ((mp < dp) && (mp < yp)) {
          pas.System.val$5(su,{get: function () {
              return mo;
            }, set: function (v) {
              mo = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }})}
         else if ((yp < mp) && (yp < dp)) pas.System.val$5(su,{get: function () {
            return ye;
          }, set: function (v) {
            ye = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return Result;
        pas.System.Delete({get: function () {
            return AValue;
          }, set: function (v) {
            AValue = v;
          }},1,vp);
        if ($mod.TTMSFNCUtils.VarPos(pas.SysUtils.FormatSettings.DateSeparator,AValue,{get: function () {
            return vp;
          }, set: function (v) {
            vp = v;
          }}) > 0) {
          su = pas.System.Copy(AValue,1,vp - 1);
          if (((dp > mp) && (dp < yp)) || ((dp > yp) && (dp < mp))) {
            pas.System.val$5(su,{get: function () {
                return da;
              }, set: function (v) {
                da = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if (((mp > dp) && (mp < yp)) || ((mp > yp) && (mp < dp))) {
            pas.System.val$5(su,{get: function () {
                return mo;
              }, set: function (v) {
                mo = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if (((yp > mp) && (yp < dp)) || ((yp > dp) && (yp < mp))) pas.System.val$5(su,{get: function () {
              return ye;
            }, set: function (v) {
              ye = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err !== 0) return Result;
          pas.System.Delete({get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }},1,vp);
          AValue = pas.SysUtils.Trim(AValue);
          if ($mod.TTMSFNCUtils.VarPos(" ",AValue,{get: function () {
              return vp;
            }, set: function (v) {
              vp = v;
            }}) > 0) {
            ts = pas.System.Copy(AValue,vp,AValue.length);
            AValue = pas.System.Copy(AValue,1,vp - 1);
          };
          if ((dp > mp) && (dp > yp)) {
            pas.System.val$5(AValue,{get: function () {
                return da;
              }, set: function (v) {
                da = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if ((mp > dp) && (mp > yp)) {
            pas.System.val$5(AValue,{get: function () {
                return mo;
              }, set: function (v) {
                mo = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if ((yp > mp) && (yp > dp)) pas.System.val$5(AValue,{get: function () {
              return ye;
            }, set: function (v) {
              ye = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err !== 0) return Result;
          if (da > 31) return Result;
          if (mo > 12) return Result;
          if (ts !== "") {
            if ($mod.TTMSFNCUtils.VarPos(pas.SysUtils.FormatSettings.TimeSeparator,ts,{get: function () {
                return vp;
              }, set: function (v) {
                vp = v;
              }}) > 0) {
              su = pas.System.Copy(ts,1,vp - 1);
              pas.System.val$5(su,{get: function () {
                  return ho;
                }, set: function (v) {
                  ho = v;
                }},{get: function () {
                  return err;
                }, set: function (v) {
                  err = v;
                }});
              if (err !== 0) return Result;
              if (ho > 23) return Result;
              pas.System.Delete({get: function () {
                  return ts;
                }, set: function (v) {
                  ts = v;
                }},1,vp);
              if ($mod.TTMSFNCUtils.VarPos(pas.SysUtils.FormatSettings.TimeSeparator,ts,{get: function () {
                  return vp;
                }, set: function (v) {
                  vp = v;
                }}) > 0) {
                su = pas.System.Copy(ts,1,vp - 1);
                pas.System.val$5(su,{get: function () {
                    return mi;
                  }, set: function (v) {
                    mi = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
                pas.System.Delete({get: function () {
                    return ts;
                  }, set: function (v) {
                    ts = v;
                  }},1,vp);
                pas.System.val$5(ts,{get: function () {
                    return se;
                  }, set: function (v) {
                    se = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
                if (se > 60) return Result;
              } else {
                pas.System.val$5(su,{get: function () {
                    return mi;
                  }, set: function (v) {
                    mi = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
              };
              if (mi > 59) return Result;
              Result = true;
            };
          } else Result = true;
          try {
            ADate.set(pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,0));
          } catch ($e) {
            Result = false;
          };
        };
      };
      return Result;
    };
    this.IPos = function (su, s) {
      var Result = 0;
      Result = pas.System.Pos(pas.SysUtils.UpperCase(su),pas.SysUtils.UpperCase(s));
      return Result;
    };
    this.UnFixMarkup = function (su, SpecialChars, SpecialCharsOnly) {
      var Result = "";
      var i = 0;
      if (!SpecialCharsOnly) {
        while (pas.System.Pos("&lt;",su) > 0) {
          this.TagReplaceString("&lt;","<",{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
        while (pas.System.Pos("&gt;",su) > 0) {
          this.TagReplaceString("&gt;",">",{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
        while (pas.System.Pos("&amp;",su) > 0) {
          this.TagReplaceString("&amp;","&",{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
        while (pas.System.Pos("&quot;",su) > 0) {
          this.TagReplaceString("&quot;",'"',{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
      };
      if (SpecialChars) {
        for (i = 4; i <= 92; i++) {
          while (pas.System.Pos($impl.HTMLSpecialChar[i - 1],su) > 0) {
            this.TagReplaceString($impl.HTMLSpecialChar[i - 1],$impl.HTMLEncodedChar[i - 1],{get: function () {
                return su;
              }, set: function (v) {
                su = v;
              }});
          };
        };
      };
      Result = su;
      return Result;
    };
    this.FixMarkup = function (su, SpecialChars) {
      var Result = "";
      var i = 0;
      var res = "";
      var ch = "\x00";
      while (pas.System.Pos("&",su) > 0) {
        this.TagReplaceString("&","*amp;",{get: function () {
            return su;
          }, set: function (v) {
            su = v;
          }});
      };
      while (pas.System.Pos("*amp;",su) > 0) {
        this.TagReplaceString("*amp;","&amp;",{get: function () {
            return su;
          }, set: function (v) {
            su = v;
          }});
      };
      while (pas.System.Pos('"',su) > 0) {
        this.TagReplaceString('"',"&quot;",{get: function () {
            return su;
          }, set: function (v) {
            su = v;
          }});
      };
      while (pas.System.Pos("<",su) > 0) {
        this.TagReplaceString("<","&lt;",{get: function () {
            return su;
          }, set: function (v) {
            su = v;
          }});
      };
      while (pas.System.Pos(">",su) > 0) {
        this.TagReplaceString(">","&gt;",{get: function () {
            return su;
          }, set: function (v) {
            su = v;
          }});
      };
      if (SpecialChars) {
        for (i = 4; i <= 92; i++) {
          while (pas.System.Pos($impl.HTMLEncodedChar[i - 1],su) > 0) {
            this.TagReplaceString($impl.HTMLEncodedChar[i - 1],$impl.HTMLSpecialChar[i - 1],{get: function () {
                return su;
              }, set: function (v) {
                su = v;
              }});
          };
        };
        res = "";
        for (var $l = 1, $end = su.length; $l <= $end; $l++) {
          i = $l;
          ch = this.CharInStr(su,i);
          if (ch.charCodeAt() > 256) {
            res = res + "&#" + pas.SysUtils.IntToStr(ch.charCodeAt()) + ";"}
           else res = res + ch;
        };
        su = res;
      };
      Result = su;
      return Result;
    };
    this.TagReplaceString = function (Srch, Repl, Dest) {
      var Result = false;
      var i = 0;
      i = this.IPos(Srch,Dest.get());
      if (i > 0) {
        Result = true;
        pas.System.Delete(Dest,i,Srch.length);
        Dest.set(pas.System.Copy(Dest.get(),1,i - 1) + Repl + pas.System.Copy(Dest.get(),i,Dest.get().length));
      } else Result = false;
      return Result;
    };
    var larger = ">";
    var smaller = "<";
    var logand = "&";
    var logor = "^";
    var asterix = "*";
    var qmark = "?";
    var negation = "!";
    this.Matches = function (s0a, s1a) {
      var Result = false;
      var matching = false;
      var done = false;
      var len = 0;
      var lastchar = "\x00";
      var s0 = 0;
      var s1 = 0;
      var s2 = 0;
      var s3 = 0;
      var oksmaller = false;
      var oklarger = false;
      var negflag = false;
      var compstr = "";
      var flag1 = false;
      var flag2 = false;
      var flag3 = false;
      var equal = false;
      var n1 = 0.0;
      var n2 = 0.0;
      var code1 = 0;
      var code2 = 0;
      var dt1 = 0.0;
      var dt2 = 0.0;
      var q = 0;
      var i = 0;
      if (s0a === '""') s0a = "";
      if (s1a === '""') s1a = "";
      if ((s0a === "") && (s1a === "")) {
        Result = true;
        return Result;
      };
      i = 0;
      oksmaller = true;
      oklarger = true;
      flag1 = false;
      flag2 = false;
      flag3 = false;
      negflag = false;
      equal = false;
      s2 = rtl.rc(pas.System.Pos(larger,s0a),-2147483648,2147483647);
      if (s2 !== 0) {
        s2 += 1;
        if (rtl.rcCharAt(s0a,s2 - i - 1) === "=") {
          equal = true;
          s2 += 1;
        };
        while (rtl.rcCharAt(s0a,s2 - i - 1) === " ") s2 += 1;
        s3 = rtl.rc(s2,-2147483648,2147483647);
        len = 0;
        lastchar = "\x00";
        q = 0;
        while (((s2 - i) <= s0a.length) && (rtl.rcCharAt(s0a,s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((rtl.rcCharAt(s0a,s2 - i - 1) !== "&") && (rtl.rcCharAt(s0a,s2 - i - 1) !== "|")))) {
          if (rtl.rcCharAt(s0a,s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (rtl.rcCharAt(s0a,s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = rtl.rcc(rtl.rcCharAt(s0a,s2 - i - 1),0,65535);
          s2 += 1;
          if (((s2 - i) <= s0a.length) && (rtl.rcCharAt(s0a,s2 - i - 1) === " ") && pas.System.Odd(q)) {
            lastchar = rtl.rcc(rtl.rcCharAt(s0a,s2 - i - 1),0,65535);
            s2 += 1;
          };
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        pas.System.val$8($mod.TTMSFNCUtils.StripThousandSep(s1a),{get: function () {
            return n1;
          }, set: function (v) {
            n1 = v;
          }},{get: function () {
            return code1;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            code1 = v;
          }});
        pas.System.val$8($mod.TTMSFNCUtils.StripThousandSep(compstr),{get: function () {
            return n2;
          }, set: function (v) {
            n2 = v;
          }},{get: function () {
            return code2;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            code2 = v;
          }});
        dt2 = 0;
        if ($mod.TTMSFNCUtils.IsDate(compstr,{get: function () {
            return dt2;
          }, set: function (v) {
            dt2 = v;
          }})) code2 = 1;
        dt1 = 0;
        if ($mod.TTMSFNCUtils.IsDate(s1a,{get: function () {
            return dt1;
          }, set: function (v) {
            dt1 = v;
          }})) code1 = 1;
        if ((code1 === 0) && (code2 === 0)) {
          if (equal) {
            oklarger = n1 >= n2}
           else oklarger = n1 > n2;
        } else {
          if ($mod.TTMSFNCUtils.IsDate(compstr,{get: function () {
              return dt2;
            }, set: function (v) {
              dt2 = v;
            }}) && $mod.TTMSFNCUtils.IsDate(s1a,{get: function () {
              return dt1;
            }, set: function (v) {
              dt1 = v;
            }})) {
            if (equal) {
              oklarger = dt1 >= dt2}
             else oklarger = dt1 > dt2;
          } else {
            if (equal) {
              oklarger = pas.SysUtils.CompareStr(compstr,s1a) <= 0}
             else oklarger = pas.SysUtils.CompareStr(compstr,s1a) < 0;
          };
        };
        flag1 = true;
      };
      equal = false;
      s2 = rtl.rc(pas.System.Pos(smaller,s0a),-2147483648,2147483647);
      if (s2 !== 0) {
        s2 += 1;
        if (rtl.rcCharAt(s0a,s2 - i - 1) === "=") {
          equal = true;
          s2 += 1;
        };
        lastchar = "\x00";
        while (((s2 - i) <= s0a.length) && (rtl.rcCharAt(s0a,s2 - i - 1) === " ")) s2 += 1;
        s3 = rtl.rc(s2,-2147483648,2147483647);
        len = 0;
        q = 0;
        while (((s2 - i) <= s0a.length) && (rtl.rcCharAt(s0a,s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((rtl.rcCharAt(s0a,s2 - i - 1) !== "&") && (rtl.rcCharAt(s0a,s2 - i - 1) !== "|")))) {
          if (rtl.rcCharAt(s0a,s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (rtl.rcCharAt(s0a,s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = rtl.rcc(rtl.rcCharAt(s0a,s2 - i - 1),0,65535);
          s2 += 1;
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        pas.System.val$8($mod.TTMSFNCUtils.StripThousandSep(s1a),{get: function () {
            return n1;
          }, set: function (v) {
            n1 = v;
          }},{get: function () {
            return code1;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            code1 = v;
          }});
        pas.System.val$8($mod.TTMSFNCUtils.StripThousandSep(compstr),{get: function () {
            return n2;
          }, set: function (v) {
            n2 = v;
          }},{get: function () {
            return code2;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            code2 = v;
          }});
        if ($mod.TTMSFNCUtils.IsDate(compstr,{get: function () {
            return dt2;
          }, set: function (v) {
            dt2 = v;
          }})) code2 = 1;
        if ($mod.TTMSFNCUtils.IsDate(s1a,{get: function () {
            return dt1;
          }, set: function (v) {
            dt1 = v;
          }})) code1 = 1;
        if ((code1 === 0) && (code2 === 0)) {
          if (equal) {
            oksmaller = n1 <= n2}
           else oksmaller = n1 < n2;
        } else {
          if ($mod.TTMSFNCUtils.IsDate(compstr,{get: function () {
              return dt2;
            }, set: function (v) {
              dt2 = v;
            }}) && $mod.TTMSFNCUtils.IsDate(s1a,{get: function () {
              return dt1;
            }, set: function (v) {
              dt1 = v;
            }})) {
            if (equal) {
              oksmaller = dt1 <= dt2}
             else oksmaller = dt1 < dt2;
          } else {
            if (equal) {
              oksmaller = pas.SysUtils.CompareStr(compstr,s1a) >= 0}
             else oksmaller = pas.SysUtils.CompareStr(compstr,s1a) > 0;
          };
        };
        flag2 = true;
      };
      s2 = rtl.rc(pas.System.Pos(negation,s0a),-2147483648,2147483647);
      if (s2 !== 0) {
        s2 += 1;
        while (rtl.rcCharAt(s0a,s2 - i - 1) === " ") s2 += 1;
        s3 = rtl.rc(s2,-2147483648,2147483647);
        len = 0;
        lastchar = "\x00";
        q = 0;
        while (((s2 - i) <= s0a.length) && (rtl.rcCharAt(s0a,s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((rtl.rcCharAt(s0a,s2 - i - 1) !== "&") && (rtl.rcCharAt(s0a,s2 - i - 1) !== "|")))) {
          if (rtl.rcCharAt(s0a,s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (rtl.rcCharAt(s0a,s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = rtl.rcc(rtl.rcCharAt(s0a,s2 - i - 1),0,65535);
          s2 += 1;
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        flag3 = true;
      };
      if (flag3) {
        if (pas.System.Pos(larger,s0a) === 0) flag1 = flag3;
        if (pas.System.Pos(smaller,s0a) === 0) flag2 = flag3;
      };
      if (pas.System.Pos(logor,s0a) !== 0) if (flag1 || flag2) {
        Result = oksmaller || oklarger;
        return Result;
      };
      if (pas.System.Pos(logand,s0a) !== 0) if (flag1 && flag2) {
        Result = oksmaller && oklarger;
        return Result;
      };
      if (((pas.System.Pos(larger,s0a) !== 0) && oklarger) || ((pas.System.Pos(smaller,s0a) !== 0) && oksmaller)) {
        Result = true;
        return Result;
      };
      s0 = 1;
      s1 = 1;
      done = (s0a === "") || (s1a === "");
      matching = true;
      while (!done && matching) {
        var $tmp = rtl.rcCharAt(s0a,s0 - i - 1);
        if ($tmp === qmark) {
          matching = s1 <= s1a.length;
          if (matching) {
            s0 += 1;
            s1 += 1;
          };
        } else if ($tmp === negation) {
          negflag = true;
          s0 += 1;
        } else if ($tmp === '"') {
          s0 += 1;
        } else if ($tmp === asterix) {
          do {
            s0 += 1;
          } while (!(((s0 - i) > s0a.length) || (rtl.rcCharAt(s0a,s0 - i - 1) !== asterix)));
          len = rtl.rc(s1a.length - s1,-2147483648,2147483647);
          s1 += len;
          matching = this.Matches(pas.System.Copy(s0a,s0,s0a.length),pas.System.Copy(s1a,s1,s1a.length));
          while ((len >= 0) && !matching) {
            s1 -= 1;
            len -= 1;
            matching = this.Matches(pas.System.Copy(s0a,s0,s0a.length),pas.System.Copy(s1a,s1,s1a.length));
          };
          if (matching) {
            s0 = rtl.rc(s0a.length + 1,-2147483648,2147483647);
            s1 = rtl.rc(s1a.length + 1,-2147483648,2147483647);
          };
        } else {
          if ((s0 <= s0a.length) && (s1 <= s1a.length)) {
            matching = rtl.rcCharAt(s0a,s0 - i - 1) === rtl.rcCharAt(s1a,s1 - i - 1)}
           else matching = false;
          if (matching) {
            s0 += 1;
            s1 += 1;
          };
        };
        done = (s0 > s0a.length) && (s1 > s1a.length);
      };
      if (negflag) {
        Result = !matching}
       else Result = matching;
      return Result;
    };
    this.StripThousandSep = function (ps) {
      var Result = "";
      var i = 0;
      var s = "";
      Result = "";
      s = ps;
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        if (s.charAt(i - 1) === pas.SysUtils.FormatSettings.DecimalSeparator) {
          Result = Result + "."}
         else if (s.charAt(i - 1) !== pas.SysUtils.FormatSettings.ThousandSeparator) Result = Result + s.charAt(i - 1);
      };
      return Result;
    };
    this.ClosingParenthesis = function (s1) {
      var Result = 0;
      var i = 0;
      var j = 0;
      var k = 0;
      var r = 0;
      r = 0;
      j = 0;
      k = 0;
      i = 1;
      while (i <= s1.length) {
        if (s1.charAt(i - 1) === ")") k += 1;
        if (s1.charAt(i - 1) === "(") j += 1;
        if ((s1.charAt(i - 1) === ")") && (j === k)) {
          r = i;
          break;
        };
        i += 1;
      };
      Result = r;
      return Result;
    };
    this.GetMarkupIndex = function (Markup) {
      var Result = 0;
      Result = this.IndexOfTextInArray(Markup,$impl.HTMLSpecialChar);
      return Result;
    };
    this.GetSpecialChar = function (Value) {
      var Result = "";
      Result = $impl.HTMLEncodedChar[Value - 1];
      return Result;
    };
    this.IndexOfTextInArray = function (AText, AValues) {
      var Result = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = rtl.length(AValues) - 1; $l <= $end; $l++) {
        I = $l;
        if (pas.SysUtils.SameText(AText,AValues[I])) {
          if ((pas.System.Pos("cute",AText) > 0) || (pas.System.Pos("grave",AText) > 0) || (pas.System.Pos("uml",AText) > 0) || (pas.System.Pos("circ",AText) > 0) || (pas.System.Pos("tilde",AText) > 0) || (pas.System.Pos("ring",AText) > 0) || (pas.System.Pos("cedil",AText) > 0)) {
            if (AText === AValues[I]) {
              Result = I;
              break;
            };
          } else {
            Result = I;
            break;
          };
        };
      };
      return Result;
    };
    this.GetParentForm = function (AControl) {
      var Result = null;
      var c = null;
      Result = null;
      c = AControl;
      if (!(c != null)) return Result;
      if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(c.FParent)) {
        Result = rtl.as(c.FParent,pas["WEBLib.Forms"].TCustomForm)}
       else Result = this.GetParentForm(c.FParent);
      return Result;
    };
    this.GetOwnerForm = function (AComponent) {
      var Result = null;
      var c = null;
      Result = null;
      c = AComponent;
      if (!(c != null)) return Result;
      if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(c.FOwner)) {
        Result = rtl.as(c.FOwner,pas["WEBLib.Forms"].TCustomForm)}
       else Result = this.GetOwnerForm(c.FOwner);
      return Result;
    };
    this.Message = function (AMessage) {
      var Result = 0;
      Result = $mod.TTMSFNCUtils.Message$1(AMessage,pas["WEBLib.Dialogs"].TMsgDlgType.mtInformation,rtl.createSet(pas["WEBLib.Dialogs"].TMsgDlgBtn.mbOK),0);
      return Result;
    };
    this.Message$1 = function (AMessage, ADialogType, AButtons, AHelpContext) {
      var Result = 0;
      Result = 0;
      if (((pas["WEBLib.Dialogs"].TMsgDlgBtn.mbOK in AButtons) && (pas["WEBLib.Dialogs"].TMsgDlgBtn.mbCancel in AButtons)) || ((pas["WEBLib.Dialogs"].TMsgDlgBtn.mbYes in AButtons) && (pas["WEBLib.Dialogs"].TMsgDlgBtn.mbNo in AButtons))) {
        if (window.confirm(AMessage))
        {
          return 1
        }
        else
        {
          return 2
        };
      } else {
        window.alert(AMessage);
        return 1;
      };
      return Result;
    };
    this.SelectFile = function (AFileName, ADefaultFolder, AFilter, ACallBack) {
      var Result = false;
      Result = true;
      if (ACallBack != null) ACallBack(AFileName.get(),Result);
      return Result;
    };
    this.SaveFile = function (AFileName, AFilter, ACallBack) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.EscapeString = function (AValue) {
      var $Self = this;
      var Result = "";
      var res = "";
      var ch = "\x00";
      var i = 0;
      function EscapeSpecialChar(ch, s) {
        var Result = false;
        var i = 0;
        Result = false;
        s.set("");
        for (i = 1; i <= 7; i++) {
          if (ch === $impl.JSONSpecialChar[i - 1]) {
            s.set($impl.JSONEncodedSpecialChar[i - 1]);
            Result = true;
            break;
          };
        };
        return Result;
      };
      Result = "";
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        i = $l;
        ch = this.CharInStr(AValue,i);
        if (ch > "") {
          Result = Result + "\\u" + pas.SysUtils.IntToHex(ch.charCodeAt(),4)}
         else {
          res = "";
          if (EscapeSpecialChar(ch,{get: function () {
              return res;
            }, set: function (v) {
              res = v;
            }})) {
            Result = Result + res}
           else Result = Result + ch;
        };
      };
      return Result;
    };
    this.UnescapeString = function (AValue) {
      var Result = "";
      var i = 0;
      var j = 0;
      var c = 0;
      var o = 0;
      var s = "";
      var x = 0;
      s = rtl.strSetLength(s,AValue.length);
      o = 0;
      i = 1;
      j = 1;
      while (i <= AValue.length) {
        if (AValue.charAt(i - o - 1) === "\\") {
          if (i < AValue.length) {
            if (AValue.charAt((i + 1) - o - 1) === "\\") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"\\");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === "/") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"/");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === "b") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"\b");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === "f") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"\f");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === "n") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"\n");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === "r") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"\r");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === "t") {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,"\t");
              i += 2;
            } else if (AValue.charAt((i + 1) - o - 1) === '"') {
              x = j - o;
              s = rtl.setCharAt(s,x - 1,'"');
              i += 2;
            } else if ((AValue.charAt((i + 1) - o - 1) === "u") && ((i + 1 + 4) <= AValue.length) && pas.SysUtils.TryStrToInt("$" + pas.System.Copy(AValue,i + 2,4),{get: function () {
                return c;
              }, set: function (v) {
                c = v;
              }})) {
              i += 6;
              x = j - o;
              s = rtl.setCharAt(s,x - 1,String.fromCharCode(c));
            } else throw pas.SysUtils.Exception.$create("CreateFmt",["Invalid code at position %s",pas.System.VarRecs(18,pas.SysUtils.IntToStr(i))]);
          } else throw pas.SysUtils.Exception.$create("Create$1",["Unexpected end of string"]);
        } else {
          x = j - o;
          s = rtl.setCharAt(s,x - 1,AValue.charAt(i - o - 1));
          i += 1;
        };
        j += 1;
      };
      s = rtl.strSetLength(s,j - 1);
      Result = s;
      return Result;
    };
    this.DownloadImage = function (AURL) {
      var Result = null;
      Result = null;
      return Result;
    };
    var CSVSeparators = [",",";","#","\t","|","@","*","-","+","&"];
    this.GetBestDelimiter = function (ALine1, Aline2, ACheckDecimalSeperator) {
      var Result = "\x00";
      var I = 0;
      var parts1 = 0;
      var parts2 = 0;
      var maxParts = 0;
      var maxBackup = 0;
      var Del = "\x00";
      var DelBackup = "\x00";
      var SplitChar = "\x00";
      var s = null;
      Del = "\x00";
      DelBackup = ",";
      parts2 = -1;
      maxParts = 0;
      maxBackup = 0;
      for (I = 1; I <= 10; I++) {
        SplitChar = CSVSeparators[I - 1];
        s = pas.Classes.TStringList.$create("Create$1");
        try {
          $mod.TTMSFNCUtils.Split(SplitChar,ALine1,s,false);
          parts1 = s.GetCount();
          if (Aline2 !== "") {
            $mod.TTMSFNCUtils.Split(SplitChar,Aline2,s,false);
            parts2 = s.GetCount();
          };
          if (!ACheckDecimalSeperator || (SplitChar !== pas.SysUtils.FormatSettings.DecimalSeparator)) {
            if ((parts2 > 0) && (parts1 === parts2)) {
              if (parts1 > maxParts) {
                Del = SplitChar;
                maxParts = parts1;
              };
            } else {
              if (parts1 > maxBackup) {
                DelBackup = SplitChar;
                maxBackup = parts1;
              };
            };
          };
        } finally {
          s = rtl.freeLoc(s);
        };
      };
      if (Del !== "\x00") {
        Result = Del}
       else Result = DelBackup;
      return Result;
    };
  });
  this.TTMSFNCClipBoardFormat = {"0": "cfText", cfText: 0, "1": "cfRTF", cfRTF: 1, "2": "cfHTML", cfHTML: 2, "3": "cfBitmap", cfBitmap: 3, "4": "cfBitmapWin", cfBitmapWin: 4, "5": "cfStream", cfStream: 5, "6": "cfRichTextStream", cfRichTextStream: 6};
  this.$rtti.$Enum("TTMSFNCClipBoardFormat",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TTMSFNCClipBoardFormat});
  rtl.createClass(this,"TTMSFNCClipBoard",pas.System.TObject,function () {
    this.FClipboardData = "";
    this.HasFormat = function (AFormat) {
      rtl.rc(AFormat,0,6);
      var Result = false;
      Result = true;
      return Result;
    };
    this.HasContent = function () {
      var Result = false;
      Result = this.HasFormat($mod.TTMSFNCClipBoardFormat.cfText) || this.HasFormat($mod.TTMSFNCClipBoardFormat.cfRTF) || this.HasFormat($mod.TTMSFNCClipBoardFormat.cfBitmap) || this.HasFormat($mod.TTMSFNCClipBoardFormat.cfBitmapWin) || this.HasFormat($mod.TTMSFNCClipBoardFormat.cfRichTextStream) || this.HasFormat($mod.TTMSFNCClipBoardFormat.cfStream);
      return Result;
    };
    this.Clear = function () {
    };
    this.SetText = function (AText) {
      $mod.TTMSFNCClipBoard.FClipboardData = AText;
      window.navigator.clipboard.writeText(AText);
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FClipboardData;
      return Result;
    };
    this.SetStream = function (AStream) {
      throw pas.SysUtils.Exception.$create("Create$1",["SetStream not supported"]);
    };
    this.GetStream = function () {
      var Result = null;
      Result = null;
      throw pas.SysUtils.Exception.$create("Create$1",["GetStream not supported"]);
      return Result;
    };
    this.SetBitmap = function (ABitmap) {
      throw pas.SysUtils.Exception.$create("Create$1",["SetBitmap not supported"]);
    };
    this.GetBitmap = function () {
      var Result = null;
      Result = null;
      throw pas.SysUtils.Exception.$create("Create$1",["GetBitmap not supported"]);
      return Result;
    };
    this.SetRichTextStream = function (AStream) {
      throw pas.SysUtils.Exception.$create("Create$1",["SetRichTextStream not supported"]);
    };
    this.GetRichTextStream = function () {
      var Result = null;
      Result = null;
      throw pas.SysUtils.Exception.$create("Create$1",["GetRichTextStream not supported"]);
      return Result;
    };
    this.SetRTF = function (ARTF) {
      throw pas.SysUtils.Exception.$create("Create$1",["SetRTF not supported"]);
    };
    this.GetRTF = function () {
      var Result = "";
      Result = "";
      throw pas.SysUtils.Exception.$create("Create$1",["GetRTF not supported"]);
      return Result;
    };
    this.SetHTML = function (AHTML) {
      throw pas.SysUtils.Exception.$create("Create$1",["SetHTML not supported"]);
    };
    this.GetHTML = function () {
      var Result = "";
      Result = "";
      throw pas.SysUtils.Exception.$create("Create$1",["GetHTML not supported"]);
      return Result;
    };
  });
  this.Hiword = function (L) {
    var Result = 0;
    Result = rtl.lw(L >>> 16);
    return Result;
  };
  this.LoWord = function (L) {
    var Result = 0;
    Result = L & 0xFFFF;
    return Result;
  };
  this.MakeWord = function (b1, b2) {
    var Result = 0;
    Result = b1 | (b2 << 8);
    return Result;
  };
  this.MakeLong = function (i1, i2) {
    var Result = 0;
    Result = i1 | (i2 << 16);
    return Result;
  };
  this.CreateUploadFile = function (AName, AData) {
    var Result = $mod.TTMSFNCUtilsFile.$new();
    Result.Data = AData;
    Result.Name = AName;
    return Result;
  };
  this.ExtractFileNameEx = function (AFile) {
    var Result = "";
    Result = AFile.Name;
    return Result;
  };
  this.GetMimeTypeEx = function (AFile) {
    var Result = "";
    Result = $mod.TTMSFNCUtils.GetMimeType(AFile.Name);
    return Result;
  };
  this.CF_FNCSTREAM = 0;
  this.CF_FNCRICHTEXTSTREAM = 0;
  this.CF_FNCRTF = 0;
  this.CF_FNCBITMAP = 0;
  this.CF_FNCHTML = 0;
  this.FNCFormatSettings = pas.SysUtils.TFormatSettings.$new();
  $mod.$implcode = function () {
    $impl.HTMLNumSpecialChar = 92;
    $impl.JSONNumSpecialChar = 7;
    $mod.$rtti.$StaticArray("HTMLEncodedChar$a",{dims: [92], eltype: rtl.string});
    $impl.HTMLEncodedChar = ["&","<",">",'"'," ","é","è","ë","ê","ó","ò","ö","ô","í","ì","ï","î","ú","ù","ü","û","á","à","ä","â","É","È","Ë","Ê","Ó","Ò","Ö","Ô","Í","Ì","Ï","Î","Ú","Ù","Ü","Û","Á","À","Ä","Â","ç","Ç","ø","Ø","å","Å","©","®","€","«","»","ã","Ã","õ","Õ","™","§","¶","ß","£","$","§","‰","¶","'","¥","¤","¢","±","¡","°","ý","Ý","¼","½","¾","Æ","æ","Ñ","ñ","Ð","´","µ","¶","·","²","³"];
    $mod.$rtti.$StaticArray("HTMLSpecialChar$a",{dims: [92], eltype: rtl.string});
    $impl.HTMLSpecialChar = ["&amp;","&lt;","&gt;","&quot;","&nbsp;","&eacute;","&egrave;","&euml;","&ecirc;","&oacute;","&ograve;","&ouml;","&ocirc;","&iacute;","&igrave;","&iuml;","&icirc;","&uacute;","&ugrave;","&uuml;","&ucirc;","&aacute;","&agrave;","&auml;","&acirc;","&Eacute;","&Egrave;","&Euml;","&Ecirc;","&Oacute;","&Ograve;","&Ouml;","&Ocirc;","&Iacute;","&Igrave;","&Iuml;","&Icirc;","&Uacute;","&Ugrave;","&Uuml;","&Ucirc;","&Aacute;","&Agrave;","&Auml;","&Acirc;","&ccedil;","&Ccedil;","&oslash;","&Oslash;","&aring;","&Aring;","&copy;","&reg;","&euro;","&laquo;","&raquo;","&atilde;","&Atilde;","&otilde;","&Otilde","&trade;","&sect;","&para;","&szlig;","&pound;","&#36;","&sect;","&permil;","&para;","&#39;","&yen;","&curren;","&cent;","&plusmn;","&iexcl;","&deg;","&#x00FD;","&#221;","&frac14;","&frac12;","&frac34;","&AElig;","&aelig;","&Ntilde;","&ntilde;","&ETH;","&acute;","&micro;","&para;","&middot","&sup2;","&sup3;"];
    $mod.$rtti.$StaticArray("JSONSpecialChar$a",{dims: [7], eltype: rtl.char});
    $impl.JSONSpecialChar = ['"',"\\","\b","\f","\n","\r","\t"];
    $mod.$rtti.$StaticArray("JSONEncodedSpecialChar$a",{dims: [7], eltype: rtl.string});
    $impl.JSONEncodedSpecialChar = ["\\u0022","\\u005C","\\u0008","\\u000C","\\u000A","\\u000D","\\u0009"];
    $impl.FMimeTypes = null;
    $impl.RegisterMimeTypes = function () {
      function AddType(AExt, AMimeType) {
        $impl.FMimeTypes.Add(AExt + $impl.FMimeTypes.GetNameValueSeparator() + AMimeType);
      };
      AddType("ez","application/andrew-inset");
      AddType("aw","application/applixware");
      AddType("atom","application/atom+xml");
      AddType("atomcat","application/atomcat+xml");
      AddType("atomsvc","application/atomsvc+xml");
      AddType("bson","application/bson");
      AddType("ccxml","application/ccxml+xml");
      AddType("cdmia","application/cdmi-capability");
      AddType("cdmic","application/cdmi-container");
      AddType("cdmid","application/cdmi-domain");
      AddType("cdmio","application/cdmi-object");
      AddType("cdmiq","application/cdmi-queue");
      AddType("cu","application/cu-seeme");
      AddType("davmount","application/davmount+xml");
      AddType("dbk","application/docbook+xml");
      AddType("dssc","application/dssc+der");
      AddType("xdssc","application/dssc+xml");
      AddType("ecma","application/ecmascript");
      AddType("emma","application/emma+xml");
      AddType("epub","application/epub+zip");
      AddType("exi","application/exi");
      AddType("pfr","application/font-tdpfr");
      AddType("gml","application/gml+xml");
      AddType("gpx","application/gpx+xml");
      AddType("gxf","application/gxf");
      AddType("stk","application/hyperstudio");
      AddType("ink","application/inkml+xml");
      AddType("inkml","application/inkml+xml");
      AddType("ipfix","application/ipfix");
      AddType("jar","application/java-archive");
      AddType("ser","application/java-serialized-object");
      AddType("class","application/java-vm");
      AddType("js","application/javascript");
      AddType("json","application/json");
      AddType("jsonml","application/jsonml+json");
      AddType("lostxml","application/lost+xml");
      AddType("hqx","application/mac-binhex40");
      AddType("cpt","application/mac-compactpro");
      AddType("mads","application/mads+xml");
      AddType("mrc","application/marc");
      AddType("mrcx","application/marcxml+xml");
      AddType("ma","application/mathematica");
      AddType("nb","application/mathematica");
      AddType("mb","application/mathematica");
      AddType("mathml","application/mathml+xml");
      AddType("mbox","application/mbox");
      AddType("mscml","application/mediaservercontrol+xml");
      AddType("metalink","application/metalink+xml");
      AddType("meta4","application/metalink4+xml");
      AddType("mets","application/mets+xml");
      AddType("mods","application/mods+xml");
      AddType("m21","application/mp21");
      AddType("mp21","application/mp21");
      AddType("mp4s","application/mp4");
      AddType("doc","application/msword");
      AddType("dot","application/msword");
      AddType("mxf","application/mxf");
      AddType("bin","application/octet-stream");
      AddType("bpk","application/octet-stream");
      AddType("class","application/octet-stream");
      AddType("deploy","application/octet-stream");
      AddType("dist","application/octet-stream");
      AddType("distz","application/octet-stream");
      AddType("dmg","application/octet-stream");
      AddType("dms","application/octet-stream");
      AddType("dump","application/octet-stream");
      AddType("elc","application/octet-stream");
      AddType("iso","application/octet-stream");
      AddType("lha","application/octet-stream");
      AddType("lrf","application/octet-stream");
      AddType("lzh","application/octet-stream");
      AddType("mar","application/octet-stream");
      AddType("pkg","application/octet-stream");
      AddType("so","application/octet-stream");
      AddType("oda","application/oda");
      AddType("opf","application/oebps-package+xml");
      AddType("ogx","application/ogg");
      AddType("omdoc","application/omdoc+xml");
      AddType("onetoc","application/onenote");
      AddType("onetoc2","application/onenote");
      AddType("onetmp","application/onenote");
      AddType("onepkg","application/onenote");
      AddType("oxps","application/oxps");
      AddType("xer","application/patch-ops-error+xml");
      AddType("pdf","application/pdf");
      AddType("pgp","application/pgp-encrypted");
      AddType("asc","application/pgp-signature");
      AddType("sig","application/pgp-signature");
      AddType("prf","application/pics-rules");
      AddType("p10","application/pkcs10");
      AddType("p7m","application/pkcs7-mime");
      AddType("p7c","application/pkcs7-mime");
      AddType("p7s","application/pkcs7-signature");
      AddType("p8","application/pkcs8");
      AddType("ac","application/pkix-attr-cert");
      AddType("cer","application/pkix-cert");
      AddType("crl","application/pkix-crl");
      AddType("pkipath","application/pkix-pkipath");
      AddType("pki","application/pkixcmp");
      AddType("pls","application/pls+xml");
      AddType("ai","application/postscript");
      AddType("eps","application/postscript");
      AddType("ps","application/postscript");
      AddType("cww","application/prs.cww");
      AddType("pskcxml","application/pskc+xml");
      AddType("rdf","application/rdf+xml");
      AddType("rif","application/reginfo+xml");
      AddType("rnc","application/relax-ng-compact-syntax");
      AddType("rl","application/resource-lists+xml");
      AddType("rld","application/resource-lists-diff+xml");
      AddType("rs","application/rls-services+xml");
      AddType("gbr","application/rpki-ghostbusters");
      AddType("mft","application/rpki-manifest");
      AddType("roa","application/rpki-roa");
      AddType("rsd","application/rsd+xml");
      AddType("rss","application/rss+xml");
      AddType("rtf","application/rtf");
      AddType("sbml","application/sbml+xml");
      AddType("scq","application/scvp-cv-request");
      AddType("scs","application/scvp-cv-response");
      AddType("spq","application/scvp-vp-request");
      AddType("spp","application/scvp-vp-response");
      AddType("sdp","application/sdp");
      AddType("setpay","application/set-payment-initiation");
      AddType("setreg","application/set-registration-initiation");
      AddType("shf","application/shf+xml");
      AddType("smi","application/smil+xml");
      AddType("smil","application/smil+xml");
      AddType("soap","application/soap+xml");
      AddType("rq","application/sparql-query");
      AddType("srx","application/sparql-results+xml");
      AddType("gram","application/srgs");
      AddType("grxml","application/srgs+xml");
      AddType("sru","application/sru+xml");
      AddType("ssdl","application/ssdl+xml");
      AddType("ssml","application/ssml+xml");
      AddType("tei","application/tei+xml");
      AddType("teicorpus","application/tei+xml");
      AddType("tfi","application/thraud+xml");
      AddType("tsd","application/timestamped-data");
      AddType("plb","application/vnd.3gpp.pic-bw-large");
      AddType("psb","application/vnd.3gpp.pic-bw-small");
      AddType("pvb","application/vnd.3gpp.pic-bw-var");
      AddType("tcap","application/vnd.3gpp2.tcap");
      AddType("pwn","application/vnd.3m.post-it-notes");
      AddType("aso","application/vnd.accpac.simply.aso");
      AddType("imp","application/vnd.accpac.simply.imp");
      AddType("acu","application/vnd.acucobol");
      AddType("atc","application/vnd.acucorp");
      AddType("acutc","application/vnd.acucorp");
      AddType("air","application/vnd.adobe.air-application-installer-package+zip");
      AddType("fcdt","application/vnd.adobe.formscentral.fcdt");
      AddType("fxp","application/vnd.adobe.fxp");
      AddType("fxpl","application/vnd.adobe.fxp");
      AddType("xdp","application/vnd.adobe.xdp+xml");
      AddType("xfdf","application/vnd.adobe.xfdf");
      AddType("ahead","application/vnd.ahead.space");
      AddType("azf","application/vnd.airzip.filesecure.azf");
      AddType("azs","application/vnd.airzip.filesecure.azs");
      AddType("azw","application/vnd.amazon.ebook");
      AddType("acc","application/vnd.americandynamics.acc");
      AddType("ami","application/vnd.amiga.ami");
      AddType("apk","application/vnd.android.package-archive");
      AddType("cii","application/vnd.anser-web-certificate-issue-initiation");
      AddType("fti","application/vnd.anser-web-funds-transfer-initiation");
      AddType("atx","application/vnd.antix.game-component");
      AddType("mpkg","application/vnd.apple.installer+xml");
      AddType("m3u8","application/vnd.apple.mpegurl");
      AddType("swi","application/vnd.aristanetworks.swi");
      AddType("iota","application/vnd.astraea-software.iota");
      AddType("aep","application/vnd.audiograph");
      AddType("mpm","application/vnd.blueice.multipass");
      AddType("bmi","application/vnd.bmi");
      AddType("rep","application/vnd.businessobjects");
      AddType("cdxml","application/vnd.chemdraw+xml");
      AddType("mmd","application/vnd.chipnuts.karaoke-mmd");
      AddType("cdy","application/vnd.cinderella");
      AddType("cla","application/vnd.claymore");
      AddType("rp9","application/vnd.cloanto.rp9");
      AddType("c4g","application/vnd.clonk.c4group");
      AddType("c4d","application/vnd.clonk.c4group");
      AddType("c4f","application/vnd.clonk.c4group");
      AddType("c4p","application/vnd.clonk.c4group");
      AddType("c4u","application/vnd.clonk.c4group");
      AddType("c11amc","application/vnd.cluetrust.cartomobile-config");
      AddType("c11amz","application/vnd.cluetrust.cartomobile-config-pkg");
      AddType("csp","application/vnd.commonspace");
      AddType("cdbcmsg","application/vnd.contact.cmsg");
      AddType("cmc","application/vnd.cosmocaller");
      AddType("clkx","application/vnd.crick.clicker");
      AddType("clkk","application/vnd.crick.clicker.keyboard");
      AddType("clkp","application/vnd.crick.clicker.palette");
      AddType("clkt","application/vnd.crick.clicker.template");
      AddType("clkw","application/vnd.crick.clicker.wordbank");
      AddType("wbs","application/vnd.criticaltools.wbs+xml");
      AddType("pml","application/vnd.ctc-posml");
      AddType("ppd","application/vnd.cups-ppd");
      AddType("car","application/vnd.curl.car");
      AddType("pcurl","application/vnd.curl.pcurl");
      AddType("dart","application/vnd.dart");
      AddType("rdz","application/vnd.data-vision.rdz");
      AddType("uvf","application/vnd.dece.data");
      AddType("uvvf","application/vnd.dece.data");
      AddType("uvd","application/vnd.dece.data");
      AddType("uvvd","application/vnd.dece.data");
      AddType("uvt","application/vnd.dece.ttml+xml");
      AddType("uvvt","application/vnd.dece.ttml+xml");
      AddType("uvx","application/vnd.dece.unspecified");
      AddType("uvvx","application/vnd.dece.unspecified");
      AddType("uvz","application/vnd.dece.zip");
      AddType("uvvz","application/vnd.dece.zip");
      AddType("fe_launch","application/vnd.denovo.fcselayout-link");
      AddType("dna","application/vnd.dna");
      AddType("mlp","application/vnd.dolby.mlp");
      AddType("dpg","application/vnd.dpgraph");
      AddType("dfac","application/vnd.dreamfactory");
      AddType("kpxx","application/vnd.ds-keypoint");
      AddType("ait","application/vnd.dvb.ait");
      AddType("svc","application/vnd.dvb.service");
      AddType("geo","application/vnd.dynageo");
      AddType("mag","application/vnd.ecowin.chart");
      AddType("nml","application/vnd.enliven");
      AddType("esf","application/vnd.epson.esf");
      AddType("msf","application/vnd.epson.msf");
      AddType("qam","application/vnd.epson.quickanime");
      AddType("slt","application/vnd.epson.salt");
      AddType("ssf","application/vnd.epson.ssf");
      AddType("es3","application/vnd.eszigno3+xml");
      AddType("et3","application/vnd.eszigno3+xml");
      AddType("ez2","application/vnd.ezpix-album");
      AddType("ez3","application/vnd.ezpix-package");
      AddType("fdf","application/vnd.fdf");
      AddType("mseed","application/vnd.fdsn.mseed");
      AddType("seed","application/vnd.fdsn.seed");
      AddType("dataless","application/vnd.fdsn.seed");
      AddType("json","application/vnd.firedac.json");
      AddType("xml","application/vnd.firedac.xml");
      AddType("bin","application/vnd.firedac.bin");
      AddType("gph","application/vnd.flographit");
      AddType("ftc","application/vnd.fluxtime.clip");
      AddType("fm","application/vnd.framemaker");
      AddType("frame","application/vnd.framemaker");
      AddType("maker","application/vnd.framemaker");
      AddType("book","application/vnd.framemaker");
      AddType("fnc","application/vnd.frogans.fnc");
      AddType("ltf","application/vnd.frogans.ltf");
      AddType("fsc","application/vnd.fsc.weblaunch");
      AddType("oas","application/vnd.fujitsu.oasys");
      AddType("oa2","application/vnd.fujitsu.oasys2");
      AddType("oa3","application/vnd.fujitsu.oasys3");
      AddType("fg5","application/vnd.fujitsu.oasysgp");
      AddType("bh2","application/vnd.fujitsu.oasysprs");
      AddType("ddd","application/vnd.fujixerox.ddd");
      AddType("xdw","application/vnd.fujixerox.docuworks");
      AddType("xbd","application/vnd.fujixerox.docuworks.binder");
      AddType("fzs","application/vnd.fuzzysheet");
      AddType("txd","application/vnd.genomatix.tuxedo");
      AddType("ggb","application/vnd.geogebra.file");
      AddType("ggt","application/vnd.geogebra.tool");
      AddType("gex","application/vnd.geometry-explorer");
      AddType("gre","application/vnd.geometry-explorer");
      AddType("gxt","application/vnd.geonext");
      AddType("g2w","application/vnd.geoplan");
      AddType("g3w","application/vnd.geospace");
      AddType("gmx","application/vnd.gmx");
      AddType("kml","application/vnd.google-earth.kml+xml");
      AddType("kmz","application/vnd.google-earth.kmz");
      AddType("gqf","application/vnd.grafeq");
      AddType("gqs","application/vnd.grafeq");
      AddType("gac","application/vnd.groove-account");
      AddType("ghf","application/vnd.groove-help");
      AddType("gim","application/vnd.groove-identity-message");
      AddType("grv","application/vnd.groove-injector");
      AddType("gtm","application/vnd.groove-tool-message");
      AddType("tpl","application/vnd.groove-tool-template");
      AddType("vcg","application/vnd.groove-vcard");
      AddType("hal","application/vnd.hal+xml");
      AddType("zmm","application/vnd.handheld-entertainment+xml");
      AddType("hbci","application/vnd.hbci");
      AddType("les","application/vnd.hhe.lesson-player");
      AddType("hpgl","application/vnd.hp-hpgl");
      AddType("hpid","application/vnd.hp-hpid");
      AddType("hps","application/vnd.hp-hps");
      AddType("jlt","application/vnd.hp-jlyt");
      AddType("pcl","application/vnd.hp-pcl");
      AddType("pclxl","application/vnd.hp-pclxl");
      AddType("sfd-hdstx","application/vnd.hydrostatix.sof-data");
      AddType("mpy","application/vnd.ibm.minipay");
      AddType("afp","application/vnd.ibm.modcap");
      AddType("listafp","application/vnd.ibm.modcap");
      AddType("list3820","application/vnd.ibm.modcap");
      AddType("irm","application/vnd.ibm.rights-management");
      AddType("sc","application/vnd.ibm.secure-container");
      AddType("icc","application/vnd.iccprofile");
      AddType("icm","application/vnd.iccprofile");
      AddType("igl","application/vnd.igloader");
      AddType("ivp","application/vnd.immervision-ivp");
      AddType("ivu","application/vnd.immervision-ivu");
      AddType("igm","application/vnd.insors.igm");
      AddType("xpw","application/vnd.intercon.formnet");
      AddType("xpx","application/vnd.intercon.formnet");
      AddType("i2g","application/vnd.intergeo");
      AddType("qbo","application/vnd.intu.qbo");
      AddType("qfx","application/vnd.intu.qfx");
      AddType("rcprofile","application/vnd.ipunplugged.rcprofile");
      AddType("irp","application/vnd.irepository.package+xml");
      AddType("xpr","application/vnd.is-xpr");
      AddType("fcs","application/vnd.isac.fcs");
      AddType("jam","application/vnd.jam");
      AddType("rms","application/vnd.jcp.javame.midlet-rms");
      AddType("jisp","application/vnd.jisp");
      AddType("joda","application/vnd.joost.joda-archive");
      AddType("ktz","application/vnd.kahootz");
      AddType("ktr","application/vnd.kahootz");
      AddType("karbon","application/vnd.kde.karbon");
      AddType("chrt","application/vnd.kde.kchart");
      AddType("kfo","application/vnd.kde.kformula");
      AddType("flw","application/vnd.kde.kivio");
      AddType("kon","application/vnd.kde.kontour");
      AddType("kpr","application/vnd.kde.kpresenter");
      AddType("kpt","application/vnd.kde.kpresenter");
      AddType("ksp","application/vnd.kde.kspread");
      AddType("kwd","application/vnd.kde.kword");
      AddType("kwt","application/vnd.kde.kword");
      AddType("htke","application/vnd.kenameaapp");
      AddType("kia","application/vnd.kidspiration");
      AddType("kne","application/vnd.kinar");
      AddType("knp","application/vnd.kinar");
      AddType("skp","application/vnd.koan");
      AddType("skd","application/vnd.koan");
      AddType("skt","application/vnd.koan");
      AddType("skm","application/vnd.koan");
      AddType("sse","application/vnd.kodak-descriptor");
      AddType("lasxml","application/vnd.las.las+xml");
      AddType("lbd","application/vnd.llamagraphics.life-balance.desktop");
      AddType("lbe","application/vnd.llamagraphics.life-balance.exchange+xml");
      AddType("123","application/vnd.lotus-1-2-3");
      AddType("apr","application/vnd.lotus-approach");
      AddType("pre","application/vnd.lotus-freelance");
      AddType("nsf","application/vnd.lotus-notes");
      AddType("org","application/vnd.lotus-organizer");
      AddType("scm","application/vnd.lotus-screencam");
      AddType("lwp","application/vnd.lotus-wordpro");
      AddType("portpkg","application/vnd.macports.portpkg");
      AddType("mcd","application/vnd.mcd");
      AddType("mc1","application/vnd.medcalcdata");
      AddType("cdkey","application/vnd.mediastation.cdkey");
      AddType("mwf","application/vnd.mfer");
      AddType("mfm","application/vnd.mfmp");
      AddType("flo","application/vnd.micrografx.flo");
      AddType("igx","application/vnd.micrografx.igx");
      AddType("mif","application/vnd.mif");
      AddType("daf","application/vnd.mobius.daf");
      AddType("dis","application/vnd.mobius.dis");
      AddType("mbk","application/vnd.mobius.mbk");
      AddType("mqy","application/vnd.mobius.mqy");
      AddType("msl","application/vnd.mobius.msl");
      AddType("plc","application/vnd.mobius.plc");
      AddType("txf","application/vnd.mobius.txf");
      AddType("mpn","application/vnd.mophun.application");
      AddType("mpc","application/vnd.mophun.certificate");
      AddType("xul","application/vnd.mozilla.xul+xml");
      AddType("cil","application/vnd.ms-artgalry");
      AddType("cab","application/vnd.ms-cab-compressed");
      AddType("xls","application/vnd.ms-excel");
      AddType("xlm","application/vnd.ms-excel");
      AddType("xla","application/vnd.ms-excel");
      AddType("xlc","application/vnd.ms-excel");
      AddType("xlt","application/vnd.ms-excel");
      AddType("xlw","application/vnd.ms-excel");
      AddType("xlam","application/vnd.ms-excel.addin.macroenabled.12");
      AddType("xlsb","application/vnd.ms-excel.sheet.binary.macroenabled.12");
      AddType("xlsm","application/vnd.ms-excel.sheet.macroenabled.12");
      AddType("xltm","application/vnd.ms-excel.template.macroenabled.12");
      AddType("eot","application/vnd.ms-fontobject");
      AddType("chm","application/vnd.ms-htmlhelp");
      AddType("ims","application/vnd.ms-ims");
      AddType("lrm","application/vnd.ms-lrm");
      AddType("thmx","application/vnd.ms-officetheme");
      AddType("cat","application/vnd.ms-pki.seccat");
      AddType("stl","application/vnd.ms-pki.stl");
      AddType("ppt","application/vnd.ms-powerpoint");
      AddType("pps","application/vnd.ms-powerpoint");
      AddType("pot","application/vnd.ms-powerpoint");
      AddType("ppam","application/vnd.ms-powerpoint.addin.macroenabled.12");
      AddType("pptm","application/vnd.ms-powerpoint.presentation.macroenabled.12");
      AddType("sldm","application/vnd.ms-powerpoint.slide.macroenabled.12");
      AddType("ppsm","application/vnd.ms-powerpoint.slideshow.macroenabled.12");
      AddType("potm","application/vnd.ms-powerpoint.template.macroenabled.12");
      AddType("mpp","application/vnd.ms-project");
      AddType("mpt","application/vnd.ms-project");
      AddType("docm","application/vnd.ms-word.document.macroenabled.12");
      AddType("dotm","application/vnd.ms-word.template.macroenabled.12");
      AddType("wps","application/vnd.ms-works");
      AddType("wks","application/vnd.ms-works");
      AddType("wcm","application/vnd.ms-works");
      AddType("wdb","application/vnd.ms-works");
      AddType("wpl","application/vnd.ms-wpl");
      AddType("xps","application/vnd.ms-xpsdocument");
      AddType("mseq","application/vnd.mseq");
      AddType("mus","application/vnd.musician");
      AddType("msty","application/vnd.muvee.style");
      AddType("taglet","application/vnd.mynfc");
      AddType("nlu","application/vnd.neurolanguage.nlu");
      AddType("ntf","application/vnd.nitf");
      AddType("nitf","application/vnd.nitf");
      AddType("nnd","application/vnd.noblenet-directory");
      AddType("nns","application/vnd.noblenet-sealer");
      AddType("nnw","application/vnd.noblenet-web");
      AddType("ngdat","application/vnd.nokia.n-gage.data");
      AddType("n-gage","application/vnd.nokia.n-gage.symbian.install");
      AddType("rpst","application/vnd.nokia.radio-preset");
      AddType("rpss","application/vnd.nokia.radio-presets");
      AddType("edm","application/vnd.novadigm.edm");
      AddType("edx","application/vnd.novadigm.edx");
      AddType("FExt","application/vnd.novadigm.FExt");
      AddType("odc","application/vnd.oasis.opendocument.chart");
      AddType("otc","application/vnd.oasis.opendocument.chart-template");
      AddType("odb","application/vnd.oasis.opendocument.database");
      AddType("odf","application/vnd.oasis.opendocument.formula");
      AddType("odft","application/vnd.oasis.opendocument.formula-template");
      AddType("odg","application/vnd.oasis.opendocument.graphics");
      AddType("otg","application/vnd.oasis.opendocument.graphics-template");
      AddType("odi","application/vnd.oasis.opendocument.image");
      AddType("oti","application/vnd.oasis.opendocument.image-template");
      AddType("odp","application/vnd.oasis.opendocument.presentation");
      AddType("otp","application/vnd.oasis.opendocument.presentation-template");
      AddType("ods","application/vnd.oasis.opendocument.spreadsheet");
      AddType("ots","application/vnd.oasis.opendocument.spreadsheet-template");
      AddType("odt","application/vnd.oasis.opendocument.text");
      AddType("odm","application/vnd.oasis.opendocument.text-master");
      AddType("ott","application/vnd.oasis.opendocument.text-template");
      AddType("oth","application/vnd.oasis.opendocument.text-web");
      AddType("xo","application/vnd.olpc-sugar");
      AddType("dd2","application/vnd.oma.dd2+xml");
      AddType("oxt","application/vnd.openofficeorg.extension");
      AddType("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation");
      AddType("sldx","application/vnd.openxmlformats-officedocument.presentationml.slide");
      AddType("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow");
      AddType("potx","application/vnd.openxmlformats-officedocument.presentationml.template");
      AddType("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
      AddType("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template");
      AddType("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document");
      AddType("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template");
      AddType("mgp","application/vnd.osgeo.mapguide.package");
      AddType("dp","application/vnd.osgi.dp");
      AddType("esa","application/vnd.osgi.subsystem");
      AddType("pdb","application/vnd.palm");
      AddType("pqa","application/vnd.palm");
      AddType("oprc","application/vnd.palm");
      AddType("paw","application/vnd.pawaafile");
      AddType("str","application/vnd.pg.format");
      AddType("ei6","application/vnd.pg.osasli");
      AddType("efif","application/vnd.picsel");
      AddType("wg","application/vnd.pmi.widget");
      AddType("plf","application/vnd.pocketlearn");
      AddType("pbd","application/vnd.powerbuilder6");
      AddType("box","application/vnd.previewsystems.box");
      AddType("mgz","application/vnd.proteus.magazine");
      AddType("qps","application/vnd.publishare-delta-tree");
      AddType("ptid","application/vnd.pvi.ptid1");
      AddType("qxd","application/vnd.quark.quarkxpress");
      AddType("qxt","application/vnd.quark.quarkxpress");
      AddType("qwd","application/vnd.quark.quarkxpress");
      AddType("qwt","application/vnd.quark.quarkxpress");
      AddType("qxl","application/vnd.quark.quarkxpress");
      AddType("qxb","application/vnd.quark.quarkxpress");
      AddType("bed","application/vnd.realvnc.bed");
      AddType("mxl","application/vnd.recordare.musicxml");
      AddType("musicxml","application/vnd.recordare.musicxml+xml");
      AddType("cryptonote","application/vnd.rig.cryptonote");
      AddType("cod","application/vnd.rim.cod");
      AddType("rm","application/vnd.rn-realmedia");
      AddType("rmvb","application/vnd.rn-realmedia-vbr");
      AddType("link66","application/vnd.route66.link66+xml");
      AddType("st","application/vnd.sailingtracker.track");
      AddType("see","application/vnd.seemail");
      AddType("sema","application/vnd.sema");
      AddType("semd","application/vnd.semd");
      AddType("semf","application/vnd.semf");
      AddType("ifm","application/vnd.shana.informed.formdata");
      AddType("itp","application/vnd.shana.informed.formtemplate");
      AddType("iif","application/vnd.shana.informed.interchange");
      AddType("ipk","application/vnd.shana.informed.package");
      AddType("twd","application/vnd.simtech-mindmapper");
      AddType("twds","application/vnd.simtech-mindmapper");
      AddType("mmf","application/vnd.smaf");
      AddType("teacher","application/vnd.smart.teacher");
      AddType("sdkm","application/vnd.solent.sdkm+xml");
      AddType("sdkd","application/vnd.solent.sdkm+xml");
      AddType("dxp","application/vnd.spotfire.dxp");
      AddType("sfs","application/vnd.spotfire.sfs");
      AddType("sdc","application/vnd.stardivision.calc");
      AddType("sda","application/vnd.stardivision.draw");
      AddType("sdd","application/vnd.stardivision.impress");
      AddType("smf","application/vnd.stardivision.math");
      AddType("sdw","application/vnd.stardivision.writer");
      AddType("vor","application/vnd.stardivision.writer");
      AddType("sgl","application/vnd.stardivision.writer-global");
      AddType("smzip","application/vnd.stepmania.package");
      AddType("sm","application/vnd.stepmania.stepchart");
      AddType("sxc","application/vnd.sun.xml.calc");
      AddType("stc","application/vnd.sun.xml.calc.template");
      AddType("sxd","application/vnd.sun.xml.draw");
      AddType("std","application/vnd.sun.xml.draw.template");
      AddType("sxi","application/vnd.sun.xml.impress");
      AddType("sti","application/vnd.sun.xml.impress.template");
      AddType("sxm","application/vnd.sun.xml.math");
      AddType("sxw","application/vnd.sun.xml.writer");
      AddType("sxg","application/vnd.sun.xml.writer.global");
      AddType("stw","application/vnd.sun.xml.writer.template");
      AddType("sus","application/vnd.sus-calendar");
      AddType("susp","application/vnd.sus-calendar");
      AddType("svd","application/vnd.svd");
      AddType("sis","application/vnd.symbian.install");
      AddType("sisx","application/vnd.symbian.install");
      AddType("xsm","application/vnd.syncml+xml");
      AddType("bdm","application/vnd.syncml.dm+wbxml");
      AddType("xdm","application/vnd.syncml.dm+xml");
      AddType("tao","application/vnd.tao.intent-module-archive");
      AddType("pcap","application/vnd.tcpdump.pcap");
      AddType("cap","application/vnd.tcpdump.pcap");
      AddType("dmp","application/vnd.tcpdump.pcap");
      AddType("tmo","application/vnd.tmobile-livetv");
      AddType("tpt","application/vnd.trid.tpt");
      AddType("mxs","application/vnd.triscape.mxs");
      AddType("tra","application/vnd.trueapp");
      AddType("ufd","application/vnd.ufdl");
      AddType("ufdl","application/vnd.ufdl");
      AddType("utz","application/vnd.uiq.theme");
      AddType("umj","application/vnd.umajin");
      AddType("unityweb","application/vnd.unity");
      AddType("uoml","application/vnd.uoml+xml");
      AddType("vcx","application/vnd.vcx");
      AddType("vsd","application/vnd.visio");
      AddType("vst","application/vnd.visio");
      AddType("vss","application/vnd.visio");
      AddType("vsw","application/vnd.visio");
      AddType("vis","application/vnd.visionary");
      AddType("vsf","application/vnd.vsf");
      AddType("wbxml","application/vnd.wap.wbxml");
      AddType("wmlc","application/vnd.wap.wmlc");
      AddType("wmlsc","application/vnd.wap.wmlscriptc");
      AddType("wtb","application/vnd.webturbo");
      AddType("nbp","application/vnd.wolfram.player");
      AddType("wpd","application/vnd.wordperfect");
      AddType("wqd","application/vnd.wqd");
      AddType("stf","application/vnd.wt.stf");
      AddType("xar","application/vnd.xara");
      AddType("xfdl","application/vnd.xfdl");
      AddType("hvd","application/vnd.yamaha.hv-dic");
      AddType("hvs","application/vnd.yamaha.hv-script");
      AddType("hvp","application/vnd.yamaha.hv-voice");
      AddType("osf","application/vnd.yamaha.openscoreformat");
      AddType("osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml");
      AddType("saf","application/vnd.yamaha.smaf-audio");
      AddType("spf","application/vnd.yamaha.smaf-phrase");
      AddType("cmp","application/vnd.yellowriver-custom-menu");
      AddType("zir","application/vnd.zul");
      AddType("zirz","application/vnd.zul");
      AddType("zaz","application/vnd.zzazz.deck+xml");
      AddType("vxml","application/voicexml+xml");
      AddType("wgt","application/widget");
      AddType("hlp","application/winhlp");
      AddType("wsdl","application/wsdl+xml");
      AddType("wspolicy","application/wspolicy+xml");
      AddType("7z","application/x-7z-compressed");
      AddType("abw","application/x-abiword");
      AddType("ace","application/x-ace-compressed");
      AddType("dmg","application/x-apple-diskimage");
      AddType("aab","application/x-authorware-bin");
      AddType("x32","application/x-authorware-bin");
      AddType("u32","application/x-authorware-bin");
      AddType("vox","application/x-authorware-bin");
      AddType("aam","application/x-authorware-map");
      AddType("aas","application/x-authorware-seg");
      AddType("bcpio","application/x-bcpio");
      AddType("torrent","application/x-bittorrent");
      AddType("blb","application/x-blorb");
      AddType("blorb","application/x-blorb");
      AddType("bz","application/x-bzip");
      AddType("bz2","application/x-bzip2");
      AddType("boz","application/x-bzip2");
      AddType("cbr","application/x-cbr");
      AddType("cba","application/x-cbr");
      AddType("cbt","application/x-cbr");
      AddType("cbz","application/x-cbr");
      AddType("cb7","application/x-cbr");
      AddType("vcd","application/x-cdlink");
      AddType("cfs","application/x-cfs-compressed");
      AddType("chat","application/x-chat");
      AddType("pgn","application/x-chess-pgn");
      AddType("nsc","application/x-conference");
      AddType("cpio","application/x-cpio");
      AddType("csh","application/x-csh");
      AddType("deb","application/x-debian-package");
      AddType("udeb","application/x-debian-package");
      AddType("dgc","application/x-dgc-compressed");
      AddType("dir","application/x-director");
      AddType("dcr","application/x-director");
      AddType("dxr","application/x-director");
      AddType("cst","application/x-director");
      AddType("cct","application/x-director");
      AddType("cxt","application/x-director");
      AddType("w3d","application/x-director");
      AddType("fgd","application/x-director");
      AddType("swa","application/x-director");
      AddType("wad","application/x-doom");
      AddType("ncx","application/x-dtbncx+xml");
      AddType("dtb","application/x-dtbook+xml");
      AddType("res","application/x-dtbresource+xml");
      AddType("dvi","application/x-dvi");
      AddType("evy","application/x-envoy");
      AddType("eva","application/x-eva");
      AddType("bdf","application/x-font-bdf");
      AddType("gsf","application/x-font-ghostscript");
      AddType("psf","application/x-font-linux-psf");
      AddType("otf","application/x-font-otf");
      AddType("pcf","application/x-font-pcf");
      AddType("snf","application/x-font-snf");
      AddType("ttf","application/x-font-ttf");
      AddType("ttc","application/x-font-ttf");
      AddType("pfa","application/x-font-type1");
      AddType("pfb","application/x-font-type1");
      AddType("pfm","application/x-font-type1");
      AddType("afm","application/x-font-type1");
      AddType("woff","application/x-font-woff");
      AddType("arc","application/x-freearc");
      AddType("spl","application/x-futuresplash");
      AddType("gca","application/x-gca-compressed");
      AddType("ulx","application/x-glulx");
      AddType("gnumeric","application/x-gnumeric");
      AddType("gramps","application/x-gramps-xml");
      AddType("gtar","application/x-gtar");
      AddType("hdf","application/x-hdf");
      AddType("install","application/x-install-instructions");
      AddType("iso","application/x-iso9660-image");
      AddType("jnlp","application/x-java-jnlp-file");
      AddType("latex","application/x-latex");
      AddType("lzh","application/x-lzh-compressed");
      AddType("lha","application/x-lzh-compressed");
      AddType("mie","application/x-mie");
      AddType("prc","application/x-mobipocket-ebook");
      AddType("mobi","application/x-mobipocket-ebook");
      AddType("application","application/x-ms-application");
      AddType("lnk","application/x-ms-shortcut");
      AddType("wmd","application/x-ms-wmd");
      AddType("wmz","application/x-ms-wmz");
      AddType("xbap","application/x-ms-xbap");
      AddType("mdb","application/x-msaccess");
      AddType("obd","application/x-msbinder");
      AddType("crd","application/x-mscardfile");
      AddType("clp","application/x-msclip");
      AddType("exe","application/x-msdownload");
      AddType("dll","application/x-msdownload");
      AddType("com","application/x-msdownload");
      AddType("bat","application/x-msdownload");
      AddType("msi","application/x-msdownload");
      AddType("mvb","application/x-msmediaview");
      AddType("m13","application/x-msmediaview");
      AddType("m14","application/x-msmediaview");
      AddType("wmf","application/x-msmetafile");
      AddType("wmz","application/x-msmetafile");
      AddType("emf","application/x-msmetafile");
      AddType("emz","application/x-msmetafile");
      AddType("mny","application/x-msmoney");
      AddType("pub","application/x-mspublisher");
      AddType("scd","application/x-msschedule");
      AddType("trm","application/x-msterminal");
      AddType("wri","application/x-mswrite");
      AddType("nc","application/x-netcdf");
      AddType("cdf","application/x-netcdf");
      AddType("nzb","application/x-nzb");
      AddType("p12","application/x-pkcs12");
      AddType("pfx","application/x-pkcs12");
      AddType("p7b","application/x-pkcs7-certificates");
      AddType("spc","application/x-pkcs7-certificates");
      AddType("p7r","application/x-pkcs7-certreqresp");
      AddType("rar","application/x-rar-compressed");
      AddType("ris","application/x-research-info-systems");
      AddType("sh","application/x-sh");
      AddType("shar","application/x-shar");
      AddType("swf","application/x-shockwave-flash");
      AddType("xap","application/x-silverlight-app");
      AddType("sql","application/x-sql");
      AddType("sit","application/x-stuffit");
      AddType("sitx","application/x-stuffitx");
      AddType("srt","application/x-subrip");
      AddType("sv4cpio","application/x-sv4cpio");
      AddType("sv4crc","application/x-sv4crc");
      AddType("t3","application/x-t3vm-image");
      AddType("gam","application/x-tads");
      AddType("tar","application/x-tar");
      AddType("tcl","application/x-tcl");
      AddType("tex","application/x-tex");
      AddType("tfm","application/x-tex-tfm");
      AddType("texinfo","application/x-texinfo");
      AddType("texi","application/x-texinfo");
      AddType("obj","application/x-tgif");
      AddType("ustar","application/x-ustar");
      AddType("src","application/x-wais-source");
      AddType("der","application/x-x509-ca-cert");
      AddType("crt","application/x-x509-ca-cert");
      AddType("fig","application/x-xfig");
      AddType("xlf","application/x-xliff+xml");
      AddType("xpi","application/x-xpinstall");
      AddType("xz","application/x-xz");
      AddType("z1","application/x-zmachine");
      AddType("z2","application/x-zmachine");
      AddType("z3","application/x-zmachine");
      AddType("z4","application/x-zmachine");
      AddType("z5","application/x-zmachine");
      AddType("z6","application/x-zmachine");
      AddType("z7","application/x-zmachine");
      AddType("z8","application/x-zmachine");
      AddType("xaml","application/xaml+xml");
      AddType("xdf","application/xcap-diff+xml");
      AddType("xenc","application/xenc+xml");
      AddType("xhtml","application/xhtml+xml");
      AddType("xht","application/xhtml+xml");
      AddType("xml","application/xml");
      AddType("xsl","application/xml");
      AddType("dtd","application/xml-dtd");
      AddType("xop","application/xop+xml");
      AddType("xpl","application/xproc+xml");
      AddType("xslt","application/xslt+xml");
      AddType("xspf","application/xspf+xml");
      AddType("mxml","application/xv+xml");
      AddType("xhvml","application/xv+xml");
      AddType("xvml","application/xv+xml");
      AddType("xvm","application/xv+xml");
      AddType("yang","application/yang");
      AddType("yin","application/yin+xml");
      AddType("zip","application/zip");
      AddType("adp","audio/adpcm");
      AddType("au","audio/basic");
      AddType("snd","audio/basic");
      AddType("mid","audio/midi");
      AddType("midi","audio/midi");
      AddType("kar","audio/midi");
      AddType("rmi","audio/midi");
      AddType("mp4a","audio/mp4");
      AddType("mpga","audio/mpeg");
      AddType("mp2","audio/mpeg");
      AddType("mp2a","audio/mpeg");
      AddType("mp3","audio/mpeg");
      AddType("m2a","audio/mpeg");
      AddType("m3a","audio/mpeg");
      AddType("oga","audio/ogg");
      AddType("ogg","audio/ogg");
      AddType("spx","audio/ogg");
      AddType("s3m","audio/s3m");
      AddType("sil","audio/silk");
      AddType("uva","audio/vnd.dece.audio");
      AddType("uvva","audio/vnd.dece.audio");
      AddType("eol","audio/vnd.digital-winds");
      AddType("dra","audio/vnd.dra");
      AddType("dts","audio/vnd.dts");
      AddType("dtshd","audio/vnd.dts.hd");
      AddType("lvp","audio/vnd.lucent.voice");
      AddType("pya","audio/vnd.ms-playready.media.pya");
      AddType("ecelp4800","audio/vnd.nuera.ecelp4800");
      AddType("ecelp7470","audio/vnd.nuera.ecelp7470");
      AddType("ecelp9600","audio/vnd.nuera.ecelp9600");
      AddType("rip","audio/vnd.rip");
      AddType("weba","audio/webm");
      AddType("aac","audio/aac");
      AddType("aif","audio/x-aiff");
      AddType("aiff","audio/x-aiff");
      AddType("aifc","audio/x-aiff");
      AddType("caf","audio/x-caf");
      AddType("flac","audio/x-flac");
      AddType("mka","audio/x-matroska");
      AddType("m3u","audio/x-mpegurl");
      AddType("wax","audio/x-ms-wax");
      AddType("wma","audio/x-ms-wma");
      AddType("ram","audio/x-pn-realaudio");
      AddType("ra","audio/x-pn-realaudio");
      AddType("rmp","audio/x-pn-realaudio-plugin");
      AddType("wav","audio/x-wav");
      AddType("xm","audio/xm");
      AddType("cdx","chemical/x-cdx");
      AddType("cif","chemical/x-cif");
      AddType("cmdf","chemical/x-cmdf");
      AddType("cml","chemical/x-cml");
      AddType("csml","chemical/x-csml");
      AddType("xyz","chemical/x-xyz");
      AddType("bmp","image/bmp");
      AddType("cgm","image/cgm");
      AddType("g3","image/g3fax");
      AddType("gif","image/gif");
      AddType("ief","image/ief");
      AddType("jpeg","image/jpeg");
      AddType("jpg","image/jpeg");
      AddType("jpe","image/jpeg");
      AddType("ktx","image/ktx");
      AddType("png","image/png");
      AddType("btif","image/prs.btif");
      AddType("sgi","image/sgi");
      AddType("svg","image/svg+xml");
      AddType("svgz","image/svg+xml");
      AddType("tiff","image/tiff");
      AddType("tif","image/tiff");
      AddType("psd","image/vnd.adobe.photoshop");
      AddType("uvi","image/vnd.dece.graphic");
      AddType("uvvi","image/vnd.dece.graphic");
      AddType("uvg","image/vnd.dece.graphic");
      AddType("uvvg","image/vnd.dece.graphic");
      AddType("sub","image/vnd.dvb.subtitle");
      AddType("djvu","image/vnd.djvu");
      AddType("djv","image/vnd.djvu");
      AddType("dwg","image/vnd.dwg");
      AddType("dxf","image/vnd.dxf");
      AddType("fbs","image/vnd.fastbidsheet");
      AddType("fpx","image/vnd.fpx");
      AddType("fst","image/vnd.fst");
      AddType("mmr","image/vnd.fujixerox.edmics-mmr");
      AddType("rlc","image/vnd.fujixerox.edmics-rlc");
      AddType("mdi","image/vnd.ms-modi");
      AddType("wdp","image/vnd.ms-photo");
      AddType("npx","image/vnd.net-fpx");
      AddType("wbmp","image/vnd.wap.wbmp");
      AddType("xif","image/vnd.xiff");
      AddType("webp","image/webp");
      AddType("3ds","image/x-3ds");
      AddType("ras","image/x-cmu-raster");
      AddType("cmx","image/x-cmx");
      AddType("fh","image/x-freehand");
      AddType("fhc","image/x-freehand");
      AddType("fh4","image/x-freehand");
      AddType("fh5","image/x-freehand");
      AddType("fh7","image/x-freehand");
      AddType("ico","image/x-icon");
      AddType("sid","image/x-mrsid-image");
      AddType("pcx","image/x-pcx");
      AddType("pic","image/x-pict");
      AddType("pct","image/x-pict");
      AddType("pnm","image/x-portable-anymap");
      AddType("pbm","image/x-portable-bitmap");
      AddType("pgm","image/x-portable-graymap");
      AddType("ppm","image/x-portable-pixmap");
      AddType("rgb","image/x-rgb");
      AddType("tga","image/x-tga");
      AddType("xbm","image/x-xbitmap");
      AddType("xpm","image/x-xpixmap");
      AddType("xwd","image/x-xwindowdump");
      AddType("eml","message/rfc822");
      AddType("mime","message/rfc822");
      AddType("igs","model/iges");
      AddType("iges","model/iges");
      AddType("msh","model/mesh");
      AddType("mesh","model/mesh");
      AddType("silo","model/mesh");
      AddType("dae","model/vnd.collada+xml");
      AddType("dwf","model/vnd.dwf");
      AddType("gdl","model/vnd.gdl");
      AddType("gtw","model/vnd.gtw");
      AddType("mts","model/vnd.mts");
      AddType("vtu","model/vnd.vtu");
      AddType("wrl","model/vrml");
      AddType("vrml","model/vrml");
      AddType("x3db","model/x3d+binary");
      AddType("x3dbz","model/x3d+binary");
      AddType("x3dv","model/x3d+vrml");
      AddType("x3dvz","model/x3d+vrml");
      AddType("x3d","model/x3d+xml");
      AddType("x3dz","model/x3d+xml");
      AddType("appcache","text/cache-manifest");
      AddType("ics","text/calendar");
      AddType("ifb","text/calendar");
      AddType("cmd","text/cmd");
      AddType("css","text/css");
      AddType("csv","text/csv");
      AddType("html","text/html");
      AddType("htm","text/html");
      AddType("n3","text/n3");
      AddType("txt","text/plain");
      AddType("text","text/plain");
      AddType("conf","text/plain");
      AddType("def","text/plain");
      AddType("list","text/plain");
      AddType("log","text/plain");
      AddType("in","text/plain");
      AddType("js","text/plain");
      AddType("dsc","text/prs.lines.tag");
      AddType("rtx","text/richtext");
      AddType("sgml","text/sgml");
      AddType("sgm","text/sgml");
      AddType("tsv","text/tab-separated-values");
      AddType("t","text/troff");
      AddType("tr","text/troff");
      AddType("roff","text/troff");
      AddType("man","text/troff");
      AddType("me","text/troff");
      AddType("ms","text/troff");
      AddType("ttl","text/turtle");
      AddType("uri","text/uri-list");
      AddType("uris","text/uri-list");
      AddType("urls","text/uri-list");
      AddType("vcard","text/vcard");
      AddType("curl","text/vnd.curl");
      AddType("dcurl","text/vnd.curl.dcurl");
      AddType("scurl","text/vnd.curl.scurl");
      AddType("mcurl","text/vnd.curl.mcurl");
      AddType("sub","text/vnd.dvb.subtitle");
      AddType("fly","text/vnd.fly");
      AddType("flx","text/vnd.fmi.flexstor");
      AddType("gv","text/vnd.graphviz");
      AddType("3dml","text/vnd.in3d.3dml");
      AddType("spot","text/vnd.in3d.spot");
      AddType("jad","text/vnd.sun.j2me.app-descriptor");
      AddType("wml","text/vnd.wap.wml");
      AddType("wmls","text/vnd.wap.wmlscript");
      AddType("s","text/x-asm");
      AddType("asm","text/x-asm");
      AddType("c","text/x-c");
      AddType("cc","text/x-c");
      AddType("cxx","text/x-c");
      AddType("cpp","text/x-c");
      AddType("h","text/x-c");
      AddType("hh","text/x-c");
      AddType("dic","text/x-c");
      AddType("f","text/x-fortran");
      AddType("for","text/x-fortran");
      AddType("f77","text/x-fortran");
      AddType("f90","text/x-fortran");
      AddType("java","text/x-java-source");
      AddType("opml","text/x-opml");
      AddType("p","text/x-pascal");
      AddType("pas","text/x-pascal");
      AddType("nfo","text/x-nfo");
      AddType("etx","text/x-setext");
      AddType("sfv","text/x-sfv");
      AddType("uu","text/x-uuencode");
      AddType("vcs","text/x-vcalendar");
      AddType("vcf","text/x-vcard");
      AddType("xml","text/xml");
      AddType("xsl","text/xml");
      AddType("dtd","text/xml-dtd");
      AddType("3gp","video/3gpp");
      AddType("3g2","video/3gpp2");
      AddType("h261","video/h261");
      AddType("h263","video/h263");
      AddType("h264","video/h264");
      AddType("jpgv","video/jpeg");
      AddType("jpm","video/jpm");
      AddType("jpgm","video/jpm");
      AddType("mj2","video/mj2");
      AddType("mjp2","video/mj2");
      AddType("mp4","video/mp4");
      AddType("mp4v","video/mp4");
      AddType("mpg4","video/mp4");
      AddType("mpeg","video/mpeg");
      AddType("mpg","video/mpeg");
      AddType("mpe","video/mpeg");
      AddType("m1v","video/mpeg");
      AddType("m2v","video/mpeg");
      AddType("ogv","video/ogg");
      AddType("qt","video/quicktime");
      AddType("mov","video/quicktime");
      AddType("uvh","video/vnd.dece.hd");
      AddType("uvvh","video/vnd.dece.hd");
      AddType("uvm","video/vnd.dece.mobile");
      AddType("uvvm","video/vnd.dece.mobile");
      AddType("uvp","video/vnd.dece.pd");
      AddType("uvvp","video/vnd.dece.pd");
      AddType("uvs","video/vnd.dece.sd");
      AddType("uvvs","video/vnd.dece.sd");
      AddType("uvv","video/vnd.dece.video");
      AddType("uvvv","video/vnd.dece.video");
      AddType("dvb","video/vnd.dvb.file");
      AddType("fvt","video/vnd.fvt");
      AddType("mxu","video/vnd.mpegurl");
      AddType("m4u","video/vnd.mpegurl");
      AddType("pyv","video/vnd.ms-playready.media.pyv");
      AddType("uvu","video/vnd.uvvu.mp4");
      AddType("uvvu","video/vnd.uvvu.mp4");
      AddType("viv","video/vnd.vivo");
      AddType("webm","video/webm");
      AddType("f4v","video/x-f4v");
      AddType("fli","video/x-fli");
      AddType("flv","video/x-flv");
      AddType("m4v","video/x-m4v");
      AddType("mkv","video/x-matroska");
      AddType("mk3d","video/x-matroska");
      AddType("mks","video/x-matroska");
      AddType("mng","video/x-mng");
      AddType("asf","video/x-ms-asf");
      AddType("asx","video/x-ms-asf");
      AddType("vob","video/x-ms-vob");
      AddType("wm","video/x-ms-wm");
      AddType("wmv","video/x-ms-wmv");
      AddType("wmx","video/x-ms-wmx");
      AddType("wvx","video/x-ms-wvx");
      AddType("avi","video/x-msvideo");
      AddType("movie","video/x-sgi-movie");
      AddType("smv","video/x-smv");
      AddType("ice","x-conference/x-cooltalk");
    };
  };
  $mod.$init = function () {
    $mod.FNCFormatSettings.$assign(pas.SysUtils.TFormatSettings.Create());
    $mod.FNCFormatSettings.DecimalSeparator = ".";
    $mod.FNCFormatSettings.ThousandSeparator = ",";
    $impl.FMimeTypes = pas.Classes.TStringList.$create("Create$1");
    $impl.RegisterMimeTypes();
  };
},["DateUtils"]);
rtl.module("Variants",["System"],function () {
  "use strict";
  var $mod = this;
});
rtl.module("WEBLib.TMSFNCJSONReader",["System","Classes","SysUtils","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.createClass(this,"TTMSFNCJSONStreamReader",pas.System.TObject,function () {
    rtl.createClass(this,"EInvalidJsonInput",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Invalid JSON Input");
        return this;
      };
    },"TTMSFNCJSONStreamReader.EInvalidJsonInput");
    rtl.createClass(this,"EInternalError",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"JSON stream reader internal error");
        return this;
      };
    },"TTMSFNCJSONStreamReader.EInternalError");
    rtl.createClass(this,"EEndOfInputReached",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"End of JSON input reached.");
        return this;
      };
    },"TTMSFNCJSONStreamReader.EEndOfInputReached");
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FStream = null;
      this.FReadStream = null;
    };
    this.$final = function () {
      this.FStream = undefined;
      this.FReadStream = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (aStream) {
      this.FStream = aStream;
      this.FReadStream = pas.Classes.TStringStream.$create("Create$3",["",pas.SysUtils.TEncoding.GetANSI(),true]);
      this.FReadStream.CopyFrom(this.FStream,this.FStream.GetSize());
      this.FReadStream.SetPosition(0);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FReadStream");
      pas.System.TObject.Destroy.call(this);
    };
    this.NextChar = function () {
      var Result = "\x00";
      if (this.Eof()) throw this.EEndOfInputReached.$create("Create$2");
      Result = this.ReadChar();
      return Result;
    };
    this.PeekChar = function () {
      var Result = "\x00";
      var p = 0;
      p = this.FReadStream.GetPosition();
      Result = this.ReadChar();
      this.FReadStream.SetPosition(p);
      return Result;
    };
    this.ReadChar = function () {
      var Result = "\x00";
      var i = 0;
      var s = "";
      Result = "\x00";
      i = 1;
      if (this.FReadStream.GetPosition() < this.FReadStream.GetSize()) {
        s = this.FReadStream.ReadString(1);
        if ((s !== "") && pas.System.Assigned(s)) Result = s.charAt(i - 1);
      };
      return Result;
    };
    this.Backup = function (c) {
      this.FReadStream.SetPosition(this.FReadStream.GetPosition() - 1);
    };
    this.MoveNext = function (Count) {
      this.FReadStream.SetPosition(this.FReadStream.GetPosition() + Count);
    };
    this.Eof = function () {
      var Result = false;
      Result = this.FReadStream.GetPosition() === this.FReadStream.GetSize();
      return Result;
    };
  });
  this.TTMSFNCJSONToken = {"0": "jstoBeginObject", jstoBeginObject: 0, "1": "jstoEndObject", jstoEndObject: 1, "2": "jstoBeginArray", jstoBeginArray: 2, "3": "jstoEndArray", jstoEndArray: 3, "4": "jstoName", jstoName: 4, "5": "jstoBoolean", jstoBoolean: 5, "6": "jstoNull", jstoNull: 6, "7": "jstoText", jstoText: 7, "8": "jstoNumber", jstoNumber: 8, "9": "jstoEOF", jstoEOF: 9};
  this.$rtti.$Enum("TTMSFNCJSONToken",{minvalue: 0, maxvalue: 9, ordtype: 1, enumtype: this.TTMSFNCJSONToken});
  rtl.createClass(this,"TTMSFNCJSONReader",pas.System.TObject,function () {
    this.TTMSFNCJSONState = {"0": "jstNone", jstNone: 0, "1": "jstBeginObject", jstBeginObject: 1, "2": "jstEndObject", jstEndObject: 2, "3": "jstBeginArray", jstBeginArray: 3, "4": "jstEndArray", jstEndArray: 4, "5": "jstTrue", jstTrue: 5, "6": "jstFalse", jstFalse: 6, "7": "jstNull", jstNull: 7, "8": "jstDoubleQuoted", jstDoubleQuoted: 8, "9": "jstBuffered", jstBuffered: 9, "10": "jstDoubleQuotedName", jstDoubleQuotedName: 10, "11": "jstInt64", jstInt64: 11, "12": "jstNumber", jstNumber: 12, "13": "jstEOF", jstEOF: 13};
    $mod.$rtti.$Enum("TTMSFNCJSONReader.TTMSFNCJSONState",{minvalue: 0, maxvalue: 13, ordtype: 1, enumtype: this.TTMSFNCJSONState});
    this.TTMSFNCJSONNumberState = {"0": "jnstNone", jnstNone: 0, "1": "jnstSign", jnstSign: 1, "2": "jnstDigit", jnstDigit: 2, "3": "jnstDecimal", jnstDecimal: 3, "4": "jnstFraction", jnstFraction: 4, "5": "jnstExpE", jnstExpE: 5, "6": "jnstExpSign", jnstExpSign: 6, "7": "jnstExpDigit", jnstExpDigit: 7};
    $mod.$rtti.$Enum("TTMSFNCJSONReader.TTMSFNCJSONNumberState",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TTMSFNCJSONNumberState});
    this.TTMSFNCJSONScope = {"0": "jscEmptyDocument", jscEmptyDocument: 0, "1": "jscEmptyArray", jscEmptyArray: 1, "2": "jscEmptyObject", jscEmptyObject: 2, "3": "jscNonEmptyDocument", jscNonEmptyDocument: 3, "4": "jscNonEmptyArray", jscNonEmptyArray: 4, "5": "jscNonEmptyObject", jscNonEmptyObject: 5, "6": "jscDanglingName", jscDanglingName: 6};
    $mod.$rtti.$Enum("TTMSFNCJSONReader.TTMSFNCJSONScope",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TTMSFNCJSONScope});
    rtl.createClass(this,"EInvalidStateException",pas.SysUtils.Exception,function () {
      this.Create$2 = function (AState) {
        pas.SysUtils.Exception.CreateFmt.call(this,"Invalid Json parser state. Expected state: %d",pas.System.VarRecs(0,AState));
        return this;
      };
    },"TTMSFNCJSONReader.EInvalidStateException");
    rtl.createClass(this,"EUnterminatedArray",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Unterminated array");
        return this;
      };
    },"TTMSFNCJSONReader.EUnterminatedArray");
    rtl.createClass(this,"EUnterminatedObject",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Unterminated object");
        return this;
      };
    },"TTMSFNCJSONReader.EUnterminatedObject");
    rtl.createClass(this,"ENameExpected",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Name expected");
        return this;
      };
    },"TTMSFNCJSONReader.ENameExpected");
    rtl.createClass(this,"EColonExpected",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Colon expected");
        return this;
      };
    },"TTMSFNCJSONReader.EColonExpected");
    rtl.createClass(this,"EReaderClosed",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Reader already closed");
        return this;
      };
    },"TTMSFNCJSONReader.EReaderClosed");
    rtl.createClass(this,"EMultipleRootNotAllowed",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Multiple root values not allowed");
        return this;
      };
    },"TTMSFNCJSONReader.EMultipleRootNotAllowed");
    rtl.createClass(this,"EExpectedValue",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Value expected but invalid character found");
        return this;
      };
    },"TTMSFNCJSONReader.EExpectedValue");
    rtl.createClass(this,"EObjectOrArrayExpected",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Object or array expected as top-level value");
        return this;
      };
    },"TTMSFNCJSONReader.EObjectOrArrayExpected");
    rtl.createClass(this,"ETooManyDepthLevels",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Maximum level of nested structured reached.");
        return this;
      };
    },"TTMSFNCJSONReader.ETooManyDepthLevels");
    rtl.createClass(this,"EInvalidEscaped",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Invalid escaped sequence");
        return this;
      };
    },"TTMSFNCJSONReader.EInvalidEscaped");
    this.MaxNumberBuffer = 255;
    this.MaxStackSize = 255;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FReader = null;
      this.FStack = rtl.arraySetLength(null,0,256);
      this.FStackSize = 0;
      this.FPeeked = 0;
      this.FPeekedInt64 = 0;
      this.FPeekedNumber = rtl.arraySetLength(null,"\x00",256);
      this.FPeekedString = "";
    };
    this.$final = function () {
      this.FReader = undefined;
      this.FStack = undefined;
      this.FPeekedNumber = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.NextPeek = function () {
      var Result = 0;
      if (this.FPeeked === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone) this.FPeeked = this.DoPeek();
      Result = this.FPeeked;
      return Result;
    };
    this.CheckState = function (State) {
      if (this.NextPeek() !== State) throw this.EInvalidStateException.$create("Create$2",[State]);
    };
    this.SkipChar = function () {
      this.FReader.MoveNext(1);
      while (this.FReader.PeekChar().charCodeAt() in $impl.Wspace) this.FReader.MoveNext(1);
    };
    this.IsLiteral = function (C) {
      var Result = false;
      Result = !pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.CharInSet(C,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.CreateCharSet("/\\;#{}[]:,' \r\n\f\t"));
      return Result;
    };
    this.IsDigit = function (C) {
      var Result = false;
      Result = (C <= "ÿ") && pas["WEBLib.TMSFNCTypes"].CharIsNumber(C);
      return Result;
    };
    this.DoPeek = function () {
      var Result = 0;
      var FPeekStack = 0;
      var C = "\x00";
      FPeekStack = this.FStack[this.FStackSize - 1];
      if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyArray) {
        this.FStack[this.FStackSize - 1] = $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyArray}
       else if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyArray) {
        C = this.NextNonWhitespace();
        var $tmp = C;
        if ($tmp === "]") {
          while (this.FReader.PeekChar().charCodeAt() in $impl.Wspace) this.FReader.MoveNext(1);
          this.SkipChar();
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndArray;
          return this.FPeeked;
        } else if ($tmp === ",") {
          this.SkipChar()}
         else {
          throw this.EUnterminatedArray.$create("Create$2");
        };
      } else if (FPeekStack in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyObject,$mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyObject)) {
        this.FStack[this.FStackSize - 1] = $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscDanglingName;
        if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyObject) {
          C = this.NextNonWhitespace();
          var $tmp1 = C;
          if ($tmp1 === "}") {
            while (this.FReader.PeekChar().charCodeAt() in $impl.Wspace) this.FReader.MoveNext(1);
            this.SkipChar();
            this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndObject;
            return this.FPeeked;
          } else if ($tmp1 === ",") {
            this.SkipChar()}
           else {
            throw this.EUnterminatedObject.$create("Create$2");
          };
        };
        C = this.NextNonWhitespace();
        var $tmp2 = C;
        if ($tmp2 === '"') {
          this.SkipChar();
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuotedName;
          return this.FPeeked;
        } else if ($tmp2 === "}") {
          if (FPeekStack !== $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyObject) {
            this.SkipChar();
            this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndObject;
            return this.FPeeked;
          } else throw this.ENameExpected.$create("Create$2")}
         else {
          throw this.ENameExpected.$create("Create$2");
        };
      } else if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscDanglingName) {
        this.FStack[this.FStackSize - 1] = $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyObject;
        C = this.NextNonWhitespace();
        if (C === ":") {
          this.SkipChar()}
         else throw this.EColonExpected.$create("Create$2");
      } else if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyDocument) {
        this.FStack[this.FStackSize - 1] = $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyDocument}
       else if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscNonEmptyDocument) {
        if (this.SkipWhitespaceUntilEnd()) {
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEOF;
          return this.FPeeked;
        } else throw this.EMultipleRootNotAllowed.$create("Create$2");
      };
      C = this.NextNonWhitespace();
      var $tmp3 = C;
      if ($tmp3 === "]") {
        if (FPeekStack === $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyArray) {
          this.SkipChar();
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndArray;
          return this.FPeeked;
        } else throw this.EExpectedValue.$create("Create$2")}
       else if ($tmp3 === '"') {
        if (this.FStackSize === 1) throw this.EObjectOrArrayExpected.$create("Create$2");
        this.SkipChar();
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted;
        return this.FPeeked;
      } else if ($tmp3 === "[") {
        this.SkipChar();
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginArray;
        return this.FPeeked;
      } else if ($tmp3 === "{") {
        this.SkipChar();
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginObject;
        return this.FPeeked;
      };
      if (this.FStackSize === 1) throw this.EObjectOrArrayExpected.$create("Create$2");
      Result = this.PeekKeyword();
      if (Result !== $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone) return Result;
      Result = this.PeekNumber();
      if (Result !== $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone) return Result;
      throw this.EExpectedValue.$create("Create$2");
      return Result;
    };
    this.PushScope = function (Scope) {
      if (this.FStackSize > 255) throw this.ETooManyDepthLevels.$create("Create$2");
      this.FStack[this.FStackSize] = Scope;
      this.FStackSize += 1;
    };
    this.NextNonWhitespace = function () {
      var Result = "\x00";
      var s = "\x00";
      var p = 0;
      p = this.FReader.FReadStream.GetPosition();
      Result = "\x00";
      s = this.ReadChar();
      do {
        if ((s > " ") || !(s.charCodeAt() in $impl.Wspace)) {
          this.FReader.FReadStream.SetPosition(p);
          return s;
        };
        s = this.ReadChar();
      } while (!this.FReader.Eof());
      this.FReader.FReadStream.SetPosition(p);
      return Result;
    };
    this.ReadChar = function () {
      var Result = "\x00";
      Result = this.FReader.ReadChar();
      return Result;
    };
    this.PeekKeyword = function () {
      var Result = 0;
      var $tmp = this.FReader.PeekChar();
      if (($tmp === "t") || ($tmp === "T")) {
        this.FReader.MoveNext(1);
        var $tmp1 = this.FReader.NextChar();
        if (($tmp1 === "r") || ($tmp1 === "R")) {
          var $tmp2 = this.FReader.NextChar();
          if (($tmp2 === "u") || ($tmp2 === "U")) {
            var $tmp3 = this.FReader.NextChar();
            if (($tmp3 === "e") || ($tmp3 === "E")) if (this.FReader.Eof() || !this.IsLiteral(this.FReader.PeekChar())) return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstTrue;
          };
        };
      } else if (($tmp === "f") || ($tmp === "F")) {
        this.FReader.MoveNext(1);
        var $tmp4 = this.FReader.NextChar();
        if (($tmp4 === "a") || ($tmp4 === "A")) {
          var $tmp5 = this.FReader.NextChar();
          if (($tmp5 === "l") || ($tmp5 === "L")) {
            var $tmp6 = this.FReader.NextChar();
            if (($tmp6 === "s") || ($tmp6 === "S")) {
              var $tmp7 = this.FReader.NextChar();
              if (($tmp7 === "e") || ($tmp7 === "E")) if (this.FReader.Eof() || !this.IsLiteral(this.FReader.PeekChar())) return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstFalse;
            };
          };
        };
      } else if (($tmp === "n") || ($tmp === "N")) {
        this.FReader.MoveNext(1);
        var $tmp8 = this.FReader.NextChar();
        if (($tmp8 === "a") || ($tmp8 === "A")) {
          var $tmp9 = this.FReader.NextChar();
          if (($tmp9 === "n") || ($tmp9 === "N")) if (this.FReader.Eof() || !this.IsLiteral(this.FReader.PeekChar())) return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNull;
        } else if (($tmp8 === "u") || ($tmp8 === "U")) {
          var $tmp10 = this.FReader.NextChar();
          if (($tmp10 === "l") || ($tmp10 === "L")) {
            var $tmp11 = this.FReader.NextChar();
            if (($tmp11 === "l") || ($tmp11 === "L")) if (this.FReader.Eof() || !this.IsLiteral(this.FReader.PeekChar())) return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNull;
          };
        };
      } else {
        return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      };
      throw this.EExpectedValue.$create("Create$2");
      return Result;
    };
    var MinIncompleteInteger = rtl.trunc(-9007199254740991 / 10);
    this.PeekNumber = function () {
      var Result = 0;
      var Last = 0;
      var Negative = false;
      var FitsInInt64 = false;
      var Value = 0;
      var NewValue = 0;
      var C = "\x00";
      var BufIndex = 0;
      C = this.FReader.PeekChar();
      if ((C !== "-") && !this.IsDigit(C)) return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      Negative = false;
      FitsInInt64 = true;
      Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstNone;
      BufIndex = 0;
      Value = -1;
      do {
        if (BufIndex >= 255) throw this.EExpectedValue.$create("Create$2");
        C = this.FReader.NextChar();
        this.FPeekedNumber[BufIndex] = C;
        BufIndex += 1;
        var $tmp = C;
        if ($tmp === "-") {
          if (Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstNone) {
            Negative = true;
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstSign;
            continue;
          } else if (Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpE) {
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpSign;
            continue;
          } else throw this.EExpectedValue.$create("Create$2")}
         else if ($tmp === "+") {
          if (Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpE) {
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpSign;
            continue;
          } else throw this.EExpectedValue.$create("Create$2")}
         else if (($tmp === "e") || ($tmp === "E")) {
          if (Last in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDigit,$mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstFraction)) {
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpE;
            continue;
          } else throw this.EExpectedValue.$create("Create$2")}
         else if ($tmp === ".") {
          if (Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDigit) {
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDecimal;
            continue;
          } else throw this.EExpectedValue.$create("Create$2")}
         else {
          if (!this.IsDigit(C)) if (!this.IsLiteral(C)) {
            this.FReader.Backup(C);
            BufIndex -= 1;
            break;
          } else throw this.EExpectedValue.$create("Create$2");
          if (Last in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstSign,$mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstNone)) {
            Value = -(C.charCodeAt() - 48);
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDigit;
          } else if (Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDigit) {
            if (Value === 0) throw this.EExpectedValue.$create("Create$2");
            NewValue = (Value * 10) - (C.charCodeAt() - 48);
            FitsInInt64 = FitsInInt64 && ((Value > -900719925474099) || ((Value === -900719925474099) && (NewValue < Value)));
            Value = NewValue;
          } else if (Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDecimal) {
            Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstFraction}
           else if (Last in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpE,$mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpSign)) Last = $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpDigit;
        };
      } while (!false);
      if ((Last === $mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDigit) && FitsInInt64 && ((Value !== -9007199254740991) || Negative)) {
        if (Negative) {
          this.FPeekedInt64 = Value}
         else this.FPeekedInt64 = -Value;
        return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64;
      } else if (Last in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstDigit,$mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstFraction,$mod.TTMSFNCJSONReader.TTMSFNCJSONNumberState.jnstExpDigit)) {
        this.FPeekedNumber[BufIndex] = "\x00";
        return $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber;
      } else throw this.EExpectedValue.$create("Create$2");
      return Result;
    };
    this.InternalReadQuoted = function (BuildString) {
      var Result = "";
      var pc = "";
      var c = "";
      var s = "";
      Result = "";
      s = "";
      pc = "";
      while (!this.FReader.Eof()) {
        c = this.ReadChar();
        if ((c === '"') && (pc !== "\\")) {
          break}
         else s = s + c;
        pc = c;
      };
      if (BuildString) Result = s;
      return Result;
    };
    this.ReadQuoted = function () {
      var Result = "";
      Result = this.InternalReadQuoted(true);
      return Result;
    };
    this.SkipQuoted = function () {
      this.InternalReadQuoted(false);
    };
    this.SkipWhitespaceUntilEnd = function () {
      var Result = false;
      var s = "\x00";
      var p = 0;
      p = this.FReader.FReadStream.GetPosition();
      Result = true;
      s = this.ReadChar();
      do {
        if ((s > " ") || !(s.charCodeAt() in $impl.Wspace)) {
          this.FReader.FReadStream.SetPosition(p);
          return false;
        };
        s = this.ReadChar();
      } while (!this.FReader.Eof());
      this.FReader.FReadStream.SetPosition(p);
      return Result;
    };
    this.Create$1 = function (AStream) {
      pas.System.TObject.Create.call(this);
      this.FReader = $mod.TTMSFNCJSONStreamReader.$create("Create$1",[AStream]);
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      this.FStack[0] = $mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyDocument;
      this.FStackSize = 1;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FReader");
      pas.System.TObject.Destroy.call(this);
    };
    this.ReadBeginArray = function () {
      this.CheckState($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginArray);
      this.PushScope($mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyArray);
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
    };
    this.ReadEndArray = function () {
      this.CheckState($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndArray);
      this.FStackSize -= 1;
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
    };
    this.ReadBeginObject = function () {
      this.CheckState($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginObject);
      this.PushScope($mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyObject);
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
    };
    this.ReadEndObject = function () {
      this.CheckState($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndObject);
      this.FStackSize -= 1;
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
    };
    this.PeekName = function () {
      var Result = "";
      var p = 0;
      p = this.FReader.FReadStream.GetPosition();
      Result = this.ReadQuoted();
      this.FReader.FReadStream.SetPosition(p);
      return Result;
    };
    this.ReadName = function () {
      var Result = "";
      this.CheckState($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuotedName);
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      Result = this.ReadQuoted();
      return Result;
    };
    this.ReadString = function () {
      var Result = "";
      var $tmp = this.NextPeek();
      if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted) {
        Result = this.ReadQuoted()}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64) {
        Result = pas.SysUtils.IntToStr(this.FPeekedInt64)}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber) {
        Result = $impl.ArrayOfCharToString(this.FPeekedNumber.slice(0))}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered) {
        Result = this.FPeekedString}
       else {
        throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted]);
      };
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnescapeString(Result);
      return Result;
    };
    this.ReadBoolean = function () {
      var Result = false;
      var $tmp = this.NextPeek();
      if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstTrue) {
        Result = true}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstFalse) {
        Result = false}
       else {
        throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstTrue]);
      };
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      return Result;
    };
    this.ReadDouble = function () {
      var Result = 0.0;
      var $tmp = this.NextPeek();
      if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64) {
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
        return this.FPeekedInt64;
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber) {
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TryStrToFloatDot($impl.ArrayOfCharToString(this.FPeekedNumber.slice(0)),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }})) {
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
          return Result;
        } else this.FPeekedString = $impl.ArrayOfCharToString(this.FPeekedNumber.slice(0));
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted) {
        this.FPeekedString = this.ReadQuoted()}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered) {}
      else {
        throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber]);
      };
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.StrToFloatDot(this.FPeekedString);
      this.FPeekedString = "";
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      return Result;
    };
    this.ReadInt64 = function () {
      var Result = 0;
      var AsDouble = 0.0;
      var $tmp = this.NextPeek();
      if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64) {
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
        return this.FPeekedInt64;
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber) {
        if (pas.SysUtils.TryStrToInt64($impl.ArrayOfCharToString(this.FPeekedNumber.slice(0)),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }})) {
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
          return Result;
        } else this.FPeekedString = $impl.ArrayOfCharToString(this.FPeekedNumber.slice(0));
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted) {
        this.FPeekedString = this.ReadQuoted();
        if (pas.SysUtils.TryStrToInt64(this.FPeekedString,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }})) {
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
          return Result;
        };
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered) {}
      else {
        throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64]);
      };
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered;
      AsDouble = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.StrToFloatDot(this.FPeekedString);
      Result = Math.round(AsDouble);
      if (AsDouble !== Result) throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64]);
      this.FPeekedString = "";
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      return Result;
    };
    this.ReadInteger = function () {
      var Result = 0;
      var AsDouble = 0.0;
      var $tmp = this.NextPeek();
      if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64) {
        Result = this.FPeekedInt64 & 0xFFFFFFFF;
        if (Result !== this.FPeekedInt64) throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64]);
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
        return Result;
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber) {
        if (pas.SysUtils.TryStrToInt($impl.ArrayOfCharToString(this.FPeekedNumber.slice(0)),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }})) {
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
          return Result;
        } else this.FPeekedString = $impl.ArrayOfCharToString(this.FPeekedNumber.slice(0));
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted) {
        this.FPeekedString = this.ReadQuoted();
        if (pas.SysUtils.TryStrToInt(this.FPeekedString,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }})) {
          this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
          return Result;
        };
      } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered) {}
      else {
        throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64]);
      };
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered;
      AsDouble = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.StrToFloatDot(this.FPeekedString);
      Result = Math.round(AsDouble);
      if (AsDouble !== Result) throw this.EInvalidStateException.$create("Create$2",[$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64]);
      this.FPeekedString = "";
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      return Result;
    };
    this.SkipValue = function () {
      var Count = 0;
      Count = 0;
      do {
        var $tmp = this.NextPeek();
        if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginArray) {
          this.PushScope($mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyArray);
          Count += 1;
        } else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginObject) {
          this.PushScope($mod.TTMSFNCJSONReader.TTMSFNCJSONScope.jscEmptyObject);
          Count += 1;
        } else if (($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndArray) || ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndObject)) {
          this.FStackSize -= 1;
          Count -= 1;
        } else if (($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted) || ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuotedName)) this.SkipQuoted();
        this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
      } while (!(Count <= 0));
    };
    this.ReadNull = function () {
      this.CheckState($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNull);
      this.FPeeked = $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNone;
    };
    this.HasNext = function () {
      var Result = false;
      Result = !(this.NextPeek() in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndObject,$mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndArray));
      return Result;
    };
    this.HasInt64 = function () {
      var Result = false;
      Result = this.NextPeek() in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64);
      return Result;
    };
    this.HasDouble = function () {
      var Result = false;
      Result = this.NextPeek() in rtl.createSet($mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber);
      return Result;
    };
    this.HasBoolean = function () {
      var Result = false;
      Result = this.Peek() in rtl.createSet($mod.TTMSFNCJSONToken.jstoBoolean);
      return Result;
    };
    this.HasString = function () {
      var Result = false;
      Result = this.Peek() in rtl.createSet($mod.TTMSFNCJSONToken.jstoText);
      return Result;
    };
    this.Peek = function () {
      var Result = 0;
      var $tmp = this.NextPeek();
      if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginObject) {
        Result = $mod.TTMSFNCJSONToken.jstoBeginObject}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndObject) {
        Result = $mod.TTMSFNCJSONToken.jstoEndObject}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBeginArray) {
        Result = $mod.TTMSFNCJSONToken.jstoBeginArray}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEndArray) {
        Result = $mod.TTMSFNCJSONToken.jstoEndArray}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuotedName) {
        Result = $mod.TTMSFNCJSONToken.jstoName}
       else if (($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstTrue) || ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstFalse)) {
        Result = $mod.TTMSFNCJSONToken.jstoBoolean}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNull) {
        Result = $mod.TTMSFNCJSONToken.jstoNull}
       else if (($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstDoubleQuoted) || ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstBuffered)) {
        Result = $mod.TTMSFNCJSONToken.jstoText}
       else if (($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstInt64) || ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstNumber)) {
        Result = $mod.TTMSFNCJSONToken.jstoNumber}
       else if ($tmp === $mod.TTMSFNCJSONReader.TTMSFNCJSONState.jstEOF) {
        Result = $mod.TTMSFNCJSONToken.jstoEOF}
       else {
        Result = $mod.TTMSFNCJSONToken.jstoEOF;
      };
      return Result;
    };
    this.IsNull = function () {
      var Result = false;
      Result = this.Peek() === $mod.TTMSFNCJSONToken.jstoNull;
      return Result;
    };
    this.Eof = function () {
      var Result = false;
      Result = this.Peek() === $mod.TTMSFNCJSONToken.jstoEOF;
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$StaticArray("TTMSFNCJSONReader.FStack$a",{dims: [256], eltype: $mod.$rtti["TTMSFNCJSONReader.TTMSFNCJSONScope"]});
    $mod.$rtti.$StaticArray("TTMSFNCJSONReader.FPeekedNumber$a",{dims: [256], eltype: rtl.char});
  });
  $mod.$implcode = function () {
    $mod.$rtti.$Set("Wspace$a",{comptype: rtl.byte});
    $impl.Wspace = rtl.createSet(0x20,0xA,0xD,0x9,0xC);
    $impl.ArrayOfCharToString = function (AArray) {
      var Result = "";
      var I = 0;
      Result = "";
      for (var $l = 0, $end = rtl.length(AArray) - 1; $l <= $end; $l++) {
        I = $l;
        if (AArray[I] === "\x00") break;
        Result = Result + AArray[I];
      };
      return Result;
    };
  };
},["WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCJSONWriter",["System","Classes","SysUtils","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TTMSFNCJSONStreamWriter",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FStream = null;
      this.FWriteStream = null;
    };
    this.$final = function () {
      this.FStream = undefined;
      this.FWriteStream = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AStream) {
      this.FStream = AStream;
      this.FWriteStream = pas.Classes.TStringStream.$create("Create$3",["",pas.SysUtils.TEncoding.GetANSI(),true]);
      return this;
    };
    this.Destroy = function () {
      try {
        this.FWriteStream.SetPosition(0);
        this.FStream.CopyFrom(this.FWriteStream,this.FWriteStream.GetSize());
      } finally {
        rtl.free(this,"FWriteStream");
      };
      pas.System.TObject.Destroy.call(this);
    };
    this.Write = function (Value) {
      this.FWriteStream.WriteString(Value);
    };
  });
  rtl.createClass(this,"TTMSFNCJSONWriter",pas.System.TObject,function () {
    rtl.createClass(this,"ECannotWriteName",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Cannot write name in current Json scope");
        return this;
      };
    },"TTMSFNCJSONWriter.ECannotWriteName");
    rtl.createClass(this,"EMultipleRootNotAllowed",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Multiple root values not allowed");
        return this;
      };
    },"TTMSFNCJSONWriter.EMultipleRootNotAllowed");
    rtl.createClass(this,"EObjectOrArrayExpected",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Object or array expected as top-level value");
        return this;
      };
    },"TTMSFNCJSONWriter.EObjectOrArrayExpected");
    rtl.createClass(this,"EInvalidNesting",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Invalid nesting. Not all arrays/objects were properly closed.");
        return this;
      };
    },"TTMSFNCJSONWriter.EInvalidNesting");
    rtl.createClass(this,"EMissingValue",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Json value missing");
        return this;
      };
    },"TTMSFNCJSONWriter.EMissingValue");
    rtl.createClass(this,"ETooManyDepthLevels",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Maximum level of nested structured reached.");
        return this;
      };
    },"TTMSFNCJSONWriter.ETooManyDepthLevels");
    rtl.createClass(this,"EEmptyJson",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Json is still empty. Cannot perform operation.");
        return this;
      };
    },"TTMSFNCJSONWriter.EEmptyJson");
    rtl.createClass(this,"EEmptyName",pas.SysUtils.Exception,function () {
      this.Create$2 = function () {
        pas.SysUtils.Exception.Create$1.call(this,"Cannot write empty name");
        return this;
      };
    },"TTMSFNCJSONWriter.EEmptyName");
    this.TTMSFNCJSONScope = {"0": "jscEmptyDocument", jscEmptyDocument: 0, "1": "jscEmptyArray", jscEmptyArray: 1, "2": "jscEmptyObject", jscEmptyObject: 2, "3": "jscNonEmptyDocument", jscNonEmptyDocument: 3, "4": "jscNonEmptyArray", jscNonEmptyArray: 4, "5": "jscNonEmptyObject", jscNonEmptyObject: 5, "6": "jscDanglingName", jscDanglingName: 6};
    $mod.$rtti.$Enum("TTMSFNCJSONWriter.TTMSFNCJSONScope",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TTMSFNCJSONScope});
    this.MaxStackSize = 255;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FWriter = null;
      this.FStack = rtl.arraySetLength(null,0,256);
      this.FStackSize = 0;
      this.FIndent = "";
      this.FSeparator = "";
      this.FDeferredName = "";
    };
    this.$final = function () {
      this.FWriter = undefined;
      this.FStack = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetIndentLength = function (Value) {
      if (Value <= 0) {
        this.FIndent = "";
        this.FSeparator = ":";
      } else {
        this.FIndent = pas.System.StringOfChar(" ",Value);
        this.FSeparator = ": ";
      };
    };
    this.GetIndentLength = function () {
      var Result = 0;
      Result = this.FIndent.length;
      return Result;
    };
    this.OpenItem = function (Empty, OpenBracket) {
      var Result = null;
      this.BeforeValue(true);
      this.PushScope(Empty);
      this.FWriter.Write(OpenBracket);
      Result = this;
      return Result;
    };
    this.CloseItem = function (Empty, NonEmpty, CloseBracket) {
      var Result = null;
      var Context = 0;
      Context = this.PeekScope();
      if (!(Context in rtl.createSet(Empty,NonEmpty))) throw this.EInvalidNesting.$create("Create$2");
      if (this.FDeferredName !== "") throw this.EMissingValue.$create("Create$2");
      this.FStackSize -= 1;
      if (Context === NonEmpty) this.NewLine();
      this.FWriter.Write(CloseBracket);
      Result = this;
      return Result;
    };
    this.PushScope = function (Scope) {
      if (this.FStackSize > 255) throw this.ETooManyDepthLevels.$create("Create$2");
      this.FStack[this.FStackSize] = Scope;
      this.FStackSize += 1;
    };
    this.PeekScope = function () {
      var Result = 0;
      if (this.FStackSize === 0) throw this.EEmptyJson.$create("Create$2");
      Result = this.FStack[this.FStackSize - 1];
      return Result;
    };
    this.ReplaceTop = function (Scope) {
      if (this.FStackSize === 0) throw this.EEmptyJson.$create("Create$2");
      this.FStack[this.FStackSize - 1] = Scope;
    };
    this.WriteDeferredName = function () {
      if (this.FDeferredName !== "") {
        this.BeforeName();
        this.InternalWriteString(this.FDeferredName);
        this.FDeferredName = "";
      };
    };
    this.InternalWriteString = function (Value) {
      this.FWriter.Write('"');
      this.FWriter.Write(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.EscapeString(Value));
      this.FWriter.Write('"');
    };
    this.NewLine = function () {
      var I = 0;
      if (this.FIndent !== "") {
        this.FWriter.Write("\r\n");
        for (var $l = 1, $end = this.FStackSize - 1; $l <= $end; $l++) {
          I = $l;
          this.FWriter.Write(this.FIndent);
        };
      };
    };
    this.BeforeName = function () {
      var $tmp = this.PeekScope();
      if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyObject) {
        this.FWriter.Write(",")}
       else if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyObject) {}
      else {
        throw this.ECannotWriteName.$create("Create$2");
      };
      this.NewLine();
      this.ReplaceTop($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscDanglingName);
    };
    this.BeforeValue = function (Root) {
      var $tmp = this.PeekScope();
      if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyDocument) {
        throw this.EMultipleRootNotAllowed.$create("Create$2")}
       else if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyDocument) {
        if (!Root) throw this.EObjectOrArrayExpected.$create("Create$2");
        this.ReplaceTop($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyDocument);
      } else if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyArray) {
        this.ReplaceTop($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyArray);
        this.NewLine();
      } else if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyArray) {
        this.FWriter.Write(",");
        this.NewLine();
      } else if ($tmp === $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscDanglingName) {
        this.FWriter.Write(this.FSeparator);
        this.ReplaceTop($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyObject);
      } else {
        throw this.EInvalidNesting.$create("Create$2");
      };
    };
    this.Create$1 = function (AStream) {
      pas.System.TObject.Create.call(this);
      this.FWriter = $mod.TTMSFNCJSONStreamWriter.$create("Create$1",[AStream]);
      this.FSeparator = ":";
      this.PushScope($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyDocument);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FWriter");
      pas.System.TObject.Destroy.call(this);
    };
    this.WriteBeginArray = function () {
      var Result = null;
      this.WriteDeferredName();
      Result = this.OpenItem($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyArray,"[");
      return Result;
    };
    this.WriteEndArray = function () {
      var Result = null;
      Result = this.CloseItem($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyArray,$mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyArray,"]");
      return Result;
    };
    this.WriteBeginObject = function () {
      var Result = null;
      this.WriteDeferredName();
      Result = this.OpenItem($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyObject,"{");
      return Result;
    };
    this.WriteEndObject = function () {
      var Result = null;
      Result = this.CloseItem($mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscEmptyObject,$mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyObject,"}");
      return Result;
    };
    this.WriteName = function (Name) {
      var Result = null;
      if (Name === "") throw this.EEmptyName.$create("Create$2");
      if (this.FDeferredName !== "") throw this.EMissingValue.$create("Create$2");
      if (this.FStackSize === 0) throw this.EEmptyJson.$create("Create$2");
      this.FDeferredName = Name;
      Result = this;
      return Result;
    };
    this.WriteString = function (Value) {
      var Result = null;
      this.WriteDeferredName();
      this.BeforeValue(false);
      this.InternalWriteString(Value);
      Result = this;
      return Result;
    };
    this.WriteRawString = function (Value) {
      var Result = null;
      this.WriteDeferredName();
      this.BeforeValue(false);
      this.FWriter.Write('"');
      this.FWriter.Write(Value);
      this.FWriter.Write('"');
      Result = this;
      return Result;
    };
    this.WriteBoolean = function (Value) {
      var Result = null;
      this.WriteDeferredName();
      this.BeforeValue(false);
      if (Value) {
        this.FWriter.Write("true")}
       else this.FWriter.Write("false");
      Result = this;
      return Result;
    };
    this.WriteNull = function () {
      var Result = null;
      this.WriteDeferredName();
      this.BeforeValue(false);
      this.FWriter.Write("null");
      Result = this;
      return Result;
    };
    this.WriteDouble = function (Value) {
      var Result = null;
      this.WriteDeferredName();
      this.BeforeValue(false);
      this.FWriter.Write(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FloatToStrDot(Value));
      Result = this;
      return Result;
    };
    this.WriteInteger = function (Value) {
      var Result = null;
      this.WriteDeferredName();
      this.BeforeValue(false);
      this.FWriter.Write(pas.SysUtils.IntToStr(Value));
      Result = this;
      return Result;
    };
    this.Close = function () {
      if ((this.FStackSize > 1) || ((this.FStackSize === 1) && (this.PeekScope() !== $mod.TTMSFNCJSONWriter.TTMSFNCJSONScope.jscNonEmptyDocument))) throw this.EInvalidNesting.$create("Create$2");
    };
    var $r = this.$rtti;
    $mod.$rtti.$StaticArray("TTMSFNCJSONWriter.FStack$a",{dims: [256], eltype: $mod.$rtti["TTMSFNCJSONWriter.TTMSFNCJSONScope"]});
  });
},["WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCPersistence",["System","Generics.Collections","Classes","TypInfo","Variants","SysUtils","WEBLib.TMSFNCTypes","WEBLib.TMSFNCJSONReader","WEBLib.TMSFNCJSONWriter","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.createInterface(this,"ITMSFNCPersistence","{363F04AF-B8A7-4C47-A2D6-8ED9C44CEFF6}",["SaveSettingsToFile","LoadSettingsFromFile","SaveSettingsToStream","LoadSettingsFromStream","CanSaveProperty","CanLoadProperty"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("SaveSettingsToFile",0,[["AFileName",rtl.string],["AAppearanceOnly",rtl.boolean]]);
    $r.addMethod("LoadSettingsFromFile",0,[["AFileName",rtl.string]]);
    $r.addMethod("SaveSettingsToStream",0,[["AStream",pas.Classes.$rtti["TStream"]],["AAppearanceOnly",rtl.boolean]]);
    $r.addMethod("LoadSettingsFromStream",0,[["AStream",pas.Classes.$rtti["TStream"]]]);
    $r.addMethod("CanSaveProperty",1,[["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]]],2,rtl.boolean);
    $r.addMethod("CanLoadProperty",1,[["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]]],2,rtl.boolean);
  });
  rtl.createInterface(this,"ITMSFNCCustomReadWriteIO","{3BC2E91F-A937-47EE-A4CB-6F705B154901}",["CustomWriteProperty","CustomReadProperty"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("CustomWriteProperty",0,[["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AWriter",pas["WEBLib.TMSFNCJSONWriter"].$rtti["TTMSFNCJSONWriter"]],["ACanWrite",rtl.boolean,1]]);
    $r.addMethod("CustomReadProperty",0,[["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AReader",pas["WEBLib.TMSFNCJSONReader"].$rtti["TTMSFNCJSONReader"]],["ACanRead",rtl.boolean,1]]);
  });
  rtl.createInterface(this,"ITMSFNCBaseListIO","{FAB1D21E-D798-4CE0-B17B-9D75E4456AB4}",["GetItemClass"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetItemClass",1,[],2,pas.System.$rtti["TClass"]);
  });
  rtl.createInterface(this,"ITMSFNCBasePersistenceIO","{91DEAFC3-8932-45F4-A3ED-5AAA0C0E9250}",["CreateObject"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("CreateObject",1,[["AClassName",rtl.string,2],["ABaseClass",pas.System.$rtti["TClass"],2]],2,pas.System.$rtti["TObject"]);
  });
  rtl.createInterface(this,"ITMSFNCBaseCollectionIO","{90FDF257-7362-411D-B7F6-E2BEE2265016}",["AddItem"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("AddItem",1,[["AObject",pas.System.$rtti["TObject"],2]],2,pas.Classes.$rtti["TCollectionItem"]);
  });
  rtl.createInterface(this,"ITMSFNCPersistenceIO","{11B625F8-447A-4AE5-BB88-5ECDEA979AF7}",["NeedsObjectReference","GetObjectReference","FindObject","FixOwners"],this.ITMSFNCBasePersistenceIO,function () {
    var $r = this.$rtti;
    $r.addMethod("NeedsObjectReference",1,[["AClass",pas.System.$rtti["TClass"],2]],2,rtl.boolean);
    $r.addMethod("GetObjectReference",1,[["AObject",pas.System.$rtti["TObject"],2]],2,rtl.string);
    $r.addMethod("FindObject",1,[["AReference",rtl.string,2]],2,pas.System.$rtti["TObject"]);
    $r.addMethod("FixOwners",0,[["AObject",pas.System.$rtti["TObject"],2],["AObjectList",pas.System.$rtti["TObject"],2]]);
  });
  rtl.createClass(this,"ETMSFNCReaderException",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"TTMSFNCStringObjectDictionary",pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$String$$TObject,function () {
  });
  rtl.createClass(this,"TTMSFNCIntegerObjectDictionary",pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$Longint$$TObject,function () {
  });
  rtl.createClass(this,"TTMSFNCIntegerIntegerDictionary",pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$Longint$$Longint,function () {
  });
  rtl.createClass(this,"TTMSFNCIntegerBooleanDictionary",pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$Longint$$Boolean,function () {
  });
  rtl.createClass(this,"TTMSFNCIntegerDoubleDictionary",pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$Longint$$Double,function () {
  });
  rtl.createClass(this,"TTMSFNCObjectList",pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TObject,function () {
  });
  rtl.createClass(this,"TTMSFNCStringList",pas["Generics.Collections"].TList$$$G$$generics$collections$$String,function () {
  });
  rtl.createClass(this,"TTMSFNCIntegerList",pas["Generics.Collections"].TList$$$G$$generics$collections$$Longint,function () {
  });
  rtl.createClass(this,"TTMSFNCDoubleList",pas["Generics.Collections"].TList$$$G$$generics$collections$$Double,function () {
  });
  this.$rtti.$DynArray("TTMSFNCObjectArray",{eltype: pas.System.$rtti["TObject"]});
  this.$rtti.$MethodVar("TTMSFNCWriterCustomWritePropertyEvent",{procsig: rtl.newTIProcSig([["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AWriter",pas["WEBLib.TMSFNCJSONWriter"].$rtti["TTMSFNCJSONWriter"]],["ACanWrite",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCWriterCustomIsAssignablePropertyEvent",{procsig: rtl.newTIProcSig([["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["AIsAssignable",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$DynArray("TTMSFNCExcludePropertyListArray",{eltype: rtl.string});
  rtl.createClass(this,"TTMSFNCWriter",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FWriter = null;
      this.FWriterRef = false;
      this.FIOReference = null;
      this.FOnCustomWriteProperty = null;
      this.FRootObject = null;
      this.FExcludeProperties = [];
      this.FOnCustomIsAssignableProperty = null;
    };
    this.$final = function () {
      this.FWriter = undefined;
      this.FIOReference = undefined;
      this.FOnCustomWriteProperty = undefined;
      this.FRootObject = undefined;
      this.FExcludeProperties = undefined;
      this.FOnCustomIsAssignableProperty = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetRootObject = function (Value) {
      this.FRootObject = Value;
      $mod.TTMSFNCPersistence.FRootObject = this.FRootObject;
    };
    this.SetExcludeProperties = function (Value) {
      this.FExcludeProperties = rtl.arrayRef(Value);
      $mod.TTMSFNCPersistence.FExcludeProperties = rtl.arrayRef(this.FExcludeProperties);
    };
    this.SetIOReference = function (Value) {
      this.FIOReference = Value;
      $mod.TTMSFNCPersistence.FIOReference = this.FIOReference;
    };
    this.WritePropInfoValue = function (AInstance, APropInfo) {
      var cn = "";
      var pName = "";
      var en = "";
      var k = 0;
      var p = null;
      var o = null;
      var v = pas.System.TMethod.$new();
      var c = 0;
      var vr = undefined;
      if ($mod.TTMSFNCPersistence.IsWriteOnly(APropInfo)) {
        this.FWriter.WriteNull();
        return;
      };
      o = AInstance;
      p = APropInfo;
      k = $mod.TTMSFNCPersistence.GetPropInfoType(p);
      pName = $mod.TTMSFNCPersistence.GetPropInfoName(p);
      var $tmp = k;
      if ($tmp === pas.System.TTypeKind.tkInteger) {
        cn = $mod.TTMSFNCPersistence.GetPropInfoTypeName(p);
        if ((cn === "TAlphaColor") || (cn === "TColor") || (cn === "TGraphicsColor")) {
          if (pas.TypInfo.GetOrdProp$1(o,p) === -1) {
            this.FWriter.WriteString("gcNull")}
           else {
            c = pas.TypInfo.GetOrdProp$1(o,p);
            this.FWriter.WriteString($impl.ColorToHTMLEx(c));
          };
        } else this.FWriter.WriteInteger(pas.TypInfo.GetOrdProp$1(o,p));
      } else if (($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkString)) {
        this.FWriter.WriteString(pas.TypInfo.GetStrProp$1(o,p))}
       else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
        if ($mod.TTMSFNCPersistence.GetPropInfoDataTypeInfo(p) === rtl.boolean) {
          this.FWriter.WriteBoolean(pas.TypInfo.GetOrdProp$1(o,p) != 0)}
         else this.FWriter.WriteInteger(pas.TypInfo.GetOrdProp$1(o,p))}
       else if ($tmp === pas.System.TTypeKind.tkBool) {
        this.FWriter.WriteBoolean(pas.TypInfo.GetBoolProp$1(o,p))}
       else if ($tmp === pas.System.TTypeKind.tkDouble) {
        this.FWriter.WriteDouble(pas.TypInfo.GetFloatProp$1(o,p))}
       else if ($tmp === pas.System.TTypeKind.tkSet) {
        this.FWriter.WriteInteger(pas.TypInfo.GetOrdProp$1(o,p))}
       else if ($tmp === pas.System.TTypeKind.tkJSValue) {
        vr = pas.TypInfo.GetJSValueProp$3(o,p);
        if (pas.JS.isUndefined(vr) || pas.JS.isNull(vr)) {
          this.FWriter.WriteNull()}
         else if (rtl.isNumber(vr)) {
          if (pas.System.Frac(rtl.getNumber(vr)) === 0) {
            this.FWriter.WriteInteger(rtl.trunc(vr))}
           else this.FWriter.WriteDouble(rtl.getNumber(vr));
        } else if (pas.JS.isBoolean(vr)) {
          this.FWriter.WriteBoolean(!(vr == false))}
         else if (rtl.isString(vr)) {
          this.FWriter.WriteString("" + vr)}
         else this.FWriter.WriteNull();
      } else if ($tmp === pas.System.TTypeKind.tkMethod) {
        v.$assign(pas.TypInfo.GetMethodProp(o,p));
        if (v.Code === null) {
          this.FWriter.WriteNull()}
         else {
          if ($mod.TTMSFNCPersistence.FRootObject != null) {
            this.FWriter.WriteString($mod.TTMSFNCPersistence.FRootObject.$class.MethodName(v.Code))}
           else this.FWriter.WriteNull();
        };
      } else {
        en = $mod.TTMSFNCPersistence.GetEnumName(pas.System.$rtti["TTypeKind"],k);
        this.FWriter.WriteNull();
      };
      if (pas["WEBLib.Graphics"].TFont.isPrototypeOf(o) && (pName === "Size")) {
        this.FWriter.WriteName("IsFMX");
        this.FWriter.WriteBoolean(false);
      };
    };
    this.WriteProperties = function (AObject) {
      var ci = null;
      var a = [];
      var I = 0;
      if (AObject != null) {
        ci = AObject.$rtti;
        try {
          a = pas.TypInfo.GetPropList(ci,pas.System.tkAny,true);
          for (var $l = 0, $end = rtl.length(a) - 1; $l <= $end; $l++) {
            I = $l;
            this.WriteProperty(AObject,a[I]);
          };
        } finally {
        };
      };
    };
    this.WriteProperty = function (AObject, AProp) {
      var pName = "";
      var k = 0;
      var b = false;
      var a = false;
      var ap = false;
      var p = null;
      var crw = null;
      var o = null;
      try {
        if (!(AProp != null)) return;
        pName = $mod.TTMSFNCPersistence.GetPropInfoName(AProp);
        k = $mod.TTMSFNCPersistence.GetPropInfoType(AProp);
        b = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(pName,$mod.TTMSFNCPersistence.FExcludeProperties) === -1;
        if (pas.SysUtils.Supports$3(AObject,$mod.ITMSFNCPersistence.$guid,{get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }})) b = p.CanSaveProperty(AObject,pName,k);
        if (b) {
          a = true;
          if (this.FOnCustomWriteProperty != null) this.FOnCustomWriteProperty(AObject,pName,k,this.FWriter,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }});
          if (a && pas.SysUtils.Supports$3(AObject,$mod.ITMSFNCCustomReadWriteIO.$guid,{get: function () {
              return crw;
            }, set: function (v) {
              crw = v;
            }})) crw.CustomWriteProperty(AObject,pName,k,this.FWriter,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }});
          if (a) {
            this.FWriter.WriteName(pName);
            if (k in rtl.createSet(pas.System.TTypeKind.tkClass)) {
              o = pas.TypInfo.GetObjectProp(AObject,pName);
              ap = $mod.TTMSFNCPersistence.IsAssignableProperty(AObject,AProp);
              if (this.FOnCustomIsAssignableProperty != null) this.FOnCustomIsAssignableProperty(AObject,pName,{get: function () {
                  return ap;
                }, set: function (v) {
                  ap = v;
                }});
              if (ap) {
                if (pas.Classes.TComponent.isPrototypeOf(o)) {
                  this.FWriter.WriteString(rtl.as(o,pas.Classes.TComponent).FName)}
                 else this.FWriter.WriteString("");
              } else this.WriteObject(o);
            } else this.WritePropInfoValue(AObject,AProp);
          };
        };
      } finally {
        rtl._Release(p);
        rtl._Release(crw);
      };
    };
    this.WriteGenericObjectList = function (AList) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = AList.FLength - 1; $l <= $end; $l++) {
        I = $l;
        this.WriteSingleObject(AList.GetItem(I));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericStringList = function (AList) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = AList.FLength - 1; $l <= $end; $l++) {
        I = $l;
        this.FWriter.WriteString(AList.GetItem(I));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericIntegerList = function (AList) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = AList.FLength - 1; $l <= $end; $l++) {
        I = $l;
        this.FWriter.WriteInteger(AList.GetItem(I));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericDoubleList = function (AList) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = AList.FLength - 1; $l <= $end; $l++) {
        I = $l;
        this.FWriter.WriteDouble(AList.GetItem(I));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteStrings = function (AList) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = AList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FWriter.WriteString(AList.Get(I));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericStringObjectDictionary = function (ADictionary) {
      var key = "";
      this.FWriter.WriteBeginArray();
      var $in = ADictionary.GetKeys().GetEnumerator$1();
      try {
        while ($in.MoveNext$1()) {
          key = $in.GetCurrent();
          this.FWriter.WriteBeginObject();
          this.FWriter.WriteName(key);
          this.WriteSingleObject(ADictionary.GetItem(key));
          this.FWriter.WriteEndObject();
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericIntegerObjectDictionary = function (ADictionary) {
      var key = 0;
      this.FWriter.WriteBeginArray();
      var $in = ADictionary.GetKeys().GetEnumerator$1();
      try {
        while ($in.MoveNext$1()) {
          key = $in.GetCurrent();
          this.FWriter.WriteBeginObject();
          this.FWriter.WriteName(pas.SysUtils.IntToStr(key));
          this.WriteSingleObject(ADictionary.GetItem(key));
          this.FWriter.WriteEndObject();
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericIntegerIntegerDictionary = function (ADictionary) {
      var key = 0;
      this.FWriter.WriteBeginArray();
      var $in = ADictionary.GetKeys().GetEnumerator$1();
      try {
        while ($in.MoveNext$1()) {
          key = $in.GetCurrent();
          this.FWriter.WriteBeginObject();
          this.FWriter.WriteName(pas.SysUtils.IntToStr(key));
          this.FWriter.WriteInteger(ADictionary.GetItem(key));
          this.FWriter.WriteEndObject();
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericIntegerBooleanDictionary = function (ADictionary) {
      var key = 0;
      this.FWriter.WriteBeginArray();
      var $in = ADictionary.GetKeys().GetEnumerator$1();
      try {
        while ($in.MoveNext$1()) {
          key = $in.GetCurrent();
          this.FWriter.WriteBeginObject();
          this.FWriter.WriteName(pas.SysUtils.IntToStr(key));
          this.FWriter.WriteBoolean(ADictionary.GetItem(key));
          this.FWriter.WriteEndObject();
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteGenericIntegerDoubleDictionary = function (ADictionary) {
      var key = 0;
      this.FWriter.WriteBeginArray();
      var $in = ADictionary.GetKeys().GetEnumerator$1();
      try {
        while ($in.MoveNext$1()) {
          key = $in.GetCurrent();
          this.FWriter.WriteBeginObject();
          this.FWriter.WriteName(pas.SysUtils.IntToStr(key));
          this.FWriter.WriteDouble(ADictionary.GetItem(key));
          this.FWriter.WriteEndObject();
        }
      } finally {
        $in = rtl.freeLoc($in)
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteCollection = function (ACollection) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = ACollection.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.WriteSingleObject(ACollection.GetItem(I));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteList = function (AList) {
      var I = 0;
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = AList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.WriteSingleObject(rtl.getObject(AList.Get(I)));
      };
      this.FWriter.WriteEndArray();
    };
    this.WriteBitmap = function (ABitmap) {
      if (pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(ABitmap)) {
        this.FWriter.WriteString("");
        return;
      };
      this.FWriter.WriteString(ABitmap.GetData());
    };
    this.WriteSingleObject = function (AObject) {
      this.FWriter.WriteBeginObject();
      if ($mod.TTMSFNCPersistence.ClassTypeVariable !== "") {
        this.FWriter.WriteName($mod.TTMSFNCPersistence.ClassTypeVariable);
        this.FWriter.WriteString(AObject.$classname);
      };
      this.WriteProperties(AObject);
      this.FWriter.WriteEndObject();
    };
    this.WriteObject = function (AObject) {
      var b = null;
      try {
        if (AObject === null) {
          this.FWriter.WriteNull()}
         else {
          if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"String")) {
            this.WriteGenericStringList(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"Integer")) {
            this.WriteGenericIntegerList(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"Double")) {
            this.WriteGenericDoubleList(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"")) {
            this.WriteGenericObjectList(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericStringDictionary(AObject.$class.ClassType())) {
            if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeObject(AObject.$class.ClassType())) {
              this.WriteGenericStringObjectDictionary(AObject)}
             else this.FWriter.WriteNull();
          } else if ($mod.TTMSFNCPersistence.IsGenericIntegerDictionary(AObject.$class.ClassType())) {
            if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeObject(AObject.$class.ClassType())) {
              this.WriteGenericIntegerObjectDictionary(AObject)}
             else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeInteger(AObject.$class.ClassType())) {
              this.WriteGenericIntegerIntegerDictionary(AObject)}
             else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeBoolean(AObject.$class.ClassType())) {
              this.WriteGenericIntegerBooleanDictionary(AObject)}
             else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeDouble(AObject.$class.ClassType())) {
              this.WriteGenericIntegerDoubleDictionary(AObject)}
             else this.FWriter.WriteNull();
          } else if ($mod.TTMSFNCPersistence.IsList(AObject.$class.ClassType())) {
            this.WriteList(AObject)}
           else if ($mod.TTMSFNCPersistence.IsCollection(AObject.$class.ClassType())) {
            this.WriteCollection(AObject)}
           else if ($mod.TTMSFNCPersistence.IsBitmap(AObject.$class.ClassType())) {
            this.WriteBitmap(AObject)}
           else if ($mod.TTMSFNCPersistence.IsDescendingClass(AObject.$class.ClassType(),["TStrings"])) {
            this.WriteStrings(AObject)}
           else {
            if ((this.FIOReference != null) && pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCPersistenceIO.$guid,{get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }})) {
              if (b.NeedsObjectReference(AObject.$class.ClassType())) {
                this.FWriter.WriteString(b.GetObjectReference(AObject))}
               else this.WriteSingleObject(AObject);
            } else this.WriteSingleObject(AObject);
          };
        };
      } finally {
        rtl._Release(b);
      };
    };
    this.Create$1 = function (AStream) {
      this.FWriter = pas["WEBLib.TMSFNCJSONWriter"].TTMSFNCJSONWriter.$create("Create$1",[AStream]);
      this.FWriterRef = false;
      return this;
    };
    this.Create$2 = function (AWriter) {
      this.FWriter = AWriter;
      this.FWriterRef = true;
      return this;
    };
    this.Destroy = function () {
      if (this.FWriterRef) {
        this.FWriter = null}
       else rtl.free(this,"FWriter");
      pas.System.TObject.Destroy.call(this);
    };
    this.Write = function (AObject) {
      this.WriteObject(AObject);
    };
    this.WriteArray = function (AName, AArray) {
      var I = 0;
      this.FWriter.WriteBeginObject();
      this.FWriter.WriteName(AName);
      this.FWriter.WriteBeginArray();
      for (var $l = 0, $end = rtl.length(AArray) - 1; $l <= $end; $l++) {
        I = $l;
        this.WriteSingleObject(AArray[I]);
      };
      this.FWriter.WriteEndArray();
      this.FWriter.WriteEndObject();
    };
  });
  this.$rtti.$MethodVar("TTMSFNCReaderCustomReadPropertyEvent",{procsig: rtl.newTIProcSig([["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AReader",pas["WEBLib.TMSFNCJSONReader"].$rtti["TTMSFNCJSONReader"]],["ACanRead",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCObjectReference",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.Instance = null;
      this.Prop = null;
      this.Id = "";
    };
    this.$final = function () {
      this.Instance = undefined;
      this.Prop = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AInstance, AProp, AId) {
      this.Instance = AInstance;
      this.Prop = AProp;
      this.Id = AId;
      return this;
    };
  });
  rtl.createClass(this,"TTMSFNCReader",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FReaderRef = false;
      this.FReferences = null;
      this.FReader = null;
      this.FIOReference = null;
      this.FOnCustomReadProperty = null;
      this.FRootObject = null;
      this.FExcludeProperties = [];
      this.FOnCustomIsAssignableProperty = null;
    };
    this.$final = function () {
      this.FReferences = undefined;
      this.FReader = undefined;
      this.FIOReference = undefined;
      this.FOnCustomReadProperty = undefined;
      this.FRootObject = undefined;
      this.FExcludeProperties = undefined;
      this.FOnCustomIsAssignableProperty = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.ReadSingleObject = function (ABaseClass) {
      var Result = null;
      var cn = "";
      var b = null;
      var p = null;
      try {
        this.FReader.ReadBeginObject();
        if ($mod.TTMSFNCPersistence.ClassTypeVariable !== "") {
          if (!this.FReader.HasNext() || (this.FReader.ReadName() !== $mod.TTMSFNCPersistence.ClassTypeVariable)) throw $mod.ETMSFNCReaderException.$create("Create$1",['"' + $mod.TTMSFNCPersistence.ClassTypeVariable + '" property not found in Object descriptor.']);
          cn = this.FReader.ReadString();
        };
        if (cn === "") cn = ABaseClass.$classname;
        Result = null;
        if (this.FIOReference != null) {
          if (pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCBasePersistenceIO.$guid,{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }})) {
            Result = b.CreateObject(cn,ABaseClass)}
           else if (pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCPersistenceIO.$guid,{get: function () {
              return p;
            }, set: function (v) {
              p = v;
            }})) Result = p.CreateObject(cn,ABaseClass);
        };
        if (!(Result != null)) Result = $mod.TTMSFNCPersistence.CreateObject(cn,ABaseClass);
        try {
          this.ReadProperties(Result);
          this.FReader.ReadEndObject();
        } catch ($e) {
          Result = rtl.freeLoc(Result);
          throw $e;
        };
      } finally {
        rtl._Release(b);
        rtl._Release(p);
      };
      return Result;
    };
    this.SetRootObject = function (Value) {
      this.FRootObject = Value;
      $mod.TTMSFNCPersistence.FRootObject = this.FRootObject;
    };
    this.SetExcludeProperties = function (Value) {
      this.FExcludeProperties = rtl.arrayRef(Value);
      $mod.TTMSFNCPersistence.FExcludeProperties = rtl.arrayRef(this.FExcludeProperties);
    };
    this.SetIOReference = function (Value) {
      this.FIOReference = Value;
      $mod.TTMSFNCPersistence.FIOReference = this.FIOReference;
    };
    this.ReadSingleObject$1 = function (AObject) {
      this.FReader.ReadBeginObject();
      if ($mod.TTMSFNCPersistence.ClassTypeVariable !== "") {
        if (!this.FReader.HasNext() || (this.FReader.ReadName() !== $mod.TTMSFNCPersistence.ClassTypeVariable)) throw $mod.ETMSFNCReaderException.$create("Create$1",['"' + $mod.TTMSFNCPersistence.ClassTypeVariable + '" property not found in Object descriptor.']);
        this.FReader.ReadString();
      };
      try {
        this.ReadProperties(AObject);
        this.FReader.ReadEndObject();
      } catch ($e) {
        throw $e;
      };
    };
    this.ReadProperties = function (AObject) {
      var Prop = null;
      while (this.FReader.HasNext()) {
        if (!this.FReader.IsNull()) {
          Prop = null;
          if (AObject != null) Prop = pas.TypInfo.GetPropInfo$2(AObject,this.FReader.ReadName());
          if (Prop != null) {
            this.ReadProperty(AObject,Prop)}
           else this.FReader.SkipValue();
        } else this.FReader.SkipValue();
      };
    };
    this.ReadProperty = function (AObject, AProp) {
      var pName = "";
      var ct = null;
      var b = false;
      var p = null;
      var pio = null;
      var k = 0;
      var a = false;
      var ap = false;
      var o = null;
      var n = "";
      var crw = null;
      try {
        if (!(AProp != null)) return;
        k = $mod.TTMSFNCPersistence.GetPropInfoType(AProp);
        pName = $mod.TTMSFNCPersistence.GetPropInfoName(AProp);
        b = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(pName,$mod.TTMSFNCPersistence.FExcludeProperties) === -1;
        if (pas.SysUtils.Supports$3(AObject,$mod.ITMSFNCPersistence.$guid,{get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }})) b = p.CanLoadProperty(AObject,pName,k);
        if (b) {
          a = true;
          if (this.FOnCustomReadProperty != null) this.FOnCustomReadProperty(AObject,pName,k,this.FReader,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }});
          if (a && pas.SysUtils.Supports$3(AObject,$mod.ITMSFNCCustomReadWriteIO.$guid,{get: function () {
              return crw;
            }, set: function (v) {
              crw = v;
            }})) crw.CustomReadProperty(AObject,pName,k,this.FReader,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }});
          if (a) {
            if (k in rtl.createSet(pas.System.TTypeKind.tkClass)) {
              ct = $mod.TTMSFNCPersistence.GetPropInfoDataTypeInfoClassType(AProp);
              if ($mod.TTMSFNCPersistence.IsGenericList(ct,"String")) {
                this.ReadGenericStringList(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsGenericList(ct,"Double")) {
                this.ReadGenericDoubleList(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsGenericList(ct,"Integer")) {
                this.ReadGenericIntegerList(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsGenericList(ct,"")) {
                this.ReadGenericObjectList(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsGenericStringDictionary(ct)) {
                if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeObject(ct)) {
                  this.ReadGenericStringObjectDictionary(pas.TypInfo.GetObjectProp(AObject,pName))}
                 else this.FReader.SkipValue();
              } else if ($mod.TTMSFNCPersistence.IsGenericIntegerDictionary(ct)) {
                if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeObject(ct)) {
                  this.ReadGenericIntegerObjectDictionary(pas.TypInfo.GetObjectProp(AObject,pName))}
                 else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeInteger(ct)) {
                  this.ReadGenericIntegerIntegerDictionary(pas.TypInfo.GetObjectProp(AObject,pName))}
                 else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeBoolean(ct)) {
                  this.ReadGenericIntegerBooleanDictionary(pas.TypInfo.GetObjectProp(AObject,pName))}
                 else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeDouble(ct)) {
                  this.ReadGenericIntegerDoubleDictionary(pas.TypInfo.GetObjectProp(AObject,pName))}
                 else this.FReader.SkipValue();
              } else if ($mod.TTMSFNCPersistence.IsList(ct)) {
                this.ReadList(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsCollection(ct)) {
                this.ReadCollection(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsBitmap(ct)) {
                this.ReadBitmap(pas.TypInfo.GetObjectProp(AObject,pName))}
               else if ($mod.TTMSFNCPersistence.IsDescendingClass(ct,["TStrings"])) {
                this.ReadStrings(pas.TypInfo.GetObjectProp(AObject,pName))}
               else {
                a = false;
                if ((this.FIOReference != null) && pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCPersistenceIO.$guid,{get: function () {
                    return pio;
                  }, set: function (v) {
                    pio = v;
                  }})) a = pio.NeedsObjectReference(ct);
                if (a) {
                  if (this.FReader.IsNull()) {
                    this.FReader.ReadNull();
                    pas.TypInfo.SetObjectProp(AObject,pName,null);
                  } else this.FReferences.Add($mod.TTMSFNCObjectReference.$create("Create$1",[AObject,AProp,this.FReader.ReadString()]));
                } else {
                  o = pas.TypInfo.GetObjectProp(AObject,pName);
                  ap = $mod.TTMSFNCPersistence.IsAssignableProperty(AObject,AProp);
                  if (this.FOnCustomIsAssignableProperty != null) this.FOnCustomIsAssignableProperty(AObject,pName,{get: function () {
                      return ap;
                    }, set: function (v) {
                      ap = v;
                    }});
                  if (ap) {
                    n = this.FReader.ReadString();
                    if ((this.FRootObject != null) && pas.Classes.TComponent.isPrototypeOf(this.FRootObject)) pas.TypInfo.SetObjectProp(AObject,pName,rtl.as(this.FRootObject,pas.Classes.TComponent).FindComponent(n));
                  } else this.ReadExistingObject(o);
                };
              };
            } else this.ReadPropInfoValue(AObject,AProp);
          };
        } else this.FReader.SkipValue();
      } finally {
        rtl._Release(p);
        rtl._Release(crw);
        rtl._Release(pio);
      };
    };
    this.ReadPropInfoValue = function (AInstance, APropInfo) {
      var pName = "";
      var cn = "";
      var cnv = "";
      var en = "";
      var k = 0;
      var p = null;
      var o = null;
      var i = 0;
      var s = "";
      var b = false;
      var d = 0.0;
      var ii = 0;
      var v = "";
      var m = pas.System.TMethod.$new();
      var bsz = false;
      var vr = undefined;
      if ($mod.TTMSFNCPersistence.IsWriteOnly(APropInfo) || this.FReader.IsNull()) {
        this.FReader.ReadNull();
        return;
      };
      o = AInstance;
      p = APropInfo;
      pName = $mod.TTMSFNCPersistence.GetPropInfoName(p);
      k = rtl.rc($mod.TTMSFNCPersistence.GetPropInfoType(p),0,20);
      var $tmp = k;
      if ($tmp === pas.System.TTypeKind.tkInteger) {
        cn = $mod.TTMSFNCPersistence.GetPropInfoTypeName(p);
        if ((cn === "TAlphaColor") || (cn === "TColor") || (cn === "TGraphicsColor")) {
          cnv = this.FReader.ReadString();
          if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) {
            if (cnv === "gcNull") {
              pas.TypInfo.SetOrdProp(o,pName,-1)}
             else {
              pas.TypInfo.SetOrdProp(o,pName,$impl.HTMLToColorEx(cnv));
            };
          };
        } else {
          i = rtl.rc(this.FReader.ReadInteger(),-2147483648,2147483647);
          if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetOrdProp$1(o,p,i);
        };
      } else if (($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkString)) {
        s = this.FReader.ReadString();
        if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetStrProp$1(o,p,s);
      } else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
        if ($mod.TTMSFNCPersistence.GetPropInfoDataTypeInfo(p) === rtl.boolean) {
          b = this.FReader.ReadBoolean();
          if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetOrdProp$1(o,p,(b ? 1 : 0));
        } else {
          i = rtl.rc(this.FReader.ReadInteger(),-2147483648,2147483647);
          if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetOrdProp$1(o,p,i);
        }}
       else if ($tmp === pas.System.TTypeKind.tkBool) {
        b = this.FReader.ReadBoolean();
        if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) {
          pas.TypInfo.SetBoolProp$1(o,p,b);
        };
      } else if ($tmp === pas.System.TTypeKind.tkDouble) {
        d = this.FReader.ReadDouble();
        if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetFloatProp$1(o,p,d);
      } else if ($tmp === pas.System.TTypeKind.tkSet) {
        i = rtl.rc(this.FReader.ReadInteger(),-2147483648,2147483647);
        if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetOrdProp$1(o,p,i);
      } else if ($tmp === pas.System.TTypeKind.tkJSValue) {
        vr = null;
        if (this.FReader.HasDouble()) {
          vr = this.FReader.ReadDouble()}
         else if (this.FReader.HasInt64()) {
          vr = this.FReader.ReadInt64()}
         else if (this.FReader.HasBoolean()) {
          vr = this.FReader.ReadBoolean()}
         else if (this.FReader.HasString()) {
          vr = this.FReader.ReadString()}
         else this.FReader.ReadNull();
        if (!$mod.TTMSFNCPersistence.IsReadOnly(p)) {
          pas.TypInfo.SetJSValueProp$3(o,p,vr);
        };
      } else if ($tmp === pas.System.TTypeKind.tkMethod) {
        m.Data = null;
        m.Code = null;
        if (this.FReader.IsNull()) {
          this.FReader.ReadNull()}
         else {
          if ($mod.TTMSFNCPersistence.FRootObject != null) {
            v = this.FReader.ReadString();
            m.Code = $mod.TTMSFNCPersistence.FRootObject.$class.MethodAddress(v);
            if (m.Code !== null) m.Data = $mod.TTMSFNCPersistence.FRootObject;
          } else this.FReader.ReadNull();
        };
        pas.TypInfo.SetMethodProp(o,p,m);
      } else {
        en = $mod.TTMSFNCPersistence.GetEnumName(pas.System.$rtti["TTypeKind"],k);
        this.FReader.ReadNull();
      };
      if (pas["WEBLib.Graphics"].TFont.isPrototypeOf(o) && (pName === "Size")) {
        if (this.FReader.HasNext()) {
          s = this.FReader.PeekName();
          if (s === "IsFMX") {
            this.FReader.ReadName();
            bsz = this.FReader.ReadBoolean();
            if (bsz) {
              rtl.as(o,pas["WEBLib.Graphics"].TFont).SetSize(Math.round((rtl.as(o,pas["WEBLib.Graphics"].TFont).FSize / 96) * 72));
            };
          };
        };
      };
    };
    this.ReadExistingObject = function (AObject) {
      if (AObject != null) {
        if (!this.FReader.IsNull()) {
          this.FReader.ReadBeginObject();
          if ($mod.TTMSFNCPersistence.ClassTypeVariable !== "") {
            if (!this.FReader.HasNext() || (this.FReader.ReadName() !== $mod.TTMSFNCPersistence.ClassTypeVariable)) throw $mod.ETMSFNCReaderException.$create("Create$1",['"' + $mod.TTMSFNCPersistence.ClassTypeVariable + '" property not found in Object descriptor.']);
            this.FReader.ReadString();
          };
          this.ReadProperties(AObject);
          this.FReader.ReadEndObject();
        } else this.FReader.SkipValue();
      } else this.FReader.ReadNull();
    };
    this.ReadGenericStringList = function (AList) {
      var obj = "";
      AList.Clear();
      this.FReader.ReadBeginArray();
      while (this.FReader.HasNext()) {
        if (!this.FReader.IsNull()) {
          obj = this.FReader.ReadString();
          AList.Add(obj);
        } else this.FReader.SkipValue();
      };
      this.FReader.ReadEndArray();
    };
    this.ReadGenericDoubleList = function (AList) {
      var obj = 0.0;
      AList.Clear();
      this.FReader.ReadBeginArray();
      while (this.FReader.HasNext()) {
        if (!this.FReader.IsNull()) {
          obj = this.FReader.ReadDouble();
          AList.Add(obj);
        } else this.FReader.SkipValue();
      };
      this.FReader.ReadEndArray();
    };
    this.ReadGenericIntegerList = function (AList) {
      var obj = 0;
      AList.Clear();
      this.FReader.ReadBeginArray();
      while (this.FReader.HasNext()) {
        if (!this.FReader.IsNull()) {
          obj = this.FReader.ReadInteger();
          AList.Add(obj);
        } else this.FReader.SkipValue();
      };
      this.FReader.ReadEndArray();
    };
    this.ReadStrings = function (AList) {
      var obj = "";
      AList.Clear();
      this.FReader.ReadBeginArray();
      while (this.FReader.HasNext()) {
        if (!this.FReader.IsNull()) {
          obj = this.FReader.ReadString();
          AList.Add(obj);
        } else this.FReader.SkipValue();
      };
      this.FReader.ReadEndArray();
    };
    this.ReadGenericObjectList = function (AList) {
      var obj = null;
      var b = null;
      var c = null;
      var i = null;
      var cl = false;
      try {
        if (pas.SysUtils.Supports$3(AList,$mod.ITMSFNCBaseListIO.$guid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          c = i.GetItemClass()}
         else c = $mod.TTMSFNCPersistence.GetGenericListType(AList.$class.ClassType());
        cl = false;
        this.FReader.ReadBeginArray();
        if (!this.FReader.HasNext()) {
          AList.Clear()}
         else {
          while (this.FReader.HasNext()) {
            if (!this.FReader.IsNull()) {
              obj = this.ReadSingleObject(c);
              if (obj != null) {
                if (!cl) {
                  AList.Clear();
                  cl = true;
                };
                if ((this.FIOReference != null) && pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCPersistenceIO.$guid,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }})) b.FixOwners(obj,AList);
                AList.Add(obj);
              };
            } else this.FReader.SkipValue();
          };
        };
        this.FReader.ReadEndArray();
      } finally {
        rtl._Release(i);
        rtl._Release(b);
      };
    };
    this.ReadGenericStringObjectDictionary = function (ADictionary) {
      var obj = null;
      var k = "";
      var c = null;
      var i = null;
      var cl = false;
      try {
        if (pas.SysUtils.Supports$3(ADictionary,$mod.ITMSFNCBaseListIO.$guid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          c = i.GetItemClass()}
         else c = $mod.TTMSFNCPersistence.GetGenericDictionaryValueType(ADictionary.$class.ClassType());
        cl = false;
        ADictionary.Clear();
        this.FReader.ReadBeginArray();
        if (!this.FReader.HasNext()) {
          ADictionary.Clear()}
         else {
          while (this.FReader.HasNext()) {
            if (!this.FReader.IsNull()) {
              this.FReader.ReadBeginObject();
              k = this.FReader.ReadName();
              obj = this.ReadSingleObject(c);
              if (obj != null) {
                if (!cl) {
                  ADictionary.Clear();
                  cl = true;
                };
                ADictionary.Add(k,obj);
              };
              this.FReader.ReadEndObject();
            } else this.FReader.SkipValue();
          };
        };
        this.FReader.ReadEndArray();
      } finally {
        rtl._Release(i);
      };
    };
    this.ReadGenericIntegerObjectDictionary = function (ADictionary) {
      var obj = null;
      var k = 0;
      var c = null;
      var i = null;
      var cl = false;
      try {
        if (pas.SysUtils.Supports$3(ADictionary,$mod.ITMSFNCBaseListIO.$guid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          c = i.GetItemClass()}
         else c = $mod.TTMSFNCPersistence.GetGenericDictionaryValueType(ADictionary.$class.ClassType());
        cl = false;
        ADictionary.Clear();
        this.FReader.ReadBeginArray();
        if (!this.FReader.HasNext()) {
          ADictionary.Clear()}
         else {
          while (this.FReader.HasNext()) {
            if (!this.FReader.IsNull()) {
              this.FReader.ReadBeginObject();
              pas.SysUtils.TryStrToInt(this.FReader.ReadName(),{get: function () {
                  return k;
                }, set: function (v) {
                  k = v;
                }});
              obj = this.ReadSingleObject(c);
              if (obj != null) {
                if (!cl) {
                  ADictionary.Clear();
                  cl = true;
                };
                ADictionary.Add(k,obj);
              };
              this.FReader.ReadEndObject();
            } else this.FReader.SkipValue();
          };
        };
        this.FReader.ReadEndArray();
      } finally {
        rtl._Release(i);
      };
    };
    this.ReadGenericIntegerIntegerDictionary = function (ADictionary) {
      var obj = 0;
      var k = 0;
      var cl = false;
      cl = false;
      ADictionary.Clear();
      this.FReader.ReadBeginArray();
      if (!this.FReader.HasNext()) {
        ADictionary.Clear()}
       else {
        while (this.FReader.HasNext()) {
          if (!this.FReader.IsNull()) {
            this.FReader.ReadBeginObject();
            pas.SysUtils.TryStrToInt(this.FReader.ReadName(),{get: function () {
                return k;
              }, set: function (v) {
                k = v;
              }});
            obj = this.FReader.ReadInteger();
            if (!cl) {
              ADictionary.Clear();
              cl = true;
            };
            ADictionary.Add(k,obj);
            this.FReader.ReadEndObject();
          } else this.FReader.SkipValue();
        };
      };
      this.FReader.ReadEndArray();
    };
    this.ReadGenericIntegerBooleanDictionary = function (ADictionary) {
      var obj = false;
      var k = 0;
      var cl = false;
      cl = false;
      ADictionary.Clear();
      this.FReader.ReadBeginArray();
      if (!this.FReader.HasNext()) {
        ADictionary.Clear()}
       else {
        while (this.FReader.HasNext()) {
          if (!this.FReader.IsNull()) {
            this.FReader.ReadBeginObject();
            pas.SysUtils.TryStrToInt(this.FReader.ReadName(),{get: function () {
                return k;
              }, set: function (v) {
                k = v;
              }});
            obj = this.FReader.ReadBoolean();
            if (!cl) {
              ADictionary.Clear();
              cl = true;
            };
            ADictionary.Add(k,obj);
            this.FReader.ReadEndObject();
          } else this.FReader.SkipValue();
        };
      };
      this.FReader.ReadEndArray();
    };
    this.ReadGenericIntegerDoubleDictionary = function (ADictionary) {
      var obj = 0.0;
      var k = 0;
      var cl = false;
      cl = false;
      ADictionary.Clear();
      this.FReader.ReadBeginArray();
      if (!this.FReader.HasNext()) {
        ADictionary.Clear()}
       else {
        while (this.FReader.HasNext()) {
          if (!this.FReader.IsNull()) {
            this.FReader.ReadBeginObject();
            pas.SysUtils.TryStrToInt(this.FReader.ReadName(),{get: function () {
                return k;
              }, set: function (v) {
                k = v;
              }});
            obj = this.FReader.ReadDouble();
            if (!cl) {
              ADictionary.Clear();
              cl = true;
            };
            ADictionary.Add(k,obj);
            this.FReader.ReadEndObject();
          } else this.FReader.SkipValue();
        };
      };
      this.FReader.ReadEndArray();
    };
    this.ReadCollection = function (ACollection) {
      var obj = null;
      var c = null;
      var i = null;
      var ii = null;
      var cl = false;
      try {
        if (pas.SysUtils.Supports$3(ACollection,$mod.ITMSFNCBaseListIO.$guid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          c = i.GetItemClass()}
         else c = ACollection.FItemClass;
        pas.SysUtils.Supports$3(ACollection,$mod.ITMSFNCBaseCollectionIO.$guid,{get: function () {
            return ii;
          }, set: function (v) {
            ii = v;
          }});
        cl = false;
        this.FReader.ReadBeginArray();
        if (!this.FReader.HasNext()) {
          ACollection.Clear()}
         else {
          while (this.FReader.HasNext()) {
            if (!this.FReader.IsNull()) {
              obj = this.ReadSingleObject(c);
              if (obj != null) {
                if (!cl) {
                  ACollection.Clear();
                  cl = true;
                };
                try {
                  if (pas.Classes.TPersistent.isPrototypeOf(obj)) {
                    if (ii != null) {
                      ii.AddItem(obj).Assign(rtl.as(obj,pas.Classes.TPersistent))}
                     else ACollection.Add().Assign(rtl.as(obj,pas.Classes.TPersistent));
                  };
                } finally {
                  obj = rtl.freeLoc(obj);
                };
              };
            } else this.FReader.SkipValue();
          };
        };
        this.FReader.ReadEndArray();
      } finally {
        rtl._Release(i);
        rtl._Release(ii);
      };
    };
    this.ReadList = function (AList) {
      var obj = null;
      var b = null;
      var c = null;
      var i = null;
      var cl = false;
      try {
        c = pas.System.TObject;
        if (pas.SysUtils.Supports$3(AList,$mod.ITMSFNCBaseListIO.$guid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) c = i.GetItemClass();
        cl = false;
        this.FReader.ReadBeginArray();
        if (!this.FReader.HasNext()) {
          AList.Clear()}
         else {
          while (this.FReader.HasNext()) {
            if (!this.FReader.IsNull()) {
              obj = this.ReadSingleObject(c);
              if (obj != null) {
                if (!cl) {
                  AList.Clear();
                  cl = true;
                };
                if ((this.FIOReference != null) && pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCPersistenceIO.$guid,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }})) b.FixOwners(obj,AList);
                AList.Add(obj);
              };
            } else this.FReader.SkipValue();
          };
        };
        this.FReader.ReadEndArray();
      } finally {
        rtl._Release(i);
        rtl._Release(b);
      };
    };
    this.ReadBitmap = function (ABitmap) {
      var s = "";
      if (this.FReader.IsNull()) return;
      s = this.FReader.ReadString();
      if (s !== "") {
        ABitmap.SetData(s);
      };
    };
    this.ReadObject = function (AObject) {
      if (AObject === null) {
        this.FReader.ReadNull()}
       else {
        if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"String")) {
          this.ReadGenericStringList(AObject)}
         else if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"Double")) {
          this.ReadGenericDoubleList(AObject)}
         else if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"Integer")) {
          this.ReadGenericIntegerList(AObject)}
         else if ($mod.TTMSFNCPersistence.IsGenericList(AObject.$class.ClassType(),"")) {
          this.ReadGenericObjectList(AObject)}
         else if ($mod.TTMSFNCPersistence.IsGenericStringDictionary(AObject.$class.ClassType())) {
          if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeObject(AObject.$class.ClassType())) {
            this.ReadGenericStringObjectDictionary(AObject)}
           else this.FReader.ReadNull();
        } else if ($mod.TTMSFNCPersistence.IsGenericIntegerDictionary(AObject.$class.ClassType())) {
          if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeObject(AObject.$class.ClassType())) {
            this.ReadGenericIntegerObjectDictionary(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeInteger(AObject.$class.ClassType())) {
            this.ReadGenericIntegerIntegerDictionary(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeBoolean(AObject.$class.ClassType())) {
            this.ReadGenericIntegerBooleanDictionary(AObject)}
           else if ($mod.TTMSFNCPersistence.IsGenericDictionaryValueTypeDouble(AObject.$class.ClassType())) {
            this.ReadGenericIntegerDoubleDictionary(AObject)}
           else this.FReader.ReadNull();
        } else if ($mod.TTMSFNCPersistence.IsList(AObject.$class.ClassType())) {
          this.ReadList(AObject)}
         else if ($mod.TTMSFNCPersistence.IsCollection(AObject.$class.ClassType())) {
          this.ReadCollection(AObject)}
         else if ($mod.TTMSFNCPersistence.IsBitmap(AObject.$class.ClassType())) {
          this.ReadBitmap(AObject)}
         else if ($mod.TTMSFNCPersistence.IsDescendingClass(AObject.$class.ClassType(),["TStrings"])) {
          this.ReadStrings(AObject)}
         else this.ReadSingleObject$1(AObject);
      };
    };
    this.Create$1 = function (AStream) {
      this.FReader = pas["WEBLib.TMSFNCJSONReader"].TTMSFNCJSONReader.$create("Create$1",[AStream]);
      this.FReaderRef = false;
      this.FReferences = pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCObjectReference.$create("Create$4",[true]);
      return this;
    };
    this.Create$2 = function (AReader) {
      this.FReader = AReader;
      this.FReaderRef = true;
      this.FReferences = pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCObjectReference.$create("Create$4",[true]);
      return this;
    };
    this.Destroy = function () {
      if (this.FReaderRef) {
        this.FReader = null}
       else rtl.free(this,"FReader");
      rtl.free(this,"FReferences");
      pas.System.TObject.Destroy.call(this);
    };
    this.Read = function (AClass) {
      var Result = null;
      Result = this.ReadSingleObject(AClass);
      return Result;
    };
    this.Read$1 = function (AObject) {
      this.ReadObject(AObject);
    };
    this.ReadArray = function (AName) {
      var Result = [];
      var Name = "";
      this.FReader.ReadBeginObject();
      while (this.FReader.HasNext()) {
        if (!this.FReader.IsNull()) {
          Name = this.FReader.ReadName();
          if (Name === AName) {
            this.FReader.ReadBeginArray();
            while (this.FReader.HasNext()) {
              Result = rtl.arraySetLength(Result,null,rtl.length(Result) + 1);
              Result[rtl.length(Result) - 1] = this.ReadSingleObject(pas.System.TObject);
            };
            this.FReader.ReadEndArray();
          } else this.FReader.SkipValue();
        } else this.FReader.SkipValue();
      };
      return Result;
    };
    this.SolveReferences = function () {
      var b = null;
      var r = 0;
      var rf = null;
      var o = null;
      try {
        if ((this.FIOReference != null) && pas.SysUtils.Supports$3(this.FIOReference,$mod.ITMSFNCPersistenceIO.$guid,{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }})) {
          for (var $l = 0, $end = this.FReferences.FLength - 1; $l <= $end; $l++) {
            r = $l;
            rf = this.FReferences.GetItem(r);
            o = b.FindObject(rf.Id);
            pas.TypInfo.SetObjectProp$1(rf.Instance,rf.Prop,o);
          };
        };
      } finally {
        rtl._Release(b);
      };
    };
  });
  rtl.createClass(this,"TTMSFNCObjectPersistence",pas.System.TObject,function () {
    this.SaveObjectToString = function (AObject) {
      var Result = "";
      var ss = null;
      ss = pas.Classes.TStringStream.$create("Create$3",["",pas.SysUtils.TEncoding.GetUTF8(),true]);
      try {
        $mod.TTMSFNCPersistence.SaveSettingsToStream(AObject,ss);
        ss.SetPosition(0);
        Result = ss.GetDataString();
      } finally {
        ss = rtl.freeLoc(ss);
      };
      return Result;
    };
    this.LoadObjectFromString = function (AObject, AString) {
      var ms = null;
      ms = pas.Classes.TStringStream.$create("Create$3",[AString,pas.SysUtils.TEncoding.GetUTF8(),true]);
      try {
        $mod.TTMSFNCPersistence.LoadSettingsFromStream(AObject,ms);
      } finally {
        ms = rtl.freeLoc(ms);
      };
    };
  });
  rtl.createClass(this,"TTMSFNCPersistence",pas.System.TObject,function () {
    this.ClassTypeVariable = "";
    this.IgnoreExceptions = false;
    this.FOnCustomReadProperty = null;
    this.FOnCustomWriteProperty = null;
    this.FRootObject = null;
    this.FExcludeProperties = [];
    this.FIOReference = null;
    this.DoCustomReadProperty = function (AObject, APropertyName, APropertyKind, AReader, ACanRead) {
      rtl.rc(APropertyKind,0,20);
      if (this.FOnCustomReadProperty != null) this.FOnCustomReadProperty(AObject,APropertyName,APropertyKind,AReader,ACanRead);
    };
    this.DoCustomWriteProperty = function (AObject, APropertyName, APropertyKind, AWriter, ACanWrite) {
      rtl.rc(APropertyKind,0,20);
      if (this.FOnCustomWriteProperty != null) this.FOnCustomWriteProperty(AObject,APropertyName,APropertyKind,AWriter,ACanWrite);
    };
    this.SaveSettingsToFile = function (AObject, AFileName) {
      var ms = null;
      ms = pas.Classes.TMemoryStream.$create("Create");
      try {
        this.SaveSettingsToStream(AObject,ms);
        pas["WEBLib.TMSFNCTypes"].TTMSFNCMemoryStream.SaveToFile.call(ms,AFileName);
      } finally {
        ms = rtl.freeLoc(ms);
      };
    };
    this.LoadSettingsFromFile = function (AObject, AFileName) {
      var $Self = this;
      var ms = null;
      ms = pas.Classes.TMemoryStream.$create("Create");
      try {
        ms.LoadFromFile(AFileName,function () {
          $Self.LoadSettingsFromStream(AObject,ms);
          ms = rtl.freeLoc(ms);
        },null);
      } finally {
      };
    };
    this.SaveSettingsToStream = function (AObject, AStream) {
      var Writer = null;
      Writer = $mod.TTMSFNCWriter.$create("Create$1",[AStream]);
      try {
        Writer.SetIOReference($mod.TTMSFNCPersistence.FIOReference);
        Writer.SetRootObject($mod.TTMSFNCPersistence.FRootObject);
        Writer.FOnCustomWriteProperty = rtl.createCallback(this,"DoCustomWriteProperty");
        Writer.Write(AObject);
      } finally {
        Writer = rtl.freeLoc(Writer);
      };
    };
    this.LoadSettingsFromStream = function (AObject, AStream) {
      var Reader = null;
      AStream.SetPosition(0);
      Reader = $mod.TTMSFNCReader.$create("Create$1",[AStream]);
      try {
        Reader.SetIOReference($mod.TTMSFNCPersistence.FIOReference);
        Reader.SetRootObject($mod.TTMSFNCPersistence.FRootObject);
        Reader.FOnCustomReadProperty = rtl.createCallback(this,"DoCustomReadProperty");
        Reader.Read$1(AObject);
      } finally {
        Reader = rtl.freeLoc(Reader);
      };
    };
    this.GetEnumValues = function (AValues, APropInfo) {
      var p = null;
      var pi = null;
      var ps = null;
      var I = 0;
      var k = 0;
      p = $impl.GetTypeInfoEx(APropInfo);
      if ((p != null) && rtl.isExt(p,rtl.tTypeInfoSet)) p = p.comptype;
      if ((p != null) && rtl.isExt(p,rtl.tTypeInfoInteger)) {
        pi = p;
        for (var $l = pi.minvalue, $end = pi.maxvalue; $l <= $end; $l++) {
          I = $l;
          AValues.Add($mod.TTMSFNCPersistence.GetEnumName(p,I));
        };
      };
    };
    this.CreateObject = function (AClassName, BaseClass) {
      var Result = null;
      var ObjType = null;
      ObjType = pas.Classes.GetClass(AClassName);
      if (ObjType === null) {
        if ($mod.TTMSFNCPersistence.IgnoreExceptions) {
          Result = null;
          return Result;
        } else throw $mod.ETMSFNCReaderException.$create("CreateFmt",['Type "%s" not found',pas.System.VarRecs(18,AClassName)]);
      };
      if (!$mod.TTMSFNCPersistence.IgnoreExceptions) {
        if (!ObjType.InheritsFrom(pas.System.TObject)) throw $mod.ETMSFNCReaderException.$create("Create$1",['Type "%s" is not an class type']);
        if (BaseClass !== null) if (!ObjType.InheritsFrom(BaseClass)) throw $mod.ETMSFNCReaderException.$create("CreateFmt",['Type "%s" does not inherit from %s',pas.System.VarRecs(18,AClassName,18,BaseClass.$classname)]);
      };
      if (ObjType.InheritsFrom(pas["WEBLib.Controls"].TCustomControl)) {
        Result = ObjType.$create("Create$1",[null])}
       else if (ObjType.InheritsFrom(pas.Classes.TCollectionItem)) {
        Result = ObjType.$create("Create$1",[null])}
       else if (ObjType.InheritsFrom(pas.Classes.TPersistent)) {
        Result = ObjType.$create("Create")}
       else throw $mod.ETMSFNCReaderException.$create("CreateFmt",['Type "%s" not supported',pas.System.VarRecs(18,AClassName)]);
      return Result;
    };
    this.GetPropInfoDataTypeInfo = function (APropInfo) {
      var Result = null;
      Result = null;
      if (APropInfo != null) Result = APropInfo.typeinfo;
      return Result;
    };
    this.GetPropInfoDataTypeInfoClassType = function (APropInfo) {
      var Result = null;
      var t = null;
      Result = null;
      if ((APropInfo != null) && (APropInfo.typeinfo != null)) {
        t = APropInfo.typeinfo;
        if (t.class){
          return t.class.ClassType();
        };
      };
      return Result;
    };
    this.GetPropInfoType = function (APropInfo) {
      var Result = 0;
      if (APropInfo.typeinfo != null) {
        Result = rtl.rc(APropInfo.typeinfo.kind,0,20)}
       else Result = rtl.rc(pas.System.TTypeKind.tkUnknown,0,20);
      return Result;
    };
    this.GetPropInfoName = function (APropInfo) {
      var Result = "";
      Result = APropInfo.name;
      return Result;
    };
    this.GetPropInfoTypeName = function (APropInfo) {
      var Result = "";
      Result = "";
      if (APropInfo.typeinfo != null) Result = APropInfo.typeinfo.name;
      return Result;
    };
    this.GetEnumName = function (ATypeInfo, AValue) {
      rtl.rc(AValue,-2147483648,2147483647);
      var Result = "";
      Result = ATypeInfo.enumtype[AValue];
      return Result;
    };
    this.IsWriteOnly = function (APropInfo) {
      var Result = false;
      Result = APropInfo.getter === "";
      return Result;
    };
    this.IsReadOnly = function (APropInfo) {
      var Result = false;
      Result = APropInfo.setter === "";
      return Result;
    };
    this.IsAssignableProperty = function (AObject, APropInfo) {
      var Result = false;
      var oProp = null;
      var k = 0;
      var pName = "";
      Result = false;
      k = rtl.rc(this.GetPropInfoType(APropInfo),0,20);
      if (k in rtl.createSet(pas.System.TTypeKind.tkClass)) {
        pName = this.GetPropInfoName(APropInfo);
        oProp = pas.TypInfo.GetObjectProp(AObject,pName);
        Result = ((oProp != null) && this.IsComponent(oProp.$class.ClassType())) || !(oProp != null);
      };
      return Result;
    };
    this.IsColor = function (APropertyName) {
      var Result = false;
      Result = (APropertyName === "TAlphaColor") || (APropertyName === "TColor") || (APropertyName === "TGraphicsColor");
      return Result;
    };
    this.IsStrokeKind = function (APropertyName) {
      var Result = false;
      Result = APropertyName === "TTMSFNCGraphicsStrokeKind";
      return Result;
    };
    this.IsFillKind = function (APropertyName) {
      var Result = false;
      Result = APropertyName === "TTMSFNCGraphicsFillKind";
      return Result;
    };
    this.IsDate = function (APropertyName) {
      var Result = false;
      Result = APropertyName === "TDate";
      return Result;
    };
    this.IsDateTime = function (APropertyName) {
      var Result = false;
      Result = APropertyName === "TDateTime";
      return Result;
    };
    this.IsTime = function (APropertyName) {
      var Result = false;
      Result = APropertyName === "TTime";
      return Result;
    };
    this.GetGenericListType = function (AClass) {
      var Result = null;
      var cn = "";
      var po = 0;
      var pc = 0;
      var fn = "";
      var sl = null;
      var c = 0;
      var I = 0;
      var p = null;
      if (!(AClass != null)) return pas.System.TObject;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TList<",cn) || pas.StrUtils.AnsiStartsStr("TObjectList<",cn)) {
          po = rtl.rc(pas.System.Pos("<",cn),-2147483648,2147483647);
          pc = rtl.rc(pas.System.Pos(">",cn),-2147483648,2147483647);
          if ((po > 0) && (pc > 0)) {
            fn = pas.System.Copy(cn,po + 1,pc - po - 1);
            sl = pas.Classes.TStringList.$create("Create$1");
            try {
              sl.SetDelimiter(".");
              sl.SetDelimitedText(fn);
              while (sl.GetCount() > 0) {
                fn = sl.GetDelimitedText();
                p = pas.Classes.GetClass(fn);
                if (p != null) return p;
                sl.Delete(0);
              };
            } finally {
              sl = rtl.freeLoc(sl);
            };
          };
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = pas.System.TObject;
      return Result;
    };
    this.GetGenericDictionaryValueType = function (AClass) {
      var Result = null;
      var cn = "";
      var po = 0;
      var pc = 0;
      var poc = 0;
      var fn = "";
      var sl = null;
      var c = 0;
      var I = 0;
      var p = null;
      if (!(AClass != null)) return pas.System.TObject;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<",cn)) {
          po = rtl.rc(pas.System.Pos("<",cn),-2147483648,2147483647);
          pc = rtl.rc(pas.System.Pos(">",cn),-2147483648,2147483647);
          if ((po > 0) && (pc > 0)) {
            fn = pas.System.Copy(cn,po + 1,pc - po - 1);
            poc = rtl.rc(pas.System.Pos(",",fn),-2147483648,2147483647);
            if (poc > 0) {
              fn = pas.System.Copy(fn,poc + 1,fn.length - poc);
              sl = pas.Classes.TStringList.$create("Create$1");
              try {
                sl.SetDelimiter(".");
                sl.SetDelimitedText(fn);
                while (sl.GetCount() > 0) {
                  fn = sl.GetDelimitedText();
                  p = pas.Classes.GetClass(fn);
                  if (p != null) return p;
                  sl.Delete(0);
                };
              } finally {
                sl = rtl.freeLoc(sl);
              };
            };
          };
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = pas.System.TObject;
      return Result;
    };
    this.IsGenericDictionaryValueTypeObject = function (AClass) {
      var Result = false;
      var cn = "";
      var po = 0;
      var pc = 0;
      var poc = 0;
      var fn = "";
      var sl = null;
      var c = 0;
      var I = 0;
      var p = null;
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<",cn)) {
          po = rtl.rc(pas.System.Pos("<",cn),-2147483648,2147483647);
          pc = rtl.rc(pas.System.Pos(">",cn),-2147483648,2147483647);
          if ((po > 0) && (pc > 0)) {
            fn = pas.System.Copy(cn,po + 1,pc - po - 1);
            poc = rtl.rc(pas.System.Pos(",",fn),-2147483648,2147483647);
            if (poc > 0) {
              fn = pas.System.Copy(fn,poc + 1,fn.length - poc);
              sl = pas.Classes.TStringList.$create("Create$1");
              try {
                sl.SetDelimiter(".");
                sl.SetDelimitedText(fn);
                while (sl.GetCount() > 0) {
                  fn = sl.GetDelimitedText();
                  p = pas.Classes.GetClass(fn);
                  if (p != null) return true;
                  sl.Delete(0);
                };
              } finally {
                sl = rtl.freeLoc(sl);
              };
            };
          };
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericDictionaryValueTypeInteger = function (AClass) {
      var Result = false;
      var cn = "";
      var po = 0;
      var pc = 0;
      var poc = 0;
      var fn = "";
      var sl = null;
      var c = 0;
      var I = 0;
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<",cn)) {
          po = rtl.rc(pas.System.Pos("<",cn),-2147483648,2147483647);
          pc = rtl.rc(pas.System.Pos(">",cn),-2147483648,2147483647);
          if ((po > 0) && (pc > 0)) {
            fn = pas.System.Copy(cn,po + 1,pc - po - 1);
            poc = rtl.rc(pas.System.Pos(",",fn),-2147483648,2147483647);
            if (poc > 0) {
              fn = pas.System.Copy(fn,poc + 1,fn.length - poc);
              sl = pas.Classes.TStringList.$create("Create$1");
              try {
                sl.SetDelimiter(".");
                sl.SetDelimitedText(fn);
                while (sl.GetCount() > 0) {
                  fn = sl.GetDelimitedText();
                  if ((pas.SysUtils.UpperCase(fn) === "INTEGER") || (pas.SysUtils.UpperCase(fn) === "SYSTEM.INTEGER") || (pas.SysUtils.UpperCase(fn) === "LONGINT") || (pas.SysUtils.UpperCase(fn) === "SYSTEM.LONGINT")) return true;
                  sl.Delete(0);
                };
              } finally {
                sl = rtl.freeLoc(sl);
              };
            };
          };
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericDictionaryValueTypeBoolean = function (AClass) {
      var Result = false;
      var cn = "";
      var po = 0;
      var pc = 0;
      var poc = 0;
      var fn = "";
      var sl = null;
      var c = 0;
      var I = 0;
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<",cn)) {
          po = rtl.rc(pas.System.Pos("<",cn),-2147483648,2147483647);
          pc = rtl.rc(pas.System.Pos(">",cn),-2147483648,2147483647);
          if ((po > 0) && (pc > 0)) {
            fn = pas.System.Copy(cn,po + 1,pc - po - 1);
            poc = rtl.rc(pas.System.Pos(",",fn),-2147483648,2147483647);
            if (poc > 0) {
              fn = pas.System.Copy(fn,poc + 1,fn.length - poc);
              sl = pas.Classes.TStringList.$create("Create$1");
              try {
                sl.SetDelimiter(".");
                sl.SetDelimitedText(fn);
                while (sl.GetCount() > 0) {
                  fn = sl.GetDelimitedText();
                  if ((pas.SysUtils.UpperCase(fn) === "BOOLEAN") || (pas.SysUtils.UpperCase(fn) === "SYSTEM.BOOLEAN")) return true;
                  sl.Delete(0);
                };
              } finally {
                sl = rtl.freeLoc(sl);
              };
            };
          };
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericDictionaryValueTypeDouble = function (AClass) {
      var Result = false;
      var cn = "";
      var po = 0;
      var pc = 0;
      var poc = 0;
      var fn = "";
      var sl = null;
      var c = 0;
      var I = 0;
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<",cn)) {
          po = rtl.rc(pas.System.Pos("<",cn),-2147483648,2147483647);
          pc = rtl.rc(pas.System.Pos(">",cn),-2147483648,2147483647);
          if ((po > 0) && (pc > 0)) {
            fn = pas.System.Copy(cn,po + 1,pc - po - 1);
            poc = rtl.rc(pas.System.Pos(",",fn),-2147483648,2147483647);
            if (poc > 0) {
              fn = pas.System.Copy(fn,poc + 1,fn.length - poc);
              sl = pas.Classes.TStringList.$create("Create$1");
              try {
                sl.SetDelimiter(".");
                sl.SetDelimitedText(fn);
                while (sl.GetCount() > 0) {
                  fn = sl.GetDelimitedText();
                  if ((pas.SysUtils.UpperCase(fn) === "DOUBLE") || (pas.SysUtils.UpperCase(fn) === "SYSTEM.DOUBLE")) return true;
                  sl.Delete(0);
                };
              } finally {
                sl = rtl.freeLoc(sl);
              };
            };
          };
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericList = function (AClass, AType) {
      var Result = false;
      var cn = "";
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TList<",cn) || pas.StrUtils.AnsiStartsStr("TObjectList<",cn)) {
          if ((AType === "") || ((AType !== "") && (pas.System.Pos(pas.SysUtils.LowerCase(AType),pas.SysUtils.LowerCase(cn)) > 0)) || (pas.System.Pos(pas.SysUtils.LowerCase(AType),pas.SysUtils.LowerCase(cn)) > 0)) return true;
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericDictionary = function (AClass) {
      var Result = false;
      var cn = "";
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<",cn)) return true;
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericStringDictionary = function (AClass) {
      var Result = false;
      var cn = "";
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<string",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<string",cn) || pas.StrUtils.AnsiStartsStr("TDictionary<System.string",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<System.string",cn)) return true;
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsGenericIntegerDictionary = function (AClass) {
      var Result = false;
      var cn = "";
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        if (pas.StrUtils.AnsiStartsStr("TDictionary<Integer",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<Integer",cn) || pas.StrUtils.AnsiStartsStr("TDictionary<System.Integer",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<System.Integer",cn) || pas.StrUtils.AnsiStartsStr("TDictionary<System.Longint",cn) || pas.StrUtils.AnsiStartsStr("TObjectDictionary<System.Longint",cn)) return true;
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsCollection = function (AClass) {
      var Result = false;
      Result = this.IsDescendingClass(AClass,["TCollection"]);
      return Result;
    };
    this.IsComponent = function (AClass) {
      var Result = false;
      Result = this.IsDescendingClass(AClass,["TComponent","TTMSFNCCustomComponent"]);
      return Result;
    };
    this.IsControl = function (AClass) {
      var Result = false;
      Result = this.IsDescendingClass(AClass,["TControl"]);
      return Result;
    };
    this.IsList = function (AClass) {
      var Result = false;
      Result = this.IsDescendingClass(AClass,["TList"]);
      return Result;
    };
    this.IsDescendingClass = function (AClass, AClassParentList) {
      var Result = false;
      var cn = "";
      var I = 0;
      if (!(AClass != null)) return false;
      do {
        cn = AClass.$classname;
        for (var $l = 0, $end = rtl.length(AClassParentList) - 1; $l <= $end; $l++) {
          I = $l;
          if (cn === rtl.rcArrR(AClassParentList,I)) return true;
        };
        AClass = AClass.$ancestor;
      } while (AClass != null);
      Result = false;
      return Result;
    };
    this.IsBitmap = function (AClass) {
      var Result = false;
      Result = this.IsDescendingClass(AClass,["TBitmap","TPicture","TTMSFNCBitmap","TGraphic"]);
      return Result;
    };
    this.IsStrings = function (AClass) {
      var Result = false;
      Result = this.IsDescendingClass(AClass,["TStrings"]);
      return Result;
    };
  });
  this.TTMSFNCJSONToClassPropertyType = {"0": "cptUndefined", cptUndefined: 0, "1": "cptString", cptString: 1, "2": "cptBoolean", cptBoolean: 2, "3": "cptDateTime", cptDateTime: 3, "4": "cptObject", cptObject: 4, "5": "cptDouble", cptDouble: 5, "6": "cptInteger", cptInteger: 6, "7": "cptInteger64", cptInteger64: 7, "8": "cptObjectArray", cptObjectArray: 8, "9": "cptStringArray", cptStringArray: 9, "10": "cptBooleanArray", cptBooleanArray: 10, "11": "cptDateTimeArray", cptDateTimeArray: 11, "12": "cptDoubleArray", cptDoubleArray: 12, "13": "cptIntegerArray", cptIntegerArray: 13, "14": "cptInteger64Array", cptInteger64Array: 14};
  this.$rtti.$Enum("TTMSFNCJSONToClassPropertyType",{minvalue: 0, maxvalue: 14, ordtype: 1, enumtype: this.TTMSFNCJSONToClassPropertyType});
  this.TTMSFNCJSONToClassBaseClass = {"0": "cbcNone", cbcNone: 0, "1": "cbcPersistent", cbcPersistent: 1};
  this.$rtti.$Enum("TTMSFNCJSONToClassBaseClass",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCJSONToClassBaseClass});
  rtl.recNewT(this,"TTMSFNCJSONToClassOptions",function () {
    this.SortProperties = false;
    this.DelphiCasing = false;
    this.RemoveSpecialCharacters = false;
    this.AddConstructor = false;
    this.AddDestructor = false;
    this.AddAssign = false;
    this.AddUnit = false;
    this.BaseClass = 0;
    this.AddImplementation = false;
    this.$eq = function (b) {
      return (this.SortProperties === b.SortProperties) && (this.DelphiCasing === b.DelphiCasing) && (this.RemoveSpecialCharacters === b.RemoveSpecialCharacters) && (this.AddConstructor === b.AddConstructor) && (this.AddDestructor === b.AddDestructor) && (this.AddAssign === b.AddAssign) && (this.AddUnit === b.AddUnit) && (this.BaseClass === b.BaseClass) && (this.AddImplementation === b.AddImplementation);
    };
    this.$assign = function (s) {
      this.SortProperties = s.SortProperties;
      this.DelphiCasing = s.DelphiCasing;
      this.RemoveSpecialCharacters = s.RemoveSpecialCharacters;
      this.AddConstructor = s.AddConstructor;
      this.AddDestructor = s.AddDestructor;
      this.AddAssign = s.AddAssign;
      this.AddUnit = s.AddUnit;
      this.BaseClass = s.BaseClass;
      this.AddImplementation = s.AddImplementation;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCJSONToClassOptions",{},this);
    $r.addField("SortProperties",rtl.boolean);
    $r.addField("DelphiCasing",rtl.boolean);
    $r.addField("RemoveSpecialCharacters",rtl.boolean);
    $r.addField("AddConstructor",rtl.boolean);
    $r.addField("AddDestructor",rtl.boolean);
    $r.addField("AddAssign",rtl.boolean);
    $r.addField("AddUnit",rtl.boolean);
    $r.addField("BaseClass",$mod.$rtti["TTMSFNCJSONToClassBaseClass"]);
    $r.addField("AddImplementation",rtl.boolean);
  });
  this.$rtti.$RefToProcVar("TTMSFNCJSONToClassExportEvent",{procsig: rtl.newTIProcSig([["APropertyName",rtl.string,1],["APropertyType",this.$rtti["TTMSFNCJSONToClassPropertyType"],1]])});
  rtl.createClass(this,"TTMSFNCJSONToClassProperty",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FName = "";
      this.FType = 0;
    };
    var a = ["and","array","as","asm","begin","case","class","const","constructor","destructor","dispinterface","div","do","downto","else","end","except","exports","file","finalization","finally","for","function","goto","if","implementation","in","inherited","initialization","inline","interface","is","label","library","mod","nil","not","object","of","or","out","packed","procedure","program","property","raise","record","repeat","resourcestring","set","shl","shr","string","then","threadvar","to","try","type","unit","until","uses","var","while","with","xor"];
    this.FixKeyWord = function (AValue) {
      var Result = "";
      Result = AValue;
      if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(pas.SysUtils.UpperCase(AValue),a) !== -1) Result = "&" + AValue;
      return Result;
    };
    this.IsObject = function () {
      var Result = false;
      Result = this.FType in rtl.createSet($mod.TTMSFNCJSONToClassPropertyType.cptObject,$mod.TTMSFNCJSONToClassPropertyType.cptObjectArray,$mod.TTMSFNCJSONToClassPropertyType.cptStringArray,$mod.TTMSFNCJSONToClassPropertyType.cptBooleanArray,$mod.TTMSFNCJSONToClassPropertyType.cptDateTimeArray,$mod.TTMSFNCJSONToClassPropertyType.cptDoubleArray,$mod.TTMSFNCJSONToClassPropertyType.cptIntegerArray,$mod.TTMSFNCJSONToClassPropertyType.cptInteger64Array);
      return Result;
    };
    this.DelphiName = function (ACallBack, AOptions, AFixKeyWord) {
      var Result = "";
      var n = "";
      var s = "";
      var c = "\x00";
      var sl = null;
      var I = 0;
      var p = "";
      var pt = 0;
      Result = "";
      if (this.FName.length > 0) {
        p = this.FName;
        pt = rtl.rc(this.FType,0,14);
        if (ACallBack != null) ACallBack({get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }},{get: function () {
            return pt;
          }, set: function (v) {
            rtl.rc(v,0,14);
            pt = v;
          }});
        sl = pas.Classes.TStringList.$create("Create$1");
        try {
          if (AOptions.RemoveSpecialCharacters) {
            s = p;
            p = "";
            for (var $in = s, $l = 0, $end = $in.length - 1; $l <= $end; $l++) {
              c = $in.charAt($l);
              if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsLetterOrDigit(c)) {
                p = p + c}
               else p = p + "_";
            };
          };
          pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Split("_",p,sl,false);
          for (var $l1 = 0, $end1 = sl.GetCount() - 1; $l1 <= $end1; $l1++) {
            I = $l1;
            n = sl.Get(I);
            if (n.length > 0) {
              if (AOptions.DelphiCasing) n = pas.SysUtils.UpperCase(rtl.rcCharAt(n,0)) + pas.System.Copy(n,2,n.length - 1);
            };
            Result = Result + n;
          };
          if (AFixKeyWord) Result = this.FixKeyWord(Result);
        } finally {
          sl = rtl.freeLoc(sl);
        };
      };
      return Result;
    };
    this.DelphiType = function (ACallBack, AOptions) {
      var Result = "";
      var n = "";
      var t = 0;
      Result = "";
      n = this.FName;
      t = rtl.rc(this.FType,0,14);
      if (ACallBack != null) ACallBack({get: function () {
          return n;
        }, set: function (v) {
          n = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          rtl.rc(v,0,14);
          t = v;
        }});
      var $tmp = t;
      if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptUndefined) {
        Result = "UNDEFINED"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptString) {
        Result = "string"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptBoolean) {
        Result = "Boolean"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptDateTime) {
        Result = "TDateTime"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptObject) {
        Result = "T" + this.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false)}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptDouble) {
        Result = "Double"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptInteger) {
        Result = "Integer"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptInteger64) {
        Result = "Int64"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptObjectArray) {
        Result = "TObjectList<" + "T" + this.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + ">"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptDoubleArray) {
        Result = "TList<Double>"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptStringArray) {
        Result = "TList<string>"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptBooleanArray) {
        Result = "TList<Boolean>"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptDateTimeArray) {
        Result = "TList<TDateTime>"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptIntegerArray) {
        Result = "TList<Integer>"}
       else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptInteger64Array) Result = "TList<Int64>";
      return Result;
    };
    this.Create$1 = function (AName, AType) {
      rtl.rc(AType,0,14);
      this.FName = AName;
      this.FType = rtl.rc(AType,0,14);
      return this;
    };
  });
  rtl.createClass(this,"TTMSFNCJSONToClassProperties",pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty,function () {
  });
  rtl.createClass(this,"TTMSFNCJSONToClassItem",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FProperties = null;
      this.FParentProperty = null;
    };
    this.$final = function () {
      this.FProperties = undefined;
      this.FParentProperty = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetProperties = function () {
      var Result = null;
      if (!(this.FProperties != null)) this.FProperties = $mod.TTMSFNCJSONToClassProperties.$create("Create$4",[true]);
      Result = this.FProperties;
      return Result;
    };
    this.GetClassName = function (ACallBack, AOptions) {
      var Result = "";
      Result = "TMyDelphiClass";
      if (this.FParentProperty != null) Result = "T" + this.FParentProperty.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false);
      return Result;
    };
    this.Create$1 = function (AParentProperty) {
      this.FParentProperty = AParentProperty;
      return this;
    };
    this.Destroy = function () {
      if (this.FProperties != null) rtl.free(this,"FProperties");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCJSONToClassItems",pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCJSONToClassItem,function () {
  });
  rtl.createClass(this,"TTMSFNCJSONToClass",pas.System.TObject,function () {
    this.FClasses = null;
    this.JSONValueToClass = function (AParentProperty, AJSONValue) {
      var v = null;
      var n = "";
      var p = null;
      var sz = 0;
      var K = 0;
      var t = 0;
      var ci = null;
      if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(AJSONValue)) {
        ci = $mod.TTMSFNCJSONToClassItem.$create("Create$1",[AParentProperty]);
        this.FClasses.Add(ci);
        sz = rtl.rc(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONObjectSize(rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONObject)),-2147483648,2147483647);
        for (var $l = 0, $end = sz - 1; $l <= $end; $l++) {
          K = $l;
          n = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONObjectName(rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONObject),K);
          v = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValue(AJSONValue,n);
          p = null;
          if (v != null) {
            t = rtl.rc(this.JSONValueToPropertyType(v),0,14);
            if (t !== $mod.TTMSFNCJSONToClassPropertyType.cptUndefined) {
              p = $mod.TTMSFNCJSONToClassProperty.$create("Create$1",[n,t]);
              ci.GetProperties().Add(p);
            };
          };
          this.JSONValueToClass(p,v);
        };
      } else if (pas["WEBLib.JSON"].TJSONArray.isPrototypeOf(AJSONValue)) {
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArraySize(rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONArray)) > 0) {
          t = rtl.rc(this.JSONValueToPropertyType(AJSONValue),0,14);
          v = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArrayItem(rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONArray),0);
          if (!(AParentProperty != null) && (t !== $mod.TTMSFNCJSONToClassPropertyType.cptUndefined)) {
            ci = $mod.TTMSFNCJSONToClassItem.$create("Create$1",[null]);
            p = $mod.TTMSFNCJSONToClassProperty.$create("Create$1",["Items",t]);
            ci.GetProperties().Add(p);
            this.FClasses.Add(ci);
            AParentProperty = p;
          };
          this.JSONValueToClass(AParentProperty,v);
        } else {
          ci = $mod.TTMSFNCJSONToClassItem.$create("Create$1",[AParentProperty]);
          this.FClasses.Add(ci);
        };
      };
    };
    this.JSONValueToPropertyType = function (AJSONValue) {
      var Result = 0;
      var s = "";
      var dt = 0.0;
      var b = false;
      var v = null;
      var p = 0;
      var d = 0.0;
      var i = 0;
      var i64 = 0;
      Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptUndefined,0,14);
      if (!(AJSONValue != null)) return Result;
      if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(AJSONValue)) {
        Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptObject,0,14)}
       else if (pas["WEBLib.JSON"].TJSONArray.isPrototypeOf(AJSONValue)) {
        Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptObjectArray,0,14);
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArraySize(rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONArray)) > 0) {
          v = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArrayItem(rtl.as(AJSONValue,pas["WEBLib.JSON"].TJSONArray),0);
          if (v != null) {
            p = rtl.rc(this.JSONValueToPropertyType(v),0,14);
            var $tmp = p;
            if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptString) {
              Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptStringArray,0,14)}
             else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptBoolean) {
              Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptBooleanArray,0,14)}
             else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptDateTime) {
              Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptDateTimeArray,0,14)}
             else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptObject) {
              Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptObjectArray,0,14)}
             else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptDouble) {
              Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptDoubleArray,0,14)}
             else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptInteger) {
              Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptIntegerArray,0,14)}
             else if ($tmp === $mod.TTMSFNCJSONToClassPropertyType.cptInteger64) Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptInteger64Array,0,14);
          };
        };
      } else if (pas["WEBLib.JSON"].TJSONNumber.isPrototypeOf(AJSONValue)) {
        s = AJSONValue.GetStrValue();
        if (pas.SysUtils.TryStrToInt(s,{get: function () {
            return i;
          }, set: function (v) {
            rtl.rc(v,-2147483648,2147483647);
            i = v;
          }})) {
          Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptInteger,0,14)}
         else if (pas.SysUtils.TryStrToInt64(s,{get: function () {
            return i64;
          }, set: function (v) {
            rtl.rc(v,-9007199254740991,9007199254740991);
            i64 = v;
          }})) {
          Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptInteger64,0,14)}
         else if (!pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TryStrToFloatDot(s,{get: function () {
            return d;
          }, set: function (v) {
            d = v;
          }})) {
          Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptString,0,14)}
         else Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptDouble,0,14);
      } else if (pas["WEBLib.JSON"].TJSONTrue.isPrototypeOf(AJSONValue) || pas["WEBLib.JSON"].TJSONFalse.isPrototypeOf(AJSONValue)) {
        Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptBoolean,0,14)}
       else if (pas["WEBLib.JSON"].TJSONString.isPrototypeOf(AJSONValue)) {
        s = AJSONValue.GetStrValue();
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TryStrToFloatDot(s,{get: function () {
            return d;
          }, set: function (v) {
            d = v;
          }})) {
          Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptString,0,14)}
         else if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsDate(s,{get: function () {
            return dt;
          }, set: function (v) {
            dt = v;
          }}) || (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ISOToDateTime(s,true) > 0) || pas.SysUtils.TryStrToDateTime(s,{get: function () {
            return dt;
          }, set: function (v) {
            dt = v;
          }})) {
          Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptDateTime,0,14)}
         else if (pas.SysUtils.TryStrToBool(s,{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }})) {
          Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptBoolean,0,14)}
         else Result = rtl.rc($mod.TTMSFNCJSONToClassPropertyType.cptString,0,14);
      };
      return Result;
    };
    this.ExportToDelphi = function (AJSONString, AOptions, ACallBack) {
      var $Self = this;
      var Result = "";
      var root = null;
      var I = 0;
      var K = 0;
      var c = null;
      var sl = null;
      var p = null;
      var ind = "";
      var cn = "";
      var slRendered = null;
      function SortList(AList) {
        var $ir = rtl.createIntfRefs();
        try {
          AList.Sort$1($ir.ref(1,pas["Generics.Defaults"].TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.Construct(function (ALeft, ARight) {
            var Result = 0;
            Result = rtl.rc(pas.SysUtils.CompareText(ALeft.FName,ARight.FName),-2147483648,2147483647);
            return Result;
          })));
        } finally {
          $ir.free();
        };
      };
      root = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ParseJSON(AJSONString);
      if (root != null) {
        try {
          $mod.TTMSFNCJSONToClass.FClasses = $mod.TTMSFNCJSONToClassItems.$create("Create$4",[true]);
          try {
            this.JSONValueToClass(null,root);
            sl = pas.Classes.TStringList.$create("Create$1");
            slRendered = pas.Classes.TStringList.$create("Create$1");
            try {
              ind = "";
              if (AOptions.AddUnit) {
                sl.Add("unit MyDelphiUnit;");
                sl.Add("");
                sl.Add("interface");
                sl.Add("");
                sl.Add("uses");
                sl.Add("  Classes, System.Generics.Collections;");
                sl.Add("");
                sl.Add("type");
                ind = "  ";
              };
              for (var $l = this.FClasses.FLength - 1; $l >= 0; $l--) {
                I = $l;
                c = this.FClasses.GetItem(I);
                cn = c.GetClassName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions));
                if (slRendered.IndexOf(cn) === -1) {
                  var $tmp = AOptions.BaseClass;
                  if ($tmp === $mod.TTMSFNCJSONToClassBaseClass.cbcNone) {
                    sl.Add(ind + cn + " = class")}
                   else if ($tmp === $mod.TTMSFNCJSONToClassBaseClass.cbcPersistent) sl.Add(ind + cn + " = class(TPersistent)");
                  if (AOptions.SortProperties) SortList(c.GetProperties());
                  if (c.GetProperties().FLength > 0) {
                    sl.Add(ind + "private");
                    for (var $l1 = 0, $end = c.GetProperties().FLength - 1; $l1 <= $end; $l1++) {
                      K = $l1;
                      p = c.GetProperties().GetItem(K);
                      sl.Add(ind + "  F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + ": " + p.DelphiType(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions)) + ";");
                    };
                  };
                  if (AOptions.AddConstructor || AOptions.AddDestructor || AOptions.AddAssign) {
                    sl.Add(ind + "public");
                    if (AOptions.AddAssign) {
                      var $tmp1 = AOptions.BaseClass;
                      if ($tmp1 === $mod.TTMSFNCJSONToClassBaseClass.cbcNone) {
                        sl.Add(ind + "  procedure Assign(Source: TObject);")}
                       else if ($tmp1 === $mod.TTMSFNCJSONToClassBaseClass.cbcPersistent) sl.Add(ind + "  procedure Assign(Source: TPersistent); override;");
                    };
                    if (AOptions.AddConstructor) sl.Add(ind + "  constructor Create;");
                    if (AOptions.AddDestructor) sl.Add(ind + "  destructor Destroy; override;");
                  };
                  if (c.GetProperties().FLength > 0) {
                    sl.Add(ind + "published");
                    for (var $l2 = 0, $end1 = c.GetProperties().FLength - 1; $l2 <= $end1; $l2++) {
                      K = $l2;
                      p = c.GetProperties().GetItem(K);
                      sl.Add(ind + "  property " + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),true) + ": " + p.DelphiType(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions)) + " read F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + " write F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + ";");
                    };
                  };
                  sl.Add(ind + "end;");
                  sl.Add("");
                  slRendered.Add(cn);
                };
              };
              slRendered.Clear();
              if (AOptions.AddUnit) {
                sl.Add("implementation");
                sl.Add("");
                if (AOptions.AddImplementation) {
                  slRendered.Clear();
                  for (var $l3 = this.FClasses.FLength - 1; $l3 >= 0; $l3--) {
                    I = $l3;
                    c = this.FClasses.GetItem(I);
                    cn = c.GetClassName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions));
                    if (slRendered.IndexOf(cn) === -1) {
                      if (AOptions.AddConstructor || AOptions.AddDestructor || AOptions.AddAssign) {
                        sl.Add("{ " + c.GetClassName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions)) + " }");
                        sl.Add("");
                        if (AOptions.AddAssign) {
                          var $tmp2 = AOptions.BaseClass;
                          if ($tmp2 === $mod.TTMSFNCJSONToClassBaseClass.cbcNone) {
                            sl.Add("procedure " + cn + ".Assign(Source: TObject);")}
                           else if ($tmp2 === $mod.TTMSFNCJSONToClassBaseClass.cbcPersistent) sl.Add("procedure " + cn + ".Assign(Source: TPersistent);");
                          sl.Add("begin");
                          sl.Add("  if (Source is " + cn + ") then");
                          sl.Add("  begin");
                          for (var $l4 = 0, $end2 = c.GetProperties().FLength - 1; $l4 <= $end2; $l4++) {
                            K = $l4;
                            p = c.GetProperties().GetItem(K);
                            if (p.FType === $mod.TTMSFNCJSONToClassPropertyType.cptObject) {
                              sl.Add("    F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + ".Assign((Source as " + cn + ")." + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),true) + ");")}
                             else if (!p.IsObject()) {
                              sl.Add("    F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + " := (Source as " + cn + ")." + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),true) + ";")}
                             else sl.Add("    //F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + " := (Source as " + cn + ")." + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),true) + "; //implement list copy");
                          };
                          sl.Add("  end;");
                          sl.Add("end;");
                          sl.Add("");
                        };
                        if (AOptions.AddConstructor) {
                          sl.Add("constructor " + cn + ".Create;");
                          sl.Add("begin");
                          sl.Add("  inherited;");
                          for (var $l5 = 0, $end3 = c.GetProperties().FLength - 1; $l5 <= $end3; $l5++) {
                            K = $l5;
                            p = c.GetProperties().GetItem(K);
                            if (p.IsObject()) sl.Add("  F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + " := " + p.DelphiType(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions)) + ".Create;");
                          };
                          sl.Add("end;");
                          sl.Add("");
                        };
                        if (AOptions.AddDestructor) {
                          sl.Add("destructor " + cn + ".Destroy;");
                          sl.Add("begin");
                          for (var $l6 = 0, $end4 = c.GetProperties().FLength - 1; $l6 <= $end4; $l6++) {
                            K = $l6;
                            p = c.GetProperties().GetItem(K);
                            if (p.IsObject()) sl.Add("  F" + p.DelphiName(ACallBack,$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),false) + ".Free;");
                          };
                          sl.Add("  inherited;");
                          sl.Add("end;");
                          sl.Add("");
                        };
                        slRendered.Add(cn);
                      };
                    };
                  };
                };
                sl.Add("end.");
              };
              while (sl.GetCount() > 0) {
                if (sl.Get(sl.GetCount() - 1) === "") {
                  sl.Delete(sl.GetCount() - 1)}
                 else break;
              };
              Result = sl.GetTextStr();
            } finally {
              slRendered = rtl.freeLoc(slRendered);
              sl = rtl.freeLoc(sl);
            };
          } finally {
            rtl.free(this,"FClasses");
          };
        } finally {
          root = rtl.freeLoc(root);
        };
      };
      return Result;
    };
    this.ExportToDelphi$1 = function (AJSONString, ACallBack) {
      var Result = "";
      Result = this.ExportToDelphi(AJSONString,$mod.TTMSFNCJSONToClassOptions.$clone($mod.DefaultJSONToClassOptions()),ACallBack);
      return Result;
    };
    this.ExportToDelphi$2 = function (AJSONValue, AOptions, ACallBack) {
      var Result = "";
      Result = this.ExportToDelphi(AJSONValue.ToString(),$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),ACallBack);
      return Result;
    };
    this.ExportToDelphi$3 = function (AJSONValue, ACallBack) {
      var Result = "";
      Result = this.ExportToDelphi(AJSONValue.ToString(),$mod.TTMSFNCJSONToClassOptions.$clone($mod.DefaultJSONToClassOptions()),ACallBack);
      return Result;
    };
    this.ExportToDelphiFromFile = function (AFileName, ACallBack) {
      var Result = "";
      Result = this.ExportToDelphiFromFile$1(AFileName,$mod.TTMSFNCJSONToClassOptions.$clone($mod.DefaultJSONToClassOptions()),ACallBack);
      return Result;
    };
    this.ExportToDelphiFromFile$1 = function (AFileName, AOptions, ACallBack) {
      var Result = "";
      var sl = null;
      sl = pas.Classes.TStringList.$create("Create$1");
      try {
        sl.LoadFromFile(AFileName);
        Result = this.ExportToDelphi(sl.GetTextStr(),$mod.TTMSFNCJSONToClassOptions.$clone(AOptions),ACallBack);
      } finally {
        sl = rtl.freeLoc(sl);
      };
      return Result;
    };
  });
  this.$rtti.$StaticArray("ExcludePropertyList$a",{dims: [59], eltype: rtl.string});
  this.ExcludePropertyList = ["Align","AllowFocus","Anchors","BevelEdges","BevelInner","BevelKind","BevelOuter","BevelWidth","BiDiMode","BitmapContainer","BorderSpacing","CanParentFocus","ClipChildren","ClipParent","Constraints","Ctl3D","DisableFocusEffect","DoubleBuffered","DragCursor","DragKind","DragMode","ElementID","ElementClassName","ElementPosition","ElementFont","Enabled","EnableDragHighLight","Height","Hint","HitTest","Left","Locked","Margins","Name","Opacity","Padding","ParentBiDiMode","ParentColor","ParentCtl3D","ParentDoubleBuffered","ParentFont","ParentShowHint","PopupMenu","Position","RotationAngle","RotationCenter","Scale","ShowHint","Size","StyleElements","StyleName","TabOrder","TabStop","Tag","Top","Touch","TouchTargetExpansion","Visible","Width"];
  this.DefaultJSONToClassOptions = function () {
    var Result = $mod.TTMSFNCJSONToClassOptions.$new();
    Result.AddUnit = false;
    Result.AddImplementation = false;
    Result.AddConstructor = false;
    Result.AddDestructor = false;
    Result.AddAssign = false;
    Result.BaseClass = $mod.TTMSFNCJSONToClassBaseClass.cbcNone;
    Result.SortProperties = true;
    Result.DelphiCasing = true;
    Result.RemoveSpecialCharacters = true;
    return Result;
  };
  $mod.$implcode = function () {
    $impl.gcNull = -1;
    $mod.$rtti.$ClassRef("TCustomControlClass",{instancetype: pas["WEBLib.Controls"].$rtti["TCustomControl"]});
    $impl.GetTypeInfoEx = function (APropInfo) {
      var Result = null;
      Result = APropInfo.typeinfo;
      return Result;
    };
    $impl.GetColorRed = function (AColor) {
      var Result = 0;
      AColor = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = pas["WEBLib.Graphics"].GetRValue(AColor);
      return Result;
    };
    $impl.GetColorGreen = function (AColor) {
      var Result = 0;
      AColor = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = pas["WEBLib.Graphics"].GetGValue(AColor);
      return Result;
    };
    $impl.GetColorBlue = function (AColor) {
      var Result = 0;
      AColor = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = pas["WEBLib.Graphics"].GetBValue(AColor);
      return Result;
    };
    $impl.HTMLToColorEx = function (AHTML) {
      var Result = 0;
      function HexVal(s) {
        var Result = 0;
        var i = 0;
        var j = 0;
        var i1 = 0;
        var i2 = 0;
        if (s.length < 2) {
          Result = 0;
          return Result;
        };
        i1 = 1;
        i2 = 2;
        if (s.charAt(i1 - 1) >= "A") {
          i = (s.charCodeAt(i1 - 1) - 65) + 10}
         else i = s.charCodeAt(i1 - 1) - 48;
        if (s.charAt(i2 - 1) >= "A") {
          j = (s.charCodeAt(i2 - 1) - 65) + 10}
         else j = s.charCodeAt(i2 - 1) - 48;
        Result = (i << 4) + j;
        return Result;
      };
      var r = 0;
      var g = 0;
      var b = 0;
      r = HexVal(pas.System.Copy(AHTML,2,2));
      g = HexVal(pas.System.Copy(AHTML,4,2)) << 8;
      b = HexVal(pas.System.Copy(AHTML,6,2)) << 16;
      Result = b + g + r;
      return Result;
    };
    var HTMLHexColor = "#RRGGBB";
    var HexDigit = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
    $impl.ColorToHTMLEx = function (AColor) {
      var Result = "";
      var c = 0;
      var i = 0;
      i = 1;
      c = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = HTMLHexColor;
      Result = rtl.setCharAt(Result,(1 + i) - 1,HexDigit[$impl.GetColorRed(c) >>> 4]);
      Result = rtl.setCharAt(Result,(2 + i) - 1,HexDigit[$impl.GetColorRed(c) & 0xF]);
      Result = rtl.setCharAt(Result,(3 + i) - 1,HexDigit[$impl.GetColorGreen(c) >>> 4]);
      Result = rtl.setCharAt(Result,(4 + i) - 1,HexDigit[$impl.GetColorGreen(c) & 0xF]);
      Result = rtl.setCharAt(Result,(5 + i) - 1,HexDigit[$impl.GetColorBlue(c) >>> 4]);
      Result = rtl.setCharAt(Result,(6 + i) - 1,HexDigit[$impl.GetColorBlue(c) & 0xF]);
      return Result;
    };
  };
  $mod.$init = function () {
    $mod.TTMSFNCPersistence.ClassTypeVariable = "$type";
    $mod.TTMSFNCPersistence.IgnoreExceptions = false;
  };
},["RTTI","DateUtils","StrUtils","WEBLib.Controls","WEBLib.Graphics","JS","Generics.Defaults","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCTypes",["System","Types","Classes","WEBLib.Graphics","WEBLib.Controls","SysUtils","Math","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.createInterface(this,"ITMSFNCProductInfo","{C53329EA-7B3A-4507-AD9E-88ACD6A85054}",["GetVersion","GetDocURL","GetTipsURL"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetVersion",1,[],2,rtl.string);
    $r.addMethod("GetDocURL",1,[],2,rtl.string);
    $r.addMethod("GetTipsURL",1,[],2,rtl.string);
  });
  this.TTMSFNCBaseDocURL = "https://download.tmssoftware.com/doc/";
  this.TTMSFNCBaseTipsURL = "https://www.tmssoftware.com/site/tmsfnccore.asp?s=faq";
  this.pidWinARM32x = 0x800;
  this.pidWinARM64x = 0x40000;
  this.pidWeb = 0x1000;
  this.ssCommand = pas.Classes.TShiftState$a.ssCtrl;
  this.TMSPlatformsWinOnly = 0;
  this.TMSPlatformsWinMac = 0;
  this.TMSPlatformsDesktop = 0;
  this.TMSPlatforms = 0;
  this.TMSPlatformsWeb = 0;
  this.TMSPlatformsWebDesktop = 0;
  this.KEY_CANCEL = 3;
  this.KEY_CONTROL = 17;
  this.KEY_SHIFT = 16;
  this.KEY_ESCAPE = 27;
  this.KEY_INSERT = 45;
  this.KEY_DELETE = 46;
  this.KEY_TAB = 9;
  this.KEY_SUBTRACT = 109;
  this.KEY_ADD = 107;
  this.KEY_MULTIPLY = 106;
  this.KEY_DIVIDE = 111;
  this.KEY_PRIOR = 33;
  this.KEY_NEXT = 34;
  this.KEY_UP = 38;
  this.KEY_DOWN = 40;
  this.KEY_RIGHT = 39;
  this.KEY_LEFT = 37;
  this.KEY_HOME = 36;
  this.KEY_END = 35;
  this.KEY_RETURN = 13;
  this.KEY_SPACE = 32;
  this.KEY_MENU = 18;
  this.KEY_BACK = 8;
  this.KEY_F1 = 112;
  this.KEY_F2 = 113;
  this.KEY_F3 = 114;
  this.KEY_F4 = 115;
  this.KEY_F5 = 116;
  this.KEY_F6 = 117;
  this.KEY_F7 = 118;
  this.KEY_F8 = 119;
  this.KEY_F9 = 120;
  this.KEY_F10 = 121;
  this.KEY_F11 = 122;
  this.KEY_F12 = 123;
  this.SReadError = "Stream read error";
  this.SWriteError = "Stream write error";
  this.$rtti.$RefToProcVar("TTMSFNCStreamLoadedEvent",{procsig: rtl.newTIProcSig([])});
  rtl.createHelper(this,"TTMSFNCMemoryStream",null,function () {
    this.GetBytes = function () {
      var Result = [];
      var p = 0;
      var b = [];
      p = this.GetPosition();
      this.SetPosition(0);
      b = rtl.arraySetLength(b,0,this.GetSize());
      this.Read$1(rtl.arrayRef(b),0,rtl.length(b));
      Result = rtl.arrayRef(b);
      this.SetPosition(p);
      return Result;
    };
    this.OpenFile = function (FileType) {
      var b = [];
      var s = "";
      var f = "";
      f = "tmp." + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetFileExtension(FileType);
      b = rtl.arrayRef($mod.TTMSFNCMemoryStream.GetBytes.call(this));
      s = FileType;
      var file = new Blob([new Uint8Array(b)], {type: s});
      var fileURL = window.URL.createObjectURL(file);
      if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveOrOpenBlob(file, f);
        return;
      }
      window.open(fileURL);
    };
    this.SaveToFile = function (FileName) {
      var s = "";
      var b = [];
      s = FileName;
      b = rtl.arrayRef($mod.TTMSFNCMemoryStream.GetBytes.call(this));
      var userAgent = navigator.userAgent.toLowerCase();
          if (userAgent.indexOf('electron/') > -1) {
            var arr = new Uint8Array(b);
            nfs.writeFileSync(s, arr);
          } else {
            var newBlob = new Blob([new Uint8Array(b)], {type: "octet/stream"})
      
            if (window.navigator && window.navigator.msSaveOrOpenBlob) {
              window.navigator.msSaveOrOpenBlob(newBlob, s);
              return;
            }
      
            const data = window.URL.createObjectURL(newBlob);
            var link = document.createElement('a');
            link.href = data;
            link.download = s;
            document.body.appendChild(link);
            link.click();
            setTimeout(function(){
             document.body.removeChild(link);
              window.URL.revokeObjectURL(data);
            }, 100);
          };
    };
  });
  rtl.recNewT(this,"TSizeF",function () {
    this.cx = 0.0;
    this.cy = 0.0;
    this.$eq = function (b) {
      return (this.cx === b.cx) && (this.cy === b.cy);
    };
    this.$assign = function (s) {
      this.cx = s.cx;
      this.cy = s.cy;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSizeF",{},this);
    $r.addField("cx",rtl.double);
    $r.addField("cy",rtl.double);
  });
  rtl.recNewT(this,"TPointF",function () {
    this.X = 0.0;
    this.Y = 0.0;
    this.$eq = function (b) {
      return (this.X === b.X) && (this.Y === b.Y);
    };
    this.$assign = function (s) {
      this.X = s.X;
      this.Y = s.Y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPointF",{},this);
    $r.addField("X",rtl.double);
    $r.addField("Y",rtl.double);
  });
  rtl.recNewT(this,"TRectF",function () {
    this.Left = 0.0;
    this.Top = 0.0;
    this.Right = 0.0;
    this.Bottom = 0.0;
    this.$eq = function (b) {
      return (this.Left === b.Left) && (this.Top === b.Top) && (this.Right === b.Right) && (this.Bottom === b.Bottom);
    };
    this.$assign = function (s) {
      this.Left = s.Left;
      this.Top = s.Top;
      this.Right = s.Right;
      this.Bottom = s.Bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TRectF",{},this);
    $r.addField("Left",rtl.double);
    $r.addField("Top",rtl.double);
    $r.addField("Right",rtl.double);
    $r.addField("Bottom",rtl.double);
  });
  this.$rtti.$Class("TTMSFNCBitmap");
  rtl.createClass(this,"TTMSFNCSVGImport",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FRotationAngle = 0.0;
      this.FViewRect = $mod.TRectF.$new();
      this.FGrayScale = false;
      this.FCustomFillColor = 0;
      this.FCustomStrokeColor = 0;
      this.FTintColor = 0;
      this.FCustomOpacity = 0.0;
    };
    this.$final = function () {
      this.FViewRect = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function () {
      this.FRotationAngle = 0;
      this.FCustomOpacity = -1;
      this.FCustomFillColor = -1;
      this.FCustomStrokeColor = -1;
      this.FTintColor = -1;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCSVGImport.isPrototypeOf(Source)) {
        this.FGrayScale = rtl.as(Source,$mod.TTMSFNCSVGImport).FGrayScale;
        this.FCustomFillColor = rtl.as(Source,$mod.TTMSFNCSVGImport).FCustomFillColor;
        this.FCustomStrokeColor = rtl.as(Source,$mod.TTMSFNCSVGImport).FCustomStrokeColor;
        this.FTintColor = rtl.as(Source,$mod.TTMSFNCSVGImport).FTintColor;
        this.FCustomOpacity = rtl.as(Source,$mod.TTMSFNCSVGImport).FCustomOpacity;
        this.FRotationAngle = rtl.as(Source,$mod.TTMSFNCSVGImport).FRotationAngle;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("GrayScale",0,rtl.boolean,"FGrayScale","FGrayScale",4,{Default: false});
    $r.addProperty("CustomFillColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FCustomFillColor","FCustomFillColor");
    $r.addProperty("CustomStrokeColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FCustomStrokeColor","FCustomStrokeColor");
    $r.addProperty("TintColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FTintColor","FTintColor");
    $r.addProperty("CustomOpacity",0,rtl.double,"FCustomOpacity","FCustomOpacity");
    $r.addProperty("RotationAngle",0,rtl.double,"FRotationAngle","FRotationAngle");
  });
  rtl.createClass(this,"TTMSFNCBitmap",pas["WEBLib.Graphics"].TBitmap,function () {
    this.CreateFromStream = function (AStream) {
      this.Create$3();
      this.LoadFromStream(AStream);
      return this;
    };
  });
  this.$rtti.$DynArray("TTMSFNCObjectExcludePropertyListArray",{eltype: rtl.string});
  rtl.createHelper(this,"TTMSFNCObjectHelper",null,function () {
    this.ToJSONValue = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ParseJSON($mod.TTMSFNCObjectHelper.ToJSON$1.call(this));
      return Result;
    };
    this.ToJSON = function (AExcludedProperties) {
      var Result = "";
      var s = null;
      var p = null;
      var arr = [];
      var I = 0;
      var ep = [];
      arr = rtl.arraySetLength(arr,"",rtl.length(AExcludedProperties));
      for (var $l = 0, $end = rtl.length(AExcludedProperties) - 1; $l <= $end; $l++) {
        I = $l;
        arr[I] = AExcludedProperties[I];
      };
      s = pas.Classes.TStringStream.$create("Create$3",["",pas.SysUtils.TEncoding.GetANSI(),true]);
      p = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.$create("Create");
      try {
        ep = p.FExcludeProperties;
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.FExcludeProperties = rtl.arrayRef(arr);
        p.$class.SaveSettingsToStream(this,s);
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.FExcludeProperties = rtl.arrayRef(ep);
        Result = s.GetDataString();
      } finally {
        p = rtl.freeLoc(p);
        s = rtl.freeLoc(s);
      };
      return Result;
    };
    this.ToJSON$1 = function () {
      var Result = "";
      var s = null;
      s = pas.Classes.TStringStream.$create("Create$3",["",pas.SysUtils.TEncoding.GetANSI(),true]);
      try {
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToStream(this,s);
        Result = s.GetDataString();
      } finally {
        s = rtl.freeLoc(s);
      };
      return Result;
    };
    this.FromJSON = function (Value) {
      var s = null;
      var cs = "";
      var obj = null;
      s = pas.Classes.TStringStream.$create("Create$3",[Value,pas.SysUtils.TEncoding.GetANSI(),true]);
      try {
        obj = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.FIOReference;
        cs = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.ClassTypeVariable;
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.ClassTypeVariable = "";
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.FIOReference = this;
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromStream(this,s);
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.ClassTypeVariable = cs;
        pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.FIOReference = obj;
      } finally {
        s = rtl.freeLoc(s);
      };
    };
    this.Log = function () {
      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Log($mod.TTMSFNCObjectHelper.ToJSON$1.call(this));
    };
    this.SaveToJSONFile = function (AFileName) {
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToFile(this,AFileName);
    };
    this.LoadFromJSONFile = function (AFileName) {
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromFile(this,AFileName);
    };
    this.SaveToJSONStream = function (AStream) {
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToStream(this,AStream);
    };
    this.LoadFromJSONStream = function (AStream) {
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromStream(this,AStream);
    };
  });
  rtl.createHelper(this,"TTMSFNCJSONValueHelper",null,function () {
    this.GetProperties = function (AName) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValue(this,AName);
      return Result;
    };
    this.GetAsArray = function () {
      var Result = null;
      Result = null;
      if (pas["WEBLib.JSON"].TJSONArray.isPrototypeOf(this)) Result = rtl.as(this,pas["WEBLib.JSON"].TJSONArray);
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      Result = "";
      if (this != null) Result = this.GetStrValue();
      return Result;
    };
    this.GetAsDouble = function () {
      var Result = 0.0;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValueAsDouble(this);
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValueAsInteger(this);
      return Result;
    };
    this.GetAsBoolean = function () {
      var Result = false;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValueAsBoolean(this);
      return Result;
    };
    this.Find = function (APath) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FindJSONValue(this,APath);
      return Result;
    };
  });
  rtl.createHelper(this,"TTMSFNCJSONArrayHelper",null,function () {
    this.GetValues = function (AIndex) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArrayItem(this,AIndex);
      return Result;
    };
    this.GetLength = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArraySize(this);
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCMargins",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FRight = 0.0;
      this.FBottom = 0.0;
      this.FTop = 0.0;
      this.FLeft = 0.0;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetBottom = function (Value) {
      if (this.FBottom !== Value) {
        this.FBottom = Value;
        this.Changed();
      };
    };
    this.SetLeft = function (Value) {
      if (this.FLeft !== Value) {
        this.FLeft = Value;
        this.Changed();
      };
    };
    this.SetRight = function (Value) {
      if (this.FRight !== Value) {
        this.FRight = Value;
        this.Changed();
      };
    };
    this.SetTop = function (Value) {
      if (this.FTop !== Value) {
        this.FTop = Value;
        this.Changed();
      };
    };
    this.IsLeftStored = function () {
      var Result = false;
      Result = this.FLeft !== 0;
      return Result;
    };
    this.IsTopStored = function () {
      var Result = false;
      Result = this.FTop !== 0;
      return Result;
    };
    this.IsRightStored = function () {
      var Result = false;
      Result = this.FRight !== 0;
      return Result;
    };
    this.IsBottomStored = function () {
      var Result = false;
      Result = this.FBottom !== 0;
      return Result;
    };
    this.GetRect = function () {
      var Result = $mod.TRectF.$new();
      Result.$assign($mod.RectF(this.FLeft,this.FTop,this.FRight,this.FBottom));
      return Result;
    };
    this.SetRect = function (Value) {
      this.FLeft = Value.Left;
      this.FTop = Value.Top;
      this.FRight = Value.Right;
      this.FBottom = Value.Bottom;
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      this.FLeft = 0;
      this.FBottom = 0;
      this.FRight = 0;
      this.FTop = 0;
      return this;
    };
    this.Create$2 = function (ARect) {
      this.FLeft = ARect.Left;
      this.FBottom = ARect.Bottom;
      this.FRight = ARect.Right;
      this.FTop = ARect.Top;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCMargins.isPrototypeOf(Source)) {
        this.FLeft = rtl.as(Source,$mod.TTMSFNCMargins).FLeft;
        this.FTop = rtl.as(Source,$mod.TTMSFNCMargins).FTop;
        this.FRight = rtl.as(Source,$mod.TTMSFNCMargins).FRight;
        this.FBottom = rtl.as(Source,$mod.TTMSFNCMargins).FBottom;
      };
    };
    this.Empty = function () {
      var Result = false;
      var r = $mod.TRectF.$new();
      r.$assign($mod.RectF(this.FLeft,this.FTop,this.FRight,this.FBottom));
      Result = $mod.RectIsEmpty(r);
      return Result;
    };
    this.PaddingRect = function (R) {
      var Result = $mod.TRectF.$new();
      Result.$assign($mod.RectF(R.Left + this.FLeft,R.Top + this.FTop,R.Right - this.FRight,R.Bottom - this.FBottom));
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Left",14,rtl.double,"FLeft","SetLeft",4,{stored: "IsLeftStored"});
    $r.addProperty("Top",14,rtl.double,"FTop","SetTop",4,{stored: "IsTopStored"});
    $r.addProperty("Right",14,rtl.double,"FRight","SetRight",4,{stored: "IsRightStored"});
    $r.addProperty("Bottom",14,rtl.double,"FBottom","SetBottom",4,{stored: "IsBottomStored"});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCPoint",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FY = 0.0;
      this.FX = 0.0;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetX = function (Value) {
      if (this.FX !== Value) {
        this.FX = Value;
        this.Changed();
      };
    };
    this.SetY = function (Value) {
      if (this.FY !== Value) {
        this.FY = Value;
        this.Changed();
      };
    };
    this.IsXStored = function () {
      var Result = false;
      Result = this.FX !== 0;
      return Result;
    };
    this.IsYStored = function () {
      var Result = false;
      Result = this.FY !== 0;
      return Result;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      this.FX = 0;
      this.FY = 0;
      return this;
    };
    this.Create$2 = function (APoint) {
      this.FX = APoint.X;
      this.FY = APoint.Y;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCPoint.isPrototypeOf(Source)) {
        this.FX = rtl.as(Source,$mod.TTMSFNCPoint).FX;
        this.FY = rtl.as(Source,$mod.TTMSFNCPoint).FY;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("X",14,rtl.double,"FX","SetX",4,{stored: "IsXStored"});
    $r.addProperty("Y",14,rtl.double,"FY","SetY",4,{stored: "IsYStored"});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCScaledBitmap",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FBitmap = null;
      this.FScale = 0.0;
      this.FBitmapName = "";
    };
    this.$final = function () {
      this.FBitmap = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.IsScaleStored = function () {
      var Result = false;
      Result = this.FScale !== 1.0;
      return Result;
    };
    this.SetBitmap = function (Value) {
      if (this.FBitmap !== Value) {
        this.FBitmap.Assign(Value);
        this.Changed(false);
      };
    };
    this.SetScale = function (Value) {
      if (this.FScale !== Value) {
        this.FScale = Value;
        this.Changed(false);
      };
    };
    this.SetBitmapName = function (Value) {
      if (this.FBitmapName !== Value) {
        this.FBitmapName = Value;
        this.Changed(false);
      };
    };
    this.BitmapChanged = function (Sender) {
      this.Changed(false);
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FBitmap = $mod.TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FScale = 1.0;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCScaledBitmap.isPrototypeOf(Source)) {
        this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCScaledBitmap).FBitmap);
        this.FBitmapName = rtl.as(Source,$mod.TTMSFNCScaledBitmap).FBitmapName;
        this.FScale = rtl.as(Source,$mod.TTMSFNCScaledBitmap).FScale;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Bitmap",2,$mod.$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapName",2,rtl.string,"FBitmapName","SetBitmapName");
    $r.addProperty("Scale",14,rtl.double,"FScale","SetScale",4,{stored: "IsScaleStored"});
  });
  rtl.createClass(this,"TTMSFNCScaledBitmaps",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItems = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItems = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.GetBitmap = function (Scale) {
      var Result = null;
      Result = this.GetBitmapByScale(Scale);
      return Result;
    };
    this.SetBitmap = function (Scale, Value) {
      var b = null;
      b = this.GetItemByScale(Scale);
      if (!(b != null)) b = this.Add$1(Scale);
      b.FBitmap.Assign(Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCScaledBitmap);
      return this;
    };
    this.Add$1 = function (Scale) {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      Result.SetScale(Scale);
      return Result;
    };
    this.AddBitmapFromResource = function (ResourceName, Scale) {
      var Result = null;
      Result = this.AddBitmapFromResource$1(ResourceName,0,Scale);
      return Result;
    };
    this.AddBitmapFromResource$1 = function (ResourceName, AInstance, Scale) {
      var Result = null;
      Result = this.Add$1(Scale);
      Result.FBitmap.LoadFromResource$1(ResourceName,AInstance);
      return Result;
    };
    this.AddBitmap = function (Bitmap, Scale) {
      var Result = null;
      Result = this.Add$1(Scale);
      Result.FBitmap.Assign(Bitmap);
      return Result;
    };
    this.AddBitmapName = function (BitmapName, Scale) {
      var Result = null;
      Result = this.Add$1(Scale);
      Result.SetBitmapName(BitmapName);
      return Result;
    };
    this.AddDrawBitmap = function (Bitmap, Scale) {
      var Result = null;
      Result = this.Add$1(Scale);
      Result.FBitmap.Assign(Bitmap);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.Insert$2 = function (Index, Scale) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      Result.SetScale(Scale);
      return Result;
    };
    this.GetBitmapByScale = function (Scale) {
      var Result = null;
      var it = null;
      Result = null;
      it = this.GetItemByScale(Scale);
      if (it != null) Result = it.FBitmap;
      return Result;
    };
    this.GetItemByScale = function (Scale) {
      var Result = null;
      var I = 0;
      var cl = null;
      var it = null;
      var mx = 0.0;
      Result = null;
      cl = null;
      mx = 0;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = this.GetItems(I);
        if (it.FScale === Scale) {
          Result = it;
          break;
        } else if ((it.FScale !== Scale) && (it.FScale > mx)) {
          cl = it;
          mx = it.FScale;
        };
      };
      if (Result === null) Result = cl;
      return Result;
    };
  });
  this.TTMSFNCPictureFormat = {"0": "pfBMP", pfBMP: 0, "1": "pfGIF", pfGIF: 1, "2": "pfJPG", pfJPG: 2, "3": "pfPNG", pfPNG: 3, "4": "pfICO", pfICO: 4, "5": "pfTiff", pfTiff: 5, "6": "pfMetaFile", pfMetaFile: 6, "7": "pfNone", pfNone: 7};
  this.$rtti.$Enum("TTMSFNCPictureFormat",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TTMSFNCPictureFormat});
  rtl.createInterface(this,"ITMSFNCCustomEditor","{CC0C60B7-75F3-47CE-8A7F-8005A19F12E8}",["SetText","SetSelStart","SetSelLength","GetTextLength"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("SetText",0,[["AValue",rtl.string]]);
    $r.addMethod("SetSelStart",0,[["AValue",rtl.longint]]);
    $r.addMethod("SetSelLength",0,[["AValue",rtl.longint]]);
    $r.addMethod("GetTextLength",1,[],2,rtl.longint);
  });
  rtl.createClass(this,"TTMSFNCOwnedCollection",pas.Classes.TOwnedCollection,function () {
  });
  rtl.createClass(this,"TTMSFNCPersistent",pas.Classes.TPersistent,function () {
  });
  this.InflateRectEx = function (R, DX, DY) {
    R.Left = R.Left - DX;
    R.Right = R.Right + DX;
    R.Top = R.Top - DY;
    R.Bottom = R.Bottom + DY;
  };
  this.ConvertToRectF = function (Rect) {
    var Result = $mod.TRectF.$new();
    Result.Left = Rect.Left;
    Result.Top = Rect.Top;
    Result.Right = Rect.Right;
    Result.Bottom = Rect.Bottom;
    return Result;
  };
  this.ConvertToRectF$1 = function (Rect) {
    var Result = $mod.TRectF.$new();
    Result.$assign(Rect);
    return Result;
  };
  this.ConvertToRect = function (Rect) {
    var Result = pas.Types.TRect.$new();
    Result.Left = Math.round(Rect.Left);
    Result.Top = Math.round(Rect.Top);
    Result.Right = Math.round(Rect.Right);
    Result.Bottom = Math.round(Rect.Bottom);
    return Result;
  };
  this.ConvertToRect$1 = function (Rect) {
    var Result = pas.Types.TRect.$new();
    Result.$assign(Rect);
    return Result;
  };
  this.ConvertToSizeF = function (Size) {
    var Result = $mod.TSizeF.$new();
    Result.cx = Size.cx;
    Result.cy = Size.cy;
    return Result;
  };
  this.ConvertToSizeF$1 = function (Size) {
    var Result = $mod.TSizeF.$new();
    Result.$assign(Size);
    return Result;
  };
  this.ConvertToSize = function (Size) {
    var Result = pas.Types.TSize.$new();
    Result.cx = Math.round(Size.cx);
    Result.cy = Math.round(Size.cy);
    return Result;
  };
  this.ConvertToSize$1 = function (Size) {
    var Result = pas.Types.TSize.$new();
    Result.$assign(Size);
    return Result;
  };
  this.ConvertToPointF = function (Point) {
    var Result = $mod.TPointF.$new();
    Result.X = Point.x;
    Result.Y = Point.y;
    return Result;
  };
  this.ConvertToPointF$1 = function (Point) {
    var Result = $mod.TPointF.$new();
    Result.$assign(Point);
    return Result;
  };
  this.ConvertToPoint = function (Point) {
    var Result = pas.Types.TPoint.$new();
    Result.x = Math.round(Point.X);
    Result.y = Math.round(Point.Y);
    return Result;
  };
  this.ConvertToPoint$1 = function (Point) {
    var Result = pas.Types.TPoint.$new();
    Result.$assign(Point);
    return Result;
  };
  this.OffsetRectEx = function (R, DX, DY) {
    var Result = false;
    R.Left = R.Left + DX;
    R.Right = R.Right + DX;
    R.Top = R.Top + DY;
    R.Bottom = R.Bottom + DY;
    Result = true;
    return Result;
  };
  this.OffsetRectEx$1 = function (R, DX, DY) {
    var Result = false;
    R.Left = R.Left + DX;
    R.Right = R.Right + DX;
    R.Top = R.Top + DY;
    R.Bottom = R.Bottom + DY;
    Result = true;
    return Result;
  };
  this.PtInRectEx = function (Rect, P) {
    var Result = false;
    Result = (P.X >= Rect.Left) && (P.X < Rect.Right) && (P.Y >= Rect.Top) && (P.Y < Rect.Bottom);
    return Result;
  };
  this.IntersectRectEx = function (Rect1, Rect2) {
    var Result = false;
    Result = (Rect1.Left < Rect2.Right) && (Rect1.Right > Rect2.Left) && (Rect1.Top < Rect2.Bottom) && (Rect1.Bottom > Rect2.Top);
    return Result;
  };
  this.IntersectRectEx$1 = function (Rect, R1, R2) {
    var Result = false;
    var tmpRect = $mod.TRectF.$new();
    tmpRect.$assign(R1);
    if (R2.Left > R1.Left) tmpRect.Left = R2.Left;
    if (R2.Top > R1.Top) tmpRect.Top = R2.Top;
    if (R2.Right < R1.Right) tmpRect.Right = R2.Right;
    if (R2.Bottom < R1.Bottom) tmpRect.Bottom = R2.Bottom;
    Result = !$mod.RectIsEmpty(tmpRect);
    if (!Result) {
      tmpRect.Top = 0.0;
      tmpRect.Bottom = 0.0;
      tmpRect.Left = 0.0;
      tmpRect.Right = 0.0;
    };
    Rect.$assign(tmpRect);
    return Result;
  };
  this.EqualRectEx = function (R1, R2) {
    var Result = false;
    Result = (R1.Left === R2.Left) && (R1.Right === R2.Right) && (R1.Top === R2.Top) && (R1.Bottom === R2.Bottom);
    return Result;
  };
  this.EqualRectEx$1 = function (R1, R2) {
    var Result = false;
    Result = (R1.Left === R2.Left) && (R1.Right === R2.Right) && (R1.Top === R2.Top) && (R1.Bottom === R2.Bottom);
    return Result;
  };
  this.RectWidthEx = function (Rect) {
    var Result = 0;
    Result = Rect.Right - Rect.Left;
    return Result;
  };
  this.RectWidthEx$1 = function (Rect) {
    var Result = 0.0;
    Result = Rect.Right - Rect.Left;
    return Result;
  };
  this.RectHeightEx = function (Rect) {
    var Result = 0;
    Result = Rect.Bottom - Rect.Top;
    return Result;
  };
  this.RectHeightEx$1 = function (Rect) {
    var Result = 0.0;
    Result = Rect.Bottom - Rect.Top;
    return Result;
  };
  this.RectCenterEx = function (R, B) {
    var Result = pas.Types.TRect.$new();
    $mod.OffsetRectEx(R,-R.Left,-R.Top);
    $mod.OffsetRectEx(R,rtl.trunc(($mod.RectWidthEx(B) - $mod.RectWidthEx(R)) / 2),rtl.trunc(($mod.RectHeightEx(B) - $mod.RectHeightEx(R)) / 2));
    $mod.OffsetRectEx(R,B.Left,B.Top);
    Result.$assign(R);
    return Result;
  };
  this.RectCenterEx$1 = function (R, B) {
    var Result = $mod.TRectF.$new();
    $mod.OffsetRectEx$1(R,-R.Left,-R.Top);
    $mod.OffsetRectEx$1(R,Math.round(($mod.RectWidthEx$1(B) - $mod.RectWidthEx$1(R)) / 2),Math.round(($mod.RectHeightEx$1(B) - $mod.RectHeightEx$1(R)) / 2));
    $mod.OffsetRectEx$1(R,B.Left,B.Top);
    Result.$assign(R);
    return Result;
  };
  this.RectCenterAtEx = function (Rect, ADesignatedArea) {
    var Result = $mod.TRectF.$new();
    Result.$assign(Rect);
    $mod.RectCenterEx$1(Result,ADesignatedArea);
    return Result;
  };
  this.RectSnapToPixelEx = function (Rect, AScale, APlaceBetweenPixels) {
    var Result = $mod.TRectF.$new();
    var LScale = 0.0;
    var HalfPixel = 0.0;
    if (AScale <= 0) {
      LScale = 1}
     else LScale = AScale;
    Result.Left = pas.System.Trunc(Rect.Left * LScale) / LScale;
    Result.Top = pas.System.Trunc(Rect.Top * LScale) / LScale;
    Result.Right = Result.Left + (Math.round((Rect.Right - Rect.Left) * LScale) / LScale);
    Result.Bottom = Result.Top + (Math.round((Rect.Bottom - Rect.Top) * LScale) / LScale);
    if (APlaceBetweenPixels) {
      HalfPixel = 1 / (2 * LScale);
      $mod.OffsetRectEx$1(Result,HalfPixel,HalfPixel);
    };
    return Result;
  };
  this.RectFitIntoEx = function (Rect, ADesignatedArea, Ratio) {
    var Result = $mod.TRectF.$new();
    if (((ADesignatedArea.Right - ADesignatedArea.Left) <= 0) || ((ADesignatedArea.Bottom - ADesignatedArea.Top) <= 0)) {
      Ratio.set(1);
      return Rect;
    };
    if (((Rect.Right - Rect.Left) / (ADesignatedArea.Right - ADesignatedArea.Left)) > ((Rect.Bottom - Rect.Top) / (ADesignatedArea.Bottom - ADesignatedArea.Top))) {
      Ratio.set((Rect.Right - Rect.Left) / (ADesignatedArea.Right - ADesignatedArea.Left))}
     else Ratio.set((Rect.Bottom - Rect.Top) / (ADesignatedArea.Bottom - ADesignatedArea.Top));
    Result.$assign($mod.RectF(0,0,(Rect.Right - Rect.Left) / Ratio.get(),(Rect.Bottom - Rect.Top) / Ratio.get()));
    $mod.RectCenterEx$1(Result,ADesignatedArea);
    return Result;
  };
  this.RectFitIntoEx$1 = function (Rect, ADesignatedArea) {
    var Result = $mod.TRectF.$new();
    var Ratio = 0.0;
    Result.$assign($mod.RectFitIntoEx(Rect,ADesignatedArea,{get: function () {
        return Ratio;
      }, set: function (v) {
        Ratio = v;
      }}));
    return Result;
  };
  this.GetPointLength = function (Point) {
    var Result = 0.0;
    Result = Math.sqrt(pas.System.Sqr$1(Point.X) + pas.System.Sqr$1(Point.Y));
    return Result;
  };
  this.MakeRectF = function (Left, Top, Width, Height) {
    var Result = $mod.TRectF.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Right = Left + Width;
    Result.Bottom = Top + Height;
    return Result;
  };
  this.CenterPointEx = function (R) {
    var Result = $mod.TPointF.$new();
    Result.X = ((R.Right - R.Left) / 2.0) + R.Left;
    Result.Y = ((R.Bottom - R.Top) / 2.0) + R.Top;
    return Result;
  };
  this.CompareValueEx = function (A, B, Epsilon) {
    var Result = 0;
    if (pas.Math.SameValue(A,B,Epsilon)) {
      Result = 0}
     else if (A < B) {
      Result = -1}
     else Result = 1;
    return Result;
  };
  this.RectIsEmpty = function (R) {
    var Result = false;
    Result = (R.Right < R.Left) || pas.Math.SameValue(R.Right,R.Left,0.0) || (R.Bottom < R.Top) || pas.Math.SameValue(R.Bottom,R.Top,0.0);
    return Result;
  };
  this.EmptyRect = function () {
    var Result = $mod.TRectF.$new();
    Result.$assign($mod.RectF(0,0,0,0));
    return Result;
  };
  this.RectIntersectsWithEx = function (ARect, R) {
    var Result = false;
    Result = (ARect.Left < R.Right) && (ARect.Right > R.Left) && (ARect.Top < R.Bottom) && (ARect.Bottom > R.Top);
    return Result;
  };
  this.RectF = function (Left, Top, Right, Bottom) {
    var Result = $mod.TRectF.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Bottom = Bottom;
    Result.Right = Right;
    return Result;
  };
  this.PointF = function (X, Y) {
    var Result = $mod.TPointF.$new();
    Result.X = X;
    Result.Y = Y;
    return Result;
  };
  this.BitmapToDrawBitmap = function (ABitmap) {
    var Result = null;
    Result = null;
    if (ABitmap != null) {
      Result = ABitmap;
    };
    return Result;
  };
  this.IsBitmapEmpty = function (ABitmap) {
    var Result = false;
    var b = null;
    Result = true;
    if (ABitmap != null) {
      b = $mod.BitmapToDrawBitmap(ABitmap);
      if (b != null) {
        Result = b.Empty();
      };
    };
    return Result;
  };
  this.CharInArray = function (AChar, ACharArray) {
    var Result = false;
    var ch = "\x00";
    var I = 0;
    Result = false;
    for (var $l = 0, $end = rtl.length(ACharArray) - 1; $l <= $end; $l++) {
      I = $l;
      ch = ACharArray[I];
      if (ch === AChar) {
        Result = true;
        return Result;
      };
    };
    return Result;
  };
  this.CharIsNumber = function (AChar) {
    var Result = false;
    Result = AChar.charCodeAt() in rtl.createSet(null,48,57);
    return Result;
  };
  this.CharIsLetter = function (AChar) {
    var Result = false;
    Result = (AChar.charCodeAt() in rtl.createSet(null,97,122)) || (AChar.charCodeAt() in rtl.createSet(null,65,90));
    return Result;
  };
  this.CharIsHex = function (AChar) {
    var Result = false;
    Result = (AChar.charCodeAt() in rtl.createSet(null,48,57)) || (AChar.charCodeAt() in rtl.createSet(null,97,102)) || (AChar.charCodeAt() in rtl.createSet(null,65,70));
    return Result;
  };
  this.CharIsLetterOrNumber = function (AChar) {
    var Result = false;
    Result = $mod.CharIsLetter(AChar) || $mod.CharIsNumber(AChar);
    return Result;
  };
  this.VarToStr = function (S) {
    var Result = "";
    Result = S;
    return Result;
  };
  this.VarToDateTime = function (S) {
    var Result = 0.0;
    Result = pas.SysUtils.StrToDateTime(S);
    return Result;
  };
  this.AnsiPos = function (Substr, S) {
    var Result = 0;
    Result = pas.System.Pos(Substr,S);
    return Result;
  };
  this.AnsiUpperCase = function (S) {
    var Result = "";
    Result = pas.SysUtils.UpperCase(S);
    return Result;
  };
  this.AnsiLowerCase = function (S) {
    var Result = "";
    Result = pas.SysUtils.LowerCase(S);
    return Result;
  };
  this.HInstance = function () {
    var Result = 0;
    Result = 0;
    return Result;
  };
  this.CreateNewGUID = function () {
    var Result = "";
    var g = pas.System.TGuid.$new();
    pas.SysUtils.CreateGUID(g);
    Result = pas.SysUtils.GUIDToString(g);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.SVGREGISTERED = false;
  };
},["WEBLib.TMSFNCUtils","WEBLib.TMSFNCPersistence","JS"]);
rtl.module("WEBLib.TMSFNCGraphicsTypes",["System","Classes","Types","WEBLib.TMSFNCTypes","WEBLib.Graphics"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.FPC_FULLVERSION = 0;
  this.PathScale = 1E-4;
  this.PathFontSize = 1E-2;
  this.PathPosition = 1E-3;
  this.PathAngle = 1E-4;
  this.gcAliceblue = 0xFFF8F0;
  this.gcAntiquewhite = 0xD7EBFA;
  this.gcAqua = 0xFFFF00;
  this.gcAquamarine = 0xD4FF7F;
  this.gcAzure = 0xFFFFF0;
  this.gcBeige = 0xDCF5F5;
  this.gcBisque = 0xC4E4FF;
  this.gcBlack = 0x0;
  this.gcBlanchedalmond = 0xCDEBFF;
  this.gcBlue = 0xFF0000;
  this.gcBlueviolet = 0xE22B8A;
  this.gcBrown = 0x2A2AA5;
  this.gcBurlywood = 0x87B8DE;
  this.gcCadetblue = 0xA09E5F;
  this.gcChartreuse = 0xFF7F;
  this.gcChocolate = 0x1E69D2;
  this.gcCoral = 0x507FFF;
  this.gcCornflowerblue = 0xED9564;
  this.gcCornsilk = 0xDCF8FF;
  this.gcCrimson = 0x3C14DC;
  this.gcCyan = 0xFFFF00;
  this.gcDarkblue = 0x8B0000;
  this.gcDarkcyan = 0x8B8B00;
  this.gcDarkgoldenrod = 0xB86B8;
  this.gcDarkgray = 0xA9A9A9;
  this.gcDarkgreen = 0x6400;
  this.gcDarkgrey = 0xA9A9A9;
  this.gcDarkkhaki = 0x6BB7BD;
  this.gcDarkmagenta = 0x8B008B;
  this.gcDarkolivegreen = 0x2F6B55;
  this.gcDarkorange = 0x8CFF;
  this.gcDarkorchid = 0xCC3299;
  this.gcDarkred = 0x8B;
  this.gcDarksalmon = 0x7A96E9;
  this.gcDarkseagreen = 0x8FBC8F;
  this.gcDarkslateblue = 0x8B3D48;
  this.gcDarkslategray = 0x4F4F2F;
  this.gcDarkslategrey = 0x4F4F2F;
  this.gcDarkturquoise = 0xD1CE00;
  this.gcDarkviolet = 0xD30094;
  this.gcDeeppink = 0x9314FF;
  this.gcDeepskyblue = 0xFFBF00;
  this.gcDimgray = 0x696969;
  this.gcDimgrey = 0x696969;
  this.gcDodgerblue = 0xFF901E;
  this.gcFirebrick = 0x2222B2;
  this.gcFloralwhite = 0xF0FAFF;
  this.gcForestgreen = 0x228B22;
  this.gcFuchsia = 0xFF00FF;
  this.gcGainsboro = 0xDCDCDC;
  this.gcGhostwhite = 0xFFF8F8;
  this.gcGold = 0xD7FF;
  this.gcGoldenrod = 0x20A5DA;
  this.gcGray = 0x808080;
  this.gcGreen = 0x8000;
  this.gcGreenyellow = 0x2FFFAD;
  this.gcGrey = 0x808080;
  this.gcHoneydew = 0xF0FFF0;
  this.gcHotpink = 0xB469FF;
  this.gcIndianred = 0x5C5CCD;
  this.gcIndigo = 0x82004B;
  this.gcIvory = 0xF0FFFF;
  this.gcKhaki = 0x8CE6F0;
  this.gcLavender = 0xFAE6E6;
  this.gcLavenderblush = 0xF5F0FF;
  this.gcLawngreen = 0xFC7C;
  this.gcLemonchiffon = 0xCDFAFF;
  this.gcLightblue = 0xE6D8AD;
  this.gcLightcoral = 0x8080F0;
  this.gcLightcyan = 0xFFFFE0;
  this.gcLightgoldenrodyellow = 0xD2FAFA;
  this.gcLightgray = 0xD3D3D3;
  this.gcLightgreen = 0x90EE90;
  this.gcLightgrey = 0xD3D3D3;
  this.gcLightpink = 0xC1B6FF;
  this.gcLightsalmon = 0x7AA0FF;
  this.gcLightseagreen = 0xAAB220;
  this.gcLightskyblue = 0xFACE87;
  this.gcLightslategray = 0x998877;
  this.gcLightslategrey = 0x998877;
  this.gcLightsteelblue = 0xDEC4B0;
  this.gcLightyellow = 0xE0FFFF;
  this.gcLtGray = 0xC0C0C0;
  this.gcMedGray = 0xA4A0A0;
  this.gcDkGray = 0x808080;
  this.gcMoneyGreen = 0xC0DCC0;
  this.gcLegacySkyBlue = 0xF0CAA6;
  this.gcCream = 0xF0FBFF;
  this.gcLime = 0xFF00;
  this.gcLimegreen = 0x32CD32;
  this.gcLinen = 0xE6F0FA;
  this.gcMagenta = 0xFF00FF;
  this.gcMaroon = 0x80;
  this.gcMediumaquamarine = 0xAACD66;
  this.gcMediumblue = 0xCD0000;
  this.gcMediumorchid = 0xD355BA;
  this.gcMediumpurple = 0xDB7093;
  this.gcMediumseagreen = 0x71B33C;
  this.gcMediumslateblue = 0xEE687B;
  this.gcMediumspringgreen = 0x9AFA00;
  this.gcMediumturquoise = 0xCCD148;
  this.gcMediumvioletred = 0x8515C7;
  this.gcMidnightblue = 0x701919;
  this.gcMintcream = 0xFAFFF5;
  this.gcMistyrose = 0xE1E4FF;
  this.gcMoccasin = 0xB5E4FF;
  this.gcNavajowhite = 0xADDEFF;
  this.gcNavy = 0x800000;
  this.gcOldlace = 0xE6F5FD;
  this.gcOlive = 0x8080;
  this.gcOlivedrab = 0x238E6B;
  this.gcOrange = 0xA5FF;
  this.gcOrangered = 0x45FF;
  this.gcOrchid = 0xD670DA;
  this.gcPalegoldenrod = 0xAAE8EE;
  this.gcPalegreen = 0x98FB98;
  this.gcPaleturquoise = 0xEEEEAF;
  this.gcPalevioletred = 0x9370DB;
  this.gcPapayawhip = 0xD5EFFF;
  this.gcPeachpuff = 0xB9DAFF;
  this.gcPeru = 0x3F85CD;
  this.gcPink = 0xCBC0FF;
  this.gcPlum = 0xDDA0DD;
  this.gcPowderblue = 0xE6E0B0;
  this.gcPurple = 0x800080;
  this.gcRed = 0xFF;
  this.gcRosybrown = 0x8F8FBC;
  this.gcRoyalblue = 0xE16941;
  this.gcSaddlebrown = 0x13458B;
  this.gcSalmon = 0x7280FA;
  this.gcSandybrown = 0x60A4F4;
  this.gcSeagreen = 0x578B2E;
  this.gcSeashell = 0xEEF5FF;
  this.gcSienna = 0x2D52A0;
  this.gcSilver = 0xC0C0C0;
  this.gcSkyblue = 0xEBCE87;
  this.gcSlateblue = 0xCD5A6A;
  this.gcSlategray = 0x908070;
  this.gcSlategrey = 0x908070;
  this.gcSnow = 0xFAFAFF;
  this.gcSpringgreen = 0x7FFF00;
  this.gcSteelblue = 0xB48246;
  this.gcTan = 0x8CB4D2;
  this.gcTeal = 0x808000;
  this.gcThistle = 0xD8BFD8;
  this.gcTomato = 0x4763FF;
  this.gcTurquoise = 0xD0E040;
  this.gcViolet = 0xEE82EE;
  this.gcWheat = 0xB3DEF5;
  this.gcWhite = 0xFFFFFF;
  this.gcWhitesmoke = 0xF5F5F5;
  this.gcYellow = 0xFFFF;
  this.gcYellowgreen = 0x32CD9A;
  this.gcNull = -1;
  rtl.recNewT(this,"TTMSFNCGraphicsColorEntry",function () {
    this.Value = 0;
    this.Name = "";
    this.$eq = function (b) {
      return (this.Value === b.Value) && (this.Name === b.Name);
    };
    this.$assign = function (s) {
      this.Value = s.Value;
      this.Name = s.Name;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCGraphicsColorEntry",{},this);
    $r.addField("Value",pas["WEBLib.Graphics"].$rtti["TColor"]);
    $r.addField("Name",rtl.string);
  });
  this.TMSFNCGraphicsColorCount = 154;
  this.TTMSFNCGraphicsStrokeKind = {"0": "gskNone", gskNone: 0, "1": "gskSolid", gskSolid: 1, "2": "gskDash", gskDash: 2, "3": "gskDot", gskDot: 3, "4": "gskDashDot", gskDashDot: 4, "5": "gskDashDotDot", gskDashDotDot: 5};
  this.$rtti.$Enum("TTMSFNCGraphicsStrokeKind",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCGraphicsStrokeKind});
  this.TTMSFNCGraphicsTextureMode = {"0": "gtmOriginal", gtmOriginal: 0, "1": "gtmFit", gtmFit: 1, "2": "gtmStretch", gtmStretch: 2, "3": "gtmCenter", gtmCenter: 3, "4": "gtmTile", gtmTile: 4};
  this.$rtti.$Enum("TTMSFNCGraphicsTextureMode",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCGraphicsTextureMode});
  this.TTMSFNCGraphicsFillKind = {"0": "gfkNone", gfkNone: 0, "1": "gfkSolid", gfkSolid: 1, "2": "gfkGradient", gfkGradient: 2, "3": "gfkTexture", gfkTexture: 3};
  this.$rtti.$Enum("TTMSFNCGraphicsFillKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGraphicsFillKind});
  this.TTMSFNCGraphicsFillGradientMode = {"0": "gfgmDefault", gfgmDefault: 0, "1": "gfgmCollection", gfgmCollection: 1};
  this.$rtti.$Enum("TTMSFNCGraphicsFillGradientMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGraphicsFillGradientMode});
  this.TTMSFNCGraphicsFillGradientType = {"0": "gfgtLinear", gfgtLinear: 0, "1": "gfgtRadial", gfgtRadial: 1};
  this.$rtti.$Enum("TTMSFNCGraphicsFillGradientType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGraphicsFillGradientType});
  this.TTMSFNCGraphicsFillOrientation = {"0": "gfoHorizontal", gfoHorizontal: 0, "1": "gfoVertical", gfoVertical: 1, "2": "gfoCustom", gfoCustom: 2};
  this.$rtti.$Enum("TTMSFNCGraphicsFillOrientation",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGraphicsFillOrientation});
  this.TTMSFNCGraphicsTextAlign = {"0": "gtaCenter", gtaCenter: 0, "1": "gtaLeading", gtaLeading: 1, "2": "gtaTrailing", gtaTrailing: 2};
  this.$rtti.$Enum("TTMSFNCGraphicsTextAlign",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGraphicsTextAlign});
  this.TTMSFNCGraphicsTextTrimming = {"0": "gttNone", gttNone: 0, "1": "gttCharacter", gttCharacter: 1, "2": "gttWord", gttWord: 2};
  this.$rtti.$Enum("TTMSFNCGraphicsTextTrimming",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGraphicsTextTrimming});
  this.TTMSFNCGraphicsSide = {"0": "gsLeft", gsLeft: 0, "1": "gsTop", gsTop: 1, "2": "gsRight", gsRight: 2, "3": "gsBottom", gsBottom: 3};
  this.$rtti.$Enum("TTMSFNCGraphicsSide",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGraphicsSide});
  this.$rtti.$Set("TTMSFNCGraphicsSides",{comptype: this.$rtti["TTMSFNCGraphicsSide"]});
  this.TTMSFNCGraphicsTextQuality = {"0": "gtqDefault", gtqDefault: 0, "1": "gtqAntiAliasing", gtqAntiAliasing: 1, "2": "gtqClearType", gtqClearType: 2};
  this.$rtti.$Enum("TTMSFNCGraphicsTextQuality",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGraphicsTextQuality});
  this.AllSides = rtl.createSet(this.TTMSFNCGraphicsSide.gsLeft,this.TTMSFNCGraphicsSide.gsTop,this.TTMSFNCGraphicsSide.gsRight,this.TTMSFNCGraphicsSide.gsBottom);
  this.Epsilon = 1E-40;
  rtl.recNewT(this,"TTMSFNCGraphicsMatrix",function () {
    this.m11 = 0.0;
    this.m12 = 0.0;
    this.m13 = 0.0;
    this.m21 = 0.0;
    this.m22 = 0.0;
    this.m23 = 0.0;
    this.m31 = 0.0;
    this.m32 = 0.0;
    this.m33 = 0.0;
    this.$eq = function (b) {
      return (this.m11 === b.m11) && (this.m12 === b.m12) && (this.m13 === b.m13) && (this.m21 === b.m21) && (this.m22 === b.m22) && (this.m23 === b.m23) && (this.m31 === b.m31) && (this.m32 === b.m32) && (this.m33 === b.m33);
    };
    this.$assign = function (s) {
      this.m11 = s.m11;
      this.m12 = s.m12;
      this.m13 = s.m13;
      this.m21 = s.m21;
      this.m22 = s.m22;
      this.m23 = s.m23;
      this.m31 = s.m31;
      this.m32 = s.m32;
      this.m33 = s.m33;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCGraphicsMatrix",{},this);
    $r.addField("m11",rtl.double);
    $r.addField("m12",rtl.double);
    $r.addField("m13",rtl.double);
    $r.addField("m21",rtl.double);
    $r.addField("m22",rtl.double);
    $r.addField("m23",rtl.double);
    $r.addField("m31",rtl.double);
    $r.addField("m32",rtl.double);
    $r.addField("m33",rtl.double);
  });
  this.$rtti.$Class("TTMSFNCGraphicsStroke");
  this.$rtti.$Class("TTMSFNCGraphicsFill");
  this.$rtti.$Class("TTMSFNCGraphicsFont");
  rtl.createClass(this,"TTMSFNCGraphicsSaveState",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FSaveDC = 0;
      this.FFont = null;
      this.FStroke = null;
      this.FFill = null;
      this.FCustomSaveDC = 0;
    };
    this.$final = function () {
      this.FFont = undefined;
      this.FStroke = undefined;
      this.FFill = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetFont = function (Value) {
      this.FFont.AssignSource(Value);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FFill = $mod.TTMSFNCGraphicsFill.$create("Create$1",[$mod.TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FStroke = $mod.TTMSFNCGraphicsStroke.$create("Create$1",[$mod.TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FFont = $mod.TTMSFNCGraphicsFont.$create("Create$2");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FFont");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCGraphicsFillGradientItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FColor = 0;
      this.FPosition = 0.0;
      this.FOpacity = 0.0;
    };
    this.IsPositionStored = function () {
      var Result = false;
      Result = this.FPosition !== 0.0;
      return Result;
    };
    this.SetColor = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColor !== Value) {
        this.FColor = rtl.rc(Value,-9007199254740991,9007199254740991);
        this.UpdateGradient();
      };
    };
    this.SetPosition = function (Value) {
      if (this.FPosition !== Value) {
        this.FPosition = Value;
        this.UpdateGradient();
      };
    };
    this.IsOpacityStored = function () {
      var Result = false;
      Result = this.FOpacity !== 1.0;
      return Result;
    };
    this.SetOpacity = function (Value) {
      if (this.FOpacity !== Value) {
        this.FOpacity = Value;
        this.UpdateGradient();
      };
    };
    this.UpdateGradient = function () {
      if ($mod.TTMSFNCGraphicsFillGradientItems.isPrototypeOf(this.FCollection)) rtl.as(this.FCollection,$mod.TTMSFNCGraphicsFillGradientItems).UpdateGradient();
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FColor = 16777215;
      this.FPosition = 0.0;
      this.FOpacity = 1.0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGraphicsFillGradientItem.isPrototypeOf(Source)) {
        this.FColor = rtl.rc(rtl.as(Source,$mod.TTMSFNCGraphicsFillGradientItem).FColor,-9007199254740991,9007199254740991);
        this.FOpacity = rtl.as(Source,$mod.TTMSFNCGraphicsFillGradientItem).FOpacity;
        this.FPosition = rtl.as(Source,$mod.TTMSFNCGraphicsFillGradientItem).FPosition;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Opacity",14,rtl.double,"FOpacity","SetOpacity",4,{stored: "IsOpacityStored"});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 16777215});
    $r.addProperty("Position",14,rtl.double,"FPosition","SetPosition",4,{stored: "IsPositionStored"});
  });
  this.$rtti.$Class("TTMSFNCCustomGraphicsFill");
  rtl.createClass(this,"TTMSFNCGraphicsFillGradientItems",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItemEx = function (Index) {
      rtl.rc(Index,-2147483648,2147483647);
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      rtl.rc(Index,-2147483648,2147483647);
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.UpdateGradient = function () {
      if (this.FOwner$1 != null) this.FOwner$1.Changed();
    };
    this.GetGradientClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCGraphicsFillGradientItem;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.GetGradientClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (index) {
      rtl.rc(index,-2147483648,2147483647);
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCCustomGraphicsFill",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FUpdateCount = 0;
      this.FOnChanged = null;
      this.FOrientation = 0;
      this.FKind = 0;
      this.FDefaultKind = 0;
      this.FColor = 0;
      this.FDefaultColor = 0;
      this.FColorTo = 0;
      this.FColorMirror = 0;
      this.FColorMirrorTo = 0;
      this.FDefaultColorTo = 0;
      this.FDefaultColorMirror = 0;
      this.FDefaultColorMirrorTo = 0;
      this.FOpacity = 0.0;
      this.FTexture = null;
      this.FTextureMode = 0;
      this.FGradientMode = 0;
      this.FGradientItems = null;
      this.FGradientType = 0;
      this.FGradientAngle = 0.0;
      this.FGradientCenterPoint = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      this.FGradientCenterColor = 0;
      this.FGradientMatrix = $mod.TTMSFNCGraphicsMatrix.$new();
    };
    this.$final = function () {
      this.FOnChanged = undefined;
      this.FTexture = undefined;
      this.FGradientItems = undefined;
      this.FGradientCenterPoint = undefined;
      this.FGradientMatrix = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetKind = function (Value) {
      rtl.rc(Value,0,3);
      if (this.FKind !== Value) {
        this.FKind = rtl.rc(Value,0,3);
        this.Changed();
      };
    };
    this.SetOrientation = function (Value) {
      rtl.rc(Value,0,2);
      if (this.FOrientation !== Value) {
        this.FOrientation = rtl.rc(Value,0,2);
        this.Changed();
      };
    };
    this.SetColor = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColor !== Value) {
        this.FColor = rtl.rc(Value,-9007199254740991,9007199254740991);
        if (this.FColor === -1) {
          this.FColor = -1}
         else if (this.FColor === 536870912) this.FColor = 15790320;
        this.Changed();
      };
    };
    this.SetColorTo = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColorTo !== Value) {
        this.FColorTo = rtl.rc(Value,-9007199254740991,9007199254740991);
        if (this.FColorTo === -1) {
          this.FColorTo = -1}
         else if (this.FColorTo === 536870912) this.FColorTo = 15790320;
        this.Changed();
      };
    };
    this.SetColorMirror = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColorMirror !== Value) {
        this.FColorMirror = rtl.rc(Value,-9007199254740991,9007199254740991);
        if (this.FColorMirror === -1) {
          this.FColorMirror = -1}
         else if (this.FColorMirror === 536870912) this.FColorMirror = 15790320;
        this.Changed();
      };
    };
    this.SetColorMirrorTo = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColorMirrorTo !== Value) {
        this.FColorMirrorTo = rtl.rc(Value,-9007199254740991,9007199254740991);
        if (this.FColorMirrorTo === -1) {
          this.FColorMirrorTo = -1}
         else if (this.FColorMirrorTo === 536870912) this.FColorMirrorTo = 15790320;
        this.Changed();
      };
    };
    this.SetOpacity = function (Value) {
      if (this.FOpacity !== Value) {
        this.FOpacity = Value;
        this.Changed();
      };
    };
    this.IsOpacityStored = function () {
      var Result = false;
      Result = this.FOpacity !== 1;
      return Result;
    };
    this.SetTexture = function (Value) {
      if (this.FTexture !== Value) {
        this.FTexture.Assign(Value);
        this.Changed();
      };
    };
    this.SetTextureMode = function (Value) {
      rtl.rc(Value,0,4);
      if (this.FTextureMode !== Value) {
        this.FTextureMode = rtl.rc(Value,0,4);
        this.Changed();
      };
    };
    this.SetGradientItems = function (Value) {
      this.FGradientItems.Assign(Value);
    };
    this.SetGradientMode = function (Value) {
      rtl.rc(Value,0,1);
      if (this.FGradientMode !== Value) {
        this.FGradientMode = rtl.rc(Value,0,1);
        this.Changed();
      };
    };
    this.SetGradientType = function (Value) {
      rtl.rc(Value,0,1);
      if (this.FGradientType !== Value) {
        this.FGradientType = rtl.rc(Value,0,1);
        this.Changed();
      };
    };
    this.IsGradientAngleStored = function () {
      var Result = false;
      Result = this.FGradientAngle !== 0;
      return Result;
    };
    this.SetGradientAngle = function (Value) {
      if (this.FGradientAngle !== Value) {
        this.FGradientAngle = Value;
        this.Changed();
      };
    };
    this.SetGradientCenterPoint = function (Value) {
      this.FGradientCenterPoint.$assign(Value);
      this.Changed();
    };
    this.SetGradientCenterColor = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FGradientCenterColor !== Value) {
        this.FGradientCenterColor = rtl.rc(Value,-9007199254740991,9007199254740991);
        this.Changed();
      };
    };
    this.IsColorStored = function () {
      var Result = false;
      Result = this.FColor !== this.FDefaultColor;
      return Result;
    };
    this.IsKindStored = function () {
      var Result = false;
      Result = this.FKind !== this.FDefaultKind;
      return Result;
    };
    this.IsColorMirrorStored = function () {
      var Result = false;
      Result = this.FColorMirror !== this.FDefaultColorMirror;
      return Result;
    };
    this.IsColorMirrorToStored = function () {
      var Result = false;
      Result = this.FColorMirrorTo !== this.FDefaultColorMirrorTo;
      return Result;
    };
    this.IsColorToStored = function () {
      var Result = false;
      Result = this.FColorTo !== this.FDefaultColorTo;
      return Result;
    };
    this.Changed = function () {
      if ((this.FOnChanged != null) && (this.FUpdateCount === 0)) this.FOnChanged(this);
    };
    this.TextureChanged = function (Sender) {
      this.Changed();
    };
    this.Create$1 = function (AKind, AColor, AColorTo, AColorMirror, AColorMirrorTo) {
      rtl.rc(AKind,0,3);
      rtl.rc(AColor,-9007199254740991,9007199254740991);
      rtl.rc(AColorTo,-9007199254740991,9007199254740991);
      rtl.rc(AColorMirror,-9007199254740991,9007199254740991);
      rtl.rc(AColorMirrorTo,-9007199254740991,9007199254740991);
      this.FGradientItems = $mod.TTMSFNCGraphicsFillGradientItems.$create("Create$3",[this]);
      this.FKind = rtl.rc(AKind,0,3);
      this.FDefaultKind = rtl.rc(AKind,0,3);
      this.FGradientMatrix.$assign($mod.MatrixIdentity());
      this.FGradientCenterColor = -1;
      this.FGradientMode = rtl.rc($mod.TTMSFNCGraphicsFillGradientMode.gfgmDefault,0,1);
      this.FGradientAngle = 0.0;
      this.FGradientCenterPoint.$assign(pas["WEBLib.TMSFNCTypes"].PointF(0,0));
      this.FGradientType = rtl.rc($mod.TTMSFNCGraphicsFillGradientType.gfgtLinear,0,1);
      this.FColor = rtl.rc(AColor,-9007199254740991,9007199254740991);
      this.FDefaultColor = rtl.rc(AColor,-9007199254740991,9007199254740991);
      this.FOpacity = 1;
      this.FOrientation = rtl.rc($mod.TTMSFNCGraphicsFillOrientation.gfoVertical,0,2);
      this.FColorTo = rtl.rc(AColorTo,-9007199254740991,9007199254740991);
      this.FColorMirror = rtl.rc(AColorMirror,-9007199254740991,9007199254740991);
      this.FColorMirrorTo = rtl.rc(AColorMirrorTo,-9007199254740991,9007199254740991);
      this.FDefaultColorTo = rtl.rc(AColorTo,-9007199254740991,9007199254740991);
      this.FDefaultColorMirror = rtl.rc(AColorMirror,-9007199254740991,9007199254740991);
      this.FDefaultColorMirrorTo = rtl.rc(AColorMirrorTo,-9007199254740991,9007199254740991);
      this.FTextureMode = rtl.rc($mod.TTMSFNCGraphicsTextureMode.gtmStretch,0,4);
      this.FTexture = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FTexture.FOnChange = rtl.createCallback(this,"TextureChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FTexture");
      rtl.free(this,"FGradientItems");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomGraphicsFill.isPrototypeOf(Source)) {
        this.FColor = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FColor,-9007199254740991,9007199254740991);
        this.FColorTo = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FColorTo,-9007199254740991,9007199254740991);
        this.FColorMirror = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FColorMirror,-9007199254740991,9007199254740991);
        this.FColorMirrorTo = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FColorMirrorTo,-9007199254740991,9007199254740991);
        this.FKind = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FKind,0,3);
        this.FOrientation = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FOrientation,0,2);
        this.FOpacity = rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FOpacity;
        this.FTexture.Assign(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FTexture);
        this.FTextureMode = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FTextureMode,0,4);
        this.FGradientMode = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FGradientMode,0,1);
        this.FGradientAngle = rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FGradientAngle;
        this.FGradientCenterPoint.$assign(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FGradientCenterPoint);
        this.FGradientItems.Assign(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FGradientItems);
        this.FGradientType = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FGradientType,0,1);
        this.FGradientCenterColor = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FGradientCenterColor,-9007199254740991,9007199254740991);
      } else if ($mod.TTMSFNCCustomGraphicsStroke.isPrototypeOf(Source)) {
        this.FColor = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsStroke).FColor,-9007199254740991,9007199254740991);
        this.FColorTo = -1;
        this.FColorMirror = -1;
        this.FColorMirrorTo = -1;
        this.FKind = rtl.rc($mod.TTMSFNCGraphicsFillKind.gfkSolid,0,3);
        this.FOrientation = rtl.rc($mod.TTMSFNCGraphicsFillOrientation.gfoVertical,0,2);
        this.FOpacity = 1;
      };
      this.Changed();
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      this.FUpdateCount -= 1;
      this.Changed();
    };
    this.ClearGradientItems = function () {
      this.FGradientItems.Clear();
    };
    this.AddGradientItem = function (AColor, APosition, AOpacity) {
      rtl.rc(AColor,-9007199254740991,9007199254740991);
      var Result = null;
      Result = this.FGradientItems.Add$1();
      Result.SetColor(AColor);
      Result.SetPosition(APosition);
      Result.SetOpacity(AOpacity);
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCGraphicsFill",this.TTMSFNCCustomGraphicsFill,function () {
    var $r = this.$rtti;
    $r.addProperty("OnChanged",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChanged","FOnChanged");
    $r.addProperty("Kind",14,$mod.$rtti["TTMSFNCGraphicsFillKind"],"FKind","SetKind",4,{stored: "IsKindStored"});
    $r.addProperty("Orientation",2,$mod.$rtti["TTMSFNCGraphicsFillOrientation"],"FOrientation","SetOrientation",4,{Default: $mod.TTMSFNCGraphicsFillOrientation.gfoVertical});
    $r.addProperty("Color",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{stored: "IsColorStored"});
    $r.addProperty("ColorTo",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColorTo","SetColorTo",4,{stored: "IsColorToStored"});
    $r.addProperty("ColorMirror",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColorMirror","SetColorMirror",4,{stored: "IsColorMirrorStored"});
    $r.addProperty("ColorMirrorTo",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColorMirrorTo","SetColorMirrorTo",4,{stored: "IsColorMirrorToStored"});
    $r.addProperty("TextureMode",2,$mod.$rtti["TTMSFNCGraphicsTextureMode"],"FTextureMode","SetTextureMode",4,{Default: $mod.TTMSFNCGraphicsTextureMode.gtmStretch});
    $r.addProperty("Texture",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FTexture","SetTexture");
  });
  rtl.createClass(this,"TTMSFNCGraphicsFont",pas["WEBLib.Graphics"].TFont,function () {
    this.$init = function () {
      pas["WEBLib.Graphics"].TFont.$init.call(this);
      this.FUpdateCount = 0;
      this.FOnChanged = null;
    };
    this.$final = function () {
      this.FOnChanged = undefined;
      pas["WEBLib.Graphics"].TFont.$final.call(this);
    };
    this.DoChanged = function (Sender) {
      if ((this.FOnChanged != null) && (this.FUpdateCount === 0)) this.FOnChanged(this);
    };
    this.Create$2 = function () {
      pas["WEBLib.Graphics"].TFont.Create$1.call(this);
      this.SetHeight(-12);
      this.FOnChange = rtl.createCallback(this,"DoChanged");
      return this;
    };
    this.Assign = function (Source) {
      pas["WEBLib.Graphics"].TFont.Assign.call(this,Source);
      this.DoChanged(this);
    };
    this.AssignSource = function (Source) {
      this.Assign(Source);
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      this.FUpdateCount -= 1;
      this.DoChanged(this);
    };
  });
  this.TTMSFNCAppearanceGlobalFontType = {"0": "aftNone", aftNone: 0, "1": "aftColor", aftColor: 1, "2": "aftSize", aftSize: 2, "3": "aftName", aftName: 3, "4": "aftScale", aftScale: 4, "5": "aftStyle", aftStyle: 5};
  this.$rtti.$Enum("TTMSFNCAppearanceGlobalFontType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCAppearanceGlobalFontType});
  rtl.createInterface(this,"ITMSFNCAppearanceGlobalFont","{85CF4F6B-3FF9-4CB7-AD6A-7FC477ED5462}",["SetFonts"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("SetFonts",0,[["ASetType",$mod.$rtti["TTMSFNCAppearanceGlobalFontType"]]]);
  });
  rtl.createClass(this,"TTMSFNCAppearanceGlobalFont",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FColor = 0;
      this.FSize = 0.0;
      this.FName = "";
      this.FScale = 0.0;
      this.FOldScale = 0.0;
      this.FStyle = {};
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FStyle = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetColor = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColor !== Value) {
        this.FColor = rtl.rc(Value,-9007199254740991,9007199254740991);
        this.SetFonts($mod.TTMSFNCAppearanceGlobalFontType.aftColor);
      };
    };
    this.SetSize = function (Value) {
      if (this.FSize !== Value) {
        this.FSize = Value;
        this.SetFonts($mod.TTMSFNCAppearanceGlobalFontType.aftSize);
      };
    };
    this.SetName = function (Value) {
      if (this.FName !== Value) {
        this.FName = Value;
        this.SetFonts($mod.TTMSFNCAppearanceGlobalFontType.aftName);
      };
    };
    this.SetScale = function (Value) {
      if (this.FScale !== Value) {
        this.FOldScale = this.FScale;
        this.FScale = Value;
        this.SetFonts($mod.TTMSFNCAppearanceGlobalFontType.aftScale);
      };
    };
    this.SetStyle = function (Value) {
      if (rtl.neSet(this.FStyle,Value)) {
        this.FStyle = rtl.refSet(Value);
        this.SetFonts($mod.TTMSFNCAppearanceGlobalFontType.aftStyle);
      };
    };
    this.IsNameStored = function () {
      var Result = false;
      Result = this.FName !== "";
      return Result;
    };
    this.IsScaleStored = function () {
      var Result = false;
      Result = this.FScale !== 1;
      return Result;
    };
    this.IsSizeStored = function () {
      var Result = false;
      Result = this.FSize !== 0;
      return Result;
    };
    this.IsStyleStored = function () {
      var Result = false;
      Result = rtl.neSet(this.FStyle,{});
      return Result;
    };
    this.SetFonts = function (ASetType) {
      rtl.rc(ASetType,0,5);
      var fi = null;
      try {
        if (pas.SysUtils.Supports$3(this.FOwner,$mod.ITMSFNCAppearanceGlobalFont.$guid,{get: function () {
            return fi;
          }, set: function (v) {
            fi = v;
          }})) fi.SetFonts(ASetType);
      } finally {
        rtl._Release(fi);
      };
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FColor = -1;
      this.FSize = 0;
      this.FScale = 1;
      this.FName = "";
      this.FStyle = {};
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCAppearanceGlobalFont.isPrototypeOf(Source)) {
        this.SetColor(rtl.as(Source,$mod.TTMSFNCAppearanceGlobalFont).FColor);
        this.SetSize(rtl.as(Source,$mod.TTMSFNCAppearanceGlobalFont).FSize);
        this.SetName(rtl.as(Source,$mod.TTMSFNCAppearanceGlobalFont).FName);
        this.SetScale(rtl.as(Source,$mod.TTMSFNCAppearanceGlobalFont).FScale);
        this.SetStyle(rtl.refSet(rtl.as(Source,$mod.TTMSFNCAppearanceGlobalFont).FStyle));
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.ApplyChange = function (AFont, ASetType) {
      rtl.rc(ASetType,0,5);
      if (AFont != null) {
        var $tmp = ASetType;
        if ($tmp === $mod.TTMSFNCAppearanceGlobalFontType.aftColor) {
          AFont.SetColor(this.FColor)}
         else if ($tmp === $mod.TTMSFNCAppearanceGlobalFontType.aftSize) {
          AFont.SetSize(Math.round(this.FSize))}
         else if ($tmp === $mod.TTMSFNCAppearanceGlobalFontType.aftName) {
          AFont.SetName(this.FName)}
         else if ($tmp === $mod.TTMSFNCAppearanceGlobalFontType.aftScale) {
          AFont.SetHeight(Math.round((AFont.FHeight * this.FScale) / this.FOldScale));
        } else if ($tmp === $mod.TTMSFNCAppearanceGlobalFontType.aftStyle) AFont.SetStyle(rtl.refSet(this.FStyle));
      };
    };
    this.GetOldScale = function () {
      var Result = 0.0;
      Result = this.FOldScale;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: -1});
    $r.addProperty("Size",14,rtl.double,"FSize","SetSize",4,{stored: "IsSizeStored"});
    $r.addProperty("Name",14,rtl.string,"FName","SetName",4,{stored: "IsNameStored"});
    $r.addProperty("Scale",14,rtl.double,"FScale","SetScale",4,{stored: "IsScaleStored"});
    $r.addProperty("Style",14,pas["WEBLib.Graphics"].$rtti["TFontStyles"],"FStyle","SetStyle",4,{stored: "IsStyleStored"});
  });
  rtl.createClass(this,"TTMSFNCCustomGraphicsStroke",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FUpdateCount = 0;
      this.FOnChanged = null;
      this.FKind = 0;
      this.FColor = 0;
      this.FWidth = 0.0;
      this.FOpacity = 0.0;
      this.FDefaultKind = 0;
      this.FDefaultColor = 0;
      this.FDefaultWidth = 0.0;
    };
    this.$final = function () {
      this.FOnChanged = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetKind = function (Value) {
      rtl.rc(Value,0,5);
      if (this.FKind !== Value) {
        this.FKind = rtl.rc(Value,0,5);
        this.Changed();
      };
    };
    this.SetColor = function (Value) {
      rtl.rc(Value,-9007199254740991,9007199254740991);
      if (this.FColor !== Value) {
        this.FColor = rtl.rc(Value,-9007199254740991,9007199254740991);
        if (this.FColor === -1) {
          this.FColor = -1}
         else if (this.FColor === 536870912) this.FColor = 15790320;
        this.Changed();
      };
    };
    this.SetWidth = function (Value) {
      if (this.FWidth !== Value) {
        this.FWidth = Value;
        this.Changed();
      };
    };
    this.SetOpacity = function (Value) {
      if (this.FOpacity !== Value) {
        this.FOpacity = Value;
        this.Changed();
      };
    };
    this.IsOpacityStored = function () {
      var Result = false;
      Result = this.FOpacity !== 1;
      return Result;
    };
    this.IsWidthStored = function () {
      var Result = false;
      Result = this.FWidth !== this.FDefaultWidth;
      return Result;
    };
    this.IsKindStored = function () {
      var Result = false;
      Result = this.FKind !== this.FDefaultKind;
      return Result;
    };
    this.IsColorStored = function () {
      var Result = false;
      Result = this.FColor !== this.FDefaultColor;
      return Result;
    };
    this.Changed = function () {
      if ((this.FOnChanged != null) && (this.FUpdateCount === 0)) this.FOnChanged(this);
    };
    this.Create$1 = function (AKind, AColor, AWidth) {
      rtl.rc(AKind,0,5);
      rtl.rc(AColor,-9007199254740991,9007199254740991);
      this.FKind = rtl.rc(AKind,0,5);
      this.FDefaultKind = rtl.rc(AKind,0,5);
      this.FColor = rtl.rc(AColor,-9007199254740991,9007199254740991);
      this.FDefaultColor = rtl.rc(AColor,-9007199254740991,9007199254740991);
      this.FOpacity = 1;
      this.FDefaultWidth = AWidth;
      this.FWidth = AWidth;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomGraphicsStroke.isPrototypeOf(Source)) {
        this.FColor = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsStroke).FColor,-9007199254740991,9007199254740991);
        this.FKind = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsStroke).FKind,0,5);
        this.FOpacity = rtl.as(Source,$mod.TTMSFNCCustomGraphicsStroke).FOpacity;
        this.FWidth = rtl.as(Source,$mod.TTMSFNCCustomGraphicsStroke).FWidth;
      } else if ($mod.TTMSFNCCustomGraphicsFill.isPrototypeOf(Source)) {
        this.FColor = rtl.rc(rtl.as(Source,$mod.TTMSFNCCustomGraphicsFill).FColor,-9007199254740991,9007199254740991);
        this.FKind = rtl.rc($mod.TTMSFNCGraphicsStrokeKind.gskSolid,0,5);
        this.FOpacity = 1;
        this.FWidth = 1;
      };
      this.Changed();
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      this.FUpdateCount -= 1;
      this.Changed();
    };
  });
  rtl.createClass(this,"TTMSFNCGraphicsStroke",this.TTMSFNCCustomGraphicsStroke,function () {
    var $r = this.$rtti;
    $r.addProperty("OnChanged",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChanged","FOnChanged");
    $r.addProperty("Kind",14,$mod.$rtti["TTMSFNCGraphicsStrokeKind"],"FKind","SetKind",4,{stored: "IsKindStored"});
    $r.addProperty("Color",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{stored: "IsColorStored"});
    $r.addProperty("Width",14,rtl.double,"FWidth","SetWidth",4,{stored: "IsWidthStored"});
  });
  this.$rtti.$DynArray("TTMSFNCGraphicsPathPolygon",{eltype: pas["WEBLib.TMSFNCTypes"].$rtti["TPointF"]});
  this.TTMSFNCGraphicsPathPointKind = {"0": "gppMoveTo", gppMoveTo: 0, "1": "gppLineTo", gppLineTo: 1, "2": "gppCurveTo", gppCurveTo: 2, "3": "gppClose", gppClose: 3};
  this.$rtti.$Enum("TTMSFNCGraphicsPathPointKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGraphicsPathPointKind});
  this.TTMSFNCGraphicsPathCubicBezier$clone = function (a) {
    var b = [];
    b.length = 4;
    for (var c = 0; c < 4; c++) b[c] = pas["WEBLib.TMSFNCTypes"].TPointF.$clone(a[c]);
    return b;
  };
  this.$rtti.$StaticArray("TTMSFNCGraphicsPathCubicBezier",{dims: [4], eltype: pas["WEBLib.TMSFNCTypes"].$rtti["TPointF"]});
  rtl.recNewT(this,"TTMSFNCGraphicsPathPoint",function () {
    this.Kind = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Point = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.Kind === b.Kind) && this.Point.$eq(b.Point);
    };
    this.$assign = function (s) {
      this.Kind = s.Kind;
      this.Point.$assign(s.Point);
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCGraphicsPathPoint",{},this);
    $r.addField("Kind",$mod.$rtti["TTMSFNCGraphicsPathPointKind"]);
    $r.addField("Point",pas["WEBLib.TMSFNCTypes"].$rtti["TPointF"]);
  });
  this.TTMSFNCGraphicsPathDrawMode = {"0": "pdmPolygon", pdmPolygon: 0, "1": "pdmPolyline", pdmPolyline: 1, "2": "pdmPath", pdmPath: 2};
  this.$rtti.$Enum("TTMSFNCGraphicsPathDrawMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGraphicsPathDrawMode});
  rtl.createClass(this,"TTMSFNCGraphicsPathPoints",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      rtl.rc(Index,-2147483648,2147483647);
      var Result = $mod.TTMSFNCGraphicsPathPoint.$new();
      Result.$assign(rtl.getObject(this.Get(Index)));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      rtl.rc(Index,-2147483648,2147483647);
      var v = $mod.TTMSFNCGraphicsPathPoint.$new();
      v.$assign(Value);
      this.Put(Index,v);
    };
  });
  this.TTMSFNCGraphicsCorner = {"0": "gcTopLeft", gcTopLeft: 0, "1": "gcTopRight", gcTopRight: 1, "2": "gcBottomLeft", gcBottomLeft: 2, "3": "gcBottomRight", gcBottomRight: 3};
  this.$rtti.$Enum("TTMSFNCGraphicsCorner",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGraphicsCorner});
  this.$rtti.$Set("TTMSFNCGraphicsCorners",{comptype: this.$rtti["TTMSFNCGraphicsCorner"]});
  rtl.createClass(this,"TTMSFNCGraphicsPath",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FStartPoint = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      this.FClippable = false;
      this.FPoints = null;
    };
    this.$final = function () {
      this.FStartPoint = undefined;
      this.FPoints = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.CalculateBezierCoefficients = function (Bezier, AX, BX, CX, AY, BY, CY) {
      CX.set(3 * (Bezier[1].X - Bezier[0].X));
      CY.set(3 * (Bezier[1].Y - Bezier[0].Y));
      BX.set((3 * (Bezier[2].X - Bezier[1].X)) - CX.get());
      BY.set((3 * (Bezier[2].Y - Bezier[1].Y)) - CY.get());
      AX.set(Bezier[3].X - Bezier[0].X - CX.get() - BX.get());
      AY.set(Bezier[3].Y - Bezier[0].Y - CY.get() - BY.get());
    };
    this.GetCount = function () {
      var Result = 0;
      Result = rtl.rc(this.FPoints.GetCount(),-2147483648,2147483647);
      return Result;
    };
    this.GetPoint = function (AIndex) {
      rtl.rc(AIndex,-2147483648,2147483647);
      var Result = $mod.TTMSFNCGraphicsPathPoint.$new();
      Result.$assign(this.FPoints.GetItem(AIndex));
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FPoints = $mod.TTMSFNCGraphicsPathPoints.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FPoints");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      var I = 0;
      if ($mod.TTMSFNCGraphicsPath.isPrototypeOf(Source)) {
        this.FPoints.SetCount(Source.GetCount());
        for (var $l = 0, $end = Source.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FPoints.SetItem(I,Source.GetPoint(I));
        };
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.LastPoint = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      if (this.GetCount() > 0) {
        Result.$assign(this.FPoints.GetItem(this.FPoints.GetCount() - 1).Point)}
       else {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(0,0));
      };
      return Result;
    };
    this.IsPointVisible = function (P) {
      var Result = false;
      var pt = [];
      pt = rtl.arraySetLength(pt,pas["WEBLib.TMSFNCTypes"].TPointF,0);
      this.FlattenToPolygon({get: function () {
          return pt;
        }, set: function (v) {
          pt = v;
        }},0.25);
      Result = $mod.PointInPoly(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(P),rtl.arrayRef(pt));
      return Result;
    };
    this.IsRectVisible = function (R) {
      var Result = false;
      var pt = [];
      pt = rtl.arraySetLength(pt,pas["WEBLib.TMSFNCTypes"].TPointF,0);
      this.FlattenToPolygon({get: function () {
          return pt;
        }, set: function (v) {
          pt = v;
        }},0.25);
      Result = $mod.PolyInRect(rtl.arrayRef(pt),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(R));
      return Result;
    };
    this.PointOnBezier = function (StartPoint, AX, BX, CX, AY, BY, CY, T) {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var SquareT = 0.0;
      var CubeT = 0.0;
      SquareT = T * T;
      CubeT = SquareT * T;
      Result.X = (AX * CubeT) + (BX * SquareT) + (CX * T) + StartPoint.X;
      Result.Y = (AY * CubeT) + (BY * SquareT) + (CY * T) + StartPoint.Y;
      return Result;
    };
    this.CreateBezier = function (Bezier, PointCount) {
      rtl.rc(PointCount,-2147483648,2147483647);
      var Result = [];
      var AX = 0.0;
      var BX = 0.0;
      var CX = 0.0;
      var AY = 0.0;
      var BY = 0.0;
      var CY = 0.0;
      var DT = 0.0;
      var T = 0.0;
      var I = 0;
      if (PointCount === 0) return Result;
      DT = 1 / ((1 * PointCount) - 1);
      T = 0;
      Result = rtl.arraySetLength(Result,pas["WEBLib.TMSFNCTypes"].TPointF,PointCount);
      this.CalculateBezierCoefficients(Bezier,{get: function () {
          return AX;
        }, set: function (v) {
          AX = v;
        }},{get: function () {
          return BX;
        }, set: function (v) {
          BX = v;
        }},{get: function () {
          return CX;
        }, set: function (v) {
          CX = v;
        }},{get: function () {
          return AY;
        }, set: function (v) {
          AY = v;
        }},{get: function () {
          return BY;
        }, set: function (v) {
          BY = v;
        }},{get: function () {
          return CY;
        }, set: function (v) {
          CY = v;
        }});
      for (var $l = 0, $end = PointCount - 1; $l <= $end; $l++) {
        I = $l;
        rtl.rcArrR(Result,I).$assign(this.PointOnBezier(Bezier[0],AX,BX,CX,AY,BY,CY,T));
        T = T + DT;
      };
      return Result;
    };
    var SmallAmount = 0.001;
    this.GetBounds = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var pt = $mod.TTMSFNCGraphicsPathPoint.$new();
      if (this.FPoints.GetCount() < 1) return pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0);
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0xFFFF,0xFFFF,-0xFFFF,-0xFFFF));
      for (var $l = 0, $end = this.FPoints.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        pt.$assign(this.FPoints.GetItem(I));
        if (pt.Kind === $mod.TTMSFNCGraphicsPathPointKind.gppClose) continue;
        if (pt.Point.X < Result.Left) Result.Left = pt.Point.X;
        if (pt.Point.X > Result.Right) Result.Right = pt.Point.X;
        if (pt.Point.Y < Result.Top) Result.Top = pt.Point.Y;
        if (pt.Point.Y > Result.Bottom) Result.Bottom = pt.Point.Y;
      };
      if (pas.Math.SameValue(Result.Right - Result.Left,0,1E-3)) Result.Right = Result.Left + 1E-3;
      if (pas.Math.SameValue(Result.Bottom - Result.Top,0,1E-3)) Result.Bottom = Result.Top + 1E-3;
      return Result;
    };
    this.IsClippable = function () {
      var Result = false;
      Result = this.FClippable;
      return Result;
    };
    this.MoveTo = function (P) {
      var pt = $mod.TTMSFNCGraphicsPathPoint.$new();
      pt.Kind = rtl.rc($mod.TTMSFNCGraphicsPathPointKind.gppMoveTo,0,3);
      pt.Point.$assign(P);
      this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(pt));
      this.FStartPoint.$assign(this.FPoints.GetItem(this.FPoints.GetCount() - 1).Point);
    };
    this.LineTo = function (P) {
      var pt = $mod.TTMSFNCGraphicsPathPoint.$new();
      pt.Kind = rtl.rc($mod.TTMSFNCGraphicsPathPointKind.gppLineTo,0,3);
      pt.Point.$assign(P);
      this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(pt));
      if ((P.X === this.FStartPoint.X) && (P.Y === this.FStartPoint.Y)) this.FClippable = true;
    };
    this.CurveTo = function (ControlPoint1, ControlPoint2, EndPoint) {
      var pt = $mod.TTMSFNCGraphicsPathPoint.$new();
      pt.Kind = rtl.rc($mod.TTMSFNCGraphicsPathPointKind.gppCurveTo,0,3);
      pt.Point.$assign(ControlPoint1);
      this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(pt));
      pt.Kind = rtl.rc($mod.TTMSFNCGraphicsPathPointKind.gppCurveTo,0,3);
      pt.Point.$assign(ControlPoint2);
      this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(pt));
      pt.Kind = rtl.rc($mod.TTMSFNCGraphicsPathPointKind.gppCurveTo,0,3);
      pt.Point.$assign(EndPoint);
      this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(pt));
    };
    this.SmoothCurveTo = function (ControlPoint2, EndPoint) {
      var ControlPoint1 = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      if (this.GetCount() > 2) {
        ControlPoint1.X = this.LastPoint().X + (this.LastPoint().X - this.FPoints.GetItem(this.FPoints.GetCount() - 2).Point.X);
        ControlPoint1.Y = this.LastPoint().Y + (this.LastPoint().Y - this.FPoints.GetItem(this.FPoints.GetCount() - 2).Point.Y);
      } else ControlPoint1.$assign(ControlPoint2);
      this.CurveTo(ControlPoint1,ControlPoint2,EndPoint);
    };
    var OneThird = 1 / 3;
    var TwoThirds = 2 / 3;
    this.QuadCurveTo = function (ControlPoint, EndPoint) {
      var LP = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var CP1 = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var CP2 = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      LP.$assign(this.LastPoint());
      CP1.X = (0.33333333333333331 * LP.X) + (0.66666666666666663 * ControlPoint.X);
      CP1.Y = (0.33333333333333331 * LP.Y) + (0.66666666666666663 * ControlPoint.Y);
      CP2.X = (0.66666666666666663 * ControlPoint.X) + (0.33333333333333331 * EndPoint.X);
      CP2.Y = (0.66666666666666663 * ControlPoint.Y) + (0.33333333333333331 * EndPoint.Y);
      this.CurveTo(CP1,CP2,EndPoint);
    };
    this.AddPolygon = function (APolygon) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(APolygon) - 1; $l <= $end; $l++) {
        I = $l;
        this.LineTo(rtl.rcArrR(APolygon,I));
      };
    };
    this.ClosePath = function () {
      var pt = $mod.TTMSFNCGraphicsPathPoint.$new();
      pt.Kind = rtl.rc($mod.TTMSFNCGraphicsPathPointKind.gppClose,0,3);
      pt.Point.$assign(this.FStartPoint);
      this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(pt));
      this.FClippable = true;
    };
    this.AddLine = function (StartPoint, EndPoint) {
      if (this.GetCount() === 0) {
        this.MoveTo(StartPoint)}
       else this.LineTo(StartPoint);
      this.LineTo(EndPoint);
    };
    this.AddEllipse = function (ARect) {
      var CX = 0.0;
      var CY = 0.0;
      var PX = 0.0;
      var PY = 0.0;
      var c = 0.0;
      c = 0.5522847498;
      CX = (ARect.Left + ARect.Right) / 2;
      CY = (ARect.Top + ARect.Bottom) / 2;
      PX = c * ((ARect.Right - ARect.Left) / 2);
      PY = c * ((ARect.Bottom - ARect.Top) / 2);
      this.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,CY));
      this.CurveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,CY - PY),pas["WEBLib.TMSFNCTypes"].PointF(CX - PX,ARect.Top),pas["WEBLib.TMSFNCTypes"].PointF(CX,ARect.Top));
      this.CurveTo(pas["WEBLib.TMSFNCTypes"].PointF(CX + PX,ARect.Top),pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,CY - PY),pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,CY));
      this.CurveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,CY + PY),pas["WEBLib.TMSFNCTypes"].PointF(CX + PX,ARect.Bottom),pas["WEBLib.TMSFNCTypes"].PointF(CX,ARect.Bottom));
      this.CurveTo(pas["WEBLib.TMSFNCTypes"].PointF(CX - PX,ARect.Bottom),pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,CY + PY),pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,CY));
      this.FClippable = true;
    };
    this.AddRectangle = function (ARect, ARoundingX, ARoundingY, ACorners) {
      if ((ARoundingX === 0.0) && (ARoundingY === 0.0)) {
        this.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top));
        this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top));
        this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom));
        this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom));
      } else {
        if ($mod.TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          this.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ARoundingX,ARect.Bottom));
          this.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ARoundingX,ARect.Bottom - ARoundingY),pas["WEBLib.TMSFNCTypes"].PointF(ARoundingX,ARoundingY),-270,90);
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom - ARoundingY));
        } else {
          this.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom));
        };
        if ($mod.TTMSFNCGraphicsCorner.gcTopLeft in ACorners) {
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top + ARoundingY));
          this.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ARoundingX,ARect.Top + ARoundingY),pas["WEBLib.TMSFNCTypes"].PointF(ARoundingX,ARoundingY),-180,90);
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ARoundingX,ARect.Top));
        } else this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top));
        if ($mod.TTMSFNCGraphicsCorner.gcTopRight in ACorners) {
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right - ARoundingX,ARect.Top));
          this.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right - ARoundingX,ARect.Top + ARoundingY),pas["WEBLib.TMSFNCTypes"].PointF(ARoundingX,ARoundingY),-90,90);
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top + ARoundingY));
        } else this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top));
        if ($mod.TTMSFNCGraphicsCorner.gcBottomRight in ACorners) {
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom - ARoundingY));
          this.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right - ARoundingX,ARect.Bottom - ARoundingY),pas["WEBLib.TMSFNCTypes"].PointF(ARoundingX,ARoundingY),0,90);
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right - ARoundingX,ARect.Bottom));
        } else this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom));
        if ($mod.TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ARoundingX,ARect.Bottom))}
         else this.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom));
      };
      this.ClosePath();
      this.FClippable = true;
    };
    var BezierArcAngleEpsilon = 0.01;
    var MinSweepAngle = 1E-10;
    this.AddArc = function (Center, Radius, StartAngle, SweepAngle) {
      var UseMoveTo = false;
      var I = 0;
      var F = 0.0;
      var TotalSweep = 0.0;
      var LocalSweep = 0.0;
      var PrevSweep = 0.0;
      var Done = false;
      StartAngle = pas.Math.DegToRad(StartAngle);
      SweepAngle = pas.Math.DegToRad(SweepAngle);
      I = rtl.rc(pas.System.Trunc(StartAngle / (2 * Math.PI)),-2147483648,2147483647);
      F = StartAngle - (I * 2 * Math.PI);
      StartAngle = F;
      if (SweepAngle >= (2 * Math.PI)) SweepAngle = 2 * Math.PI;
      if (SweepAngle <= (-2 * Math.PI)) SweepAngle = -2 * Math.PI;
      if (Math.abs(SweepAngle) < 1E-10) return;
      TotalSweep = 0;
      Done = false;
      UseMoveTo = true;
      do {
        if (SweepAngle < 0) {
          PrevSweep = TotalSweep;
          LocalSweep = -Math.PI / 2;
          TotalSweep = TotalSweep - (Math.PI / 2);
          if (TotalSweep <= (SweepAngle + 0.01)) {
            LocalSweep = SweepAngle - PrevSweep;
            Done = true;
          };
        } else {
          PrevSweep = TotalSweep;
          LocalSweep = Math.PI / 2;
          TotalSweep = TotalSweep + (Math.PI / 2);
          if (TotalSweep >= (SweepAngle - 0.01)) {
            LocalSweep = SweepAngle - PrevSweep;
            Done = true;
          };
        };
        $impl.DrawArcWithBezier(this,Center.X,Center.Y,Radius.X,Radius.Y,StartAngle,LocalSweep,UseMoveTo);
        UseMoveTo = false;
        StartAngle = StartAngle + LocalSweep;
      } while (!Done);
    };
    this.AddPath = function (APath) {
      var I = 0;
      this.FPoints.SetCapacity(this.FPoints.GetCount() + APath.GetCount());
      for (var $l = 0, $end = APath.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FPoints.Add($mod.TTMSFNCGraphicsPathPoint.$clone(APath.GetPoint(I)));
      };
    };
    this.ApplyMatrix = function (AMatrix) {
      var I = 0;
      var pt = $mod.TTMSFNCGraphicsPathPoint.$new();
      if (this.FPoints.GetCount() > 0) {
        for (var $l = 0, $end = this.FPoints.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if (this.FPoints.GetItem(I).Kind in rtl.createSet($mod.TTMSFNCGraphicsPathPointKind.gppMoveTo,$mod.TTMSFNCGraphicsPathPointKind.gppLineTo,$mod.TTMSFNCGraphicsPathPointKind.gppCurveTo)) {
            pt.$assign(this.FPoints.GetItem(I));
            pt.Point.$assign($mod.MatrixMultiply$1(pt.Point,AMatrix));
            this.FPoints.SetItem(I,pt);
          };
        };
      };
    };
    this.Clear = function () {
      this.FPoints.Clear();
    };
    this.Flatten = function (Flatness) {
      var J = 0;
      var I = 0;
      var BPts = [];
      var B = rtl.arraySetLength(null,pas["WEBLib.TMSFNCTypes"].TPointF,4);
      var F = 0.0;
      var Len = 0.0;
      var SegCount = 0;
      var OldPathData = null;
      var CurPoint = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var x = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      if (this.FPoints.GetCount() > 0) {
        F = Math.max(Flatness,0.05);
        OldPathData = $mod.TTMSFNCGraphicsPathPoints.$create("Create$1");
        try {
          OldPathData.SetCount(this.FPoints.GetCount());
          for (var $l = 0, $end = this.FPoints.GetCount() - 1; $l <= $end; $l++) {
            J = $l;
            OldPathData.Add($mod.TTMSFNCGraphicsPathPoint.$clone(this.FPoints.GetItem(J)));
          };
          this.FPoints.Clear();
          J = 0;
          while (J < OldPathData.GetCount()) {
            var $tmp = OldPathData.GetItem(J).Kind;
            if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppMoveTo) {
              this.MoveTo(OldPathData.GetItem(J).Point);
              CurPoint.$assign(OldPathData.GetItem(J).Point);
            } else if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppLineTo) {
              this.LineTo(OldPathData.GetItem(J).Point);
              CurPoint.$assign(OldPathData.GetItem(J).Point);
            } else if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppCurveTo) {
              B[0].$assign(CurPoint);
              B[1].$assign(OldPathData.GetItem(J).Point);
              J += 1;
              B[2].$assign(OldPathData.GetItem(J).Point);
              J += 1;
              B[3].$assign(OldPathData.GetItem(J).Point);
              BPts = this.CreateBezier(B,6);
              Len = 0;
              for (var $l1 = 0, $end1 = rtl.length(BPts) - 1 - 1; $l1 <= $end1; $l1++) {
                I = $l1;
                x.X = rtl.rcArrR(BPts,I).X - rtl.rcArrR(BPts,I + 1).X;
                x.Y = rtl.rcArrR(BPts,I).Y - rtl.rcArrR(BPts,I + 1).Y;
                Len = Len + pas["WEBLib.TMSFNCTypes"].GetPointLength(x);
              };
              SegCount = rtl.rc(Math.round(Len / F),-2147483648,2147483647);
              if (SegCount < 2) {
                this.LineTo(B[3])}
               else {
                BPts = this.CreateBezier(B,SegCount);
                for (var $l2 = 0, $end2 = rtl.length(BPts) - 1; $l2 <= $end2; $l2++) {
                  I = $l2;
                  this.LineTo(rtl.rcArrR(BPts,I));
                };
                CurPoint.$assign(OldPathData.GetItem(J).Point);
              };
            } else if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppClose) this.ClosePath();
            J += 1;
          };
        } finally {
          OldPathData = rtl.freeLoc(OldPathData);
        };
      };
    };
    this.FlattenToPolygon = function (Polygon, Flatness) {
      var $Self = this;
      function AddPoint(P) {
        if ((rtl.length(Polygon.get()) > 0) && pas.Math.SameValue(P.X,rtl.rcArrR(Polygon.get(),rtl.length(Polygon.get()) - 1).X,1E-3) && pas.Math.SameValue(P.Y,rtl.rcArrR(Polygon.get(),rtl.length(Polygon.get()) - 1).Y,1E-3)) return;
        Polygon.set(rtl.arraySetLength(Polygon.get(),pas["WEBLib.TMSFNCTypes"].TPointF,rtl.length(Polygon.get()) + 1));
        rtl.rcArrR(Polygon.get(),rtl.length(Polygon.get()) - 1).$assign(P);
      };
      var J = 0;
      var I = 0;
      var BPts = [];
      var B = rtl.arraySetLength(null,pas["WEBLib.TMSFNCTypes"].TPointF,4);
      var SP = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var CurPoint = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var X = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var F = 0.0;
      var Len = 0.0;
      var SegCount = 0;
      Polygon.set(rtl.arraySetLength(Polygon.get(),pas["WEBLib.TMSFNCTypes"].TPointF,0));
      if (this.FPoints.GetCount() > 0) {
        F = Math.max(Flatness,0.05);
        J = 0;
        while (J < this.FPoints.GetCount()) {
          var $tmp = this.FPoints.GetItem(J).Kind;
          if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppMoveTo) {
            AddPoint(this.FPoints.GetItem(J).Point);
            CurPoint.$assign(this.FPoints.GetItem(J).Point);
            SP.$assign(CurPoint);
          } else if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppLineTo) {
            AddPoint(this.FPoints.GetItem(J).Point);
            CurPoint.$assign(this.FPoints.GetItem(J).Point);
          } else if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppCurveTo) {
            B[0].$assign(CurPoint);
            B[1].$assign(this.FPoints.GetItem(J).Point);
            J += 1;
            B[2].$assign(this.FPoints.GetItem(J).Point);
            J += 1;
            B[3].$assign(this.FPoints.GetItem(J).Point);
            BPts = this.CreateBezier(B,6);
            Len = 0;
            for (var $l = 0, $end = rtl.length(BPts) - 1 - 1; $l <= $end; $l++) {
              I = $l;
              X.X = rtl.rcArrR(BPts,I).X - rtl.rcArrR(BPts,I + 1).X;
              X.Y = rtl.rcArrR(BPts,I).Y - rtl.rcArrR(BPts,I + 1).Y;
              Len = Len + pas["WEBLib.TMSFNCTypes"].GetPointLength(X);
            };
            SegCount = rtl.rc(Math.round(Len / F),-2147483648,2147483647);
            if (SegCount < 2) {
              AddPoint(B[0]);
              AddPoint(B[3]);
            } else {
              BPts = this.CreateBezier(B,SegCount);
              for (var $l1 = 0, $end1 = rtl.length(BPts) - 1; $l1 <= $end1; $l1++) {
                I = $l1;
                AddPoint(rtl.rcArrR(BPts,I));
              };
            };
            CurPoint.$assign(this.FPoints.GetItem(J).Point);
          } else if ($tmp === $mod.TTMSFNCGraphicsPathPointKind.gppClose) {
            AddPoint(SP);
          };
          J += 1;
        };
      };
    };
  });
  rtl.createClass(this,"TTMSFNCGraphicsColorObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FColor = 0;
    };
    this.Create$1 = function (AColor) {
      rtl.rc(AColor,-9007199254740991,9007199254740991);
      this.FColor = rtl.rc(AColor,-9007199254740991,9007199254740991);
      return this;
    };
  });
  this.TTMSFNCGraphicsModifyRectMode = {"0": "gcrmNone", gcrmNone: 0, "1": "gcrmExpandAll", gcrmExpandAll: 1, "2": "gcrmShrinkAll", gcrmShrinkAll: 2, "3": "gcrmShiftRightAndExpandHeight", gcrmShiftRightAndExpandHeight: 3, "4": "gcrmShiftDownAndExpandWidth", gcrmShiftDownAndExpandWidth: 4, "5": "gcrmShiftRightAndShrinkHeight", gcrmShiftRightAndShrinkHeight: 5, "6": "gcrmShiftRightDown", gcrmShiftRightDown: 6, "7": "gcrmShiftRightUp", gcrmShiftRightUp: 7, "8": "gcrmShiftLeftUp", gcrmShiftLeftUp: 8, "9": "gcrmShiftLeftDown", gcrmShiftLeftDown: 9, "10": "gcrmShiftUpAndExpandWidth", gcrmShiftUpAndExpandWidth: 10, "11": "gcrmShiftLeftAndExpandHeight", gcrmShiftLeftAndExpandHeight: 11};
  this.$rtti.$Enum("TTMSFNCGraphicsModifyRectMode",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TTMSFNCGraphicsModifyRectMode});
  this.TTMSFNCGraphicsModifyPointMode = {"0": "gcpmNone", gcpmNone: 0, "1": "gcpmLeftUp", gcpmLeftUp: 1, "2": "gcpmRightDown", gcpmRightDown: 2, "3": "gcpmLeftDown", gcpmLeftDown: 3, "4": "gcpmRightUp", gcpmRightUp: 4};
  this.$rtti.$Enum("TTMSFNCGraphicsModifyPointMode",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCGraphicsModifyPointMode});
  this.TTMSFNCGraphicsExpanderState = {"0": "gesCollapsed", gesCollapsed: 0, "1": "gesExpanded", gesExpanded: 1};
  this.$rtti.$Enum("TTMSFNCGraphicsExpanderState",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGraphicsExpanderState});
  this.TTMSFNCGraphicsCompactState = {"0": "gcsCollapsed", gcsCollapsed: 0, "1": "gcsExpanded", gcsExpanded: 1};
  this.$rtti.$Enum("TTMSFNCGraphicsCompactState",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGraphicsCompactState});
  rtl.createClass(this,"TTMSFNCGraphicsColorList",pas.Classes.TStringList,function () {
    this.AddOrSetValue = function (AKey, AValue) {
      var I = 0;
      var it = null;
      it = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (AKey === this.Get(I)) {
          it = this.GetObject(I);
          break;
        };
      };
      if (!(it != null)) {
        this.AddObject(AKey,AValue);
      } else this.PutObject(I,AValue);
    };
    this.TryGetValue = function (AKey, AValue) {
      var Result = false;
      var I = 0;
      Result = false;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (AKey === this.Get(I)) {
          AValue.set(rtl.as(this.GetObject(I),$mod.TTMSFNCGraphicsColorObject));
          Result = true;
          break;
        };
      };
      return Result;
    };
  });
  this.ModifyRect = function (ARect, ARectMode) {
    var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    Result.$assign(ARect);
    var $tmp = ARectMode;
    if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmExpandAll) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) - 0.5,pas.System.Int(Result.Top) - 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) + 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) + 0.5,pas.System.Int(Result.Top) + 0.5,pas.System.Int(Result.Right) - 0.5,pas.System.Int(Result.Bottom) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftRightAndExpandHeight) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) + 0.5,pas.System.Int(Result.Top) - 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) + 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftRightDown) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) + 0.5,pas.System.Int(Result.Top) + 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) + 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftRightAndShrinkHeight) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) + 0.5,pas.System.Int(Result.Top) + 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftDownAndExpandWidth) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) - 0.5,pas.System.Int(Result.Top) + 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) + 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftUpAndExpandWidth) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) - 0.5,pas.System.Int(Result.Top) - 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftRightUp) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) + 0.5,pas.System.Int(Result.Top) - 0.5,pas.System.Int(Result.Right) + 0.5,pas.System.Int(Result.Bottom) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftLeftUp) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) - 0.5,pas.System.Int(Result.Top) - 0.5,pas.System.Int(Result.Right) - 0.5,pas.System.Int(Result.Bottom) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftLeftDown) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) - 0.5,pas.System.Int(Result.Top) + 0.5,pas.System.Int(Result.Right) - 0.5,pas.System.Int(Result.Bottom) + 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyRectMode.gcrmShiftLeftAndExpandHeight) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(Result.Left) - 0.5,pas.System.Int(Result.Top) - 0.5,pas.System.Int(Result.Right) - 0.5,pas.System.Int(Result.Bottom) + 0.5));
    return Result;
  };
  this.ModifyPoint = function (APoint, APointMode) {
    var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
    Result.$assign(APoint);
    var $tmp = APointMode;
    if ($tmp === $mod.TTMSFNCGraphicsModifyPointMode.gcpmRightDown) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(pas.System.Int(Result.X) + 0.5,pas.System.Int(Result.Y) + 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyPointMode.gcpmLeftUp) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(pas.System.Int(Result.X) - 0.5,pas.System.Int(Result.Y) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyPointMode.gcpmRightUp) {
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(pas.System.Int(Result.X) + 0.5,pas.System.Int(Result.Y) - 0.5))}
     else if ($tmp === $mod.TTMSFNCGraphicsModifyPointMode.gcpmLeftDown) Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(pas.System.Int(Result.X) - 0.5,pas.System.Int(Result.Y) + 0.5));
    return Result;
  };
  this.MakeGraphicsColor = function (ARed, AGreen, ABlue) {
    rtl.rc(ARed,0,255);
    rtl.rc(AGreen,0,255);
    rtl.rc(ABlue,0,255);
    var Result = 0;
    Result = rtl.rc(pas["WEBLib.Graphics"].RGB(ARed,AGreen,ABlue),-9007199254740991,9007199254740991);
    return Result;
  };
  this.Lighter = function (AColor, APercent) {
    rtl.rc(AColor,-9007199254740991,9007199254740991);
    rtl.rc(APercent,0,255);
    var Result = 0;
    var r = 0;
    var g = 0;
    var b = 0;
    AColor = rtl.rc(pas["WEBLib.Graphics"].ColorToRGB(AColor),-9007199254740991,9007199254740991);
    r = rtl.rc(pas["WEBLib.Graphics"].GetRValue(AColor),0,255);
    g = rtl.rc(pas["WEBLib.Graphics"].GetGValue(AColor),0,255);
    b = rtl.rc(pas["WEBLib.Graphics"].GetBValue(AColor),0,255);
    r = rtl.rc(r + Math.min(255,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(255 - r,APercent,100)),0,255);
    g = rtl.rc(g + Math.min(255,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(255 - g,APercent,100)),0,255);
    b = rtl.rc(b + Math.min(255,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(255 - b,APercent,100)),0,255);
    Result = rtl.rc($mod.MakeGraphicsColor(r,g,b),-9007199254740991,9007199254740991);
    return Result;
  };
  this.Darker = function (AColor, APercent) {
    rtl.rc(AColor,-9007199254740991,9007199254740991);
    rtl.rc(APercent,0,255);
    var Result = 0;
    var r = 0;
    var g = 0;
    var b = 0;
    AColor = rtl.rc(pas["WEBLib.Graphics"].ColorToRGB(AColor),-9007199254740991,9007199254740991);
    r = rtl.rc(pas["WEBLib.Graphics"].GetRValue(AColor),0,255);
    g = rtl.rc(pas["WEBLib.Graphics"].GetGValue(AColor),0,255);
    b = rtl.rc(pas["WEBLib.Graphics"].GetBValue(AColor),0,255);
    r = rtl.rc(r - Math.max(0,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(255 - r,APercent,100)),0,255);
    g = rtl.rc(g - Math.max(0,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(255 - g,APercent,100)),0,255);
    b = rtl.rc(b - Math.max(0,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(255 - b,APercent,100)),0,255);
    Result = rtl.rc($mod.MakeGraphicsColor(r,g,b),-9007199254740991,9007199254740991);
    return Result;
  };
  this.Blend = function (AColor1, AColor2, ALevel) {
    var Result = 0;
    var c1 = 0;
    var c2 = 0;
    var r = 0;
    var g = 0;
    var b = 0;
    var v1 = 0;
    var v2 = 0;
    ALevel = Math.round(2.55 * ALevel);
    c1 = pas["WEBLib.Graphics"].ColorToRGB(AColor1);
    c2 = pas["WEBLib.Graphics"].ColorToRGB(AColor2);
    v1 = c1 & 255;
    v2 = c2 & 255;
    r = Math.max(0,Math.min(255,((ALevel * (v1 - v2)) >>> 8) + v2));
    v1 = Math.floor(c1 / 256) & 255;
    v2 = Math.floor(c2 / 256) & 255;
    g = Math.max(0,Math.min(255,((ALevel * (v1 - v2)) >>> 8) + v2));
    v1 = Math.floor(c1 / 65536) & 255;
    v2 = Math.floor(c2 / 65536) & 255;
    b = Math.max(0,Math.min(255,((ALevel * (v1 - v2)) >>> 8) + v2));
    Result = (b << 16) + (g << 8) + r;
    return Result;
  };
  this.ColorLookup = function () {
    var Result = null;
    Result = $impl.FColorLookup;
    return Result;
  };
  this.PointInPoly = function (APoint, APolygon) {
    var Result = false;
    var minX = 0.0;
    var maxX = 0.0;
    var minY = 0.0;
    var maxY = 0.0;
    var I = 0;
    var J = 0;
    var q = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
    var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
    var ptn = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
    var inside = false;
    var chk = false;
    var calc = 0.0;
    var chkc = false;
    Result = false;
    if (rtl.length(APolygon) === 0) return Result;
    minX = APolygon[0].X;
    maxX = APolygon[0].X;
    minY = APolygon[0].Y;
    maxY = APolygon[0].Y;
    for (var $l = 1, $end = rtl.length(APolygon) - 1; $l <= $end; $l++) {
      I = $l;
      q.$assign(APolygon[I]);
      minX = Math.min(q.X,minX);
      maxX = Math.max(q.X,maxX);
      minY = Math.min(q.Y,minY);
      maxY = Math.max(q.Y,maxY);
    };
    if ((APoint.X < minX) || (APoint.X > maxX) || (APoint.Y < minY) || (APoint.Y > maxY)) {
      Result = false;
      return Result;
    };
    inside = false;
    J = rtl.length(APolygon) - 1;
    for (var $l1 = 0, $end1 = rtl.length(APolygon) - 1; $l1 <= $end1; $l1++) {
      I = $l1;
      pt.$assign(APolygon[I]);
      ptn.$assign(APolygon[J]);
      chk = (pt.Y > APoint.Y) !== (ptn.Y > APoint.Y);
      if ((ptn.Y - pt.Y) !== 0) {
        calc = (((ptn.X - pt.X) * (APoint.Y - pt.Y)) / (ptn.Y - pt.Y)) + pt.X;
        chkc = APoint.X < calc;
        if (chk && chkc) inside = !inside;
      };
      J = I;
    };
    Result = inside;
    return Result;
  };
  this.RectInPoly = function (ARect, APolygon) {
    var Result = false;
    Result = $mod.PointInPoly(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top)),rtl.arrayRef(APolygon)) || $mod.PointInPoly(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top)),rtl.arrayRef(APolygon)) || $mod.PointInPoly(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom)),rtl.arrayRef(APolygon)) || $mod.PointInPoly(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom)),rtl.arrayRef(APolygon));
    return Result;
  };
  this.PolyInRect = function (APolygon, ARect) {
    var Result = false;
    var I = 0;
    Result = false;
    for (var $l = 0, $end = rtl.length(APolygon) - 1; $l <= $end; $l++) {
      I = $l;
      if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(ARect,APolygon[I])) {
        Result = true;
        return Result;
      };
    };
    return Result;
  };
  this.DrawGradient = function (ACanvas, AColor, AColorTo, ARect, ARounding, ACorners, ADirection) {
    rtl.rc(AColor,-9007199254740991,9007199254740991);
    rtl.rc(AColorTo,-9007199254740991,9007199254740991);
    var diffr = 0;
    var startr = 0;
    var endr = 0;
    var diffg = 0;
    var startg = 0;
    var endg = 0;
    var diffb = 0;
    var startb = 0;
    var endb = 0;
    var si = 0;
    var rstepr = 0.0;
    var rstepg = 0.0;
    var rstepb = 0.0;
    var rstepw = 0.0;
    var i = 0;
    var stepw = 0;
    var oldp = 0;
    var oldb = 0;
    var Steps = 0;
    var R = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var iend = 0.0;
    var a = 0.0;
    var oldps = 0;
    var oldbs = 0;
    R.$assign(ARect);
    if (ADirection) {
      Steps = rtl.rc(Math.round(R.Right - R.Left),-2147483648,2147483647)}
     else Steps = rtl.rc(Math.round(R.Bottom - R.Top),-2147483648,2147483647);
    if (Steps === 0) Steps = 1;
    AColor = rtl.rc(pas["WEBLib.Graphics"].ColorToRGB(AColor),-9007199254740991,9007199254740991);
    AColorTo = rtl.rc(pas["WEBLib.Graphics"].ColorToRGB(AColorTo),-9007199254740991,9007199254740991);
    startr = rtl.rc(AColor & 0xFF,-2147483648,2147483647);
    startg = rtl.rc(Math.floor((AColor & 0xFF00) / 256),-2147483648,2147483647);
    startb = rtl.rc(Math.floor((AColor & 0xFF0000) / 65536),-2147483648,2147483647);
    endr = rtl.rc(AColorTo & 0xFF,-2147483648,2147483647);
    endg = rtl.rc(Math.floor((AColorTo & 0xFF00) / 256),-2147483648,2147483647);
    endb = rtl.rc(Math.floor((AColorTo & 0xFF0000) / 65536),-2147483648,2147483647);
    diffr = rtl.rc(endr - startr,-2147483648,2147483647);
    diffg = rtl.rc(endg - startg,-2147483648,2147483647);
    diffb = rtl.rc(endb - startb,-2147483648,2147483647);
    rstepr = diffr / Steps;
    rstepg = diffg / Steps;
    rstepb = diffb / Steps;
    if (ADirection) {
      rstepw = (R.Right - R.Left) / Steps}
     else rstepw = (R.Bottom - R.Top) / Steps;
    oldb = rtl.rc(ACanvas.FBrush.FColor,-9007199254740991,9007199254740991);
    oldbs = rtl.rc(ACanvas.FBrush.FStyle,0,7);
    oldp = rtl.rc(ACanvas.FPen.FColor,-9007199254740991,9007199254740991);
    oldps = rtl.rc(ACanvas.FPen.FStyle,0,8);
    ACanvas.FPen.FStyle = rtl.rc(pas["WEBLib.Graphics"].TPenStyle.psSolid,0,8);
    ACanvas.FBrush.FStyle = rtl.rc(pas["WEBLib.Graphics"].TBrushStyle.bsSolid,0,7);
    for (var $l = 0, $end = Steps - 1; $l <= $end; $l++) {
      i = $l;
      endr = rtl.rc(startr + Math.round(rstepr * i),-2147483648,2147483647);
      endg = rtl.rc(startg + Math.round(rstepg * i),-2147483648,2147483647);
      endb = rtl.rc(startb + Math.round(rstepb * i),-2147483648,2147483647);
      stepw = rtl.rc(Math.round(i * rstepw),0,65535);
      ACanvas.FPen.SetColor(endr + (endg << 8) + (endb << 16));
      ACanvas.FBrush.FColor = rtl.rc(ACanvas.FPen.FColor,-9007199254740991,9007199254740991);
      if (ADirection) {
        si = rtl.rc(pas.System.Trunc(rstepw),-2147483648,2147483647);
        iend = R.Left + stepw + si;
        iend = Math.min(iend,R.Right);
        dr.$assign(R);
        if ((i <= ARounding) && (($mod.TTMSFNCGraphicsCorner.gcTopLeft in ACorners) || ($mod.TTMSFNCGraphicsCorner.gcBottomLeft in ACorners))) {
          a = Math.sqrt(Math.pow(ARounding,2) - Math.pow(ARounding - i,2));
          if ($mod.TTMSFNCGraphicsCorner.gcTopLeft in ACorners) dr.Top = dr.Top + Math.round(ARounding - a);
          if ($mod.TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) dr.Bottom = dr.Bottom - Math.round(ARounding - a);
        } else if ((i >= (Steps - ARounding)) && (($mod.TTMSFNCGraphicsCorner.gcBottomRight in ACorners) || ($mod.TTMSFNCGraphicsCorner.gcTopRight in ACorners))) {
          a = Math.sqrt(Math.pow(ARounding,2) - Math.pow(ARounding - (Steps - i),2));
          if ($mod.TTMSFNCGraphicsCorner.gcTopRight in ACorners) dr.Top = dr.Top + Math.round(ARounding - a);
          if ($mod.TTMSFNCGraphicsCorner.gcBottomRight in ACorners) dr.Bottom = dr.Bottom - Math.round(ARounding - a);
        };
        ACanvas.Rectangle(dr.Left + stepw,dr.Top,iend,dr.Bottom);
      } else {
        si = rtl.rc(pas.System.Trunc(rstepw),-2147483648,2147483647);
        iend = R.Top + stepw + si;
        iend = Math.min(iend,R.Bottom);
        dr.$assign(R);
        if ((i <= ARounding) && (($mod.TTMSFNCGraphicsCorner.gcTopLeft in ACorners) || ($mod.TTMSFNCGraphicsCorner.gcTopRight in ACorners))) {
          a = Math.sqrt(Math.pow(ARounding,2) - Math.pow(ARounding - i,2));
          if ($mod.TTMSFNCGraphicsCorner.gcTopLeft in ACorners) dr.Left = dr.Left + Math.round(ARounding - a);
          if ($mod.TTMSFNCGraphicsCorner.gcTopRight in ACorners) dr.Right = dr.Right - Math.round(ARounding - a);
        } else if ((i >= (Steps - ARounding)) && (($mod.TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) || ($mod.TTMSFNCGraphicsCorner.gcBottomRight in ACorners))) {
          a = Math.sqrt(Math.pow(ARounding,2) - Math.pow(ARounding - (Steps - i),2));
          if ($mod.TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) dr.Left = dr.Left + Math.round(ARounding - a);
          if ($mod.TTMSFNCGraphicsCorner.gcBottomRight in ACorners) dr.Right = dr.Right - Math.round(ARounding - a);
        };
        ACanvas.Rectangle(dr.Left,dr.Top + stepw,dr.Right,iend);
      };
    };
    ACanvas.FBrush.FColor = rtl.rc(oldb,-9007199254740991,9007199254740991);
    ACanvas.FBrush.FStyle = rtl.rc(oldbs,0,7);
    ACanvas.FPen.SetColor(oldp);
    ACanvas.FPen.FStyle = rtl.rc(oldps,0,8);
  };
  this.IsMatrixIdentity = function (AMatrix) {
    var Result = false;
    Result = (AMatrix.m11 === 1) && (AMatrix.m12 === 0) && (AMatrix.m13 === 0) && (AMatrix.m21 === 0) && (AMatrix.m22 === 1) && (AMatrix.m23 === 0) && (AMatrix.m31 === 0) && (AMatrix.m32 === 0) && (AMatrix.m33 === 1);
    return Result;
  };
  this.IsMatrixEmpty = function (AMatrix) {
    var Result = false;
    Result = (AMatrix.m11 === 0) && (AMatrix.m12 === 0) && (AMatrix.m13 === 0) && (AMatrix.m21 === 0) && (AMatrix.m22 === 0) && (AMatrix.m23 === 0) && (AMatrix.m31 === 0) && (AMatrix.m32 === 0) && (AMatrix.m33 === 0);
    return Result;
  };
  this.MatrixEmpty = function () {
    var Result = $mod.TTMSFNCGraphicsMatrix.$new();
    Result.m11 = 0;
    Result.m12 = 0;
    Result.m13 = 0;
    Result.m21 = 0;
    Result.m22 = 0;
    Result.m23 = 0;
    Result.m31 = 0;
    Result.m32 = 0;
    Result.m33 = 0;
    return Result;
  };
  this.MatrixIdentity = function () {
    var Result = $mod.TTMSFNCGraphicsMatrix.$new();
    Result.m11 = 1;
    Result.m12 = 0;
    Result.m13 = 0;
    Result.m21 = 0;
    Result.m22 = 1;
    Result.m23 = 0;
    Result.m31 = 0;
    Result.m32 = 0;
    Result.m33 = 1;
    return Result;
  };
  this.MatrixCreateRotation = function (AAngle) {
    var Result = $mod.TTMSFNCGraphicsMatrix.$new();
    var S = 0.0;
    var C = 0.0;
    S = Math.sin(AAngle);
    C = Math.cos(AAngle);
    Result.$assign($mod.MatrixIdentity());
    Result.m11 = C;
    Result.m12 = S;
    Result.m21 = -S;
    Result.m22 = C;
    return Result;
  };
  this.MatrixCreateScaling = function (AScaleX, AScaleY) {
    var Result = $mod.TTMSFNCGraphicsMatrix.$new();
    Result.$assign($mod.MatrixIdentity());
    Result.m11 = AScaleX;
    Result.m22 = AScaleY;
    return Result;
  };
  this.MatrixCreateTranslation = function (ADeltaX, ADeltaY) {
    var Result = $mod.TTMSFNCGraphicsMatrix.$new();
    Result.$assign($mod.MatrixIdentity());
    Result.m31 = ADeltaX;
    Result.m32 = ADeltaY;
    return Result;
  };
  this.MatrixMultiply = function (AMatrix1, AMatrix2) {
    var Result = $mod.TTMSFNCGraphicsMatrix.$new();
    Result.m11 = (AMatrix1.m11 * AMatrix2.m11) + (AMatrix1.m12 * AMatrix2.m21) + (AMatrix1.m13 * AMatrix2.m31);
    Result.m12 = (AMatrix1.m11 * AMatrix2.m12) + (AMatrix1.m12 * AMatrix2.m22) + (AMatrix1.m13 * AMatrix2.m32);
    Result.m13 = (AMatrix1.m11 * AMatrix2.m13) + (AMatrix1.m12 * AMatrix2.m23) + (AMatrix1.m13 * AMatrix2.m33);
    Result.m21 = (AMatrix1.m21 * AMatrix2.m11) + (AMatrix1.m22 * AMatrix2.m21) + (AMatrix1.m23 * AMatrix2.m31);
    Result.m22 = (AMatrix1.m21 * AMatrix2.m12) + (AMatrix1.m22 * AMatrix2.m22) + (AMatrix1.m23 * AMatrix2.m32);
    Result.m23 = (AMatrix1.m21 * AMatrix2.m13) + (AMatrix1.m22 * AMatrix2.m23) + (AMatrix1.m23 * AMatrix2.m33);
    Result.m31 = (AMatrix1.m31 * AMatrix2.m11) + (AMatrix1.m32 * AMatrix2.m21) + (AMatrix1.m33 * AMatrix2.m31);
    Result.m32 = (AMatrix1.m31 * AMatrix2.m12) + (AMatrix1.m32 * AMatrix2.m22) + (AMatrix1.m33 * AMatrix2.m32);
    Result.m33 = (AMatrix1.m31 * AMatrix2.m13) + (AMatrix1.m32 * AMatrix2.m23) + (AMatrix1.m33 * AMatrix2.m33);
    return Result;
  };
  this.MatrixMultiply$1 = function (APoint, AMatrix) {
    var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
    Result.X = (APoint.X * AMatrix.m11) + (APoint.Y * AMatrix.m21) + AMatrix.m31;
    Result.Y = (APoint.X * AMatrix.m12) + (APoint.Y * AMatrix.m22) + AMatrix.m32;
    return Result;
  };
  $mod.$implcode = function () {
    $impl.FColorLookup = null;
    $impl.DrawArcWithBezier = function (Path, CenterX, CenterY, RadiusX, RadiusY, StartAngle, SweepRange, UseMoveTo) {
      var Coord = [];
      var Pts = [];
      var A = 0.0;
      var X = 0.0;
      var Y = 0.0;
      var C = 0.0;
      var B = 0.0;
      var CC = 0.0;
      var SS = 0.0;
      var I = 0;
      if (SweepRange === 0) {
        if (UseMoveTo) {
          if (Path.FPoints.GetCount() < 1) {
            Path.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(CenterX + (RadiusX * Math.cos(StartAngle)),CenterY - (RadiusY * Math.sin(StartAngle))))}
           else Path.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(CenterX + (RadiusX * Math.cos(StartAngle)),CenterY - (RadiusY * Math.sin(StartAngle))));
        };
        Path.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(CenterX + (RadiusX * Math.cos(StartAngle)),CenterY - (RadiusY * Math.sin(StartAngle))));
        return;
      };
      B = Math.sin(SweepRange / 2);
      C = Math.cos(SweepRange / 2);
      A = 1 - C;
      X = (A * 4) / 3;
      Y = B - ((X * C) / B);
      SS = Math.sin(StartAngle + (SweepRange / 2));
      CC = Math.cos(StartAngle + (SweepRange / 2));
      Coord = rtl.arraySetLength(Coord,pas["WEBLib.TMSFNCTypes"].TPointF,4);
      Coord[0].$assign(pas["WEBLib.TMSFNCTypes"].PointF(C,-B));
      Coord[1].$assign(pas["WEBLib.TMSFNCTypes"].PointF(C + X,-Y));
      Coord[2].$assign(pas["WEBLib.TMSFNCTypes"].PointF(C + X,Y));
      Coord[3].$assign(pas["WEBLib.TMSFNCTypes"].PointF(C,B));
      Pts = rtl.arraySetLength(Pts,pas["WEBLib.TMSFNCTypes"].TPointF,4);
      for (I = 0; I <= 3; I++) {
        rtl.rcArrR(Pts,I).$assign(pas["WEBLib.TMSFNCTypes"].PointF(CenterX + (RadiusX * ((rtl.rcArrR(Coord,I).X * CC) - (rtl.rcArrR(Coord,I).Y * SS))),CenterY + (RadiusY * ((rtl.rcArrR(Coord,I).X * SS) + (rtl.rcArrR(Coord,I).Y * CC)))));
      };
      if (UseMoveTo) {
        if (Path.FPoints.GetCount() < 1) {
          Path.MoveTo(Pts[0])}
         else Path.LineTo(Pts[0]);
      };
      Path.CurveTo(Pts[1],Pts[2],Pts[3]);
    };
  };
  $mod.$init = function () {
    $impl.FColorLookup = $mod.TTMSFNCGraphicsColorList.$create("Create$1");
    $impl.FColorLookup.AddOrSetValue("aliceblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16775408]));
    $impl.FColorLookup.AddOrSetValue("antiquewhite",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14150650]));
    $impl.FColorLookup.AddOrSetValue("aqua",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16776960]));
    $impl.FColorLookup.AddOrSetValue("aquamarine",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13959039]));
    $impl.FColorLookup.AddOrSetValue("azure",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16777200]));
    $impl.FColorLookup.AddOrSetValue("beige",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14480885]));
    $impl.FColorLookup.AddOrSetValue("bisque",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[12903679]));
    $impl.FColorLookup.AddOrSetValue("black",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[0]));
    $impl.FColorLookup.AddOrSetValue("blanchedalmond",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13495295]));
    $impl.FColorLookup.AddOrSetValue("blue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16711680]));
    $impl.FColorLookup.AddOrSetValue("blueviolet",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14822282]));
    $impl.FColorLookup.AddOrSetValue("brown",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[2763429]));
    $impl.FColorLookup.AddOrSetValue("burlywood",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8894686]));
    $impl.FColorLookup.AddOrSetValue("cadetblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[10526303]));
    $impl.FColorLookup.AddOrSetValue("chartreuse",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[65407]));
    $impl.FColorLookup.AddOrSetValue("chocolate",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[1993170]));
    $impl.FColorLookup.AddOrSetValue("coral",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[5275647]));
    $impl.FColorLookup.AddOrSetValue("cornflowerblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15570276]));
    $impl.FColorLookup.AddOrSetValue("cornsilk",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14481663]));
    $impl.FColorLookup.AddOrSetValue("crimson",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[3937500]));
    $impl.FColorLookup.AddOrSetValue("cyan",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16776960]));
    $impl.FColorLookup.AddOrSetValue("darkblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9109504]));
    $impl.FColorLookup.AddOrSetValue("darkcyan",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9145088]));
    $impl.FColorLookup.AddOrSetValue("darkgoldenrod",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[755384]));
    $impl.FColorLookup.AddOrSetValue("darkgray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11119017]));
    $impl.FColorLookup.AddOrSetValue("darkgreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[25600]));
    $impl.FColorLookup.AddOrSetValue("darkgrey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11119017]));
    $impl.FColorLookup.AddOrSetValue("darkkhaki",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[7059389]));
    $impl.FColorLookup.AddOrSetValue("darkmagenta",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9109643]));
    $impl.FColorLookup.AddOrSetValue("darkolivegreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[3107669]));
    $impl.FColorLookup.AddOrSetValue("darkorange",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[36095]));
    $impl.FColorLookup.AddOrSetValue("darkorchid",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13382297]));
    $impl.FColorLookup.AddOrSetValue("darkred",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[139]));
    $impl.FColorLookup.AddOrSetValue("darksalmon",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8034025]));
    $impl.FColorLookup.AddOrSetValue("darkseagreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9419919]));
    $impl.FColorLookup.AddOrSetValue("darkslateblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9125192]));
    $impl.FColorLookup.AddOrSetValue("darkslategray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[5197615]));
    $impl.FColorLookup.AddOrSetValue("darkslategrey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[5197615]));
    $impl.FColorLookup.AddOrSetValue("darkturquoise",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13749760]));
    $impl.FColorLookup.AddOrSetValue("darkviolet",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13828244]));
    $impl.FColorLookup.AddOrSetValue("deeppink",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9639167]));
    $impl.FColorLookup.AddOrSetValue("deepskyblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16760576]));
    $impl.FColorLookup.AddOrSetValue("dimgray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[6908265]));
    $impl.FColorLookup.AddOrSetValue("dimgrey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[6908265]));
    $impl.FColorLookup.AddOrSetValue("dodgerblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16748574]));
    $impl.FColorLookup.AddOrSetValue("firebrick",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[2237106]));
    $impl.FColorLookup.AddOrSetValue("floralwhite",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15792895]));
    $impl.FColorLookup.AddOrSetValue("forestgreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[2263842]));
    $impl.FColorLookup.AddOrSetValue("fuchsia",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16711935]));
    $impl.FColorLookup.AddOrSetValue("gainsboro",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14474460]));
    $impl.FColorLookup.AddOrSetValue("ghostwhite",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16775416]));
    $impl.FColorLookup.AddOrSetValue("gold",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[55295]));
    $impl.FColorLookup.AddOrSetValue("goldenrod",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[2139610]));
    $impl.FColorLookup.AddOrSetValue("gray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8421504]));
    $impl.FColorLookup.AddOrSetValue("green",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[32768]));
    $impl.FColorLookup.AddOrSetValue("greenyellow",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[3145645]));
    $impl.FColorLookup.AddOrSetValue("grey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8421504]));
    $impl.FColorLookup.AddOrSetValue("honeydew",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15794160]));
    $impl.FColorLookup.AddOrSetValue("hotpink",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11823615]));
    $impl.FColorLookup.AddOrSetValue("indianred",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[6053069]));
    $impl.FColorLookup.AddOrSetValue("indigo",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8519755]));
    $impl.FColorLookup.AddOrSetValue("ivory",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15794175]));
    $impl.FColorLookup.AddOrSetValue("khaki",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9234160]));
    $impl.FColorLookup.AddOrSetValue("lavender",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16443110]));
    $impl.FColorLookup.AddOrSetValue("lavenderblush",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16118015]));
    $impl.FColorLookup.AddOrSetValue("lawngreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[64636]));
    $impl.FColorLookup.AddOrSetValue("lemonchiffon",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13499135]));
    $impl.FColorLookup.AddOrSetValue("lightblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15128749]));
    $impl.FColorLookup.AddOrSetValue("lightcoral",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8421616]));
    $impl.FColorLookup.AddOrSetValue("lightcyan",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16777184]));
    $impl.FColorLookup.AddOrSetValue("lightgoldenrodyellow",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13826810]));
    $impl.FColorLookup.AddOrSetValue("lightgray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13882323]));
    $impl.FColorLookup.AddOrSetValue("lightgreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9498256]));
    $impl.FColorLookup.AddOrSetValue("lightgrey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13882323]));
    $impl.FColorLookup.AddOrSetValue("lightpink",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[12695295]));
    $impl.FColorLookup.AddOrSetValue("lightsalmon",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8036607]));
    $impl.FColorLookup.AddOrSetValue("lightseagreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11186720]));
    $impl.FColorLookup.AddOrSetValue("lightskyblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16436871]));
    $impl.FColorLookup.AddOrSetValue("lightslategray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[10061943]));
    $impl.FColorLookup.AddOrSetValue("lightslategrey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[10061943]));
    $impl.FColorLookup.AddOrSetValue("lightsteelblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14599344]));
    $impl.FColorLookup.AddOrSetValue("lightyellow",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14745599]));
    $impl.FColorLookup.AddOrSetValue("lime",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[65280]));
    $impl.FColorLookup.AddOrSetValue("limegreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[3329330]));
    $impl.FColorLookup.AddOrSetValue("linen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15134970]));
    $impl.FColorLookup.AddOrSetValue("magenta",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16711935]));
    $impl.FColorLookup.AddOrSetValue("maroon",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[128]));
    $impl.FColorLookup.AddOrSetValue("mediumaquamarine",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11193702]));
    $impl.FColorLookup.AddOrSetValue("mediumblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13434880]));
    $impl.FColorLookup.AddOrSetValue("mediumorchid",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13850042]));
    $impl.FColorLookup.AddOrSetValue("mediumpurple",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14381203]));
    $impl.FColorLookup.AddOrSetValue("mediumseagreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[7451452]));
    $impl.FColorLookup.AddOrSetValue("mediumslateblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15624315]));
    $impl.FColorLookup.AddOrSetValue("mediumspringgreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[10156544]));
    $impl.FColorLookup.AddOrSetValue("mediumturquoise",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13422920]));
    $impl.FColorLookup.AddOrSetValue("mediumvioletred",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8721863]));
    $impl.FColorLookup.AddOrSetValue("midnightblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[7346457]));
    $impl.FColorLookup.AddOrSetValue("mintcream",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16449525]));
    $impl.FColorLookup.AddOrSetValue("mistyrose",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14804223]));
    $impl.FColorLookup.AddOrSetValue("moccasin",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11920639]));
    $impl.FColorLookup.AddOrSetValue("navajowhite",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11394815]));
    $impl.FColorLookup.AddOrSetValue("navy",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8388608]));
    $impl.FColorLookup.AddOrSetValue("oldlace",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15136253]));
    $impl.FColorLookup.AddOrSetValue("olive",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[32896]));
    $impl.FColorLookup.AddOrSetValue("olivedrab",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[2330219]));
    $impl.FColorLookup.AddOrSetValue("orange",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[42495]));
    $impl.FColorLookup.AddOrSetValue("orangered",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[17919]));
    $impl.FColorLookup.AddOrSetValue("orchid",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14053594]));
    $impl.FColorLookup.AddOrSetValue("palegoldenrod",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11200750]));
    $impl.FColorLookup.AddOrSetValue("palegreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[10025880]));
    $impl.FColorLookup.AddOrSetValue("paleturquoise",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15658671]));
    $impl.FColorLookup.AddOrSetValue("palevioletred",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9662683]));
    $impl.FColorLookup.AddOrSetValue("papayawhip",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14020607]));
    $impl.FColorLookup.AddOrSetValue("peachpuff",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[12180223]));
    $impl.FColorLookup.AddOrSetValue("peru",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[4163021]));
    $impl.FColorLookup.AddOrSetValue("pink",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13353215]));
    $impl.FColorLookup.AddOrSetValue("plum",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14524637]));
    $impl.FColorLookup.AddOrSetValue("powderblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15130800]));
    $impl.FColorLookup.AddOrSetValue("purple",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8388736]));
    $impl.FColorLookup.AddOrSetValue("red",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[255]));
    $impl.FColorLookup.AddOrSetValue("rosybrown",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9408444]));
    $impl.FColorLookup.AddOrSetValue("royalblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14772545]));
    $impl.FColorLookup.AddOrSetValue("saddlebrown",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[1262987]));
    $impl.FColorLookup.AddOrSetValue("salmon",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[7504122]));
    $impl.FColorLookup.AddOrSetValue("sandybrown",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[6333684]));
    $impl.FColorLookup.AddOrSetValue("seagreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[5737262]));
    $impl.FColorLookup.AddOrSetValue("seashell",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15660543]));
    $impl.FColorLookup.AddOrSetValue("sienna",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[2970272]));
    $impl.FColorLookup.AddOrSetValue("skyblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15453831]));
    $impl.FColorLookup.AddOrSetValue("slateblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13458026]));
    $impl.FColorLookup.AddOrSetValue("slategray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9470064]));
    $impl.FColorLookup.AddOrSetValue("slategrey",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9470064]));
    $impl.FColorLookup.AddOrSetValue("snow",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16448255]));
    $impl.FColorLookup.AddOrSetValue("springgreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8388352]));
    $impl.FColorLookup.AddOrSetValue("steelblue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11829830]));
    $impl.FColorLookup.AddOrSetValue("violet",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[15631086]));
    $impl.FColorLookup.AddOrSetValue("thistle",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[14204888]));
    $impl.FColorLookup.AddOrSetValue("tan",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[9221330]));
    $impl.FColorLookup.AddOrSetValue("tomato",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[4678655]));
    $impl.FColorLookup.AddOrSetValue("turquoise",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[13688896]));
    $impl.FColorLookup.AddOrSetValue("wheat",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[11788021]));
    $impl.FColorLookup.AddOrSetValue("whitesmoke",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16119285]));
    $impl.FColorLookup.AddOrSetValue("yellowgreen",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[3329434]));
    $impl.FColorLookup.AddOrSetValue("red",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[255]));
    $impl.FColorLookup.AddOrSetValue("black",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[0]));
    $impl.FColorLookup.AddOrSetValue("blue",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16711680]));
    $impl.FColorLookup.AddOrSetValue("green",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[32768]));
    $impl.FColorLookup.AddOrSetValue("aqua",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16776960]));
    $impl.FColorLookup.AddOrSetValue("yellow",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[65535]));
    $impl.FColorLookup.AddOrSetValue("fuchsia",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16711935]));
    $impl.FColorLookup.AddOrSetValue("white",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[16777215]));
    $impl.FColorLookup.AddOrSetValue("lime",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[65280]));
    $impl.FColorLookup.AddOrSetValue("silver",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[12632256]));
    $impl.FColorLookup.AddOrSetValue("gray",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8421504]));
    $impl.FColorLookup.AddOrSetValue("olive",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[32896]));
    $impl.FColorLookup.AddOrSetValue("navy",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8388608]));
    $impl.FColorLookup.AddOrSetValue("purple",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8388736]));
    $impl.FColorLookup.AddOrSetValue("teal",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[8421376]));
    $impl.FColorLookup.AddOrSetValue("orange",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[42495]));
    $impl.FColorLookup.AddOrSetValue("maroon",$mod.TTMSFNCGraphicsColorObject.$create("Create$1",[128]));
  };
},["WEBLib.TMSFNCUtils","SysUtils","Math"]);
rtl.module("WEBLib.TMSFNCStyles",["System","Classes","WEBLib.Graphics","WEBLib.Controls","WEBLib.Forms","WEBLib.TMSFNCTypes","WEBLib.TMSFNCCustomComponent","WEBLib.TMSFNCGraphicsTypes","JS","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  rtl.createInterface(this,"ITMSFNCAdaptToStyle","{3EFF288D-3927-4E86-8E9D-EF684B501C9E}",["GetAdaptToStyle","SetAdaptToStyle"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetAdaptToStyle",1,[],2,rtl.boolean);
    $r.addMethod("SetAdaptToStyle",0,[["Value",rtl.boolean,2]]);
    $r.addProperty("AdaptToStyle",3,rtl.boolean,"GetAdaptToStyle","SetAdaptToStyle",2);
  });
  rtl.createClass(this,"TTMSFNCStyles",pas.System.TObject,function () {
    this.ExtractColor = function (AValue) {
      var $Self = this;
      var Result = 0;
      var s = "";
      var s2 = "";
      var sl = null;
      var p = 0;
      var p2 = 0;
      function ParseValue(AValue) {
        var Result = 0;
        Result = pas.SysUtils.StrToInt(pas.SysUtils.Trim(pas.SysUtils.StringReplace(AValue,"rgb(","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll))));
        return Result;
      };
      Result = -1;
      if (AValue !== "") {
        s = pas.SysUtils.LowerCase(pas.SysUtils.StringReplace(AValue," ","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
        if (pas.System.Pos("linear-gradient",s) === 1) {
          p = pas.System.Pos("rgb",s);
          if (p === 0) p = pas.System.Pos("#",s);
          p2 = pas.System.Pos$1(")",s,p);
          s2 = pas.System.Copy(s,p,(p2 - p) + 1);
          p = pas.System.Pos$1("rgb",s,p2);
          if (p === 0) p = pas.System.Pos("#",s);
          p2 = pas.System.Pos$1(")",s,p);
          Result = this.ExtractColor(s2);
        } else if (pas.System.Pos("rgb",s) === 1) {
          sl = pas.Classes.TStringList.$create("Create$1");
          try {
            sl.SetDelimiter(",");
            sl.SetDelimitedText(s);
            Result = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(ParseValue(sl.Get(0)),ParseValue(sl.Get(1)),ParseValue(sl.Get(2)));
          } finally {
            sl = rtl.freeLoc(sl);
          };
        } else if (pas.System.Pos("#",s) === 1) Result = pas["WEBLib.Graphics"].HexToColor(s);
      };
      return Result;
    };
    this.ExtractColorTo = function (AValue) {
      var $Self = this;
      var Result = 0;
      var s = "";
      var s3 = "";
      var sl = null;
      var p = 0;
      var p2 = 0;
      function ParseValue(AValue) {
        var Result = 0;
        Result = pas.SysUtils.StrToInt(pas.SysUtils.Trim(pas.SysUtils.StringReplace(AValue,"rgb(","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll))));
        return Result;
      };
      Result = -1;
      if (AValue !== "") {
        s = pas.SysUtils.LowerCase(pas.SysUtils.StringReplace(AValue," ","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
        if (pas.System.Pos("linear-gradient",s) === 1) {
          p = pas.System.Pos("rgb",s);
          if (p === 0) p = pas.System.Pos("#",s);
          p2 = pas.System.Pos$1(")",s,p);
          p = pas.System.Pos$1("rgb",s,p2);
          if (p === 0) p = pas.System.Pos("#",s);
          p2 = pas.System.Pos$1(")",s,p);
          s3 = pas.System.Copy(s,p,(p2 - p) + 1);
          Result = this.ExtractColor(s3);
        } else if (pas.System.Pos("rgb",s) === 1) {
          sl = pas.Classes.TStringList.$create("Create$1");
          try {
            sl.SetDelimiter(",");
            sl.SetDelimitedText(s);
            Result = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(ParseValue(sl.Get(0)),ParseValue(sl.Get(1)),ParseValue(sl.Get(2)));
          } finally {
            sl = rtl.freeLoc(sl);
          };
        } else if (pas.System.Pos("#",s) === 1) Result = pas["WEBLib.Graphics"].HexToColor(s);
      };
      return Result;
    };
    this.ExtractFontName = function (AValue) {
      var Result = "";
      Result = AValue;
      return Result;
    };
    this.GetStyleBackgroundFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCGridStyle","background");
      return Result;
    };
    this.GetStyleBackgroundStroke = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCGridStyle","border-color");
      return Result;
    };
    this.GetStyleDefaultButtonFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCButtonStyle","background");
      return Result;
    };
    this.GetStyleDefaultButtonStroke = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCButtonStyle","border-color");
      return Result;
    };
    this.GetStyleEditTextColor = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCEditStyle","--foreground");
      return Result;
    };
    this.GetStyleEditFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCEditStyle","background");
      return Result;
    };
    this.GetStyleEditStroke = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCStyle","border-color");
      return Result;
    };
    this.GetStyleHeaderFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCHeaderItemStyle","background");
      return Result;
    };
    this.GetStyleHeaderStroke = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCHeaderItemStyle","border-color");
      return Result;
    };
    this.GetStyleSelectionFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCGridStyle","--selection");
      return Result;
    };
    this.GetStyleAlternativeSelectionFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCMemoStyle","--selection");
      return Result;
    };
    this.GetStyleAlternativeBackgroundFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCMemoStyle","background");
      return Result;
    };
    this.GetStyleAlternativeBackgroundStroke = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCMemoStyle","border-color");
      return Result;
    };
    this.GetStyleFocusFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCGridStyle","--focus");
      return Result;
    };
    this.GetStyleLineFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCGridStyle","--linefill");
      return Result;
    };
    this.GetStyleTextFont = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCHeaderItemStyle","font-family");
      return Result;
    };
    this.GetStyleTextColor = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCHeaderItemStyle","color");
      return Result;
    };
    this.GetStyleAlternateBackgroundFill = function () {
      var Result = "";
      Result = this.FindCSSStyleProperty(".TMSFNCGridStyle","--alternatingrowbackground");
      return Result;
    };
    this.FindCSSStyleRule = function (ARuleName) {
      var Result = null;
      var s = "";
      var f = "";
      Result = null;
      s = ARuleName;
      f = $mod.CSSStyleFileName;
      for (var i = 0; i < document.styleSheets.length; i++){
        var fn = document.styleSheets[i].href;
        if (fn != null) {
        if (f == fn.substring(fn.lastIndexOf('/')+1)){
          var classes = document.styleSheets[i].rules || document.styleSheets[i].cssRules;
          for (var x = 0; x < classes.length; x++) {
            if (classes[x].selectorText !== undefined) {
              if (classes[x].selectorText.startsWith(s)) {
                  return classes[x];
              }
            }
          }
         }
        }
      };
      return Result;
    };
    this.FindCSSStyleProperty = function (ARuleName, APropertyName) {
      var Result = "";
      var j = null;
      var s = "";
      var v = "";
      Result = "";
      j = this.FindCSSStyleRule(ARuleName);
      if (j != null) {
        s = APropertyName;
        v = j.style.getPropertyValue(s);
        Result = v;
      };
      return Result;
    };
    this.StyleServicesEnabled = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetStyleLineFillColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleLineFill();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleBackgroundFillColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleBackgroundFill();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleBackgroundFillColorTo = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleBackgroundFill();
        if (f !== "") {
          c = this.ExtractColorTo(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleAlternativeBackgroundFillColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleAlternativeBackgroundFill();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleAlternativeBackgroundFillColorTo = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleAlternativeBackgroundFill();
        if (f !== "") {
          c = this.ExtractColorTo(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleBackgroundStrokeColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleBackgroundStroke();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleHeaderFillColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleHeaderFill();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleHeaderFillColorTo = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleHeaderFill();
        if (f !== "") {
          c = this.ExtractColorTo(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleHeaderStrokeColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleHeaderStroke();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleSelectionFillColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleSelectionFill();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleSelectionFillColorTo = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleSelectionFill();
        if (f !== "") {
          c = this.ExtractColorTo(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleTextFontColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleTextColor();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleAlternativeTextFontColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleEditTextColor();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleDefaultButtonFillColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleDefaultButtonFill();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
    this.GetStyleDefaultButtonStrokeColor = function (AColor) {
      var Result = false;
      var f = "";
      var c = 0;
      Result = false;
      if (this.StyleServicesEnabled()) {
        f = this.GetStyleDefaultButtonStroke();
        if (f !== "") {
          c = this.ExtractColor(f);
          AColor.set(c);
          Result = c !== -1;
        };
      };
      return Result;
    };
  });
  this.$rtti.$MethodVar("TTMSFNCStylesManagerCanLoadStyleEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AStyle",rtl.string],["AComponent",pas.Classes.$rtti["TComponent"]],["ACanLoadStyle",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCStylesManagerStyleLoadedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AStyle",rtl.string],["AComponent",pas.Classes.$rtti["TComponent"]]]), methodkind: 0});
  this.$rtti.$DynArray("TTMSFNCStylesManagerFileArray",{eltype: rtl.string});
  this.$rtti.$DynArray("TTMSFNCStylesManagerComponentArray",{eltype: pas.Classes.$rtti["TComponent"]});
  rtl.createInterface(this,"ITMSFNCStylesManager","{88852C7F-B7B5-4FFA-BB47-6D95600CB1F3}",["GetSubComponentArray"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetSubComponentArray",1,[],2,$mod.$rtti["TTMSFNCStylesManagerComponentArray"]);
  });
  rtl.createClass(this,"TTMSFNCStylesManagerOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FAdaptFormColor = false;
    };
    this.Create$1 = function () {
      this.FAdaptFormColor = true;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("AdaptFormColor",0,rtl.boolean,"FAdaptFormColor","FAdaptFormColor",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCStylesManager",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FComponents$1 = [];
      this.FStyle = "";
      this.FStyleResource = "";
      this.FStyleForm = null;
      this.FOnCanLoadStyle = null;
      this.FOnStyleLoaded = null;
      this.FOptions = null;
    };
    this.$final = function () {
      this.FComponents$1 = undefined;
      this.FStyleForm = undefined;
      this.FOnCanLoadStyle = undefined;
      this.FOnStyleLoaded = undefined;
      this.FOptions = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        this.LoadStyleFromFile(this.FStyle);
      };
    };
    this.SetStyleResource = function (Value) {
      if (this.FStyleResource !== Value) {
        this.FStyleResource = Value;
        if (this.FStyleResource !== "") ;
      };
    };
    this.SetOptions = function (Value) {
      this.FOptions.Assign(Value);
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfnccore/components/ttmsfncstyling";
      return Result;
    };
    this.InternalLoadStyleFromJSONValue = function (AJSONValue, AComponents) {
      var $Self = this;
      var ct = "";
      var I = 0;
      var K = 0;
      var f = null;
      var io = null;
      var s = null;
      var st = "";
      var b = false;
      var sm = null;
      var arr = [];
      function IsComponentInArray(AComponent) {
        var Result = false;
        var K = 0;
        if (((rtl.length(AComponents) > 0) && (rtl.length(AComponents) === 0)) || !(rtl.length(AComponents) > 0)) {
          Result = true}
         else {
          Result = false;
          for (var $l = 0, $end = rtl.length(AComponents) - 1; $l <= $end; $l++) {
            K = $l;
            if (AComponents[K] === AComponent) {
              Result = true;
              break;
            };
          };
        };
        return Result;
      };
      function ApplyStyleToComponent(AComponent) {
        var $ir = rtl.createIntfRefs();
        try {
          if (!(AComponent != null)) return;
          if ((AComponent.$classname === ct) && IsComponentInArray(AComponent)) {
            if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(AComponent,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence),{get: function () {
                return io;
              }, set: function (v) {
                io = v;
              }})) {
              st = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValueAsString(AJSONValue);
              b = true;
              $Self.DoCanLoadStyle(st,AComponent,{get: function () {
                  return b;
                }, set: function (v) {
                  b = v;
                }});
              if (b) {
                s = pas.Classes.TStringStream.$create("Create$3",[st,pas.SysUtils.TEncoding.GetANSI(),true]);
                try {
                  io.LoadSettingsFromStream(s);
                } finally {
                  s = rtl.freeLoc(s);
                };
                $Self.DoStyleLoaded(st,AComponent);
              };
            };
          };
        } finally {
          $ir.free();
          rtl._Release(io);
        };
      };
      var $ir = rtl.createIntfRefs();
      try {
        f = this.FStyleForm;
        if (!(f != null)) {
          if (pas["WEBLib.Forms"].TFrame.isPrototypeOf($Self.FOwner)) {
            f = $Self.FOwner}
           else f = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetOwnerForm($Self);
        };
        if (!(f != null)) return;
        if (AJSONValue != null) {
          ct = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONProp(AJSONValue,pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.ClassTypeVariable);
          if (ct !== "") {
            for (var $l = f.GetComponentCount() - 1; $l >= 0; $l--) {
              I = $l;
              ApplyStyleToComponent(f.GetComponent(I));
              if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(f.GetComponent(I),pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCStylesManager),{get: function () {
                  return sm;
                }, set: function (v) {
                  sm = v;
                }})) {
                arr = sm.GetSubComponentArray();
                for (var $l1 = 0, $end = rtl.length(arr) - 1; $l1 <= $end; $l1++) {
                  K = $l1;
                  ApplyStyleToComponent(arr[K]);
                };
              };
            };
          };
        };
      } finally {
        $ir.free();
        rtl._Release(sm);
      };
    };
    this.InternalLoadStyle = function (AValue, AComponents) {
      var v = null;
      var jv = null;
      var va = null;
      var fc = null;
      var fcs = "";
      var ja = null;
      var I = 0;
      var f = null;
      var c = 0;
      v = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ParseJSON(AValue);
      if (v != null) {
        try {
          if (this.FOptions.FAdaptFormColor) {
            fc = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValue(v,"FormColor");
            if (fc != null) {
              fcs = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONProp(v,"FormColor");
              f = this.FStyleForm;
              if (!(f != null)) f = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetOwnerForm(this);
              if (f != null) {
                c = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(fcs);
                f.SetColor(c);
              };
            };
          };
          va = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONValue(v,"Styles");
          if (pas["WEBLib.JSON"].TJSONArray.isPrototypeOf(va)) {
            ja = rtl.as(va,pas["WEBLib.JSON"].TJSONArray);
            for (var $l = 0, $end = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArraySize(ja) - 1; $l <= $end; $l++) {
              I = $l;
              jv = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArrayItem(ja,I);
              if (jv != null) this.InternalLoadStyleFromJSONValue(jv,rtl.arrayRef(AComponents));
            };
          } else {
            if (v != null) this.InternalLoadStyleFromJSONValue(v,rtl.arrayRef(AComponents));
          };
        } finally {
          v = rtl.freeLoc(v);
        };
      };
    };
    this.DoCanLoadStyle = function (AStyle, AComponent, ACanLoadStyle) {
      if (this.FOnCanLoadStyle != null) this.FOnCanLoadStyle(this,AStyle,AComponent,ACanLoadStyle);
    };
    this.DoStyleLoaded = function (AStyle, AComponent) {
      if (this.FOnStyleLoaded != null) this.FOnStyleLoaded(this,AStyle,AComponent);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      this.FOptions = $mod.TTMSFNCStylesManagerOptions.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FOptions");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.LoadStyleFromText = function (AText) {
      var a = [];
      a = rtl.arraySetLength(a,null,0);
      this.InternalLoadStyle(AText,rtl.arrayRef(a));
    };
    this.LoadStyleFromStream = function (AStream) {
      var a = [];
      a = rtl.arraySetLength(a,null,0);
      this.LoadStyleFromStream$1(AStream,rtl.arrayRef(a));
    };
    this.LoadStyleFromFile = function (AFile) {
      var a = [];
      a = rtl.arraySetLength(a,null,0);
      this.LoadStyleFromFile$1(AFile,rtl.arrayRef(a));
    };
    this.LoadStyleFromText$1 = function (AText, AComponents) {
      this.InternalLoadStyle(AText,rtl.arrayRef(AComponents));
    };
    this.LoadStyleFromStream$1 = function (AStream, AComponents) {
      var ss = null;
      ss = pas.Classes.TStringStream.$create("Create$1");
      try {
        ss.LoadFromStream(AStream);
        this.InternalLoadStyle(ss.GetDataString(),rtl.arrayRef(AComponents));
      } finally {
        ss = rtl.freeLoc(ss);
      };
    };
    this.LoadStyleFromFile$1 = function (AFile, AComponents) {
      var $Self = this;
      var ss = null;
      ss = pas.Classes.TStringStream.$create("Create$1");
      try {
        this.FComponents$1 = rtl.arrayRef(AComponents);
        ss.LoadFromFile(AFile,function () {
          $Self.InternalLoadStyle(ss.GetDataString(),rtl.arrayRef(AComponents));
          ss = rtl.freeLoc(ss);
        },null);
      } finally {
      };
    };
    this.LoadStyleFromURL = function (AURL, AComponents) {
      this.LoadStyleFromFile$1(AURL,rtl.arrayRef(AComponents));
    };
    this.LoadStyleFromURL$1 = function (AURL) {
      var a = [];
      a = rtl.arraySetLength(a,null,0);
      this.LoadStyleFromFile$1(AURL,rtl.arrayRef(a));
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Options",2,$mod.$rtti["TTMSFNCStylesManagerOptions"],"FOptions","SetOptions");
    $r.addProperty("Style",2,rtl.string,"FStyle","SetStyle");
    $r.addProperty("StyleResource",2,rtl.string,"FStyleResource","SetStyleResource");
    $r.addProperty("OnCanLoadStyle",0,$mod.$rtti["TTMSFNCStylesManagerCanLoadStyleEvent"],"FOnCanLoadStyle","FOnCanLoadStyle");
    $r.addProperty("OnStyleLoaded",0,$mod.$rtti["TTMSFNCStylesManagerStyleLoadedEvent"],"FOnStyleLoaded","FOnStyleLoaded");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.CSSStyleFileName = "";
},["WEBLib.TMSFNCUtils","SysUtils","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCGraphics"]);
rtl.module("WEBLib.DesignIntf",["System","Classes","Web","JS","TypInfo","WEBLib.Forms","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Interface("IMenuItem");
  rtl.createInterface(this,"IMenuItems","{1F683FB4-D9CF-4CC7-934D-99A300314500}",["GetItem","SameAs","Find","FindByName","Count","Clear","AddItem","InsertItem","InsertItem$1","AddLine","InsertLine","InsertLine$1"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetItem",1,[["Index",rtl.longint]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("SameAs",1,[["AItem",pas.System.$rtti["IUnknown"],2]],2,rtl.boolean);
    $r.addMethod("Find",1,[["ACaption",pas.System.$rtti["WideString"],2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("FindByName",1,[["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("Count",1,[],2,rtl.longint);
    $r.addProperty("Items",1,$mod.$rtti["IMenuItem"],"GetItem","",2);
    $r.addMethod("Clear",0,[]);
    $r.addMethod("AddItem",1,[["ACaption",pas.System.$rtti["WideString"],2],["AShortCut",pas["WEBLib.Menus"].$rtti["TShortCut"]],["AChecked",rtl.boolean],["AEnabled",rtl.boolean],["AOnClick",pas.Classes.$rtti["TNotifyEvent"]],["hCtx",pas["WEBLib.Menus"].$rtti["THelpContext"]],["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("InsertItem",1,[["ACaption",pas.System.$rtti["WideString"],2],["AShortCut",pas["WEBLib.Menus"].$rtti["TShortCut"]],["AChecked",rtl.boolean],["AEnabled",rtl.boolean],["AOnClick",pas.Classes.$rtti["TNotifyEvent"]],["hCtx",pas["WEBLib.Menus"].$rtti["THelpContext"]],["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("InsertItem$1",1,[["Index",rtl.longint],["ACaption",pas.System.$rtti["WideString"],2],["AShortCut",pas["WEBLib.Menus"].$rtti["TShortCut"]],["AChecked",rtl.boolean],["AEnabled",rtl.boolean],["AOnClick",pas.Classes.$rtti["TNotifyEvent"]],["hCtx",pas["WEBLib.Menus"].$rtti["THelpContext"]],["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("AddLine",1,[["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("InsertLine",1,[["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
    $r.addMethod("InsertLine$1",1,[["Index",rtl.longint],["AName",rtl.string,2]],2,$mod.$rtti["IMenuItem"]);
  });
  rtl.createInterface(this,"IMenu","{C24B5609-AD3A-4246-8FDC-65B57EFA75AA}",["Items"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Items",1,[],2,$mod.$rtti["IMenuItems"]);
  });
  rtl.createInterface(this,"IMainMenu","{4605DA9D-79C3-4969-8DC4-FAD9B96D287B}",[],this.IMenu,function () {
  });
  rtl.createInterface(this,"IPopupMenu","{16ABD57D-6CC6-4004-B4FD-53C46429894F}",["Popup","PopupComponent"],this.IMenu,function () {
    var $r = this.$rtti;
    $r.addMethod("Popup",0,[["X",rtl.longint],["Y",rtl.longint]]);
    $r.addMethod("PopupComponent",1,[],2,pas.Classes.$rtti["TComponent"]);
  });
  rtl.createInterface(this,"IMenuItem","{FEA8F8DA-E0D9-4DB3-B7B7-C1C38394BA17}",["GetCaption","SetCaption","GetChecked","SetChecked","GetEnabled","SetEnabled","GetGroupIndex","SetGroupIndex","GetHelpContext","SetHelpContext","GetHint","SetHint","GetRadioItem","SetRadioItem","GetShortCut","SetShortCut","GetTag","SetTag","GetVisible","SetVisible","Name","MenuIndex","Parent","HasParent","IsLine"],this.IMenuItems,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCaption",1,[],2,pas.System.$rtti["WideString"]);
    $r.addMethod("SetCaption",0,[["ACaption",pas.System.$rtti["WideString"],2]]);
    $r.addMethod("GetChecked",1,[],2,rtl.boolean);
    $r.addMethod("SetChecked",0,[["AChecked",rtl.boolean]]);
    $r.addMethod("GetEnabled",1,[],2,rtl.boolean);
    $r.addMethod("SetEnabled",0,[["AEnabled",rtl.boolean]]);
    $r.addMethod("GetGroupIndex",1,[],2,rtl.byte);
    $r.addMethod("SetGroupIndex",0,[["AGroupIndex",rtl.byte]]);
    $r.addMethod("GetHelpContext",1,[],2,pas["WEBLib.Menus"].$rtti["THelpContext"]);
    $r.addMethod("SetHelpContext",0,[["AHelpContext",pas["WEBLib.Menus"].$rtti["THelpContext"]]]);
    $r.addMethod("GetHint",1,[],2,rtl.string);
    $r.addMethod("SetHint",0,[["AHint",rtl.string,2]]);
    $r.addMethod("GetRadioItem",1,[],2,rtl.boolean);
    $r.addMethod("SetRadioItem",0,[["ARadioItem",rtl.boolean]]);
    $r.addMethod("GetShortCut",1,[],2,pas["WEBLib.Menus"].$rtti["TShortCut"]);
    $r.addMethod("SetShortCut",0,[["AShortCut",pas["WEBLib.Menus"].$rtti["TShortCut"]]]);
    $r.addMethod("GetTag",1,[],2,rtl.longint);
    $r.addMethod("SetTag",0,[["AValue",rtl.longint]]);
    $r.addMethod("GetVisible",1,[],2,rtl.boolean);
    $r.addMethod("SetVisible",0,[["AVisible",rtl.boolean]]);
    $r.addMethod("Name",1,[],2,pas.Classes.$rtti["TComponentName"]);
    $r.addMethod("MenuIndex",1,[],2,rtl.longint);
    $r.addMethod("Parent",1,[],2,$r);
    $r.addMethod("HasParent",1,[],2,rtl.boolean);
    $r.addMethod("IsLine",1,[],2,rtl.boolean);
    $r.addProperty("Caption",3,pas.System.$rtti["WideString"],"GetCaption","SetCaption",2);
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked",2);
    $r.addProperty("Enabled",3,rtl.boolean,"GetEnabled","SetEnabled",2);
    $r.addProperty("GroupIndex",3,rtl.byte,"GetGroupIndex","SetGroupIndex",2);
    $r.addProperty("HelpContext",3,pas["WEBLib.Menus"].$rtti["THelpContext"],"GetHelpContext","SetHelpContext",2);
    $r.addProperty("Hint",3,rtl.string,"GetHint","SetHint",2);
    $r.addProperty("RadioItem",3,rtl.boolean,"GetRadioItem","SetRadioItem",2);
    $r.addProperty("ShortCut",3,pas["WEBLib.Menus"].$rtti["TShortCut"],"GetShortCut","SetShortCut",2);
    $r.addProperty("Tag",3,rtl.longint,"GetTag","SetTag",2);
    $r.addProperty("Visible",3,rtl.boolean,"GetVisible","SetVisible",2);
  });
  rtl.createInterface(this,"IMenuItem2","{7BB2E6D5-A47D-4ECD-B891-29ECB256199F}",["Click"],this.IMenuItem,function () {
    var $r = this.$rtti;
    $r.addMethod("Click",0,[]);
  });
  this.$rtti.$MethodVar("TLoadJavaScriptCallBack",{procsig: rtl.newTIProcSig([["AJavaScriptFile",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TErrorJavaScriptCallBack",{procsig: rtl.newTIProcSig([["AError",pas.Web.$rtti["TJSErrorEvent"]]]), methodkind: 0});
  this.$rtti.$ClassRef("TComponentClass",{instancetype: pas.Classes.$rtti["TComponent"]});
  this.$rtti.$DynArray("TIconArray",{eltype: rtl.string});
  this.$rtti.$DynArray("TComponentClassArray",{eltype: this.$rtti["TComponentClass"]});
  rtl.createClass(this,"TRegisteredComponent",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FClass = null;
      this.FIcon = "";
      this.FPage = "";
    };
    this.$final = function () {
      this.FClass = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (APage, AClass, AIcon) {
      this.FPage = APage;
      this.FClass = AClass;
      this.FIcon = AIcon;
      return this;
    };
  });
  rtl.createInterface(this,"IDesignerSelections","{2A041D7A-7175-3AD1-B2C4-57B3F6EDFAF4}",["Add","Get","GetCount"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Add",1,[["Item",pas.Classes.$rtti["TPersistent"],2]],2,rtl.longint);
    $r.addMethod("Get",1,[["Index",rtl.longint]],2,pas.Classes.$rtti["TPersistent"]);
    $r.addMethod("GetCount",1,[],2,rtl.longint);
    $r.addProperty("Count",1,rtl.longint,"GetCount","",2);
    $r.addProperty("Items",1,pas.Classes.$rtti["TPersistent"],"Get","",2);
  });
  this.$rtti.$ProcVar("TGetStrProc",{procsig: rtl.newTIProcSig([["AUnitName",rtl.string]])});
  rtl.createClass(this,"TSelectionEditor",pas.System.TObject,function () {
    this.RequiresUnits = function (Proc) {
    };
  });
  this.$rtti.$ClassRef("TSelectionEditorClass",{instancetype: this.$rtti["TSelectionEditor"]});
  rtl.createClass(this,"TRegisteredSelectionEditor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FClass = null;
      this.FEditor = null;
    };
    this.$final = function () {
      this.FClass = undefined;
      this.FEditor = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AClass, AEditorClass) {
      pas.System.TObject.Create.call(this);
      this.FClass = AClass;
      this.FEditor = AEditorClass;
      return this;
    };
  });
  rtl.createClass(this,"TLibraryRequirementsEditor",pas.System.TObject,function () {
    this.RequiresLibraries = function (Proc) {
    };
  });
  this.$rtti.$ClassRef("TLibraryRequirementsEditorClass",{instancetype: this.$rtti["TLibraryRequirementsEditor"]});
  rtl.createClass(this,"TRegisteredLibraryRequirementsEditor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FClass = null;
      this.FEditor = null;
    };
    this.$final = function () {
      this.FClass = undefined;
      this.FEditor = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AClass, AEditorClass) {
      pas.System.TObject.Create.call(this);
      this.FClass = AClass;
      this.FEditor = AEditorClass;
      return this;
    };
  });
  this.TPropertyAttribute = {"0": "paDialog", paDialog: 0, "1": "paValueList", paValueList: 1, "2": "paSortList", paSortList: 2, "3": "paValueEditable", paValueEditable: 3, "4": "paSubProperties", paSubProperties: 4};
  this.$rtti.$Enum("TPropertyAttribute",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TPropertyAttribute});
  this.$rtti.$Set("TPropertyAttributes",{comptype: this.$rtti["TPropertyAttribute"]});
  rtl.createClass(this,"TPropertyEditor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FComponent = null;
      this.FPropertyName = "";
      this.FPropertyInfo = null;
      this.FResultProc = null;
    };
    this.$final = function () {
      this.FComponent = undefined;
      this.FPropertyInfo = undefined;
      this.FResultProc = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = this.GetStrValueAt(0);
      return Result;
    };
    this.GetStrValueAt = function (Index) {
      var Result = "";
      Result = pas.TypInfo.GetStrProp$1(this.FComponent,this.FPropertyInfo);
      return Result;
    };
    this.SetStrValue = function (Value) {
      pas.TypInfo.SetStrProp$1(this.FComponent,this.FPropertyInfo,Value);
    };
    this.Modified = function () {
    };
    this.Create$1 = function () {
      this.FPropertyName = "";
      this.FPropertyInfo = null;
      return this;
    };
    this.Edit = function () {
      this.Edit$1(null);
    };
    this.Edit$1 = function (AProc) {
      this.FResultProc = AProc;
    };
    this.GetAttributes = function () {
      var Result = {};
      Result = rtl.createSet($mod.TPropertyAttribute.paDialog);
      return Result;
    };
    this.GetValue = function () {
      var Result = "";
      Result = "(Unknown)";
      return Result;
    };
    this.GetComponent = function () {
      var Result = null;
      Result = this.FComponent;
      return Result;
    };
    this.GetComponent$1 = function (Index) {
      var Result = null;
      Result = this.FComponent;
      return Result;
    };
    this.GetValues = function (Proc) {
    };
    this.SetValue = function (Value) {
    };
    this.GetOrdValue = function () {
      var Result = 0;
      Result = this.GetOrdValueAt(0);
      return Result;
    };
    this.GetOrdValueAt = function (Index) {
      var Result = 0;
      Result = pas.TypInfo.GetOrdProp$1(this.FComponent,this.FPropertyInfo);
      return Result;
    };
    this.GetObjectValue = function () {
      var Result = null;
      Result = this.GetObjectValueAt(0);
      return Result;
    };
    this.GetObjectValueAt = function (Index) {
      var Result = null;
      Result = pas.TypInfo.GetObjectProp$2(this.FComponent,this.FPropertyInfo);
      return Result;
    };
    this.SetOrdValue = function (Value) {
      pas.TypInfo.SetOrdProp$1(this.FComponent,this.FPropertyInfo,Value);
    };
  });
  rtl.createClass(this,"TStringProperty",this.TPropertyEditor,function () {
    this.GetValue = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
    this.SetValue = function (Value) {
      this.SetStrValue(Value);
    };
  });
  rtl.createClass(this,"TIntegerProperty",this.TPropertyEditor,function () {
  });
  rtl.createClass(this,"TClassProperty",this.TPropertyEditor,function () {
  });
  this.$rtti.$ClassRef("TPropertyEditorClass",{instancetype: this.$rtti["TPropertyEditor"]});
  rtl.createClass(this,"TRegisteredPropertyEditor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FClass = null;
      this.FPropertyName = "";
      this.FPropertyType = null;
      this.FEditor = null;
    };
    this.$final = function () {
      this.FClass = undefined;
      this.FEditor = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (APropertyType, AClass, AProperty, AEditor) {
      pas.System.TObject.Create.call(this);
      this.FClass = AClass;
      this.FPropertyName = AProperty;
      this.FPropertyType = APropertyType;
      this.FEditor = AEditor;
      return this;
    };
  });
  rtl.createClass(this,"TRegisteredIgnoredProperty",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FClass = null;
      this.FPropertyName = "";
    };
    this.$final = function () {
      this.FClass = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AClass, AProperty) {
      pas.System.TObject.Create.call(this);
      this.FClass = AClass;
      this.FPropertyName = AProperty;
      return this;
    };
  });
  rtl.createClass(this,"TComponentEditor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FComponent = null;
      this.FResultProc = null;
      this.FExecResultProc = null;
    };
    this.$final = function () {
      this.FComponent = undefined;
      this.FResultProc = undefined;
      this.FExecResultProc = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Edit = function () {
      this.Edit$1(null);
    };
    this.Edit$1 = function (AProc) {
      this.FResultProc = AProc;
    };
    this.ExecuteVerb = function (Index) {
      this.ExecuteVerb$1(Index,null);
    };
    this.ExecuteVerb$1 = function (Index, AProc) {
      this.FExecResultProc = AProc;
    };
    this.PrepareItem = function (Index, AItem) {
    };
    this.GetVerb = function (Index) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetVerbCount = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetComponent = function () {
      var Result = null;
      Result = this.FComponent;
      return Result;
    };
    this.GetComponent$1 = function (Index) {
      var Result = null;
      Result = this.FComponent;
      return Result;
    };
    this.GetDefaultProperty = function () {
      var Result = "";
      Result = "";
      return Result;
    };
  });
  this.$rtti.$ClassRef("TComponentEditorClass",{instancetype: this.$rtti["TComponentEditor"]});
  rtl.createClass(this,"TRegisteredComponentEditor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FClass = null;
      this.FEditor = null;
    };
    this.$final = function () {
      this.FClass = undefined;
      this.FEditor = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AClass, AEditorClass) {
      pas.System.TObject.Create.call(this);
      this.FClass = AClass;
      this.FEditor = AEditorClass;
      return this;
    };
  });
  rtl.createClass(this,"TDefaultEditor",this.TComponentEditor,function () {
  });
  this.$rtti.$ProcVar("TIdentToInt",{procsig: rtl.newTIProcSig([["Ident",rtl.string,2],["Int",rtl.longint,1]],rtl.boolean)});
  this.$rtti.$ProcVar("TIntToIdent",{procsig: rtl.newTIProcSig([["Int",rtl.longint],["Ident",rtl.string,1]],rtl.boolean)});
  rtl.createClass(this,"TRegisteredIdentToInt",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FIdentToInt = null;
      this.FIntToIdent = null;
      this.FPropertyType = null;
    };
    this.$final = function () {
      this.FIdentToInt = undefined;
      this.FIntToIdent = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (APropertyType, AIdentToInt, AIntToIdent) {
      this.FPropertyType = APropertyType;
      this.FIdentToInt = AIdentToInt;
      this.FIntToIdent = AIntToIdent;
      return this;
    };
  });
  var cPNGExt = "_PNG";
  this.RegisterComponents = function (Page, ComponentClasses, Icons) {
    var I = 0;
    var c = null;
    var ic = "";
    for (var $l = 0, $end = rtl.length(ComponentClasses) - 1; $l <= $end; $l++) {
      I = $l;
      c = ComponentClasses[I];
      if (rtl.length(Icons) > 0) {
        ic = Icons[I]}
       else ic = "";
      if (ic === "") ic = $impl.TIconDataDict.Find(c.$classname + cPNGExt);
      if (ic === "") ic = $impl.TIconDataDict.Find(c.$classname);
      $impl.RegisteredComponentList[c.$classname] = $mod.TRegisteredComponent.$create("Create$1",[Page,c,ic]);
    };
  };
  this.RegisterSelectionEditor = function (AClass, AEditorClass) {
    $impl.RegisteredSelectionEditorList[AClass.$classname] = $mod.TRegisteredSelectionEditor.$create("Create$1",[AClass,AEditorClass]);
  };
  this.RegisterPropertyEditor = function (PropertyType, ComponentClass, PropertyName, EditorClass) {
    var LKey = "";
    var LType = "";
    var LClass = "";
    LType = "";
    if (PropertyType != null) LType = PropertyType.name;
    LClass = "";
    if (ComponentClass != null) LClass = ComponentClass.$classname;
    LKey = LType + "_" + LClass + "_" + PropertyName;
    $impl.RegisteredPropertyEditorList[LKey] = $mod.TRegisteredPropertyEditor.$create("Create$1",[PropertyType,ComponentClass,PropertyName,EditorClass]);
  };
  this.RegisterComponentEditor = function (AClass, ComponentEditor) {
    $impl.RegisteredComponentEditorList[AClass.$classname] = $mod.TRegisteredComponentEditor.$create("Create$1",[AClass,ComponentEditor]);
  };
  this.RegisterIgnoredProperty = function (ComponentClass, PropertyName) {
    var LKey = "";
    var LClass = "";
    LClass = "";
    if (ComponentClass != null) LClass = ComponentClass.$classname;
    LKey = LClass + "_" + PropertyName;
    $impl.RegisteredIgnoredPropertyList[LKey] = $mod.TRegisteredIgnoredProperty.$create("Create$1",[ComponentClass,PropertyName]);
  };
  this.RegisterLibraryRequirementsEditor = function (AClass, AEditorClass) {
    $impl.RegisteredLibraryRequirementsEditorList[AClass.$classname] = $mod.TRegisteredLibraryRequirementsEditor.$create("Create$1",[AClass,AEditorClass]);
  };
  this.RegisterIcon = function (AComponentName, AIconName, AUnitName) {
    $impl.TIconDataDict.Add(AComponentName,AIconName,AUnitName);
  };
  this.GetRegisteredComponents = function (List) {
    var a = Object.keys($impl.RegisteredComponentList).map(function(key) {
          return [$impl.RegisteredComponentList[key]];
        });
    
        a.forEach(function(element) {
          List.Add(element[0]);
        });
  };
  this.GetRegisteredPages = function (List) {
    var a = Object.keys($impl.RegisteredComponentList).map(function(key) {
          return [$impl.RegisteredComponentList[key]];
        });
    
        a.forEach(function(element) {
          var p = element[0].FPage;
          if (List.IndexOf(p) == -1) {
            List.Add(element[0].FPage);
          }
        });
  };
  this.GetSelectionEditors = function (List) {
    var a = Object.keys($impl.RegisteredSelectionEditorList).map(function(key) {
          return [$impl.RegisteredSelectionEditorList[key]];
        });
    
        a.forEach(function(element) {
          List.Add(element[0]);
        });
  };
  this.LoadComponentFromJavaScript = function (JavaScriptFile, CallBack, ErrorCallBack) {
    var self = this;
        var JavaScript = {
          loadcomponent: function(src) {
            var n = src.substr(0, src.lastIndexOf("."));
            if (!pas[n]) {
              var script = document.createElement('script'), loaded;
              script.async = false;
              script.setAttribute('src', src);
              script.onerror = function(e){
                if (ErrorCallBack != null)
                {
                  ErrorCallBack(e);
                }
              }
              script.onreadystatechange = script.onload = function() {
                if (!loaded) {
                  if (CallBack != null)
                    CallBack(src);
                }
                loaded = true;
              };
              document.getElementsByTagName('head')[0].appendChild(script);
            }
          }
        };
    
        JavaScript.loadcomponent(JavaScriptFile);
  };
  this.InitializeComponentFromJavaScript = function (JavaScriptFile) {
    var src = "";
    if ($mod.IsComponentFromJavaScriptLoaded(JavaScriptFile)) {
      src = JavaScriptFile;
      var n = src.substr(0, src.lastIndexOf("."))
      var module = pas[n];
      rtl.loadintf(module);
      rtl.loadimpl(module);
    };
  };
  this.GetRegisteredComponentClass = function (ComponentClassName) {
    var Result = null;
    var r = null;
    Result = null;
    r = $mod.GetRegisteredComponent(ComponentClassName);
    if (r != null) Result = r.FClass;
    return Result;
  };
  this.GetRegisteredComponent = function (ComponentClassName) {
    var Result = null;
    var res = null;
    Result = null;
    if (ComponentClassName === "") return Result;
    res = null;
    var a = Object.keys($impl.RegisteredComponentList).map(function(key) {
          return [$impl.RegisteredComponentList[key]];
        });
    
        for (let el of a) {
          if (el[0].FClass.$classname.toLowerCase() == ComponentClassName.toLowerCase()) {
            res = el[0];
            break; }
        };
    Result = res;
    return Result;
  };
  this.GetRegisteredSelectionEditor = function (ComponentClassName) {
    var Result = null;
    var cn = "";
    var c = null;
    Result = null;
    if (ComponentClassName === "") return Result;
    c = pas.Classes.GetClass(ComponentClassName);
    if (!(c != null)) {
      c = $mod.GetRegisteredComponentClass(ComponentClassName);
      if (!(c != null)) return null;
    };
    do {
      cn = c.$classname;
      Result = rtl.getObject($impl.RegisteredSelectionEditorList[cn]);
      if (Result != null) return Result;
      c = c.$ancestor;
    } while (c != null);
    return Result;
  };
  this.GetRegisteredLibraryRequirementsEditor = function (ComponentClassName) {
    var Result = null;
    var cn = "";
    var c = null;
    Result = null;
    if (ComponentClassName === "") return Result;
    c = pas.Classes.GetClass(ComponentClassName);
    if (!(c != null)) return null;
    do {
      cn = c.$classname;
      Result = rtl.getObject($impl.RegisteredLibraryRequirementsEditorList[cn]);
      if (Result != null) return Result;
      c = c.$ancestor;
    } while (c != null);
    return Result;
  };
  this.GetRegisteredPropertyEditor = function (PropertyType, AClass, AProperty) {
    var Result = null;
    var LKey = "";
    var LType = "";
    var LPropEditor = null;
    var LList = null;
    var i = 0;
    var c = null;
    Result = null;
    LType = PropertyType.name;
    LKey = LType + "__";
    LPropEditor = rtl.getObject($impl.RegisteredPropertyEditorList[LKey]);
    if (LPropEditor != null) Result = LPropEditor;
    if (!(Result != null) && (AClass != null) && (AProperty !== "")) {
      c = AClass;
      do {
        LKey = LType + "_" + c.$classname + "_" + AProperty;
        LPropEditor = rtl.getObject($impl.RegisteredPropertyEditorList[LKey]);
        if (LPropEditor != null) {
          Result = LPropEditor;
          break;
        };
        c = c.$ancestor;
      } while (c != null);
    };
    if (!(Result != null)) {
      LList = pas.Classes.TList.$create("Create$1");
      $impl.GetPropertyEditors(LList);
      for (var $l = 0, $end = LList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        LPropEditor = rtl.getObject(LList.Get(i));
        if (LPropEditor.FPropertyType === PropertyType) {
          if ((LPropEditor.FPropertyName === "") || (LPropEditor.FPropertyName === AProperty)) {
            if (!(LPropEditor.FClass != null)) {
              Result = LPropEditor;
              break;
            } else if (AClass != null) {
              c = AClass;
              do {
                if (LPropEditor.FClass.$classname === c.$classname) {
                  Result = LPropEditor;
                  break;
                };
                c = c.$ancestor;
              } while (c != null);
              if (Result != null) break;
            };
          };
        };
      };
      LList = rtl.freeLoc(LList);
    };
    return Result;
  };
  this.GetRegisteredComponentEditor = function (AClass) {
    var Result = null;
    var cn = "";
    var c = null;
    Result = null;
    if (!(AClass != null)) return Result;
    c = AClass;
    if (!(c != null)) return null;
    do {
      cn = c.$classname;
      Result = rtl.getObject($impl.RegisteredComponentEditorList[cn]);
      if (Result != null) return Result;
      c = c.$ancestor;
    } while (c != null);
    return Result;
  };
  this.IsComponentFromJavaScriptLoaded = function (JavaScriptFile) {
    var Result = false;
    var src = "";
    src = JavaScriptFile;
    var n = src.substr(0, src.lastIndexOf("."))
    return (pas[n]);
    return Result;
  };
  this.IsIgnoredProperty = function (AClass, AProperty) {
    var Result = false;
    var LKey = "";
    var LIgnoredProperty = null;
    Result = false;
    if (!(AClass != null)) {
      LKey = "_" + AProperty;
      LIgnoredProperty = rtl.getObject($impl.RegisteredIgnoredPropertyList[LKey]);
      if (LIgnoredProperty != null) {
        Result = true;
      };
    } else if ((AClass != null) && (AProperty !== "")) {
      LKey = AClass.$classname + "_" + AProperty;
      LIgnoredProperty = rtl.getObject($impl.RegisteredIgnoredPropertyList[LKey]);
      if (LIgnoredProperty != null) {
        Result = true;
      } else {
        LKey = "_" + AProperty;
        LIgnoredProperty = rtl.getObject($impl.RegisteredIgnoredPropertyList[LKey]);
        if (LIgnoredProperty != null) {
          Result = true;
        };
      };
    };
    return Result;
  };
  this.RegisterIntegerConsts = function (IntegerPropertyType, AIdentToInt, AIntToIdent) {
    var LKey = "";
    LKey = IntegerPropertyType.name;
    $impl.RegisteredIdentToIntList[LKey] = $mod.TRegisteredIdentToInt.$create("Create$1",[IntegerPropertyType,AIdentToInt,AIntToIdent]);
  };
  this.GetRegisteredIdentToInt = function (IntegerPropertyType) {
    var Result = null;
    var ri = null;
    var LKey = "";
    Result = null;
    LKey = IntegerPropertyType.name;
    ri = rtl.getObject($impl.RegisteredIdentToIntList[LKey]);
    if (ri != null) Result = ri.FIdentToInt;
    return Result;
  };
  this.GetRegisteredIntToIdent = function (IntegerPropertyType) {
    var Result = null;
    var ri = null;
    var LKey = "";
    Result = null;
    LKey = IntegerPropertyType.name;
    ri = rtl.getObject($impl.RegisteredIdentToIntList[LKey]);
    if (ri != null) Result = ri.FIntToIdent;
    return Result;
  };
  $mod.$implcode = function () {
    rtl.createClass($impl,"TIconData",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FNameConst = "";
        this.FNameUnit = "";
      };
    });
    rtl.createClass($impl,"TIconDataDict",pas.System.TObject,function () {
      this.FDict = null;
      this.Add = function (AComponentName, AConstantName, AUnitName) {
        var lData = null;
        if (this.FDict === null) $impl.TIconDataDict.FDict = pas["Generics.Collections"].TObjectDictionary$$$G$$generics$collections$$String$$TIconData.$create("Create$5",[rtl.createSet(pas["Generics.Collections"].TDictionaryOwnership.doOwnsValues)]);
        if (this.FDict.TryGetValue(pas.SysUtils.TStringHelper.ToUpper.call({get: function () {
            return AComponentName;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }}),{get: function () {
            return lData;
          }, set: function (v) {
            lData = v;
          }})) return;
        lData = $impl.TIconData.$create("Create");
        try {
          lData.FNameConst = AConstantName;
          lData.FNameUnit = AUnitName;
          if (pas.SysUtils.TStringHelper.IsEmpty.call({p: lData, get: function () {
              return this.p.FNameConst;
            }, set: function (v) {
              this.p.FNameConst = v;
            }})) ;
          if (pas.SysUtils.TStringHelper.IsEmpty.call({p: lData, get: function () {
              return this.p.FNameUnit;
            }, set: function (v) {
              this.p.FNameUnit = v;
            }})) ;
          this.FDict.Add(pas.SysUtils.TStringHelper.ToUpper.call({get: function () {
              return AComponentName;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }}),lData);
          lData = null;
        } finally {
          lData = rtl.freeLoc(lData);
        };
      };
      this.Find = function (AComponentName) {
        var Result = "";
        var lData = null;
        Result = pas.SysUtils.TStringHelper.Empty;
        if ((this.FDict === null) || !this.FDict.TryGetValue(pas.SysUtils.TStringHelper.ToUpper.call({get: function () {
            return AComponentName;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }}),{get: function () {
            return lData;
          }, set: function (v) {
            lData = v;
          }})) return Result;
        Result = pas[lData.FNameUnit][lData.FNameConst];
        return Result;
      };
    });
    $impl.RegisteredComponentList = null;
    $impl.RegisteredSelectionEditorList = null;
    $impl.RegisteredPropertyEditorList = null;
    $impl.RegisteredIgnoredPropertyList = null;
    $impl.RegisteredLibraryRequirementsEditorList = null;
    $impl.RegisteredComponentEditorList = null;
    $impl.RegisteredIdentToIntList = null;
    $impl.GetPropertyEditors = function (List) {
      var a = Object.keys($impl.RegisteredPropertyEditorList).map(function(key) {
            return [$impl.RegisteredPropertyEditorList[key]];
          });
      
          a.forEach(function(element) {
            List.Add(element[0]);
          });
    };
  };
  $mod.$init = function () {
    (function () {
      rtl.free($impl.TIconDataDict,"FDict");
    })();
    $impl.RegisteredComponentList = Object.create(null);
    $impl.RegisteredSelectionEditorList = Object.create(null);
    $impl.RegisteredPropertyEditorList = Object.create(null);
    $impl.RegisteredIgnoredPropertyList = Object.create(null);
    $impl.RegisteredLibraryRequirementsEditorList = Object.create(null);
    $impl.RegisteredComponentEditorList = Object.create(null);
    $impl.RegisteredIdentToIntList = Object.create(null);
  };
},["SysUtils","Generics.Collections"]);
rtl.module("WEBLib.TMSFNCCustomComponent",["System","Classes","WEBLib.TMSFNCTypes","WEBLib.TMSFNCPersistence","WEBLib.Controls","TypInfo"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$MethodVar("TTMSFNCCustomComponentCanSavePropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]],["ACanSave",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomComponentCanLoadPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]],["ACanLoad",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCNameLabel",pas["WEBLib.Controls"].TCustomControl,function () {
    this.GetText = function () {
      var Result = "";
      Result = "";
      if (this.FOwner != null) Result = this.FOwner.FName;
      return Result;
    };
    this.Paint = function () {
      var g = null;
      pas["WEBLib.Controls"].TCustomControl.Paint.call(this);
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[this.GetCanvas(),false]);
      try {
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(0);
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth(),this.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        if ((this.FOwner != null) && $mod.TTMSFNCCustomComponent.isPrototypeOf(this.FOwner)) g.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(g.FFont.FHeight,rtl.as(this.FOwner,$mod.TTMSFNCCustomComponent).FDesigntimeFormPixelsPerInch,96));
        g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth(),this.GetHeight())),this.GetText(),false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
      } finally {
        g = rtl.freeLoc(g);
      };
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      var l = 0.0;
      var t = 0.0;
      var w = 0.0;
      var h = 0.0;
      var sc = 0;
      var sz = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var g = null;
      var c = null;
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
      try {
        sc = 6;
        if ((this.FOwner != null) && $mod.TTMSFNCCustomComponent.isPrototypeOf(this.FOwner)) {
          g.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(g.FFont.FHeight,rtl.as(this.FOwner,$mod.TTMSFNCCustomComponent).FDesigntimeFormPixelsPerInch,96));
          sc = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(sc,rtl.as(this.FOwner,$mod.TTMSFNCCustomComponent).FDesigntimeFormPixelsPerInch,96);
        };
        sz.$assign(g.CalculateTextSize$1(this.GetText()));
        w = sz.cx + sc;
        h = sz.cy + sc;
      } finally {
        g = rtl.freeLoc(g);
      };
      if ((this.FOwner != null) && pas["WEBLib.Controls"].TControl.isPrototypeOf(this.FOwner)) {
        c = rtl.as(this.FOwner,pas["WEBLib.Controls"].TControl);
        l = (c.GetWidth() / 2) - (w / 2);
        t = c.GetHeight();
      } else {
        l = X;
        t = Y;
      };
      pas["WEBLib.Controls"].TControl.SetBounds.call(this,Math.round(l),Math.round(t),Math.round(w),Math.round(h));
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomComponent",pas["WEBLib.Controls"].TCustomControl,function () {
    this.FBlockPersistenceInterface = false;
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FStored = false;
      this.FNameLabel = null;
      this.FDesigntimeFormPixelsPerInch = 0;
      this.FAppearancePersisting = false;
      this.FAdaptToStyle = false;
      this.FOnCanSaveProperty = null;
      this.FOnCanLoadProperty = null;
    };
    this.$final = function () {
      this.FNameLabel = undefined;
      this.FOnCanSaveProperty = undefined;
      this.FOnCanLoadProperty = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.GetVersionNumber = function (AMaj, AMin, ARel, ABld) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.DoCanSaveProperty = function (AObject, APropertyName, APropertyType, ACanSave) {
      if (this.FOnCanSaveProperty != null) this.FOnCanSaveProperty(this,AObject,APropertyName,APropertyType,ACanSave);
    };
    this.DoCanLoadProperty = function (AObject, APropertyName, APropertyType, ACanLoad) {
      if (this.FOnCanLoadProperty != null) this.FOnCanLoadProperty(this,AObject,APropertyName,APropertyType,ACanLoad);
    };
    this.IsAppearanceProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.CanSaveProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      if ((AObject === this) && !this.FBlockPersistenceInterface) {
        Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(APropertyName,pas["WEBLib.TMSFNCPersistence"].ExcludePropertyList) === -1}
       else Result = true;
      if (this.FAppearancePersisting) Result = Result && this.IsAppearanceProperty(AObject,APropertyName,APropertyType);
      this.DoCanSaveProperty(AObject,APropertyName,APropertyType,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.CanLoadProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      if ((AObject === this) && !this.FBlockPersistenceInterface) {
        Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(APropertyName,pas["WEBLib.TMSFNCPersistence"].ExcludePropertyList) === -1}
       else Result = true;
      this.DoCanLoadProperty(AObject,APropertyName,APropertyType,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL;
      return Result;
    };
    this.GetTipsURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseTipsURL;
      return Result;
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.SetDefaultGraphicColors = function () {
      var c = 0;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupFillColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupFillColor = 16777215;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundStrokeColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupStrokeColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupStrokeColor = 12632256;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleDefaultButtonFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor = 11119017;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultTextFontColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultTextFontColor = 0;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor = c;
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].Blend(c,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor,25);
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].Blend(c,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor,30);
      } else {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor = 0;
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251);
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177);
      };
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorDisabled = 11119017;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorDisabled = 13882323;
    };
    this.ChangeDPIScale = function (M, D) {
    };
    this.SetAdaptToStyle = function (Value) {
      this.FAdaptToStyle = Value;
    };
    this.Paint = function () {
      var pic = null;
      var g = null;
      var r = null;
      var rc = null;
      pas["WEBLib.Controls"].TCustomControl.Paint.call(this);
      r = null;
      pic = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[this.GetCanvas(),false]);
      try {
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(0);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth(),this.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        rc = pas["WEBLib.DesignIntf"].GetRegisteredComponent(this.$classname);
        if (rc != null) pic.LoadFromResource(rc.FIcon);
        g.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(2,2,this.GetWidth() - 2,this.GetHeight() - 2)),pic,true,true,true,false);
      } finally {
        if (r != null) r = rtl.freeLoc(r);
        pic = rtl.freeLoc(pic);
        g = rtl.freeLoc(g);
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.RealignLabel();
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.SetVisible(false);
    };
    this.RealignLabel = function () {
      if (this.FNameLabel != null) this.FNameLabel.SetBounds(this.GetLeft(),this.GetTop(),this.GetWidth(),this.GetHeight());
    };
    this.RegisterRuntimeClasses = function () {
    };
    this.Notification = function (AComponent, AOperation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((AComponent === this.FNameLabel) && (AOperation === pas.Classes.TOperation.opRemove)) this.FNameLabel = null;
    };
    this.Create$1 = function (AOwner) {
      var ppi = 0;
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      ppi = 96;
      this.FDesigntimeFormPixelsPerInch = ppi;
      this.SetDefaultGraphicColors();
      this.SetWidth(26);
      this.SetHeight(26);
      if (!this.IsDesigning()) this.RegisterRuntimeClasses();
      return this;
    };
    this.SetName = function (Value) {
      pas["WEBLib.Controls"].TCustomControl.SetName.apply(this,arguments);
      if (!(this.FNameLabel != null) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this.FOwner)) {
        this.FNameLabel = $mod.TTMSFNCNameLabel.$create("Create$1",[this]);
        this.FNameLabel.SetParent(this);
        this.FNameLabel.SetTabStop(false);
      };
      this.RealignLabel();
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      var sc = 0.0;
      sc = this.FDesigntimeFormPixelsPerInch / 96;
      pas["WEBLib.Controls"].TControl.SetBounds.call(this,X,Y,Math.round(26 * sc),Math.round(26 * sc));
      this.RealignLabel();
    };
    this.BeginUpdate = function () {
      pas["WEBLib.Controls"].TControl.BeginUpdate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
    };
    this.IsDesignTime = function () {
      var Result = false;
      Result = false;
      if (this.FOwner != null) Result = this.IsDesigning() && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      return Result;
    };
    this.IsLoading = function () {
      var Result = false;
      Result = pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState;
      return Result;
    };
    this.IsReading = function () {
      var Result = false;
      Result = pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState;
      return Result;
    };
    this.IsDesigning = function () {
      var Result = false;
      Result = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) || (pas["WEBLib.Forms"].VSIDE != null);
      return Result;
    };
    this.IsDestroying = function () {
      var Result = false;
      Result = pas.Classes.TComponentStateItem.csDestroying in this.FComponentState;
      return Result;
    };
    this.SaveSettingsToFile = function (AFileName, AAppearanceOnly) {
      this.FAppearancePersisting = AAppearanceOnly;
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToFile(this,AFileName);
      this.FAppearancePersisting = false;
    };
    this.LoadSettingsFromFile = function (AFileName) {
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromFile(this,AFileName);
    };
    this.SaveSettingsToStream = function (AStream, AAppearanceOnly) {
      this.FAppearancePersisting = AAppearanceOnly;
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToStream(this,AStream);
      this.FAppearancePersisting = false;
    };
    this.LoadSettingsFromStream = function (AStream) {
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromStream(this,AStream);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("OnCanSaveProperty",0,$mod.$rtti["TTMSFNCCustomComponentCanSavePropertyEvent"],"FOnCanSaveProperty","FOnCanSaveProperty");
    $r.addProperty("OnCanLoadProperty",0,$mod.$rtti["TTMSFNCCustomComponentCanLoadPropertyEvent"],"FOnCanLoadProperty","FOnCanLoadProperty");
  });
  this.$rtti.$ClassRef("TTMSFNCCustomComponentClass",{instancetype: this.$rtti["TTMSFNCCustomComponent"]});
},["WEBLib.TMSFNCUtils","SysUtils","WEBLib.Forms","WEBLib.TMSFNCStyles","WEBLib.TMSFNCGraphics","WEBLib.Graphics","WEBLib.TMSFNCGraphicsTypes","Types","WEBLib.DesignIntf"]);
rtl.module("WEBLib.TMSFNCBitmapContainer",["System","Classes","WEBLib.TMSFNCTypes","WEBLib.TMSFNCCustomComponent","WEBLib.Controls"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCBitmapContainer");
  this.$rtti.$Class("TTMSFNCBitmapItem");
  rtl.createInterface(this,"ITMSFNCBitmapContainer","{ED26710D-395F-4971-8AC9-A31083BF2A3C}",["SetBitmapContainer","GetBitmapContainer"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("SetBitmapContainer",0,[["Value",$mod.$rtti["TTMSFNCBitmapContainer"],2]]);
    $r.addMethod("GetBitmapContainer",1,[],2,$mod.$rtti["TTMSFNCBitmapContainer"]);
    $r.addProperty("BitmapContainer",3,$mod.$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer",2);
  });
  rtl.createInterface(this,"ITMSFNCBitmapContainerGetItem","{98F65D59-B40C-4574-AF9C-3CA68E86AE10}",["ItemCount","GetItem"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("ItemCount",1,[],2,rtl.longint);
    $r.addMethod("GetItem",1,[["AIndex",rtl.longint]],2,$mod.$rtti["TTMSFNCBitmapItem"]);
  });
  rtl.createClass(this,"TTMSFNCBitmapItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FBitmap = null;
      this.FTag = 0;
      this.FName = "";
    };
    this.$final = function () {
      this.FBitmap = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetBitmap = function (Value) {
      this.FBitmap.Assign(Value);
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
      this.FName = "Item" + pas.SysUtils.IntToStr(this.FCollection.GetCount());
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.DoBitmapChanged = function (Sender) {
      if ($mod.TTMSFNCBitmapCollection.isPrototypeOf(this.FCollection)) {
        if (rtl.as(this.FCollection,$mod.TTMSFNCBitmapCollection).FOwner$1 != null) rtl.as(this.FCollection,$mod.TTMSFNCBitmapCollection).FOwner$1.DoBitmapChanged(this);
      };
    };
    this.Assign = function (Source) {
      this.FName = rtl.as(Source,$mod.TTMSFNCBitmapItem).FName;
      this.FTag = rtl.as(Source,$mod.TTMSFNCBitmapItem).FTag;
      this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCBitmapItem).FBitmap);
    };
    this.GetDisplayName = function () {
      var Result = "";
      if (this.FName !== "") {
        Result = this.FName}
       else Result = "";
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("Name",0,rtl.string,"FName","FName");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag");
  });
  rtl.createClass(this,"TTMSFNCBitmapCollection",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetBitmapItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCBitmapItem;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.GetBitmapItemClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  rtl.createClass(this,"TControlList",pas.Classes.TList,function () {
  });
  rtl.createClass(this,"TTMSFNCBitmapContainer",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FControls$1 = null;
      this.FItems = null;
      this.FOnBitmapChanged = null;
    };
    this.$final = function () {
      this.FControls$1 = undefined;
      this.FItems = undefined;
      this.FOnBitmapChanged = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.GetBitmapName = function (AIndex) {
      var Result = "";
      Result = "";
      if ((AIndex >= 0) && (AIndex <= (this.GetItems().GetCount() - 1))) Result = this.GetItems().GetItemEx(AIndex).FName;
      return Result;
    };
    this.GetBitmap = function (AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.GetItems().GetCount() - 1))) Result = this.GetItems().GetItemEx(AIndex).FBitmap;
      return Result;
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FItems;
      return Result;
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,0);
      return Result;
    };
    this.CreateItems = function () {
      var Result = null;
      Result = $mod.TTMSFNCBitmapCollection.$create("Create$3",[this]);
      return Result;
    };
    this.RegisterRuntimeClasses = function () {
      pas.Classes.RegisterClass($mod.TTMSFNCBitmapContainer);
    };
    this.Notification = function (AComponent, AOperation) {
      var i = 0;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if ((AOperation === pas.Classes.TOperation.opRemove) && (this.FControls$1 != null)) {
        for (var $l = this.FControls$1.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FControls$1.Get(i) == AComponent) this.FControls$1.Delete(i);
        };
      };
    };
    this.DoBitmapChanged = function (Sender) {
      var f = null;
      var I = 0;
      f = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetParentForm(this);
      if (f != null) {
        for (var $l = 0, $end = f.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          if (pas["WEBLib.Controls"].TWinControl.isPrototypeOf(f.GetControls(I))) this.InvalidateMembers(rtl.as(f.GetControls(I),pas["WEBLib.Controls"].TWinControl));
        };
      };
      if (this.FOnBitmapChanged != null) this.FOnBitmapChanged(this);
    };
    this.InvalidateMembers = function (AControl) {
      var I = 0;
      if (!(AControl != null)) return;
      if (pas.TypInfo.GetPropInfo$2(AControl,"BitmapContainer") != null) AControl.Invalidate();
      for (var $l = 0, $end = AControl.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas["WEBLib.Controls"].TWinControl.isPrototypeOf(AControl.GetControls(I))) this.InvalidateMembers(rtl.as(AControl.GetControls(I),pas["WEBLib.Controls"].TWinControl));
      };
    };
    this.Create$5 = function () {
      this.Create$1(null);
      return this;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      this.FItems = this.CreateItems();
      this.FControls$1 = $mod.TControlList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FControls$1;
        }, set: function (v) {
          this.p.FControls$1 = v;
        }});
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCBitmapContainer.isPrototypeOf(Source)) {
        this.FItems.Assign(rtl.as(Source,$mod.TTMSFNCBitmapContainer).GetItems());
      } else pas["WEBLib.Controls"].TControl.Assign.apply(this,arguments);
    };
    this.Changed = function () {
      var i = 0;
      for (var $l = 0, $end = this.FControls$1.GetCount() - 1; $l <= $end; $l++) i = $l;
    };
    this.RegisterControl = function (AControl) {
      this.FControls$1.Add(AControl);
    };
    this.FindBitmap = function (i, ABitmap) {
      if ((i >= 0) && (i <= (this.GetItems().GetCount() - 1))) ABitmap.Assign(this.GetItems().GetItemEx(i).FBitmap);
    };
    this.GetItem = function (AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.ItemCount() - 1))) Result = this.GetItems().GetItemEx(AIndex);
      return Result;
    };
    this.FindBitmap$1 = function (s) {
      var Result = null;
      var i = 0;
      Result = null;
      s = pas.SysUtils.UpperCase(s);
      i = 1;
      while (i <= this.GetItems().GetCount()) {
        if (pas.SysUtils.UpperCase(this.GetItems().GetItemEx(i - 1).FName) === s) {
          Result = this.GetItems().GetItemEx(i - 1).FBitmap;
          break;
        };
        i += 1;
      };
      return Result;
    };
    this.ItemCount = function () {
      var Result = 0;
      Result = this.GetItems().GetCount();
      return Result;
    };
    this.RandomBitmapName = function () {
      var Result = "";
      Result = this.GetBitmapName(pas.System.Random(this.ItemCount()));
      return Result;
    };
    this.RandomBitmap = function () {
      var Result = null;
      Result = this.GetBitmap(pas.System.Random(this.ItemCount()));
      return Result;
    };
    this.AddFromURL = function (URL, BitmapName) {
      var bmpi = null;
      bmpi = this.GetItems().Add$1();
      bmpi.FBitmap.LoadFromURL(URL,null);
      bmpi.FName = BitmapName;
    };
    this.AddFromResource = function (ResourceName, BitmapName, AInstance) {
      var bmpi = null;
      bmpi = this.GetItems().Add$1();
      bmpi.FBitmap.LoadFromResource$1(ResourceName,AInstance);
      bmpi.FName = BitmapName;
    };
    this.AddFromResource$1 = function (ResourceName, BitmapName) {
      this.AddFromResource(ResourceName,BitmapName,this.GetInstance());
    };
    this.AddFromFile = function (FileName, BitmapName) {
      var bmpi = null;
      bmpi = this.GetItems().Add$1();
      bmpi.FBitmap.LoadFromFile(FileName,null);
      bmpi.FName = BitmapName;
    };
    rtl.addIntf(this,$mod.ITMSFNCBitmapContainerGetItem);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCBitmapCollection"],"GetItems","SetItems");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("OnBitmapChanged",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnBitmapChanged","FOnBitmapChanged");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["TypInfo","WEBLib.Forms","SysUtils","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCHTMLEngine",["System","Classes","WEBLib.TMSFNCGraphics","Types","WEBLib.Graphics","WEBLib.TMSFNCTypes","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCGraphicsTypes"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TMSFNCHTMLENGINE_ATTR_DELIM = '"';
  this.HTMLDrawEx = function (AGraphics, s, fr, XPos, YPos, FocusLink, HoverLink, ShadowOffset, CheckHotSpot, CheckHeight, Print, Selected, Blink, HoverStyle, WordWrap, ResFactor, URLColor, HoverColor, HoverFontColor, ShadowColor, AnchorVal, StripVal, FocusAnchor, XSize, YSize, HyperLinks, MouseLink, HoverRect, LineCount, LineSpacing, BitmapContainer, Opacity, HyperLinkUnderline, HighlightColor, HighlightTextColor, HighlightTextStyle) {
    var Result = false;
    var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var cid = "";
    var cv = "";
    var ct = "";
    cid = "";
    cv = "";
    ct = "";
    cr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
    Result = $mod.HTMLDrawEx$1(AGraphics,s,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(fr),XPos,YPos,FocusLink,HoverLink,ShadowOffset,CheckHotSpot,CheckHeight,Print,Selected,Blink,HoverStyle,WordWrap,false,"",ResFactor,URLColor,HoverColor,HoverFontColor,ShadowColor,AnchorVal,StripVal,FocusAnchor,XSize,YSize,HyperLinks,MouseLink,HoverRect,cr,{get: function () {
        return cid;
      }, set: function (v) {
        cid = v;
      }},{get: function () {
        return cv;
      }, set: function (v) {
        cv = v;
      }},{get: function () {
        return ct;
      }, set: function (v) {
        ct = v;
      }},LineCount,LineSpacing,BitmapContainer,Opacity,HyperLinkUnderline,HighlightColor,HighlightTextColor,rtl.refSet(HighlightTextStyle));
    return Result;
  };
  this.HTMLDrawEx$1 = function (AGraphics, s, fr, XPos, YPos, FocusLink, HoverLink, ShadowOffset, CheckHotSpot, CheckHeight, Print, Selected, Blink, HoverStyle, WordWrap, Down, DownID, ResFactor, URLColor, HoverColor, HoverFontColor, ShadowColor, AnchorVal, StripVal, FocusAnchor, XSize, YSize, HyperLinks, MouseLink, HoverRect, ControlRect, CID, CV, CT, LineCount, LineSpacing, BitmapContainer, Opacity, HyperLinkUnderline, HighlightColor, HighlightTextColor, HighlightTextStyle) {
    var Result = false;
    var su = "";
    var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var hr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var rr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var htmlwidth = 0.0;
    var htmlheight = 0.0;
    var txtheight = 0.0;
    var ch = 0.0;
    var rh = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
    var Align = 0;
    var PIndent = 0;
    var OldFont = null;
    var OldFontColor = 0;
    var CalcFont = null;
    var CalcFontColor = 0;
    var DrawFont = null;
    var DrawFontCOlor = 0;
    var FontColor = 0;
    var OldPenColor = 0;
    var OldPenKind = 0;
    var OldCalcFont = null;
    var OldCalcFontColor = 0;
    var BkColor = 0;
    var BGColor = 0;
    var OldDrawFont = null;
    var OldDrawFontColor = 0;
    var Hotspot = false;
    var ImageHotspot = false;
    var Anchor = false;
    var OldAnchor = false;
    var MouseInAnchor = false;
    var error = false;
    var blnkKind = 0;
    var paracolor = 0;
    var pencolor = 0;
    var blnkcolor = 0;
    var hifcol = 0;
    var hibcol = 0;
    var LastAnchor = "";
    var OldAnchorVal = "";
    var LType = "";
    var IMGSize = pas.Types.TPoint.$new();
    var isSup = false;
    var isSub = false;
    var isPara = false;
    var isShad = false;
    var hlcount = 0;
    var licount = 0;
    var imgali = 0.0;
    var subh = 0.0;
    var suph = 0.0;
    var ListIndex = 0;
    var Invisible = false;
    var FoundTag = false;
    var nnFit = 0;
    var inspoint = 0;
    var hifStyles = {};
    var AltImg = 0;
    var ImgIdx = 0;
    var OldImgIdx = 0;
    var ColL = 0;
    var ColB = 0;
    var ofsx = 0;
    var newofsx = 0;
    var FHot = false;
    var floatrect = pas.Types.TRect.$new();
    var floatpt = pas.Types.TPoint.$new();
    var txtfloat = 0;
    var txtfloatbefore = 0;
    var imgfloat = 0;
    function HTMLDrawLine(AGraphics, s, r, Calc, w, h, subh, suph, imgali, Align, PIndent, XPos, YPos, Hotspot, ImageHotSpot, OffsetX, NewOffsetX, floatrect, txtfloat) {
      var Result = "";
      var su = "";
      var Res = "";
      var TagProp = "";
      var Prop = "";
      var Tagp = "";
      var LineText = "";
      var dsu = "";
      var NewAlign = 0;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ir = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var fs = {};
      var linebreak = false;
      var imgbreak = false;
      var linkbreak = false;
      var indent = 0;
      var bmpx = 0;
      var bmpy = 0;
      var imgw = 0;
      var imgh = 0;
      var err = 0;
      var sw = 0.0;
      var th = 0.0;
      var errs = 0.0;
      var rh = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var TagPos = 0;
      var SpacePos = 0;
      var o = 0;
      var l = 0;
      var bmp = null;
      var bmpcreated = false;
      var NewColor = 0;
      var TagWidth = 0;
      var TagHeight = 0;
      var WordLen = 0;
      var WordWidth = 0.0;
      var TagChar = "\x00";
      var LengthFits = false;
      var ptf1 = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var ptf2 = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var imgalign = 0;
      var imgoffs = 0;
      var imgth = 0;
      var ControlType = "";
      var ControlWidth = "";
      var ControlHeight = "";
      var ControlID = "";
      var ControlValue = "";
      var ControlProp = "";
      var ControlLen = "";
      var origh = 0.0;
      Result = "";
      LineText = "";
      WordWidth = 0;
      r.Bottom = r.Bottom - subh.get();
      w.set(0);
      sw = 0;
      linebreak = false;
      imgbreak = false;
      linkbreak = false;
      Hotspot.set(false);
      ImageHotSpot.set(false);
      origh = h.get();
      h.set(0);
      cr.$assign(r);
      Res = "";
      if (!Calc) cr.Left = cr.Left + OffsetX;
      if (isPara && !Calc) {
        pencolor = AGraphics.FStroke.FColor;
        AGraphics.FStroke.SetColor(AGraphics.FFill.FColor);
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(fr.Left,r.Top,fr.Right,r.Top + origh)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      };
      while ((s.get().length > 0) && !linebreak && !imgbreak) {
        TagPos = pas.System.Pos("<",s.get());
        if (WordWrap) {
          SpacePos = $impl.PosBreak(s.get())}
         else SpacePos = 0;
        if ((TagPos > 0) && ((SpacePos > TagPos) || (SpacePos === 0))) {
          su = pas.System.Copy(s.get(),1,TagPos - 1)}
         else {
          if (SpacePos > 0) {
            su = pas.System.Copy(s.get(),1,SpacePos)}
           else su = s.get();
        };
        WordLen = su.length;
        while (pas.System.Pos("&nbsp;",su) > 0) {
          pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TagReplaceString("&nbsp;"," ",{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
        while (pas.System.Pos("&lt;",su) > 0) {
          pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TagReplaceString("&lt;","<",{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
        while (pas.System.Pos("&gt;",su) > 0) {
          pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TagReplaceString("&gt;",">",{get: function () {
              return su;
            }, set: function (v) {
              su = v;
            }});
        };
        if (WordLen > 0) {
          if (h.get() === 0) h.set(origh);
          rh.$assign(AGraphics.CalculateText(su,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,false));
          th = rh.Bottom - rh.Top;
          if (isSub && (subh.get() < (th / 4))) subh.set(th / 4);
          if (isSup && (suph.get() < (th / 4))) suph.set(th / 4);
          if (th > h.get()) h.set(th);
          StripVal.set(StripVal.get() + su);
          if (Invisible) pas.System.Delete(s,1,WordLen);
          if (!Invisible) {
            if (!Calc) {
              if (isSup) cr.Bottom = cr.Bottom - suph.get();
              if (isSub) cr.Bottom = cr.Bottom + subh.get();
              cr.Bottom = cr.Bottom - imgali.get();
              rh.$assign(AGraphics.CalculateText(su,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,false));
              errs = rh.Right - rh.Left;
              if (BkColor !== -1) {
                AGraphics.FFill.SetColor(BkColor);
                AGraphics.FStroke.SetColor(BkColor);
                AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
                AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                rh.$assign(AGraphics.CalculateText$1("gh"));
                AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(cr.Left,cr.Top,cr.Left + errs,cr.Top + (rh.Bottom - rh.Top))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              };
              BkColor = -1;
              if (isShad) {
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(cr,ShadowOffset,ShadowOffset);
                AGraphics.FFont.SetColor(ShadowColor);
                AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr),su,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,false,false,-1,-1);
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(cr,-ShadowOffset,-ShadowOffset);
                AGraphics.FFont.SetColor(OldFontColor);
              };
              if ((su !== "") && (su.charAt(su.length - 1) === " ") && Anchor) {
                dsu = su + "\x00"}
               else dsu = su;
              AGraphics.FFont.SetColor(FontColor);
              AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr),dsu,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,false,false,-1,-1);
              cr.Right = cr.Left + errs;
              if (Anchor && ((HyperLinks.get() - 1) === FocusLink)) FocusAnchor.set(LastAnchor);
              if (error) {
                AGraphics.FStroke.SetColor(255);
                AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                AGraphics.FStroke.SetWidth(1);
                l = Math.round((cr.Left / 2) * 2);
                if ((l % 4) === 0) {
                  o = 2}
                 else o = 0;
                while (l < cr.Right) {
                  ptf1.$assign(pas["WEBLib.TMSFNCTypes"].PointF(l,(r.Bottom + o) - 1));
                  if (o === 2) {
                    o = 0}
                   else o = 2;
                  ptf2.$assign(pas["WEBLib.TMSFNCTypes"].PointF(l + 2,(r.Bottom + o) - 1));
                  AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(ptf1),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(ptf2),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
                  l += 2;
                };
              };
              cr.Left = cr.Right;
              cr.Right = r.Right;
              cr.Bottom = r.Bottom;
              cr.Top = r.Top;
            } else {
              cr.$assign(r);
              rh.$assign(AGraphics.CalculateText(su,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,false));
              cr.Right = cr.Left + (rh.Right - rh.Left);
              if ((YPos > cr.Top) && (YPos < cr.Bottom) && (XPos > w.get())) {
                nnFit = 0;
                if (nnFit === WordLen) {
                  inspoint = inspoint + WordLen}
                 else inspoint = inspoint + nnFit;
              };
              WordWidth = cr.Right - cr.Left;
              w.set(w.get() + WordWidth);
              if (((XPos - cr.Left) >= (w.get() - WordWidth)) && ((XPos - cr.Left) <= w.get()) && Anchor) {
                Hotspot.set(true);
                if (YPos > cr.Top) {
                  AnchorVal.set(LastAnchor);
                  MouseInAnchor = true;
                };
              };
            };
            LengthFits = ((w.get() + PIndent.get()) < ((r.Right - r.Left - ofsx) + 1)) || ((r.Right - r.Left - ofsx) <= WordWidth);
            LineText = LineText + su;
            if (LengthFits || !WordWrap) {
              Res = Res + pas.System.Copy(s.get(),1,WordLen);
              pas.System.Delete(s,1,WordLen);
              if (su.length >= WordLen) {
                if (pas.System.Copy(su,WordLen,1) === " ") {
                  rh.$assign(AGraphics.CalculateText$1(" "));
                  sw = rh.Right - rh.Left;
                } else sw = 0;
              } else sw = 0;
            } else {
              linebreak = true;
              w.set(w.get() - WordWidth);
            };
          };
        };
        TagPos = pas.System.Pos("<",s.get());
        if ((TagPos === 1) && (s.get().length <= 2)) s.set("");
        if (!linebreak && (TagPos === 1) && (s.get().length > 2)) {
          if ((s.get().charAt(1) === "/") && (s.get().length > 3)) {
            var $tmp = pas.System.upcase(s.get().charAt(2));
            if ($tmp === "A") {
              if ((!HoverStyle || (HoverLink === HyperLinks.get())) && !Calc) {
                AGraphics.FFont.SetStyle(rtl.diffSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
                if (HoverColor !== -1) BkColor = HoverColor;
                if (HoverFontColor !== -1) FontColor = HoverFontColor;
              };
              if (!Selected) FontColor = OldFontColor;
              Anchor = false;
              if (MouseInAnchor) {
                hr.Bottom = r.Bottom;
                hr.Right = r.Left + w.get();
                if (r.Top !== hr.Top) {
                  hr.Left = r.Left;
                  hr.Top = r.Top;
                };
                HoverRect.$assign(hr);
                MouseLink.set(HyperLinks.get());
                MouseInAnchor = false;
              };
              if (FocusLink === (HyperLinks.get() - 1)) {
                rr.Right = cr.Left;
                rr.Bottom = cr.Bottom - imgali.get();
                rh.$assign(AGraphics.CalculateText$1("gh"));
                rr.Top = rr.Bottom - (rh.Bottom - rh.Top);
                pas["WEBLib.TMSFNCTypes"].InflateRectEx(rr,1,0);
              };
            } else if ($tmp === "E") {
              if (!Calc) error = false;
            } else if ($tmp === "B") {
              if (s.get().charAt(3) !== ">") {
                FontColor = OldFontColor}
               else AGraphics.FFont.SetStyle(rtl.diffSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)));
            } else if ($tmp === "S") {
              TagChar = pas.System.upcase(s.get().charAt(3));
              if (TagChar === "U") {
                isSup = false;
                isSub = false;
              } else if (TagChar === "H") {
                isShad = false}
               else AGraphics.FFont.SetStyle(rtl.diffSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)));
            } else if ($tmp === "F") {
              AGraphics.FFont.SetName(OldFont.FName);
              AGraphics.FFont.SetSize(OldFont.FSize);
              if (!Calc && !Selected) {
                FontColor = OldFontColor;
                AGraphics.FFill.SetColor(BGColor);
              };
            } else if ($tmp === "H") {
              if (!Calc) {
                FontColor = hifcol;
                BkColor = hibcol;
                AGraphics.FFont.SetStyle(rtl.refSet(hifStyles));
                AGraphics.FFill.SetColor(hibcol);
              };
            } else if ($tmp === "I") {
              AGraphics.FFont.SetStyle(rtl.diffSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)));
            } else if ($tmp === "L") {
              linebreak = true;
            } else if ($tmp === "O") {
              NewOffsetX.set(0);
            } else if ($tmp === "P") {
              linebreak = true;
              if (!Calc) {
                Align.set(pas.Classes.TAlignment.taLeftJustify);
                AGraphics.FFill.SetColor(paracolor);
                isPara = false;
              };
            } else if ($tmp === "U") {
              if ((s.get().charAt(3) !== ">") && (ListIndex > 0)) {
                ListIndex -= 1}
               else AGraphics.FFont.SetStyle(rtl.diffSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
            } else if ($tmp === "R") {}
            else if ($tmp === "Z") Invisible = false;
          } else {
            var $tmp1 = pas.System.upcase(s.get().charAt(1));
            if ($tmp1 === "A") {
              if ((FocusLink === HyperLinks.get()) && !Calc) {
                rr.Left = cr.Left;
                rr.Top = cr.Top;
              };
              HyperLinks.set(HyperLinks.get() + 1);
              if ((!HoverStyle || (HoverLink === HyperLinks.get())) && !Calc) {
                if (HyperLinkUnderline) AGraphics.FFont.SetStyle(rtl.unionSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
                if ((HoverColor !== -1) && !Calc) BkColor = HoverColor;
                if (HoverFontColor !== -1) FontColor = HoverFontColor;
              };
              if (!Selected && ((HoverFontColor === -1) || (HoverLink !== HyperLinks.get()) || !HoverStyle)) {
                OldFontColor = FontColor;
                FontColor = URLColor;
              };
              TagProp = pas.System.Copy(s.get(),3,pas.System.Pos(">",s.get()) - 1);
              Prop = pas.System.Copy(TagProp,pas.System.Pos('"',TagProp) + 1,TagProp.length);
              Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
              LastAnchor = Prop;
              Anchor = true;
              hr.Left = w.get();
              hr.Top = r.Top;
            } else if ($tmp1 === "B") {
              TagChar = pas.System.upcase(s.get().charAt(2));
              var $tmp2 = TagChar;
              if ($tmp2 === ">") {
                AGraphics.FFont.SetStyle(rtl.unionSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)))}
               else if ($tmp2 === "R") {
                if (h.get() === 0) h.set(origh);
                linebreak = true;
                StripVal.set(StripVal.get() + "\r");
              } else if ($tmp2 === "L") {
                if (!Blink) FontColor = blnkcolor}
               else if ($tmp2 === "O") {
                bmpy = 0;
                Res = Res + pas.System.Copy(s.get(),1,pas.System.Pos(">",s.get()));
                if (!Calc && !Selected) {
                  TagProp = pas.SysUtils.UpperCase(pas.System.Copy(s.get(),6,pas.System.Pos(">",s.get()) - 1));
                  if (pas.System.Pos("BACKGROUND",TagProp) > 0) {
                    Prop = pas.System.Copy(TagProp,pas.System.Pos("BACKGROUND",TagProp) + 10,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    if (pas.System.Pos("IDX:",pas.SysUtils.UpperCase(Prop)) > 0) {
                      pas.System.Delete({get: function () {
                          return Prop;
                        }, set: function (v) {
                          Prop = v;
                        }},1,4);
                    };
                    bmp = null;
                    bmpcreated = false;
                    if ((pas.System.Pos(":",Prop) === 0) && (BitmapContainer != null)) {
                      bmp = BitmapContainer.FindBitmap$1(Prop);
                    };
                    if (pas.System.Pos("URL://",pas.SysUtils.UpperCase(Prop)) > 0) {
                      pas.System.Delete({get: function () {
                          return Prop;
                        }, set: function (v) {
                          Prop = v;
                        }},1,6);
                      bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromURL(Prop);
                      bmpcreated = true;
                    };
                    if (bmp != null) {
                      if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp) && (bmp.GetWidth() > 0) && (bmp.GetHeight() > 0)) {
                        while (bmpy < (fr.Bottom - fr.Top)) {
                          bmpx = 0;
                          while (bmpx < (fr.Right - fr.Left)) {
                            AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(fr.Left + bmpx),Math.round(fr.Top + bmpy),Math.round(fr.Left + bmpx) + bmp.GetWidth(),Math.round(fr.Top + bmpy) + bmp.GetHeight())),bmp,true,false,true,false);
                            bmpx = bmpx + bmp.GetWidth();
                          };
                          bmpy = bmpy + bmp.GetHeight();
                        };
                      };
                      if (bmpcreated) bmp = rtl.freeLoc(bmp);
                    };
                  };
                  if (pas.System.Pos("BGTOPLEFT",TagProp) > 0) {
                    Prop = pas.System.Copy(TagProp,pas.System.Pos("BGTOPLEFT",TagProp) + 10,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    bmp = null;
                    if ((pas.System.Pos(":",Prop) === 0) && (BitmapContainer != null)) {
                      bmp = BitmapContainer.FindBitmap$1(Prop);
                    };
                    if (bmp != null) {
                      if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp) && (bmp.GetWidth() > 0) && (bmp.GetHeight() > 0)) {
                        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(fr.Left),Math.round(fr.Top + bmpy),Math.round(fr.Left) + bmp.GetWidth(),Math.round(fr.Top) + bmp.GetHeight())),bmp,true,false,true,false);
                      };
                    };
                  };
                  if (pas.System.Pos("BGTOPRIGHT",TagProp) > 0) {
                    Prop = pas.System.Copy(TagProp,pas.System.Pos("BGTOPRIGHT",TagProp) + 10,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    bmp = null;
                    if ((pas.System.Pos(":",Prop) === 0) && (BitmapContainer != null)) {
                      bmp = BitmapContainer.FindBitmap$1(Prop);
                    };
                    if (bmp != null) {
                      if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp) && (bmp.GetWidth() > 0) && (bmp.GetHeight() > 0)) {
                        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(fr.Right) - bmp.GetWidth(),Math.round(fr.Top + bmpy),Math.round(fr.Right),Math.round(fr.Top) + bmp.GetHeight())),bmp,true,false,true,false);
                      };
                    };
                  };
                  if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("BGCOLOR",TagProp,{get: function () {
                      return TagPos;
                    }, set: function (v) {
                      TagPos = v;
                    }}) > 0) {
                    Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    NewColor = -1;
                    if (Prop.length > 0) {
                      if (Prop.charAt(0) === "#") {
                        NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(Prop)}
                       else {
                        NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.TextToColor(pas.SysUtils.LowerCase(Prop));
                      };
                    };
                    if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("BGCOLORTO",TagProp,{get: function () {
                        return TagPos;
                      }, set: function (v) {
                        TagPos = v;
                      }}) > 0) {
                      Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                      Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                      Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                      Prop = "H";
                      if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("DIR",TagProp,{get: function () {
                          return TagPos;
                        }, set: function (v) {
                          TagPos = v;
                        }}) > 0) {
                        Prop = pas.System.Copy(TagProp,TagPos + 3,TagProp.length);
                        Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                        Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                      };
                      AGraphics.FStroke.SetColor(NewColor);
                    } else {
                      BGColor = AGraphics.FFill.FColor;
                      AGraphics.FFill.SetColor(NewColor);
                      pencolor = AGraphics.FStroke.FColor;
                      AGraphics.FStroke.SetColor(NewColor);
                      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
                      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                      AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(fr.Left - 2,fr.Top,fr.Right,fr.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                      AGraphics.FStroke.SetColor(pencolor);
                    };
                  };
                };
              };
            } else if ($tmp1 === "E") {
              if (!Calc) error = true;
            } else if ($tmp1 === "C") {
              TagProp = pas.System.Copy(s.get(),9,pas.System.Pos(">",s.get()) - 1);
              ControlType = "";
              ControlID = "";
              ControlValue = "";
              ControlWidth = "";
              ControlHeight = "";
              ControlProp = "";
              ControlLen = "";
              $mod.ParseControl(TagProp,{get: function () {
                  return ControlType;
                }, set: function (v) {
                  ControlType = v;
                }},{get: function () {
                  return ControlID;
                }, set: function (v) {
                  ControlID = v;
                }},{get: function () {
                  return ControlValue;
                }, set: function (v) {
                  ControlValue = v;
                }},{get: function () {
                  return ControlWidth;
                }, set: function (v) {
                  ControlWidth = v;
                }},{get: function () {
                  return ControlHeight;
                }, set: function (v) {
                  ControlHeight = v;
                }},{get: function () {
                  return ControlProp;
                }, set: function (v) {
                  ControlProp = v;
                }},{get: function () {
                  return ControlLen;
                }, set: function (v) {
                  ControlLen = v;
                }});
              ch = 25;
              if (ControlHeight !== "") {
                pas.System.val$8(ControlHeight,{get: function () {
                    return ch;
                  }, set: function (v) {
                    ch = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) ch = 25;
              };
              if ((ControlWidth !== "") || (ControlType === "CHECK") || (ControlType === "RADIO")) {
                pas.System.val$6(ControlWidth,{get: function () {
                    return indent;
                  }, set: function (v) {
                    indent = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err === 0) {
                  IMGSize.x = indent;
                  IMGSize.y = Math.round(AGraphics.CalculateTextHeight$1("gh")) + 10;
                };
                if ((ControlType === "CHECK") || (ControlType === "RADIO")) {
                  h.set(16)}
                 else h.set(23);
                if (ch > 25) h.set(ch - 2);
                if (!Calc) {
                  if ((ControlType === "EDIT") || (ControlType === "PASSWORD") || (ControlType === "MASK")) ;
                  if (ControlType === "COMBO") ;
                  if (ControlType === "CHECK") {
                    IMGSize.x = Math.round(16 * ResFactor) + 2;
                    IMGSize.y = IMGSize.x;
                    indent = IMGSize.x;
                    ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cr.Left + 1,cr.Top + ((cr.Bottom - cr.Top - (IMGSize.y - 2)) / 2),(cr.Left + IMGSize.x) - 1,cr.Top + ((cr.Bottom - cr.Top - (IMGSize.y - 2)) / 2) + (IMGSize.y - 2)));
                    ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(ir.Left),Math.round(ir.Top),Math.round(ir.Right),Math.round(ir.Bottom)));
                    AGraphics.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ir),pas.SysUtils.UpperCase(ControlValue) === "TRUE",Down && (DownID === ControlID),true,1.0);
                  };
                  if (ControlType === "RADIO") {
                    IMGSize.x = Math.round(16 * ResFactor) + 2;
                    IMGSize.y = IMGSize.x;
                    indent = IMGSize.x;
                    ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cr.Left + 1,cr.Top + ((cr.Bottom - cr.Top - (IMGSize.y - 2)) / 2),(cr.Left + IMGSize.x) - 1,cr.Top + ((cr.Bottom - cr.Top - (IMGSize.y - 2)) / 2) + (IMGSize.y - 2)));
                    ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(ir.Left),Math.round(ir.Top),Math.round(ir.Right),Math.round(ir.Bottom)));
                    AGraphics.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ir),pas.SysUtils.UpperCase(ControlValue) === "TRUE",Down && (DownID === ControlID),true,1.0);
                  };
                  if (ControlType === "BUTTON") {
                    IMGSize.y = 22;
                    ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cr.Left + 2,cr.Top + ((cr.Bottom - cr.Top - IMGSize.y) / 2),(cr.Left + indent) - 2,cr.Top + ((cr.Bottom - cr.Top - IMGSize.y) / 2) + IMGSize.y));
                    FHot = pas["WEBLib.TMSFNCTypes"].PtInRectEx(ir,pas["WEBLib.TMSFNCTypes"].PointF(XPos,YPos));
                    ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(ir.Left),Math.round(ir.Top),Math.round(ir.Right),Math.round(ir.Bottom)));
                    AGraphics.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ir),Down && (DownID === ControlID),FHot,true,true,1.0);
                    pas["WEBLib.TMSFNCTypes"].InflateRectEx(ir,-2,-2);
                    AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ir),ControlValue,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
                  };
                };
                if (ControlType === "BUTTON") IMGSize.y = 22;
                if (ControlType === "COMBO") IMGSize.y = 25;
                if ((ControlType === "CHECK") || (ControlType === "RADIO")) {
                  IMGSize.x = Math.round(16 * ResFactor) + 2;
                  IMGSize.y = IMGSize.x;
                };
                if ((((XPos - r.Left) > w.get()) && ((XPos - r.Left) < (w.get() + IMGSize.x)) && (YPos > cr.Top) && (YPos < (cr.Top + IMGSize.y))) || (CheckHotSpot && (CID.get() === ControlID))) {
                  ImageHotSpot.set(true);
                  AnchorVal.set("ctrl");
                  AltImg = ImgIdx;
                  ir.Left = r.Left + w.get();
                  ir.Right = ir.Left + IMGSize.x;
                  ir.Top = cr.Top;
                  ir.Bottom = cr.Top + IMGSize.y;
                  ControlRect.$assign(ir);
                  CV.set(ControlValue);
                  CID.set(ControlID);
                  CT.set(ControlType);
                };
                if (((w.get() + IMGSize.x) > (r.Right - r.Left)) && (IMGSize.x < (r.Right - r.Left))) {
                  imgbreak = true;
                } else {
                  w.set(w.get() + IMGSize.x);
                  cr.Left = cr.Left + IMGSize.x;
                  if (IMGSize.y > h.get()) h.set(IMGSize.y);
                };
              };
            } else if ($tmp1 === "H") {
              var $tmp3 = pas.System.upcase(s.get().charAt(2));
              if ($tmp3 === "R") {
                linebreak = true;
                if (!Calc) {
                  TagProp = pas.System.Copy(s.get(),4,pas.System.Pos(">",s.get()) - 1);
                  NewColor = 0;
                  if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("COLOR",pas.SysUtils.UpperCase(TagProp),{get: function () {
                      return TagPos;
                    }, set: function (v) {
                      TagPos = v;
                    }}) > 0) {
                    Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    if (Prop.length > 0) {
                      if (Prop.charAt(0) === "#") {
                        NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(Prop)}
                       else {
                        NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.TextToColor(pas.SysUtils.LowerCase(Prop));
                      };
                    };
                  };
                  AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                  pencolor = AGraphics.FStroke.FColor;
                  AGraphics.FStroke.SetColor(NewColor);
                  ptf1.$assign(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,cr.Bottom + 1));
                  ptf2.$assign(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,cr.Bottom + 1));
                  AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                  AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(ptf1),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(ptf2),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
                  AGraphics.FStroke.SetColor(pencolor);
                };
              } else if ($tmp3 === "I") {
                if (!Calc) {
                  hifcol = FontColor;
                  hibcol = BkColor;
                  hifStyles = rtl.refSet(AGraphics.FFont.FStyle);
                  BkColor = HighlightColor;
                  FontColor = HighlightTextColor;
                };
                AGraphics.FFont.SetStyle(rtl.refSet(HighlightTextStyle));
              };
            } else if ($tmp1 === "I") {
              TagChar = pas.System.upcase(s.get().charAt(2));
              if (TagChar === ">") {
                AGraphics.FFont.SetStyle(rtl.unionSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)))}
               else if (TagChar === "N") {
                TagProp = pas.System.Copy(s.get(),3,pas.System.Pos(">",s.get()) - 1);
                Prop = pas.System.Copy(TagProp,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("x",TagProp) + 2,TagProp.length);
                Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                pas.System.val$6(Prop,{get: function () {
                    return indent;
                  }, set: function (v) {
                    indent = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err === 0) {
                  if (indent > w.get()) {
                    w.set(indent);
                    cr.Left = fr.Left + indent;
                  };
                };
              } else if (TagChar === "M") {
                imgalign = 0;
                imgoffs = 0;
                imgfloat = $impl.TTMSFNCHTMLEngineFloatStyle.fsNone;
                imgth = Math.round(AGraphics.CalculateTextHeight$1("gh"));
                ImgIdx += 1;
                ir.$assign(cr);
                TagProp = pas.System.Copy(s.get(),3,pas.System.Pos(">",s.get()) - 1);
                Prop = pas.System.Copy(TagProp,pas.System.Pos("SRC",pas.SysUtils.UpperCase(TagProp)) + 4,TagProp.length);
                Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                TagProp = pas.SysUtils.UpperCase(TagProp);
                if ((pas.System.Pos("ALT",TagProp) > 0) && (AltImg === ImgIdx)) {
                  Prop = pas.System.Copy(TagProp,pas.System.Pos("ALT",TagProp) + 4,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                };
                TagWidth = 0;
                TagHeight = 0;
                if (pas.System.Pos("WIDTH",TagProp) > 0) {
                  Tagp = pas.System.Copy(TagProp,pas.System.Pos("WIDTH",TagProp) + 6,TagProp.length);
                  Tagp = pas.System.Copy(Tagp,pas.System.Pos('"',Tagp) + 1,Tagp.length);
                  Tagp = pas.System.Copy(Tagp,1,pas.System.Pos('"',Tagp) - 1);
                  pas.System.val$6(Tagp,{get: function () {
                      return TagWidth;
                    }, set: function (v) {
                      TagWidth = v;
                    }},{get: function () {
                      return err;
                    }, set: function (v) {
                      err = v;
                    }});
                  if (pas.System.Pos("%",Tagp) > 0) TagWidth = Math.round((TagWidth / 100) * (cr.Right - cr.Left));
                };
                if (pas.System.Pos("HEIGHT",TagProp) > 0) {
                  Tagp = pas.System.Copy(TagProp,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("HEIGHT",TagProp) + 7,TagProp.length);
                  Tagp = pas.System.Copy(Tagp,pas.System.Pos('"',Tagp) + 1,Tagp.length);
                  Tagp = pas.System.Copy(Tagp,1,pas.System.Pos('"',Tagp) - 1);
                  pas.System.val$6(Tagp,{get: function () {
                      return TagHeight;
                    }, set: function (v) {
                      TagHeight = v;
                    }},{get: function () {
                      return err;
                    }, set: function (v) {
                      err = v;
                    }});
                  if (pas.System.Pos("%",Tagp) > 0) TagHeight = Math.round((TagHeight / 100) * (cr.Bottom - cr.Top));
                };
                if (pas.System.Pos("ALIGN",TagProp) > 0) {
                  Tagp = pas.System.Copy(TagProp,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("ALIGN",TagProp) + 6,TagProp.length);
                  Tagp = pas.System.Copy(Tagp,pas.System.Pos('"',Tagp) + 1,Tagp.length);
                  Tagp = pas.System.Copy(Tagp,1,pas.System.Pos('"',Tagp) - 1);
                  if (Tagp === "MIDDLE") imgalign = 1;
                  if (Tagp === "TOP") imgalign = 2;
                };
                if (pas.System.Pos("FLOAT",TagProp) > 0) {
                  Tagp = pas.System.Copy(TagProp,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("FLOAT",TagProp) + 6,TagProp.length);
                  Tagp = pas.System.Copy(Tagp,pas.System.Pos('"',Tagp) + 1,Tagp.length);
                  Tagp = pas.System.Copy(Tagp,1,pas.System.Pos('"',Tagp) - 1);
                  if (Tagp === "LEFT") {
                    imgfloat = $impl.TTMSFNCHTMLEngineFloatStyle.fsLeft;
                    ir.Left = fr.Left;
                  };
                  if (Tagp === "RIGHT") imgfloat = $impl.TTMSFNCHTMLEngineFloatStyle.fsRight;
                };
                IMGSize.x = 0;
                IMGSize.y = 0;
                if (pas.System.Pos("IDX:",pas.SysUtils.UpperCase(Prop)) > 0) {
                  pas.System.Delete({get: function () {
                      return Prop;
                    }, set: function (v) {
                      Prop = v;
                    }},1,4);
                };
                bmp = null;
                bmpcreated = false;
                if ((pas.System.Pos(":",Prop) === 0) && (BitmapContainer != null)) {
                  bmp = BitmapContainer.FindBitmap$1(Prop);
                };
                if (pas.System.Pos("URL://",pas.SysUtils.UpperCase(Prop)) > 0) {
                  pas.System.Delete({get: function () {
                      return Prop;
                    }, set: function (v) {
                      Prop = v;
                    }},1,6);
                  bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromURL(Prop);
                  bmpcreated = true;
                };
                if (pas.System.Pos("DATA:",pas.SysUtils.UpperCase(Prop)) > 0) {
                  if (pas.System.Pos("BASE64,",pas.SysUtils.UpperCase(Prop)) > 0) {
                    pas.System.Delete({get: function () {
                        return Prop;
                      }, set: function (v) {
                        Prop = v;
                      }},1,pas.System.Pos("BASE64,",pas.SysUtils.UpperCase(Prop)) + 6);
                    bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
                    pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.LoadBitmapFromBase64(Prop,bmp,false);
                    bmpcreated = true;
                  };
                };
                imgw = 0;
                imgh = 0;
                if (bmp != null) {
                  if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
                    if ((TagWidth > 0) && (TagHeight > 0)) {
                      imgw = TagWidth;
                      imgh = TagHeight;
                    };
                    if ((TagWidth > 0) && (TagHeight === 0)) {
                      imgw = TagWidth;
                      imgh = Math.round((TagWidth / bmp.GetWidth()) * bmp.GetHeight());
                    };
                    if ((TagWidth === 0) && (TagHeight > 0)) {
                      imgw = Math.round((TagHeight / bmp.GetHeight()) * bmp.GetWidth());
                      imgh = TagHeight;
                    };
                    if ((TagWidth === 0) && (TagHeight === 0)) {
                      imgw = bmp.GetWidth();
                      imgh = bmp.GetHeight();
                    };
                    if (imgfloat === $impl.TTMSFNCHTMLEngineFloatStyle.fsRight) ir.Left = r.Right - imgw;
                    if (!Calc) {
                      if ((TagWidth > 0) || (TagHeight > 0)) {
                        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(ir.Left),Math.round(ir.Top),Math.round(ir.Left) + imgw,Math.round(ir.Top) + imgh)),bmp,true,false,true,false);
                      } else if ((TagWidth > 0) && (TagHeight === 0)) {
                        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(ir.Left),Math.round(ir.Top),Math.round(ir.Left) + TagWidth,Math.round(ir.Top) + TagHeight)),bmp,true,false,true,false);
                      } else {
                        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(ir.Left),Math.round(ir.Top),Math.round(ir.Left) + bmp.GetWidth(),Math.round(ir.Top) + bmp.GetHeight())),bmp,true,false,true,false);
                      };
                    };
                    if ((TagWidth > 0) || (TagHeight > 0)) {
                      IMGSize.x = imgw;
                      IMGSize.y = imgh;
                    } else {
                      IMGSize.x = bmp.GetWidth();
                      IMGSize.y = bmp.GetHeight();
                    };
                  };
                  if (bmpcreated) bmp = rtl.freeLoc(bmp);
                };
                if (((XPos - r.Left) > w.get()) && ((XPos - r.Left) < (w.get() + IMGSize.x)) && (YPos > cr.Top) && (YPos < (cr.Top + IMGSize.y)) && Anchor) {
                  ImageHotSpot.set(true);
                  AnchorVal.set(LastAnchor);
                  AltImg = ImgIdx;
                };
                if (((w.get() + IMGSize.x) > (r.Right - r.Left)) && (IMGSize.x < (r.Right - r.Left))) {
                  imgbreak = true;
                } else {
                  w.set(w.get() + IMGSize.x + 2);
                  cr.Left = cr.Left + IMGSize.x + 2;
                  if (IMGSize.y > h.get()) h.set(IMGSize.y);
                };
                if (pas.System.Pos("ALIGN",TagProp) > 0) {
                  if (pas.System.Pos('"TOP',TagProp) > 0) {
                    rh.$assign(AGraphics.CalculateText$1("gh"));
                    imgali.set(h.get() - (rh.Bottom - rh.Top));
                  } else {
                    if (pas.System.Pos('"MIDDLE',TagProp) > 0) {
                      rh.$assign(AGraphics.CalculateText$1("gh"));
                      imgali.set((h.get() - (rh.Bottom - rh.Top)) / 2);
                    };
                  };
                };
                if (pas.System.Pos("WRAP",TagProp) > 0) {
                  rh.$assign(AGraphics.CalculateText$1("gh"));
                  h.set(rh.Bottom - rh.Top);
                  imgali.set(0);
                };
                if (imgfloat === $impl.TTMSFNCHTMLEngineFloatStyle.fsLeft) {
                  rh.$assign(AGraphics.CalculateText$1("gh"));
                  imgali.set(h.get() - (rh.Bottom - rh.Top));
                  floatrect.Left = imgw;
                  floatrect.Bottom = imgh;
                  if (!Calc) {
                    rh.$assign(AGraphics.CalculateText$1("gh"));
                    h.set(rh.Bottom - rh.Top);
                  };
                };
                if (imgfloat === $impl.TTMSFNCHTMLEngineFloatStyle.fsRight) {
                  rh.$assign(AGraphics.CalculateText$1("gh"));
                  imgali.set(h.get() - (rh.Bottom - rh.Top));
                  floatrect.Right = imgw;
                  floatrect.Bottom = imgh;
                  if (!Calc) {
                    rh.$assign(AGraphics.CalculateText$1("gh"));
                    h.set(rh.Bottom - rh.Top);
                  };
                  w.set(fr.Right);
                };
              };
            } else if ($tmp1 === "L") {
              NewColor = -1;
              LType = "";
              if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(">",s.get(),{get: function () {
                  return TagPos;
                }, set: function (v) {
                  TagPos = v;
                }}) > 0) {
                TagProp = pas.SysUtils.UpperCase(pas.System.Copy(s.get(),3,TagPos - 1));
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("TYPE",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 4,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  LType = Prop;
                };
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("COLOR",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  if (Prop.length > 0) {
                    if (Prop.charAt(0) === "#") {
                      NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(Prop)}
                     else NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.TextToColor(Prop);
                  };
                };
              };
              w.set(w.get() + (12 * ListIndex));
              if (linkbreak) {
                imgbreak = true}
               else linkbreak = true;
              cr.Left = cr.Left + (12 * (ListIndex - 1));
              if (!Calc && !Invisible) {
                if (LType === "") {
                  if (NewColor !== -1) {
                    ColL = AGraphics.FFont.FColor;
                    FontColor = NewColor;
                  };
                  Prop = AGraphics.FFont.FName;
                  fs = rtl.refSet(AGraphics.FFont.FStyle);
                  AGraphics.FFont.SetStyle({});
                  if (pas.System.Odd(ListIndex)) {
                    AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr),"•",false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,false,false,-1,-1)}
                   else AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr),"o",false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,false,false,-1,-1);
                  AGraphics.FFont.SetName(Prop);
                  AGraphics.FFont.SetStyle(rtl.refSet(fs));
                  if (NewColor !== -1) FontColor = ColL;
                } else {
                  ColB = -1;
                  if (LType === "SQUARE") {
                    ColB = AGraphics.FFill.FColor;
                    AGraphics.FStroke.SetColor(NewColor);
                    AGraphics.FFill.SetColor(NewColor);
                    AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
                    AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                    AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(cr.Left,cr.Top + 2,cr.Left + 8,cr.Top + 10)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                    AGraphics.FFill.SetColor(ColB);
                  };
                  if (LType === "CIRCLE") {
                    ColB = AGraphics.FFill.FColor;
                    AGraphics.FStroke.SetColor(NewColor);
                    AGraphics.FFill.SetColor(NewColor);
                    AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
                    AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                    AGraphics.DrawEllipse$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(cr.Left,cr.Top + 2,cr.Left + 8,cr.Top + 10)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                    AGraphics.FFill.SetColor(ColB);
                  };
                };
              };
              cr.Left = cr.Left + 12;
            } else if ($tmp1 === "U") {
              if (s.get().charAt(2) !== ">") {
                ListIndex += 1;
                if (w.get() > 0) linebreak = true;
              } else AGraphics.FFont.SetStyle(rtl.unionSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
            } else if ($tmp1 === "O") {
              TagChar = pas.System.upcase(s.get().charAt(2));
              if (TagChar === "F") {
                TagProp = pas.System.Copy(s.get(),3,pas.System.Pos(">",s.get()) - 1);
                Prop = pas.System.Copy(TagProp,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("x",TagProp) + 2,TagProp.length);
                Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                pas.System.val$6(Prop,NewOffsetX,{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                cr.Left = NewOffsetX.get();
                w.set(NewOffsetX.get());
              };
            } else if ($tmp1 === "P") {
              if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(">",s.get(),{get: function () {
                  return TagPos;
                }, set: function (v) {
                  TagPos = v;
                }}) > 0) {
                TagProp = pas.SysUtils.UpperCase(pas.System.Copy(s.get(),3,TagPos - 1));
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("ALIGN",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  if (pas.System.Pos("RIGHT",Prop) > 0) NewAlign = pas.Classes.TAlignment.taRightJustify;
                  if (pas.System.Pos("LEFT",Prop) > 0) NewAlign = pas.Classes.TAlignment.taLeftJustify;
                  if (pas.System.Pos("CENTER",Prop) > 0) NewAlign = pas.Classes.TAlignment.taCenter;
                  linebreak = NewAlign !== Align.get();
                  if (w.get() === 0) Align.set(NewAlign);
                };
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("INDENT",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 6,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  PIndent.set($impl.IStrToInt(Prop));
                };
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("FLOAT",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  if (Prop === "LEFT") txtfloat.set($impl.TTMSFNCHTMLEngineFloatStyle.fsLeft);
                  if (Prop === "RIGHT") txtfloat.set($impl.TTMSFNCHTMLEngineFloatStyle.fsRight);
                  floatpt.$assign(pas.Types.Point(Math.round(r.Left),Math.round(r.Top)));
                };
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("BGCOLOR",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  NewColor = -1;
                  if (Prop.length > 0) {
                    if (Prop.charAt(0) === "#") {
                      NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(Prop)}
                     else NewColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.TextToColor(Prop);
                  };
                  if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("BGCOLORTO",TagProp,{get: function () {
                      return TagPos;
                    }, set: function (v) {
                      TagPos = v;
                    }}) > 0) {
                    Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    if (!Calc) {
                      isPara = true;
                      AGraphics.FStroke.SetColor(NewColor);
                    };
                  } else {
                    if (!Calc) {
                      isPara = true;
                      paracolor = AGraphics.FFill.FColor;
                      AGraphics.FFill.SetColor(NewColor);
                      pencolor = AGraphics.FStroke.FColor;
                      AGraphics.FStroke.SetColor(NewColor);
                      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
                      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                      AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(fr.Left,r.Top,fr.Right,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                    };
                  };
                };
              };
            } else if ($tmp1 === "F") {
              if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(">",s.get(),{get: function () {
                  return TagPos;
                }, set: function (v) {
                  TagPos = v;
                }}) > 0) {
                if (AGraphics.FFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone) {
                  BGColor = -1}
                 else BGColor = AGraphics.FFill.FColor;
                TagProp = pas.SysUtils.UpperCase(pas.System.Copy(s.get(),6,TagPos - 6));
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("FACE",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 4,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  AGraphics.FFont.SetName(Prop);
                };
                if ((pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(" COLOR",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) && !Selected) {
                  Prop = pas.System.Copy(TagProp,TagPos + 6,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  if (AGraphics.FFill.FColor !== -1) {
                    OldFontColor = AGraphics.FFont.FColor}
                   else OldFontColor = 0;
                  if (Prop.length > 0) {
                    if (Prop.charAt(0) === "#") {
                      FontColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(Prop)}
                     else FontColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.TextToColor(Prop);
                  };
                };
                if ((pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("BGCOLOR",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) && !Calc && !Selected) {
                  Prop = pas.System.Copy(TagProp,TagPos + 7,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                  if (Prop.length > 0) {
                    if (Prop.charAt(0) === "#") {
                      BkColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor(Prop)}
                     else BkColor = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.TextToColor(Prop);
                  };
                };
                if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("STYLE",TagProp,{get: function () {
                    return TagPos;
                  }, set: function (v) {
                    TagPos = v;
                  }}) > 0) {
                  Prop = pas.System.Copy(TagProp,TagPos + 5,TagProp.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos("=",Prop) + 1,Prop.length);
                  Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                  if (pas.System.Pos("FONT-SIZE:",pas.SysUtils.UpperCase(Prop)) > 0) {
                    pas.System.Delete({get: function () {
                        return Prop;
                      }, set: function (v) {
                        Prop = v;
                      }},1,10);
                    if (pas.System.Pos("PT",pas.SysUtils.UpperCase(Prop)) > 0) {
                      Prop = pas.SysUtils.Trim(pas.System.Copy(Prop,1,pas.System.Pos("PT",pas.SysUtils.UpperCase(Prop)) - 1));
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,$impl.IStrToInt(Prop),1);
                    };
                  };
                } else {
                  if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("SIZE",TagProp,{get: function () {
                      return TagPos;
                    }, set: function (v) {
                      TagPos = v;
                    }}) > 0) {
                    Prop = pas.System.Copy(TagProp,TagPos + 4,TagProp.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos("=",Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
                    Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
                    var $tmp4 = $impl.IStrToInt(Prop);
                    if ($tmp4 === 1) {
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,8,1)}
                     else if ($tmp4 === 2) {
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,10,1)}
                     else if ($tmp4 === 3) {
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,12,1)}
                     else if ($tmp4 === 4) {
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,14,1)}
                     else if ($tmp4 === 5) {
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,16,1)}
                     else {
                      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,$impl.IStrToInt(Prop),1);
                    };
                  };
                };
              };
            } else if ($tmp1 === "S") {
              TagChar = pas.System.upcase(s.get().charAt(2));
              if (TagChar === ">") {
                AGraphics.FFont.SetStyle(rtl.unionSet(AGraphics.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)))}
               else {
                if (TagChar === "H") {
                  isShad = true}
                 else {
                  if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("<SUB>",s.get()) === 1) {
                    isSub = true}
                   else if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("<SUP>",s.get()) === 1) isSup = true;
                };
              };
            } else if ($tmp1 === "R") {
              TagProp = pas.System.Copy(s.get(),3,pas.System.Pos(">",s.get()) - 1);
              Prop = pas.System.Copy(TagProp,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IPos("a",TagProp) + 2,TagProp.length);
              Prop = pas.System.Copy(Prop,pas.System.Pos('"',Prop) + 1,Prop.length);
              Prop = pas.System.Copy(Prop,1,pas.System.Pos('"',Prop) - 1);
            } else if ($tmp1 === "Z") Invisible = true;
          };
          if ((pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(">",s.get(),{get: function () {
              return TagPos;
            }, set: function (v) {
              TagPos = v;
            }}) > 0) && !imgbreak) {
            Res = Res + pas.System.Copy(s.get(),1,TagPos);
            pas.System.Delete(s,1,TagPos);
          } else if (!imgbreak) pas.System.Delete(s,1,s.get().length);
        };
      };
      w.set(w.get() - sw);
      if (w.get() > XSize.get()) XSize.set(w.get() + 2);
      if ((FocusLink === (HyperLinks.get() - 1)) && Anchor && !Calc) {
        rr.Right = cr.Left;
        rr.Bottom = cr.Bottom;
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(rr,1,0);
        rr.Left = r.Left + 1;
        rr.Top = rr.Bottom;
      };
      Result = Res;
      return Result;
    };
    Anchor = false;
    error = false;
    OldFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
    OldFont.AssignSource(AGraphics.FFont);
    OldFontColor = AGraphics.FFont.FColor;
    DrawFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
    DrawFont.AssignSource(AGraphics.FFont);
    DrawFontCOlor = AGraphics.FFont.FColor;
    CalcFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
    CalcFont.AssignSource(AGraphics.FFont);
    CalcFontColor = AGraphics.FFont.FColor;
    OldDrawFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
    OldDrawFont.AssignSource(AGraphics.FFont);
    OldDrawFontColor = AGraphics.FFont.FColor;
    OldCalcFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
    OldCalcFont.AssignSource(AGraphics.FFont);
    OldCalcFontColor = AGraphics.FFont.FColor;
    blnkcolor = AGraphics.FFill.FColor;
    OldPenColor = AGraphics.FStroke.FColor;
    blnkKind = AGraphics.FFill.FKind;
    OldPenKind = AGraphics.FStroke.FKind;
    BGColor = -1;
    BkColor = -1;
    paracolor = -1;
    isPara = false;
    isShad = false;
    Invisible = false;
    ControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
    CV.set("");
    CT.set("");
    if (!CheckHotSpot) CID.set("");
    ofsx = 0;
    newofsx = 0;
    txtfloat = $impl.TTMSFNCHTMLEngineFloatStyle.fsNone;
    floatrect.$assign(pas.Types.Rect(0,0,0,0));
    Result = false;
    r.$assign(fr);
    Align = pas.Classes.TAlignment.taLeftJustify;
    PIndent = 0;
    XSize.set(0);
    YSize.set(0);
    HyperLinks.set(0);
    hlcount = 0;
    ListIndex = 0;
    licount = 0;
    StripVal.set("");
    FocusAnchor.set("");
    MouseLink.set(-1);
    MouseInAnchor = false;
    ImgIdx = 0;
    AltImg = -1;
    if (pas.System.Pos("&",s) > 0) {
      s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnFixMarkup(s,true,true);
      do {
        FoundTag = false;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.TagReplaceString("&amp;","&",{get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }})) FoundTag = true;
      } while (FoundTag);
    };
    s = $impl.DBTagStrip(s);
    s = $impl.UnicodeTagStrip(s);
    s = $impl.CRLFStrip(s,true);
    inspoint = 0;
    LineCount.set(0);
    while (s.length > 0) {
      OldFont.AssignSource(OldCalcFont);
      OldFontColor = OldCalcFontColor;
      AGraphics.FFont.AssignSource(CalcFont);
      FontColor = CalcFontColor;
      OldAnchor = Anchor;
      OldAnchorVal = LastAnchor;
      suph = 0;
      subh = 0;
      imgali = 0;
      isSup = false;
      isSub = false;
      Hotspot = false;
      ImageHotspot = false;
      htmlwidth = 0;
      rh.$assign(AGraphics.CalculateText$1("gh"));
      htmlheight = rh.Bottom - rh.Top;
      txtheight = htmlheight;
      OldImgIdx = ImgIdx;
      s = pas.SysUtils.Trim(s);
      txtfloatbefore = txtfloat;
      su = HTMLDrawLine(AGraphics,{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),true,{get: function () {
          return htmlwidth;
        }, set: function (v) {
          htmlwidth = v;
        }},{get: function () {
          return htmlheight;
        }, set: function (v) {
          htmlheight = v;
        }},{get: function () {
          return subh;
        }, set: function (v) {
          subh = v;
        }},{get: function () {
          return suph;
        }, set: function (v) {
          suph = v;
        }},{get: function () {
          return imgali;
        }, set: function (v) {
          imgali = v;
        }},{get: function () {
          return Align;
        }, set: function (v) {
          Align = v;
        }},{get: function () {
          return PIndent;
        }, set: function (v) {
          PIndent = v;
        }},XPos,YPos,{get: function () {
          return Hotspot;
        }, set: function (v) {
          Hotspot = v;
        }},{get: function () {
          return ImageHotspot;
        }, set: function (v) {
          ImageHotspot = v;
        }},ofsx,{get: function () {
          return newofsx;
        }, set: function (v) {
          newofsx = v;
        }},floatrect,{get: function () {
          return txtfloat;
        }, set: function (v) {
          txtfloat = v;
        }});
      LineCount.set(LineCount.get() + 1);
      Anchor = OldAnchor;
      LastAnchor = OldAnchorVal;
      CalcFont.AssignSource(AGraphics.FFont);
      CalcFontColor = AGraphics.FFont.FColor;
      OldCalcFont.AssignSource(OldFont);
      OldCalcFontColor = OldFontColor;
      htmlheight = htmlheight + LineSpacing;
      dr.$assign(r);
      var $tmp = Align;
      if ($tmp === pas.Classes.TAlignment.taCenter) {
        if ((r.Right - r.Left - htmlwidth) > 0) dr.Left = r.Left + ((r.Right - r.Left - htmlwidth) / 2)}
       else if ($tmp === pas.Classes.TAlignment.taRightJustify) if ((r.Right - htmlwidth) > r.Left) dr.Left = r.Right - htmlwidth;
      dr.Left = dr.Left + PIndent;
      dr.Right = dr.Right + PIndent;
      dr.Bottom = dr.Top + htmlheight + subh + suph;
      if (!CheckHeight) {
        OldFont.AssignSource(OldDrawFont);
        OldFontColor = OldDrawFontColor;
        AGraphics.FFont.AssignSource(DrawFont);
        FontColor = DrawFontCOlor;
        HyperLinks.set(hlcount);
        ListIndex = licount;
        ImgIdx = OldImgIdx;
        HTMLDrawLine(AGraphics,{get: function () {
            return su;
          }, set: function (v) {
            su = v;
          }},pas["WEBLib.TMSFNCTypes"].TRectF.$clone(dr),CheckHotSpot,{get: function () {
            return htmlwidth;
          }, set: function (v) {
            htmlwidth = v;
          }},{get: function () {
            return htmlheight;
          }, set: function (v) {
            htmlheight = v;
          }},{get: function () {
            return subh;
          }, set: function (v) {
            subh = v;
          }},{get: function () {
            return suph;
          }, set: function (v) {
            suph = v;
          }},{get: function () {
            return imgali;
          }, set: function (v) {
            imgali = v;
          }},{get: function () {
            return Align;
          }, set: function (v) {
            Align = v;
          }},{get: function () {
            return PIndent;
          }, set: function (v) {
            PIndent = v;
          }},XPos,YPos,{get: function () {
            return Hotspot;
          }, set: function (v) {
            Hotspot = v;
          }},{get: function () {
            return ImageHotspot;
          }, set: function (v) {
            ImageHotspot = v;
          }},ofsx,{get: function () {
            return newofsx;
          }, set: function (v) {
            newofsx = v;
          }},floatrect,{get: function () {
            return txtfloat;
          }, set: function (v) {
            txtfloat = v;
          }});
        hlcount = HyperLinks.get();
        licount = ListIndex;
        r.Left = fr.Left + floatrect.Left;
        r.Right = fr.Right - floatrect.Right;
        if (dr.Top > floatrect.Bottom) {
          floatrect.Left = 0;
          floatrect.Right = 0;
          r.Left = fr.Left;
        };
        rh.$assign(AGraphics.CalculateText$1("gh"));
        if ((Hotspot && (YPos > (dr.Bottom - imgali - (rh.Bottom - rh.Top))) && (YPos < (dr.Bottom - imgali))) || ImageHotspot) {
          Result = true;
        };
        ofsx = newofsx;
        DrawFont.AssignSource(AGraphics.FFont);
        DrawFontCOlor = FontColor;
        OldDrawFont.AssignSource(OldFont);
        OldDrawFontColor = OldFontColor;
      };
      if ((txtfloat !== $impl.TTMSFNCHTMLEngineFloatStyle.fsNone) && (txtfloat !== txtfloatbefore)) {
        r.Left = floatpt.x;
        r.Top = floatpt.y;
        txtfloat = $impl.TTMSFNCHTMLEngineFloatStyle.fsNone;
      } else {
        r.Top = r.Top + htmlheight + subh + suph;
        YSize.set(YSize.get() + htmlheight + subh + suph);
      };
      if (((r.Top + txtheight) > (r.Bottom + 1)) && !CheckHeight) s = "";
    };
    if (YSize.get() === 0) {
      rh.$assign(AGraphics.CalculateText$1("gh"));
      YSize.set(rh.Bottom - rh.Top);
    };
    inspoint = inspoint >>> 1;
    AGraphics.FStroke.SetKind(OldPenKind);
    AGraphics.FFill.SetKind(blnkKind);
    AGraphics.FStroke.SetColor(OldPenColor);
    AGraphics.FFill.SetColor(blnkcolor);
    AGraphics.FFont.AssignSource(OldFont);
    OldFont = rtl.freeLoc(OldFont);
    DrawFont = rtl.freeLoc(DrawFont);
    CalcFont = rtl.freeLoc(CalcFont);
    OldDrawFont = rtl.freeLoc(OldDrawFont);
    OldCalcFont = rtl.freeLoc(OldCalcFont);
    return Result;
  };
  this.HiLight = function (s, h, tag, DoCase, FullText) {
    var Result = "";
    var hs = "";
    var l = 0;
    var k = 0;
    var m = 0;
    var IsHTML = false;
    tag = pas.SysUtils.UpperCase(tag);
    hs = pas.SysUtils.UpperCase(s);
    l = pas.System.Pos("<" + tag + ">",hs);
    while (l > 0) {
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},l,tag.length + 2);
      pas.System.Delete({get: function () {
          return hs;
        }, set: function (v) {
          hs = v;
        }},l,tag.length + 2);
      l = pas.System.Pos("<" + tag + ">",hs);
    };
    l = pas.System.Pos("</" + tag + ">",hs);
    while (l > 0) {
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},l,tag.length + 3);
      pas.System.Delete({get: function () {
          return hs;
        }, set: function (v) {
          hs = v;
        }},l,tag.length + 3);
      l = pas.System.Pos("</" + tag + ">",hs);
    };
    if (!DoCase) h = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(h);
    IsHTML = pas.System.Pos("</",s) > 0;
    if (IsHTML) {
      hs = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnFixMarkup($impl.HTMLStripAll(s),true,false)}
     else hs = s;
    if (!DoCase) hs = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(hs);
    Result = "";
    if (FullText) {
      if (h === hs) if (IsHTML) {
        s = "<" + tag + ">" + s + "</" + tag + ">"}
       else s = "<" + tag + ">" + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(s,true) + "</" + tag + ">";
    } else if (!IsHTML) {
      l = pas.System.Pos(h,hs);
      if (l > 0) {
        do {
          Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(pas.System.Copy(s,1,l - 1),false) + "<" + tag + ">" + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(pas.System.Copy(s,l,h.length),false) + "</" + tag + ">";
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,(l + h.length) - 1);
          pas.System.Delete({get: function () {
              return hs;
            }, set: function (v) {
              hs = v;
            }},1,(l + h.length) - 1);
          l = pas.System.Pos(h,hs);
        } while (!(l === 0));
        s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(s,false);
      };
    } else {
      l = pas.System.Pos(h,hs);
      while (l > 0) {
        pas.System.Delete({get: function () {
            return hs;
          }, set: function (v) {
            hs = v;
          }},1,(l + h.length) - 1);
        do {
          k = pas.System.Pos("<",s);
          m = pas.System.Pos("&",s);
          while (((k > 0) && (k <= l)) || ((m > 0) && (m < l))) {
            if ((k > 0) && ((m <= 0) || (k < m))) {
              Result = Result + pas.System.Copy(s,1,k - 1);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,k - 1);
              l = l - (k - 1);
              m = m - (k - 1);
              k = pas.System.Pos(">",s);
              if (k === 0) k = s.length;
              Result = Result + pas.System.Copy(s,1,k);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,k);
              m = m - k;
              k = pas.System.Pos("<",s);
            } else {
              Result = Result + pas.System.Copy(s,1,m - 1);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,m - 1);
              l = l - (m - 1) - 1;
              k = k - (m - 1);
              m = pas.System.Pos(";",s);
              l = (l - m) + 1;
              if (m === 0) m = s.length;
              Result = Result + pas.System.Copy(s,1,m);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,m);
              k = k - m;
              m = pas.System.Pos("&",s);
            };
          };
          Result = Result + pas.System.Copy(s,1,l - 1) + "<" + tag + ">";
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,l - 1);
          k = k - (l - 1);
          m = m - (l - 1);
          l = h.length;
          while ((((k > 0) && (k <= l)) || ((m > 0) && (m <= l))) && (l > 0) && (s !== "")) {
            if ((k > 0) && ((m <= 0) || (k < m))) {
              Result = Result + pas.System.Copy(s,1,k - 1);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,k - 1);
              l = l - (k - 1);
              m = m - (k - 1);
              k = pas.System.Pos(">",s);
              if (k === 0) k = s.length;
              Result = Result + pas.System.Copy(s,1,k);
              if (pas.SysUtils.UpperCase(pas.System.Copy(s,1,6)) === "</FONT") Result = Result + "</" + tag + "><" + tag + ">";
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,k);
              m = m - k;
              k = pas.System.Pos("<",s);
            } else {
              Result = Result + pas.System.Copy(s,1,m - 1);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,m - 1);
              l = l - (m - 1) - 1;
              k = k - (m - 1);
              m = pas.System.Pos(";",s);
              if (m === 0) m = s.length;
              Result = Result + pas.System.Copy(s,1,m);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,m);
              k = k - m;
              m = pas.System.Pos("&",s);
            };
          };
          if (l > 0) {
            Result = Result + pas.System.Copy(s,1,l);
            pas.System.Delete({get: function () {
                return s;
              }, set: function (v) {
                s = v;
              }},1,l);
          };
          Result = Result + "</" + tag + ">";
          l = 0;
        } while (!(l === 0));
        l = pas.System.Pos(h,hs);
      };
    };
    Result = Result + s;
    return Result;
  };
  this.UnHiLight = function (s, tag) {
    var Result = "";
    var IsHTML = false;
    var WasHTML = false;
    Result = "";
    WasHTML = pas.System.Pos("</",s) > 0;
    tag = pas.SysUtils.UpperCase(tag);
    while (pas.System.Pos("<" + tag + ">",pas.SysUtils.UpperCase(s)) > 0) s = pas.SysUtils.StringReplace(s,"<" + tag + ">","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
    while (pas.System.Pos("</" + tag + ">",pas.SysUtils.UpperCase(s)) > 0) s = pas.SysUtils.StringReplace(s,"</" + tag + ">","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
    IsHTML = pas.System.Pos("</",s) > 0;
    if (WasHTML && !IsHTML) s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnFixMarkup(s,false,false);
    Result = s;
    return Result;
  };
  this.GetControlValue = function (HTML, ControlID, ControlValue) {
    var Result = false;
    var lp = 0;
    var Tag = "";
    var CType = "";
    var CID = "";
    var CV = "";
    var CW = "";
    var CH = "";
    var CP = "";
    var CL = "";
    Result = false;
    lp = 0;
    while ($impl.VarIPos("<CONTROL ",HTML,{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return HTML;
        }, set: function (v) {
          HTML = v;
        }},1,lp);
      Tag = pas.System.Copy(HTML,1,pas.System.Pos(">",HTML));
      CType = "";
      CID = "";
      CV = "";
      CW = "";
      CH = "";
      CP = "";
      CL = "";
      $mod.ParseControl(Tag,{get: function () {
          return CType;
        }, set: function (v) {
          CType = v;
        }},{get: function () {
          return CID;
        }, set: function (v) {
          CID = v;
        }},{get: function () {
          return CV;
        }, set: function (v) {
          CV = v;
        }},{get: function () {
          return CW;
        }, set: function (v) {
          CW = v;
        }},{get: function () {
          return CH;
        }, set: function (v) {
          CH = v;
        }},{get: function () {
          return CP;
        }, set: function (v) {
          CP = v;
        }},{get: function () {
          return CL;
        }, set: function (v) {
          CL = v;
        }});
      if (ControlID === CID) {
        ControlValue.set(CV);
        Result = true;
        return Result;
      };
    };
    return Result;
  };
  this.GetControlProp = function (HTML, ControlID) {
    var Result = "";
    var lp = 0;
    var Tag = "";
    var CType = "";
    var CID = "";
    var CV = "";
    var CW = "";
    var CH = "";
    var CP = "";
    var CL = "";
    Result = "";
    lp = 0;
    while ($impl.VarIPos("<CONTROL ",HTML,{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return HTML;
        }, set: function (v) {
          HTML = v;
        }},1,lp);
      Tag = pas.System.Copy(HTML,1,pas.System.Pos(">",HTML));
      CType = "";
      CID = "";
      CV = "";
      CW = "";
      CH = "";
      CP = "";
      CL = "";
      $mod.ParseControl(Tag,{get: function () {
          return CType;
        }, set: function (v) {
          CType = v;
        }},{get: function () {
          return CID;
        }, set: function (v) {
          CID = v;
        }},{get: function () {
          return CV;
        }, set: function (v) {
          CV = v;
        }},{get: function () {
          return CW;
        }, set: function (v) {
          CW = v;
        }},{get: function () {
          return CH;
        }, set: function (v) {
          CH = v;
        }},{get: function () {
          return CP;
        }, set: function (v) {
          CP = v;
        }},{get: function () {
          return CL;
        }, set: function (v) {
          CL = v;
        }});
      if (ControlID === CID) {
        Result = CP;
        return Result;
      };
    };
    return Result;
  };
  this.GetControlMaxLen = function (HTML, ControlID) {
    var Result = 0;
    var lp = 0;
    var e = 0;
    var Tag = "";
    var CType = "";
    var CID = "";
    var CV = "";
    var CW = "";
    var CH = "";
    var CP = "";
    var CL = "";
    Result = 0;
    lp = 0;
    e = 0;
    while ($impl.VarIPos("<CONTROL ",HTML,{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return HTML;
        }, set: function (v) {
          HTML = v;
        }},1,lp);
      Tag = pas.System.Copy(HTML,1,pas.System.Pos(">",HTML));
      CType = "";
      CID = "";
      CV = "";
      CW = "";
      CH = "";
      CP = "";
      CL = "";
      $mod.ParseControl(Tag,{get: function () {
          return CType;
        }, set: function (v) {
          CType = v;
        }},{get: function () {
          return CID;
        }, set: function (v) {
          CID = v;
        }},{get: function () {
          return CV;
        }, set: function (v) {
          CV = v;
        }},{get: function () {
          return CW;
        }, set: function (v) {
          CW = v;
        }},{get: function () {
          return CH;
        }, set: function (v) {
          CH = v;
        }},{get: function () {
          return CP;
        }, set: function (v) {
          CP = v;
        }},{get: function () {
          return CL;
        }, set: function (v) {
          CL = v;
        }});
      if (ControlID === CID) {
        pas.System.val$6(CL,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},{get: function () {
            return e;
          }, set: function (v) {
            e = v;
          }});
        return Result;
      };
    };
    return Result;
  };
  this.SetControlValue = function (HTML, ControlID, ControlValue) {
    var Result = false;
    var lp = 0;
    var Tag = "";
    var Temp = "";
    var CType = "";
    var CID = "";
    var CV = "";
    var CW = "";
    var CH = "";
    var CP = "";
    var CL = "";
    Result = false;
    Temp = "";
    ControlValue = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(ControlValue,true);
    lp = 0;
    while ($impl.VarIPos("<CONTROL ",HTML.get(),{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0) {
      Temp = Temp + pas.System.Copy(HTML.get(),1,lp);
      pas.System.Delete(HTML,1,lp);
      Tag = pas.System.Copy(HTML.get(),1,pas.System.Pos(">",HTML.get()));
      CType = "";
      CID = "";
      CV = "";
      CW = "";
      CH = "";
      CP = "";
      CL = "";
      $mod.ParseControl(Tag,{get: function () {
          return CType;
        }, set: function (v) {
          CType = v;
        }},{get: function () {
          return CID;
        }, set: function (v) {
          CID = v;
        }},{get: function () {
          return CV;
        }, set: function (v) {
          CV = v;
        }},{get: function () {
          return CW;
        }, set: function (v) {
          CW = v;
        }},{get: function () {
          return CH;
        }, set: function (v) {
          CH = v;
        }},{get: function () {
          return CP;
        }, set: function (v) {
          CP = v;
        }},{get: function () {
          return CL;
        }, set: function (v) {
          CL = v;
        }});
      if (ControlID === CID) {
        Temp = Temp + "CONTROL ID=" + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + ControlID + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + " VALUE=" + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + ControlValue + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + " WIDTH=" + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + CW + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + " TYPE=" + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + CType + $mod.TMSFNCHTMLENGINE_ATTR_DELIM;
        if (CP !== "") Temp = Temp + " PROP=" + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(CP,true) + $mod.TMSFNCHTMLENGINE_ATTR_DELIM;
        if (CL !== "") Temp = Temp + " MAXLEN=" + $mod.TMSFNCHTMLENGINE_ATTR_DELIM + CL + $mod.TMSFNCHTMLENGINE_ATTR_DELIM;
        Temp = Temp + ">";
        HTML.set(Temp + pas.System.Copy(HTML.get(),pas.System.Pos(">",HTML.get()) + 1,HTML.get().length));
        Result = true;
        return Result;
      };
    };
    return Result;
  };
  this.ClearRadioControls = function (HTML) {
    var Result = "";
    var lp = 0;
    var Tag = "";
    var CType = "";
    var CID = "";
    var CV = "";
    var CW = "";
    var CH = "";
    var CP = "";
    var CL = "";
    var sl = null;
    var s = "";
    Result = "";
    s = HTML;
    sl = pas.Classes.TStringList.$create("Create$1");
    lp = 0;
    while ($impl.VarIPos("<CONTROL ",HTML,{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return HTML;
        }, set: function (v) {
          HTML = v;
        }},1,lp);
      Tag = pas.System.Copy(HTML,1,pas.System.Pos(">",HTML));
      CType = "";
      CID = "";
      CV = "";
      CW = "";
      CH = "";
      CP = "";
      CL = "";
      $mod.ParseControl(Tag,{get: function () {
          return CType;
        }, set: function (v) {
          CType = v;
        }},{get: function () {
          return CID;
        }, set: function (v) {
          CID = v;
        }},{get: function () {
          return CV;
        }, set: function (v) {
          CV = v;
        }},{get: function () {
          return CW;
        }, set: function (v) {
          CW = v;
        }},{get: function () {
          return CH;
        }, set: function (v) {
          CH = v;
        }},{get: function () {
          return CP;
        }, set: function (v) {
          CP = v;
        }},{get: function () {
          return CL;
        }, set: function (v) {
          CL = v;
        }});
      if (CType === "RADIO") sl.Add(CID);
    };
    for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
      lp = $l;
      $mod.SetControlValue({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},sl.Get(lp),"FALSE");
    };
    sl = rtl.freeLoc(sl);
    Result = s;
    return Result;
  };
  this.GetNextControlID = function (HTML, ControlID) {
    var Result = "";
    var lp = 0;
    var Tag = "";
    var CType = "";
    var CID = "";
    var CV = "";
    var CW = "";
    var CH = "";
    var CP = "";
    var CL = "";
    var flg = false;
    Result = "";
    flg = ControlID === "";
    lp = 0;
    while ($impl.VarIPos("<CONTROL ",HTML,{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return HTML;
        }, set: function (v) {
          HTML = v;
        }},1,lp);
      Tag = pas.System.Copy(HTML,1,pas.System.Pos(">",HTML));
      CType = "";
      CID = "";
      CV = "";
      CW = "";
      CH = "";
      CP = "";
      CL = "";
      $mod.ParseControl(Tag,{get: function () {
          return CType;
        }, set: function (v) {
          CType = v;
        }},{get: function () {
          return CID;
        }, set: function (v) {
          CID = v;
        }},{get: function () {
          return CV;
        }, set: function (v) {
          CV = v;
        }},{get: function () {
          return CW;
        }, set: function (v) {
          CW = v;
        }},{get: function () {
          return CH;
        }, set: function (v) {
          CH = v;
        }},{get: function () {
          return CP;
        }, set: function (v) {
          CP = v;
        }},{get: function () {
          return CL;
        }, set: function (v) {
          CL = v;
        }});
      if (flg && (CType !== "BUTTON") && (CType !== "CHECK") && (CType !== "RADIO")) {
        Result = CID;
        return Result;
      };
      if (ControlID === CID) flg = true;
    };
    return Result;
  };
  this.HasHTMLControl = function (HTML) {
    var Result = false;
    var lp = 0;
    lp = 0;
    Result = $impl.VarIPos("<CONTROL",HTML,{get: function () {
        return lp;
      }, set: function (v) {
        lp = v;
      }}) > 0;
    return Result;
  };
  this.ParseControl = function (Tag, ControlType, ControlID, ControlValue, ControlWidth, ControlHeight, ControlProp, ControlLen) {
    var Prop = "";
    var vp = 0;
    ControlType.set("");
    ControlWidth.set("");
    ControlHeight.set("");
    ControlValue.set("");
    ControlID.set("");
    ControlProp.set("");
    ControlLen.set("");
    vp = 0;
    if ($impl.VarIPos("TYPE=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlType.set(pas.SysUtils.UpperCase(Prop));
    };
    if ($impl.VarIPos("WIDTH=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlWidth.set(Prop);
    };
    if ($impl.VarIPos("HEIGHT=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlHeight.set(Prop);
    };
    if ($impl.VarIPos("ID=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlID.set(Prop);
    };
    if ($impl.VarIPos("VALUE=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlValue.set(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnFixMarkup(Prop,true,false));
    };
    if ($impl.VarIPos("PROP=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlProp.set(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnFixMarkup(Prop,true,false));
    };
    if ($impl.VarIPos("MAXLEN=",Tag,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Prop = pas.System.Copy(Tag,vp + 1,Tag.length);
      Prop = pas.System.Copy(Prop,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) + 1,Prop.length);
      Prop = pas.System.Copy(Prop,1,pas.System.Pos($mod.TMSFNCHTMLENGINE_ATTR_DELIM,Prop) - 1);
      ControlLen.set(Prop);
    };
  };
  $mod.$implcode = function () {
    $impl.TTMSFNCHTMLEngineFloatStyle = {"0": "fsNone", fsNone: 0, "1": "fsLeft", fsLeft: 1, "2": "fsRight", fsRight: 2};
    $mod.$rtti.$Enum("TTMSFNCHTMLEngineFloatStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: $impl.TTMSFNCHTMLEngineFloatStyle});
    $impl.VarIPos = function (su, s, Res) {
      var Result = 0;
      Res.set(pas.System.Pos(su,pas.SysUtils.UpperCase(s)));
      Result = Res.get();
      return Result;
    };
    $impl.HTMLStripAll = function (s) {
      var Result = "";
      var TagPos = 0;
      var PTP = 0;
      Result = "";
      while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("<",s,{get: function () {
          return TagPos;
        }, set: function (v) {
          TagPos = v;
        }}) > 0) {
        PTP = TagPos;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(">",s,{get: function () {
            return TagPos;
          }, set: function (v) {
            TagPos = v;
          }}) > PTP) {
          Result = Result + pas.System.Copy(s,1,PTP - 1);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,TagPos);
        } else break;
      };
      Result = Result + s;
      return Result;
    };
    $impl.IStrToInt = function (s) {
      var Result = 0;
      var Err = 0;
      var Res = 0;
      pas.System.val$6(s,{get: function () {
          return Res;
        }, set: function (v) {
          Res = v;
        }},{get: function () {
          return Err;
        }, set: function (v) {
          Err = v;
        }});
      Result = Res;
      return Result;
    };
    $impl.DBTagStrip = function (s) {
      var Result = "";
      var i = 0;
      var j = 0;
      i = pas.System.Pos("<#",s);
      if (i > 0) {
        Result = pas.System.Copy(s,1,i - 1);
        pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},1,i);
        j = pas.System.Pos(">",s);
        if (j > 0) pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},j,1);
        Result = Result + s;
      } else Result = s;
      return Result;
    };
    $impl.HexVal = function (s) {
      var Result = 0;
      var i = 0;
      var j = 0;
      if (s.length < 2) {
        Result = 0;
        return Result;
      };
      if (s.charAt(0) >= "A") {
        i = (s.charCodeAt(1 - 1) - 65) + 10}
       else i = s.charCodeAt(1 - 1) - 48;
      if (s.charAt(1) >= "A") {
        j = (s.charCodeAt(2 - 1) - 65) + 10}
       else j = s.charCodeAt(2 - 1) - 48;
      Result = (i << 4) + j;
      return Result;
    };
    $impl.UnicodeTagStrip = function (s) {
      var Result = "";
      var i = 0;
      var j = 0;
      var k = 0;
      var e = 0;
      var nn = 0;
      var su = "";
      var res = "";
      var w = 0;
      var ishex = false;
      function NonNum(aval, dohex) {
        var Result = 0;
        var i = 0;
        var ofs = 0;
        if (dohex) {
          ofs = 4}
         else ofs = 3;
        Result = ofs;
        for (var $l = ofs, $end = aval.length; $l <= $end; $l++) {
          i = $l;
          if (!((aval.charAt(i - 1) >= "0") && (aval.charAt(i - 1) <= "9"))) {
            Result = i;
            break;
          };
          if (dohex && !((aval.charAt(i - 1) >= "A") && (aval.charAt(i - 1) <= "F")) && dohex && !((aval.charAt(i - 1) >= "a") && (aval.charAt(i - 1) <= "f"))) {
            Result = i;
            break;
          };
        };
        return Result;
      };
      res = "";
      do {
        i = pas.System.Pos("&#",s);
        k = pas.System.Pos("&&#",s);
        if ((k === (i - 1)) && (k !== 0)) i = 0;
        if (i > 0) {
          res = res + pas.System.Copy(s,1,i - 1);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,i - 1);
          ishex = pas.System.Pos("&#x",s) === 1;
          j = pas.System.Pos(";",s);
          if (j > 7) {
            nn = NonNum(s,ishex);
            j = nn;
          };
          if (j > 0) {
            if (ishex) {
              su = pas.System.Copy(s,4,j - 4);
              try {
                w = $impl.HexVal(su);
                e = 0;
              } catch ($e) {
                w = 0;
              };
            } else {
              su = pas.System.Copy(s,3,j - 3);
              pas.System.val$6(su,{get: function () {
                  return w;
                }, set: function (v) {
                  w = v;
                }},{get: function () {
                  return e;
                }, set: function (v) {
                  e = v;
                }});
            };
            if ((su.length > 0) && (su.length <= 6) && (e === 0)) {
              res = res + String.fromCharCode(w);
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,j);
            };
          } else {
            res = res + "&#";
            pas.System.Delete({get: function () {
                return s;
              }, set: function (v) {
                s = v;
              }},1,2);
          };
        } else res = res + s;
      } while (!(i <= 0));
      Result = res;
      return Result;
    };
    $impl.CRLFStrip = function (s, Break) {
      var Result = "";
      var i = 0;
      Result = "";
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        if (!((s.charAt(i - 1) === "\r") || (s.charAt(i - 1) === "\n"))) {
          Result = Result + s.charAt(i - 1)}
         else if ((s.charAt(i - 1) === "\r") && Break) Result = Result + "<BR>";
      };
      return Result;
    };
    $impl.IsCJKChar = function (C) {
      var Result = false;
      Result = false;
      if (C < "✐") return Result;
      var $tmp = C.charCodeAt() & 0xFFFFFFFF;
      if ((($tmp >= 0x4E00) && ($tmp <= 0x9FFF)) || (($tmp >= 0x3400) && ($tmp <= 0x4DBF)) || (($tmp >= 0x20000) && ($tmp <= 0x2A6DF)) || (($tmp >= 0x2A700) && ($tmp <= 0x2B73F)) || (($tmp >= 0x2B740) && ($tmp <= 0x2B81F)) || (($tmp >= 0x2B820) && ($tmp <= 0x2CEAF)) || (($tmp >= 0xF900) && ($tmp <= 0xFAFF)) || (($tmp >= 0x2F800) && ($tmp <= 0x2FA1F))) Result = true;
      return Result;
    };
    $impl.PosBreak = function (A) {
      var Result = 0;
      var I = 0;
      var C = "\x00";
      Result = 0;
      for (var $l = 1, $end = A.length; $l <= $end; $l++) {
        I = $l;
        C = A.charAt(I - 1);
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.CharInSet(C,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.CreateCharSet(" ")) || $impl.IsCJKChar(C)) {
          Result = I;
          break;
        };
      };
      return Result;
    };
  };
},["SysUtils","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCGraphics.General",["System","Classes","WEBLib.TMSFNCGraphicsTypes","Types","WEBLib.Graphics","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TTMSFNCGraphicsContextGeneral",pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphicsContext,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphicsContext.$init.call(this);
      this.FPrinting = false;
      this.FOldPenStyle = 0;
      this.FOldPenWidth = 0;
    };
    this.GetNativeCanvas = function () {
      var Result = null;
      Result = this.GetCanvas();
      return Result;
    };
    this.DrawRotatedText = function (ACanvas, ARect, AText, AAngle, AHorizontalAlign, AVerticalAlign) {
      var tw = 0.0;
      var th = 0.0;
      var so = 0;
      var s = "";
      var xs = 0.0;
      var ys = 0.0;
      var angle = 0.0;
      var ha = 0;
      var va = 0;
      var r = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      s = AText;
      angle = -10 * AAngle;
      xs = ARect.Left;
      ys = ARect.Top;
      tw = ACanvas.TextWidth(s);
      th = ACanvas.TextHeight(s);
      var $tmp = AHorizontalAlign;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
        ha = pas.Classes.TAlignment.taLeftJustify}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
        ha = pas.Classes.TAlignment.taCenter}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) ha = pas.Classes.TAlignment.taRightJustify;
      var $tmp1 = AVerticalAlign;
      if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
        va = pas["WEBLib.Graphics"].TVerticalAlignment.taVerticalCenter}
       else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
        va = pas["WEBLib.Graphics"].TVerticalAlignment.taAlignTop}
       else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) va = pas["WEBLib.Graphics"].TVerticalAlignment.taAlignBottom;
      r.$assign(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      ACanvas.TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(r),s,false,false,ha,va);
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.GetFillColor = function () {
      var Result = 0;
      Result = this.GetCanvas().FBrush.FColor;
      return Result;
    };
    this.CalculateText = function (AText, ARect, AWordWrapping) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      r.$assign(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      r.$assign(this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(r),AText,AWordWrapping,true,pas.Classes.TAlignment.taLeftJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignTop));
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right,r.Bottom));
      return Result;
    };
    this.SetTextAngle = function (ARect, AAngle) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ar = 0.0;
      var cx = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var c = 0.0;
      var s = 0.0;
      var w = 0.0;
      var cw = 0.0;
      var h = 0.0;
      var ch = 0.0;
      Result.$assign(ARect);
      if (AAngle !== 0) {
        ar = pas.Math.DegToRad(AAngle);
        cx.X = Result.Left + ((Result.Right - Result.Left) / 2);
        cx.Y = Result.Top + ((Result.Bottom - Result.Top) / 2);
        this.GetCanvas().Transform(Math.cos(ar),Math.sin(ar),-Math.sin(ar),Math.cos(ar),cx.X,cx.Y);
        w = Result.Right - Result.Left;
        h = Result.Bottom - Result.Top;
        c = Math.cos(ar);
        s = Math.sin(ar);
        cw = Math.abs(w * c) + Math.abs(h * s);
        ch = Math.abs(w * s) + Math.abs(h * c);
        Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-cw / 2,-ch / 2,cw / 2,ch / 2));
      };
      return Result;
    };
    this.CreatePath = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetMatrix = function () {
      var Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$new();
      Result.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].MatrixIdentity());
      return Result;
    };
    this.Render = function () {
    };
    this.PathOpen = function (APath) {
    };
    this.PathMoveTo = function (APath, APoint) {
      this.GetCanvas().PathMoveTo$1(APoint.X,APoint.Y);
    };
    this.PathLineTo = function (APath, APoint) {
      this.GetCanvas().PathLineTo$1(APoint.X,APoint.Y);
    };
    this.PathClose = function (APath) {
      this.GetCanvas().PathClose();
    };
    this.ResetTransform = function () {
      this.GetCanvas().SetTransform(1,0,0,1,0,0);
    };
    this.ResetClip = function () {
      this.RestoreState(null);
    };
    this.ScaleTransform = function (AX, AY) {
      var m = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$new();
      m.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].MatrixCreateScaling(AX,AY));
      this.GetCanvas().Transform(m.m11,m.m12,m.m21,m.m22,m.m31,m.m32);
    };
    this.RotateTransform = function (AAngle) {
      var m = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$new();
      m.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].MatrixCreateRotation(pas.Math.DegToRad(AAngle)));
      this.GetCanvas().Transform(m.m11,m.m12,m.m21,m.m22,m.m31,m.m32);
    };
    this.TranslateTransform = function (AX, AY) {
      var m = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$new();
      m.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].MatrixCreateTranslation(AX,AY));
      this.GetCanvas().Transform(m.m11,m.m12,m.m21,m.m22,m.m31,m.m32);
    };
    this.SetTextQuality = function (ATextQuality) {
    };
    this.SetAntiAliasing = function (AAntiAliasing) {
    };
    this.SetShowAcceleratorChar = function (AShowAcceleratorChar) {
    };
    this.SetSize = function (AWidth, AHeight) {
    };
    this.ResetTextAngle = function (AAngle) {
      if (AAngle !== 0) this.GetCanvas().SetTransform(1,0,0,1,0,0);
    };
    this.BeginScene = function () {
      var Result = false;
      Result = false;
      if (this.GetCanvas() != null) {
        this.GetCanvas().BeginScene();
        Result = true;
        this.GetCanvas().Clear();
      };
      return Result;
    };
    this.EndScene = function () {
      this.GetCanvas().EndScene();
    };
    this.BeginPrinting = function () {
      this.FPrinting = true;
    };
    this.EndPrinting = function () {
      if (this.FPrinting) this.FPrinting = false;
    };
    this.StartSpecialPen = function () {
      this.FOldPenStyle = this.GetCanvas().FPen.FStyle;
      this.FOldPenWidth = this.GetCanvas().FPen.FWidth;
      this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDot;
      this.GetCanvas().FPen.FWidth = 1;
    };
    this.StopSpecialPen = function () {
      this.GetCanvas().FPen.FStyle = this.FOldPenStyle;
      this.GetCanvas().FPen.FWidth = this.FOldPenWidth;
    };
    this.RestoreState = function (AState) {
      if (AState != null) AState.FSaveDC = 0;
      this.GetCanvas().Restore();
      this.GetCanvas().Refresh();
    };
    this.SaveState = function (AState) {
      this.GetCanvas().Refresh();
      this.GetCanvas().Save();
    };
    this.SetMatrix = function (AMatrix) {
    };
    this.SetScale = function (AScale) {
    };
    this.SetFontSize = function (ASize) {
      this.GetCanvas().FFont.SetSize(ASize);
    };
    this.SetFontColor = function (AColor) {
      this.GetCanvas().FFont.SetColor(AColor);
    };
    this.SetFontName = function (AName) {
      this.GetCanvas().FFont.SetName(AName);
    };
    this.SetFont = function (AFont) {
      this.GetCanvas().FFont.Assign(AFont);
    };
    this.SetFontStyles = function (AStyle) {
      this.GetCanvas().FFont.SetStyle(rtl.refSet(AStyle));
    };
    this.SetFill = function (AFill) {
      this.GetCanvas().FBrush.FColor = AFill.FColor;
      this.GetCanvas().FBrush.FGradient = pas["WEBLib.Graphics"].TBrushGradient.bgNone;
      this.GetCanvas().FBrush.ClearGradient();
      var $tmp = AFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) {
        this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsSolid}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        this.GetCanvas().FBrush.ClearGradient();
        if ((AFill.FColorMirror !== -1) && (AFill.FColorMirrorTo !== -1)) {
          this.GetCanvas().FBrush.AddGradientColor(AFill.FColor,0);
          this.GetCanvas().FBrush.AddGradientColor(AFill.FColorTo,0.5);
          this.GetCanvas().FBrush.AddGradientColor(AFill.FColorMirror,0.5);
          this.GetCanvas().FBrush.AddGradientColor(AFill.FColorMirrorTo,1);
        } else {
          this.GetCanvas().FBrush.AddGradientColor(AFill.FColor,0);
          this.GetCanvas().FBrush.AddGradientColor(AFill.FColorTo,1);
        };
        var $tmp1 = AFill.FOrientation;
        if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal) {
          this.GetCanvas().FBrush.FGradient = pas["WEBLib.Graphics"].TBrushGradient.bgLinearHorz}
         else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoVertical) this.GetCanvas().FBrush.FGradient = pas["WEBLib.Graphics"].TBrushGradient.bgLinearVert;
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone) this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
    };
    this.SetFillKind = function (AKind) {
      var $tmp = AKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone) {
        this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear}
       else if (($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) || ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient)) this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsSolid;
    };
    this.SetFillColor = function (AColor) {
      this.GetCanvas().FBrush.FColor = AColor;
    };
    this.SetStroke = function (AStroke) {
      this.GetCanvas().FPen.SetColor(AStroke.FColor);
      this.GetCanvas().FPen.FWidth = Math.round(AStroke.FWidth);
      var $tmp = AStroke.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psSolid}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDash) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDash}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDot) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDot}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDot) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDashDot}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDotDot) this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDashDotDot;
    };
    this.SetStrokeKind = function (AKind) {
      var $tmp = AKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psSolid}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDash) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDash}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDot) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDot}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDot) {
        this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDashDot}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDotDot) this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psDashDotDot;
    };
    this.SetStrokeColor = function (AColor) {
      this.GetCanvas().FPen.SetColor(AColor);
    };
    this.SetStrokeWidth = function (AWidth) {
      this.GetCanvas().FPen.FWidth = Math.round(AWidth);
    };
    this.DrawLine = function (AStroke, AFromPoint, AToPoint, AModifyPointModeFrom, AModifyPointModeTo) {
      this.GetCanvas().MoveTo$1(AFromPoint.X,AFromPoint.Y);
      this.GetCanvas().LineTo$1(AToPoint.X,AToPoint.Y);
    };
    this.DrawPolygon = function (AStroke, APolygon) {
      var pts = [];
      var I = 0;
      var bs = 0;
      var c = 0;
      pts = rtl.arraySetLength(pts,pas["WEBLib.Graphics"].TCanvasPointF,rtl.length(APolygon));
      for (var $l = 0, $end = rtl.length(APolygon) - 1; $l <= $end; $l++) {
        I = $l;
        pts[I].$assign(pas["WEBLib.Graphics"].CreateCanvasPointF(APolygon[I].X,APolygon[I].Y));
      };
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      this.GetCanvas().Polygon$1(pts);
      this.GetCanvas().FBrush.FStyle = bs;
      this.GetCanvas().FBrush.FColor = c;
    };
    this.FillPolygon = function (AFill, APolygon) {
      var pts = [];
      var I = 0;
      var ps = 0;
      pts = rtl.arraySetLength(pts,pas["WEBLib.Graphics"].TCanvasPointF,rtl.length(APolygon));
      for (var $l = 0, $end = rtl.length(APolygon) - 1; $l <= $end; $l++) {
        I = $l;
        pts[I].$assign(pas["WEBLib.Graphics"].CreateCanvasPointF(APolygon[I].X,APolygon[I].Y));
      };
      ps = this.GetCanvas().FPen.FStyle;
      this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear;
      this.GetCanvas().Polygon$1(pts);
      this.GetCanvas().FPen.FStyle = ps;
    };
    this.DrawPolyline = function (AStroke, APolyline) {
      var I = 0;
      var pts = [];
      var bs = 0;
      var c = 0;
      pts = rtl.arraySetLength(pts,pas["WEBLib.Graphics"].TCanvasPointF,rtl.length(APolyline));
      for (var $l = 0, $end = rtl.length(APolyline) - 1; $l <= $end; $l++) {
        I = $l;
        pts[I].$assign(pas["WEBLib.Graphics"].CreateCanvasPointF(APolyline[I].X,APolyline[I].Y));
      };
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      this.GetCanvas().Polyline$1(pts);
      this.GetCanvas().FBrush.FStyle = bs;
      this.GetCanvas().FBrush.FColor = c;
    };
    this.FillPolyline = function (AFill, APolyline) {
      var pts = [];
      var I = 0;
      var ps = 0;
      pts = rtl.arraySetLength(pts,pas["WEBLib.Graphics"].TCanvasPointF,rtl.length(APolyline));
      for (var $l = 0, $end = rtl.length(APolyline) - 1; $l <= $end; $l++) {
        I = $l;
        pts[I].$assign(pas["WEBLib.Graphics"].CreateCanvasPointF(APolyline[I].X,APolyline[I].Y));
      };
      ps = this.GetCanvas().FPen.FStyle;
      this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear;
      this.GetCanvas().Polyline$1(pts);
      this.GetCanvas().FPen.FStyle = ps;
    };
    this.FillArc = function (AFill, ACenter, ARadius, AStartAngle, ASweepAngle) {
      var ps = 0;
      ps = this.GetCanvas().FPen.FStyle;
      this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear;
      this.GetCanvas().AngleArc$1(ACenter.X,ACenter.Y,ARadius.X,pas.Math.DegToRad(AStartAngle),pas.Math.DegToRad(ASweepAngle));
      this.GetCanvas().FPen.FStyle = ps;
    };
    this.DrawArc = function (AStroke, ACenter, ARadius, AStartAngle, ASweepAngle) {
      var bs = 0;
      var c = 0;
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      this.GetCanvas().AngleArc$1(ACenter.X,ACenter.Y,ARadius.X,pas.Math.DegToRad(AStartAngle),pas.Math.DegToRad(ASweepAngle));
      this.GetCanvas().FBrush.FStyle = bs;
      this.GetCanvas().FBrush.FColor = c;
    };
    this.FillRect = function (AFill, ARect, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = 0;
      var bs = 0;
      var ps = 0;
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      c = -1;
      bs = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      if (AFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        if ((AFill.FColor !== -1) && (AFill.FColorTo !== -1)) {
          if ((AFill.FColorMirror !== -1) && (AFill.FColorMirrorTo !== -1)) {
            var $tmp = AFill.FOrientation;
            if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal) {
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Left + ((r.Right - r.Left) / 2),r.Bottom)),0,{},true);
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColorMirror,AFill.FColorMirrorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left) / 2),r.Top,r.Right,r.Bottom)),0,{},true);
            } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoVertical) {
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right,r.Top + ((r.Bottom - r.Top) / 2))),0,{},false);
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColorMirror,AFill.FColorMirrorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top + ((r.Bottom - r.Top) / 2),r.Right,r.Bottom)),0,{},false);
            };
          } else pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),0,{},AFill.FOrientation === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal);
        };
        c = this.GetCanvas().FBrush.FColor;
        bs = this.GetCanvas().FBrush.FStyle;
        this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      };
      ps = this.GetCanvas().FPen.FStyle;
      this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear;
      if ((AFill.FColor !== -1) && (AFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid)) {
        this.GetCanvas().Rectangle$3(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom));
      };
      this.GetCanvas().FPen.FStyle = ps;
      if (AFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        this.GetCanvas().FBrush.FColor = c;
        this.GetCanvas().FBrush.FStyle = bs;
      };
    };
    this.DrawRect = function (AStroke, ARect, ASides, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(ARect);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
    };
    this.FillRoundRect = function (AFill, ARect, ARounding, ACorners, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rg = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = {};
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      rg.$assign(r);
      rg.Bottom = rg.Bottom - 1;
      rg.Right = rg.Right - 1;
      if (AFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        if ((AFill.FColor !== -1) && (AFill.FColorTo !== -1)) {
          if ((AFill.FColorMirror !== -1) && (AFill.FColorMirrorTo !== -1)) {
            var $tmp = AFill.FOrientation;
            if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal) {
              c = {};
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft));
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft));
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(rg.Left,rg.Top,rg.Left + ((rg.Right - rg.Left) / 2),r.Bottom)),ARounding,rtl.refSet(c),true);
              c = {};
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight));
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight));
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColorMirror,AFill.FColorMirrorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(rg.Left + ((rg.Right - r.Left) / 2),rg.Top,rg.Right,rg.Bottom)),ARounding,rtl.refSet(c),true);
            } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoVertical) {
              c = {};
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft));
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight));
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(rg.Left,rg.Top,rg.Right,rg.Top + ((rg.Bottom - rg.Top) / 2))),ARounding,rtl.refSet(c),false);
              c = {};
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft));
              if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight in ACorners) c = rtl.unionSet(c,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight));
              pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColorMirror,AFill.FColorMirrorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(rg.Left,rg.Top + ((rg.Bottom - rg.Top) / 2),rg.Right,rg.Bottom)),ARounding,rtl.refSet(c),false);
            };
          } else pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColorTo,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rg),ARounding,rtl.refSet(ACorners),AFill.FOrientation === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal);
        };
      } else if ((AFill.FColor !== -1) && (AFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid)) pas["WEBLib.TMSFNCGraphicsTypes"].DrawGradient(this.GetCanvas(),AFill.FColor,AFill.FColor,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ARounding,rtl.refSet(ACorners),AFill.FOrientation === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal);
    };
    this.DrawRoundRect = function (AStroke, ARect, ARounding, ACorners, AModifyRectMode) {
      var $Self = this;
      var r = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      var rg = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      var rc = 0.0;
      var cl = 0;
      var bs = 0;
      function CanvasArc(ACanvas, Center, Radius, StartAngle, SweepAngle) {
        ACanvas.AngleArc$1(Center.X,Center.Y,Radius.X,pas.Math.DegToRad(StartAngle),pas.Math.DegToRad(SweepAngle));
      };
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      rg.$assign(r);
      rg.Bottom = rg.Bottom - 1;
      rg.Right = rg.Right - 1;
      cl = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      rc = Math.round(ARounding);
      if (rtl.eqSet(ACorners,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight))) {
        this.GetCanvas().RoundRect$3(r,rc * 2,rc * 2)}
       else if (rtl.eqSet(ACorners,{})) {
        this.GetCanvas().Rectangle$3(r)}
       else {
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          this.GetCanvas().MoveTo$1(r.Left + rc,r.Bottom);
          CanvasArc(this.GetCanvas(),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom - rc)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rc,rc)),-270,90);
          this.GetCanvas().MoveTo$1(r.Left,r.Bottom - rc);
        } else {
          this.GetCanvas().MoveTo$1(r.Left,r.Bottom);
        };
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft in ACorners) {
          this.GetCanvas().LineTo$1(r.Left,r.Top + rc);
          CanvasArc(this.GetCanvas(),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top + rc)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rc,rc)),-180,90);
          this.GetCanvas().MoveTo$1(r.Left + rc,r.Top);
        } else this.GetCanvas().LineTo$1(r.Left,r.Top);
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight in ACorners) {
          this.GetCanvas().LineTo$1(r.Right - rc,r.Top);
          CanvasArc(this.GetCanvas(),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top + rc)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rc,rc)),-90,90);
          this.GetCanvas().MoveTo$1(r.Right,r.Top + rc);
        } else this.GetCanvas().LineTo$1(r.Right,r.Top);
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight in ACorners) {
          this.GetCanvas().LineTo$1(r.Right,r.Bottom - rc);
          CanvasArc(this.GetCanvas(),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom - rc)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rc,rc)),0,90);
          this.GetCanvas().MoveTo$1(r.Right - rc,r.Bottom);
        } else {
          this.GetCanvas().LineTo$1(r.Right,r.Bottom);
        };
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          this.GetCanvas().LineTo$1(r.Left + rc,r.Bottom);
        } else this.GetCanvas().LineTo$1(r.Left,r.Bottom);
      };
      this.GetCanvas().FBrush.FColor = cl;
      this.GetCanvas().FBrush.FStyle = bs;
    };
    this.FillEllipse = function (AFill, ARect, AModifyRectMode) {
      var r = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      var ps = 0;
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      ps = this.GetCanvas().FPen.FStyle;
      this.GetCanvas().FPen.FStyle = pas["WEBLib.Graphics"].TPenStyle.psClear;
      this.GetCanvas().Ellipse$3(r);
      this.GetCanvas().FPen.FStyle = ps;
    };
    this.DrawEllipse = function (AStroke, ARect, AModifyRectMode) {
      var r = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      var bs = 0;
      var c = 0;
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      this.GetCanvas().Ellipse$3(r);
      this.GetCanvas().FBrush.FStyle = bs;
      this.GetCanvas().FBrush.FColor = c;
    };
    this.DrawBitmap = function (ABitmap, ASrcRect, ADstRect, AOpacity) {
      this.GetCanvas().StretchDraw$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(ADstRect.Left,ADstRect.Top,ADstRect.Right,ADstRect.Bottom)),ABitmap);
    };
    this.ClipRect = function (ARect) {
      this.GetCanvas().SetClipRect(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
    };
    this.ClipPath = function (APath) {
      if (APath != null) {
        this.GetCanvas().PathBegin();
        this.ConvertToPath(APath,0.25);
        this.GetCanvas().Clip();
      };
    };
    this.DrawFocusPath = function (AStroke, APath, AColor) {
      var bs = 0;
      var c = 0;
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      this.GetCanvas().FPen.SetColor(AColor);
      this.StartSpecialPen();
      this.DrawPath(AStroke,APath,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
      this.StopSpecialPen();
      this.GetCanvas().FBrush.FColor = c;
      this.GetCanvas().FBrush.FStyle = bs;
    };
    this.DrawFocusRectangle = function (AStroke, ARect, AColor, AModifyRectMode) {
      var r = pas["WEBLib.Graphics"].TCanvasRectF.$new();
      var c = 0;
      var bs = 0;
      ARect.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].ModifyRect(ARect,AModifyRectMode));
      r.$assign(pas["WEBLib.Graphics"].CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      this.GetCanvas().FPen.SetColor(AColor);
      this.StartSpecialPen();
      this.GetCanvas().Rectangle$3(r);
      this.StopSpecialPen();
      this.GetCanvas().FBrush.FColor = c;
      this.GetCanvas().FBrush.FStyle = bs;
    };
    this.DrawText = function (AText, ARect, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle) {
      var rcalc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rh = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var st = null;
      var c = 0;
      var bs = 0;
      c = this.GetCanvas().FBrush.FColor;
      bs = this.GetCanvas().FBrush.FStyle;
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsClear;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom));
      if (AWordWrapping) {
        var $tmp = AVerticalAlign;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          rcalc.$assign(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping));
          rh = Math.round(rcalc.Bottom - rcalc.Top);
          r.Top = r.Top + Math.max(0,(r.Bottom - r.Top - rh) / 2);
          r.Bottom = Math.max(0,Math.min(Math.round(ARect.Bottom),r.Top + rh));
        } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
          rcalc.$assign(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping));
          rh = Math.round(rcalc.Bottom - rcalc.Top);
          r.Top = r.Bottom - rh;
          r.Bottom = r.Top + rh;
        };
      };
      if (AAngle !== 0) {
        this.DrawRotatedText(this.GetCanvas(),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AText,AAngle,AHorizontalAlign,AVerticalAlign)}
       else {
        st = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSaveState.$create("Create$1");
        try {
          this.SaveState(st);
          this.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
          var $tmp1 = AHorizontalAlign;
          if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
            var $tmp2 = AVerticalAlign;
            if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
              this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taLeftJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignTop)}
             else if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
              this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taLeftJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taVerticalCenter)}
             else if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taLeftJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignBottom);
          } else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
            var $tmp3 = AVerticalAlign;
            if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
              this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taCenter,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignTop)}
             else if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
              this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taCenter,pas["WEBLib.Graphics"].TVerticalAlignment.taVerticalCenter)}
             else if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taCenter,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignBottom);
          } else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
            var $tmp4 = AVerticalAlign;
            if ($tmp4 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
              this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taRightJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignTop)}
             else if ($tmp4 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
              this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taRightJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taVerticalCenter)}
             else if ($tmp4 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) this.GetCanvas().TextRect$1(pas["WEBLib.Graphics"].TCanvasRectF.$clone(pas["WEBLib.Graphics"].CreateCanvasRectF(r.Left,r.Top,r.Right,r.Bottom)),AText,AWordWrapping,false,pas.Classes.TAlignment.taRightJustify,pas["WEBLib.Graphics"].TVerticalAlignment.taAlignBottom);
          };
        } finally {
          this.RestoreState(st);
        };
      };
      this.GetCanvas().FBrush.FColor = c;
      this.GetCanvas().FBrush.FStyle = bs;
    };
    this.DrawPath = function (AStroke, APath, APathMode) {
      var p = [];
      if (APath != null) {
        if (APathMode === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPath) {
          this.GetCanvas().PathBegin();
          this.ConvertToPath(APath,0.25);
          this.GetCanvas().PathStroke();
        } else {
          p = rtl.arraySetLength(p,pas["WEBLib.TMSFNCTypes"].TPointF,0);
          APath.FlattenToPolygon({get: function () {
              return p;
            }, set: function (v) {
              p = v;
            }},0.25);
          var $tmp = APathMode;
          if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon) {
            this.DrawPolygon(AStroke,rtl.arrayRef(p))}
           else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolyline) this.DrawPolyline(AStroke,rtl.arrayRef(p));
        };
      };
    };
    this.FillPath = function (AFill, APath, APathMode) {
      var p = [];
      if (APath != null) {
        if (APathMode === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPath) {
          this.GetCanvas().PathBegin();
          this.ConvertToPath(APath,0.25);
          this.GetCanvas().PathFill();
        } else {
          p = rtl.arraySetLength(p,pas["WEBLib.TMSFNCTypes"].TPointF,0);
          APath.FlattenToPolygon({get: function () {
              return p;
            }, set: function (v) {
              p = v;
            }},0.25);
          var $tmp = APathMode;
          if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon) {
            this.FillPolygon(AFill,rtl.arrayRef(p))}
           else if (($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolyline) || ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPath)) this.FillPolyline(AFill,rtl.arrayRef(p));
        };
      };
    };
  });
  this.GetNativeContextClass = function () {
    var Result = null;
    Result = $mod.TTMSFNCGraphicsContextGeneral;
    return Result;
  };
},["Math"]);
rtl.module("WEBLib.TMSFNCGraphics.WEB",["System","Classes","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCUtils","Types","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphics","WEBLib.Graphics"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TTMSFNCGraphicsContextWEB",pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphicsContext,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphicsContext.$init.call(this);
      this.FActivePath = null;
      this.FScale = 0.0;
      this.FNeedsRendering = false;
      this.FFont = null;
      this.FFill = null;
      this.FStroke = null;
      this.FContextSize = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      this.FNCanvas = null;
      this.FBitmap = null;
    };
    this.$final = function () {
      this.FActivePath = undefined;
      this.FFont = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FContextSize = undefined;
      this.FBitmap = undefined;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphicsContext.$final.call(this);
    };
    this.GetNativeCanvas = function () {
      var Result = null;
      Result = this.FNCanvas;
      return Result;
    };
    this.DestroyResources = function () {
      if (this.FNCanvas != null) {
        this.RestoreContext();
        this.FNCanvas = null;
      };
      if (this.FBitmap != null) {
        rtl.free(this,"FBitmap");
        this.FBitmap = null;
      };
    };
    this.DrawTextInternal = function (AText, ARect, AWordWrap, AHorizontalAlignment, ACalculate) {
      var $Self = this;
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var i = 0;
      var s = "";
      var sn = "";
      var l = 0;
      var w = 0.0;
      var mw = 0.0;
      var f = false;
      var tw = 0.0;
      var th = 0.0;
      var lcnt = 0;
      var rs = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var fws = 0.0;
      function ApplyFont() {
      };
      function FindNextWord(AText, APos) {
        var Result = "";
        var l = 0;
        var i = 0;
        Result = "";
        l = AText.length;
        if (APos.get() > l) return Result;
        i = APos.get();
        while (true) {
          if (((AText.charAt(i - 1) === "\n") && (AText.charAt(i - 1 - 1) === "\r")) || ((AText.charAt(i - 1) === "\r") && (AText.charAt(i - 1 - 1) === "\n")) || (AText.charAt(i - 1) === " ")) {
            if (AText.charAt(i - 1) === " ") {
              Result = pas.System.Copy(AText,APos.get(),i - (APos.get() - 1))}
             else Result = pas.System.Copy(AText,APos.get(),i - APos.get());
            break;
          } else if ((AText.charAt(i - 1) === "\n") || (AText.charAt(i - 1) === "\r") || (AText.charAt(i - 1) === " ")) {
            Result = pas.System.Copy(AText,APos.get(),i - (APos.get() - 1));
            break;
          } else if (i >= l) {
            Result = pas.System.Copy(AText,APos.get(),i - (APos.get() - 1));
            break;
          } else i += 1;
        };
        APos.set(i + 1);
        return Result;
      };
      ApplyFont();
      if (!AWordWrap) {
        if (!ACalculate) ;
      } else {
        rs.$assign(ARect);
        mw = 0;
        i = 1;
        lcnt = 0;
        fws = 0;
        tw = 0;
        s = FindNextWord(AText,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }});
        mw = mw + w;
        if ((s.length > 0) && (s.charAt(s.length - 1) === " ")) mw = mw + fws;
        while (i <= AText.length) {
          l = s.length;
          if ((l >= 2) && (((s.charAt(l - 1) === "\n") && (s.charAt(l - 1 - 1) === "\r")) || ((s.charAt(l - 1) === "\r") && (s.charAt(l - 1 - 1) === "\n")))) {
            s = pas.System.Copy(s,1,l - 2);
            f = true;
          } else if ((l >= 1) && ((s.charAt(l - 1) === "\n") || (s.charAt(l - 1) === "\r"))) {
            s = pas.System.Copy(s,1,l - 1);
            f = true;
          } else f = false;
          sn = FindNextWord(AText,{get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }});
          if (((ARect.Left + mw + w) > ARect.Right) || f) {
            if (s !== "") {
              lcnt += 1;
              if (mw > tw) tw = mw;
              if (!ACalculate) ;
              mw = 0;
            };
            s = "";
            ARect.Top = ARect.Top + th;
            if ((pas.System.Trunc(ARect.Top) > pas.System.Trunc(ARect.Bottom - th)) && !ACalculate) break;
          };
          mw = mw + w;
          if ((sn.length > 0) && (sn.charAt(sn.length - 1) === " ")) mw = mw + fws;
          s = s + sn;
        };
        if (s !== "") {
          lcnt += 1;
          if (mw > tw) tw = mw;
          if (!ACalculate) ;
        };
        Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rs.Left,rs.Top,rs.Left + tw,rs.Top + (lcnt * th)));
      };
      return Result;
    };
    this.DrawLinearGradient = function (ARect) {
      if (!(this.FNCanvas != null)) return;
      var $tmp = this.FFill.FOrientation;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoHorizontal) {}
      else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillOrientation.gfoVertical) ;
      if ((this.FFill.FColorTo !== -1) && (this.FFill.FColorMirror !== -1)) {}
      else if (this.FFill.FColorTo !== -1) ;
    };
    this.FontChanged = function (Sender) {
    };
    this.FillChanged = function (Sender) {
      if (!(this.FNCanvas != null)) return;
      this.ApplyFill();
    };
    this.StrokeChanged = function (Sender) {
      if (!(this.FNCanvas != null)) return;
      this.ApplyStroke();
    };
    this.RestoreContext = function () {
      if (!(this.FNCanvas != null)) return;
    };
    this.SaveContext = function () {
      if (!(this.FNCanvas != null)) return;
    };
    this.ApplyStroke = function () {
      if (!(this.FNCanvas != null)) return;
    };
    this.ApplyFill = function () {
      if (!(this.FNCanvas != null)) return;
      var $tmp = this.FFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) ;
    };
    this.Create$1 = function (AGraphics) {
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphicsContext.Create$1.apply(this,arguments);
      this.FScale = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(null,-1);
      this.FNeedsRendering = true;
      this.FContextSize.cx = 0;
      this.FContextSize.cy = 0;
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      return this;
    };
    this.Destroy = function () {
      this.Render();
      if (this.FFont != null) {
        rtl.free(this,"FFont");
        this.FFont = null;
      };
      if (this.FFill != null) {
        rtl.free(this,"FFill");
        this.FFill = null;
      };
      if (this.FStroke != null) {
        rtl.free(this,"FStroke");
        this.FStroke = null;
      };
      this.DestroyResources();
      pas.System.TObject.Destroy.call(this);
    };
    this.GetFillColor = function () {
      var Result = 0;
      Result = this.GetGraphics().FFill.FColor;
      return Result;
    };
    this.CalculateText = function (AText, ARect, AWordWrapping) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      if (!(this.FNCanvas != null)) return Result;
      this.SaveContext();
      Result.$assign(this.DrawTextInternal(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,true));
      this.RestoreContext();
      return Result;
    };
    this.SetTextAngle = function (ARect, AAngle) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ar = 0.0;
      var cx = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var w = 0.0;
      var h = 0.0;
      var c = 0.0;
      var s = 0.0;
      var cw = 0.0;
      var ch = 0.0;
      Result.$assign(ARect);
      if (!(this.FNCanvas != null)) return Result;
      if (AAngle !== 0) {
        ar = pas.Math.DegToRad(AAngle);
        cx.X = Result.Left + ((Result.Right - Result.Left) / 2);
        cx.Y = Result.Top + ((Result.Bottom - Result.Top) / 2);
        this.SaveContext();
        w = Result.Right - Result.Left;
        h = Result.Bottom - Result.Top;
        c = Math.cos(ar);
        s = Math.sin(ar);
        cw = Math.abs(w * c) + Math.abs(h * s);
        ch = Math.abs(w * s) + Math.abs(h * c);
        Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-cw / 2,-ch / 2,cw / 2,ch / 2));
      };
      return Result;
    };
    this.CreatePath = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetMatrix = function () {
      var Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$new();
      Result.$assign(pas["WEBLib.TMSFNCGraphicsTypes"].MatrixEmpty());
      return Result;
    };
    this.Render = function () {
      if (!this.FNeedsRendering) return;
      this.FNeedsRendering = false;
      this.DestroyResources();
    };
    this.PathOpen = function (APath) {
    };
    this.PathMoveTo = function (APath, APoint) {
    };
    this.PathLineTo = function (APath, APoint) {
    };
    this.PathClose = function (APath) {
    };
    this.ResetClip = function () {
      if (!(this.FNCanvas != null)) return;
      this.RestoreContext();
    };
    this.ResetTransform = function () {
      if (!(this.FNCanvas != null)) return;
      this.RestoreContext();
      this.SaveContext();
    };
    this.ScaleTransform = function (AX, AY) {
      if (!(this.FNCanvas != null)) return;
    };
    this.RotateTransform = function (AAngle) {
      if (!(this.FNCanvas != null)) return;
    };
    this.TranslateTransform = function (AX, AY) {
      if (!(this.FNCanvas != null)) return;
    };
    this.SetTextQuality = function (ATextQuality) {
    };
    this.SetAntiAliasing = function (AAntiAliasing) {
      if (!(this.FNCanvas != null)) return;
    };
    this.SetShowAcceleratorChar = function (AShowAcceleratorChar) {
    };
    this.SetSize = function (AWidth, AHeight) {
      this.FContextSize.cx = AWidth;
      this.FContextSize.cy = AHeight;
      this.DestroyResources();
      this.FBitmap = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      this.ScaleTransform(this.FScale,this.FScale);
      this.SaveContext();
    };
    this.SetMatrix = function (AMatrix) {
    };
    this.SetScale = function (AScale) {
      this.FScale = AScale;
    };
    this.ResetTextAngle = function (AAngle) {
      if (!(this.FNCanvas != null)) return;
      if (AAngle !== 0) this.RestoreContext();
    };
    this.BeginScene = function () {
      var Result = false;
      Result = false;
      if (!(this.FNCanvas != null)) return Result;
      Result = true;
      return Result;
    };
    this.EndScene = function () {
      if (!(this.FNCanvas != null)) return;
      this.Render();
    };
    this.BeginPrinting = function () {
    };
    this.EndPrinting = function () {
    };
    this.StartSpecialPen = function () {
      if (!(this.FNCanvas != null)) return;
    };
    this.StopSpecialPen = function () {
      if (!(this.FNCanvas != null)) return;
    };
    this.RestoreState = function (AState) {
      if (!(this.FNCanvas != null)) return;
      this.RestoreContext();
    };
    this.SaveState = function (AState) {
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
    };
    this.SetFontSize = function (ASize) {
      if (!(this.FNCanvas != null)) return;
      this.FFont.SetSize(ASize);
    };
    this.SetFontColor = function (AColor) {
      if (!(this.FNCanvas != null)) return;
      this.FFont.SetColor(AColor);
    };
    this.SetFontName = function (AName) {
      if (!(this.FNCanvas != null)) return;
      this.FFont.SetName(AName);
    };
    this.SetFont = function (AFont) {
      if (!(this.FNCanvas != null)) return;
      this.FFont.AssignSource(AFont);
    };
    this.SetFontStyles = function (AStyle) {
      if (!(this.FNCanvas != null)) return;
      this.FFont.SetStyle(rtl.refSet(AStyle));
    };
    this.SetFill = function (AFill) {
      if (!(this.FNCanvas != null)) return;
      this.FFill.Assign(AFill);
    };
    this.SetFillKind = function (AKind) {
      if (!(this.FNCanvas != null)) return;
      this.FFill.SetKind(AKind);
    };
    this.SetFillColor = function (AColor) {
      if (!(this.FNCanvas != null)) return;
      this.FFill.SetColor(AColor);
    };
    this.SetStroke = function (AStroke) {
      if (!(this.FNCanvas != null)) return;
      this.FStroke.Assign(AStroke);
    };
    this.SetStrokeKind = function (AKind) {
      if (!(this.FNCanvas != null)) return;
      this.FStroke.SetKind(AKind);
    };
    this.SetStrokeColor = function (AColor) {
      if (!(this.FNCanvas != null)) return;
      this.FStroke.SetColor(AColor);
    };
    this.SetStrokeWidth = function (AWidth) {
      if (!(this.FNCanvas != null)) return;
      this.FStroke.SetWidth(AWidth);
    };
    this.DrawLine = function (AStroke, AFromPoint, AToPoint, AModifyPointModeFrom, AModifyPointModeTo) {
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
      this.RestoreContext();
    };
    this.DrawPolygon = function (AStroke, APolygon) {
      if (!(this.FNCanvas != null)) return;
      if (rtl.length(APolygon) === 0) return;
      this.SaveContext();
      this.ApplyStroke();
      this.RestoreContext();
    };
    this.FillPolygon = function (AFill, APolygon) {
      if (!(this.FNCanvas != null)) return;
      if (rtl.length(APolygon) === 0) return;
      this.SaveContext();
      var $tmp = AFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) {
        this.ApplyFill();
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        if (this.FActivePath != null) this.DrawLinearGradient(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.FActivePath.GetBounds()));
      };
      this.RestoreContext();
    };
    this.DrawPolyline = function (AStroke, APolyline) {
      if (!(this.FNCanvas != null)) return;
      if (rtl.length(APolyline) === 0) return;
      this.SaveContext();
      this.ApplyStroke();
      this.RestoreContext();
    };
    this.FillPolyline = function (AFill, APolyline) {
      if (!(this.FNCanvas != null)) return;
      if (rtl.length(APolyline) === 0) return;
      this.SaveContext();
      var $tmp = AFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) {
        this.ApplyFill();
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        if (this.FActivePath != null) this.DrawLinearGradient(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.FActivePath.GetBounds()));
      };
      this.RestoreContext();
    };
    this.FillArc = function (AFill, ACenter, ARadius, AStartAngle, ASweepAngle) {
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
      var $tmp = AFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) {
        this.ApplyFill();
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        this.DrawLinearGradient(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ACenter.X - ARadius.X,ACenter.Y - ARadius.Y,ACenter.X + ARadius.X,ACenter.Y + ARadius.Y)));
      };
      this.RestoreContext();
    };
    this.DrawArc = function (AStroke, ACenter, ARadius, AStartAngle, ASweepAngle) {
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
      this.ApplyStroke();
      this.RestoreContext();
    };
    this.FillRect = function (AFill, ARect, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(this.FNCanvas != null)) return;
      r.$assign(ARect);
      this.SaveContext();
      var $tmp = AFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) {
        this.ApplyFill();
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        this.DrawLinearGradient(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
      };
      this.RestoreContext();
    };
    this.DrawRect = function (AStroke, ARect, ASides, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(this.FNCanvas != null)) return;
      r.$assign(ARect);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight in ASides) this.DrawLine(AStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
    };
    this.FillRoundRect = function (AFill, ARect, ARounding, ACorners, AModifyRectMode) {
      var pth = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rc = 0.0;
      r.$assign(ARect);
      rc = ARounding;
      pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
      try {
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom - rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-270,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom - rc));
        } else {
          pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom));
        };
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top + rc));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top + rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-180,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top));
        } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top));
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top + rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-90,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top + rc));
        } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top));
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom - rc));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom - rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),0,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom));
        } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom));
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom))}
         else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom));
        pth.ClosePath();
        this.FillPath(this.FFill,pth,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
      } finally {
        pth = rtl.freeLoc(pth);
      };
    };
    this.DrawRoundRect = function (AStroke, ARect, ARounding, ACorners, AModifyRectMode) {
      var pth = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rc = 0.0;
      r.$assign(ARect);
      rc = ARounding;
      pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
      try {
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom - rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-270,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom - rc));
        } else {
          pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom));
        };
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top + rc));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top + rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-180,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top));
        } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top));
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top + rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-90,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top + rc));
        } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top));
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom - rc));
          pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom - rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),0,90);
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom));
        } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom));
        if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom))}
         else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom));
        pth.ClosePath();
        this.DrawPath(this.FStroke,pth,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
      } finally {
        pth = rtl.freeLoc(pth);
      };
    };
    this.FillEllipse = function (AFill, ARect, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(this.FNCanvas != null)) return;
      r.$assign(ARect);
      this.SaveContext();
      var $tmp = AFill.FKind;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid) {
        this.ApplyFill();
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient) {
        this.DrawLinearGradient(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
      };
      this.RestoreContext();
    };
    this.DrawEllipse = function (AStroke, ARect, AModifyRectMode) {
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
      this.ApplyStroke();
      this.RestoreContext();
    };
    this.DrawBitmap = function (ABitmap, ASrcRect, ADstRect, AOpacity) {
      if (!(ABitmap != null) || !(this.FNCanvas != null)) return;
      this.SaveContext();
      try {} finally {
      };
      this.RestoreContext();
    };
    this.ClipRect = function (ARect) {
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
    };
    this.ClipPath = function (APath) {
      if (!(this.FNCanvas != null)) return;
      try {
        this.SaveContext();
      } finally {
      };
    };
    this.DrawFocusPath = function (AStroke, APath, AColor) {
      if (!(this.FNCanvas != null)) return;
    };
    this.DrawFocusRectangle = function (AStroke, ARect, AColor, AModifyRectMode) {
      if (!(this.FNCanvas != null)) return;
    };
    this.DrawText = function (AText, ARect, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle) {
      var R = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(this.FNCanvas != null)) return;
      this.SaveContext();
      R.$assign(this.DrawTextInternal(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,AHorizontalAlign,true));
      var $tmp = AVerticalAlign;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
        this.DrawTextInternal(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top + ((ARect.Bottom - ARect.Top - (R.Bottom - R.Top)) / 2),ARect.Right,ARect.Top + ((ARect.Bottom - ARect.Top - (R.Bottom - R.Top)) / 2) + (R.Bottom - R.Top))),AWordWrapping,AHorizontalAlign,false)}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
        this.DrawTextInternal(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top,ARect.Right,ARect.Top + (R.Bottom - R.Top))),AWordWrapping,AHorizontalAlign,false)}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) this.DrawTextInternal(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Bottom - (R.Bottom - R.Top),ARect.Right,ARect.Bottom)),AWordWrapping,AHorizontalAlign,false);
      this.RestoreContext();
    };
    this.DrawPath = function (AStroke, APath, APathMode) {
      var p = [];
      if (APath != null) {
        this.FActivePath = APath;
        p = rtl.arraySetLength(p,pas["WEBLib.TMSFNCTypes"].TPointF,0);
        APath.FlattenToPolygon({get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }},0.25);
        var $tmp = APathMode;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon) {
          this.DrawPolygon(AStroke,rtl.arrayRef(p))}
         else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolyline) this.DrawPolyline(AStroke,rtl.arrayRef(p));
        this.FActivePath = null;
      };
    };
    this.FillPath = function (AFill, APath, APathMode) {
      var p = [];
      if (APath != null) {
        this.FActivePath = APath;
        p = rtl.arraySetLength(p,pas["WEBLib.TMSFNCTypes"].TPointF,0);
        APath.FlattenToPolygon({get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }},0.25);
        var $tmp = APathMode;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon) {
          this.FillPolygon(AFill,rtl.arrayRef(p))}
         else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolyline) this.FillPolyline(AFill,rtl.arrayRef(p));
        this.FActivePath = null;
      };
    };
  });
  this.GetNativeContextClass = function () {
    var Result = null;
    Result = $mod.TTMSFNCGraphicsContextWEB;
    return Result;
  };
},["SysUtils","Math"]);
rtl.module("WEBLib.TMSFNCGraphics",["System","Classes","WEBLib.TMSFNCGraphicsTypes","WEBLib.Graphics","JS","WEBLib.TMSFNCBitmapContainer","Types","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TTMSFNCGraphics");
  rtl.createClass(this,"TTMSFNCGraphicsContext",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FGraphics = null;
    };
    this.$final = function () {
      this.FGraphics = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCanvas = function () {
      var Result = null;
      Result = null;
      if (this.GetGraphics() != null) Result = this.GetGraphics().GetCanvas();
      return Result;
    };
    this.GetGraphics = function () {
      var Result = null;
      Result = this.FGraphics;
      return Result;
    };
    this.Create$1 = function (AGraphics) {
      this.FGraphics = AGraphics;
      return this;
    };
    this.ConvertToPath = function (APath, Flatness) {
      var Result = null;
      var J = 0;
      var I = 0;
      var BPts = [];
      var B = rtl.arraySetLength(null,pas["WEBLib.TMSFNCTypes"].TPointF,4);
      var F = 0.0;
      var Len = 0.0;
      var SegCount = 0;
      var CurPoint = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var x = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      Result = this.CreatePath();
      if (APath.GetCount() > 0) {
        F = Math.max(Flatness,0.05);
        J = 0;
        while (J < APath.GetCount()) {
          var $tmp = APath.GetPoint(J).Kind;
          if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathPointKind.gppMoveTo) {
            this.PathOpen(Result);
            this.PathMoveTo(Result,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(APath.GetPoint(J).Point));
            CurPoint.$assign(APath.GetPoint(J).Point);
          } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathPointKind.gppLineTo) {
            this.PathLineTo(Result,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(APath.GetPoint(J).Point));
            CurPoint.$assign(APath.GetPoint(J).Point);
          } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathPointKind.gppCurveTo) {
            B[0].$assign(CurPoint);
            B[1].$assign(APath.GetPoint(J).Point);
            J += 1;
            B[2].$assign(APath.GetPoint(J).Point);
            J += 1;
            B[3].$assign(APath.GetPoint(J).Point);
            BPts = APath.CreateBezier(B,6);
            Len = 0;
            for (var $l = 0, $end = rtl.length(BPts) - 1 - 1; $l <= $end; $l++) {
              I = $l;
              x.X = BPts[I].X - BPts[I + 1].X;
              x.Y = BPts[I].Y - BPts[I + 1].Y;
              Len = Len + pas["WEBLib.TMSFNCTypes"].GetPointLength(x);
            };
            SegCount = Math.round(Len / F);
            if (SegCount < 2) {
              this.PathLineTo(Result,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(B[3]))}
             else {
              BPts = APath.CreateBezier(B,SegCount);
              for (var $l1 = 0, $end1 = rtl.length(BPts) - 1; $l1 <= $end1; $l1++) {
                I = $l1;
                this.PathLineTo(Result,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(BPts[I]));
              };
              CurPoint.$assign(APath.GetPoint(J).Point);
            };
          } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathPointKind.gppClose) this.PathClose(Result);
          J += 1;
        };
      };
      return Result;
    };
  });
  this.$rtti.$ClassRef("TTMSFNCGraphicsContextClass",{instancetype: this.$rtti["TTMSFNCGraphicsContext"]});
  rtl.createClass(this,"TTMSFNCGraphics",pas.System.TObject,function () {
    this.DefaultSelectionFillColor = 0;
    this.DefaultTextFontColor = 0;
    this.DefaultPopupFillColor = 0;
    this.DefaultPopupStrokeColor = 0;
    this.DefaultButtonStrokeColorFocused = 0;
    this.DefaultButtonFillColorFocused = 0;
    this.DefaultButtonStrokeColorDisabled = 0;
    this.DefaultButtonFillColorDisabled = 0;
    this.DefaultButtonStrokeColor = 0;
    this.DefaultButtonFillColor = 0;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FSaveFont = null;
      this.FActiveCanvas = null;
      this.FBlockUpdate = 0;
      this.FNative = false;
      this.FContextNative = null;
      this.FContextGeneral = null;
      this.FBitmap = null;
      this.FFill = null;
      this.FStroke = null;
      this.FFont = null;
      this.FHighlightColor = 0;
      this.FOptimizedHTMLDrawing = false;
      this.FHighlightTextColor = 0;
      this.FHighlightFontStyles = {};
      this.FURLUnderline = false;
      this.FURLColor = 0;
      this.FBitmapContainer = null;
    };
    this.$final = function () {
      this.FSaveFont = undefined;
      this.FActiveCanvas = undefined;
      this.FContextNative = undefined;
      this.FContextGeneral = undefined;
      this.FBitmap = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FFont = undefined;
      this.FHighlightFontStyles = undefined;
      this.FBitmapContainer = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCanvas = function () {
      var Result = null;
      Result = this.FActiveCanvas;
      return Result;
    };
    this.GetContext = function () {
      var Result = null;
      if (this.FNative) {
        Result = this.FContextNative}
       else Result = this.FContextGeneral;
      return Result;
    };
    this.FontChanged = function (Sender) {
      this.SetFont(rtl.as(Sender,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont));
    };
    this.FillChanged = function (Sender) {
      this.SetFill(rtl.as(Sender,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill));
    };
    this.StrokeChanged = function (Sender) {
      this.SetStroke(rtl.as(Sender,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke));
    };
    this.InitializeDefaultAppearance = function () {
      this.FURLColor = 16711680;
      this.FURLUnderline = true;
      this.SetFill(this.FFill);
      this.SetStroke(this.FStroke);
      this.SetFont(this.FFont);
    };
    this.InternalDrawBitmapPartSync = function (ASourceLeft, ASourceTop, ASourceRight, ASourceBottom, ADestinationLeft, ADestinationTop, ADestinationRight, ADestinationBottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var $Self = this;
      var Result = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rs = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ADestinationLeft,ADestinationTop,ADestinationRight,ADestinationBottom));
      rs.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ASourceLeft,ASourceTop,ASourceRight,ASourceBottom));
      if (pas["WEBLib.TMSFNCTypes"].RectIsEmpty(r) || pas["WEBLib.TMSFNCTypes"].RectIsEmpty(rs)) return Result;
      if (!this.HasSVG(ABitmap)) {
        Result = new Promise(function (AResolve, AReject) {
          var bmp = null;
          var g = null;
          g = $mod.TTMSFNCGraphics.$create("CreateBitmapCanvas",[Math.round(ASourceRight - ASourceLeft),Math.round(ASourceBottom - ASourceTop),$Self.FNative,true]);
          try {
            g.BeginScene();
            g.DrawBitmap(-ASourceLeft,-ASourceTop,-ASourceLeft + g.FBitmap.GetWidth(),-ASourceTop + g.FBitmap.GetHeight(),ABitmap,false,false,false,false);
            g.EndScene();
            bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
            bmp.Assign(g.FBitmap);
            AResolve(bmp);
          } finally {
            g = rtl.freeLoc(g);
          };
        });
      };
      return Result;
    };
    this.InternalCalculateText = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var a = "";
      var s = "";
      var fa = "";
      var XSize = 0.0;
      var YSize = 0.0;
      var hl = 0;
      var ml = 0;
      var hr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var lc = 0;
      var AControlID = "";
      var AControlType = "";
      var AControlValue = "";
      Result.$assign(ARect);
      if (Math.round(Result.Right - Result.Left) <= 0) {
        Result.Bottom = Result.Top;
        return Result;
      };
      if (AText !== "") {
        if (ASupportHTML && ((pas.System.Pos("</",AText) > 0) || (pas.System.Pos("/>",AText) > 0) || (pas.System.Pos("<BR>",pas.SysUtils.UpperCase(AText)) > 0))) {
          hr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
          XSize = 0;
          YSize = 0;
          hl = -1;
          ml = -1;
          fa = "";
          s = "";
          a = "";
          lc = 0;
          cr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
          AControlID = "";
          AControlValue = "";
          AControlType = "";
          pas["WEBLib.TMSFNCHTMLEngine"].HTMLDrawEx$1(this,AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),0,0,-1,-1,0,false,true,false,false,false,false,AWordWrapping,false,"",1.0,this.FURLColor,-1,-1,-1,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }},{get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},{get: function () {
              return fa;
            }, set: function (v) {
              fa = v;
            }},{get: function () {
              return XSize;
            }, set: function (v) {
              XSize = v;
            }},{get: function () {
              return YSize;
            }, set: function (v) {
              YSize = v;
            }},{get: function () {
              return hl;
            }, set: function (v) {
              hl = v;
            }},{get: function () {
              return ml;
            }, set: function (v) {
              ml = v;
            }},hr,cr,{get: function () {
              return AControlID;
            }, set: function (v) {
              AControlID = v;
            }},{get: function () {
              return AControlValue;
            }, set: function (v) {
              AControlValue = v;
            }},{get: function () {
              return AControlType;
            }, set: function (v) {
              AControlType = v;
            }},{get: function () {
              return lc;
            }, set: function (v) {
              lc = v;
            }},0,this.FBitmapContainer,1,this.FURLUnderline,this.FHighlightColor,this.FHighlightTextColor,rtl.refSet(this.FHighlightFontStyles));
          YSize = YSize + 1;
          Result.Right = Result.Left + XSize;
          Result.Bottom = Result.Top + YSize;
        } else {
          Result.$assign(this.GetContext().CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping));
          Result.Bottom = Result.Bottom + 1;
        };
      } else {
        Result.Right = Result.Left;
        Result.Bottom = Result.Top;
      };
      return Result;
    };
    this.InternalDrawText = function (ARect, AText, AControlID, AControlValue, AControlType, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var a = "";
      var s = "";
      var fa = "";
      var XSize = 0.0;
      var YSize = 0.0;
      var hl = 0;
      var ml = 0;
      var hr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var xs = 0.0;
      var ys = 0.0;
      var lc = 0;
      var htmlr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var isanchor = false;
      var st = null;
      var oldc = 0;
      oldc = this.GetContext().GetFillColor();
      this.GetContext().SetFillColor(this.FFont.FColor);
      if ((AMinHeight > -1) && ((ARect.Bottom - ARect.Top) < AMinHeight)) ARect.Bottom = ARect.Top + AMinHeight;
      if ((AMinWidth > -1) && ((ARect.Right - ARect.Left) < AMinWidth)) ARect.Right = ARect.Left + AMinWidth;
      ARect.$assign(this.GetContext().SetTextAngle(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AAngle));
      Result = "";
      if (((pas.System.Pos("</",AText) > 0) || (pas.System.Pos("/>",AText) > 0) || (pas.System.Pos("<BR>",pas.SysUtils.UpperCase(AText)) > 0)) && ASupportHTML) {
        hr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
        XSize = 0;
        YSize = 0;
        hl = -1;
        ml = -1;
        fa = "";
        s = "";
        a = "";
        lc = 0;
        cr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
        AControlID.set("");
        AControlValue.set("");
        AControlType.set("");
        pas["WEBLib.TMSFNCHTMLEngine"].HTMLDrawEx$1(this,AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),0,0,-1,-1,0,false,true,false,false,false,false,AWordWrapping,false,"",1.0,this.FURLColor,-1,-1,-1,{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }},{get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},{get: function () {
            return fa;
          }, set: function (v) {
            fa = v;
          }},{get: function () {
            return XSize;
          }, set: function (v) {
            XSize = v;
          }},{get: function () {
            return YSize;
          }, set: function (v) {
            YSize = v;
          }},{get: function () {
            return hl;
          }, set: function (v) {
            hl = v;
          }},{get: function () {
            return ml;
          }, set: function (v) {
            ml = v;
          }},hr,cr,AControlID,AControlValue,AControlType,{get: function () {
            return lc;
          }, set: function (v) {
            lc = v;
          }},0,this.FBitmapContainer,1,this.FURLUnderline,this.FHighlightColor,this.FHighlightTextColor,rtl.refSet(this.FHighlightFontStyles));
        YSize = YSize + 1;
        XSize = XSize + 1;
        if ((AWordWrapping && (lc <= 1)) || !AWordWrapping) {
          xs = ARect.Left;
          ys = ARect.Top;
          var $tmp = AHorizontalAlign;
          if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
            xs = xs + ((ARect.Right - ARect.Left - XSize) / 2)}
           else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) xs = (ARect.Left + (ARect.Right - ARect.Left)) - XSize;
          var $tmp1 = AVerticalAlign;
          if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
            ys = ys + ((ARect.Bottom - ARect.Top - YSize) / 2)}
           else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) ys = (ys + (ARect.Bottom - ARect.Top)) - YSize;
          htmlr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(xs,ys,xs + XSize,ys + YSize));
        } else htmlr.$assign(ARect);
        st = this.SaveState(true);
        this.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
        isanchor = pas["WEBLib.TMSFNCHTMLEngine"].HTMLDrawEx$1(this,AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(htmlr),Math.round(AX),Math.round(AY),-1,-1,0,ATestAnchor,false,false,false,false,false,AWordWrapping,false,"",1.0,this.FURLColor,-1,-1,-1,{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }},{get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},{get: function () {
            return fa;
          }, set: function (v) {
            fa = v;
          }},{get: function () {
            return XSize;
          }, set: function (v) {
            XSize = v;
          }},{get: function () {
            return YSize;
          }, set: function (v) {
            YSize = v;
          }},{get: function () {
            return hl;
          }, set: function (v) {
            hl = v;
          }},{get: function () {
            return ml;
          }, set: function (v) {
            ml = v;
          }},hr,cr,AControlID,AControlValue,AControlType,{get: function () {
            return lc;
          }, set: function (v) {
            lc = v;
          }},0,this.FBitmapContainer,1,this.FURLUnderline,this.FHighlightColor,this.FHighlightTextColor,rtl.refSet(this.FHighlightFontStyles));
        this.RestoreState(st,true);
        if (isanchor) Result = a;
      } else if (!ATestAnchor) this.GetContext().DrawText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle);
      this.GetContext().ResetTextAngle(AAngle);
      this.GetContext().SetFillColor(oldc);
      return Result;
    };
    this.DrawTexture = function (ARect, ATexture, ATextureMode) {
      var LR = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var R = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var IR = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var J = 0;
      if (pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(ATexture)) return;
      LR.$assign(ARect);
      var $tmp = ATextureMode;
      if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextureMode.gtmOriginal) {
        R.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top,ARect.Left + ATexture.GetWidth(),ARect.Top + ATexture.GetHeight()));
        pas["WEBLib.TMSFNCTypes"].IntersectRectEx$1(IR,LR,R);
        this.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,IR.Right - IR.Left,IR.Bottom - IR.Top)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(R.Left,R.Top,R.Left + (IR.Right - IR.Left),R.Top + (IR.Bottom - IR.Top))),ATexture,false,false,false,false);
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextureMode.gtmFit) {
        R.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,ATexture.GetWidth(),ATexture.GetHeight()));
        R.$assign(pas["WEBLib.TMSFNCTypes"].RectSnapToPixelEx(pas["WEBLib.TMSFNCTypes"].RectFitIntoEx$1(R,ARect),1,false));
        this.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,ATexture.GetWidth(),ATexture.GetHeight())),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(R),ATexture,false,true,false,false);
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextureMode.gtmStretch) {
        this.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,ATexture.GetWidth(),ATexture.GetHeight())),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ATexture,false,true,false,false)}
       else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextureMode.gtmTile) {
        for (var $l = 0, $end = pas.System.Trunc((LR.Right - LR.Left) / ATexture.GetWidth()) + 1; $l <= $end; $l++) {
          I = $l;
          for (var $l1 = 0, $end1 = pas.System.Trunc((LR.Bottom - LR.Top) / ATexture.GetHeight()) + 1; $l1 <= $end1; $l1++) {
            J = $l1;
            R.$assign(pas["WEBLib.TMSFNCTypes"].RectF(LR.Left,LR.Top,LR.Left + ATexture.GetWidth(),LR.Top + ATexture.GetHeight()));
            pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(R,I * ATexture.GetWidth(),J * ATexture.GetHeight());
            pas["WEBLib.TMSFNCTypes"].IntersectRectEx$1(IR,LR,R);
            if (pas["WEBLib.TMSFNCTypes"].IntersectRectEx(IR,R)) this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(R.Left,R.Top,R.Left + (IR.Right - IR.Left),R.Top + (IR.Bottom - IR.Top))),ATexture,false,false,false,false);
          };
        };
      } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextureMode.gtmCenter) {
        R.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,ATexture.GetWidth(),ATexture.GetHeight()));
        R.$assign(pas["WEBLib.TMSFNCTypes"].RectSnapToPixelEx(pas["WEBLib.TMSFNCTypes"].RectCenterAtEx(R,ARect),1,false));
        this.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,ATexture.GetWidth(),ATexture.GetHeight())),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(R),ATexture,true,false,true,false);
      };
    };
    this.DrawSVG = function (ABitmap, ARect) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.HasSVG = function (ABitmap) {
      var Result = false;
      Result = false;
      return Result;
    };
    var TTMSFNCGraphicsColorToGrayscale = {"0": "ctgLightness", ctgLightness: 0, "1": "ctgAverage", ctgAverage: 1, "2": "ctgLuminosity", ctgLuminosity: 2};
    this.ConvertBitmapToGrayScale = function (ABitmap) {
      var $Self = this;
      function MinColor(A, B, C) {
        var Result = 0;
        Result = Math.min(A,Math.min(B,C));
        return Result;
      };
      function MaxColor(A, B, C) {
        var Result = 0;
        Result = Math.max(A,Math.max(B,C));
        return Result;
      };
      function ColorToGray(AColor, AMode) {
        var Result = 0;
        var R = 0;
        var G = 0;
        var B = 0;
        var X = 0;
        var A = 0;
        var $tmp = AMode;
        if ($tmp === TTMSFNCGraphicsColorToGrayscale.ctgLightness) {
          X = rtl.trunc((MaxColor(R,G,B) + MinColor(R,G,B)) / 2)}
         else if ($tmp === TTMSFNCGraphicsColorToGrayscale.ctgAverage) {
          X = rtl.trunc((R + G + B) / 3)}
         else if ($tmp === TTMSFNCGraphicsColorToGrayscale.ctgLuminosity) {
          X = Math.round((0.21 * R) + (0.71 * G) + (0.07 * B))}
         else {
          X = 0;
        };
        return Result;
      };
      var I = 0;
      var J = 0;
      if ((ABitmap != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(ABitmap)) {
        for (var $l = 0, $end = ABitmap.GetWidth() - 1; $l <= $end; $l++) {
          I = $l;
          for (var $l1 = 0, $end1 = ABitmap.GetHeight() - 1; $l1 <= $end1; $l1++) {
            J = $l1;
          };
        };
      };
    };
    this.Create$1 = function (ACanvas, ANative) {
      this.FNative = ANative;
      this.FActiveCanvas = ACanvas;
      if (!ANative) {
        this.FContextGeneral = pas["WEBLib.TMSFNCGraphics.General"].TTMSFNCGraphicsContextGeneral.$create("Create$1",[this]);
        this.FContextGeneral.SetSize(1,1);
      } else {
        this.FContextNative = pas["WEBLib.TMSFNCGraphics.WEB"].GetNativeContextClass().$create("Create$1",[this]);
        this.FContextNative.SetSize(1,1);
      };
      this.FSaveFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      if (ACanvas != null) this.FSaveFont.Assign(ACanvas.FFont);
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FHighlightColor = 16711680;
      this.FHighlightTextColor = 16777215;
      this.FHighlightFontStyles = {};
      this.InitializeDefaultAppearance();
      return this;
    };
    this.CreateNative = function (ACanvas) {
      this.Create$1(ACanvas,true);
      return this;
    };
    this.CreateBitmapCanvas = function (AWidth, AHeight, ANative, AHighDPI) {
      this.FNative = ANative;
      this.FBitmap = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      this.FBitmap.SetWidth(AWidth);
      this.FBitmap.SetHeight(AHeight);
      this.FActiveCanvas = this.FBitmap.GetCanvas();
      if (!ANative) {
        this.FContextGeneral = pas["WEBLib.TMSFNCGraphics.General"].TTMSFNCGraphicsContextGeneral.$create("Create$1",[this]);
        this.FContextGeneral.SetSize(AWidth,AHeight);
      } else {
        this.FContextNative = pas["WEBLib.TMSFNCGraphics.WEB"].GetNativeContextClass().$create("Create$1",[this]);
        this.FContextNative.SetSize(AWidth,AHeight);
      };
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.InitializeDefaultAppearance();
      return this;
    };
    this.CreateNativeBitmapCanvas = function (AWidth, AHeight) {
      this.CreateBitmapCanvas(AWidth,AHeight,true,true);
      return this;
    };
    this.Destroy = function () {
      if (this.FContextNative != null) {
        rtl.free(this,"FContextNative");
        this.FContextNative = null;
      };
      if (this.FContextGeneral != null) {
        rtl.free(this,"FContextGeneral");
        this.FContextGeneral = null;
      };
      if (this.FFont != null) {
        rtl.free(this,"FFont");
        this.FFont = null;
      };
      if ((this.FSaveFont != null) && (this.FActiveCanvas != null)) {
        this.FActiveCanvas.FFont.Assign(this.FSaveFont);
        rtl.free(this,"FSaveFont");
        this.FSaveFont = null;
      };
      if (this.FFill != null) {
        this.FFill.FOnChanged = null;
        rtl.free(this,"FFill");
        this.FFill = null;
      };
      if (this.FStroke != null) {
        this.FStroke.FOnChanged = null;
        rtl.free(this,"FStroke");
        this.FStroke = null;
      };
      this.FBitmapContainer = null;
      if (this.FBitmap != null) {
        rtl.free(this,"FBitmap");
        this.FBitmap = null;
      };
      pas.System.TObject.Destroy.call(this);
    };
    this.GetMatrix = function () {
      var Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$new();
      Result.$assign(this.GetContext().GetMatrix());
      return Result;
    };
    this.StartSpecialPen = function () {
      this.GetContext().StartSpecialPen();
    };
    this.StopSpecialPen = function () {
      this.GetContext().StopSpecialPen();
    };
    this.BeginPrinting = function () {
      this.GetContext().BeginPrinting();
    };
    this.EndPrinting = function () {
      this.GetContext().EndPrinting();
    };
    this.BeginScene = function () {
      var Result = false;
      Result = this.GetContext().BeginScene();
      return Result;
    };
    this.EndScene = function () {
      this.GetContext().EndScene();
    };
    this.SetMatrix = function (AMatrix) {
      this.GetContext().SetMatrix(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsMatrix.$clone(AMatrix));
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGraphics.isPrototypeOf(Source)) {
        this.FFill.BeginUpdate();
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCGraphics).FFill);
        this.FFill.EndUpdate();
        this.FStroke.BeginUpdate();
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCGraphics).FStroke);
        this.FStroke.EndUpdate();
        this.FFont.BeginUpdate();
        this.FFont.AssignSource(rtl.as(Source,$mod.TTMSFNCGraphics).FFont);
        this.FFont.EndUpdate();
      };
    };
    this.SetFill = function (AFill) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFill(AFill);
      this.FFill.Assign(AFill);
      this.FBlockUpdate -= 1;
    };
    this.SetStroke = function (AStroke) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetStroke(AStroke);
      this.FStroke.Assign(AStroke);
      this.FBlockUpdate -= 1;
    };
    this.RestoreState = function (AState, ACanvasOnly) {
      if (!ACanvasOnly) {
        this.SetFill(AState.FFill);
        this.SetStroke(AState.FStroke);
        this.SetFont(AState.FFont);
      };
      this.GetContext().RestoreState(AState);
      AState = rtl.freeLoc(AState);
    };
    this.SetFillKind = function (AKind) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFillKind(AKind);
      this.FFill.SetKind(AKind);
      this.FBlockUpdate -= 1;
    };
    this.SetFillColor = function (AColor) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFillColor(AColor);
      this.FFill.SetColor(AColor);
      this.FBlockUpdate -= 1;
    };
    this.SetFontColor = function (AColor) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFontColor(AColor);
      this.FFont.SetColor(AColor);
      this.FBlockUpdate -= 1;
    };
    this.SetFontName = function (AName) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFontName(AName);
      this.FFont.SetName(AName);
      this.FBlockUpdate -= 1;
    };
    this.SetFont = function (AFont) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFont(AFont);
      this.FFont.AssignSource(AFont);
      this.FBlockUpdate -= 1;
    };
    this.SetFontSize = function (ASize) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFontSize(ASize);
      this.FFont.SetSize(ASize);
      this.FBlockUpdate -= 1;
    };
    this.SetFontStyles = function (AStyle) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetFontStyles(rtl.refSet(AStyle));
      this.FFont.SetStyle(rtl.refSet(AStyle));
      this.FBlockUpdate -= 1;
    };
    this.SetStrokeKind = function (AKind) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetStrokeKind(AKind);
      this.FStroke.SetKind(AKind);
      this.FBlockUpdate -= 1;
    };
    this.SetStrokeColor = function (AColor) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetStrokeColor(AColor);
      this.FStroke.SetColor(AColor);
      this.FBlockUpdate -= 1;
    };
    this.SetStrokeWidth = function (AWidth) {
      if (this.FBlockUpdate > 0) return;
      this.FBlockUpdate += 1;
      this.GetContext().SetStrokeWidth(AWidth);
      this.FStroke.SetWidth(AWidth);
      this.FBlockUpdate -= 1;
    };
    this.DrawLine = function (AFromPoint, AToPoint, AModifyPointModeFrom, AModifyPointModeTo) {
      this.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToPointF(AFromPoint)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToPointF(AToPoint)),AModifyPointModeFrom,AModifyPointModeTo);
    };
    this.DrawLine$1 = function (AFromPoint, AToPoint, AModifyPointModeFrom, AModifyPointModeTo) {
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawLine(this.FStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(AFromPoint),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(AToPoint),AModifyPointModeFrom,AModifyPointModeTo);
    };
    this.DrawFocusRectangle = function (ALeft, ATop, ARight, ABottom, AColor, AModifyRectMode) {
      this.DrawFocusRectangle$1(pas.Types.TRect.$clone(pas.Types.Rect(ALeft,ATop,ARight,ABottom)),AColor,AModifyRectMode);
    };
    this.DrawFocusRectangle$1 = function (ARect, AColor, AModifyRectMode) {
      this.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AColor,AModifyRectMode);
    };
    this.DrawFocusRectangle$2 = function (ALeft, ATop, ARight, ABottom, AColor, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom));
      this.GetContext().DrawFocusRectangle(this.FStroke,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AColor,AModifyRectMode);
    };
    this.DrawFocusRectangle$3 = function (ARect, AColor, AModifyRectMode) {
      this.DrawFocusRectangle$2(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,AColor,AModifyRectMode);
    };
    this.DrawFocusPath = function (APath, AColor) {
      this.GetContext().DrawFocusPath(this.FStroke,APath,AColor);
    };
    this.DrawPolygon = function (APolygon) {
      var pth = null;
      if (((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) || (this.FFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture)) {
        var $tmp = this.FFill.FKind;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) {
          pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
          try {
            pth.AddPolygon(APolygon);
            this.DrawTexture(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pth.GetBounds()),this.FFill.FTexture,this.FFill.FTextureMode);
          } finally {
            pth = rtl.freeLoc(pth);
          };
        } else {
          this.GetContext().FillPolygon(this.FFill,rtl.arrayRef(APolygon));
        };
      };
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawPolygon(this.FStroke,rtl.arrayRef(APolygon));
    };
    this.DrawPolyline = function (APolyline) {
      if ((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) this.GetContext().FillPolyline(this.FFill,rtl.arrayRef(APolyline));
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawPolyline(this.FStroke,rtl.arrayRef(APolyline));
    };
    this.DrawPath = function (APath, APathMode) {
      if (((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) || (this.FFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture)) {
        var $tmp = this.FFill.FKind;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) {
          this.DrawTexture(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(APath.GetBounds()),this.FFill.FTexture,this.FFill.FTextureMode)}
         else {
          this.GetContext().FillPath(this.FFill,APath,APathMode);
        };
      };
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawPath(this.FStroke,APath,APathMode);
    };
    this.DrawArc = function (Center, Radius, StartAngle, SweepAngle) {
      var pth = null;
      if ((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) {
        var $tmp = this.FFill.FKind;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) {
          pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
          try {
            pth.AddArc(Center,Radius,StartAngle,SweepAngle);
            this.DrawTexture(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pth.GetBounds()),this.FFill.FTexture,this.FFill.FTextureMode);
          } finally {
            pth = rtl.freeLoc(pth);
          };
        } else {
          this.GetContext().FillArc(this.FFill,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(Center),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(Radius),StartAngle,SweepAngle);
        };
      };
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawArc(this.FStroke,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(Center),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(Radius),StartAngle,SweepAngle);
    };
    this.DrawArc$1 = function (Center, Radius, StartAngle, SweepAngle) {
      this.DrawArc(pas["WEBLib.TMSFNCTypes"].ConvertToPointF(Center),pas["WEBLib.TMSFNCTypes"].ConvertToPointF(Radius),StartAngle,SweepAngle);
    };
    this.DrawRectangle = function (ALeft, ATop, ARight, ABottom, AModifyRectMode) {
      this.DrawRectangle$1(ALeft,ATop,ARight,ABottom,pas["WEBLib.TMSFNCGraphicsTypes"].AllSides,AModifyRectMode);
    };
    this.DrawRectangle$1 = function (ALeft, ATop, ARight, ABottom, ASides, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var pth = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom));
      if (((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) || (this.FFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture)) {
        var $tmp = this.FFill.FKind;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) {
          pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
          try {
            pth.AddRectangle(r,0.0,0.0,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight));
            this.DrawTexture(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FFill.FTexture,this.FFill.FTextureMode);
          } finally {
            pth = rtl.freeLoc(pth);
          };
        } else {
          this.GetContext().FillRect(this.FFill,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AModifyRectMode);
        };
      };
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawRect(this.FStroke,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),rtl.refSet(ASides),AModifyRectMode);
    };
    this.DrawEllipse = function (ALeft, ATop, ARight, ABottom, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var pth = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom));
      if (((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) || (this.FFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture)) {
        var $tmp = this.FFill.FKind;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) {
          pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
          try {
            pth.AddEllipse(r);
            this.DrawTexture(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FFill.FTexture,this.FFill.FTextureMode);
          } finally {
            pth = rtl.freeLoc(pth);
          };
        } else {
          this.GetContext().FillEllipse(this.FFill,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AModifyRectMode);
        };
      };
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawEllipse(this.FStroke,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AModifyRectMode);
    };
    this.DrawRectangle$2 = function (ARect, AModifyRectMode) {
      this.DrawRectangle(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,AModifyRectMode);
    };
    this.DrawRectangle$3 = function (ARect, ASides, AModifyRectMode) {
      this.DrawRectangle$1(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,rtl.refSet(ASides),AModifyRectMode);
    };
    this.DrawRectangle$4 = function (ALeft, ATop, ARight, ABottom, AModifyRectMode) {
      this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),AModifyRectMode);
    };
    this.DrawRectangle$5 = function (ALeft, ATop, ARight, ABottom, ASides, AModifyRectMode) {
      this.DrawRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),rtl.refSet(ASides),AModifyRectMode);
    };
    this.DrawEllipse$1 = function (ALeft, ATop, ARight, ABottom, AModifyRectMode) {
      this.DrawEllipse$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),AModifyRectMode);
    };
    this.DrawRectangle$6 = function (ARect, AModifyRectMode) {
      this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AModifyRectMode);
    };
    this.DrawRectangle$7 = function (ARect, ASides, AModifyRectMode) {
      this.DrawRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),rtl.refSet(ASides),AModifyRectMode);
    };
    this.DrawRoundRectangle = function (ALeft, ATop, ARight, ABottom, ARounding, ACorners, AModifyRectMode) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rc = 0.0;
      var pth = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom));
      if (((this.FFill.FColor !== -1) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone)) || (this.FFill.FKind === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture)) {
        var $tmp = this.FFill.FKind;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) {
          pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
          try {
            rc = ARounding;
            if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
              pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom));
              pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom - rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-270,90);
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom - rc));
            } else {
              pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom));
            };
            if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft in ACorners) {
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top + rc));
              pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top + rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-180,90);
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Top));
            } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top));
            if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight in ACorners) {
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top));
              pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Top + rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),-90,90);
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top + rc));
            } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top));
            if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight in ACorners) {
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom - rc));
              pth.AddArc(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom - rc),pas["WEBLib.TMSFNCTypes"].PointF(rc,rc),0,90);
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - rc,r.Bottom));
            } else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Bottom));
            if (pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft in ACorners) {
              pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + rc,r.Bottom))}
             else pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom));
            pth.ClosePath();
            this.DrawTexture(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FFill.FTexture,this.FFill.FTextureMode);
          } finally {
            pth = rtl.freeLoc(pth);
          };
        } else {
          this.GetContext().FillRoundRect(this.FFill,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ARounding,rtl.refSet(ACorners),AModifyRectMode);
        };
      };
      if ((this.FStroke.FColor !== -1) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) this.GetContext().DrawRoundRect(this.FStroke,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ARounding,rtl.refSet(ACorners),AModifyRectMode);
    };
    this.DrawRoundRectangle$1 = function (ARect, ARounding, ACorners, AModifyRectMode) {
      this.DrawRoundRectangle(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,ARounding,rtl.refSet(ACorners),AModifyRectMode);
    };
    this.DrawRoundRectangle$2 = function (ALeft, ATop, ARight, ABottom, ARounding, ACorners, AModifyRectMode) {
      this.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),ARounding,rtl.refSet(ACorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DrawRoundRectangle$3 = function (ARect, ARounding, ACorners, AModifyRectMode) {
      this.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ARounding,rtl.refSet(ACorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DrawEllipse$2 = function (ARect, AModifyRectMode) {
      this.DrawEllipse(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,AModifyRectMode);
    };
    this.DrawBitmapPart = function (ASourceLeft, ASourceTop, ASourceRight, ASourceBottom, ADestinationLeft, ADestinationTop, ADestinationRight, ADestinationBottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rs = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      var bmp = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ADestinationLeft,ADestinationTop,ADestinationRight,ADestinationBottom));
      rs.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ASourceLeft,ASourceTop,ASourceRight,ASourceBottom));
      if (pas["WEBLib.TMSFNCTypes"].RectIsEmpty(r) || pas["WEBLib.TMSFNCTypes"].RectIsEmpty(rs)) return;
      if (!this.DrawSVG(ABitmap,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r))) {
        g = $mod.TTMSFNCGraphics.$create("CreateBitmapCanvas",[Math.round(ASourceRight - ASourceLeft),Math.round(ASourceBottom - ASourceTop),this.FNative,true]);
        try {
          g.BeginScene();
          g.DrawBitmap(-ASourceLeft,-ASourceTop,-ASourceLeft + g.FBitmap.GetWidth(),-ASourceTop + g.FBitmap.GetHeight(),ABitmap,false,false,false,false);
          g.EndScene();
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
          try {
            bmp.Assign(g.FBitmap);
            this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,AAspectRatio,AStretch,ACenter,ACropping);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        } finally {
          g = rtl.freeLoc(g);
        };
      };
    };
    this.DrawBitmapPart$1 = function (ASourceRect, ADestinationRect, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmapPart(ASourceRect.Left,ASourceRect.Top,ASourceRect.Right,ASourceRect.Bottom,ADestinationRect.Left,ADestinationRect.Top,ADestinationRect.Right,ADestinationRect.Bottom,ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmap = function (ALeft, ATop, ARight, ABottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(ABitmap != null)) return;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom));
      r.$assign(this.GetBitmapDrawRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ABitmap,AAspectRatio,AStretch,ACenter,ACropping));
      if (!this.DrawSVG(ABitmap,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r))) this.GetContext().DrawBitmap(pas["WEBLib.TMSFNCTypes"].BitmapToDrawBitmap(ABitmap),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,ABitmap.GetWidth(),ABitmap.GetHeight())),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),1);
    };
    this.DrawBitmap$1 = function (ARect, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmap(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawEllipse$3 = function (ARect, AModifyRectMode) {
      this.DrawEllipse$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AModifyRectMode);
    };
    this.DrawBitmapPart$2 = function (ASourceLeft, ASourceTop, ASourceRight, ASourceBottom, ADestinationLeft, ADestinationTop, ADestinationRight, ADestinationBottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ASourceLeft,ASourceTop,ASourceRight,ASourceBottom)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ADestinationLeft,ADestinationTop,ADestinationRight,ADestinationBottom)),ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmapPart$3 = function (ASourceRect, ADestinationRect, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ASourceRect)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ADestinationRect)),ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmap$2 = function (ALeft, ATop, ARight, ABottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmap$3 = function (ARect, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmap$4 = function (ALeft, ATop, ABitmap) {
      this.DrawBitmap$3(pas.Types.TRect.$clone(pas.Types.Rect(ALeft,ATop,ALeft + ABitmap.GetWidth(),ATop + ABitmap.GetHeight())),ABitmap,true,false,true,false);
    };
    this.DrawBitmap$5 = function (ALeft, ATop, ABitmap) {
      this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ALeft + ABitmap.GetWidth(),ATop + ABitmap.GetHeight())),ABitmap,true,false,true,false);
    };
    this.DrawCheckBox = function (ARect, AChecked, AFocused, AEnabled, AScaleFactor) {
      var c = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(ARect);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-1,-1);
      if (AEnabled) {
        if (AFocused) {
          c = 11829830}
         else c = 0;
      } else c = 11119017;
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      if (AEnabled) {
        this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(13882323,85))}
       else this.FFill.SetColor(13882323);
      this.FStroke.SetWidth(1);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FStroke.SetColor(c);
      this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-(r.Right - r.Left) / 5,-(r.Bottom - r.Top) / 5);
      this.FStroke.SetWidth(2);
      this.FStroke.SetColor(c);
      if (AChecked) {
        this.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - 1,r.Bottom - 1)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        this.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - 1,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Bottom - 1)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      };
    };
    this.DrawButton = function (ARect, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(ARect);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FStroke.SetWidth(1);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      if (AAdaptToStyle) {
        if (AEnabled) {
          if (!AFocused) {
            this.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultButtonStrokeColor);
            this.FFill.SetColor($mod.TTMSFNCGraphics.DefaultButtonFillColor);
          } else {
            this.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultButtonStrokeColorFocused);
            this.FFill.SetColor($mod.TTMSFNCGraphics.DefaultButtonFillColorFocused);
          };
        } else {
          this.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultButtonStrokeColorDisabled);
          this.FFill.SetColor($mod.TTMSFNCGraphics.DefaultButtonFillColorDisabled);
        };
      } else {
        if (AEnabled) {
          if (!AFocused) {
            this.FStroke.SetColor(11119017);
            this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225));
          } else {
            this.FStroke.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177));
            this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251));
          };
        } else {
          this.FStroke.SetColor(11119017);
          this.FFill.SetColor(13882323);
        };
      };
      this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-1,-1);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      if (!ADown) {
        this.FStroke.SetColor(this.FFill.FColor)}
       else this.FStroke.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(this.FStroke.FColor,40));
      this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DrawCloseButton = function (ARect, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      var bmp = null;
      var bmpa = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      this.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
      if (AAdaptToStyle) {
        bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
        bmpa.SetSize(Math.round(16 * AScaleFactor),Math.round(16 * AScaleFactor));
        g = $mod.TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
        try {
          g.BeginScene();
          g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          g.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultSelectionFillColor);
          g.FStroke.SetWidth(2);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(3 * AScaleFactor,3 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(12 * AScaleFactor,12 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(3 * AScaleFactor,12 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(12 * AScaleFactor,3 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
        try {
          r.$assign(ARect);
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
          try {
            bmp.Assign(bmpa);
            this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        } finally {
          bmpa = rtl.freeLoc(bmpa);
        };
      } else {
        bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSCLOSESVG);
        try {
          r.$assign(ARect);
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-6 * AScaleFactor,-6 * AScaleFactor);
          this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
        } finally {
          bmp = rtl.freeLoc(bmp);
        };
      };
    };
    this.DrawExpanderButton = function (ARect, AState, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      var bmpa = null;
      var bmp = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      this.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
      if (AAdaptToStyle) {
        bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
        bmpa.SetSize(Math.round(16 * AScaleFactor),Math.round(16 * AScaleFactor));
        g = $mod.TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
        try {
          g.BeginScene();
          g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          g.FStroke.SetWidth(2);
          g.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultSelectionFillColor);
          var $tmp = AState;
          if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsExpanderState.gesCollapsed) {
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(5 * AScaleFactor,6 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(8 * AScaleFactor,9 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(8 * AScaleFactor,9 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(11 * AScaleFactor,6 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsExpanderState.gesExpanded) {
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(5 * AScaleFactor,9 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(8 * AScaleFactor,6 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(8 * AScaleFactor,6 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(11 * AScaleFactor,9 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          };
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
        if (bmpa != null) {
          try {
            r.$assign(ARect);
            bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
            try {
              bmp.Assign(bmpa);
              this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
            } finally {
              bmp = rtl.freeLoc(bmp);
            };
          } finally {
            bmpa = rtl.freeLoc(bmpa);
          };
        };
      } else {
        var $tmp1 = AState;
        if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsExpanderState.gesCollapsed) {
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSDOWNSVG)}
         else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsExpanderState.gesExpanded) {
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSUPSVG)}
         else {
          bmp = null;
        };
        if (bmp != null) {
          try {
            r.$assign(ARect);
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-4 * AScaleFactor,-4 * AScaleFactor);
            this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        };
      };
    };
    this.DrawCompactButton = function (ARect, AState, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      var bmpa = null;
      var bmp = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      this.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
      if (AAdaptToStyle) {
        bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
        bmpa.SetSize(Math.round(16 * AScaleFactor),Math.round(16 * AScaleFactor));
        g = $mod.TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
        try {
          g.BeginScene();
          g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          g.FStroke.SetWidth(2);
          g.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultSelectionFillColor);
          var $tmp = AState;
          if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCompactState.gcsCollapsed) {
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6 * AScaleFactor,5 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(9 * AScaleFactor,8 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(9 * AScaleFactor,8 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6 * AScaleFactor,11 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCompactState.gcsExpanded) {
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(9 * AScaleFactor,5 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6 * AScaleFactor,8 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6 * AScaleFactor,8 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(9 * AScaleFactor,11 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          };
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
        if (bmpa != null) {
          try {
            r.$assign(ARect);
            bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
            try {
              bmp.Assign(bmpa);
              this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
            } finally {
              bmp = rtl.freeLoc(bmp);
            };
          } finally {
            bmpa = rtl.freeLoc(bmpa);
          };
        };
      } else {
        var $tmp1 = AState;
        if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCompactState.gcsCollapsed) {
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSRIGHTSVG)}
         else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCompactState.gcsExpanded) {
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSLEFTSVG)}
         else {
          bmp = null;
        };
        if (bmp != null) {
          try {
            r.$assign(ARect);
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-4 * AScaleFactor,-4 * AScaleFactor);
            this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        };
      };
    };
    this.DrawDropDownButton = function (ARect, ADown, AFocused, AEnabled, ACenter, AAdaptToStyle, AScaleFactor) {
      var bmp = null;
      var bmpa = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      this.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADown,AFocused,AEnabled,AAdaptToStyle,1.0);
      if (AAdaptToStyle) {
        bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
        bmpa.SetSize(Math.round(7 * AScaleFactor),Math.round(7 * AScaleFactor));
        g = $mod.TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
        try {
          g.BeginScene();
          g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          g.FStroke.SetColor($mod.TTMSFNCGraphics.DefaultSelectionFillColor);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(0,1 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6 * AScaleFactor,1 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(0,2 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6 * AScaleFactor,2 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(1 * AScaleFactor,3 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(5 * AScaleFactor,3 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(2 * AScaleFactor,4 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(4 * AScaleFactor,4 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(3 * AScaleFactor,5 * AScaleFactor)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(3 * AScaleFactor,5 * AScaleFactor)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
        try {
          if (((ARect.Right - bmpa.GetWidth() - (10 * AScaleFactor)) > ARect.Left) && !ACenter) {
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Right - bmpa.GetWidth() - (10 * AScaleFactor),ARect.Top,ARect.Right,ARect.Bottom))}
           else r.$assign(ARect);
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
          try {
            bmp.Assign(bmpa);
            this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        } finally {
          bmpa = rtl.freeLoc(bmpa);
        };
      } else {
        bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        bmp.LoadFromResource($mod.TMSFNCGRAPHICSEXPANDSVG);
        try {
          if (!ACenter) {
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Right - (16 * AScaleFactor),ARect.Top,ARect.Right - (2 * AScaleFactor),ARect.Bottom));
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-2 * AScaleFactor,-2 * AScaleFactor);
          } else {
            r.$assign(ARect);
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-4 * AScaleFactor,-4 * AScaleFactor);
          };
          this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
        } finally {
          bmp = rtl.freeLoc(bmp);
        };
      };
    };
    this.DrawRadioButton = function (ARect, AChecked, AFocused, AEnabled, AScaleFactor) {
      var c = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(ARect);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-1,-1);
      if (AEnabled) {
        if (AFocused) {
          c = 11829830}
         else c = 0;
      } else c = 11119017;
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      if (AEnabled) {
        this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(13882323,85))}
       else this.FFill.SetColor(13882323);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FStroke.SetWidth(1);
      this.FStroke.SetColor(c);
      this.DrawEllipse$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-(r.Right - r.Left) / 5,-(r.Bottom - r.Top) / 5);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FFill.SetColor(c);
      if (AChecked) {
        this.DrawEllipse$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      };
    };
    this.DrawProgressBar = function (ARect, AValue, AFormat, AMax, AColor, ATextColor, AShowText, AEnabled, AScaleFactor) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rp = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var v = 0.0;
      var tc = 0;
      var fc = 0;
      r.$assign(ARect);
      rp.$assign(r);
      fc = this.FFill.FColor;
      if (AEnabled) {
        this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(13882323,75))}
       else this.FFill.SetColor(13882323);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FStroke.SetColor(11119017);
      this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      v = Math.max(0,Math.min(AValue,AMax));
      if ((v >= 0) && (v <= AMax) && (AMax > 0)) {
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(rp,-1,-1);
        rp.Right = rp.Left + (((rp.Right - r.Left) * v) / AMax);
        this.FFill.SetColor(AColor);
        this.FStroke.SetColor(this.FFill.FColor);
        this.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rp),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        if (AShowText) {
          tc = this.FFont.FColor;
          this.FFont.SetColor(ATextColor);
          this.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas.SysUtils.Format(AFormat,pas.System.VarRecs(3,(v / AMax) * 100)),false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          this.FFont.SetColor(tc);
        };
      };
      this.FFill.SetColor(fc);
    };
    this.DrawCheckBox$1 = function (ARect, AChecked, AFocused, AEnabled, AScaleFactor) {
      this.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AChecked,AFocused,AEnabled,AScaleFactor);
    };
    this.DrawButton$1 = function (ARect, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      this.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
    };
    this.DrawCloseButton$1 = function (ARect, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      this.DrawCloseButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
    };
    this.DrawExpanderButton$1 = function (ARect, AState, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      this.DrawExpanderButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AState,ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
    };
    this.DrawCompactButton$1 = function (ARect, AState, ADown, AFocused, AEnabled, AAdaptToStyle, AScaleFactor) {
      this.DrawCompactButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AState,ADown,AFocused,AEnabled,AAdaptToStyle,AScaleFactor);
    };
    this.DrawDropDownButton$1 = function (ARect, ADown, AFocused, AEnabled, ACenter, AAdaptToStyle, AScaleFactor) {
      this.DrawDropDownButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ADown,AFocused,AEnabled,ACenter,AAdaptToStyle,AScaleFactor);
    };
    this.DrawRadioButton$1 = function (ARect, AChecked, AFocused, AEnabled, AScaleFactor) {
      this.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AChecked,AFocused,AEnabled,AScaleFactor);
    };
    this.DrawProgressBar$1 = function (ARect, AValue, AFormat, AMax, AColor, ATextColor, AShowText, AEnabled, AScaleFactor) {
      this.DrawProgressBar(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AValue,AFormat,AMax,AColor,ATextColor,AShowText,AEnabled,AScaleFactor);
    };
    this.DrawBitmapWithName = function (ALeft, ATop, ARight, ABottom, ABitmapName, AApplyScale, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      var b = null;
      b = this.$class.GetBitmapFromBitmapContainer(this.FBitmapContainer,ABitmapName,AApplyScale,AScale);
      if (b != null) this.DrawBitmap(ALeft,ATop,ARight,ABottom,b,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmapWithName$1 = function (ARect, ABitmapName, AApplyScale, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      var b = null;
      b = this.$class.GetBitmapFromBitmapContainer(this.FBitmapContainer,ABitmapName,AApplyScale,AScale);
      if (b != null) this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),b,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawScaledBitmap = function (ARect, ABitmaps, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      var b = null;
      var bmp = null;
      if (ABitmaps != null) {
        if (AScale > 0) {
          b = ABitmaps.GetItemByScale(AScale)}
         else b = ABitmaps.GetItemByScale(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(null,-1));
        if (b != null) {
          if ((b.FBitmap != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(b.FBitmap)) {
            this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),b.FBitmap,AAspectRatio,AStretch,ACenter,ACropping)}
           else {
            bmp = this.$class.GetBitmapFromBitmapContainer(this.FBitmapContainer,b.FBitmapName,true,AScale);
            if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
              this.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),bmp,AAspectRatio,AStretch,ACenter,ACropping)}
             else this.DrawBitmapWithName$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),b.FBitmapName,false,b.FScale,AAspectRatio,AStretch,ACenter,ACropping);
          };
        };
      };
    };
    this.DrawScaledBitmap$1 = function (ALeft, ATop, ARight, ABottom, ABitmaps, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      var b = null;
      var bmp = null;
      if (ABitmaps != null) {
        if (AScale > 0) {
          b = ABitmaps.GetItemByScale(AScale)}
         else b = ABitmaps.GetItemByScale(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(null,-1));
        if (b != null) {
          if ((b.FBitmap != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(b.FBitmap)) {
            this.DrawBitmap(ALeft,ATop,ARight,ABottom,b.FBitmap,AAspectRatio,AStretch,ACenter,ACropping)}
           else {
            bmp = this.$class.GetBitmapFromBitmapContainer(this.FBitmapContainer,b.FBitmapName,true,AScale);
            if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
              this.DrawBitmap(ALeft,ATop,ARight,ABottom,bmp,AAspectRatio,AStretch,ACenter,ACropping)}
             else this.DrawBitmapWithName(ALeft,ATop,ARight,ABottom,b.FBitmapName,false,b.FScale,AAspectRatio,AStretch,ACenter,ACropping);
          };
        };
      };
    };
    this.DrawBitmapWithName$2 = function (ALeft, ATop, ARight, ABottom, ABitmapName, AApplyScale, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmapWithName$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),ABitmapName,AApplyScale,AScale,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawBitmapWithName$3 = function (ARect, ABitmapName, AApplyScale, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawBitmapWithName$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ABitmapName,AApplyScale,AScale,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawScaledBitmap$2 = function (ARect, ABitmaps, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ABitmaps,AScale,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.DrawScaledBitmap$3 = function (ALeft, ATop, ARight, ABottom, ABitmaps, AScale, AAspectRatio, AStretch, ACenter, ACropping) {
      this.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),ABitmaps,AScale,AAspectRatio,AStretch,ACenter,ACropping);
    };
    this.GetBitmapDrawRectangle = function (ALeft, ATop, ARight, ABottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmp = null;
      var rdest = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var w = 0.0;
      var h = 0.0;
      var x = 0.0;
      var y = 0.0;
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      bmp = ABitmap;
      if (bmp != null) {
        x = 0;
        y = 0;
        w = 0;
        h = 0;
        this.$class.GetAspectSize({get: function () {
            return w;
          }, set: function (v) {
            w = v;
          }},{get: function () {
            return h;
          }, set: function (v) {
            h = v;
          }},bmp.GetWidth(),bmp.GetHeight(),ARight - ALeft,ABottom - ATop,AAspectRatio,AStretch,ACropping);
        if (ACenter || ACropping) {
          x = Math.round((ARight - ALeft - w) / 2);
          y = Math.round((ABottom - ATop - h) / 2);
        };
        rdest.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ALeft + x,ATop + y,ALeft + x + w,ATop + y + h));
        Result.$assign(rdest);
      };
      return Result;
    };
    this.GetBitmapDrawRectangle$1 = function (ARect, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetBitmapDrawRectangle(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,ABitmap,AAspectRatio,AStretch,ACenter,ACropping));
      return Result;
    };
    this.GetBitmapDrawRectangle$2 = function (ALeft, ATop, ARight, ABottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var Result = pas.Types.TRect.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].ConvertToRect(this.GetBitmapDrawRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),ABitmap,AAspectRatio,AStretch,ACenter,ACropping)));
      return Result;
    };
    this.GetBitmapDrawRectangle$3 = function (ARect, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var Result = pas.Types.TRect.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].ConvertToRect(this.GetBitmapDrawRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),ABitmap,AAspectRatio,AStretch,ACenter,ACropping)));
      return Result;
    };
    this.ClipRect = function (ARect) {
      this.GetContext().ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DrawBitmapPartSync = async function (ASourceLeft, ASourceTop, ASourceRight, ASourceBottom, ADestinationLeft, ADestinationTop, ADestinationRight, ADestinationBottom, ABitmap, AAspectRatio, AStretch, ACenter, ACropping) {
      var Result = null;
      Result = await this.InternalDrawBitmapPartSync(ASourceLeft,ASourceTop,ASourceRight,ASourceBottom,ADestinationLeft,ADestinationTop,ADestinationRight,ADestinationBottom,ABitmap,AAspectRatio,AStretch,ACenter,ACropping);
      return Result;
    };
    this.CalculateTextSize = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,ASupportHTML));
      Result.cx = r.Right - r.Left;
      Result.cy = r.Bottom - r.Top;
      return Result;
    };
    this.CalculateTextWidth = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,ASupportHTML));
      Result = r.Right - r.Left;
      return Result;
    };
    this.CalculateTextHeight = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,ASupportHTML));
      Result = r.Bottom - r.Top;
      return Result;
    };
    var arr$1 = ["<BR>","<BR/>"];
    this.CalculateText = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var lst = null;
      var i = 0;
      var l = 0;
      var p = 0;
      var b = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var y = 0.0;
      Result.$assign(ARect);
      b = this.FOptimizedHTMLDrawing && pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(AText);
      if (b) {
        for (i = 0; i <= 1; i++) {
          p = pas.System.Pos(arr$1[i],pas.SysUtils.UpperCase(AText));
          l = arr$1[i].length;
        };
        if ((p > 0) && (l > 0)) {
          lst = pas.Classes.TStringList.$create("Create$1");
          try {
            lst.SetLineBreak(pas.System.Copy(AText,p,l));
            lst.SetTextStr(AText);
            y = 0;
            for (var $l = 0, $end = lst.GetCount() - 1; $l <= $end; $l++) {
              i = $l;
              r.$assign(this.InternalCalculateText(lst.Get(i),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,ASupportHTML));
              y = y + (r.Bottom - r.Top);
            };
            Result.Bottom = Result.Top + y;
          } finally {
            lst = rtl.freeLoc(lst);
          };
        } else b = false;
      };
      if (!b) Result.$assign(this.InternalCalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AWordWrapping,ASupportHTML));
      return Result;
    };
    this.CalculateTextSize$1 = function (AText) {
      var Result = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      Result.$assign(this.CalculateTextSize(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,true));
      return Result;
    };
    this.CalculateTextWidth$1 = function (AText) {
      var Result = 0.0;
      Result = this.CalculateTextWidth(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,true);
      return Result;
    };
    this.CalculateTextHeight$1 = function (AText) {
      var Result = 0.0;
      Result = this.CalculateTextHeight(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,true);
      return Result;
    };
    this.CalculateText$1 = function (AText) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),false,true));
      return Result;
    };
    this.ClipRect$1 = function (ARect) {
      this.ClipRect$1(pas.Types.TRect.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRect$1(ARect)));
    };
    this.CalculateTextSize$2 = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = pas.Types.TSize.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].ConvertToSize(this.CalculateTextSize(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AWordWrapping,ASupportHTML)));
      return Result;
    };
    this.CalculateTextWidth$2 = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = 0;
      Result = Math.round(this.CalculateTextWidth(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AWordWrapping,ASupportHTML));
      return Result;
    };
    this.CalculateTextHeight$2 = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = 0;
      Result = Math.round(this.CalculateTextHeight(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AWordWrapping,ASupportHTML));
      return Result;
    };
    this.CalculateText$2 = function (AText, ARect, AWordWrapping, ASupportHTML) {
      var Result = pas.Types.TRect.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].ConvertToRect(this.CalculateText(AText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AWordWrapping,ASupportHTML)));
      return Result;
    };
    this.CalculateTextSizeInt = function (AText) {
      var Result = pas.Types.TSize.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].ConvertToSize(this.CalculateTextSize$1(AText)));
      return Result;
    };
    this.CalculateTextWidthInt = function (AText) {
      var Result = 0;
      Result = Math.round(this.CalculateTextWidth$1(AText));
      return Result;
    };
    this.CalculateTextHeightInt = function (AText) {
      var Result = 0;
      Result = Math.round(this.CalculateTextHeight$1(AText));
      return Result;
    };
    this.CalculateTextInt = function (AText) {
      var Result = pas.Types.TRect.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].ConvertToRect(this.CalculateText$1(AText)));
      return Result;
    };
    this.DrawText = function (APoint, AText, AAngle, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var AControlID = "";
      var AControlValue = "";
      var AControlType = "";
      AControlID = "";
      AControlValue = "";
      AControlType = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(APoint.X,APoint.Y,APoint.X + 10000,APoint.Y + 10000)),AText,{get: function () {
          return AControlID;
        }, set: function (v) {
          AControlID = v;
        }},{get: function () {
          return AControlValue;
        }, set: function (v) {
          AControlValue = v;
        }},{get: function () {
          return AControlType;
        }, set: function (v) {
          AControlType = v;
        }},false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,AAngle,-1,-1,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.DrawText$1 = function (ARect, AText, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var AControlID = "";
      var AControlValue = "";
      var AControlType = "";
      AControlID = "";
      AControlValue = "";
      AControlType = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AText,{get: function () {
          return AControlID;
        }, set: function (v) {
          AControlID = v;
        }},{get: function () {
          return AControlValue;
        }, set: function (v) {
          AControlValue = v;
        }},{get: function () {
          return AControlType;
        }, set: function (v) {
          AControlType = v;
        }},AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.DrawText$2 = function (ALeft, ATop, ARight, ABottom, AText, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var AControlID = "";
      var AControlValue = "";
      var AControlType = "";
      AControlID = "";
      AControlValue = "";
      AControlType = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),AText,{get: function () {
          return AControlID;
        }, set: function (v) {
          AControlID = v;
        }},{get: function () {
          return AControlValue;
        }, set: function (v) {
          AControlValue = v;
        }},{get: function () {
          return AControlType;
        }, set: function (v) {
          AControlType = v;
        }},AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.DrawText$3 = function (ARect, AText, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var AControlID = "";
      var AControlValue = "";
      var AControlType = "";
      AControlID = "";
      AControlValue = "";
      AControlType = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AText,{get: function () {
          return AControlID;
        }, set: function (v) {
          AControlID = v;
        }},{get: function () {
          return AControlValue;
        }, set: function (v) {
          AControlValue = v;
        }},{get: function () {
          return AControlType;
        }, set: function (v) {
          AControlType = v;
        }},AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.DrawText$4 = function (ALeft, ATop, ARight, ABottom, AText, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var AControlID = "";
      var AControlValue = "";
      var AControlType = "";
      AControlID = "";
      AControlValue = "";
      AControlType = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),AText,{get: function () {
          return AControlID;
        }, set: function (v) {
          AControlID = v;
        }},{get: function () {
          return AControlValue;
        }, set: function (v) {
          AControlValue = v;
        }},{get: function () {
          return AControlType;
        }, set: function (v) {
          AControlType = v;
        }},AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    var arr = ["<BR>","<BR/>"];
    this.DrawText$5 = function (ARect, AText, AControlID, AControlValue, AControlType, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      var lst = null;
      var i = 0;
      var l = 0;
      var p = 0;
      var b = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rd = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      rd.$assign(ARect);
      b = !ATestAnchor && this.FOptimizedHTMLDrawing;
      b = b && pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(AText);
      if (b) {
        for (i = 0; i <= 1; i++) {
          p = pas.System.Pos(arr[i],pas.SysUtils.UpperCase(AText));
          l = arr[i].length;
        };
        if ((p > 0) && (l > 0)) {
          lst = pas.Classes.TStringList.$create("Create$1");
          try {
            lst.SetLineBreak(pas.System.Copy(AText,p,l));
            lst.SetTextStr(AText);
            for (var $l = 0, $end = lst.GetCount() - 1; $l <= $end; $l++) {
              i = $l;
              r.$assign(this.CalculateText(lst.Get(i),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rd),AWordWrapping,ASupportHTML));
              this.InternalDrawText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right + 1,r.Bottom)),lst.Get(i),AControlID,AControlValue,AControlType,AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
              rd.Top = rd.Top + (r.Bottom - r.Top);
              rd.Bottom = rd.Bottom + (r.Bottom - r.Top);
            };
          } finally {
            lst = rtl.freeLoc(lst);
          };
        } else b = false;
      };
      if (!b) {
        Result = this.InternalDrawText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AText,AControlID,AControlValue,AControlType,AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      };
      return Result;
    };
    this.DrawText$6 = function (ALeft, ATop, ARight, ABottom, AText, AControlID, AControlValue, AControlType, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),AText,AControlID,AControlValue,AControlType,AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.DrawText$7 = function (ARect, AText, AControlID, AControlValue, AControlType, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)),AText,AControlID,AControlValue,AControlType,AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.DrawText$8 = function (ALeft, ATop, ARight, ABottom, AText, AControlID, AControlValue, AControlType, AWordWrapping, AHorizontalAlign, AVerticalAlign, ATrimming, AAngle, AMinWidth, AMinHeight, ASupportHTML, ATestAnchor, AX, AY) {
      var Result = "";
      Result = this.DrawText$5(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(ALeft,ATop,ARight,ABottom)),AText,AControlID,AControlValue,AControlType,AWordWrapping,AHorizontalAlign,AVerticalAlign,ATrimming,AAngle,AMinWidth,AMinHeight,ASupportHTML,ATestAnchor,AX,AY);
      return Result;
    };
    this.SaveState = function (ACanvasOnly) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSaveState.$create("Create$1");
      if (!ACanvasOnly) {
        Result.FFill.Assign(this.FFill);
        Result.FStroke.Assign(this.FStroke);
        Result.FFont.AssignSource(this.FFont);
      };
      this.GetContext().SaveState(Result);
      return Result;
    };
    this.ApplyHilight = function (AText, AHilight, ATag, ADoCase) {
      var Result = "";
      Result = pas["WEBLib.TMSFNCHTMLEngine"].HiLight(AText,AHilight,ATag,ADoCase,false);
      return Result;
    };
    this.GetBitmapFromBitmapContainer = function (ABitmapContainer, AName, AApplyScale, AScale) {
      var Result = null;
      Result = null;
      if ((ABitmapContainer != null) && (AName !== "")) {
        if (AApplyScale) {
          if (AScale > 0) {
            Result = ABitmapContainer.FindBitmap$1(AName + "_" + pas.SysUtils.FloatToStr(AScale))}
           else Result = ABitmapContainer.FindBitmap$1(AName + "_" + pas.SysUtils.FloatToStr(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(null,-1)));
        };
        if (!(Result != null)) Result = ABitmapContainer.FindBitmap$1(AName);
      };
      return Result;
    };
    this.GetScaledBitmap = function (ABitmaps, AScale, ABitmapContainer) {
      var Result = null;
      var b = null;
      var bmp = null;
      Result = null;
      if (ABitmaps != null) {
        if (AScale > 0) {
          b = ABitmaps.GetItemByScale(AScale)}
         else b = ABitmaps.GetItemByScale(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(null,-1));
        if (b != null) {
          if ((b.FBitmap != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(b.FBitmap)) {
            Result = b.FBitmap}
           else {
            bmp = this.GetBitmapFromBitmapContainer(ABitmapContainer,b.FBitmapName,true,AScale);
            if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
              Result = bmp}
             else {
              bmp = this.GetBitmapFromBitmapContainer(ABitmapContainer,b.FBitmapName,false,0);
              if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) Result = bmp;
            };
          };
        };
      };
      return Result;
    };
    this.GetAspectSize = function (AWidth, AHeight, AOriginalWidth, AOriginalHeight, ANewWidth, ANewHeight, AAspectRatio, AStretch, ACropping) {
      var arc = 0.0;
      var ar = 0.0;
      if (AAspectRatio) {
        if ((AOriginalWidth > 0) && (AOriginalHeight > 0) && (ANewWidth > 0) && (ANewHeight > 0)) {
          if ((AOriginalWidth < ANewWidth) && (AOriginalHeight < ANewHeight) && !AStretch) {
            AWidth.set(AOriginalWidth);
            AHeight.set(AOriginalHeight);
          } else {
            if ((AOriginalWidth / AOriginalHeight) < (ANewWidth / ANewHeight)) {
              AHeight.set(ANewHeight);
              AWidth.set((ANewHeight * AOriginalWidth) / AOriginalHeight);
            } else {
              AWidth.set(ANewWidth);
              AHeight.set((ANewWidth * AOriginalHeight) / AOriginalWidth);
            };
          };
        } else {
          AWidth.set(0);
          AHeight.set(0);
        };
      } else {
        if (AStretch) {
          AWidth.set(ANewWidth);
          AHeight.set(ANewHeight);
        } else {
          AWidth.set(AOriginalWidth);
          AHeight.set(AOriginalHeight);
          if (ACropping) {
            if ((AWidth.get() >= AHeight.get()) && (AWidth.get() > 0)) {
              AHeight.set((AOriginalWidth / AWidth.get()) * AHeight.get());
              AWidth.set(AOriginalWidth);
            } else if ((AHeight.get() >= AWidth.get()) && (AHeight.get() > 0)) {
              AWidth.set((AOriginalHeight / AHeight.get()) * AWidth.get());
              AHeight.set(AOriginalHeight);
            };
            if (AHeight.get() === 0) {
              ar = 1}
             else ar = AWidth.get() / AHeight.get();
            if (AOriginalHeight === 0) {
              arc = 1}
             else arc = AOriginalWidth / AOriginalHeight;
            if ((ar < 1) || (arc > ar)) {
              AHeight.set(AOriginalWidth / ar);
              AWidth.set(AOriginalWidth);
            } else {
              AWidth.set(ar * AOriginalHeight);
              AHeight.set(AOriginalHeight);
            };
          };
        };
      };
    };
    this.DrawSample = function (ACanvas, ARect) {
      var g = null;
      g = $mod.TTMSFNCGraphics.$create("Create$1",[ACanvas,false]);
      try {
        g.FFont.SetName("Courier New");
        g.FFont.SetSize(20);
        g.FFont.SetColor(16777215);
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        g.FFill.SetColor(36095);
        g.FFill.SetColorTo(11829830);
        g.FStroke.SetColor(9109504);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),"Sample",false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
      } finally {
        g = rtl.freeLoc(g);
      };
    };
    this.SetDefaultGraphicColors = function () {
      $mod.TTMSFNCGraphics.DefaultPopupFillColor = 16777215;
      $mod.TTMSFNCGraphics.DefaultPopupStrokeColor = 12632256;
      $mod.TTMSFNCGraphics.DefaultButtonFillColor = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225);
      $mod.TTMSFNCGraphics.DefaultButtonStrokeColor = 11119017;
      $mod.TTMSFNCGraphics.DefaultTextFontColor = 0;
      $mod.TTMSFNCGraphics.DefaultSelectionFillColor = 0;
      $mod.TTMSFNCGraphics.DefaultButtonFillColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251);
      $mod.TTMSFNCGraphics.DefaultButtonStrokeColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177);
      $mod.TTMSFNCGraphics.DefaultButtonStrokeColorDisabled = 11119017;
      $mod.TTMSFNCGraphics.DefaultButtonFillColorDisabled = 13882323;
    };
    this.PointInCircle = function (APoint, ACenter, ARadius) {
      var Result = false;
      if (ARadius > 0) {
        Result = (pas.System.Sqr$1((APoint.X - ACenter.X) / ARadius) + pas.System.Sqr$1((APoint.Y - ACenter.Y) / ARadius)) <= 1}
       else Result = false;
      return Result;
    };
    this.PointInPath = function (APoint, APath) {
      var Result = false;
      Result = APath.IsPointVisible(APoint);
      return Result;
    };
    this.PointInPath$1 = function (APoint, APath) {
      var Result = false;
      Result = this.PointInPath(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToPointF(APoint)),APath);
      return Result;
    };
    this.PointInPolygon = function (APoint, APolygon) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].PointInPoly(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(APoint),rtl.arrayRef(APolygon));
      return Result;
    };
    this.PointInPolygon$1 = function (APoint, APolygon) {
      var Result = false;
      Result = this.PointInPolygon(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToPointF(APoint)),rtl.arrayRef(APolygon));
      return Result;
    };
    this.PointInRect = function (APoint, ARect) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCTypes"].PtInRectEx(ARect,APoint);
      return Result;
    };
    this.PointInRect$1 = function (APoint, ARect) {
      var Result = false;
      Result = this.PointInRect(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToPointF(APoint)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].ConvertToRectF(ARect)));
      return Result;
    };
    this.GetColorRed = function (AColor) {
      var Result = 0;
      AColor = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = pas["WEBLib.Graphics"].GetRValue(AColor);
      return Result;
    };
    this.GetColorGreen = function (AColor) {
      var Result = 0;
      AColor = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = pas["WEBLib.Graphics"].GetGValue(AColor);
      return Result;
    };
    this.GetColorBlue = function (AColor) {
      var Result = 0;
      AColor = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = pas["WEBLib.Graphics"].GetBValue(AColor);
      return Result;
    };
    var HTMLHexColor = "#RRGGBB";
    var HexDigit = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
    this.ColorToHTML = function (AColor) {
      var Result = "";
      var c = 0;
      var i = 0;
      i = 1;
      c = pas["WEBLib.Graphics"].ColorToRGB(AColor);
      Result = HTMLHexColor;
      Result = rtl.setCharAt(Result,(1 + i) - 1,HexDigit[this.GetColorRed(c) >>> 4]);
      Result = rtl.setCharAt(Result,(2 + i) - 1,HexDigit[this.GetColorRed(c) & 0xF]);
      Result = rtl.setCharAt(Result,(3 + i) - 1,HexDigit[this.GetColorGreen(c) >>> 4]);
      Result = rtl.setCharAt(Result,(4 + i) - 1,HexDigit[this.GetColorGreen(c) & 0xF]);
      Result = rtl.setCharAt(Result,(5 + i) - 1,HexDigit[this.GetColorBlue(c) >>> 4]);
      Result = rtl.setCharAt(Result,(6 + i) - 1,HexDigit[this.GetColorBlue(c) & 0xF]);
      return Result;
    };
    this.HTMLToColor = function (AHTML) {
      var Result = 0;
      var r = 0;
      var g = 0;
      var b = 0;
      Result = -1;
      if (AHTML === "") return Result;
      if (AHTML.length === 4) {
        r = pas.SysUtils.StrToInt("$" + pas.System.Copy(AHTML,2,1) + pas.System.Copy(AHTML,2,1));
        g = pas.SysUtils.StrToInt("$" + pas.System.Copy(AHTML,3,1) + pas.System.Copy(AHTML,3,1));
        b = pas.SysUtils.StrToInt("$" + pas.System.Copy(AHTML,4,1) + pas.System.Copy(AHTML,4,1));
      } else {
        r = pas.SysUtils.StrToInt("$" + pas.System.Copy(AHTML,2,2));
        g = pas.SysUtils.StrToInt("$" + pas.System.Copy(AHTML,4,2));
        b = pas.SysUtils.StrToInt("$" + pas.System.Copy(AHTML,6,2));
      };
      Result = pas["WEBLib.Graphics"].RGB(r,g,b);
      return Result;
    };
    this.TextToColor = function (AText) {
      var Result = 0;
      var s = "";
      var c = null;
      var v = null;
      s = AText;
      s = pas.SysUtils.LowerCase(s);
      if (pas.System.Pos("cl",s) === 1) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,2);
      if (pas.System.Pos("cla",s) === 1) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,3);
      if (pas.System.Pos("gc",s) === 1) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,2);
      Result = 0;
      c = pas["WEBLib.TMSFNCGraphicsTypes"].ColorLookup();
      if (c != null) {
        if (c.TryGetValue(s,{get: function () {
            return v;
          }, set: function (w) {
            v = w;
          }})) Result = v.FColor;
      };
      return Result;
    };
  });
  rtl.createInterface(this,"ITMSFNCGraphicsExport","{481CA803-8B50-4545-B212-57AC0D065D09}",["Export","ApplyExportScale","ResetExportScale","SetExportRect"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Export",0,[["AGraphics",$mod.$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]);
    $r.addMethod("ApplyExportScale",0,[["AScale",rtl.double]]);
    $r.addMethod("ResetExportScale",0,[]);
    $r.addMethod("SetExportRect",0,[["AExportRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]);
  });
  this.TMSFNCGRAPHICSCLOSE = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJ" + "cEhZcwAACxIAAAsSAdLdfvwAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuOWwzfk4AAABVSURBVDhPYxh+" + "QBSI/0OYWAFIThjCxA5ACmAYHeCTQwHYFGITwwuQNSBjkgBFmkGAIgNAGv5BaZINQdYMA0Qbgk0zDBBlCCiR4FMA" + "khOCMIcJYGAAAHvVMBv6PIFYAAAAAElFTkSuQmCC";
  this.TMSFNCGRAPHICSDOWN = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBA" + "JqcGAAAAGdJREFUOI3tzjsOwjAURNGDUqSgTxU5K2AVrJtswjUsgHSR0qdxAZZFPrS+3ZvRzBsqf9MUtBtazJk+oM" + "e0VTriiZCFX8nbpENMgfARjsn74vKj5IFruhfc8d6zIF9S/Hyk5HS4spMVeFcOjszaOwMAAAAASUVORK5CYII=";
  this.TMSFNCGRAPHICSDOWN2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAA" + "RnQU1BAACxjwv8YQUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMT" + "ZEaa/1AAAAdElEQVQ4T6XMsQ2AMBBD0UxBBwyA2L9jCWpY5bCLSJfgSFgUr+AHX4mIX2R0yOiQ0SGjQ8Ud5q7RCl" + "vX5IEDLlhS4/gGvuV/5YEJTuCAR+qYjW/N/81Hko8Mx/QKST0yHJOMCYfDMcnokNEho0NGh4zfRXkAxSYKjdpwcI" + "UAAAAASUVORK5CYII=";
  this.TMSFNCGRAPHICSUP = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJq" + "cGAAAAEZJREFUOI3tjLEJACAMwLLo5EM+rTjpXV7g0oI4tYKbgYwJfJ6Txet4iu6Jxk10TTSuQACidzKAIrGik24ZpC" + "PeJ8ky+DhZ1JENPrPndiwAAAAASUVORK5CYII=";
  this.TMSFNCGRAPHICSUP2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARn" + "QU1BAACxjwv8YQUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa" + "/1AAAAcklEQVQ4T6XMMQ6AMAiF4S46eSEvremk5/IC+GggKfE1ER2+gZ9AEZFfaMygMYPGDBozaOyshu0aGo0eXmb4" + "hEbw42qGTx4B/HiHCWYYPgmDOWEDPfbmT46uNWEwC/THTp/oLvQwfEFjBo0ZNGbQ+J6UG5Y9CmuVGrAsAAAAAElFTkS" + "uQmCC";
  this.TMSFNCGRAPHICSPIN = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQ" + "U1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1" + "AAABKklEQVQ4T2PAB0JDQ5mjoqIEgUxGiAiRIDo6WiY8PHwdEGvW19czQYUJA6AGhbCwsO9Aek1ISIiZvb09C1QKPwB" + "qaAbi/1DNJ4HYiqDNIE1ADZ9AGqGa/wLp6xERESZAaVQ/AyUUgDgIiOdCbQFrQsL/gPgxUM4OFACSQMYdIP4FFPwNxH" + "+gpqNoAortAYayHNSfjAwgNwMFvaCaMTQA8W+g+M7IyEgNiLuQAMgUoNsDgYruoWkCOe1gcHCwHlQpJgA6wwCo6DySJ" + "hD+BDQwCaoEEwA1SQAVzQLiq0BcBMRXgBhk25PAwEBJqDJUkJaWxgr0QzoQbwYqdABGNCeQrQPSDKTv44w3oFPEgYqm" + "Amk9UNqECjMCxWSBeAeUjx1ANWAkZCSD0AADAwDRpKHlJfOjAwAAAABJRU5ErkJggg==";
  this.TMSFNCGRAPHICSPIN2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARn" + "QU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa" + "/1AAAA/UlEQVQ4T33Su2oCQRTGcddLYWmlQhTLCBIsQgoLSW2nj2Bj7yv4DGkCeYOQxiaBNJapbCI2ooU+gY3gbf1/" + "w47MjosHfsvM7DlzY1JhGN6TQQGBM2bEOgke8IU60tGY4SYlqWGHT7wgC/PPT/SNoFDxH1owKyclWyrawsYJczwj8J" + "O1tR4+oFX8OGONtpLLWGCPA47Q7H78ogqd06yoPXeg4qQCTfaDR1x3ZxuapYsl3NDWJnjCtUjcThNTuKHL6cPNM2yj" + "hHfMMMQ/tNoGuoNYkeiTwwBjvCKPBlS8QuzFWPoU8QadQ29TY3qbFXxH/Ru2oYKbhww7kSdMXQD8wIToOQZE/AAAAA" + "BJRU5ErkJggg==";
  this.TMSFNCGRAPHICSRIGHT = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMB" + "AJqcGAAAAFNJREFUOI3tzzsSQFAQRNFDqSezHUuwYBJLsBuhEomE4/ll3HBq+nY1PxENRrS5xzK4L1jPSiISesxP" + "JcORJJqwU9xthjrX/ko4mpBQocN0tf1rbDeZDIfcSud0AAAAAElFTkSuQmCC";
  this.TMSFNCGRAPHICSLEFT = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBA" + "JqcGAAAAEpJREFUOI3lzKENgEAQAMEJBkkIDdDTSxp6gqMyCkB8IQgMFdwZAutn+U19Bi84MUbxhZrBawSXB+8RDD" + "MaDkyvmQyZyYYuOvh6N24uDUKEV//MAAAAAElFTkSuQmCC";
  this.TMSFNCGRAPHICSEXPAND = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOvwAADr8" + "BOAVTJAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4zjOaXUAAAACVJREFUGFdj+P//P07MEBYW9h8Xxi" + "8JAjglYACnBAzglMAEDAwARZ1DA4NRF38AAAAASUVORK5CYII=";
  this.TMSFNCGRAPHICSEXPANDSVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d" + "3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTJweC" + "IgaGVpZ2h0PSIxMnB4IiB2aWV3Qm94PSIwIDAgMTIgMTIiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxwYXRoI" + "HN0eWxlPSIgc3Ryb2tlOm5vbmU7ZmlsbC1ydWxlOm5vbnplcm87ZmlsbDpyZ2IoMCUsMCUsMCUpO2ZpbGwtb3BhY2l0eToxOyIg" + "ZD0iTSAxMS44Mzk4NDQgMi44ODY3MTkgQyAxMS42Mjg5MDYgMi42NzU3ODEgMTEuMjgxMjUgMi42NzU3ODEgMTEuMDcwMzEyIDI" + "uODg2NzE5IEwgNiA3Ljk1NzAzMSBMIDAuOTI5Njg4IDIuODg2NzE5IEMgMC43MTg3NSAyLjY3NTc4MSAwLjM3MTA5NCAyLjY3NT" + "c4MSAwLjE2MDE1NiAyLjg4NjcxOSBDIC0wLjA1NDY4NzUgMy4xMDE1NjIgLTAuMDU0Njg3NSAzLjQ0NTMxMiAwLjE2MDE1NiAzL" + "jY2MDE1NiBMIDUuNjEzMjgxIDkuMTEzMjgxIEMgNS43MTQ4NDQgOS4yMTQ4NDQgNS44NTU0NjkgOS4yNzM0MzggNiA5LjI3MzQz" + "OCBDIDYuMTQ0NTMxIDkuMjczNDM4IDYuMjg1MTU2IDkuMjE0ODQ0IDYuMzg2NzE5IDkuMTEzMjgxIEwgMTEuODM5ODQ0IDMuNjY" + "wMTU2IEMgMTIuMDU0Njg4IDMuNDQ1MzEyIDEyLjA1NDY4OCAzLjEwMTU2MiAxMS44Mzk4NDQgMi44ODY3MTkgWiBNIDExLjgzOT" + "g0NCAyLjg4NjcxOSAiLz4KPC9nPgo8L3N2Zz4K";
  this.TMSFNCGRAPHICSDOWNSVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d" + "3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTJweC" + "IgaGVpZ2h0PSIxMnB4IiB2aWV3Qm94PSIwIDAgMTIgMTIiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxwYXRoI" + "HN0eWxlPSIgc3Ryb2tlOm5vbmU7ZmlsbC1ydWxlOm5vbnplcm87ZmlsbDpyZ2IoMCUsMCUsMCUpO2ZpbGwtb3BhY2l0eToxOyIg" + "ZD0iTSAxMS44Mzk4NDQgMi44ODY3MTkgQyAxMS42Mjg5MDYgMi42NzU3ODEgMTEuMjgxMjUgMi42NzU3ODEgMTEuMDcwMzEyIDI" + "uODg2NzE5IEwgNiA3Ljk1NzAzMSBMIDAuOTI5Njg4IDIuODg2NzE5IEMgMC43MTg3NSAyLjY3NTc4MSAwLjM3MTA5NCAyLjY3NT" + "c4MSAwLjE2MDE1NiAyLjg4NjcxOSBDIC0wLjA1NDY4NzUgMy4xMDE1NjIgLTAuMDU0Njg3NSAzLjQ0NTMxMiAwLjE2MDE1NiAzL" + "jY2MDE1NiBMIDUuNjEzMjgxIDkuMTEzMjgxIEMgNS43MTQ4NDQgOS4yMTQ4NDQgNS44NTU0NjkgOS4yNzM0MzggNiA5LjI3MzQz" + "OCBDIDYuMTQ0NTMxIDkuMjczNDM4IDYuMjg1MTU2IDkuMjE0ODQ0IDYuMzg2NzE5IDkuMTEzMjgxIEwgMTEuODM5ODQ0IDMuNjY" + "wMTU2IEMgMTIuMDU0Njg4IDMuNDQ1MzEyIDEyLjA1NDY4OCAzLjEwMTU2MiAxMS44Mzk4NDQgMi44ODY3MTkgWiBNIDExLjgzOT" + "g0NCAyLjg4NjcxOSAiLz4KPC9nPgo8L3N2Zz4K";
  this.TMSFNCGRAPHICSUPSVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3" + "dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTJweCI" + "gaGVpZ2h0PSIxMnB4IiB2aWV3Qm94PSIwIDAgMTIgMTIiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxwYXRoIH" + "N0eWxlPSIgc3Ryb2tlOm5vbmU7ZmlsbC1ydWxlOm5vbnplcm87ZmlsbDpyZ2IoMCUsMCUsMCUpO2ZpbGwtb3BhY2l0eToxOyIgZ" + "D0iTSAxMS44Mzk4NDQgOC4zMzk4NDQgTCA2LjM4NjcxOSAyLjg4NjcxOSBDIDYuMjg1MTU2IDIuNzg1MTU2IDYuMTQ0NTMxIDIu" + "NzI2NTYyIDYgMi43MjY1NjIgQyA1Ljg1NTQ2OSAyLjcyNjU2MiA1LjcxNDg0NCAyLjc4NTE1NiA1LjYxMzI4MSAyLjg4NjcxOSB" + "MIDAuMTYwMTU2IDguMzM5ODQ0IEMgLTAuMDU0Njg3NSA4LjU1NDY4OCAtMC4wNTQ2ODc1IDguODk4NDM4IDAuMTYwMTU2IDkuMT" + "EzMjgxIEMgMC4zNzEwOTQgOS4zMjQyMTkgMC43MTg3NSA5LjMyNDIxOSAwLjkyOTY4OCA5LjExMzI4MSBMIDYgNC4wNDI5NjkgT" + "CAxMS4wNzAzMTIgOS4xMTMyODEgQyAxMS4xNzU3ODEgOS4yMTg3NSAxMS4zMTY0MDYgOS4yNzM0MzggMTEuNDUzMTI1IDkuMjcz" + "NDM4IEMgMTEuNTkzNzUgOS4yNzM0MzggMTEuNzM0Mzc1IDkuMjE4NzUgMTEuODM5ODQ0IDkuMTEzMjgxIEMgMTIuMDU0Njg4IDg" + "uODk4NDM4IDEyLjA1NDY4OCA4LjU1NDY4OCAxMS44Mzk4NDQgOC4zMzk4NDQgWiBNIDExLjgzOTg0NCA4LjMzOTg0NCAiLz4KPC" + "9nPgo8L3N2Zz4K";
  this.TMSFNCGRAPHICSRIGHTSVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3" + "dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTJweCI" + "gaGVpZ2h0PSIxMnB4IiB2aWV3Qm94PSIwIDAgMTIgMTIiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxwYXRoIH" + "N0eWxlPSIgc3Ryb2tlOm5vbmU7ZmlsbC1ydWxlOm5vbnplcm87ZmlsbDpyZ2IoMCUsMCUsMCUpO2ZpbGwtb3BhY2l0eToxOyIgZ" + "D0iTSA5LjExMzI4MSA1LjYxMzI4MSBMIDMuNjYwMTU2IDAuMTYwMTU2IEMgMy40NDUzMTIgLTAuMDU0Njg3NSAzLjEwMTU2MiAt" + "MC4wNTQ2ODc1IDIuODg2NzE5IDAuMTYwMTU2IEMgMi42NzU3ODEgMC4zNzEwOTQgMi42NzU3ODEgMC43MTg3NSAyLjg4NjcxOSA" + "wLjkyOTY4OCBMIDcuOTU3MDMxIDYgTCAyLjg4NjcxOSAxMS4wNzAzMTIgQyAyLjY3NTc4MSAxMS4yODEyNSAyLjY3NTc4MSAxMS" + "42Mjg5MDYgMi44ODY3MTkgMTEuODM5ODQ0IEMgMi45OTIxODggMTEuOTQ1MzEyIDMuMTMyODEyIDEyIDMuMjczNDM4IDEyIEMgM" + "y40MTQwNjIgMTIgMy41NTA3ODEgMTEuOTQ1MzEyIDMuNjYwMTU2IDExLjgzOTg0NCBMIDkuMTEzMjgxIDYuMzg2NzE5IEMgOS4y" + "MTQ4NDQgNi4yODUxNTYgOS4yNzM0MzggNi4xNDQ1MzEgOS4yNzM0MzggNiBDIDkuMjczNDM4IDUuODU1NDY5IDkuMjE0ODQ0IDU" + "uNzE0ODQ0IDkuMTEzMjgxIDUuNjEzMjgxIFogTSA5LjExMzI4MSA1LjYxMzI4MSAiLz4KPC9nPgo8L3N2Zz4K";
  this.TMSFNCGRAPHICSLEFTSVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3" + "dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTJweCI" + "gaGVpZ2h0PSIxMnB4IiB2aWV3Qm94PSIwIDAgMTIgMTIiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxwYXRoIH" + "N0eWxlPSIgc3Ryb2tlOm5vbmU7ZmlsbC1ydWxlOm5vbnplcm87ZmlsbDpyZ2IoMCUsMCUsMCUpO2ZpbGwtb3BhY2l0eToxOyIgZ" + "D0iTSA0LjA0Mjk2OSA2IEwgOS4xMTMyODEgMC45Mjk2ODggQyA5LjMyNDIxOSAwLjcxODc1IDkuMzI0MjE5IDAuMzcxMDk0IDku" + "MTEzMjgxIDAuMTYwMTU2IEMgOC44OTg0MzggLTAuMDU0Njg3NSA4LjU1NDY4OCAtMC4wNTQ2ODc1IDguMzM5ODQ0IDAuMTYwMTU" + "2IEwgMi44ODY3MTkgNS42MTMyODEgQyAyLjc4NTE1NiA1LjcxNDg0NCAyLjcyNjU2MiA1Ljg1NTQ2OSAyLjcyNjU2MiA2IEMgMi" + "43MjY1NjIgNi4xNDQ1MzEgMi43ODUxNTYgNi4yODUxNTYgMi44ODY3MTkgNi4zODY3MTkgTCA4LjMzOTg0NCAxMS44Mzk4NDQgQ" + "yA4LjQ0OTIxOSAxMS45NDUzMTIgOC41ODU5MzggMTIgOC43MjY1NjIgMTIgQyA4Ljg2NzE4OCAxMiA5LjAwNzgxMiAxMS45NDUz" + "MTIgOS4xMTMyODEgMTEuODM5ODQ0IEMgOS4zMjQyMTkgMTEuNjI4OTA2IDkuMzI0MjE5IDExLjI4MTI1IDkuMTEzMjgxIDExLjA" + "3MDMxMiBaIE0gNC4wNDI5NjkgNiAiLz4KPC9nPgo8L3N2Zz4K";
  this.TMSFNCGRAPHICSCLOSESVG = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciI" + "HhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTJweCIgaGVpZ2h0PSIxMnB4IiB2aWV3" + "Qm94PSIwIDAgMTIgMTIiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxwYXRoIHN0eWxlPSIgc3Ryb2tlOm5vbmU" + "7ZmlsbC1ydWxlOm5vbnplcm87ZmlsbDpyZ2IoMCUsMCUsMCUpO2ZpbGwtb3BhY2l0eToxOyIgZD0iTSA3LjA2MjUgNiBMIDExLj" + "c4MTI1IDEuMjgxMjUgQyAxMi4wNzQyMTkgMC45ODgyODEgMTIuMDc0MjE5IDAuNTExNzE5IDExLjc4MTI1IDAuMjE4NzUgQyAxM" + "S40ODgyODEgLTAuMDc0MjE4OCAxMS4wMTE3MTkgLTAuMDc0MjE4OCAxMC43MTg3NSAwLjIxODc1IEwgNiA0LjkzNzUgTCAxLjI4" + "MTI1IDAuMjE4NzUgQyAwLjk4ODI4MSAtMC4wNzQyMTg4IDAuNTExNzE5IC0wLjA3NDIxODggMC4yMTg3NSAwLjIxODc1IEMgLTA" + "uMDc0MjE4OCAwLjUxMTcxOSAtMC4wNzQyMTg4IDAuOTg4MjgxIDAuMjE4NzUgMS4yODEyNSBMIDQuOTM3NSA2IEwgMC4yMTg3NS" + "AxMC43MTg3NSBDIC0wLjA3NDIxODggMTEuMDExNzE5IC0wLjA3NDIxODggMTEuNDg4MjgxIDAuMjE4NzUgMTEuNzgxMjUgQyAwL" + "jM2NzE4OCAxMS45MjU3ODEgMC41NTg1OTQgMTIgMC43NSAxMiBDIDAuOTQxNDA2IDEyIDEuMTMyODEyIDExLjkyNTc4MSAxLjI4" + "MTI1IDExLjc4MTI1IEwgNiA3LjA2MjUgTCAxMC43MTg3NSAxMS43ODEyNSBDIDEwLjg2NzE4OCAxMS45MjU3ODEgMTEuMDU4NTk" + "0IDEyIDExLjI1IDEyIEMgMTEuNDQxNDA2IDEyIDExLjYzMjgxMiAxMS45MjU3ODEgMTEuNzgxMjUgMTEuNzgxMjUgQyAxMi4wNz" + "QyMTkgMTEuNDg4MjgxIDEyLjA3NDIxOSAxMS4wMTE3MTkgMTEuNzgxMjUgMTAuNzE4NzUgWiBNIDcuMDYyNSA2ICIvPgo8L2c+C" + "jwvc3ZnPgo=";
  $mod.$init = function () {
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSCLOSE);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSDOWN);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSRIGHT);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSLEFT);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSEXPAND);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSPIN);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSPIN2);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSDOWN);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSDOWN2);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSUP);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSUP2);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSEXPANDSVG);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSUPSVG);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSRIGHTSVG);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSLEFTSVG);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSDOWNSVG);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRAPHICSCLOSESVG);
  };
},["SysUtils","Math","WEBLib.TMSFNCUtils","WEBLib.TMSFNCHTMLEngine","WEBLib.TMSFNCGraphics.General","WEBLib.TMSFNCGraphics.WEB"]);
rtl.module("WEBLib.TMSFNCGridCell",["System","Classes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.TMSFNCGraphicsTypes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TTMSFNCFixedGridCell");
  this.TTMSFNCGridNodeState = {"0": "nsClosed", nsClosed: 0, "1": "nsOpen", nsOpen: 1};
  this.$rtti.$Enum("TTMSFNCGridNodeState",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridNodeState});
  this.TTMSFNCGridSortKind = {"0": "skNone", skNone: 0, "1": "skAscending", skAscending: 1, "2": "skDescending", skDescending: 2};
  this.$rtti.$Enum("TTMSFNCGridSortKind",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridSortKind});
  this.$rtti.$Class("TTMSFNCGridCell");
  rtl.createClass(this,"TTMSFNCGridCellLayout",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FSides = {};
      this.FFill = null;
      this.FStroke = null;
      this.FVerticalTextAlign = 0;
      this.FFont = null;
      this.FTextAlign = 0;
      this.FWordWrapping = false;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FSides = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FFont = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      if (this.FFill !== Value) {
        this.FFill.Assign(Value);
        this.Changed();
      };
    };
    this.SetSides = function (Value) {
      if (rtl.neSet(this.FSides,Value)) {
        this.FSides = rtl.refSet(Value);
        this.Changed();
      };
    };
    this.SetStroke = function (Value) {
      if (this.FStroke !== Value) {
        this.FStroke.Assign(Value);
        this.Changed();
      };
    };
    this.SetFont = function (Value) {
      if (this.FFont !== Value) {
        this.FFont.Assign(Value);
        this.Changed();
      };
    };
    this.SetTextAlign = function (Value) {
      if (this.FTextAlign !== Value) {
        this.FTextAlign = Value;
        this.Changed();
      };
    };
    this.SetVerticalTextAlign = function (Value) {
      if (this.FVerticalTextAlign !== Value) {
        this.FVerticalTextAlign = Value;
        this.Changed();
      };
    };
    this.SetWordWrapping = function (Value) {
      if (this.FWordWrapping !== Value) {
        this.FWordWrapping = Value;
        this.Changed();
      };
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.FillChanged = function (Sender) {
      this.Changed();
    };
    this.FontChanged = function (Sender) {
      this.Changed();
    };
    this.StrokeChanged = function (Sender) {
      this.Changed();
    };
    this.Create$1 = function () {
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FFill.SetColor(16777215);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FStroke.SetColor(12632256);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FSides = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom);
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FWordWrapping = false;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFont");
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridCellLayout.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCGridCellLayout).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCGridCellLayout).FStroke);
        this.FSides = rtl.refSet(rtl.as(Source,$mod.TTMSFNCGridCellLayout).FSides);
        this.FFont.Assign(rtl.as(Source,$mod.TTMSFNCGridCellLayout).FFont);
        this.FTextAlign = rtl.as(Source,$mod.TTMSFNCGridCellLayout).FTextAlign;
        this.FVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCGridCellLayout).FVerticalTextAlign;
        this.FWordWrapping = rtl.as(Source,$mod.TTMSFNCGridCellLayout).FWordWrapping;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Sides",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsSides"],"FSides","SetSides",4,{Default: rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom)});
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
    $r.addProperty("TextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTextAlign","SetTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("VerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("WordWrapping",2,rtl.boolean,"FWordWrapping","SetWordWrapping",4,{Default: false});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCGridCellProgressLayout",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FTextColor = 0;
      this.FColor = 0;
      this.FFormat = "";
      this.FOnChange = null;
      this.FShowText = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetColor = function (Value) {
      if (this.FColor !== Value) {
        this.FColor = Value;
        this.Changed();
      };
    };
    this.SetTextColor = function (Value) {
      if (this.FTextColor !== Value) {
        this.FTextColor = Value;
        this.Changed();
      };
    };
    this.SetFormat = function (Value) {
      if (this.FFormat !== Value) {
        this.FFormat = Value;
        this.Changed();
      };
    };
    this.SetShowText = function (Value) {
      if (this.FShowText !== Value) {
        this.FShowText = Value;
        this.Changed();
      };
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      this.FTextColor = 0;
      this.FColor = 3329434;
      this.FFormat = "%.0f%%";
      this.FShowText = true;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridCellProgressLayout.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TTMSFNCGridCellProgressLayout).FColor;
        this.FTextColor = rtl.as(Source,$mod.TTMSFNCGridCellProgressLayout).FTextColor;
        this.FFormat = rtl.as(Source,$mod.TTMSFNCGridCellProgressLayout).FFormat;
        this.FShowText = rtl.as(Source,$mod.TTMSFNCGridCellProgressLayout).FShowText;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 3329434});
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor",4,{Default: 0});
    $r.addProperty("Format",2,rtl.string,"FFormat","SetFormat");
    $r.addProperty("ShowText",2,rtl.boolean,"FShowText","SetShowText",4,{Default: true});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  this.$rtti.$MethodVar("TTMSFNCCellBeforeDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"],1],["ATextRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"],1],["ADrawText",rtl.boolean,1],["ADrawBackGround",rtl.boolean,1],["ADrawBorder",rtl.boolean,1],["AllowDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCellAfterDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ATextRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  this.TTMSFNCGridCellControlPosition = {"0": "gcpLeft", gcpLeft: 0, "1": "gcpTop", gcpTop: 1, "2": "gcpRight", gcpRight: 2, "3": "gcpBottom", gcpBottom: 3, "4": "gcpCenter", gcpCenter: 4};
  this.$rtti.$Enum("TTMSFNCGridCellControlPosition",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCGridCellControlPosition});
  rtl.createClass(this,"TTMSFNCGridCell",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FText = "";
      this.FLayout = null;
      this.FBitmapContainer = null;
      this.FDisplayHTMLFormatting = false;
      this.FWidth = 0.0;
      this.FHeight = 0.0;
      this.FTop = 0.0;
      this.FLeft = 0.0;
      this.FControlBitmap = null;
      this.FControlEnabled = false;
      this.FOnBeforeDraw = null;
      this.FOnAfterDraw = null;
      this.FOnControlClick = null;
      this.FControlStretched = false;
      this.FControlPosition = 0;
      this.FOptimizedHTMLDrawing = false;
      this.FScaleFactor = 0.0;
      this.FAngle = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FLayout = undefined;
      this.FBitmapContainer = undefined;
      this.FControlBitmap = undefined;
      this.FOnBeforeDraw = undefined;
      this.FOnAfterDraw = undefined;
      this.FOnControlClick = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
      };
    };
    this.SetLayout = function (Value) {
      this.FLayout.Assign(Value);
    };
    this.SetDisplayHTMLFormatting = function (Value) {
      if (this.FDisplayHTMLFormatting !== Value) {
        this.FDisplayHTMLFormatting = Value;
      };
    };
    this.SetHeight = function (Value) {
      if (this.FHeight !== Value) {
        this.FHeight = Value;
      };
    };
    this.SetWidth = function (Value) {
      if (this.FWidth !== Value) {
        this.FWidth = Value;
      };
    };
    this.SetLeft = function (Value) {
      if (this.FLeft !== Value) {
        this.FLeft = Value;
      };
    };
    this.SetTop = function (Value) {
      if (this.FTop !== Value) {
        this.FTop = Value;
      };
    };
    this.SetControlBitmap = function (Value) {
      if (this.FControlBitmap !== Value) {
        this.FControlBitmap = Value;
      };
    };
    this.GetControlBitmap = function () {
      var Result = null;
      Result = this.FControlBitmap;
      return Result;
    };
    this.SetControlEnabled = function (Value) {
      if (this.FControlEnabled !== Value) {
        this.FControlEnabled = Value;
      };
    };
    this.SetAngle = function (Value) {
      if (this.FAngle !== Value) {
        this.FAngle = Value;
      };
    };
    this.Changed = function (Sender) {
    };
    this.DoControlClick = function (Sender) {
      if (this.FOnControlClick != null) this.FOnControlClick(this);
    };
    this.HandleControlMouseDown = function (Button, Shift, X, Y) {
    };
    this.HandleControlMouseUp = function (Button, Shift, X, Y) {
      this.DoControlClick(this);
    };
    this.HandleControlMouseMove = function (Shift, X, Y, ACursor) {
    };
    this.DoBeforeDraw = function (AGraphics, ARect, ATextRect, ADrawText, ADrawBackGround, ADrawBorder, AllowDraw) {
      if (this.FOnBeforeDraw != null) this.FOnBeforeDraw(this,AGraphics,ARect,ATextRect,ADrawText,ADrawBackGround,ADrawBorder,AllowDraw);
    };
    this.DoAfterDraw = function (AGraphics, ARect, ATextRect) {
      if (this.FOnAfterDraw != null) this.FOnAfterDraw(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ATextRect));
    };
    this.IsHTML = function () {
      var Result = false;
      if (this.FDisplayHTMLFormatting) {
        Result = false}
       else Result = (pas.System.Pos("</",this.FText) > 0) || (pas.System.Pos("/>",this.FText) > 0) || (pas.System.Pos("<BR>",pas.SysUtils.UpperCase(this.FText)) > 0);
      return Result;
    };
    this.GetTextWidth = function () {
      var Result = 0.0;
      var str = "";
      var g = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      str = this.FText;
      Result = 0;
      if (str !== "") {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.BeginScene();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        g.FBitmapContainer = this.FBitmapContainer;
        try {
          g.SetFont(this.FLayout.FFont);
          r.$assign(this.GetTextRect(false));
          txtr.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FLayout.FWordWrapping,true));
          if (Math.abs(this.FAngle) === 90) {
            Result = txtr.Bottom - txtr.Top}
           else Result = txtr.Right - txtr.Left;
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      return Result;
    };
    this.GetTextHeight = function () {
      var Result = 0.0;
      var str = "";
      var g = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      str = this.FText;
      Result = 0;
      if (str !== "") {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.BeginScene();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        g.FBitmapContainer = this.FBitmapContainer;
        try {
          g.SetFont(this.FLayout.FFont);
          r.$assign(this.GetTextRect(false));
          txtr.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FLayout.FWordWrapping,true));
          if (Math.abs(this.FAngle) === 0) {
            Result = txtr.Bottom - txtr.Top}
           else Result = txtr.Right - txtr.Left;
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      return Result;
    };
    this.XYToAnchor = function (X, Y) {
      var Result = "";
      var g = null;
      var ha = 0;
      var va = 0;
      Result = "";
      if (this.IsHTML()) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.BeginScene();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        g.FBitmapContainer = this.FBitmapContainer;
        try {
          g.FFont.Assign(this.FLayout.FFont);
          ha = this.FLayout.FTextAlign;
          va = this.FLayout.FVerticalTextAlign;
          Result = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetTextRect(true)),this.FText,false,ha,va,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,true,X,Y);
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      return Result;
    };
    this.GetStrippedHTMLText = function () {
      var Result = "";
      var str = "";
      str = this.FText;
      if (this.IsHTML()) {
        Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(str)}
       else Result = str;
      return Result;
    };
    this.GetControlWidth = function () {
      var Result = 0.0;
      var c = null;
      Result = 0;
      c = this.GetControlBitmap();
      if (c != null) Result = c.GetWidth();
      return Result;
    };
    this.GetControlHeight = function () {
      var Result = 0.0;
      var c = null;
      Result = 0;
      c = this.GetControlBitmap();
      if (c != null) Result = c.GetHeight();
      return Result;
    };
    this.GetRealTextRect = function (AAbsolute) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var s = "";
      Result.$assign(pas["WEBLib.TMSFNCTypes"].EmptyRect());
      r.$assign(this.GetTextRect(AAbsolute));
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
      try {
        g.GetContext().BeginScene();
        g.SetFont(this.FLayout.FFont);
        s = this.FText;
        if (s === "") s = "gh";
        tr.$assign(g.CalculateText(s,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FLayout.FWordWrapping,!this.FDisplayHTMLFormatting));
        tr.Left = r.Left;
        tr.Right = r.Right;
        var $tmp = this.FLayout.FTextAlign;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          var $tmp1 = this.FLayout.FVerticalTextAlign;
          if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
            tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - (tr.Right - tr.Left)) / 2),r.Top + ((r.Bottom - r.Top - (tr.Bottom - tr.Top)) / 2),r.Left + ((r.Right - r.Left - (tr.Right - tr.Left)) / 2) + (tr.Right - tr.Left),r.Top + ((r.Bottom - r.Top - (tr.Bottom - tr.Top)) / 2) + (tr.Bottom - tr.Top)))}
           else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
            tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - (tr.Right - tr.Left)) / 2),r.Top,r.Left + ((r.Right - r.Left - (tr.Right - tr.Left)) / 2) + (tr.Right - tr.Left),r.Top + (tr.Bottom - tr.Top)))}
           else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - (tr.Right - tr.Left)) / 2),r.Bottom - (tr.Bottom - tr.Top),r.Left + ((r.Right - r.Left - (tr.Right - tr.Left)) / 2) + (tr.Right - tr.Left),r.Bottom));
        } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
          var $tmp2 = this.FLayout.FVerticalTextAlign;
          if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
            tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top + ((r.Bottom - r.Top - (tr.Bottom - tr.Top)) / 2),r.Left + (tr.Right - tr.Left),r.Top + ((r.Bottom - r.Top - (tr.Bottom - tr.Top)) / 2) + (tr.Bottom - tr.Top)))}
           else if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
            tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Left + (tr.Right - tr.Left),r.Top + (tr.Bottom - tr.Top)))}
           else if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Bottom - (tr.Bottom - tr.Top),r.Left + (tr.Right - tr.Left),r.Bottom));
        } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
          var $tmp3 = this.FLayout.FVerticalTextAlign;
          if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
            tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right - (tr.Right - tr.Left),r.Top + ((r.Bottom - r.Top - (tr.Bottom - tr.Top)) / 2),r.Right,r.Top + ((r.Bottom - r.Top - (tr.Bottom - tr.Top)) / 2) + (tr.Bottom - tr.Top)))}
           else if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
            tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right - (tr.Right - tr.Left),r.Top,r.Right,r.Top + (tr.Bottom - tr.Top)))}
           else if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) tr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right - (tr.Right - tr.Left),r.Bottom - (tr.Bottom - tr.Top),r.Right,r.Bottom));
        };
        Result.$assign(tr);
        Result.Top = Math.max(r.Top,Result.Top);
        Result.Left = Math.max(r.Left,Result.Left);
        Result.Right = r.Right;
        Result.Bottom = r.Bottom;
        g.GetContext().EndScene();
      } finally {
        g = rtl.freeLoc(g);
      };
      return Result;
    };
    this.GetTextRect = function (AAbsolute) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rct = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = null;
      var res = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (AAbsolute) {
        r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft,this.FTop,this.FLeft + this.FWidth,this.FTop + this.FHeight))}
       else r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FWidth,this.FHeight));
      rct.$assign(this.GetControlRect(false));
      c = this.GetControlBitmap();
      if (!this.FControlStretched && (c != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(c)) {
        var $tmp = this.FControlPosition;
        if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpLeft) {
          res.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + (rct.Right - rct.Left) + 2,r.Top,r.Right,r.Bottom))}
         else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpTop) {
          res.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top + (rct.Bottom - rct.Top) + 2,r.Right,r.Bottom))}
         else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpRight) {
          res.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right - (rct.Right - rct.Left) - 2,r.Bottom))}
         else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpBottom) {
          res.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right,r.Bottom - (rct.Bottom - rct.Top) - 2))}
         else {
          res.$assign(r);
        };
      } else res.$assign(r);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(res,-3,-3);
      Result.$assign(res);
      return Result;
    };
    this.GetControlRect = function (AAbsolute) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = null;
      var cw = 0.0;
      var ch = 0.0;
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      c = this.GetControlBitmap();
      if ((c != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(c)) {
        if (AAbsolute) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft,this.FTop,this.FLeft + this.FWidth,this.FTop + this.FHeight))}
         else r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FWidth,this.FHeight));
        if (this.FControlStretched) {
          Result.$assign(r);
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(Result,-2 * this.FScaleFactor,-2 * this.FScaleFactor);
        } else {
          cw = this.GetControlWidth() * this.FScaleFactor;
          ch = this.GetControlHeight() * this.FScaleFactor;
          var $tmp = this.FControlPosition;
          if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpLeft) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 2,r.Top + ((r.Bottom - r.Top - ch) / 2),r.Left + cw + 2,r.Top + ((r.Bottom - r.Top - ch) / 2) + ch))}
           else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpTop) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - cw) / 2),r.Top + 2,r.Left + ((r.Right - r.Left - cw) / 2) + cw,r.Top + 2 + ch))}
           else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpRight) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right - cw - 2,r.Top + ((r.Bottom - r.Top - ch) / 2),r.Right - 2,r.Top + ((r.Bottom - r.Top - ch) / 2) + ch))}
           else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpBottom) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - cw) / 2),r.Bottom - 2 - ch,r.Left + ((r.Right - r.Left - cw) / 2) + cw,r.Bottom - 2))}
           else if ($tmp === $mod.TTMSFNCGridCellControlPosition.gcpCenter) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - cw) / 2),r.Top + ((r.Bottom - r.Top - ch) / 2),r.Left + ((r.Right - r.Left - cw) / 2) + cw,r.Top + ((r.Bottom - r.Top - ch) / 2) + ch));
        };
      };
      return Result;
    };
    this.HandleMouseMove = function (Shift, X, Y, AHandled, ACursor) {
      var ctlr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FControlEnabled) {
        ctlr.$assign(this.GetControlRect(true));
        AHandled.set(pas["WEBLib.TMSFNCTypes"].PtInRectEx(ctlr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y)));
        if (AHandled.get()) this.HandleControlMouseMove(rtl.refSet(Shift),X,Y,ACursor);
      };
    };
    this.HandleMouseDown = function (Button, Shift, X, Y, AHandled) {
      var ctlr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FControlEnabled) {
        ctlr.$assign(this.GetControlRect(true));
        AHandled.set(pas["WEBLib.TMSFNCTypes"].PtInRectEx(ctlr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y)));
        if (AHandled.get()) this.HandleControlMouseDown(Button,rtl.refSet(Shift),X,Y);
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y, AHandled) {
      var ctlr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FControlEnabled) {
        ctlr.$assign(this.GetControlRect(true));
        AHandled.set(pas["WEBLib.TMSFNCTypes"].PtInRectEx(ctlr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y)));
        if (AHandled.get()) this.HandleControlMouseUp(Button,rtl.refSet(Shift),X,Y);
      };
    };
    this.Draw = function (AGraphics, ADrawText, ADrawBackGround, ADrawBorder) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var s = "";
      var AllowDraw = false;
      var st = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft,this.FTop,this.FLeft + this.FWidth,this.FTop + this.FHeight));
      rt.$assign(this.GetTextRect(true));
      AllowDraw = true;
      AGraphics.SetFill(this.FLayout.FFill);
      AGraphics.SetStroke(this.FLayout.FStroke);
      AGraphics.SetFont(this.FLayout.FFont);
      this.DoBeforeDraw(AGraphics,r,rt,{get: function () {
          return ADrawText;
        }, set: function (v) {
          ADrawText = v;
        }},{get: function () {
          return ADrawBackGround;
        }, set: function (v) {
          ADrawBackGround = v;
        }},{get: function () {
          return ADrawBorder;
        }, set: function (v) {
          ADrawBorder = v;
        }},{get: function () {
          return AllowDraw;
        }, set: function (v) {
          AllowDraw = v;
        }});
      if (AllowDraw) {
        if (!ADrawBackGround) {
          AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
          AGraphics.FFill.SetColor(-1);
        };
        if (!ADrawBorder) {
          AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
          AGraphics.FStroke.SetColor(-1);
        };
        if (ADrawBackGround || ADrawBorder) AGraphics.DrawRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),rtl.refSet(this.FLayout.FSides),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        s = this.FText;
        if ((s !== "") && ADrawText) {
          AGraphics.SetFont(this.FLayout.FFont);
          st = null;
          if (this.FAngle !== 0) st = AGraphics.SaveState(false);
          try {
            if (this.FAngle !== 0) AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rt));
            AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rt),s,this.FLayout.FWordWrapping,this.FLayout.FTextAlign,this.FLayout.FVerticalTextAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,this.FAngle,-1,-1,!this.FDisplayHTMLFormatting,false,-1,-1);
          } finally {
            if (this.FAngle !== 0) AGraphics.RestoreState(st,false);
          };
        };
        this.DrawControl(AGraphics);
        this.DoAfterDraw(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rt));
      };
    };
    this.DrawControl = function (AGraphics) {
      var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = null;
      c = this.GetControlBitmap();
      if (c != null) {
        rc.$assign(this.GetControlRect(true));
        rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(rc.Left),Math.round(rc.Top),Math.round(rc.Right),Math.round(rc.Bottom)));
        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),c,true,false,true,false);
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridCell.isPrototypeOf(Source)) {
        this.FText = rtl.as(Source,$mod.TTMSFNCGridCell).FText;
        this.FLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridCell).FLayout);
        this.FLeft = rtl.as(Source,$mod.TTMSFNCGridCell).FLeft;
        this.FTop = rtl.as(Source,$mod.TTMSFNCGridCell).FTop;
        this.FWidth = rtl.as(Source,$mod.TTMSFNCGridCell).FWidth;
        this.FHeight = rtl.as(Source,$mod.TTMSFNCGridCell).FHeight;
        this.FControlStretched = rtl.as(Source,$mod.TTMSFNCGridCell).FControlStretched;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.AssignLayout = function (Source) {
      if ($mod.TTMSFNCGridCellLayout.isPrototypeOf(Source)) this.SetLayout(Source);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FScaleFactor = 1.0;
      this.FLayout = $mod.TTMSFNCGridCellLayout.$create("Create$1");
      this.FLayout.FOnChange = rtl.createCallback(this,"Changed");
      this.FControlStretched = false;
      this.FControlEnabled = true;
      return this;
    };
    this.Destroy = function () {
      this.FControlBitmap = null;
      rtl.free(this,"FLayout");
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.$rtti.$ClassRef("TTMSFNCGridCellClass",{instancetype: this.$rtti["TTMSFNCGridCell"]});
  rtl.createClass(this,"TTMSFNCBaseCheckGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FChecked = false;
      this.FOnCheckChanged = null;
    };
    this.$final = function () {
      this.FOnCheckChanged = undefined;
      $mod.TTMSFNCGridCell.$final.call(this);
    };
    this.SetChecked = function (Value) {
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        this.DoCheckChanged(this);
      };
    };
    this.HandleControlMouseUp = function (Button, Shift, X, Y) {
      $mod.TTMSFNCGridCell.HandleControlMouseUp.apply(this,arguments);
      this.SetChecked(!this.FChecked);
    };
    this.DoCheckChanged = function (Sender) {
      if (this.FOnCheckChanged != null) this.FOnCheckChanged(this);
    };
    this.GetControlWidth = function () {
      var Result = 0.0;
      Result = 19;
      return Result;
    };
    this.GetControlHeight = function () {
      var Result = 0.0;
      Result = 19;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",4,{Default: false});
    $r.addProperty("OnCheckChanged",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnCheckChanged","FOnCheckChanged");
  });
  rtl.createClass(this,"TTMSFNCRadioGridCell",this.TTMSFNCBaseCheckGridCell,function () {
  });
  rtl.createClass(this,"TTMSFNCCheckGridCell",this.TTMSFNCBaseCheckGridCell,function () {
  });
  rtl.createClass(this,"TTMSFNCButtonGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FButtonDown = false;
      this.FButtonWidth = 0;
      this.FButtonText = "";
      this.FButtonHeight = 0;
    };
    this.SetButtonText = function (Value) {
      if (this.FButtonText !== Value) this.FButtonText = Value;
    };
    this.SetButtonWidth = function (Value) {
      if (this.FButtonWidth !== Value) this.FButtonWidth = Value;
    };
    this.SetButtonHeight = function (Value) {
      if (this.FButtonHeight !== Value) this.FButtonHeight = Value;
    };
    this.HandleControlMouseDown = function (Button, Shift, X, Y) {
      $mod.TTMSFNCGridCell.HandleControlMouseDown.apply(this,arguments);
      this.FButtonDown = true;
    };
    this.HandleControlMouseUp = function (Button, Shift, X, Y) {
      $mod.TTMSFNCGridCell.HandleControlMouseUp.apply(this,arguments);
      this.FButtonDown = false;
    };
    this.GetControlWidth = function () {
      var Result = 0.0;
      Result = this.FButtonWidth;
      return Result;
    };
    this.GetControlHeight = function () {
      var Result = 0.0;
      Result = this.FButtonHeight;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCGridCell.Create$1.apply(this,arguments);
      this.FButtonWidth = 24;
      this.FButtonHeight = 20;
      this.FButtonDown = false;
      return this;
    };
    this.DrawControl = function (AGraphics) {
      var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      rc.$assign(this.GetControlRect(true));
      rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(rc.Left),Math.round(rc.Top),Math.round(rc.Right),Math.round(rc.Bottom)));
      AGraphics.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),false,this.FButtonDown,this.FControlEnabled,true,1.0);
      if (this.FButtonText !== "") {
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(rc,-2,-2);
        AGraphics.FFont.SetColor(0);
        AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),this.FButtonText,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttWord,0,-1,-1,true,false,-1,-1);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("ButtonText",2,rtl.string,"FButtonText","SetButtonText");
    $r.addProperty("ButtonWidth",2,rtl.longint,"FButtonWidth","SetButtonWidth",4,{Default: 24});
    $r.addProperty("ButtonHeight",2,rtl.longint,"FButtonHeight","SetButtonHeight",4,{Default: 20});
  });
  rtl.createClass(this,"TTMSFNCProgressGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FValue = 0.0;
      this.FColor = 0;
      this.FShowText = false;
      this.FTextColor = 0;
      this.FFormat = "";
    };
    this.SetValue = function (Value) {
      this.FValue = Value;
    };
    this.SetColor = function (Value) {
      this.FColor = Value;
    };
    this.SetShowText = function (Value) {
      this.FShowText = Value;
    };
    this.SetTextColor = function (Value) {
      this.FTextColor = Value;
    };
    this.SetFormat = function (Value) {
      this.FFormat = Value;
    };
    this.Draw = function (AGraphics, ADrawText, ADrawBackGround, ADrawBorder) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      $mod.TTMSFNCGridCell.Draw.apply(this,arguments);
      if (ADrawBackGround) {
        r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft + 4,this.FTop + 4,(this.FLeft + this.FWidth) - 4,(this.FTop + this.FHeight) - 4));
        AGraphics.DrawProgressBar(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FValue,this.FFormat,100,this.FColor,this.FTextColor,this.FShowText,true,1.0);
      };
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCGridCell.Create$1.apply(this,arguments);
      this.FValue = 0;
      this.FColor = 3329434;
      this.FTextColor = 0;
      this.FShowText = true;
      this.FFormat = "%.0f%%";
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Value",2,rtl.double,"FValue","SetValue");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 3329434});
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor",4,{Default: 0});
    $r.addProperty("ShowText",2,rtl.boolean,"FShowText","SetShowText",4,{Default: true});
    $r.addProperty("Format",2,rtl.string,"FFormat","SetFormat");
  });
  rtl.createClass(this,"TTMSFNCCommentGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FCommentColor = 0;
      this.FCommentText = "";
      this.FCommentTextColor = 0;
    };
    this.PtInComment = function (X, Y) {
      var Result = false;
      var pth = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft,this.FTop,this.FLeft + this.FWidth,this.FTop + this.FHeight));
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-3,-3);
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
      g.BeginScene();
      g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
      g.FBitmapContainer = this.FBitmapContainer;
      pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
      try {
        pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - 7,r.Top));
        pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top));
        pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top + 7));
        pth.ClosePath();
        Result = g.$class.PointInPath(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(X,Y)),pth);
      } finally {
        pth = rtl.freeLoc(pth);
        g.EndScene();
        g = rtl.freeLoc(g);
      };
      return Result;
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCGridCell.Create$1.apply(this,arguments);
      this.FCommentColor = 255;
      this.FCommentTextColor = 0;
      return this;
    };
    this.HandleMouseDown = function (Button, Shift, X, Y, AHandled) {
      $mod.TTMSFNCGridCell.HandleMouseDown.apply(this,arguments);
      AHandled.set(this.PtInComment(X,Y));
    };
    this.HandleMouseMove = function (Shift, X, Y, AHandled, ACursor) {
      $mod.TTMSFNCGridCell.HandleMouseMove.apply(this,arguments);
      AHandled.set(this.PtInComment(X,Y));
      if (AHandled.get()) ACursor.set(21);
    };
    this.HandleMouseUp = function (Button, Shift, X, Y, AHandled) {
      $mod.TTMSFNCGridCell.HandleMouseUp.apply(this,arguments);
      AHandled.set(this.PtInComment(X,Y));
      if (AHandled.get()) this.DoControlClick(this);
    };
    this.Draw = function (AGraphics, ADrawText, ADrawBackGround, ADrawBorder) {
      var pth = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      $mod.TTMSFNCGridCell.Draw.apply(this,arguments);
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft,this.FTop,this.FLeft + this.FWidth,this.FTop + this.FHeight));
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-3,-3);
      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      AGraphics.FFill.SetColor(this.FCommentColor);
      AGraphics.FStroke.SetColor(this.FCommentColor);
      pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
      try {
        pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - 7,r.Top));
        pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top));
        pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,r.Top + 7));
        pth.ClosePath();
        AGraphics.DrawPath(pth,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
      } finally {
        pth = rtl.freeLoc(pth);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("CommentText",0,rtl.string,"FCommentText","FCommentText");
    $r.addProperty("CommentColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FCommentColor","FCommentColor",4,{Default: 255});
    $r.addProperty("CommentTextColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FCommentTextColor","FCommentTextColor",4,{Default: 0});
  });
  rtl.createClass(this,"TTMSFNCFixedGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FShowDropDownButton = false;
      this.FSortIndex = 0;
      this.FSortKind = 0;
      this.FSizeMargin = 0;
    };
    this.PtInDropDown = function (X, Y) {
      var Result = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var mgr = 0.0;
      var sz = 0.0;
      Result = false;
      if (!this.FShowDropDownButton) return Result;
      mgr = (this.FSizeMargin + 2) * this.FScaleFactor;
      sz = 15 * this.FScaleFactor;
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF((this.FLeft + this.FWidth) - sz - mgr,this.FTop + ((this.FHeight - sz) / 2),(this.FLeft + this.FWidth) - mgr,this.FTop + ((this.FHeight - sz) / 2) + sz));
      Result = pas["WEBLib.TMSFNCTypes"].PtInRectEx(r,pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
      return Result;
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCGridCell.Create$1.apply(this,arguments);
      this.FSizeMargin = 0;
      return this;
    };
    this.HandleMouseDown = function (Button, Shift, X, Y, AHandled) {
      $mod.TTMSFNCGridCell.HandleMouseDown.apply(this,arguments);
      AHandled.set(this.PtInDropDown(X,Y));
    };
    this.HandleMouseMove = function (Shift, X, Y, AHandled, ACursor) {
      $mod.TTMSFNCGridCell.HandleMouseMove.apply(this,arguments);
      AHandled.set(this.PtInDropDown(X,Y));
    };
    this.HandleMouseUp = function (Button, Shift, X, Y, AHandled) {
      $mod.TTMSFNCGridCell.HandleMouseUp.apply(this,arguments);
      AHandled.set(this.PtInDropDown(X,Y));
      if (AHandled.get()) this.DoControlClick(this);
    };
    this.Draw = function (AGraphics, ADrawText, ADrawBackGround, ADrawBorder) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sz = 0.0;
      var szr = 0.0;
      var mgr = 0.0;
      $mod.TTMSFNCGridCell.Draw.apply(this,arguments);
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FLeft,this.FTop,this.FLeft + this.FWidth,this.FTop + this.FHeight));
      sr.$assign(r);
      mgr = (this.FSizeMargin + 2) * this.FScaleFactor;
      if (this.FShowDropDownButton) {
        sz = 15 * this.FScaleFactor;
        dr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right - sz - mgr,r.Top + ((r.Bottom - r.Top - sz) / 2),r.Right - mgr,r.Top + ((r.Bottom - r.Top - sz) / 2) + sz));
        AGraphics.DrawDropDownButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(dr.Left),pas.System.Int(dr.Top),pas.System.Int(dr.Right),pas.System.Int(dr.Bottom))),false,false,true,true,false,1.0);
        sr.Right = dr.Left;
      };
      if (this.FSortKind !== $mod.TTMSFNCGridSortKind.skNone) {
        szr = 12 * this.FScaleFactor;
        sr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(sr.Right - szr - (3 * this.FScaleFactor) - mgr,sr.Top + ((sr.Bottom - sr.Top - szr) / 2),sr.Right - (3 * this.FScaleFactor) - mgr,sr.Top + ((sr.Bottom - sr.Top - szr) / 2) + szr));
        this.DrawSortIndicator(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(sr));
      };
    };
    this.DrawSortIndicator = function (AGraphics, ARect) {
      var pth = null;
      var vertt = 0;
      var c = 0;
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FSortIndex === -1) {
        c = 11829830}
       else c = 17919;
      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      AGraphics.FFill.SetColor(c);
      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      AGraphics.FStroke.SetColor(c);
      vertt = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      txtr.$assign(ARect);
      pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
      try {
        var $tmp = this.FSortKind;
        if ($tmp === $mod.TTMSFNCGridSortKind.skAscending) {
          vertt = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing;
          pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ((ARect.Right - ARect.Left) / 2),ARect.Top));
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom));
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom));
          txtr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top + 2,ARect.Right,ARect.Bottom + 2));
        } else if ($tmp === $mod.TTMSFNCGridSortKind.skDescending) {
          vertt = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
          pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top));
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top));
          pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ((ARect.Right - ARect.Left) / 2),ARect.Bottom));
          txtr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top - 2,ARect.Right,ARect.Bottom - 2));
        };
        pth.ClosePath();
        AGraphics.DrawPath(pth,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
        if (this.FSortIndex !== -1) {
          AGraphics.FFont.SetColor(16777215);
          pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,9,1);
          AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),pas.SysUtils.IntToStr(this.FSortIndex),false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,vertt,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
        };
      } finally {
        pth = rtl.freeLoc(pth);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("ShowDropDownButton",0,rtl.boolean,"FShowDropDownButton","FShowDropDownButton",4,{Default: false});
    $r.addProperty("SortKind",0,$mod.$rtti["TTMSFNCGridSortKind"],"FSortKind","FSortKind",4,{Default: $mod.TTMSFNCGridSortKind.skDescending});
    $r.addProperty("SortIndex",0,rtl.longint,"FSortIndex","FSortIndex",4,{Default: -1});
    $r.addProperty("SizeMargin",0,rtl.longint,"FSizeMargin","FSizeMargin",4,{Default: 0});
  });
  rtl.createClass(this,"TTMSFNCNodeGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FState = 0;
    };
    this.HandleControlMouseMove = function (Shift, X, Y, ACursor) {
      $mod.TTMSFNCGridCell.HandleControlMouseMove.apply(this,arguments);
      ACursor.set(21);
    };
    var $r = this.$rtti;
    $r.addProperty("State",0,$mod.$rtti["TTMSFNCGridNodeState"],"FState","FState",4,{Default: $mod.TTMSFNCGridNodeState.nsClosed});
  });
  rtl.createClass(this,"TTMSFNCBitmapGridCell",this.TTMSFNCGridCell,function () {
    this.$init = function () {
      $mod.TTMSFNCGridCell.$init.call(this);
      this.FBitmap = null;
      this.FBitmapName = "";
    };
    this.$final = function () {
      this.FBitmap = undefined;
      $mod.TTMSFNCGridCell.$final.call(this);
    };
    this.SetBitmap = function (Value) {
      if (this.FBitmap !== Value) {
        this.FBitmap.Assign(Value);
      };
    };
    this.SetBitmapName = function (Value) {
      if (this.FBitmapName !== Value) {
        this.FBitmapName = Value;
      };
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCGridCell.Create$1.apply(this,arguments);
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.SetControlEnabled(false);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      $mod.TTMSFNCGridCell.Destroy.call(this);
    };
    this.GetControlBitmap = function () {
      var Result = null;
      Result = null;
      if ((this.FBitmap != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FBitmap)) {
        Result = this.FBitmap}
       else if ((this.FBitmapContainer != null) && (this.FBitmapName !== "")) Result = this.FBitmapContainer.FindBitmap$1(this.FBitmapName);
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("BitmapName",2,rtl.string,"FBitmapName","SetBitmapName");
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
  });
},["Math","SysUtils","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCGridDataUtil",["System","Classes","Types","SysUtils"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TTMSFNCGridAutoType = {"0": "atNumeric", atNumeric: 0, "1": "atFloat", atFloat: 1, "2": "atString", atString: 2, "3": "atDate", atDate: 3, "4": "atTime", atTime: 4, "5": "atScientific", atScientific: 5};
  this.$rtti.$Enum("TTMSFNCGridAutoType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCGridAutoType});
  rtl.createClass(this,"TTMSFNCGridIntList",pas.Classes.TList,function () {
    this.SetInteger = function (Index, Value) {
      this.Put(Index,Value);
    };
    this.GetInteger = function (Index) {
      var Result = 0;
      Result = rtl.trunc(this.Get(Index));
      return Result;
    };
    this.GetStrValue = function () {
      var Result = "";
      var i = 0;
      for (var $l = 1, $end = this.GetCount(); $l <= $end; $l++) {
        i = $l;
        if (i === 1) {
          Result = pas.SysUtils.IntToStr(this.GetInteger(i - 1))}
         else Result = Result + "," + pas.SysUtils.IntToStr(this.GetInteger(i - 1));
      };
      return Result;
    };
    this.SetStrValue = function (Value) {
      var sl = null;
      var i = 0;
      sl = pas.Classes.TStringList.$create("Create$1");
      sl.SetCommaText(Value);
      this.Clear();
      for (var $l = 1, $end = sl.GetCount(); $l <= $end; $l++) {
        i = $l;
        this.Add$1(pas.SysUtils.StrToInt(sl.Get(i - 1)));
      };
      sl = rtl.freeLoc(sl);
    };
    this.DeleteValue = function (Value) {
      var i = 0;
      i = this.IndexOf(Value);
      if (i !== -1) this.Delete$1(i);
    };
    this.HasValue = function (Value) {
      var Result = false;
      Result = this.IndexOfValue(Value) !== -1;
      return Result;
    };
    this.IndexOfValue = function (Value) {
      var Result = 0;
      Result = this.IndexOf(Value);
      return Result;
    };
    this.Add$1 = function (Value) {
      pas.Classes.TList.Add.call(this,Value);
    };
    this.Insert$1 = function (Index, Value) {
      pas.Classes.TList.Insert.call(this,Index,Value);
    };
    this.Delete$1 = function (Index) {
      pas.Classes.TList.Delete.call(this,Index);
    };
  });
  this.IsType = function (s) {
    var Result = 0;
    var i = 0;
    var isI = false;
    var isF = false;
    var isS = false;
    var th = 0;
    var de = 0;
    var mi = 0;
    var isE = false;
    Result = $mod.TTMSFNCGridAutoType.atString;
    if (s === "") return Result;
    isI = true;
    isF = true;
    isS = true;
    isE = false;
    th = -1;
    de = 0;
    mi = 0;
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (!$impl.CheckSignedNum(s.charAt(i - 1))) isI = false;
      if ((s.charAt(i - 1) === "e") || (s.charAt(i - 1) === "E")) {
        if (isE) isS = false;
        isE = true;
      };
      if ((i > 1) && (s.charAt(i - 1) === "-")) {
        isI = false;
        isF = false;
      };
      if ((i === 1) && ((s.charAt(i - 1) === "e") || (s.charAt(i - 1) === "E"))) isS = false;
      if ((i === s.length) && ((s.charAt(i - 1) === "e") || (s.charAt(i - 1) === "E") || (s.charAt(i - 1) === "+") || (s.charAt(i - 1) === "-"))) isS = false;
      if (!($impl.CheckNum(s.charAt(i - 1)) || (s.charAt(i - 1) === "-") || (s.charAt(i - 1) === pas.SysUtils.FormatSettings.ThousandSeparator) || (s.charAt(i - 1) === pas.SysUtils.FormatSettings.DecimalSeparator))) isF = false;
      if (!($impl.CheckSignedFloatNum(s.charAt(i - 1)) && (s.charAt(i - 1) !== pas.SysUtils.FormatSettings.ThousandSeparator))) isS = false;
      if ((s.charAt(i - 1) === pas.SysUtils.FormatSettings.ThousandSeparator) && ((i - th) < 4) && (th !== -1)) {
        isF = false;
      };
      if (s.charAt(i - 1) === pas.SysUtils.FormatSettings.ThousandSeparator) {
        th = i;
      };
      if (s.charAt(i - 1) === pas.SysUtils.FormatSettings.DecimalSeparator) de += 1;
      if (s.charAt(i - 1) === "-") mi += 1;
    };
    if (isI) {
      Result = $mod.TTMSFNCGridAutoType.atNumeric}
     else {
      if (isF && !isE) Result = $mod.TTMSFNCGridAutoType.atFloat;
      if (isS && isE) {
        if (mi === 2) mi = 1;
        Result = $mod.TTMSFNCGridAutoType.atScientific;
      };
    };
    if ((mi > 1) || (de > 1)) Result = $mod.TTMSFNCGridAutoType.atString;
    return Result;
  };
  this.CharPos = function (ch, s) {
    var Result = 0;
    var i = 0;
    Result = 0;
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) === ch) {
        Result = i;
        break;
      };
    };
    return Result;
  };
  this.NumSingleChar = function (p, s) {
    var Result = 0;
    var Res = 0;
    var sp = 0;
    Res = 0;
    sp = -1;
    while ($mod.SinglePos(p,s,{get: function () {
        return sp;
      }, set: function (v) {
        sp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,sp);
      Res += 1;
    };
    Result = Res;
    return Result;
  };
  this.DoubleToSingleChar = function (ch, s) {
    var Result = "";
    var Res = "";
    var i = 0;
    if ((s === "") || ($mod.CharPos(ch,s) === 0)) {
      Result = s;
      return Result;
    };
    Res = "";
    i = 1;
    do {
      Res = Res + s.charAt(i - 1);
      if ((s.charAt(i - 1) === ch) && (s.charAt((i + 1) - 1) === ch)) i += 1;
      i += 1;
    } while (!(i > s.length));
    Result = Res;
    return Result;
  };
  this.CSVToLineFeeds = function (s) {
    var res = "";
    var i = 0;
    if ($mod.CharPos("\x0B",s.get()) === 0) return;
    res = "";
    for (var $l = 1, $end = s.get().length; $l <= $end; $l++) {
      i = $l;
      if (s.get().charAt(i - 1) === "\x0B") {
        res = res + "\r\n"}
       else res = res + s.get().charAt(i - 1);
    };
    s.set(res);
  };
  this.VarCharPos = function (ch, s, Res) {
    var Result = 0;
    var i = 0;
    Result = 0;
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) === ch) {
        Res.set(i);
        Result = i;
        break;
      };
    };
    return Result;
  };
  this.NumChar = function (p, s) {
    var Result = 0;
    var Res = 0;
    var vp = 0;
    Res = 0;
    vp = -1;
    while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(p,s,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,vp);
      Res += 1;
    };
    Result = Res;
    return Result;
  };
  this.SinglePos = function (p, s, sp) {
    var Result = 0;
    var i = 0;
    var QuoteCount = 0;
    i = 1;
    QuoteCount = 0;
    while (i <= s.length) {
      if (s.charAt(i - 1) === p) {
        if (i < s.length) {
          QuoteCount += 1}
         else if (i === s.length) {
          Result = i;
          sp.set(i);
          return Result;
        };
      } else {
        if (pas.System.Odd(QuoteCount)) {
          Result = i - 1;
          sp.set(i - 1);
          return Result;
        } else QuoteCount = 0;
      };
      i += 1;
    };
    Result = 0;
    sp.set(0);
    return Result;
  };
  this.GetToken = function (s, separator) {
    var Result = "";
    var sp = 0;
    Result = "";
    sp = pas.System.Pos(separator,s.get());
    if (sp > 0) {
      Result = pas.System.Copy(s.get(),1,sp - 1);
      pas.System.Delete(s,1,sp);
    };
    return Result;
  };
  this.FileToLf = function (s, multiline) {
    var Result = "";
    var i = 0;
    if (pas.System.Pos("\b",s) > 0) for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) === "\t") s = rtl.setCharAt(s,i - 1,"\r");
      if (s.charAt(i - 1) === "\b") s = rtl.setCharAt(s,i - 1,"\n");
      if (s.charAt(i - 1) === "\x01") s = rtl.setCharAt(s,i - 1,"\x00");
    };
    if (!multiline) {
      Result = $mod.GetNextLine({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},multiline)}
     else Result = s;
    return Result;
  };
  this.LfToFile = function (s) {
    var Result = "";
    var i = 0;
    if (pas.System.Pos("\r",s) > 0) for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) === "\r") s = rtl.setCharAt(s,i - 1,"\t");
      if (s.charAt(i - 1) === "\n") s = rtl.setCharAt(s,i - 1,"\b");
      if (s.charAt(i - 1) === "\x00") s = rtl.setCharAt(s,i - 1,"\x01");
    };
    Result = s;
    return Result;
  };
  this.GetNextLine = function (s, multiline) {
    var Result = "";
    var vp = 0;
    vp = -1;
    if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos($impl.LINEFEED,s.get(),{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Result = pas.System.Copy(s.get(),1,vp - 1);
      pas.System.Delete(s,1,vp);
      if (s.get() !== "") if (s.get().charAt(0) === "\n") pas.System.Delete(s,1,1);
      if (!multiline) s.set("");
    } else {
      Result = s.get();
      s.set("");
    };
    return Result;
  };
  this.CSVQuotes = function (S) {
    var Result = "";
    var i = 0;
    Result = "";
    for (var $l = 1, $end = S.length; $l <= $end; $l++) {
      i = $l;
      Result = Result + S.charAt(i - 1);
      if (S.charAt(i - 1) === '"') Result = Result + '"';
    };
    return Result;
  };
  this.LineFeedsToCSV = function (s) {
    var vp = 0;
    vp = -1;
    while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("\r\n",s.get(),{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      pas.System.Delete(s,vp,1);
      s.set(rtl.setCharAt(s.get(),vp - 1,"\x0B"));
    };
    s.set('"' + s.get() + '"');
  };
  this.LineFeedsToCSVNQ = function (s) {
    var vp = 0;
    vp = -1;
    while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("\r\n",s.get(),{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) pas.System.Delete(s,vp,1);
  };
  this.LinesInText = function (s, multiline) {
    var Result = 0;
    var vp = 0;
    Result = 1;
    if (!multiline) return Result;
    vp = -1;
    while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos($impl.LINEFEED,s,{get: function () {
        return vp;
      }, set: function (v) {
        vp = v;
      }}) > 0) {
      Result += 1;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,vp);
    };
    return Result;
  };
  this.HTMLLineBreaks = function (s) {
    var Result = "";
    var i = 0;
    var res = "";
    res = "";
    if (pas.System.Pos("\r",s) === 0) {
      res = s}
     else for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) !== "\r") {
        res = res + s.charAt(i - 1)}
       else res = res + "<br>";
    };
    Result = res;
    return Result;
  };
  this.CRToLF = function (s) {
    var Result = "";
    var i = 0;
    var res = "";
    res = "";
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) !== "\r") {
        res = res + s.charAt(i - 1)}
       else res = res + "\n";
    };
    Result = res;
    return Result;
  };
  this.FixNonBreaking = function (su) {
    var Result = "";
    while (pas.System.Pos(" ",su) > 0) {
      $impl.TagReplaceString(" ","&nbsp;",{get: function () {
          return su;
        }, set: function (v) {
          su = v;
        }});
    };
    Result = su;
    return Result;
  };
  this.IsURL = function (s) {
    var Result = false;
    var su = "";
    su = pas.SysUtils.UpperCase(s);
    Result = (pas.System.Pos("HTTP://",su) === 1) || (pas.System.Pos("HTTPS://",su) === 1) || (pas.System.Pos("FTP://",su) === 1) || (pas.System.Pos("NNTP://",su) === 1) || (pas.System.Pos("MAILTO:",su) === 1);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.LINEFEED = "\r";
    $impl.IsNumber = function (ch) {
      var Result = false;
      Result = ch.charCodeAt() in rtl.createSet(null,0x30,0x39);
      return Result;
    };
    $impl.CheckNum = function (ch) {
      var Result = false;
      Result = $impl.IsNumber(ch);
      return Result;
    };
    $impl.CheckSignedNum = function (ch) {
      var Result = false;
      Result = $impl.IsNumber(ch) || (ch === "-");
      return Result;
    };
    $impl.CheckExpNum = function (ch) {
      var Result = false;
      Result = $impl.IsNumber(ch) || (ch === "e") || (ch === "E");
      return Result;
    };
    $impl.CheckFloatNum = function (ch) {
      var Result = false;
      Result = $impl.IsNumber(ch) || (ch === pas.SysUtils.FormatSettings.ThousandSeparator) || (ch === pas.SysUtils.FormatSettings.DecimalSeparator) || (ch === "e") || (ch === "E");
      return Result;
    };
    $impl.CheckSignedDottedNum = function (ch) {
      var Result = false;
      Result = $impl.IsNumber(ch) || (ch === ".") || (ch === "-") || (ch === "e") || (ch === "E") || (ch === "+");
      return Result;
    };
    $impl.CheckSignedFloatNum = function (ch) {
      var Result = false;
      Result = $impl.CheckFloatNum(ch) || (ch === "+") || (ch === "-");
      return Result;
    };
    $impl.IPos = function (su, s) {
      var Result = 0;
      Result = pas.System.Pos(pas.SysUtils.UpperCase(su),pas.SysUtils.UpperCase(s));
      return Result;
    };
    $impl.TagReplaceString = function (Srch, Repl, Dest) {
      var Result = false;
      var i = 0;
      i = $impl.IPos(Srch,Dest.get());
      if (i > 0) {
        Result = true;
        pas.System.Delete(Dest,i,Srch.length);
        Dest.set(pas.System.Copy(Dest.get(),1,i - 1) + Repl + pas.System.Copy(Dest.get(),i,Dest.get().length));
      } else Result = false;
      return Result;
    };
  };
},["WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCGridOptions",["System","Classes","WEBLib.TMSFNCGridDataUtil","WEBLib.TMSFNCGraphicsTypes"],function () {
  "use strict";
  var $mod = this;
  this.TTMSFNCGridTabKeyHandling = {"0": "tkhNextControl", tkhNextControl: 0, "1": "tkhNextCell", tkhNextCell: 1, "2": "tkhMixed", tkhMixed: 2};
  this.$rtti.$Enum("TTMSFNCGridTabKeyHandling",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridTabKeyHandling});
  this.TTMSFNCGridTabKeyDirection = {"0": "tkdNextColumnCell", tkdNextColumnCell: 0, "1": "tkdNextRowCell", tkdNextRowCell: 1};
  this.$rtti.$Enum("TTMSFNCGridTabKeyDirection",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridTabKeyDirection});
  this.TTMSFNCGridPrintPosition = {"0": "ppTopLeft", ppTopLeft: 0, "1": "ppTopCenter", ppTopCenter: 1, "2": "ppTopRight", ppTopRight: 2, "3": "ppBottomLeft", ppBottomLeft: 3, "4": "ppBottomCenter", ppBottomCenter: 4, "5": "ppBottomRight", ppBottomRight: 5};
  this.$rtti.$Enum("TTMSFNCGridPrintPosition",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCGridPrintPosition});
  this.TTMSFNCGridPrintCellBackground = {"0": "cbNone", cbNone: 0, "1": "cbCellColor", cbCellColor: 1, "2": "cbFull", cbFull: 2};
  this.$rtti.$Enum("TTMSFNCGridPrintCellBackground",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridPrintCellBackground});
  rtl.createClass(this,"TTMSFNCGridScrollBarOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FVerticalScrollBarVisible = false;
      this.FHorizontalScrollBarVisible = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHorizontalScrollBarVisible = function (Value) {
      if (this.FHorizontalScrollBarVisible !== Value) {
        this.FHorizontalScrollBarVisible = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.SetVerticalScrollBarVisible = function (Value) {
      if (this.FVerticalScrollBarVisible !== Value) {
        this.FVerticalScrollBarVisible = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridScrollBarOptions.isPrototypeOf(Source)) {
        this.SetVerticalScrollBarVisible(rtl.as(Source,$mod.TTMSFNCGridScrollBarOptions).FVerticalScrollBarVisible);
        this.SetHorizontalScrollBarVisible(rtl.as(Source,$mod.TTMSFNCGridScrollBarOptions).FHorizontalScrollBarVisible);
      };
    };
    this.Create$1 = function () {
      this.FVerticalScrollBarVisible = true;
      this.FHorizontalScrollBarVisible = true;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("HorizontalScrollBarVisible",2,rtl.boolean,"FHorizontalScrollBarVisible","SetHorizontalScrollBarVisible",4,{Default: true});
    $r.addProperty("VerticalScrollBarVisible",2,rtl.boolean,"FVerticalScrollBarVisible","SetVerticalScrollBarVisible",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCGridBandOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FEnabled = false;
      this.FOnChange = null;
      this.FBandRowCount = 0;
      this.FNormalRowCount = 0;
      this.FTotalRowCount = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.Changed();
      };
    };
    this.SetBandRowCount = function (Value) {
      if ((Value > 0) && (this.FBandRowCount !== Value)) {
        this.FBandRowCount = Value;
        this.FTotalRowCount = this.FNormalRowCount + this.FBandRowCount;
        this.Changed();
      };
    };
    this.SetNormalRowCount = function (Value) {
      if ((Value > 0) && (this.FNormalRowCount !== Value)) {
        this.FNormalRowCount = Value;
        this.FTotalRowCount = this.FNormalRowCount + this.FBandRowCount;
        this.Changed();
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridBandOptions.isPrototypeOf(Source)) {
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCGridBandOptions).FEnabled;
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FEnabled = false;
      this.FNormalRowCount = 1;
      this.FBandRowCount = 1;
      return this;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    var $r = this.$rtti;
    $r.addProperty("NormalRowCount",2,rtl.longint,"FNormalRowCount","SetNormalRowCount",4,{Default: 1});
    $r.addProperty("BandRowCount",2,rtl.longint,"FBandRowCount","SetBandRowCount",4,{Default: 1});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: false});
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  this.TTMSFNCGridSelectionMode = {"0": "smNone", smNone: 0, "1": "smSingleCell", smSingleCell: 1, "2": "smSingleRow", smSingleRow: 2, "3": "smSingleColumn", smSingleColumn: 3, "4": "smCellRange", smCellRange: 4, "5": "smRowRange", smRowRange: 5, "6": "smColumnRange", smColumnRange: 6, "7": "smDisjunctRow", smDisjunctRow: 7, "8": "smDisjunctColumn", smDisjunctColumn: 8, "9": "smDisjunctCell", smDisjunctCell: 9};
  this.$rtti.$Enum("TTMSFNCGridSelectionMode",{minvalue: 0, maxvalue: 9, ordtype: 1, enumtype: this.TTMSFNCGridSelectionMode});
  rtl.createClass(this,"TTMSFNCGridSelection",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMode = 0;
      this.FOnChange = null;
      this.FShowSelectionInFixedCells = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetMode = function (Value) {
      if (this.FMode !== Value) {
        this.FMode = Value;
        this.Changed();
      };
    };
    this.SetShowSelectionInFixedCells = function (Value) {
      if (this.FShowSelectionInFixedCells !== Value) {
        this.FShowSelectionInFixedCells = Value;
        this.Changed();
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridSelection.isPrototypeOf(Source)) {
        this.FMode = rtl.as(Source,$mod.TTMSFNCGridSelection).FMode;
        this.FShowSelectionInFixedCells = rtl.as(Source,$mod.TTMSFNCGridSelection).FShowSelectionInFixedCells;
      };
    };
    this.Create$1 = function () {
      this.FMode = $mod.TTMSFNCGridSelectionMode.smSingleCell;
      return this;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    var $r = this.$rtti;
    $r.addProperty("Mode",2,$mod.$rtti["TTMSFNCGridSelectionMode"],"FMode","SetMode",4,{Default: $mod.TTMSFNCGridSelectionMode.smSingleCell});
    $r.addProperty("ShowSelectionInFixedCells",2,rtl.boolean,"FShowSelectionInFixedCells","SetShowSelectionInFixedCells",4,{Default: false});
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  this.TTMSFNCGridFixedCellSelectionMode = {"0": "fcsAll", fcsAll: 0, "1": "fcsRow", fcsRow: 1, "2": "fcsColumn", fcsColumn: 2, "3": "fcsRowRange", fcsRowRange: 3, "4": "fcsColumnRange", fcsColumnRange: 4, "5": "fcsDisjunctRow", fcsDisjunctRow: 5, "6": "fcsDisjunctColumn", fcsDisjunctColumn: 6};
  this.$rtti.$Enum("TTMSFNCGridFixedCellSelectionMode",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TTMSFNCGridFixedCellSelectionMode});
  this.$rtti.$Set("TTMSFNCGridFixedCellSelection",{comptype: this.$rtti["TTMSFNCGridFixedCellSelectionMode"]});
  this.TTMSFNCGridAutoScrollingSpeedMode = {"0": "asmPixels", asmPixels: 0, "1": "asmCell", asmCell: 1};
  this.$rtti.$Enum("TTMSFNCGridAutoScrollingSpeedMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridAutoScrollingSpeedMode});
  rtl.createClass(this,"TTMSFNCGridMouseOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FDirectEdit = false;
      this.FWheelScrollSize = 0;
      this.FAutoDragging = false;
      this.FFixedRowSizing = false;
      this.FFixedColumnSizing = false;
      this.FRowDragging = false;
      this.FColumnDragging = false;
      this.FAutoScrollingInterval = 0;
      this.FRowSizing = false;
      this.FColumnSizing = false;
      this.FAutoScrollingSpeed = 0;
      this.FAutoScrolling = false;
      this.FTouchScrolling = false;
      this.FTouchScrollingSensitivity = 0.0;
      this.FFixedCellSelection = {};
      this.FRowAutoSizeOnDblClick = false;
      this.FColumnAutoSizeOnDblClick = false;
      this.FWheelScrollKeepSelection = false;
      this.FRowSizeMargin = 0;
      this.FColumnSizeMargin = 0;
      this.FAutoScrollingSpeedMode = 0;
      this.FClickMargin = 0;
    };
    this.$final = function () {
      this.FFixedCellSelection = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetWheelScrollSize = function (Value) {
      this.FWheelScrollSize = Value;
    };
    this.SetAutoScrollingInterval = function (Value) {
      this.FAutoScrollingInterval = Value;
    };
    this.SetTouchScrolling = function (Value) {
      this.FTouchScrolling = Value;
    };
    this.SetWheelScrollKeepSelection = function (Value) {
      this.FWheelScrollKeepSelection = Value;
    };
    this.IsTouchScrollingSensitivityStored = function () {
      var Result = false;
      Result = this.FTouchScrollingSensitivity !== 1;
      return Result;
    };
    this.SetColumnSizeMargin = function (Value) {
      this.FColumnSizeMargin = Value;
    };
    this.SetRowSizeMargin = function (Value) {
      this.FRowSizeMargin = Value;
    };
    this.SetClickMargin = function (Value) {
      this.FClickMargin = Value;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridMouseOptions.isPrototypeOf(Source)) {
        this.FDirectEdit = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FDirectEdit;
        this.FWheelScrollSize = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FWheelScrollSize;
        this.FColumnSizing = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FColumnSizing;
        this.FRowSizing = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FRowSizing;
        this.FFixedColumnSizing = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FFixedColumnSizing;
        this.FFixedRowSizing = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FFixedRowSizing;
        this.FColumnDragging = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FColumnDragging;
        this.FRowDragging = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FRowDragging;
        this.FAutoScrolling = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FAutoScrolling;
        this.FAutoDragging = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FAutoDragging;
        this.FAutoScrollingSpeed = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FAutoScrollingSpeed;
        this.FAutoScrollingInterval = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FAutoScrollingInterval;
        this.FTouchScrolling = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FTouchScrolling;
        this.FTouchScrollingSensitivity = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FTouchScrollingSensitivity;
        this.FFixedCellSelection = rtl.refSet(rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FFixedCellSelection);
        this.FRowAutoSizeOnDblClick = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FRowAutoSizeOnDblClick;
        this.FColumnAutoSizeOnDblClick = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FColumnAutoSizeOnDblClick;
        this.FWheelScrollKeepSelection = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FWheelScrollKeepSelection;
        this.FColumnSizeMargin = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FColumnSizeMargin;
        this.FClickMargin = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FClickMargin;
        this.FRowSizeMargin = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FRowSizeMargin;
        this.FAutoScrollingSpeedMode = rtl.as(Source,$mod.TTMSFNCGridMouseOptions).FAutoScrollingSpeedMode;
      };
    };
    this.Create$1 = function () {
      this.FTouchScrollingSensitivity = 1;
      this.FTouchScrolling = false;
      this.FDirectEdit = false;
      this.FWheelScrollSize = 4;
      this.FColumnSizing = false;
      this.FRowSizing = false;
      this.FFixedColumnSizing = false;
      this.FFixedRowSizing = false;
      this.FColumnDragging = false;
      this.FRowDragging = false;
      this.FAutoScrolling = true;
      this.FAutoDragging = true;
      this.FAutoScrollingSpeed = 1;
      this.FAutoScrollingInterval = 100;
      this.FFixedCellSelection = {};
      this.FRowAutoSizeOnDblClick = true;
      this.FColumnAutoSizeOnDblClick = true;
      this.FWheelScrollKeepSelection = false;
      this.FColumnSizeMargin = 6;
      this.FRowSizeMargin = 6;
      this.FAutoScrollingSpeedMode = $mod.TTMSFNCGridAutoScrollingSpeedMode.asmPixels;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("DirectEdit",0,rtl.boolean,"FDirectEdit","FDirectEdit",4,{Default: false});
    $r.addProperty("WheelScrollSize",2,rtl.longint,"FWheelScrollSize","SetWheelScrollSize",4,{Default: 4});
    $r.addProperty("WheelScrollKeepSelection",2,rtl.boolean,"FWheelScrollKeepSelection","SetWheelScrollKeepSelection",4,{Default: false});
    $r.addProperty("ColumnSizing",0,rtl.boolean,"FColumnSizing","FColumnSizing",4,{Default: false});
    $r.addProperty("ClickMargin",2,rtl.longint,"FClickMargin","SetClickMargin",4,{Default: 2});
    $r.addProperty("ColumnSizeMargin",2,rtl.longint,"FColumnSizeMargin","SetColumnSizeMargin",4,{Default: 2});
    $r.addProperty("RowSizing",0,rtl.boolean,"FRowSizing","FRowSizing",4,{Default: false});
    $r.addProperty("RowSizeMargin",2,rtl.longint,"FRowSizeMargin","SetRowSizeMargin",4,{Default: 2});
    $r.addProperty("FixedColumnSizing",0,rtl.boolean,"FFixedColumnSizing","FFixedColumnSizing",4,{Default: false});
    $r.addProperty("FixedRowSizing",0,rtl.boolean,"FFixedRowSizing","FFixedRowSizing",4,{Default: false});
    $r.addProperty("FixedCellSelection",0,$mod.$rtti["TTMSFNCGridFixedCellSelection"],"FFixedCellSelection","FFixedCellSelection",4,{Default: {}});
    $r.addProperty("ColumnAutoSizeOnDblClick",0,rtl.boolean,"FColumnAutoSizeOnDblClick","FColumnAutoSizeOnDblClick",4,{Default: true});
    $r.addProperty("RowAutoSizeOnDblClick",0,rtl.boolean,"FRowAutoSizeOnDblClick","FRowAutoSizeOnDblClick",4,{Default: true});
    $r.addProperty("ColumnDragging",0,rtl.boolean,"FColumnDragging","FColumnDragging",4,{Default: false});
    $r.addProperty("RowDragging",0,rtl.boolean,"FRowDragging","FRowDragging",4,{Default: false});
    $r.addProperty("AutoScrolling",0,rtl.boolean,"FAutoScrolling","FAutoScrolling",4,{Default: true});
    $r.addProperty("AutoDragging",0,rtl.boolean,"FAutoDragging","FAutoDragging",4,{Default: true});
    $r.addProperty("AutoScrollingSpeedMode",0,$mod.$rtti["TTMSFNCGridAutoScrollingSpeedMode"],"FAutoScrollingSpeedMode","FAutoScrollingSpeedMode",4,{Default: $mod.TTMSFNCGridAutoScrollingSpeedMode.asmPixels});
    $r.addProperty("AutoScrollingSpeed",0,rtl.longint,"FAutoScrollingSpeed","FAutoScrollingSpeed",4,{Default: 1});
    $r.addProperty("AutoScrollingInterval",2,rtl.longint,"FAutoScrollingInterval","SetAutoScrollingInterval",4,{Default: 100});
    $r.addProperty("TouchScrolling",2,rtl.boolean,"FTouchScrolling","SetTouchScrolling",4,{Default: false});
    $r.addProperty("TouchScrollingSensitivity",12,rtl.double,"FTouchScrollingSensitivity","FTouchScrollingSensitivity",4,{stored: "IsTouchScrollingSensitivityStored"});
  });
  this.TTMSFNCGridInsertKeyHandling = {"0": "ikhNone", ikhNone: 0, "1": "ikhInsertRowBefore", ikhInsertRowBefore: 1, "2": "ikhInsertRowAfter", ikhInsertRowAfter: 2};
  this.$rtti.$Enum("TTMSFNCGridInsertKeyHandling",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridInsertKeyHandling});
  this.TTMSFNCGridEnterKeyHandling = {"0": "ekhNone", ekhNone: 0, "1": "ekhNextColumn", ekhNextColumn: 1, "2": "ekhNextRow", ekhNextRow: 2, "3": "ekhNextColumnInRow", ekhNextColumnInRow: 3, "4": "ekhNextRowInColumn", ekhNextRowInColumn: 4, "5": "ekhNextColumnAndAppend", ekhNextColumnAndAppend: 5, "6": "ekhNextRowAndAppend", ekhNextRowAndAppend: 6, "7": "ekhNextRowAndColumnAppend", ekhNextRowAndColumnAppend: 7, "8": "ekhNextColumnAndRowAppend", ekhNextColumnAndRowAppend: 8};
  this.$rtti.$Enum("TTMSFNCGridEnterKeyHandling",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TTMSFNCGridEnterKeyHandling});
  this.TTMSFNCGridDeleteKeyHandling = {"0": "dkhNone", dkhNone: 0, "1": "dkhDeleteRow", dkhDeleteRow: 1};
  this.$rtti.$Enum("TTMSFNCGridDeleteKeyHandling",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridDeleteKeyHandling});
  rtl.createClass(this,"TTMSFNCGridKeyboardOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FTabKeyDirection = 0;
      this.FTabKeyHandling = 0;
      this.FPageScrollSize = 0;
      this.FEnterKeyHandling = 0;
      this.FEnterKeyDirectEdit = false;
      this.FDeleteKeyHandling = 0;
      this.FInsertKeyHandling = 0;
      this.FTabKeyDirectEdit = false;
      this.FArrowKeyDirectEdit = false;
      this.FAllowCellMergeShortCut = false;
    };
    this.SetPageScrollSize = function (Value) {
      this.FPageScrollSize = Value;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridKeyboardOptions.isPrototypeOf(Source)) {
        this.FTabKeyDirection = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FTabKeyDirection;
        this.FTabKeyHandling = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FTabKeyHandling;
        this.FEnterKeyHandling = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FEnterKeyHandling;
        this.FDeleteKeyHandling = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FDeleteKeyHandling;
        this.FInsertKeyHandling = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FInsertKeyHandling;
        this.FEnterKeyDirectEdit = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FEnterKeyDirectEdit;
        this.FTabKeyDirectEdit = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FTabKeyDirectEdit;
        this.FArrowKeyDirectEdit = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FArrowKeyDirectEdit;
        this.FAllowCellMergeShortCut = rtl.as(Source,$mod.TTMSFNCGridKeyboardOptions).FAllowCellMergeShortCut;
      };
    };
    this.Create$1 = function () {
      this.FTabKeyDirection = $mod.TTMSFNCGridTabKeyDirection.tkdNextColumnCell;
      this.FTabKeyHandling = $mod.TTMSFNCGridTabKeyHandling.tkhMixed;
      this.FPageScrollSize = 0;
      this.FEnterKeyHandling = $mod.TTMSFNCGridEnterKeyHandling.ekhNone;
      this.FDeleteKeyHandling = $mod.TTMSFNCGridDeleteKeyHandling.dkhNone;
      this.FInsertKeyHandling = $mod.TTMSFNCGridInsertKeyHandling.ikhNone;
      this.FEnterKeyDirectEdit = false;
      this.FArrowKeyDirectEdit = false;
      this.FTabKeyDirectEdit = false;
      this.FAllowCellMergeShortCut = false;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("AllowCellMergeShortCut",0,rtl.boolean,"FAllowCellMergeShortCut","FAllowCellMergeShortCut",4,{Default: false});
    $r.addProperty("TabKeyDirectEdit",0,rtl.boolean,"FTabKeyDirectEdit","FTabKeyDirectEdit",4,{Default: false});
    $r.addProperty("ArrowKeyDirectEdit",0,rtl.boolean,"FArrowKeyDirectEdit","FArrowKeyDirectEdit",4,{Default: false});
    $r.addProperty("InsertKeyHandling",0,$mod.$rtti["TTMSFNCGridInsertKeyHandling"],"FInsertKeyHandling","FInsertKeyHandling",4,{Default: $mod.TTMSFNCGridInsertKeyHandling.ikhNone});
    $r.addProperty("DeleteKeyHandling",0,$mod.$rtti["TTMSFNCGridDeleteKeyHandling"],"FDeleteKeyHandling","FDeleteKeyHandling",4,{Default: $mod.TTMSFNCGridDeleteKeyHandling.dkhNone});
    $r.addProperty("EnterKeyHandling",0,$mod.$rtti["TTMSFNCGridEnterKeyHandling"],"FEnterKeyHandling","FEnterKeyHandling",4,{Default: $mod.TTMSFNCGridEnterKeyHandling.ekhNone});
    $r.addProperty("EnterKeyDirectEdit",0,rtl.boolean,"FEnterKeyDirectEdit","FEnterKeyDirectEdit",4,{Default: false});
    $r.addProperty("TabKeyHandling",0,$mod.$rtti["TTMSFNCGridTabKeyHandling"],"FTabKeyHandling","FTabKeyHandling",4,{Default: $mod.TTMSFNCGridTabKeyHandling.tkhMixed});
    $r.addProperty("TabKeyDirection",0,$mod.$rtti["TTMSFNCGridTabKeyDirection"],"FTabKeyDirection","FTabKeyDirection",4,{Default: $mod.TTMSFNCGridTabKeyDirection.tkdNextColumnCell});
    $r.addProperty("PageScrollSize",2,rtl.longint,"FPageScrollSize","SetPageScrollSize",4,{Default: 0});
  });
  this.TTMSFNCGridSortBlankPosition = {"0": "blFirst", blFirst: 0, "1": "blLast", blLast: 1};
  this.$rtti.$Enum("TTMSFNCGridSortBlankPosition",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridSortBlankPosition});
  this.TTMSFNCGridSortingMode = {"0": "gsmNone", gsmNone: 0, "1": "gsmNormal", gsmNormal: 1, "2": "gsmIndexed", gsmIndexed: 2};
  this.$rtti.$Enum("TTMSFNCGridSortingMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridSortingMode});
  this.TTMSFNCGridSortColumns = {"0": "scAll", scAll: 0, "1": "scNormal", scNormal: 1, "2": "scSingle", scSingle: 2};
  this.$rtti.$Enum("TTMSFNCGridSortColumns",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridSortColumns});
  this.TTMSFNCGridBorders = {"0": "bNone", bNone: 0, "1": "bAll", bAll: 1, "2": "bVertical", bVertical: 2, "3": "bHorizontal", bHorizontal: 3};
  this.$rtti.$Enum("TTMSFNCGridBorders",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGridBorders});
  rtl.createClass(this,"TTMSFNCGridSortingOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMode = 0;
      this.FRow = 0;
      this.FColumns = 0;
      this.FMultiColumn = false;
      this.FIgnoreCase = false;
      this.FIgnoreBlanks = false;
      this.FBlankPosition = 0;
    };
    this.SetMode = function (Value) {
      this.FMode = Value;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridSortingOptions.isPrototypeOf(Source)) {
        this.FMultiColumn = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FMultiColumn;
        this.FMode = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FMode;
        this.FColumns = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FColumns;
        this.FRow = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FRow;
        this.FBlankPosition = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FBlankPosition;
        this.FIgnoreCase = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FIgnoreCase;
        this.FIgnoreBlanks = rtl.as(Source,$mod.TTMSFNCGridSortingOptions).FIgnoreBlanks;
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FMode = $mod.TTMSFNCGridSortingMode.gsmNone;
      this.FMultiColumn = true;
      this.FRow = 0;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("BlankPosition",0,$mod.$rtti["TTMSFNCGridSortBlankPosition"],"FBlankPosition","FBlankPosition",4,{Default: $mod.TTMSFNCGridSortBlankPosition.blFirst});
    $r.addProperty("Row",0,rtl.longint,"FRow","FRow",4,{Default: 0});
    $r.addProperty("IgnoreCase",0,rtl.boolean,"FIgnoreCase","FIgnoreCase",4,{Default: false});
    $r.addProperty("IgnoreBlanks",0,rtl.boolean,"FIgnoreBlanks","FIgnoreBlanks",4,{Default: false});
    $r.addProperty("MultiColumn",0,rtl.boolean,"FMultiColumn","FMultiColumn",4,{Default: true});
    $r.addProperty("Mode",2,$mod.$rtti["TTMSFNCGridSortingMode"],"FMode","SetMode",4,{Default: $mod.TTMSFNCGridSortingMode.gsmNone});
    $r.addProperty("Columns",0,$mod.$rtti["TTMSFNCGridSortColumns"],"FColumns","FColumns",4,{Default: $mod.TTMSFNCGridSortColumns.scAll});
  });
  rtl.createClass(this,"TTMSFNCGridBorderOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FFixedCellBorders = 0;
      this.FCellBorders = 0;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridBorderOptions.isPrototypeOf(Source)) {
        this.FFixedCellBorders = rtl.as(Source,$mod.TTMSFNCGridBorderOptions).FFixedCellBorders;
        this.FCellBorders = rtl.as(Source,$mod.TTMSFNCGridBorderOptions).FCellBorders;
      };
    };
    this.Create$1 = function () {
      this.FFixedCellBorders = $mod.TTMSFNCGridBorders.bAll;
      this.FCellBorders = $mod.TTMSFNCGridBorders.bAll;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("FixedCellBorders",0,$mod.$rtti["TTMSFNCGridBorders"],"FFixedCellBorders","FFixedCellBorders",4,{Default: $mod.TTMSFNCGridBorders.bAll});
    $r.addProperty("CellBorders",0,$mod.$rtti["TTMSFNCGridBorders"],"FCellBorders","FCellBorders",4,{Default: $mod.TTMSFNCGridBorders.bAll});
  });
  this.TTMSFNCGridAutoComplete = {"0": "acDisabled", acDisabled: 0, "1": "acNormal", acNormal: 1, "2": "acLookupList", acLookupList: 2};
  this.$rtti.$Enum("TTMSFNCGridAutoComplete",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridAutoComplete});
  this.TTMSFNCGridAutoPost = {"0": "apNone", apNone: 0, "1": "apCell", apCell: 1, "2": "apRow", apRow: 2};
  this.$rtti.$Enum("TTMSFNCGridAutoPost",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridAutoPost});
  rtl.createClass(this,"TTMSFNCGridEditingOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FEnabled = false;
      this.FAutoComplete = 0;
      this.FAutoCompleteItems = null;
      this.FAutoHistory = false;
      this.FAutoCompleteCaseSensitive = false;
      this.FCalcFormat = "";
      this.FAutoPost = 0;
      this.FAutoCancel = false;
      this.FDirectComboClose = false;
      this.FDirectComboDrop = false;
      this.FEditWithTags = false;
    };
    this.$final = function () {
      this.FAutoCompleteItems = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetAutoCompleteItems = function (Value) {
      this.FAutoCompleteItems.Assign(Value);
    };
    this.SetAutoPost = function (Value) {
      this.FAutoPost = Value;
    };
    this.SetAutoCancel = function (Value) {
      this.FAutoCancel = Value;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridEditingOptions.isPrototypeOf(Source)) {
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FEnabled;
        this.FAutoComplete = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FAutoComplete;
        this.FAutoCompleteItems.Assign(rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FAutoCompleteItems);
        this.FAutoHistory = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FAutoHistory;
        this.FAutoCompleteCaseSensitive = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FAutoCompleteCaseSensitive;
        this.FCalcFormat = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FCalcFormat;
        this.FAutoPost = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FAutoPost;
        this.FAutoCancel = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FAutoCancel;
        this.FEditWithTags = rtl.as(Source,$mod.TTMSFNCGridEditingOptions).FEditWithTags;
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FEnabled = true;
      this.FAutoCompleteItems = pas.Classes.TStringList.$create("Create$1");
      this.FAutoCompleteItems.FDuplicates = pas.Types.TDuplicates.dupIgnore;
      this.FAutoComplete = $mod.TTMSFNCGridAutoComplete.acDisabled;
      this.FAutoHistory = false;
      this.FAutoCompleteCaseSensitive = true;
      this.FCalcFormat = "%g";
      this.FAutoPost = $mod.TTMSFNCGridAutoPost.apCell;
      this.FAutoCancel = false;
      this.FEditWithTags = true;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAutoCompleteItems");
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("AutoCancel",2,rtl.boolean,"FAutoCancel","SetAutoCancel",4,{Default: false});
    $r.addProperty("AutoComplete",0,$mod.$rtti["TTMSFNCGridAutoComplete"],"FAutoComplete","FAutoComplete",4,{Default: $mod.TTMSFNCGridAutoComplete.acDisabled});
    $r.addProperty("AutoCompleteCaseSensitive",0,rtl.boolean,"FAutoCompleteCaseSensitive","FAutoCompleteCaseSensitive",4,{Default: true});
    $r.addProperty("AutoCompleteItems",2,pas.Classes.$rtti["TStringList"],"FAutoCompleteItems","SetAutoCompleteItems");
    $r.addProperty("AutoHistory",0,rtl.boolean,"FAutoHistory","FAutoHistory",4,{Default: false});
    $r.addProperty("AutoPost",2,$mod.$rtti["TTMSFNCGridAutoPost"],"FAutoPost","SetAutoPost",4,{Default: $mod.TTMSFNCGridAutoPost.apCell});
    $r.addProperty("CalcFormat",0,rtl.string,"FCalcFormat","FCalcFormat");
    $r.addProperty("DirectComboDrop",0,rtl.boolean,"FDirectComboDrop","FDirectComboDrop",4,{Default: false});
    $r.addProperty("DirectComboClose",0,rtl.boolean,"FDirectComboClose","FDirectComboClose",4,{Default: false});
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",4,{Default: true});
    $r.addProperty("EditWithTags",0,rtl.boolean,"FEditWithTags","FEditWithTags",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCGridLookupOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FCaseSensitive = false;
      this.FIncremental = false;
      this.FEnabled = false;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridLookupOptions.isPrototypeOf(Source)) {
        this.FCaseSensitive = rtl.as(Source,$mod.TTMSFNCGridLookupOptions).FCaseSensitive;
        this.FIncremental = rtl.as(Source,$mod.TTMSFNCGridLookupOptions).FIncremental;
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCGridLookupOptions).FEnabled;
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FCaseSensitive = false;
      this.FIncremental = true;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive",4,{Default: false});
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",4,{Default: false});
    $r.addProperty("Incremental",0,rtl.boolean,"FIncremental","FIncremental",4,{Default: true});
  });
  this.TTMSFNCGridFilterRows = {"0": "frNormal", frNormal: 0, "1": "frAll", frAll: 1};
  this.$rtti.$Enum("TTMSFNCGridFilterRows",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridFilterRows});
  rtl.createClass(this,"TTMSFNCGridFilteringOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FRows = 0;
      this.FDropDownFixedRow = 0;
      this.FDropDown = false;
      this.FOnChange = null;
      this.FDropDownHeight = 0;
      this.FDropDownWidth = 0;
      this.FMultiColumn = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetDropDown = function (Value) {
      if (this.FDropDown !== Value) {
        this.FDropDown = Value;
        this.Changed();
      };
    };
    this.SetDropDownFixedRow = function (Value) {
      if (this.FDropDownFixedRow !== Value) {
        this.FDropDownFixedRow = Value;
        this.Changed();
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FRows = $mod.TTMSFNCGridFilterRows.frNormal;
      this.FDropDown = false;
      this.FDropDownFixedRow = 0;
      this.FDropDownWidth = 100;
      this.FDropDownHeight = 120;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridFilteringOptions.isPrototypeOf(Source)) {
        this.FRows = rtl.as(Source,$mod.TTMSFNCGridFilteringOptions).FRows;
        this.FDropDown = rtl.as(Source,$mod.TTMSFNCGridFilteringOptions).FDropDown;
        this.FDropDownFixedRow = rtl.as(Source,$mod.TTMSFNCGridFilteringOptions).FDropDownFixedRow;
        this.FDropDownWidth = rtl.as(Source,$mod.TTMSFNCGridFilteringOptions).FDropDownWidth;
        this.FDropDownHeight = rtl.as(Source,$mod.TTMSFNCGridFilteringOptions).FDropDownHeight;
        this.FMultiColumn = rtl.as(Source,$mod.TTMSFNCGridFilteringOptions).FMultiColumn;
      };
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    var $r = this.$rtti;
    $r.addProperty("Rows",0,$mod.$rtti["TTMSFNCGridFilterRows"],"FRows","FRows",4,{Default: $mod.TTMSFNCGridFilterRows.frNormal});
    $r.addProperty("DropDown",2,rtl.boolean,"FDropDown","SetDropDown",4,{Default: false});
    $r.addProperty("DropDownFixedRow",2,rtl.longint,"FDropDownFixedRow","SetDropDownFixedRow",4,{Default: 0});
    $r.addProperty("DropDownWidth",0,rtl.longint,"FDropDownWidth","FDropDownWidth",4,{Default: 100});
    $r.addProperty("DropDownHeight",0,rtl.longint,"FDropDownHeight","FDropDownHeight",4,{Default: 120});
    $r.addProperty("MultiColumn",0,rtl.boolean,"FMultiColumn","FMultiColumn",4,{Default: false});
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCGridGroupingOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMergeHeader = false;
      this.FMergeSummary = false;
      this.FSummary = false;
      this.FShowGroupCount = false;
      this.FCalcFormat = "";
      this.FAutoSelectGroup = false;
      this.FAutoCheckGroup = false;
      this.FGroupCountFormat = "";
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FCalcFormat = "%g";
      this.FGroupCountFormat = "(%d)";
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridGroupingOptions.isPrototypeOf(Source)) {
        this.FCalcFormat = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FCalcFormat;
        this.FMergeHeader = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FMergeHeader;
        this.FMergeSummary = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FMergeSummary;
        this.FShowGroupCount = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FShowGroupCount;
        this.FAutoCheckGroup = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FAutoCheckGroup;
        this.FAutoSelectGroup = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FAutoSelectGroup;
        this.FGroupCountFormat = rtl.as(Source,$mod.TTMSFNCGridGroupingOptions).FGroupCountFormat;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("AutoSelectGroup",0,rtl.boolean,"FAutoSelectGroup","FAutoSelectGroup",4,{Default: false});
    $r.addProperty("AutoCheckGroup",0,rtl.boolean,"FAutoCheckGroup","FAutoCheckGroup",4,{Default: false});
    $r.addProperty("CalcFormat",0,rtl.string,"FCalcFormat","FCalcFormat");
    $r.addProperty("MergeHeader",0,rtl.boolean,"FMergeHeader","FMergeHeader",4,{Default: false});
    $r.addProperty("MergeSummary",0,rtl.boolean,"FMergeSummary","FMergeSummary",4,{Default: false});
    $r.addProperty("ShowGroupCount",0,rtl.boolean,"FShowGroupCount","FShowGroupCount",4,{Default: false});
    $r.addProperty("GroupCountFormat",0,rtl.string,"FGroupCountFormat","FGroupCountFormat");
    $r.addProperty("Summary",0,rtl.boolean,"FSummary","FSummary",4,{Default: false});
  });
  this.TTMSFNCGridClipboardPasteAction = {"0": "paReplace", paReplace: 0, "1": "paInsert", paInsert: 1};
  this.$rtti.$Enum("TTMSFNCGridClipboardPasteAction",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridClipboardPasteAction});
  rtl.createClass(this,"TTMSFNCGridClipboardOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FEnabled = false;
      this.FIgnoreReadOnly = false;
      this.FAllowColGrow = false;
      this.FAllowRowGrow = false;
      this.FPasteAction = 0;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FEnabled = true;
      this.FIgnoreReadOnly = false;
      this.FAllowColGrow = false;
      this.FAllowRowGrow = false;
      this.FPasteAction = $mod.TTMSFNCGridClipboardPasteAction.paReplace;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridClipboardOptions.isPrototypeOf(Source)) {
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCGridClipboardOptions).FEnabled;
        this.FIgnoreReadOnly = rtl.as(Source,$mod.TTMSFNCGridClipboardOptions).FIgnoreReadOnly;
        this.FAllowColGrow = rtl.as(Source,$mod.TTMSFNCGridClipboardOptions).FAllowColGrow;
        this.FAllowRowGrow = rtl.as(Source,$mod.TTMSFNCGridClipboardOptions).FAllowRowGrow;
        this.FPasteAction = rtl.as(Source,$mod.TTMSFNCGridClipboardOptions).FPasteAction;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",4,{Default: true});
    $r.addProperty("IgnoreReadOnly",0,rtl.boolean,"FIgnoreReadOnly","FIgnoreReadOnly",4,{Default: false});
    $r.addProperty("AllowColGrow",0,rtl.boolean,"FAllowColGrow","FAllowColGrow",4,{Default: false});
    $r.addProperty("AllowRowGrow",0,rtl.boolean,"FAllowRowGrow","FAllowRowGrow",4,{Default: false});
    $r.addProperty("PasteAction",0,$mod.$rtti["TTMSFNCGridClipboardPasteAction"],"FPasteAction","FPasteAction",4,{Default: $mod.TTMSFNCGridClipboardPasteAction.paReplace});
  });
  rtl.createClass(this,"TTMSFNCGridHTMLExportOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FHeaderFile = "";
      this.FFooterFile = "";
      this.FShow = false;
      this.FConvertSpecialChars = false;
      this.FWidth = 0;
      this.FNonBreakingText = false;
      this.FBorderSize = 0;
      this.FCellPadding = 0;
      this.FPrefixTag = "";
      this.FSuffixTag = "";
      this.FSaveFonts = false;
      this.FExportImages = false;
      this.FCellSpacing = 0;
      this.FSummary = "";
      this.FSaveColors = false;
      this.FXHTML = false;
      this.FTableStyle = "";
      this.FColumnWidths = null;
    };
    this.$final = function () {
      this.FColumnWidths = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FShow = false;
      this.FSaveColors = true;
      this.FSaveFonts = true;
      this.FBorderSize = 1;
      this.FCellSpacing = 0;
      this.FCellPadding = 0;
      this.FWidth = 100;
      this.FExportImages = true;
      this.FColumnWidths = pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridIntList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FColumnWidths");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridHTMLExportOptions.isPrototypeOf(Source)) {
        this.FHeaderFile = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FHeaderFile;
        this.FFooterFile = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FFooterFile;
        this.FShow = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FShow;
        this.FBorderSize = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FBorderSize;
        this.FCellSpacing = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FCellSpacing;
        this.FCellPadding = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FCellPadding;
        this.FConvertSpecialChars = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FConvertSpecialChars;
        this.FExportImages = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FExportImages;
        this.FNonBreakingText = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FNonBreakingText;
        this.FPrefixTag = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FPrefixTag;
        this.FSaveColors = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FSaveColors;
        this.FSaveFonts = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FSaveFonts;
        this.FSuffixTag = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FSuffixTag;
        this.FSummary = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FSummary;
        this.FTableStyle = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FTableStyle;
        this.FWidth = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FWidth;
        this.FXHTML = rtl.as(Source,$mod.TTMSFNCGridHTMLExportOptions).FXHTML;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("BorderSize",0,rtl.longint,"FBorderSize","FBorderSize",4,{Default: 1});
    $r.addProperty("CellSpacing",0,rtl.longint,"FCellSpacing","FCellSpacing",4,{Default: 0});
    $r.addProperty("CellPadding",0,rtl.longint,"FCellPadding","FCellPadding",4,{Default: 0});
    $r.addProperty("ConvertSpecialChars",0,rtl.boolean,"FConvertSpecialChars","FConvertSpecialChars",4,{Default: false});
    $r.addProperty("ExportImages",0,rtl.boolean,"FExportImages","FExportImages",4,{Default: true});
    $r.addProperty("FooterFile",0,rtl.string,"FFooterFile","FFooterFile");
    $r.addProperty("HeaderFile",0,rtl.string,"FHeaderFile","FHeaderFile");
    $r.addProperty("NonBreakingText",0,rtl.boolean,"FNonBreakingText","FNonBreakingText",4,{Default: false});
    $r.addProperty("PrefixTag",0,rtl.string,"FPrefixTag","FPrefixTag");
    $r.addProperty("SaveColors",0,rtl.boolean,"FSaveColors","FSaveColors",4,{Default: true});
    $r.addProperty("SaveFonts",0,rtl.boolean,"FSaveFonts","FSaveFonts",4,{Default: true});
    $r.addProperty("SuffixTag",0,rtl.string,"FSuffixTag","FSuffixTag");
    $r.addProperty("Show",0,rtl.boolean,"FShow","FShow",4,{Default: false});
    $r.addProperty("Summary",0,rtl.string,"FSummary","FSummary");
    $r.addProperty("TableStyle",0,rtl.string,"FTableStyle","FTableStyle");
    $r.addProperty("Width",0,rtl.longint,"FWidth","FWidth",4,{Default: 100});
    $r.addProperty("XHTML",0,rtl.boolean,"FXHTML","FXHTML",4,{Default: false});
  });
  rtl.createClass(this,"TTMSFNCGridURLOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FUnderline = false;
      this.FColor = 0;
      this.FShow = false;
      this.FOnChange = null;
      this.FFull = false;
      this.FOpen = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetColor = function (Value) {
      if (this.FColor !== Value) {
        this.FColor = Value;
        this.Changed();
      };
    };
    this.SetUnderline = function (Value) {
      if (this.FUnderline !== Value) {
        this.FUnderline = Value;
        this.Changed();
      };
    };
    this.SetFull = function (Value) {
      if (this.FFull !== Value) {
        this.FFull = Value;
        this.Changed();
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FShow = true;
      this.FColor = 16711680;
      this.FUnderline = true;
      this.FFull = true;
      this.FOpen = true;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridURLOptions.isPrototypeOf(Source)) {
        this.FShow = rtl.as(Source,$mod.TTMSFNCGridURLOptions).FShow;
        this.FUnderline = rtl.as(Source,$mod.TTMSFNCGridURLOptions).FUnderline;
        this.FColor = rtl.as(Source,$mod.TTMSFNCGridURLOptions).FColor;
        this.FOpen = rtl.as(Source,$mod.TTMSFNCGridURLOptions).FOpen;
        this.FFull = rtl.as(Source,$mod.TTMSFNCGridURLOptions).FFull;
      };
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    var $r = this.$rtti;
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 16711680});
    $r.addProperty("Full",2,rtl.boolean,"FFull","SetFull",4,{Default: true});
    $r.addProperty("Open",0,rtl.boolean,"FOpen","FOpen",4,{Default: true});
    $r.addProperty("Show",0,rtl.boolean,"FShow","FShow",4,{Default: true});
    $r.addProperty("Underline",2,rtl.boolean,"FUnderline","SetUnderline",4,{Default: true});
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCGridIOOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FDelimiter = "\x00";
      this.FQuoteEmptyCells = false;
      this.FXMLEncoding = "";
      this.FAlwaysQuotes = false;
      this.FSaveVirtualCellData = false;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FDelimiter = "\x00";
      this.FQuoteEmptyCells = true;
      this.FXMLEncoding = "ISO-8859-1";
      this.FAlwaysQuotes = false;
      this.FSaveVirtualCellData = true;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridIOOptions.isPrototypeOf(Source)) {
        this.FAlwaysQuotes = rtl.as(Source,$mod.TTMSFNCGridIOOptions).FAlwaysQuotes;
        this.FDelimiter = rtl.as(Source,$mod.TTMSFNCGridIOOptions).FDelimiter;
        this.FQuoteEmptyCells = rtl.as(Source,$mod.TTMSFNCGridIOOptions).FQuoteEmptyCells;
        this.FXMLEncoding = rtl.as(Source,$mod.TTMSFNCGridIOOptions).FXMLEncoding;
        this.FSaveVirtualCellData = rtl.as(Source,$mod.TTMSFNCGridIOOptions).FSaveVirtualCellData;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("AlwaysQuotes",0,rtl.boolean,"FAlwaysQuotes","FAlwaysQuotes",4,{Default: false});
    $r.addProperty("Delimiter",0,rtl.char,"FDelimiter","FDelimiter",4,{Default: "\x00"});
    $r.addProperty("QuoteEmptyCells",0,rtl.boolean,"FQuoteEmptyCells","FQuoteEmptyCells",4,{Default: true});
    $r.addProperty("XMLEncoding",0,rtl.string,"FXMLEncoding","FXMLEncoding");
    $r.addProperty("SaveVirtualCellData",0,rtl.boolean,"FSaveVirtualCellData","FSaveVirtualCellData",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCGridCellOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FDisplayHTMLFormatting = false;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetDisplayHTMLFormatting = function (Value) {
      if (this.FDisplayHTMLFormatting !== Value) {
        this.FDisplayHTMLFormatting = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FDisplayHTMLFormatting = false;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridCellOptions.isPrototypeOf(Source)) {
        this.FDisplayHTMLFormatting = rtl.as(Source,$mod.TTMSFNCGridCellOptions).FDisplayHTMLFormatting;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("DisplayHTMLFormatting",2,rtl.boolean,"FDisplayHTMLFormatting","SetDisplayHTMLFormatting",4,{Default: false});
  });
  rtl.createClass(this,"TTMSFNCGridColumnSizeOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FStretch = false;
      this.FStretchAll = false;
      this.FStretchColumn = 0;
      this.FOnChange = null;
      this.FSyncWithGrid = false;
      this.FSyncNormalCellsOnly = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetStretch = function (Value) {
      if (this.FStretch !== Value) {
        this.FStretch = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.SetStretchAll = function (Value) {
      if (this.FStretchAll !== Value) {
        this.FStretchAll = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.SetStretchColumn = function (Value) {
      if (this.FStretchColumn !== Value) {
        this.FStretchColumn = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.SetNormalCellsOnly = function (Value) {
      if (this.FSyncNormalCellsOnly !== Value) {
        this.FSyncNormalCellsOnly = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.SetSyncWithGrid = function (Value) {
      if (this.FSyncWithGrid !== Value) {
        this.FSyncWithGrid = Value;
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.Create$1 = function () {
      this.FStretch = false;
      this.FStretchAll = false;
      this.FStretchColumn = -1;
      this.FSyncWithGrid = false;
      this.FSyncNormalCellsOnly = false;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridColumnSizeOptions.isPrototypeOf(Source)) {
        this.FStretch = rtl.as(Source,$mod.TTMSFNCGridColumnSizeOptions).FStretch;
        this.FStretchAll = rtl.as(Source,$mod.TTMSFNCGridColumnSizeOptions).FStretchAll;
        this.FStretchColumn = rtl.as(Source,$mod.TTMSFNCGridColumnSizeOptions).FStretchColumn;
        this.FSyncNormalCellsOnly = rtl.as(Source,$mod.TTMSFNCGridColumnSizeOptions).FSyncNormalCellsOnly;
        this.FSyncWithGrid = rtl.as(Source,$mod.TTMSFNCGridColumnSizeOptions).FSyncWithGrid;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Stretch",2,rtl.boolean,"FStretch","SetStretch",4,{Default: false});
    $r.addProperty("StretchColumn",2,rtl.longint,"FStretchColumn","SetStretchColumn",4,{Default: -1});
    $r.addProperty("StretchAll",2,rtl.boolean,"FStretchAll","SetStretchAll",4,{Default: false});
    $r.addProperty("SyncWithGrid",2,rtl.boolean,"FSyncWithGrid","SetSyncWithGrid",4,{Default: false});
    $r.addProperty("SyncNormalCellsOnly",2,rtl.boolean,"FSyncNormalCellsOnly","SetNormalCellsOnly",4,{Default: false});
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCGridOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMouse = null;
      this.FKeyboard = null;
      this.FSorting = null;
      this.FGrouping = null;
      this.FFiltering = null;
      this.FEditing = null;
      this.FBorders = null;
      this.FLookup = null;
      this.FClipboard = null;
      this.FHTMLExport = null;
      this.FBands = null;
      this.FOnChange = null;
      this.FURL = null;
      this.FScrollBar = null;
      this.FIO = null;
      this.FCell = null;
      this.FColumnSize = null;
      this.FSelection = null;
    };
    this.$final = function () {
      this.FMouse = undefined;
      this.FKeyboard = undefined;
      this.FSorting = undefined;
      this.FGrouping = undefined;
      this.FFiltering = undefined;
      this.FEditing = undefined;
      this.FBorders = undefined;
      this.FLookup = undefined;
      this.FClipboard = undefined;
      this.FHTMLExport = undefined;
      this.FBands = undefined;
      this.FOnChange = undefined;
      this.FURL = undefined;
      this.FScrollBar = undefined;
      this.FIO = undefined;
      this.FCell = undefined;
      this.FColumnSize = undefined;
      this.FSelection = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetKeyboard = function (Value) {
      this.FKeyboard.Assign(Value);
    };
    this.SetMouse = function (Value) {
      this.FMouse.Assign(Value);
    };
    this.SetGrouping = function (Value) {
      this.FGrouping.Assign(Value);
    };
    this.SetSorting = function (Value) {
      this.FSorting.Assign(Value);
    };
    this.SetFiltering = function (Value) {
      this.FFiltering.Assign(Value);
    };
    this.SetEditing = function (Value) {
      this.FEditing.Assign(Value);
    };
    this.SetBorders = function (Value) {
      this.FBorders.Assign(Value);
    };
    this.SetLookup = function (Value) {
      this.FLookup.Assign(Value);
    };
    this.SetClipboard = function (Value) {
      this.FClipboard.Assign(Value);
    };
    this.SetHTMLExport = function (Value) {
      this.FHTMLExport.Assign(Value);
    };
    this.SetBands = function (Value) {
      this.FBands.Assign(Value);
    };
    this.SetURL = function (Value) {
      this.FURL.Assign(Value);
    };
    this.SetScrollBar = function (Value) {
      this.FScrollBar.Assign(Value);
    };
    this.SetIO = function (Value) {
      this.FIO.Assign(Value);
    };
    this.SetCell = function (Value) {
      this.FCell.Assign(Value);
    };
    this.SetColumnSize = function (Value) {
      this.FColumnSize.Assign(Value);
    };
    this.SetSelection = function (Value) {
      this.FSelection.Assign(Value);
    };
    this.DoChange = function (Sender) {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FScrollBar = $mod.TTMSFNCGridScrollBarOptions.$create("Create$1");
      this.FScrollBar.FOnChange = rtl.createCallback(this,"DoChange");
      this.FMouse = $mod.TTMSFNCGridMouseOptions.$create("Create$1");
      this.FKeyboard = $mod.TTMSFNCGridKeyboardOptions.$create("Create$1");
      this.FSorting = $mod.TTMSFNCGridSortingOptions.$create("Create$1");
      this.FGrouping = $mod.TTMSFNCGridGroupingOptions.$create("Create$1");
      this.FFiltering = $mod.TTMSFNCGridFilteringOptions.$create("Create$1");
      this.FFiltering.FOnChange = rtl.createCallback(this,"DoChange");
      this.FCell = $mod.TTMSFNCGridCellOptions.$create("Create$1");
      this.FCell.FOnChange = rtl.createCallback(this,"DoChange");
      this.FEditing = $mod.TTMSFNCGridEditingOptions.$create("Create$1");
      this.FColumnSize = $mod.TTMSFNCGridColumnSizeOptions.$create("Create$1");
      this.FColumnSize.FOnChange = rtl.createCallback(this,"DoChange");
      this.FBorders = $mod.TTMSFNCGridBorderOptions.$create("Create$1");
      this.FLookup = $mod.TTMSFNCGridLookupOptions.$create("Create$1");
      this.FClipboard = $mod.TTMSFNCGridClipboardOptions.$create("Create$1");
      this.FHTMLExport = $mod.TTMSFNCGridHTMLExportOptions.$create("Create$1");
      this.FIO = $mod.TTMSFNCGridIOOptions.$create("Create$1");
      this.FBands = $mod.TTMSFNCGridBandOptions.$create("Create$1");
      this.FBands.FOnChange = rtl.createCallback(this,"DoChange");
      this.FURL = $mod.TTMSFNCGridURLOptions.$create("Create$1");
      this.FURL.FOnChange = rtl.createCallback(this,"DoChange");
      this.FSelection = $mod.TTMSFNCGridSelection.$create("Create$1");
      this.FSelection.FOnChange = rtl.createCallback(this,"DoChange");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCell");
      rtl.free(this,"FColumnSize");
      rtl.free(this,"FScrollBar");
      rtl.free(this,"FBands");
      rtl.free(this,"FBorders");
      rtl.free(this,"FEditing");
      rtl.free(this,"FMouse");
      rtl.free(this,"FKeyboard");
      rtl.free(this,"FSorting");
      rtl.free(this,"FGrouping");
      rtl.free(this,"FFiltering");
      rtl.free(this,"FLookup");
      rtl.free(this,"FClipboard");
      rtl.free(this,"FHTMLExport");
      rtl.free(this,"FURL");
      rtl.free(this,"FIO");
      rtl.free(this,"FSelection");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridOptions.isPrototypeOf(Source)) {
        this.FMouse.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FMouse);
        this.FKeyboard.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FKeyboard);
        this.FFiltering.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FFiltering);
        this.FSorting.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FSorting);
        this.FGrouping.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FGrouping);
        this.FEditing.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FEditing);
        this.FBorders.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FBorders);
        this.FLookup.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FLookup);
        this.FClipboard.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FClipboard);
        this.FCell.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FCell);
        this.FBands.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FBands);
        this.FHTMLExport.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FHTMLExport);
        this.FURL.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FURL);
        this.FScrollBar.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FScrollBar);
        this.FIO.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FIO);
        this.FSelection.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FSelection);
        this.FColumnSize.Assign(rtl.as(Source,$mod.TTMSFNCGridOptions).FColumnSize);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Bands",2,$mod.$rtti["TTMSFNCGridBandOptions"],"FBands","SetBands");
    $r.addProperty("Borders",2,$mod.$rtti["TTMSFNCGridBorderOptions"],"FBorders","SetBorders");
    $r.addProperty("Cell",2,$mod.$rtti["TTMSFNCGridCellOptions"],"FCell","SetCell");
    $r.addProperty("ColumnSize",2,$mod.$rtti["TTMSFNCGridColumnSizeOptions"],"FColumnSize","SetColumnSize");
    $r.addProperty("Clipboard",2,$mod.$rtti["TTMSFNCGridClipboardOptions"],"FClipboard","SetClipboard");
    $r.addProperty("Editing",2,$mod.$rtti["TTMSFNCGridEditingOptions"],"FEditing","SetEditing");
    $r.addProperty("Filtering",2,$mod.$rtti["TTMSFNCGridFilteringOptions"],"FFiltering","SetFiltering");
    $r.addProperty("Grouping",2,$mod.$rtti["TTMSFNCGridGroupingOptions"],"FGrouping","SetGrouping");
    $r.addProperty("HTMLExport",2,$mod.$rtti["TTMSFNCGridHTMLExportOptions"],"FHTMLExport","SetHTMLExport");
    $r.addProperty("IO",2,$mod.$rtti["TTMSFNCGridIOOptions"],"FIO","SetIO");
    $r.addProperty("Keyboard",2,$mod.$rtti["TTMSFNCGridKeyboardOptions"],"FKeyboard","SetKeyboard");
    $r.addProperty("Lookup",2,$mod.$rtti["TTMSFNCGridLookupOptions"],"FLookup","SetLookup");
    $r.addProperty("Mouse",2,$mod.$rtti["TTMSFNCGridMouseOptions"],"FMouse","SetMouse");
    $r.addProperty("Sorting",2,$mod.$rtti["TTMSFNCGridSortingOptions"],"FSorting","SetSorting");
    $r.addProperty("URL",2,$mod.$rtti["TTMSFNCGridURLOptions"],"FURL","SetURL");
    $r.addProperty("ScrollBar",2,$mod.$rtti["TTMSFNCGridScrollBarOptions"],"FScrollBar","SetScrollBar");
    $r.addProperty("Selection",2,$mod.$rtti["TTMSFNCGridSelection"],"FSelection","SetSelection");
  });
},["Types"]);
rtl.module("WEBLib.TMSFNCUndo",["System","Classes","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TTMSFNCUndoStackItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FActionName = "";
      this.FState = null;
      this.FObj = null;
    };
    this.$final = function () {
      this.FState = undefined;
      this.FObj = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.call(this,ACollection);
      this.FState = pas.Classes.TMemoryStream.$create("Create");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FState");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCUndoManager",pas.Classes.TCollection,function () {
    this.$init = function () {
      pas.Classes.TCollection.$init.call(this);
      this.FCurrent = 0;
      this.FObject = null;
      this.FMaxStackCount = 0;
    };
    this.$final = function () {
      this.FObject = undefined;
      pas.Classes.TCollection.$final.call(this);
    };
    this.GetStackItem = function (Index) {
      var Result = null;
      Result = null;
      if ((Index > -1) && (Index < this.GetCount())) Result = this.GetItem(Index);
      return Result;
    };
    this.NextUndoAction = function () {
      var Result = "";
      Result = "";
      if ((this.FCurrent > -1) && (this.FCurrent < this.GetCount())) Result = this.GetItem(this.FCurrent).FActionName;
      return Result;
    };
    this.NextRedoAction = function () {
      var Result = "";
      Result = "";
      if ((this.FCurrent >= -1) && (this.FCurrent < (this.GetCount() - 1))) Result = this.GetItem(this.FCurrent + 1).FActionName;
      return Result;
    };
    this.CanUndo = function () {
      var Result = false;
      Result = (this.FCurrent > 0) && (this.GetCount() > 0);
      return Result;
    };
    this.CanRedo = function () {
      var Result = false;
      Result = (this.FCurrent < (this.GetCount() - 1)) && (this.GetCount() > 0);
      return Result;
    };
    this.Undo = function () {
      var p = null;
      try {
        if ((this.FCurrent > 0) && (this.FCurrent <= this.GetCount())) {
          var $with = this.GetItem(this.FCurrent - 1);
          $with.FState.SetPosition(0);
          if (pas.SysUtils.Supports$3(this.FObject,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence.$guid,{get: function () {
              return p;
            }, set: function (v) {
              p = v;
            }})) {
            p.LoadSettingsFromStream($with.FState)}
           else pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromStream(this.FObject,$with.FState);
          this.FCurrent -= 1;
        };
      } finally {
        rtl._Release(p);
      };
    };
    this.Redo = function () {
      var p = null;
      try {
        if ((this.FCurrent >= -1) && (this.FCurrent < (this.GetCount() - 1))) {
          var $with = this.GetItem(this.FCurrent + 1);
          $with.FState.SetPosition(0);
          if (pas.SysUtils.Supports$3(this.FObject,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence.$guid,{get: function () {
              return p;
            }, set: function (v) {
              p = v;
            }})) {
            p.LoadSettingsFromStream($with.FState)}
           else pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromStream(this.FObject,$with.FState);
          this.FCurrent += 1;
        };
      } finally {
        rtl._Release(p);
      };
    };
    this.ClearUndoStack = function () {
      this.Clear();
      this.FCurrent = -1;
      this.PushState("");
    };
    this.PushState = function (AActionName) {
      var p = null;
      var it = null;
      try {
        while (this.FCurrent < (this.GetCount() - 1)) {
          it = this.GetItem(this.GetCount() - 1);
          it = rtl.freeLoc(it);
        };
        var $with = this.Add();
        $with.FActionName = AActionName;
        if (pas.SysUtils.Supports$3(this.FObject,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence.$guid,{get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }})) {
          p.SaveSettingsToStream($with.FState,false)}
         else pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToStream(this.FObject,$with.FState);
        this.FCurrent += 1;
        if (this.GetCount() > this.FMaxStackCount) {
          this.Delete(0);
          this.FCurrent -= 1;
        };
      } finally {
        rtl._Release(p);
      };
    };
    this.Create$2 = function (AObject) {
      pas.Classes.TCollection.Create$1.call(this,$mod.TTMSFNCUndoStackItem);
      this.FObject = AObject;
      this.FMaxStackCount = 20;
      this.FCurrent = -1;
      return this;
    };
  });
},["SysUtils","WEBLib.TMSFNCPersistence"]);
rtl.module("WEBLib.ExtCtrls",["System","Classes","SysUtils","Types","WEBLib.Controls","WEBLib.StdCtrls","WEBLib.Graphics","Web","JS","WEBLib.WebTools","WEBLib.Menus","WEBLib.REST"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TLinkTarget = {"0": "ltCurrentTab", ltCurrentTab: 0, "1": "ltNewTab", ltNewTab: 1};
  this.$rtti.$Enum("TLinkTarget",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TLinkTarget});
  rtl.createClass(this,"TCustomLinkLabel",pas["WEBLib.StdCtrls"].TCustomLabel,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomLabel.$init.call(this);
      this.FDisplText = "";
      this.FOnLinkClick = null;
      this.FWidthStyle$1 = 0;
      this.FHeightPercent$1 = 0.0;
      this.FHeightStyle$1 = 0;
      this.FWidthPercent$1 = 0.0;
      this.FTarget = 0;
    };
    this.$final = function () {
      this.FOnLinkClick = undefined;
      pas["WEBLib.StdCtrls"].TCustomLabel.$final.call(this);
    };
    this.SetTarget = function (Value) {
      if (this.FTarget !== Value) {
        this.FTarget = Value;
        this.SetCaption(this.FCaption);
      };
    };
    this.SetWidthStyle$1 = function (Value) {
      this.FWidthStyle$1 = Value;
    };
    this.SetHeightStyle$1 = function (Value) {
      this.FHeightStyle$1 = Value;
    };
    this.SetHeightPercent$1 = function (Value) {
      this.FHeightPercent$1 = Value;
    };
    this.SetWidthPercent$1 = function (Value) {
      this.FWidthPercent$1 = Value;
    };
    this.GetOuterWidth = function () {
      var Result = 0;
      if (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone) {
        Result = pas["WEBLib.Controls"].TControl.GetOuterWidth.call(this)}
       else Result = this.GetWidth();
      return Result;
    };
    this.GetOuterHeight = function () {
      var Result = 0;
      if (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone) {
        Result = pas["WEBLib.Controls"].TControl.GetOuterHeight.call(this)}
       else Result = this.GetHeight();
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FDisplText;
      return Result;
    };
    this.SetCaption = function (AValue) {
      var iopen = 0;
      var iopena = 0;
      var iopeni = 0;
      var iopenend = 0;
      var iopenendt = 0;
      var iclose = 0;
      var scaption = "";
      var shref = "";
      var stext = "";
      var sanchor = "";
      var sid = "";
      var stype = "";
      var slcaption = "";
      var anchor = null;
      var span = null;
      var contentelement = null;
      pas["WEBLib.StdCtrls"].TCustomLabel.SetCaption.call(this,AValue);
      if (!(this.GetContainer() != null)) return;
      contentelement = this.GetContentHandle();
      if (this.GetID() !== "") {
        contentelement = document.getElementById(this.GetID());
      };
      if ((contentelement != null) && pas.System.Assigned(contentelement.nodeValue)) contentelement.nodeValue = "";
      scaption = AValue;
      slcaption = pas.SysUtils.LowerCase(scaption);
      if ((pas.System.Pos("https://",slcaption) === 1) || (pas.System.Pos("http://",slcaption) === 1)) {
        scaption = '<a href="' + scaption + '"';
        if (this.FTarget === $mod.TLinkTarget.ltNewTab) scaption = scaption + ' target="_blank"';
        scaption = scaption + ">" + this.FCaption + "</a>";
        if (!(this.FOnLinkClick != null)) {
          contentelement.innerHTML = scaption;
          return;
        };
      };
      sanchor = '<a href="';
      sid = '<a id="';
      if ((this.FOnLinkClick != null) && ((pas.System.Pos(sanchor,scaption) > 0) || (pas.System.Pos(sid,scaption) > 0))) {
        contentelement.innerHTML = "";
        while ((pas.System.Pos(sanchor,scaption) > 0) || (pas.System.Pos(sid,scaption) > 0)) {
          iopena = pas.System.Pos(sanchor,scaption);
          iopeni = pas.System.Pos(sid,scaption);
          if (((iopena < iopeni) || (iopeni <= 0)) && (iopena > 0)) {
            stype = "#url#";
            iopen = iopena + sanchor.length;
          } else {
            stype = "#id#";
            iopen = iopeni + sid.length;
          };
          iopenend = pas.System.Pos('">',scaption);
          iopenendt = pas.System.Pos('" ',scaption);
          if ((iopenendt > 0) && (iopenendt < iopenend)) iopenend = iopenendt;
          iclose = pas.System.Pos("</a>",scaption);
          shref = pas.System.Copy(scaption,iopen,iopenend - iopen);
          iopenend = pas.System.Pos('">',scaption);
          iclose = pas.System.Pos("</a>",scaption);
          stext = pas.System.Copy(scaption,iopenend + 2,iclose - (iopenend + 2));
          span = document.createElement("SPAN");
          span.innerHTML = pas.System.Copy(scaption,0,iopen);
          contentelement.appendChild(span);
          anchor = document.createElement("A");
          anchor.setAttribute("href","#");
          anchor.setAttribute("id",stype + shref);
          anchor.innerHTML = stext;
          anchor.onclick = rtl.createSafeCallback(this,"DoLinkClick");
          contentelement.appendChild(anchor);
          pas.System.Delete({get: function () {
              return scaption;
            }, set: function (v) {
              scaption = v;
            }},1,pas.System.Pos("</a>",scaption) + 3);
        };
        span = document.createElement("SPAN");
        span.innerHTML = scaption;
        contentelement.appendChild(span);
        this.FDisplText = scaption;
      } else {
        this.FDisplText = pas.SysUtils.StringReplace(AValue,"> <",">&nbsp;<",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        if ((contentelement != null) && pas.System.Assigned(contentelement.nodeValue)) {
          contentelement.nodeValue = this.FDisplText}
         else if ((contentelement != null) && (contentelement.childElementCount <= 1)) contentelement.innerHTML = this.FDisplText;
      };
    };
    this.DoLinkClick = function (Event) {
      var Result = false;
      var slink = "";
      var stype = "";
      var svalue = "";
      var ltype = 0;
      svalue = Event.target.getAttribute("id");
      stype = "#url#";
      ltype = pas["WEBLib.StdCtrls"].TSysLinkType.sltURL;
      if (!(pas.System.Pos(stype,svalue) > 0)) {
        stype = "#id#";
        ltype = pas["WEBLib.StdCtrls"].TSysLinkType.sltID;
      };
      slink = pas.SysUtils.StringReplace(svalue,stype,"",{});
      if (this.FOnLinkClick != null) this.FOnLinkClick(this,slink,ltype);
      Result = true;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FWidthStyle$1 = pas["WEBLib.Controls"].TSizeStyle.ssAbsolute;
      this.FWidthPercent$1 = 100;
      this.FHeightStyle$1 = pas["WEBLib.Controls"].TSizeStyle.ssAbsolute;
      this.FHeightPercent$1 = 100;
      this.SetTransparent(true);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: true});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",4,{Default: 16777215});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EllipsisPosition",2,pas["WEBLib.StdCtrls"].$rtti["TEllipsisPosition"],"FEllipsisPosition","SetEllipsisPosition",4,{Default: pas["WEBLib.StdCtrls"].TEllipsisPosition.epNone});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",2,pas["WEBLib.StdCtrls"].$rtti["TTextLayout"],"FLayout","SetLayout",4,{Default: pas["WEBLib.StdCtrls"].TTextLayout.tlTop});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("Target",2,$mod.$rtti["TLinkTarget"],"FTarget","SetTarget",4,{Default: $mod.TLinkTarget.ltCurrentTab});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",4,{Default: false});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle$1","SetHeightStyle$1",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle$1","SetWidthStyle$1",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent$1","SetHeightPercent$1",4,{Default: 100});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent$1","SetWidthPercent$1",4,{Default: 100});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnLinkClick",0,pas["WEBLib.StdCtrls"].$rtti["TLinkClickEvent"],"FOnLinkClick","FOnLinkClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TLinkLabel",this.TCustomLinkLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
  });
  rtl.createClass(this,"TWebLinkLabel",this.TLinkLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TTrackBarOrientation = {"0": "trHorizontal", trHorizontal: 0, "1": "trVertical", trVertical: 1};
  this.$rtti.$Enum("TTrackBarOrientation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTrackBarOrientation});
  rtl.createClass(this,"TTrackBar",pas["WEBLib.StdCtrls"].TCustomInput,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomInput.$init.call(this);
      this.FMax = 0;
      this.FMin = 0;
      this.FPosition = 0;
      this.FOnChange = null;
      this.FOrientation = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas["WEBLib.StdCtrls"].TCustomInput.$final.call(this);
    };
    this.SetOrientation = function (Value) {
      var ow = 0;
      var oh = 0;
      if (this.FOrientation !== Value) {
        ow = this.GetWidth();
        oh = this.GetHeight();
        this.FOrientation = Value;
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
          this.SetWidth(oh);
          this.SetHeight(ow);
        };
        this.UpdateElement();
      };
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "range";
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      var el = null;
      el = this.GetElementHandle();
      this.FPosition = el.value;
      this.Change();
      Result = true;
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().oninput = rtl.createSafeCallback(this,"DoHandleChange");
      };
    };
    this.SetMax = function (AValue) {
      if (this.FMax !== AValue) {
        this.FMax = AValue;
        this.DoUpdate();
      };
    };
    this.SetMin = function (AValue) {
      if (this.FMin !== AValue) {
        this.FMin = AValue;
        this.DoUpdate();
      };
    };
    this.SetPosition = function (AValue) {
      if (this.FPosition !== AValue) {
        this.FPosition = AValue;
        this.DoUpdate();
      };
    };
    this.GetPosition = function () {
      var Result = 0;
      var s = "";
      Result = this.FPosition;
      if (!(this.GetContainer() != null)) return Result;
      s = this.GetContainer().value;
      if (s !== "") Result = pas.SysUtils.StrToInt(s);
      return Result;
    };
    this.DoUpdate = function () {
      var el = null;
      if (!(this.GetContainer() != null)) return;
      this.GetContainer().setAttribute("max",pas.SysUtils.IntToStr(this.FMax));
      this.GetContainer().setAttribute("min",pas.SysUtils.IntToStr(this.FMin));
      el = this.GetElementHandle();
      el.value = this.FPosition;
      el.setAttribute('value',this.FPosition);
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.CreateControl = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateControl.call(this);
      this.DoUpdate();
    };
    this.UpdateElementVisual = function () {
      var el = null;
      pas["WEBLib.StdCtrls"].TCustomInput.UpdateElementVisual.call(this);
      el = this.GetElementHandle();
      if (this.FOrientation === $mod.TTrackBarOrientation.trHorizontal) {
        el.removeAttribute("orient");
        el.style.removeProperty("writing-mode");
        el.style.removeProperty("-webkit-appearance");
        el.style.removeProperty("height");
        if (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) el.style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()));
      } else {
        el.setAttribute("orient","vertical");
        el.style.setProperty("writing-mode","bt-lt");
        el.style.setProperty("-webkit-appearance","slider-vertical");
        el.style.removeProperty("width");
        if (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) el.style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()));
        el.style.setProperty("width","22px");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.StdCtrls"].TCustomInput.CreateInitialize.call(this);
      this.FMax = 100;
      this.FMin = 0;
      this.FPosition = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Max",2,rtl.longint,"FMax","SetMax",4,{Default: 10});
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin",4,{Default: 0});
    $r.addProperty("Orientation",2,$mod.$rtti["TTrackBarOrientation"],"FOrientation","SetOrientation",4,{Default: $mod.TTrackBarOrientation.trHorizontal});
    $r.addProperty("Position",3,rtl.longint,"GetPosition","SetPosition",4,{Default: 0});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTrackBar",this.TTrackBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTimer",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FInterval = 0;
      this.FTimerID = 0;
      this.FOnTimer = null;
      this.FEnabled = false;
    };
    this.$final = function () {
      this.FOnTimer = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetEnabled = function (Value) {
      this.FEnabled = Value;
      this.DoUpdateTimer();
    };
    this.SetInterval = function (AValue) {
      this.FInterval = AValue;
      this.DoUpdateTimer();
    };
    this.DoTimer = function () {
      if (this.FOnTimer != null) this.FOnTimer(this);
    };
    this.DoUpdateTimer = function () {
      this.DoClearTimer();
      if (this.FEnabled) this.FTimerID = window.setInterval(rtl.createSafeCallback(this,"DoTimer"),this.FInterval);
    };
    this.DoClearTimer = function () {
      if (this.FTimerID !== -1) {
        window.clearInterval(this.FTimerID);
        this.FTimerID = -1;
      };
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FInterval = 1000;
      this.FTimerID = -1;
      this.SetEnabled(true);
      return this;
    };
    this.Destroy = function () {
      this.DoClearTimer();
      pas.Classes.TComponent.Destroy.call(this);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Interval",2,rtl.longint,"FInterval","SetInterval",4,{Default: 1000});
    $r.addProperty("OnTimer",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnTimer","FOnTimer");
  });
  rtl.createClass(this,"TWebTimer",this.TTimer,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TGeolocationEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Lat",rtl.double],["Lon",rtl.double],["Alt",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TGeolocationExEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Lat",rtl.double],["Lon",rtl.double],["Alt",rtl.double],["Accuracy",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TGeolocationErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACode",rtl.longint],["AMessage",rtl.string]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TGeolocationResponseProc",{procsig: rtl.newTIProcSig([["APosition",pas.Web.$rtti["TJSPosition"]]])});
  rtl.createClass(this,"TGeoLocation",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FOnGeolocation = null;
      this.FWidth = 0;
      this.FHeight = 0;
      this.FMaximumAge = 0;
      this.FTimeOut = 0;
      this.FHighPrecision = false;
      this.FTrackID = 0;
      this.FOnGeolocationUpdate = null;
      this.FOnGeolocationEx = null;
      this.FOnGeolocationError = null;
      this.FOnGeolocationUpdateEx = null;
    };
    this.$final = function () {
      this.FOnGeolocation = undefined;
      this.FOnGeolocationUpdate = undefined;
      this.FOnGeolocationEx = undefined;
      this.FOnGeolocationError = undefined;
      this.FOnGeolocationUpdateEx = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.DoHandleGeolocation = function (APosition) {
      if (this.FOnGeolocation != null) this.FOnGeolocation(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude);
      if (this.FOnGeolocationEx != null) this.FOnGeolocationEx(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude,APosition.coords.accuracy);
    };
    this.DoHandleError = function (AValue) {
      if (this.FOnGeolocationError != null) this.FOnGeolocationError(this,AValue.code,AValue.message);
    };
    this.DoHandleGeolocationAsync = function (AProc) {
      var $Self = this;
      var posopt = pas.Web.TJSPositionOptions.$new();
      function Handler(APosition) {
        AProc(pas.Web.TJSPosition.$clone(APosition));
      };
      posopt.enableHighAccuracy = this.FHighPrecision;
      posopt.timeout = this.FTimeOut;
      posopt.maximumAge = this.FMaximumAge;
      navigator.geolocation.getCurrentPosition(Handler,null,pas.Web.TJSPositionOptions.$clone(posopt));
    };
    this.DoHandleGeolocationUpdate = function (APosition) {
      if (this.FOnGeolocationUpdate != null) this.FOnGeolocationUpdate(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude);
      if (this.FOnGeolocationUpdateEx != null) this.FOnGeolocationUpdateEx(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude,APosition.coords.accuracy);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FHighPrecision = false;
      this.FTimeOut = 60000;
      this.FMaximumAge = 0;
      this.FTrackID = -1;
      return this;
    };
    this.HasGeolocation = function () {
      var Result = false;
      Result = navigator.geolocation != null;
      return Result;
    };
    this.GetGeolocation = function () {
      var posopt = pas.Web.TJSPositionOptions.$new();
      if (navigator.geolocation != null) {
        posopt.enableHighAccuracy = this.FHighPrecision;
        posopt.timeout = this.FTimeOut;
        posopt.maximumAge = this.FMaximumAge;
        navigator.geolocation.getCurrentPosition(rtl.createCallback(this,"DoHandleGeolocation"),rtl.createCallback(this,"DoHandleError"),pas.Web.TJSPositionOptions.$clone(posopt));
      };
    };
    this.GetGeolocationAsync = function () {
      var $Self = this;
      var Result = null;
      var posopt = pas.Web.TJSPositionOptions.$new();
      Result = new Promise(function (ASuccess, AFailed) {
        if (navigator.geolocation != null) {
          $Self.DoHandleGeolocationAsync(function (APosition) {
            ASuccess(pas.Web.TJSPosition.$clone(APosition));
          });
        } else AFailed(null);
      });
      return Result;
    };
    this.StartTracking = function () {
      var posopt = pas.Web.TJSPositionOptions.$new();
      if (this.FTrackID !== -1) this.StopTracking();
      if (navigator.geolocation != null) {
        posopt.enableHighAccuracy = this.FHighPrecision;
        posopt.timeout = this.FTimeOut;
        posopt.maximumAge = this.FMaximumAge;
        this.FTrackID = navigator.geolocation.watchPosition(rtl.createCallback(this,"DoHandleGeolocationUpdate"),rtl.createCallback(this,"DoHandleError"),pas.Web.TJSPositionOptions.$clone(posopt));
      };
    };
    this.StopTracking = function () {
      if ((navigator.geolocation != null) && (this.FTrackID !== -1)) {
        navigator.geolocation.clearWatch(this.FTrackID);
        this.FTrackID = -1;
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("HighPrecision",0,rtl.boolean,"FHighPrecision","FHighPrecision",4,{Default: false});
    $r.addProperty("TimeOut",0,rtl.longint,"FTimeOut","FTimeOut",4,{Default: 60000});
    $r.addProperty("MaximumAge",0,rtl.longint,"FMaximumAge","FMaximumAge",4,{Default: 0});
    $r.addProperty("OnGeolocation",0,$mod.$rtti["TGeolocationEvent"],"FOnGeolocation","FOnGeolocation");
    $r.addProperty("OnGeolocationEx",0,$mod.$rtti["TGeolocationExEvent"],"FOnGeolocationEx","FOnGeolocationEx");
    $r.addProperty("OnGeolocationError",0,$mod.$rtti["TGeolocationErrorEvent"],"FOnGeolocationError","FOnGeolocationError");
    $r.addProperty("OnGeolocationUpdate",0,$mod.$rtti["TGeolocationEvent"],"FOnGeolocationUpdate","FOnGeolocationUpdate");
    $r.addProperty("OnGeolocationUpdateEx",0,$mod.$rtti["TGeolocationExEvent"],"FOnGeolocationUpdateEx","FOnGeolocationUpdateEx");
  });
  rtl.createClass(this,"TWebGeoLocation",this.TGeoLocation,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPaintBox",pas["WEBLib.Menus"].TWebGraphicControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebGraphicControl.$init.call(this);
      this.FOnPaint = null;
    };
    this.$final = function () {
      this.FOnPaint = undefined;
      pas["WEBLib.Menus"].TWebGraphicControl.$final.call(this);
    };
    this.Paint = function () {
      pas["WEBLib.Controls"].TCustomControl.Paint.call(this);
      if (this.FOnPaint != null) this.FOnPaint(this);
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.GetElementHandle().style.setProperty("border","1px dotted gray");
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnPaint",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPaint","FOnPaint");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebPaintBox",this.TPaintBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$RefToProcVar("TImageLoadedProc",{procsig: rtl.newTIProcSig([["AEvent",pas.Web.$rtti["TJSEvent"]]])});
  this.$rtti.$RefToProcVar("TImageErrorProc",{procsig: rtl.newTIProcSig([["AEvent",pas.Web.$rtti["TJSEvent"]]])});
  rtl.createClass(this,"TCustomImageControl",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FURL = "";
      this.FPicture = null;
      this.FAutoSize = false;
      this.FOnLoaded = null;
      this.FOnError = null;
      this.FImageLoadPtr = null;
      this.FImageErrorPtr = null;
      this.FImageLoaded = null;
      this.FImageError = null;
    };
    this.$final = function () {
      this.FPicture = undefined;
      this.FOnLoaded = undefined;
      this.FOnError = undefined;
      this.FImageLoaded = undefined;
      this.FImageError = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetURL = function (AURL) {
      this.FURL = AURL;
      this.SetContainerURL(AURL);
    };
    this.GetBase64Img = function () {
      var Result = "";
      Result = pas["WEBLib.WebTools"].GetBase64Image(this.GetElementHandle(),0,0);
      return Result;
    };
    this.HandleImageLoad = function (AEvent) {
      var Result = false;
      var el = null;
      var w = 0;
      var h = 0;
      el = this.GetElementHandle();
      w = el.naturalWidth;
      h = el.naturalHeight;
      this.FPicture.FWidth = w;
      this.FPicture.FHeight = h;
      if (this.FOnLoaded != null) this.FOnLoaded(this);
      if (this.FImageLoaded != null) this.FImageLoaded(AEvent);
      Result = true;
      return Result;
    };
    this.HandleError = function (AEvent) {
      var Result = false;
      var Handled = false;
      var LEventRec = pas["WEBLib.Controls"].TJSEventRecord.$new();
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      Result = true;
      Handled = false;
      if (this.FOnError != null) {
        LEventRec.event = AEvent;
        LRequestRec.req = AEvent.target;
        this.FOnError(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),pas["WEBLib.Controls"].TJSEventRecord.$clone(LEventRec),{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
      };
      if (this.FImageError != null) this.FImageError(AEvent);
      if (!Handled && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FURL !== "")) throw pas.SysUtils.Exception.$create("Create$1",["Error loading image " + this.FURL]);
      return Result;
    };
    this.SetPicture = function (Value) {
      this.FPicture.Assign(Value);
    };
    this.PictureChanged = function (Sender) {
      this.SetURL(this.FPicture.FFilename);
      this.UpdateElement();
    };
    this.PictureDataChanged = function (Sender) {
      this.SetContainerURL("data:image/png;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FPicture.GetData()));
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("IMG");
      if (this.FURL !== "") Result.setAttribute("src",this.FURL);
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.FAutoSize && (this.GetElementHandle() != null)) {
        this.GetElementHandle().style.removeProperty("width");
        this.GetElementHandle().style.removeProperty("height");
      };
    };
    this.SetContainerURL = function (AURL) {
      if (this.GetContainer() != null) {
        if (AURL === "") {
          this.GetContainer().removeAttribute("src")}
         else this.GetContainer().setAttribute("src",AURL);
        this.UpdateElement();
      };
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        this.GetElementBindHandle().addEventListener("load",this.FImageLoadPtr);
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.GetElementBindHandle().addEventListener("error",this.FImageErrorPtr);
      };
    };
    this.UnbindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.removeEventListener("load",this.FImageLoadPtr);
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) eh.removeEventListener("error",this.FImageErrorPtr);
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FImageLoadPtr = null;
      this.FImageErrorPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      if (this.FImageLoadPtr === null) this.FImageLoadPtr = rtl.createCallback(this,"HandleImageLoad");
      if (this.FImageErrorPtr === null) this.FImageErrorPtr = rtl.createCallback(this,"HandleError");
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FPicture = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FPicture.FOnChange = rtl.createCallback(this,"PictureChanged");
      this.FPicture.FOnDataChange = rtl.createCallback(this,"PictureDataChanged");
      this.SetColor(-1);
      this.SetTabStop(false);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FPicture");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.SetURL($impl.emptyimgres);
    };
    this.DataURL = function () {
      var Result = "";
      Result = "data:image/png;base64," + this.GetBase64Img();
      return Result;
    };
    this.DataURL$1 = function (AWidth, AHeight) {
      var Result = "";
      Result = "data:image/png;base64," + pas["WEBLib.WebTools"].GetBase64Image(this.GetElementHandle(),AWidth,AHeight);
      return Result;
    };
    this.ResizeImage = function () {
      this.ResizeImage$2(this.GetWidth(),this.GetHeight(),false);
    };
    this.ResizeImage$1 = function (AWidth, AHeight) {
      this.ResizeImage$2(AWidth,AHeight,false);
    };
    this.ResizeImage$2 = function (AWidth, AHeight, AspectRatio) {
      var w = 0;
      var h = 0;
      var r = 0.0;
      if (AspectRatio) {
        if ((this.ImageWidth() === AWidth) || (this.ImageHeight() === AHeight)) return;
      } else {
        if ((this.ImageWidth() === AWidth) && (this.ImageHeight() === AHeight)) return;
      };
      if ((AWidth === 0) || (AHeight === 0)) return;
      w = AWidth;
      h = AHeight;
      if (AspectRatio) {
        if ((this.ImageWidth() / w) > (this.ImageHeight() / h)) {
          r = this.ImageWidth() / w}
         else r = this.ImageHeight() / h;
        w = Math.round(this.ImageWidth() / r);
        h = Math.round(this.ImageHeight() / r);
      };
      this.SetURL("data:image/png;base64," + pas["WEBLib.WebTools"].GetBase64Image(this.GetElementHandle(),w,h));
    };
    this.ImageWidth = function () {
      var Result = 0;
      var el = null;
      var w = 0;
      Result = -1;
      if (this.GetElementHandle() != null) {
        el = this.GetElementHandle();
        w = el.naturalWidth;
        Result = w;
      };
      return Result;
    };
    this.ImageHeight = function () {
      var Result = 0;
      var el = null;
      var h = 0;
      Result = -1;
      if (this.GetElementHandle() != null) {
        el = this.GetElementHandle();
        h = el.naturalHeight;
        Result = h;
      };
      return Result;
    };
    this.LoadFromArrayBuffer = function (AArray) {
      var uint8b = null;
      var dataUri = "";
      uint8b = new Uint8Array(AArray);
      dataUri = btoa(new Uint8Array(uint8b).reduce(function (data, byte) {
      return data + String.fromCharCode(byte);
      }, ''));
      this.SetURL("data:image/jpeg;base64," + dataUri);
    };
    this.SaveToArrayBuffer = function (AArray) {
      AArray = pas["WEBLib.Utils"].Base64ToArrayBuffer(this.GetBase64Img());
    };
    this.LoadFromURL = function (AURL) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.LoadFromURL$1(AURL,function (AEvent) {
          ASuccess(AEvent);
        },function (AEvent) {
          AFailed(AEvent);
        });
      });
      return Result;
    };
    this.LoadFromURL$1 = function (AURL, ImageLoaded, ImageError) {
      this.FImageLoaded = ImageLoaded;
      this.FImageError = ImageError;
      this.SetURL(AURL);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize",4,{Default: false});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnError",0,pas["WEBLib.Controls"].$rtti["THTTPErrorEvent"],"FOnError","FOnError");
    $r.addProperty("OnLoaded",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnLoaded","FOnLoaded");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TImageControl",this.TCustomImageControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Picture",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPicture","SetPicture");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
  });
  rtl.createClass(this,"TWebImageControl",this.TImageControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TImageZoomControl");
  rtl.createClass(this,"TImageZoomAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FHeightPercent = 0;
      this.FWidthPercent = 0;
      this.FResponsiveHeightPercent = 0;
      this.FResponsiveWidthPercent = 0;
      this.FResponsiveMaxWidth = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHeightPercent = function (Value) {
      if ((this.FHeightPercent !== Value) && (this.FHeightPercent <= 100)) {
        this.FHeightPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetWidthPercent = function (Value) {
      if ((this.FWidthPercent !== Value) && (this.FWidthPercent <= 100)) {
        this.FWidthPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveHeightPercent = function (Value) {
      if ((this.FResponsiveHeightPercent !== Value) && (this.FResponsiveHeightPercent <= 100)) {
        this.FResponsiveHeightPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveWidthPercent = function (Value) {
      if ((this.FResponsiveWidthPercent !== Value) && (this.FResponsiveWidthPercent <= 100)) {
        this.FResponsiveWidthPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveMaxWidth = function (Value) {
      if ((this.FResponsiveMaxWidth !== Value) && (this.FResponsiveMaxWidth >= 0)) {
        this.FResponsiveMaxWidth = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.Create$1 = function (AOwner) {
      this.FHeightPercent = 100;
      this.FWidthPercent = 100;
      this.FResponsiveHeightPercent = 100;
      this.FResponsiveWidthPercent = 100;
      this.FResponsiveMaxWidth = 768;
      this.FOwner = AOwner;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas.Classes.TPersistent.Assign.apply(this,arguments);
      if ($mod.TImageZoomAppearance.isPrototypeOf(Source)) {
        this.FHeightPercent = rtl.as(Source,$mod.TImageZoomAppearance).FHeightPercent;
        this.FWidthPercent = rtl.as(Source,$mod.TImageZoomAppearance).FWidthPercent;
        this.FResponsiveHeightPercent = rtl.as(Source,$mod.TImageZoomAppearance).FResponsiveHeightPercent;
        this.FResponsiveWidthPercent = rtl.as(Source,$mod.TImageZoomAppearance).FResponsiveWidthPercent;
        this.FResponsiveMaxWidth = rtl.as(Source,$mod.TImageZoomAppearance).FResponsiveMaxWidth;
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("HeightPercent",2,rtl.longint,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("WidthPercent",2,rtl.longint,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("ResponsiveHeightPercent",2,rtl.longint,"FResponsiveHeightPercent","SetResponsiveHeightPercent",4,{Default: 100});
    $r.addProperty("ResponsiveWidthPercent",2,rtl.longint,"FResponsiveWidthPercent","SetResponsiveWidthPercent",4,{Default: 100});
    $r.addProperty("ResponsiveMaxWidth",2,rtl.longint,"FResponsiveMaxWidth","SetResponsiveMaxWidth",4,{Default: 768});
  });
  rtl.createClass(this,"TImageZoomControl",this.TCustomImageControl,function () {
    this.$init = function () {
      $mod.TCustomImageControl.$init.call(this);
      this.FStyle = null;
      this.FOverlay = null;
      this.FPictureZoom = null;
      this.FURLZoom = "";
      this.FPictureZoomDataURL = "";
      this.FAppearance = null;
      this.FZoomBkgOpacity = 0.0;
      this.FZoomBkgColor = 0;
    };
    this.$final = function () {
      this.FStyle = undefined;
      this.FOverlay = undefined;
      this.FPictureZoom = undefined;
      this.FAppearance = undefined;
      $mod.TCustomImageControl.$final.call(this);
    };
    this.SetPictureZoom = function (Value) {
      this.FPictureZoom.Assign(Value);
    };
    this.SetURLZoom = function (Value) {
      if (this.FURLZoom !== Value) {
        this.FURLZoom = Value;
        this.UpdateElement();
      };
    };
    this.PictureZoomChanged = function (Sender) {
      this.SetURLZoom(this.FPictureZoom.FFilename);
      this.FPictureZoomDataURL = "";
      this.UpdateElement();
    };
    this.PictureZoomDataChanged = function (Sender) {
      this.FPictureZoomDataURL = "data:image/png;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FPictureZoom.GetData());
      this.UpdateElement();
    };
    this.UpdateElement = function () {
      var PopupImage = "";
      var Popup = null;
      var r = 0;
      var g = 0;
      var b = 0;
      var l = 0;
      var op = "";
      $mod.TCustomImageControl.UpdateElement.call(this);
      if (!(this.GetElementHandle() != null)) return;
      if (this.FOverlay != null) {
        this.GetElementHandle().setAttribute("onClick",'document.getElementById("' + this.FName + 'myModal").style.display = "block"');
        if (this.FPictureZoomDataURL !== "") {
          PopupImage = this.FPictureZoomDataURL}
         else PopupImage = this.FURLZoom;
        if (PopupImage === "") PopupImage = this.FURL;
        if (this.GetIsLinked() && (PopupImage === "")) {
          PopupImage = this.GetElementHandle().getAttribute("src");
        };
        op = pas.SysUtils.FloatToStr(this.FZoomBkgOpacity);
        pas.SysUtils.StringReplace(op,",",".",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        l = pas["WEBLib.Graphics"].ColorToRGB(this.FZoomBkgColor);
        r = pas["WEBLib.Graphics"].GetRValue(l);
        g = pas["WEBLib.Graphics"].GetGValue(l);
        b = pas["WEBLib.Graphics"].GetBValue(l);
        this.FStyle.innerHTML = "." + this.FName + "modal-overlay {\r" + "  display: none;\r" + "  position: fixed;\r" + "  z-index: 99999999;\r" + "  width: 100%;\r" + "  height: 100%;\r" + "  overflow: hidden;\r" + "  top: 50%;\r" + "  left: 50%;\r" + "  -ms-transform: translate(-50%, -50%);\r" + "  transform: translate(-50%, -50%);\r" + "  background-color: rgba(" + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return g;
          }, set: function (v) {
            g = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }}) + ",0.2);\r" + "}\r" + "." + this.FName + "modal {\r" + "  display: block;\r" + "  position: absolute;\r" + "  z-index: 99999999;\r" + "  width: " + pas.SysUtils.IntToStr(this.FAppearance.FWidthPercent) + "%;\r" + "  height: " + pas.SysUtils.IntToStr(this.FAppearance.FHeightPercent) + "%;\r" + "  overflow: hidden;\r" + "  top: 50%;\r" + "  left: 50%;\r" + "  -ms-transform: translate(-50%, -50%);\r" + "  transform: translate(-50%, -50%);\r" + "  background-color: rgba(" + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return g;
          }, set: function (v) {
            g = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }}) + "," + op + ");\r" + "}\r" + "." + this.FName + "modal-content {\r" + "  display: block;\r" + "  margin: 0;\r" + "  position: absolute;\r" + "  top: 50%;\r" + "  left: 50%;\r" + "  -ms-transform: translate(-50%, -50%);\r" + "  transform: translate(-50%, -50%);\r" + "  max-width: 100%;\r" + "  max-height: 100%;\r" + "}\r" + "." + this.FName + "close {\r" + "  z-index: 99999999;\r" + "  position: absolute;\r" + "  top: 15px;\r" + "  right: 35px;\r" + "  color: #f1f1f1;\r" + "  font-size: 40px;\r" + "  font-weight: bold;\r" + "  transition: 0.3s;\r" + "}\r" + "." + this.FName + "close:hover,\r" + "." + this.FName + "close:focus {\r" + "  color: #bbb;\r" + "  text-decoration: none;\r" + "  cursor: pointer;\r" + "}\r" + "@media only screen and (max-width: 769px) {\r" + "\t." + this.FName + "modal {\r" + "  width: " + pas.SysUtils.IntToStr(this.FAppearance.FResponsiveWidthPercent) + "%;\r" + "  height: " + pas.SysUtils.IntToStr(this.FAppearance.FResponsiveHeightPercent) + "%;\r" + "\t}\r" + "}\r";
        this.FOverlay.setAttribute("onClick",'this.style.display = "none";');
        this.FOverlay.setAttribute("id",this.FName + "myModal");
        this.FOverlay.setAttribute("class",this.FName + "modal-overlay");
        while (this.FOverlay.firstChild != null) this.FOverlay.removeChild(this.FOverlay.firstChild);
        Popup = document.createElement("DIV");
        Popup.setAttribute("class",this.FName + "modal");
        Popup.innerHTML = '<span class="' + this.FName + 'close">&times;</span>' + '<img class="' + this.FName + 'modal-content" src="' + PopupImage + '">';
        this.FOverlay.innerHTML = "";
        this.FOverlay.appendChild(Popup);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomImageControl.CreateInitialize.call(this);
      this.FAppearance = $mod.TImageZoomAppearance.$create("Create$1",[this]);
      this.FPictureZoom = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FPictureZoom.FOnChange = rtl.createCallback(this,"PictureZoomChanged");
      this.FPictureZoom.FOnDataChange = rtl.createCallback(this,"PictureZoomDataChanged");
      this.FPictureZoomDataURL = "";
      this.FZoomBkgColor = 0;
      this.FZoomBkgOpacity = 0.9;
      this.FStyle = document.createElement("STYLE");
      this.FOverlay = document.createElement("DIV");
      document.body.appendChild(this.FStyle);
      document.body.appendChild(this.FOverlay);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(100);
        this.SetHeight(75);
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = $mod.TCustomImageControl.CreateElement.call(this);
      return Result;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      rtl.free(this,"FPictureZoom");
      $mod.TCustomImageControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",0,$mod.$rtti["TImageZoomAppearance"],"FAppearance","FAppearance");
    $r.addProperty("Picture",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPicture","SetPicture");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("PictureZoom",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPictureZoom","SetPictureZoom");
    $r.addProperty("URLZoom",2,rtl.string,"FURLZoom","SetURLZoom");
    $r.addProperty("ZoomBkgColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FZoomBkgColor","FZoomBkgColor",4,{Default: 0});
    $r.addProperty("ZoomBkgOpacity",0,rtl.double,"FZoomBkgOpacity","FZoomBkgOpacity");
  });
  rtl.createClass(this,"TWebImageZoomControl",this.TImageZoomControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomPanel",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FAutoSize = false;
      this.FIsSizing = false;
      this.FPadding = null;
      this.FShowCaption = false;
      this.FLabel = null;
      this.FPanelBody = null;
      this.FElementBodyClassName = "";
      this.FAlignment = 0;
    };
    this.$final = function () {
      this.FPadding = undefined;
      this.FLabel = undefined;
      this.FPanelBody = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetShowCaption = function (Value) {
      if (this.FShowCaption !== Value) {
        this.FShowCaption = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetPadding = function (Value) {
      this.FPadding.Assign(Value);
      this.Realign();
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElement();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      this.FPanelBody = document.createElement("DIV");
      this.FPanelBody.setAttribute("class","card-body");
      Result.appendChild(this.FPanelBody);
      return Result;
    };
    this.SetCaption = function (AValue) {
      pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
      if ((this.GetElementHandle() != null) && this.FShowCaption) {
        if (!(this.FLabel != null)) {
          this.FLabel = document.createElement("SPAN");
          this.FLabel.innerHTML = this.FCaption;
          if (this.GetChildContainer() != null) {
            this.GetChildContainer().appendChild(this.FLabel)}
           else this.GetElementHandle().appendChild(this.FLabel);
          this.UpdateElementVisual();
        } else {
          this.FLabel.innerHTML = this.FCaption;
        };
      };
    };
    this.SetBorderStyle = function (AValue) {
      pas["WEBLib.Controls"].TCustomControl.SetBorderStyle.apply(this,arguments);
      this.UpdateElement();
    };
    this.SetAutoSize = function (AValue) {
      this.FAutoSize = AValue;
      if (this.FAutoSize && !this.IsUpdating()) {
        this.DoAutoSize();
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (!this.GetIsLinked()) {
          if (this.FAutoSize) {
            this.GetElementHandle().style.setProperty("overflow","");
            this.GetElementHandle().style.setProperty("white-space","normal");
            if (this.FVisible) this.GetElementHandle().style.setProperty("display","inline");
          } else {
            this.GetElementHandle().style.setProperty("overflow","hidden");
            this.GetElementHandle().style.setProperty("white-space","nowrap");
            if (this.FVisible) this.GetElementHandle().style.setProperty("display","inline-block");
          };
          this.GetElementHandle().style.setProperty("padding-left",pas.SysUtils.IntToStr(this.FPadding.FLeft) + "px");
          this.GetElementHandle().style.setProperty("padding-right",pas.SysUtils.IntToStr(this.FPadding.FRight) + "px");
          this.GetElementHandle().style.setProperty("padding-top",pas.SysUtils.IntToStr(this.FPadding.FTop) + "px");
          this.GetElementHandle().style.setProperty("padding-bottom",pas.SysUtils.IntToStr(this.FPadding.FBottom) + "px");
          this.GetElementHandle().style.setProperty("box-sizing","border-box");
          if (this.FElementBodyClassName !== "") {
            this.GetChildContainer().setAttribute("class",this.FElementBodyClassName)}
           else this.GetChildContainer().removeAttribute("class");
        };
        if (this.FLabel != null) {
          if (this.FShowCaption) {
            this.FLabel.innerHTML = this.FCaption}
           else this.FLabel.innerHTML = "";
          if (this.FVisible) {
            this.GetElementHandle().style.setProperty("display","flex");
            var $tmp = this.FAlignment;
            if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
              this.GetElementHandle().style.setProperty("justify-content","flex-start")}
             else if ($tmp === pas.Classes.TAlignment.taCenter) {
              this.GetElementHandle().style.setProperty("justify-content","center")}
             else if ($tmp === pas.Classes.TAlignment.taRightJustify) this.GetElementHandle().style.setProperty("justify-content","flex-end");
            this.GetElementHandle().style.setProperty("align-items","center");
          };
        };
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
      };
    };
    this.HandleKeyPreview = function (Key) {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ((Key === 13) || (Key === 27)) this.GetControls(i).HandleKeyPreview(Key);
      };
    };
    this.GetOuterWidth = function () {
      var Result = 0;
      Result = pas["WEBLib.Controls"].TControl.GetOuterWidth.call(this);
      return Result;
    };
    this.GetOuterHeight = function () {
      var Result = 0;
      Result = pas["WEBLib.Controls"].TControl.GetOuterHeight.call(this);
      return Result;
    };
    this.GetChildContainer = function () {
      var Result = null;
      if (this.FPanelBody != null) {
        Result = this.FPanelBody}
       else Result = pas["WEBLib.Controls"].TControl.GetChildContainer.call(this);
      return Result;
    };
    this.RegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.RegisterParent.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.UnRegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.UnRegisterParent.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.UpdatePadding = function (ARect) {
      ARect.Left = this.FPadding.FLeft;
      ARect.Top = this.FPadding.FTop;
      ARect.Right = ARect.Right - this.FPadding.FRight;
      ARect.Bottom = ARect.Bottom - this.FPadding.FBottom;
    };
    this.DoAutoSize = function () {
      var i = 0;
      var minx = 0;
      var miny = 0;
      var maxx = 0;
      var maxy = 0;
      var r = null;
      var el = null;
      if (this.FIsSizing) return;
      this.FIsSizing = true;
      if ((this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) && (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute)) {
        maxx = 0;
        maxy = 0;
        minx = 0xFFFF;
        miny = 0xFFFF;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.GetControls(i).FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
            if ((this.GetControls(i).GetLeft() + this.GetControls(i).GetWidth()) > maxx) maxx = this.GetControls(i).GetLeft() + this.GetControls(i).GetWidth();
            if (this.GetControls(i).GetLeft() < minx) minx = this.GetControls(i).GetLeft();
          } else {
            el = this.GetControls(i).GetElementHandle();
            if (el != null) {
              r = el.getBoundingClientRect();
              if (((r.x - this.GetLeft()) + r.width) > maxx) maxx = Math.round((r.x - this.GetLeft()) + r.width);
              minx = 0;
            };
          };
          if (this.GetControls(i).FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
            if ((this.GetControls(i).GetTop() + this.GetControls(i).GetHeight()) > maxy) maxy = this.GetControls(i).GetTop() + this.GetControls(i).GetHeight();
            if (this.GetControls(i).GetTop() < miny) miny = this.GetControls(i).GetTop();
          } else {
            el = this.GetControls(i).GetElementHandle();
            if (el != null) {
              r = el.getBoundingClientRect();
              if (((r.y - this.GetTop()) + r.height) > maxy) maxy = Math.round((r.y - this.GetTop()) + r.height);
              miny = 0;
            };
          };
        };
        if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
          if ((this.GetControlsCount() === 0) || (maxx === 0) || (maxy === 0)) return;
        };
        if (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) {
          maxx += 1;
          maxy += 1;
        };
        for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.GetControls(i).SetLeft(this.GetControls(i).GetLeft() - minx);
          this.GetControls(i).SetTop(this.GetControls(i).GetTop() - miny);
        };
        this.SetWidth(maxx - minx);
        this.SetHeight(maxy - miny);
      } else {
        this.SetWidth(-1);
        this.SetHeight(-1);
      };
      this.UpdateElement();
      this.FIsSizing = false;
    };
    this.AlignControl = function (AControl) {
      pas["WEBLib.Controls"].TControl.AlignControl.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.FEnablePropagation = true;
      this.FAutoSize = false;
      this.FAlignment = pas.Classes.TAlignment.taCenter;
      this.SetColor(15790320);
      this.SetTabStop(false);
      this.FCustomBorder = true;
      this.SetShowCaption(true);
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FLabel = null;
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FPadding");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      if (this.FAutoSize) this.SetAutoSize(true);
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.Controls"].TControl.SetBounds.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPanel",this.TCustomPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementBodyClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementBodyClassName","FElementBodyClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowCaption",2,rtl.boolean,"FShowCaption","SetShowCaption",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TDivPanel",this.TPanel,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWebPanel",this.TPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomGroupBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FCaption$1 = "";
      this.FLegend = null;
      this.FFieldSet = null;
      this.FElementLegendClassName = "";
      this.FPadding = null;
      this.FTransparent = false;
    };
    this.$final = function () {
      this.FLegend = undefined;
      this.FFieldSet = undefined;
      this.FPadding = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetElementLegendClassName = function (Value) {
      if (this.FElementLegendClassName !== Value) {
        this.FElementLegendClassName = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetPadding = function (Value) {
      this.FPadding.Assign(Value);
      this.Realign();
    };
    this.SetTransparent = function (Value) {
      if (this.FTransparent !== Value) {
        this.FTransparent = Value;
        this.UpdateElementVisual();
      };
    };
    this.UpdatePadding = function (ARect) {
      ARect.Left = this.FPadding.FLeft;
      ARect.Top = this.FPadding.FTop;
      ARect.Right = ARect.Right - this.FPadding.FRight;
      ARect.Bottom = ARect.Bottom - this.FPadding.FBottom;
    };
    this.SetFieldSetSize = function () {
      var dx = 0;
      var dy = 0;
      if (this.FFieldSet != null) {
        dx = 4;
        dy = 2;
        if ((this.FElementClassName !== "") || (this.FElementLegendClassName !== "")) {
          dx = 0;
          dy = 0;
        };
        if (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
          this.FFieldSet.style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth() - dx) + "px")}
         else this.FFieldSet.style.setProperty("width","90%");
        if (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
          this.FFieldSet.style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight() - dy) + "px")}
         else this.FFieldSet.style.setProperty("height","90%");
      };
    };
    this.SetCaption = function (Value) {
      if (this.FCaption$1 !== Value) {
        this.FCaption$1 = Value;
        this.UpdateElementData();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FFieldSet = document.createElement("FIELDSET");
      Result.appendChild(this.FFieldSet);
      this.FLegend = document.createElement("LEGEND");
      this.FFieldSet.appendChild(this.FLegend);
      this.FLegend.innerHTML = this.FCaption$1;
      return Result;
    };
    this.UpdateElementData = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.FLegend != null) {
        this.FLegend.innerHTML = this.FCaption$1;
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.removeProperty("background-color");
      };
      if (this.FLegend != null) {
        this.FLegend.setAttribute("class","w-auto " + this.FElementLegendClassName);
        this.FLegend.style.setProperty("float","none");
      };
      if (this.FFieldSet != null) {
        if (this.FTransparent) {
          this.FFieldSet.style.removeProperty("background-color")}
         else this.FFieldSet.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
        this.FFieldSet.style.setProperty("overflow","visible");
        this.SetFieldSetSize();
        this.FFieldSet.style.setProperty("white-space","nowrap");
        this.FFieldSet.style.setProperty("padding-left",pas.SysUtils.IntToStr(this.FPadding.FLeft) + "px");
        this.FFieldSet.style.setProperty("padding-right",pas.SysUtils.IntToStr(this.FPadding.FRight) + "px");
        this.FFieldSet.style.setProperty("padding-top",pas.SysUtils.IntToStr(this.FPadding.FTop) + "px");
        this.FFieldSet.style.setProperty("padding-bottom",pas.SysUtils.IntToStr(this.FPadding.FBottom) + "px");
        if (this.FVisible) this.FFieldSet.style.setProperty("display","inline-block");
        this.FFieldSet.style.setProperty("webkit-user-select","none");
        this.FFieldSet.style.setProperty("moz-user-select","none");
        this.FFieldSet.style.setProperty("khtml-user-select","none");
        this.FFieldSet.style.setProperty("ms-user-select","none");
        this.FFieldSet.style.setProperty("user-select","none");
        this.FFieldSet.style.setProperty("border","1px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FBorderColor));
      };
    };
    this.SetBoundsInt = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.Controls"].TControl.SetBoundsInt.apply(this,arguments);
      this.SetFieldSetSize();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementLegendClassName("h6");
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FPadding");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetColor(15790320);
      this.FTransparent = false;
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TGroupBox",this.TCustomGroupBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("Caption",2,rtl.string,"FCaption$1","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementLegendClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLegendClassName","SetElementLegendClassName");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebGroupBox",this.TGroupBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollBox",this.TCustomPanel,function () {
    this.$init = function () {
      $mod.TCustomPanel.$init.call(this);
      this.FAutoScroll = false;
      this.FScrollBars = 0;
      this.FScrollPtr = null;
      this.FOnScroll = null;
      this.FVertScrollBar = null;
      this.FHorzScrollBar = null;
    };
    this.$final = function () {
      this.FOnScroll = undefined;
      this.FVertScrollBar = undefined;
      this.FHorzScrollBar = undefined;
      $mod.TCustomPanel.$final.call(this);
    };
    this.GetScrollLeft = function () {
      var Result = 0;
      Result = this.GetElementHandle().scrollLeft;
      return Result;
    };
    this.GetScrollTop = function () {
      var Result = 0;
      Result = this.GetElementHandle().scrollTop;
      return Result;
    };
    this.SetScrollLeft = function (Value) {
      this.GetElementHandle().scrollLeft = Value;
    };
    this.SetScrollTop = function (Value) {
      this.GetElementHandle().scrollTop = Value;
    };
    this.SetScrollBars = function (Value) {
      if (this.FScrollBars !== Value) {
        this.FScrollBars = Value;
        this.UpdateElement();
      };
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.UpdateElementVisual = function () {
      $mod.TCustomPanel.UpdateElementVisual.call(this);
      this.UpdateScrollStyle();
    };
    this.UpdateScrollStyle = function () {
      if ((this.GetElementHandle() != null) && !this.IsUpdating()) {
        var $tmp = this.FScrollBars;
        if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssNone) {
          this.GetElementHandle().style.setProperty("overflow","hidden");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssVertical) {
          this.GetElementHandle().style.removeProperty("overflow");
          this.GetElementHandle().style.setProperty("overflow-x","hidden");
          this.GetElementHandle().style.setProperty("overflow-y","auto");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssHorizontal) {
          this.GetElementHandle().style.removeProperty("overflow");
          this.GetElementHandle().style.setProperty("overflow-x","auto");
          this.GetElementHandle().style.setProperty("overflow-y","hidden");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssBoth) {
          this.GetElementHandle().style.setProperty("overflow","auto");
        };
        if (this.FVisible && !this.GetIsLinked()) this.GetElementHandle().style.setProperty("display","inline-block");
      };
    };
    this.SetAutoScroll = function (AValue) {
      this.FAutoScroll = AValue;
    };
    this.GetClientRect = function () {
      var Result = pas.Types.TRect.$new();
      var dw = 0;
      var dh = 0;
      dw = 0;
      dh = 0;
      if ((this.GetElementHandle().scrollHeight > this.GetElementHandle().clientHeight) && (this.FScrollBars in rtl.createSet(pas["WEBLib.Controls"].TScrollStyle.ssBoth,pas["WEBLib.Controls"].TScrollStyle.ssVertical))) dw = pas["WEBLib.Controls"].GetScrollBarWidth();
      if ((this.GetElementHandle().scrollWidth > this.GetElementHandle().clientWidth) && (this.FScrollBars in rtl.createSet(pas["WEBLib.Controls"].TScrollStyle.ssBoth,pas["WEBLib.Controls"].TScrollStyle.ssHorizontal))) dh = pas["WEBLib.Controls"].GetScrollBarHeight();
      Result.$assign(pas.Types.Rect(0,0,this.GetElementHandle().clientWidth - dw,this.GetElementHandle().clientHeight - dh));
      return Result;
    };
    this.HandleDoScroll = function (Event) {
      var Result = false;
      this.DoScroll();
      Result = true;
      return Result;
    };
    this.DoScroll = function () {
      if (this.FOnScroll != null) this.FOnScroll(this);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FScrollPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      if (this.FScrollPtr === null) {
        this.FScrollPtr = rtl.createCallback(this,"HandleDoScroll");
      };
    };
    this.BindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.addEventListener("scroll",this.FScrollPtr);
      };
    };
    this.UnbindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.removeEventListener("scroll",this.FScrollPtr);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomPanel.CreateInitialize.call(this);
      this.FAutoScroll = true;
      this.FScrollBars = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      this.FHorzScrollBar = pas["WEBLib.Controls"].TControlScrollBar.$create("Create$1",[this,pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal]);
      this.FVertScrollBar = pas["WEBLib.Controls"].TControlScrollBar.$create("Create$1",[this,pas["WEBLib.Controls"].TScrollBarKind.sbVertical]);
    };
    this.Destroy = function () {
      rtl.free(this,"FHorzScrollBar");
      rtl.free(this,"FVertScrollBar");
      $mod.TCustomPanel.Destroy.call(this);
    };
    this.ScrollBy = function (DeltaX, DeltaY) {
      this.SetScrollLeft(this.GetScrollLeft() + DeltaX);
      this.SetScrollTop(this.GetScrollTop() + DeltaY);
    };
    this.EndUpdate = function () {
      $mod.TCustomPanel.EndUpdate.call(this);
      this.AlignControl(this);
      this.AlignControl(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoScroll",2,rtl.boolean,"FAutoScroll","SetAutoScroll");
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ScrollBars",2,pas["WEBLib.Controls"].$rtti["TScrollStyle"],"FScrollBars","SetScrollBars");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnScroll",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnScroll","FOnScroll");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebScrollBox",this.TScrollBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSplitter",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FLayer$1 = null;
      this.FTouched = false;
      this.FFirstMove = false;
      this.FSplitControl = null;
      this.FSplitPos = 0;
      this.FSizing = false;
      this.FSizingX = 0.0;
      this.FSizingY = 0.0;
      this.FOriginalWidth = 0;
      this.FOriginalHeight = 0;
      this.FGripColor = 0;
      this.FOnMoved = null;
      this.FOnMove = null;
    };
    this.$final = function () {
      this.FLayer$1 = undefined;
      this.FSplitControl = undefined;
      this.FOnMoved = undefined;
      this.FOnMove = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetGripColor = function (Value) {
      if (this.FGripColor !== Value) {
        this.FGripColor = Value;
        this.Invalidate();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = pas["WEBLib.Controls"].TCustomControl.CreateElement.call(this);
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
    };
    this.ColorChanging = function () {
      pas["WEBLib.Controls"].TControl.ColorChanging.call(this);
      this.Invalidate();
    };
    this.DoSizeStart = function (X, Y) {
      var r = pas.Types.TRect.$new();
      var rc = pas.Types.TRect.$new();
      var i = 0;
      var c = null;
      var eh = null;
      this.FSizing = true;
      Y = Y - document.documentElement.scrollTop;
      r.$assign(pas.Types.Rect(this.GetLeft(),this.GetTop(),this.GetLeft() + this.GetWidth(),this.GetTop() + this.GetHeight()));
      if (this.FParent != null) {
        if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alRight,pas["WEBLib.Controls"].TAlign.alBottom)) {
          for (var $l = 0, $end = this.FParent.GetControlsCount() - 1; $l <= $end; $l++) {
            i = $l;
            c = this.FParent.GetControls(i);
            rc.$assign(pas.Types.Rect(c.GetLeft(),c.GetTop(),c.GetLeft() + c.GetWidth(),c.GetTop() + c.GetHeight()));
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) && (c !== this) && ((r.Left - rc.Right) < 4) && ((r.Left - rc.Right) >= 0)) {
              this.FSplitPos = rc.Left;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) && (c !== this) && ((r.Top - rc.Bottom) < 4) && ((r.Top - rc.Bottom) >= -4)) {
              this.FSplitPos = rc.Top;
            };
          };
        };
        for (var $l1 = 0, $end1 = this.FParent.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          c = this.FParent.GetControls(i);
          rc.$assign(pas.Types.Rect(c.GetLeft(),c.GetTop(),c.GetLeft() + c.GetWidth(),c.GetTop() + c.GetHeight()));
          if ((c.FAlign === this.FAlign) && (c !== this)) {
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) && ((rc.Right - r.Left) < 4)) {
              this.FSplitControl = c;
              this.FOriginalWidth = this.FSplitControl.GetWidth();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) && ((rc.Left - r.Right) < 4)) {
              this.FSplitControl = c;
              this.FSplitPos = rc.Right - this.FSplitPos - this.GetWidth();
              this.FOriginalWidth = this.FSplitControl.GetWidth();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alTop) && ((rc.Bottom - r.Top) < 4)) {
              this.FSplitControl = c;
              this.FOriginalHeight = this.FSplitControl.GetHeight();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) && ((rc.Top - r.Bottom) < 4)) {
              this.FSplitControl = c;
              this.FSplitPos = rc.Bottom - this.FSplitPos - this.GetHeight();
              this.FOriginalHeight = this.FSplitControl.GetHeight();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
          };
        };
      };
      this.FLayer$1 = document.createElement("SPAN");
      document.body.appendChild(this.FLayer$1);
      eh = this.FLayer$1;
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("z-index","99999999");
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","fixed");
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight)) eh.style.setProperty("cursor","col-resize");
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) eh.style.setProperty("cursor","row-resize");
      this.FFirstMove = true;
      this.FSizing = true;
      eh.addEventListener("mousemove",rtl.createSafeCallback(this,"HandleDocDoMouseMove"));
      eh.addEventListener("mouseup",rtl.createSafeCallback(this,"HandleDocDoMouseUp"));
      eh.addEventListener("touchmove",rtl.createCallback(this,"HandleDocDoTouchMove"));
      eh.addEventListener("touchend",rtl.createCallback(this,"HandleDocDoTouchEnd"));
    };
    this.HandleDoTouchStart = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      this.StopPropagation();
      this.PreventDefault();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.FTouched = true;
        this.Invalidate();
        this.Invalidate();
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        this.DoSizeStart(Math.round(l),Math.round(t));
      };
      Result = false;
      return Result;
    };
    this.HandleDocDoMouseMove = function (Event) {
      var Result = false;
      var dx = 0;
      var dy = 0;
      if (this.FSizing && (this.FSplitControl != null)) {
        if (this.FFirstMove) {
          this.FSizingX = Event.clientX;
          this.FSizingY = Event.clientY - document.documentElement.scrollTop;
          this.FFirstMove = false;
        } else {
          dx = Math.round(Event.clientX - this.FSizingX);
          dy = Math.round(Event.clientY - document.documentElement.scrollTop - this.FSizingY);
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) this.FSplitControl.SetWidth(Math.max(0,this.FOriginalWidth + dx));
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) this.FSplitControl.SetWidth(Math.max(0,Math.min(this.FSplitPos,this.FOriginalWidth - dx)));
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alTop) this.FSplitControl.SetHeight(Math.max(0,this.FOriginalHeight + dy));
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) this.FSplitControl.SetHeight(Math.max(0,Math.min(this.FSplitPos,this.FOriginalHeight - dy)));
          this.DoRealign();
          if (this.FOnMove != null) this.FOnMove(this);
        };
      };
      Result = true;
      return Result;
    };
    this.HandleDocDoMouseUp = function (Event) {
      var Result = false;
      this.FSizing = false;
      this.FSplitControl = null;
      this.FFirstMove = true;
      this.FLayer$1.parentNode.removeChild(this.FLayer$1);
      Result = true;
      if (this.FOnMoved != null) this.FOnMoved(this);
      return Result;
    };
    this.HandleDocDoTouchMove = function (Event) {
      var Result = false;
      var touch = null;
      var dx = 0;
      var dy = 0;
      this.StopPropagation();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        if (this.FSizing && (this.FSplitControl != null)) {
          if (this.FFirstMove) {
            this.FSizingX = touch.clientX;
            this.FSizingY = touch.clientY;
            this.FFirstMove = false;
          } else {
            dx = Math.round(touch.clientX - this.FSizingX);
            dy = Math.round(touch.clientY - this.FSizingY);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) this.FSplitControl.SetWidth(this.FOriginalWidth + dx);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) this.FSplitControl.SetWidth(this.FOriginalWidth - dx);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alTop) this.FSplitControl.SetHeight(this.FOriginalHeight + dy);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) this.FSplitControl.SetHeight(this.FOriginalHeight - dy);
            this.DoRealign();
            if (this.FOnMove != null) this.FOnMove(this);
          };
        };
      };
      Result = true;
      return Result;
    };
    this.HandleDocDoTouchEnd = function (Event) {
      var Result = false;
      this.FTouched = false;
      this.Invalidate();
      this.FSizing = false;
      this.FSplitControl = null;
      this.FFirstMove = true;
      this.FLayer$1.parentNode.removeChild(this.FLayer$1);
      Result = true;
      if (this.FOnMoved != null) this.FOnMoved(this);
      return Result;
    };
    this.DoMouseEnter = function () {
      pas["WEBLib.Controls"].TControl.DoMouseEnter.call(this);
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight)) this.SetControlCursor(14);
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) this.SetControlCursor(15);
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseUp.apply(this,arguments);
      this.FSizing = false;
      this.FSplitControl = null;
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseDown.apply(this,arguments);
      this.DoSizeStart(X,Y);
    };
    this.Paint = function () {
      var xofs = 0;
      var dx = 0;
      var yofs = 0;
      var dy = 0;
      var i = 0;
      if (this.FTouched) {
        this.GetCanvas().FBrush.FColor = 8421504;
        this.GetCanvas().FPen.SetColor(8421504);
      } else {
        this.GetCanvas().FBrush.FColor = this.FColor;
        this.GetCanvas().FPen.SetColor(this.FColor);
      };
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsSolid;
      this.GetCanvas().Rectangle$2(this.GetClientRect());
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight)) {
        dx = 0;
        dy = 6;
        yofs = rtl.trunc(this.GetHeight() / 2) - 9;
        xofs = rtl.trunc(this.GetWidth() / 2);
      };
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) {
        dx = 6;
        dy = 0;
        xofs = rtl.trunc(this.GetWidth() / 2) - 9;
        yofs = rtl.trunc(this.GetHeight() / 2) - 1;
      };
      this.GetCanvas().FBrush.FColor = this.FGripColor;
      this.GetCanvas().FPen.SetColor(this.FGripColor);
      for (i = 0; i <= 2; i++) {
        this.GetCanvas().Rectangle$1(xofs,yofs,xofs + 2,yofs + 2);
        xofs = xofs + dx;
        yofs = yofs + dy;
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetControlCursor(14);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(6);
        this.SetHeight(100);
      };
      this.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
      this.FSplitControl = null;
      this.SetGripColor(16777215);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("GripColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FGripColor","SetGripColor",4,{Default: 16777215});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
    $r.addProperty("OnMove",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMove","FOnMove");
    $r.addProperty("OnMoved",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMoved","FOnMoved");
  });
  rtl.createClass(this,"TWebSplitter",this.TSplitter,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TVerticalAlignment = {"0": "vaTop", vaTop: 0, "1": "vaCenter", vaCenter: 1, "2": "vaBottom", vaBottom: 2};
  this.$rtti.$Enum("TVerticalAlignment",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TVerticalAlignment});
  this.TGridPanelExpandStyle = {"0": "esAddRows", esAddRows: 0, "1": "esAddColumns", esAddColumns: 1};
  this.$rtti.$Enum("TGridPanelExpandStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TGridPanelExpandStyle});
  rtl.createClass(this,"TGridPanelRow",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FSizeStyle = 0;
      this.FValue = 0;
      this.FMarginBottom = 0;
      this.FMarginTop = 0;
      this.FAlignment = 0;
      this.FElementClassName = "";
    };
    this.SetMarginBottom = function (Value) {
      if (this.FMarginBottom !== Value) {
        this.FMarginBottom = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetMarginTop = function (Value) {
      if (this.FMarginTop !== Value) {
        this.FMarginTop = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetSizeStyle = function (Value) {
      if (this.FSizeStyle !== Value) {
        this.FSizeStyle = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetValue = function (Value) {
      if (this.FValue !== Value) {
        this.FValue = Value;
        this.FCollection.Update(this);
      };
    };
    this.HeightAttribute = function () {
      var Result = "";
      Result = "";
      var $tmp = this.FSizeStyle;
      if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
        Result = pas.SysUtils.IntToStr(this.FValue) + "%"}
       else if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) Result = pas.SysUtils.IntToStr(this.FValue) + "px";
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FSizeStyle = pas["WEBLib.Controls"].TSizeStyle.ssPercent;
      this.FAlignment = $mod.TVerticalAlignment.vaTop;
      this.FMarginTop = 0;
      this.FMarginBottom = 0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TGridPanelRow.isPrototypeOf(Source)) {
        this.FAlignment = rtl.as(Source,$mod.TGridPanelRow).FAlignment;
        this.FSizeStyle = rtl.as(Source,$mod.TGridPanelRow).FSizeStyle;
        this.FElementClassName = rtl.as(Source,$mod.TGridPanelRow).FElementClassName;
        this.FValue = rtl.as(Source,$mod.TGridPanelRow).FValue;
        this.FMarginTop = rtl.as(Source,$mod.TGridPanelRow).FMarginTop;
        this.FMarginBottom = rtl.as(Source,$mod.TGridPanelRow).FMarginBottom;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Alignment",0,$mod.$rtti["TVerticalAlignment"],"FAlignment","FAlignment",4,{Default: $mod.TVerticalAlignment.vaTop});
    $r.addProperty("ElementClassName",0,rtl.string,"FElementClassName","FElementClassName");
    $r.addProperty("MarginTop",2,rtl.longint,"FMarginTop","SetMarginTop");
    $r.addProperty("MarginBottom",2,rtl.longint,"FMarginBottom","SetMarginBottom");
    $r.addProperty("SizeStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FSizeStyle","SetSizeStyle");
    $r.addProperty("Value",2,rtl.longint,"FValue","SetValue");
  });
  rtl.createClass(this,"TGridPanelRows",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TGridPanelRow);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  rtl.createClass(this,"TGridPanelColumn",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FSizeStyle = 0;
      this.FValue = 0;
      this.FMarginLeft = 0;
      this.FAlignment = 0;
      this.FMarginRight = 0;
      this.FElementClassName = "";
    };
    this.SetMarginLeft = function (Value) {
      if (this.FMarginLeft !== Value) {
        this.FMarginLeft = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetMarginRight = function (Value) {
      if (this.FMarginRight !== Value) {
        this.FMarginRight = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetSizeStyle = function (Value) {
      if (this.FSizeStyle !== Value) {
        this.FSizeStyle = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetValue = function (Value) {
      if (this.FValue !== Value) {
        this.FValue = Value;
        this.FCollection.Update(this);
      };
    };
    this.WidthAttribute = function () {
      var Result = "";
      Result = "";
      var $tmp = this.FSizeStyle;
      if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
        Result = pas.SysUtils.IntToStr(this.FValue) + "%"}
       else if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) Result = pas.SysUtils.IntToStr(this.FValue) + "px";
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FSizeStyle = pas["WEBLib.Controls"].TSizeStyle.ssPercent;
      this.FValue = 0;
      this.FMarginLeft = 0;
      this.FMarginRight = 0;
      this.FAlignment = pas.Classes.TAlignment.taLeftJustify;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TGridPanelColumn.isPrototypeOf(Source)) {
        this.FAlignment = rtl.as(Source,$mod.TGridPanelColumn).FAlignment;
        this.FSizeStyle = rtl.as(Source,$mod.TGridPanelColumn).FSizeStyle;
        this.FElementClassName = rtl.as(Source,$mod.TGridPanelColumn).FElementClassName;
        this.FValue = rtl.as(Source,$mod.TGridPanelColumn).FValue;
        this.FMarginLeft = rtl.as(Source,$mod.TGridPanelColumn).FMarginLeft;
        this.FMarginRight = rtl.as(Source,$mod.TGridPanelColumn).FMarginRight;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Alignment",0,pas.Classes.$rtti["TAlignment"],"FAlignment","FAlignment",4,{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("ElementClassName",0,rtl.string,"FElementClassName","FElementClassName");
    $r.addProperty("MarginLeft",2,rtl.longint,"FMarginLeft","SetMarginLeft",4,{Default: 0});
    $r.addProperty("MarginRight",2,rtl.longint,"FMarginRight","SetMarginRight",4,{Default: 0});
    $r.addProperty("SizeStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FSizeStyle","SetSizeStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssPercent});
    $r.addProperty("Value",2,rtl.longint,"FValue","SetValue");
  });
  rtl.createClass(this,"TGridPanelColumns",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TGridPanelColumn);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  rtl.createClass(this,"TControlCollectionItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FControl = null;
      this.FRow = 0;
      this.FColumn = 0;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TControlCollectionItem.isPrototypeOf(Source)) {
        this.FColumn = rtl.as(Source,$mod.TControlCollectionItem).FColumn;
        this.FRow = rtl.as(Source,$mod.TControlCollectionItem).FRow;
        this.FControl = rtl.as(Source,$mod.TControlCollectionItem).FControl;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Column",0,rtl.longint,"FColumn","FColumn");
    $r.addProperty("Row",0,rtl.longint,"FRow","FRow");
    $r.addProperty("Control",0,pas["WEBLib.Controls"].$rtti["TWinControl"],"FControl","FControl");
  });
  rtl.createClass(this,"TControlCollection",pas.Classes.TOwnedCollection,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TControlCollectionItem);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.FindItem = function (AControl) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FControl === AControl) {
          Result = this.GetItem$1(i);
          return Result;
        };
      };
      return Result;
    };
    this.GetItemAtCell = function (ACol, ARow) {
      var Result = null;
      var i = 0;
      Result = null;
      if ((this.Owner() != null) && $mod.TGridPanel.isPrototypeOf(this.Owner())) {
        i = ACol + (rtl.as(this.Owner(),$mod.TGridPanel).FColumnCollection.GetCount() * ARow);
        if (i < this.GetCount()) Result = this.GetItem$1(i);
      };
      return Result;
    };
  });
  rtl.createClass(this,"TGridPanel",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FUpdateTable = false;
      this.FColCount = 0;
      this.FRowCollection = null;
      this.FColumnCollection = null;
      this.FControlCollection = null;
      this.FGridLineWidth = 0;
      this.FGridLineColor = 0;
      this.FExpandStyle = 0;
      this.FTbl = null;
      this.FTblBody = null;
    };
    this.$final = function () {
      this.FRowCollection = undefined;
      this.FColumnCollection = undefined;
      this.FControlCollection = undefined;
      this.FTbl = undefined;
      this.FTblBody = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetColumnCollection = function (Value) {
      this.FColumnCollection.Assign(Value);
    };
    this.SetRowCollection = function (Value) {
      this.FRowCollection.Assign(Value);
    };
    this.SetControlCollection = function (Value) {
      this.FControlCollection.Assign(Value);
    };
    this.CreateTable = function () {
      var Result = null;
      var row = null;
      var j = 0;
      var ps = "";
      this.FTbl = document.createElement("table");
      this.FTbl.setAttribute("width","100%");
      this.FTbl.setAttribute("height","100%");
      if (this.FElementClassName !== "") {
        this.FTbl.setAttribute("class",this.FElementClassName)}
       else {
        if ((this.FGridLineColor !== -1) && (this.FGridLineWidth > 0)) {
          ps = pas.SysUtils.IntToStr(this.FGridLineWidth) + "px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FGridLineColor)}
         else {
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
            ps = "1px dotted gray"}
           else ps = "0px";
        };
        this.FTbl.style.setProperty("border",ps);
        this.FTbl.style.setProperty("border-collapse","collapse");
      };
      pas["WEBLib.Controls"].SetHTMLElementColor(this.FTbl,this.FColor,!((this.FElementClassName === "") && !this.GetIsLinked()));
      this.FTblBody = document.createElement("tbody");
      for (var $l = 0, $end = this.FRowCollection.GetCount() - 1; $l <= $end; $l++) {
        j = $l;
        row = this.CreateRow(j);
        this.FTblBody.appendChild(row);
      };
      this.FTbl.appendChild(this.FTblBody);
      Result = this.FTbl;
      return Result;
    };
    this.CreateRow = function (AIndex) {
      var Result = null;
      var row = null;
      var cell = null;
      var i = 0;
      var ps = "";
      if ((this.FGridLineColor !== -1) && (this.FGridLineWidth > 0)) {
        ps = pas.SysUtils.IntToStr(this.FGridLineWidth) + "px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FGridLineColor)}
       else {
        if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
          ps = "1px dotted gray"}
         else ps = "0px";
      };
      row = document.createElement("tr");
      if (this.FElementClassName === "") row.style.setProperty("border",ps);
      if (AIndex < this.FRowCollection.GetCount()) {
        if (this.FRowCollection.GetItem$1(AIndex).FMarginTop !== 0) row.style.setProperty("margin-top",pas.SysUtils.IntToStr(this.FRowCollection.GetItem$1(AIndex).FMarginTop));
        if (this.FRowCollection.GetItem$1(AIndex).FMarginBottom !== 0) row.style.setProperty("margin-bottom",pas.SysUtils.IntToStr(this.FRowCollection.GetItem$1(AIndex).FMarginBottom));
        if (this.FRowCollection.GetItem$1(AIndex).FElementClassName !== "") {
          row.setAttribute("class",this.FRowCollection.GetItem$1(AIndex).FElementClassName);
        };
        var $tmp = this.FRowCollection.GetItem$1(AIndex).FAlignment;
        if ($tmp === $mod.TVerticalAlignment.vaCenter) {
          row.setAttribute("valign","middle")}
         else if ($tmp === $mod.TVerticalAlignment.vaBottom) row.setAttribute("valign","bottom");
        if (this.FElementClassName === "") row.style.setProperty("border",ps);
        row.setAttribute("height",this.FRowCollection.GetItem$1(AIndex).HeightAttribute());
      };
      for (var $l = 0, $end = this.FColumnCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        cell = document.createElement("td");
        if (this.FElementClassName === "") cell.style.setProperty("border",ps);
        if (this.FColumnCollection.GetItem$1(i).FMarginLeft !== 0) cell.style.setProperty("padding-left",pas.SysUtils.IntToStr(this.FColumnCollection.GetItem$1(i).FMarginLeft) + "px");
        if (this.FColumnCollection.GetItem$1(i).FMarginRight !== 0) cell.style.setProperty("padding-right",pas.SysUtils.IntToStr(this.FColumnCollection.GetItem$1(i).FMarginRight) + "px");
        if (this.FColumnCollection.GetItem$1(i).FElementClassName !== "") {
          cell.setAttribute("class",this.FColumnCollection.GetItem$1(i).FElementClassName);
        };
        var $tmp1 = this.FColumnCollection.GetItem$1(i).FAlignment;
        if ($tmp1 === pas.Classes.TAlignment.taCenter) {
          cell.setAttribute("align","center")}
         else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) cell.setAttribute("align","right");
        cell.setAttribute("id",this.FName + "R" + pas.SysUtils.IntToStr(AIndex) + "C" + pas.SysUtils.IntToStr(i));
        if (AIndex === 0) {
          cell.style.setProperty("width",this.FColumnCollection.GetItem$1(i).WidthAttribute());
        };
        row.appendChild(cell);
      };
      Result = row;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.AlignControl = function (AControl) {
      if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.UpdateTable();
      pas["WEBLib.Controls"].TControl.AlignControl.apply(this,arguments);
    };
    this.UpdateTable = function () {
      var i = 0;
      var j = 0;
      var k = 0;
      var mw = 0;
      var numrows = 0;
      var fragment = null;
      var destid = "";
      var control = null;
      var el = null;
      var row = null;
      var isPercent = false;
      var f = 0.0;
      if (!(this.FTblBody != null)) return;
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      isPercent = true;
      mw = 0;
      for (var $l = 0, $end = this.FRowCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FRowCollection.GetItem$1(i).FSizeStyle !== pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
          isPercent = false;
          break;
        } else mw = mw + this.FRowCollection.GetItem$1(i).FValue;
      };
      if (isPercent && (mw > 100)) {
        f = mw / 100;
        for (var $l1 = 0, $end1 = this.FRowCollection.GetCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FRowCollection.GetItem$1(i).FValue = pas.System.Trunc(this.FRowCollection.GetItem$1(i).FValue / f);
        };
      };
      isPercent = true;
      mw = 0;
      for (var $l2 = 0, $end2 = this.FColumnCollection.GetCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if (this.FColumnCollection.GetItem$1(i).FSizeStyle !== pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
          isPercent = false;
          break;
        } else mw = mw + this.FColumnCollection.GetItem$1(i).FValue;
      };
      if (isPercent && (mw > 100)) {
        f = mw / 100;
        for (var $l3 = 0, $end3 = this.FColumnCollection.GetCount() - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          this.FColumnCollection.GetItem$1(i).FValue = pas.System.Trunc(this.FColumnCollection.GetItem$1(i).FValue / f);
        };
      };
      numrows = this.FRowCollection.GetCount();
      if (this.FColCount !== this.FColumnCollection.GetCount()) numrows = 0;
      while (this.FTblBody.childNodes.length > numrows) {
        this.FTblBody.removeChild(this.FTblBody.childNodes.item(this.FTblBody.childNodes.length - 1));
      };
      while (this.FTblBody.childNodes.length < this.FRowCollection.GetCount()) {
        row = this.CreateRow(this.FTblBody.childNodes.length);
        this.FTblBody.appendChild(row);
      };
      for (var $l4 = 0, $end4 = this.FRowCollection.GetCount() - 1; $l4 <= $end4; $l4++) {
        i = $l4;
        row = this.FTblBody.childNodes.item(i);
        row.setAttribute("height",this.FRowCollection.GetItem$1(i).HeightAttribute());
      };
      i = 0;
      j = 0;
      for (var $l5 = 0, $end5 = this.FControlCollection.GetCount() - 1; $l5 <= $end5; $l5++) {
        k = $l5;
        if (this.FControlCollection.GetItem$1(k).FControl != null) {
          fragment = document.createDocumentFragment();
          control = this.FControlCollection.GetItem$1(k).FControl;
          this.FControlCollection.GetItem$1(k).FColumn = i;
          this.FControlCollection.GetItem$1(k).FRow = j;
          control.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          control.SetChildOrderEx(-1);
          if (control.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) {
            control.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetHeightPercent(100);
            if (control.GetElementHandle() != null) control.GetElementHandle().style.setProperty("float","left");
          };
          if (control.FAlign === pas["WEBLib.Controls"].TAlign.alRight) {
            control.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetHeightPercent(100);
            if (control.GetElementHandle() != null) control.GetElementHandle().style.setProperty("float","right");
          };
          if (control.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) {
            control.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetWidthPercent(100);
          };
          if (control.FAlign === pas["WEBLib.Controls"].TAlign.alClient) {
            control.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetWidthPercent(100);
            control.SetHeightPercent(100);
          };
          row = this.FTblBody.childNodes.item(j);
          if ((row != null) && (j < this.FRowCollection.GetCount())) {
            row.setAttribute("height",this.FRowCollection.GetItem$1(j).HeightAttribute());
            if (this.FRowCollection.GetItem$1(j).FElementClassName !== "") {
              row.setAttribute("class",this.FRowCollection.GetItem$1(j).FElementClassName)}
             else row.removeAttribute("class");
          };
          if (control.GetElementHandle() != null) fragment.appendChild(control.GetElementHandle());
          destid = this.FName + "R" + pas.SysUtils.IntToStr(j) + "C" + pas.SysUtils.IntToStr(i);
          el = document.getElementById(destid);
          if (!(el != null)) {
            row = this.CreateRow(j);
            this.FTblBody.appendChild(row);
            el = document.getElementById(destid);
            if (this.FRowCollection.GetCount() > j) row.setAttribute("height",this.FRowCollection.GetItem$1(j).HeightAttribute());
          } else {
            if ((j === 0) && (i < this.FColumnCollection.GetCount())) {
              if (this.FColumnCollection.GetItem$1(i).FSizeStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
                this.FTbl.removeAttribute("width");
                this.FTbl.removeAttribute("height");
              } else {
                this.FTbl.setAttribute("width","100%");
                this.FTbl.setAttribute("height","100%");
              };
              el.style.setProperty("width",this.FColumnCollection.GetItem$1(i).WidthAttribute());
            };
          };
          if (el != null) {
            el.appendChild(fragment);
            if (control.FAlign === pas["WEBLib.Controls"].TAlign.alTop) el.style.setProperty("vertical-align","top");
            if (control.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) el.style.setProperty("vertical-align","bottom");
          };
          i += 1;
          if (i === this.FColumnCollection.GetCount()) {
            i = 0;
            j += 1;
          };
        };
      };
      for (var $l6 = 0, $end6 = this.FColumnCollection.GetCount() - 1; $l6 <= $end6; $l6++) {
        i = $l6;
        destid = this.FName + "R0C" + pas.SysUtils.IntToStr(i);
        el = document.getElementById(destid);
        if (el != null) el.style.setProperty("width",this.FColumnCollection.GetItem$1(i).WidthAttribute());
      };
      this.FColCount = this.FColumnCollection.GetCount();
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && !this.IsUpdating()) {
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
        if (this.FUpdateTable && (this.GetContainer() != null)) {
          this.GetContainer().appendChild(this.CreateTable());
          this.UpdateTable();
          this.FUpdateTable = false;
        };
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.GetElementHandle().style.setProperty("border","1px dotted gray");
      };
      if (!this.GetIsLinked() && (this.FTbl != null)) {
        if (this.FColor !== -1) {
          this.FTbl.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.FTbl.style.removeProperty("background-color");
      };
    };
    this.RegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.RegisterParent.apply(this,arguments);
      if (!this.IsUpdating() && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if (pas.Classes.TComponentStateItem.csLoading in AValue.FComponentState) return;
        this.FControlCollection.Add$1().FControl = AValue;
        if (this.FControlCollection.GetCount() > (this.FColumnCollection.GetCount() * this.FRowCollection.GetCount())) {
          if (this.FExpandStyle === $mod.TGridPanelExpandStyle.esAddRows) {
            this.FRowCollection.Add$1()}
           else this.FColumnCollection.Add$1();
        };
        this.UpdateTable();
      };
    };
    this.TableChanged = function (Sender) {
      this.UpdateTable();
    };
    this.Notification = function (AComponent, Operation) {
      var i = 0;
      var destid = "";
      var el = null;
      if ((Operation === pas.Classes.TOperation.opRemove) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FControlCollection.GetItem$1(i).FControl === AComponent) {
            destid = this.FName + "R" + pas.SysUtils.IntToStr(this.FControlCollection.GetItem$1(i).FRow) + "C" + pas.SysUtils.IntToStr(this.FControlCollection.GetItem$1(i).FColumn);
            el = document.getElementById(destid);
            el.removeChild(el.firstChild);
            this.FControlCollection.GetItem$1(i).FControl = null;
            this.FControlCollection.Delete(i);
          };
        };
        this.UpdateTable();
      };
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FUpdateTable = true;
      this.FColCount = -1;
      this.FRowCollection = $mod.TGridPanelRows.$create("Create$3",[this]);
      this.FRowCollection.FPropName = "RowCollection";
      if (this.FDesignTime$1 && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.FRowCollection.Add$1();
        this.FRowCollection.GetItem$1(0).SetValue(100);
        this.FRowCollection.GetItem$1(0).SetSizeStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      };
      this.FColumnCollection = $mod.TGridPanelColumns.$create("Create$3",[this]);
      this.FColumnCollection.FPropName = "ColumnCollection";
      if (this.FDesignTime$1 && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.FColumnCollection.Add$1();
        this.FColumnCollection.Add$1();
        this.FColumnCollection.GetItem$1(0).SetValue(50);
        this.FColumnCollection.GetItem$1(1).SetValue(50);
        this.FColumnCollection.GetItem$1(0).SetSizeStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
        this.FColumnCollection.GetItem$1(1).SetSizeStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      };
      this.FRowCollection.FOnChange = rtl.createCallback(this,"TableChanged");
      this.FColumnCollection.FOnChange = rtl.createCallback(this,"TableChanged");
      this.FControlCollection = $mod.TControlCollection.$create("Create$3",[this]);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FRowCollection");
      rtl.free(this,"FColumnCollection");
      rtl.free(this,"FControlCollection");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.AddControl = function (AControl) {
      this.FControlCollection.Add$1().FControl = AControl;
      AControl.SetParent(this);
      if (this.FControlCollection.GetCount() > (this.FColumnCollection.GetCount() * this.FRowCollection.GetCount())) {
        if (this.FExpandStyle === $mod.TGridPanelExpandStyle.esAddRows) {
          this.FRowCollection.Add$1()}
         else this.FColumnCollection.Add$1();
      };
    };
    this.RemoveControl = function (AControl) {
      var i = 0;
      var r = 0;
      var c = 0;
      var row = null;
      var d = 0.0;
      for (var $l = 0, $end = this.FControlCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControlCollection.GetItem$1(i).FControl === AControl) {
          r = this.FControlCollection.GetItem$1(i).FRow;
          c = this.FControlCollection.GetItem$1(i).FColumn;
          row = this.FTblBody.childNodes.item(r);
          row.childNodes.item(c).innerHTML = "";
          this.FControlCollection.Delete(i);
          break;
        };
      };
      if (this.FColumnCollection.GetCount() > 0) {
        d = this.FControlCollection.GetCount() / this.FColumnCollection.GetCount();
        if (pas.System.Frac(d) > 0) d = pas.System.Trunc(d + 1);
        while (d < this.FRowCollection.GetCount()) {
          this.FRowCollection.Delete(this.FRowCollection.GetCount() - 1);
        };
      };
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.UpdateTable();
    };
    this.RemoveControls = function () {
      var i = 0;
      for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        this.RemoveControl(this.FControlCollection.GetItem$1(i).FControl);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ControlCollection",2,$mod.$rtti["TControlCollection"],"FControlCollection","SetControlCollection");
    $r.addProperty("ColumnCollection",2,$mod.$rtti["TGridPanelColumns"],"FColumnCollection","SetColumnCollection");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ExpandStyle",0,$mod.$rtti["TGridPanelExpandStyle"],"FExpandStyle","FExpandStyle",4,{Default: $mod.TGridPanelExpandStyle.esAddRows});
    $r.addProperty("GridLineWidth",0,rtl.longint,"FGridLineWidth","FGridLineWidth",4,{Default: 0});
    $r.addProperty("GridLineColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FGridLineColor","FGridLineColor",4,{Default: 0});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("RowCollection",2,$mod.$rtti["TGridPanelRows"],"FRowCollection","SetRowCollection");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebGridPanel",this.TGridPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TMultiMediaType = {"0": "mtVideo", mtVideo: 0, "1": "mtAudio", mtAudio: 1};
  this.$rtti.$Enum("TMultiMediaType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TMultiMediaType});
  this.TMultiMediaControl = {"0": "mcFullscreen", mcFullscreen: 0, "1": "mcDownload", mcDownload: 1, "2": "mcRemoteplayback", mcRemoteplayback: 2, "3": "mcPlaybackrate", mcPlaybackrate: 3, "4": "mcPictureInPicture", mcPictureInPicture: 4};
  this.$rtti.$Enum("TMultiMediaControl",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMultiMediaControl});
  this.$rtti.$Set("TMultiMediaControls",{comptype: this.$rtti["TMultiMediaControl"]});
  this.$rtti.$Int("TMultiMediaVolume",{minvalue: 0, maxvalue: 100, ordtype: 1});
  this.TMultiMediaPreload = {"0": "mpAuto", mpAuto: 0, "1": "mpNone", mpNone: 1, "2": "mpMetadata", mpMetadata: 2};
  this.$rtti.$Enum("TMultiMediaPreload",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMultiMediaPreload});
  rtl.createClass(this,"TMultimediaPlayer",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FURL = "";
      this.FMultimediaType = 0;
      this.FAutoPlay = false;
      this.FControls$1 = false;
      this.FMuted = false;
      this.FLoop = false;
      this.FVolume = 0;
      this.FPlaybackRate = 0.0;
      this.FContextMenu = false;
      this.FPoster = "";
      this.FHideControls = {};
      this.FPreload = 0;
    };
    this.$final = function () {
      this.FHideControls = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetAutoPlay = function (Value) {
      if (this.FAutoPlay !== Value) {
        this.FAutoPlay = Value;
        this.UpdateElement();
      };
    };
    this.SetControls = function (Value) {
      if (this.FControls$1 !== Value) {
        this.FControls$1 = Value;
        this.UpdateElement();
      };
    };
    this.SetMuted = function (Value) {
      var el = null;
      if (this.FMuted !== Value) {
        this.FMuted = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.muted = Value;
        };
      };
    };
    this.SetLoop = function (Value) {
      var el = null;
      if (this.FLoop !== Value) {
        this.FLoop = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.loop = Value;
        };
      };
    };
    this.SetURL = function (Value) {
      if (this.FURL !== Value) {
        this.FURL = Value;
        this.UpdateElement();
      };
    };
    this.SetVolume = function (Value) {
      var el = null;
      if ((this.FVolume !== Value) && (Value >= 0) && (Value <= 100)) {
        this.FVolume = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.volume = Value/100;
        };
      };
    };
    this.GetCurrentTime = function () {
      var Result = 0.0;
      var el = null;
      var i = 0.0;
      el = this.GetElementHandle();
      if (el != null) {
        i = el.currentTime;
      };
      Result = i;
      return Result;
    };
    this.SetCurrentTime = function (Value) {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) el.currentTime = Value;
    };
    this.GetDuration = function () {
      var Result = 0.0;
      var el = null;
      var i = 0.0;
      el = this.GetElementHandle();
      if (el != null) {
        i = el.duration;
      };
      Result = i;
      return Result;
    };
    this.GetEnded = function () {
      var Result = false;
      var el = null;
      var e = false;
      el = this.GetElementHandle();
      if (el != null) {
        e = el.ended;
      };
      Result = e;
      return Result;
    };
    this.GetPaused = function () {
      var Result = false;
      var el = null;
      var e = false;
      el = this.GetElementHandle();
      if (el != null) {
        e = el.paused;
      };
      Result = e;
      return Result;
    };
    this.SetPlaybackRate = function (Value) {
      if (this.FPlaybackRate !== Value) {
        this.FPlaybackRate = Value;
        this.UpdateElement();
      };
    };
    this.SetContextMenu = function (Value) {
      if (this.FContextMenu !== Value) {
        this.FContextMenu = Value;
        this.UpdateElement();
      };
    };
    this.SetPoster = function (Value) {
      var el = null;
      if (this.FPoster !== Value) {
        this.FPoster = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.poster = Value;
        };
      };
    };
    this.SetHideControls = function (Value) {
      if (rtl.neSet(this.FHideControls,Value)) {
        this.FHideControls = rtl.refSet(Value);
        this.UpdateElement();
      };
    };
    this.SetPreload = function (Value) {
      var s = "";
      var el = null;
      if (this.FPreload !== Value) {
        this.FPreload = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          var $tmp = Value;
          if ($tmp === $mod.TMultiMediaPreload.mpNone) {
            s = "none"}
           else if ($tmp === $mod.TMultiMediaPreload.mpAuto) {
            s = "auto"}
           else if ($tmp === $mod.TMultiMediaPreload.mpMetadata) s = "metadata";
          el.preload = s;
        };
      };
    };
    this.CreateElement = function () {
      var Result = null;
      var el = null;
      var src = null;
      var p = "";
      if (this.FMultimediaType === $mod.TMultiMediaType.mtVideo) {
        el = document.createElement("VIDEO")}
       else el = document.createElement("AUDIO");
      src = document.createElement("SOURCE");
      var $tmp = this.FPreload;
      if ($tmp === $mod.TMultiMediaPreload.mpNone) {
        p = "none"}
       else if ($tmp === $mod.TMultiMediaPreload.mpAuto) {
        p = "auto"}
       else if ($tmp === $mod.TMultiMediaPreload.mpMetadata) p = "metadata";
      el.defaultPlaybackRate = this.FPlaybackRate;
      el.preload = p;
      el.appendChild(src);
      Result = el;
      return Result;
    };
    this.UpdateElement = function () {
      var $Self = this;
      var el = null;
      var vid = null;
      var nocontrols = "";
      function booltoattr(b) {
        var Result = "";
        if (b) {
          Result = "true"}
         else Result = "false";
        return Result;
      };
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        vid = this.GetElementHandle();
        vid.controls = this.FControls;
        vid.defaultPlaybackRate = this.FPlaybackRate;
        vid.playbackRate = this.FPlaybackRate;
        vid.muted = this.FMuted;
        if (this.FControls$1) {
          this.GetElementHandle().setAttribute("controls","")}
         else this.GetElementHandle().removeAttribute("controls");
        if (this.FAutoPlay) {
          this.GetElementHandle().setAttribute("autoplay",booltoattr(this.FAutoPlay))}
         else this.GetElementHandle().removeAttribute("autoplay");
        if (this.FMuted) {
          this.GetElementHandle().setAttribute("muted",booltoattr(this.FMuted))}
         else this.GetElementHandle().removeAttribute("muted");
        if (!this.FContextMenu) {
          this.GetElementHandle().setAttribute("oncontextmenu","return false;")}
         else this.GetElementHandle().removeAttribute("oncontextmenu");
        this.GetElementHandle().setAttribute("volume",pas["WEBLib.Utils"].FormatProp("%.2f",pas.System.VarRecs(3,this.FVolume / 100)));
        this.GetElementHandle().setAttribute("src",this.FURL);
        nocontrols = "";
        if ($mod.TMultiMediaControl.mcFullscreen in this.FHideControls) nocontrols = "nofullscreen ";
        if ($mod.TMultiMediaControl.mcDownload in this.FHideControls) nocontrols = nocontrols + "nodownload ";
        if ($mod.TMultiMediaControl.mcRemoteplayback in this.FHideControls) nocontrols = nocontrols + "noremoteplayback ";
        if ($mod.TMultiMediaControl.mcPlaybackrate in this.FHideControls) nocontrols = nocontrols + "noplaybackrate ";
        if (nocontrols !== "") {
          this.GetElementHandle().setAttribute("controlsList",nocontrols)}
         else if (this.GetElementHandle().hasAttribute("controlsList")) this.GetElementHandle().removeAttribute("controlsList");
        if ($mod.TMultiMediaControl.mcPictureInPicture in this.FHideControls) {
          this.GetElementHandle().setAttribute("disablePictureInPicture","")}
         else if (this.GetElementHandle().hasAttribute("disablePictureInPicture")) this.GetElementHandle().removeAttribute("disablePictureInPicture");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FVolume = 100;
      this.FPlaybackRate = 1;
      this.FMuted = false;
      this.FAutoPlay = false;
      this.FContextMenu = true;
      this.FPreload = $mod.TMultiMediaPreload.mpAuto;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Play = function () {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) el.play();
    };
    this.Pause = function () {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) {
        el.pause();
      };
    };
    this.ReLoad = function () {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) el.load();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("AutoPlay",2,rtl.boolean,"FAutoPlay","SetAutoPlay");
    $r.addProperty("Controls",2,rtl.boolean,"FControls$1","SetControls");
    $r.addProperty("ContextMenu",2,rtl.boolean,"FContextMenu","SetContextMenu",4,{Default: true});
    $r.addProperty("HideControls",2,$mod.$rtti["TMultiMediaControls"],"FHideControls","SetHideControls");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Loop",2,rtl.boolean,"FLoop","SetLoop");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MultimediaType",0,$mod.$rtti["TMultiMediaType"],"FMultimediaType","FMultimediaType");
    $r.addProperty("Muted",2,rtl.boolean,"FMuted","SetMuted");
    $r.addProperty("PlaybackRate",2,rtl.double,"FPlaybackRate","SetPlaybackRate");
    $r.addProperty("Poster",2,rtl.string,"FPoster","SetPoster");
    $r.addProperty("Preload",2,$mod.$rtti["TMultiMediaPreload"],"FPreload","SetPreload");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("Volume",2,$mod.$rtti["TMultiMediaVolume"],"FVolume","SetVolume");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
  });
  rtl.createClass(this,"TWebMultiMediaPlayer",this.TMultimediaPlayer,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"THTMLContainer",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FHTML = null;
      this.FScrollStyle = 0;
      this.FURL = "";
      this.FOnLoaded = null;
    };
    this.$final = function () {
      this.FHTML = undefined;
      this.FOnLoaded = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetHTML = function (Value) {
      this.FHTML.Assign(Value);
    };
    this.SetURL = function (Value) {
      this.FURL = Value;
      this.LoadFromURL(this.FURL);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      var TextFound = false;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (!this.IsUpdating() && (this.GetElementHandle() != null) && (this.GetContainer() != null)) {
        if (this.FElementClassName !== "") {
          this.GetElementHandle().style.removeProperty("border");
          this.GetElementHandle().style.removeProperty("background-color");
        } else this.GetElementHandle().style.setProperty("white-space","normal");
        if (this.FHTML != null) {
          TextFound = this.FHTML.GetTextStr() !== "";
          this.GetContainer().innerHTML = this.FHTML.GetTextStr();
        };
        if (!this.GetIsLinked() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.RenderDesigning(this.$classname,this.GetContainer(),this,!TextFound,"");
        if (!this.GetIsLinked()) {
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle(),this.FFont,this.FElementFont === pas["WEBLib.Controls"].TElementFont.efCSS);
        };
        var $tmp = this.FScrollStyle;
        if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssBoth) {
          this.GetElementHandle().style.setProperty("overflow","auto")}
         else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssNone) {
          this.GetElementHandle().style.setProperty("overflow","")}
         else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssVertical) {
          this.GetElementHandle().style.setProperty("overflow-y","auto")}
         else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssHorizontal) this.GetElementHandle().style.setProperty("overflow-x","auto");
      };
    };
    this.HTMLChanged = function (Sender) {
      this.UpdateElement();
    };
    this.DoLoaded = function () {
      if (this.FOnLoaded != null) this.FOnLoaded(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FHTML = pas.Classes.TStringList.$create("Create$1");
      this.FHTML.SetSkipLastLineBreak(true);
      this.FHTML.FOnChange = rtl.createCallback(this,"HTMLChanged");
      this.FScrollStyle = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(240);
        this.SetHeight(160);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FHTML");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.LoadFromURL = function (AURL) {
      var $Self = this;
      var Result = null;
      var wr = null;
      Result = new Promise(function (ASuccess, AFailed) {
        wr = pas["WEBLib.REST"].TWebHTTPRequest.$create("Create$1",[$Self]);
        wr.FURL = AURL;
        wr.Execute$1(function (AResponse, ARequest) {
          $Self.FHTML.SetTextStr(AResponse);
          $Self.DoLoaded();
          ASuccess(true);
        },function (ARequest) {
          AFailed(false);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("HTML",2,pas.Classes.$rtti["TStringList"],"FHTML","SetHTML");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ScrollStyle",0,pas["WEBLib.Controls"].$rtti["TScrollStyle"],"FScrollStyle","FScrollStyle");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnLoaded",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnLoaded","FOnLoaded");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebHTMLContainer",this.THTMLContainer,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"THTMLForm",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FOnSubmit = null;
      this.FAction = "";
    };
    this.$final = function () {
      this.FOnSubmit = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetAction = function (Value) {
      var el = null;
      this.FAction = Value;
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
        if (this.GetIsLinked()) {
          el = this.GetElementHandle()}
         else el = this.GetChildContainer();
        if (el != null) el.setAttribute("action",this.FAction);
      };
    };
    this.UpdateElement = function () {
      if (!(this.GetElementHandle() != null)) return;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.GetElementHandle().style.setProperty("background","repeating-linear-gradient(45deg,#EEEEEE 10px,#EEEEEE 10px, #ffffff 20px)");
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      Result.appendChild(document.createElement("FORM"));
      return Result;
    };
    this.DoHandleSubmit = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      if (this.FOnSubmit != null) this.FOnSubmit(this);
      Result = true;
      return Result;
    };
    this.GetChildContainer = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = this.GetElementHandle()}
       else {
        if (this.GetIsLinked()) {
          Result = this.GetElementHandle()}
         else Result = this.GetElementHandle().firstChild;
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.GetChildContainer().addEventListener("submit",rtl.createSafeCallback(this,"DoHandleSubmit"));
    };
    this.CheckValidity = function () {
      var Result = false;
      var el = null;
      var res = false;
      el = this.GetElementHandle();
      res = el.checkValidity();
      Result = res;
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Action",2,rtl.string,"FAction","SetAction");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnSubmit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSubmit","FOnSubmit");
  });
  rtl.createClass(this,"TWebHTMLForm",this.THTMLForm,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TBadge",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FTextColor = 0;
      this.FText = "";
    };
    this.SetTextColor = function (Value) {
      this.FTextColor = Value;
      this.UpdateElement();
    };
    this.SetText = function (Value) {
      this.FText = Value;
      this.UpdateElement();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().innerHTML = this.FText;
        if (this.FElementClassName === "") {
          this.GetElementHandle().setAttribute("class","tmsbadge");
          this.GetElementHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FTextColor));
        } else {
          this.GetElementHandle().style.removeProperty("color");
        };
        this.GetElementHandle().style.removeProperty("width");
        this.GetElementHandle().style.removeProperty("height");
      };
    };
    this.SetElementClassName = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetElementClassName.apply(this,arguments);
      this.UpdateElement();
    };
    this.CreateInitialize = function () {
      var css = "";
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(255);
      this.FTextColor = 16777215;
      this.FText = "1";
      css = "span.tmsbadge {" + "  background: #FF0000;" + "  border-radius: 0.8em;" + "  -moz-border-radius: 0.8em;" + "  -webkit-border-radius: 0.8em;" + "  color: #ffffff;" + "  display: inline-block;" + "  line-height: 1.6em;" + "  margin-right: 5px;" + "  text-align: center;" + "  width: 1.6em;" + "}";
      this.AddControlStyle(css);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(20);
        this.SetHeight(20);
      };
    };
    this.Destroy = function () {
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 255});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
  });
  rtl.createClass(this,"TWebBadge",this.TBadge,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TAccordionSection",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCaption = "";
      this.FContent = "";
      this.FTag = 0;
      this.FExpanded = false;
      this.FControl = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetExpanded = function (Value) {
      if (this.FExpanded !== Value) {
        this.FExpanded = Value;
        if (this.FExpanded) {
          rtl.as(rtl.as(this.FCollection,$mod.TAccordionSections).Owner(),$mod.TAccordion).Expand(this)}
         else rtl.as(rtl.as(this.FCollection,$mod.TAccordionSections).Owner(),$mod.TAccordion).Collapse(this);
      };
    };
    this.SetCaption = function (Value) {
      this.FCaption = Value;
      rtl.as(this.FCollection,$mod.TAccordionSections).Update(this);
    };
    this.SetContent = function (Value) {
      this.FContent = Value;
      rtl.as(this.FCollection,$mod.TAccordionSections).Update(this);
    };
    this.Assign = function (Source) {
      if ($mod.TAccordionSection.isPrototypeOf(Source)) {
        this.FCaption = rtl.as(Source,$mod.TAccordionSection).FCaption;
        this.FContent = rtl.as(Source,$mod.TAccordionSection).FContent;
        this.FTag = rtl.as(Source,$mod.TAccordionSection).FTag;
      };
    };
    this.CaptionElement = function () {
      var Result = null;
      Result = document.getElementById(rtl.as(rtl.as(this.FCollection,$mod.TAccordionSections).Owner(),$mod.TAccordion).FName + "_" + pas.SysUtils.IntToStr(this.GetIndex()));
      return Result;
    };
    this.PanelElement = function () {
      var Result = null;
      var el = null;
      el = this.CaptionElement();
      Result = el.nextElementSibling;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Content",2,rtl.string,"FContent","SetContent");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag");
  });
  rtl.createClass(this,"TAccordionSections",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if ((this.FOnChange != null) && (this.FUpdateCount === 0)) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TAccordionSection);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$MethodVar("TAccordionSectionEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASection",this.$rtti["TAccordionSection"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TAccordionSectionAllowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASection",this.$rtti["TAccordionSection"]],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TAccordionSectionRenderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASection",this.$rtti["TAccordionSection"]],["ACaption",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]],["APanel",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]]]), methodkind: 0});
  rtl.createClass(this,"TAccordion",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FStyleRendered = false;
      this.FSections = null;
      this.FOnCollapsing = null;
      this.FOnExpanding = null;
      this.FOnCollapsed = null;
      this.FOnExpanded = null;
      this.FOnRenderSection = null;
      this.FElementSectionClassName = "";
      this.FElementContentClassName = "";
    };
    this.$final = function () {
      this.FSections = undefined;
      this.FOnCollapsing = undefined;
      this.FOnExpanding = undefined;
      this.FOnCollapsed = undefined;
      this.FOnExpanded = undefined;
      this.FOnRenderSection = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetSections = function (Value) {
      this.FSections.Assign(Value);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.RenderAccordion = function () {
      var i = 0;
      var sp = null;
      var btn = null;
      var divel = null;
      var p = null;
      var LCaptionElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      var LPanelElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      if (this.GetElementHandle().childNodes.length > 0) {
        while (this.GetElementHandle().firstChild != null) this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
        if (this.FElementClassName !== "") {
          this.GetElementHandle().style.removeProperty("border");
          this.GetElementHandle().style.removeProperty("background-color");
        };
      };
      sp = document.createElement("SPAN");
      this.GetElementHandle().appendChild(sp);
      for (var $l = 0, $end = this.FSections.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        btn = document.createElement("BUTTON");
        btn.innerHTML = this.FSections.GetItem$1(i).FCaption;
        btn.setAttribute("id",this.FName + "_" + pas.SysUtils.IntToStr(i));
        btn.setAttribute("class","accordion_" + this.FName);
        if (this.FElementSectionClassName !== "") btn.classList.add(this.FElementSectionClassName);
        btn.addEventListener("click",rtl.createSafeCallback(this,"DoAccordionClick"));
        divel = document.createElement("DIV");
        divel.setAttribute("class","accordionpanel_" + this.FName);
        p = document.createElement("P");
        p.style.setProperty("user-select","text");
        if (this.FElementContentClassName !== "") p.setAttribute("class",this.FElementContentClassName);
        p.innerHTML = this.FSections.GetItem$1(i).FContent;
        sp.appendChild(btn);
        sp.appendChild(divel);
        divel.appendChild(p);
        if (this.FOnRenderSection != null) {
          LCaptionElementRec.element = btn;
          LPanelElementRec.element = p;
          this.FOnRenderSection(this,this.FSections.GetItem$1(i),pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LCaptionElementRec),pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LPanelElementRec));
        };
      };
      if (!this.GetIsLinked() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.RenderDesigning(this.$classname,this.GetContainer(),this,this.FSections.GetCount() === 0,"");
    };
    this.RenderStyle = function () {
      var css = "";
      if (this.FStyleRendered) return;
      this.FStyleRendered = true;
      css = ".accordion_" + this.FName + " {" + "background-color: #eee;" + "color: #444;" + "cursor: pointer;" + "padding: 18px;" + "width: 100%;" + "text-align: left;" + "border: none;" + "outline: none;" + "transition: 0.4s;" + "}" + "\r\n" + ".accordionactive_" + this.FName + ", .accordion_" + this.FName + "::hover {" + "background-color: #ccc;" + "}" + "\r\n" + ".accordionactive_" + this.FName + "::before {" + "transform: rotate(90deg);" + "}" + "\r\n" + ".accordion_" + this.FName + "::before {" + '  content: "\\25B6";' + "  font-size: 13px;" + "  display: inline-block;" + "  margin-right: 5px;" + "}" + "\r\n" + ".accordionpanel_" + this.FName + " {" + "padding: 0 18px;" + "max-height: 0;" + "overflow: hidden;" + "transition: max-height 0.2s ease-out;" + "}";
      this.AddInstanceStyle(css);
    };
    this.SectionsChanged = function (Sender) {
      if (!this.IsUpdating()) {
        this.RenderStyle();
        this.RenderAccordion();
      };
    };
    this.DoAccordionClick = function (Event) {
      var Result = false;
      var el = null;
      var pnl = null;
      var s = "";
      var Allow = false;
      var ASection = null;
      var i = 0;
      var e = 0;
      el = Event.srcElement;
      Allow = true;
      ASection = null;
      if (el.hasAttribute("id")) {
        s = el.getAttribute("id");
        s = pas.System.Copy(s,pas.System.Pos(this.FName,s) + this.FName.length + 1,s.length);
        pas.System.val$6(s,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }},{get: function () {
            return e;
          }, set: function (v) {
            e = v;
          }});
        if ((e === 0) && (i < this.FSections.GetCount())) ASection = this.FSections.GetItem$1(i);
      };
      if (el.classList.contains("accordionactive_" + this.FName)) {
        if (this.FOnCollapsing != null) this.FOnCollapsing(this,ASection,{get: function () {
            return Allow;
          }, set: function (v) {
            Allow = v;
          }});
      } else {
        if (this.FOnExpanding != null) this.FOnExpanding(this,ASection,{get: function () {
            return Allow;
          }, set: function (v) {
            Allow = v;
          }});
      };
      if (!Allow) return Result;
      el.classList.toggle("accordionactive_" + this.FName);
      pnl = el.nextElementSibling;
      if (ASection.FControl != null) {
        ASection.FControl.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        pnl.appendChild(ASection.FControl.GetElementHandle());
        ASection.FControl.SetVisible(true);
      };
      s = pnl.style.getPropertyValue("max-height");
      if ((s !== "0px") && (s !== "")) {
        pnl.style.setProperty("max-height","0");
      } else {
        pnl.style.setProperty("max-height",pas.SysUtils.IntToStr(pnl.scrollHeight) + "px");
      };
      if (el.classList.contains("accordionactive_" + this.FName)) {
        ASection.FExpanded = true;
        if (this.FOnExpanded != null) this.FOnExpanded(this,ASection);
      } else {
        ASection.FExpanded = false;
        if (this.FOnCollapsed != null) this.FOnCollapsed(this,ASection);
      };
      Result = true;
      return Result;
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      this.GetElementHandle().style.setProperty("overflow-y","auto");
      this.GetElementHandle().style.setProperty("overflow-x","hidden");
    };
    this.Expand = function (ASection) {
      var el = null;
      var pnl = null;
      var LClass = "";
      el = ASection.CaptionElement();
      pnl = el.nextElementSibling;
      if (ASection.FControl != null) {
        ASection.FControl.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        pnl.appendChild(ASection.FControl.GetElementHandle());
        ASection.FControl.SetVisible(true);
      };
      LClass = "accordionactive_" + this.FName;
      if (!el.classList.contains(LClass)) el.classList.add(LClass);
      pnl.style.setProperty("max-height",pas.SysUtils.IntToStr(pnl.scrollHeight) + "px");
    };
    this.Collapse = function (ASection) {
      var el = null;
      var pnl = null;
      var LClass = "";
      el = ASection.CaptionElement();
      LClass = "accordionactive_" + this.FName;
      if (el.classList.contains(LClass)) el.classList.remove(LClass);
      pnl = el.nextElementSibling;
      pnl.style.setProperty("max-height","0");
    };
    this.SetElementClassName = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetElementClassName.apply(this,arguments);
      if (this.FElementClassName !== "") this.RenderAccordion();
    };
    this.Loaded = function () {
      var i = 0;
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      for (var $l = 0, $end = this.FSections.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FSections.GetItem$1(i).FControl != null) this.FSections.GetItem$1(i).FControl.SetVisible(false);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FSections = $mod.TAccordionSections.$create("Create$3",[this]);
      this.FSections.FOnChange = rtl.createCallback(this,"SectionsChanged");
      this.FSections.FPropName = "Sections";
      this.FStyleRendered = false;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FSections");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.RenderStyle();
      this.RenderAccordion();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("ElementSectionClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementSectionClassName","FElementSectionClassName");
    $r.addProperty("ElementContentClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementContentClassName","FElementContentClassName");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Sections",2,$mod.$rtti["TAccordionSections"],"FSections","SetSections");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnCollapsed",0,$mod.$rtti["TAccordionSectionEvent"],"FOnCollapsed","FOnCollapsed");
    $r.addProperty("OnCollapsing",0,$mod.$rtti["TAccordionSectionAllowEvent"],"FOnCollapsing","FOnCollapsing");
    $r.addProperty("OnExpanded",0,$mod.$rtti["TAccordionSectionEvent"],"FOnExpanded","FOnExpanded");
    $r.addProperty("OnExpanding",0,$mod.$rtti["TAccordionSectionAllowEvent"],"FOnExpanding","FOnExpanding");
    $r.addProperty("OnRenderSection",0,$mod.$rtti["TAccordionSectionRenderEvent"],"FOnRenderSection","FOnRenderSection");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebAccordion",this.TAccordion,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TGridStyle = {"0": "gTemplateColumns", gTemplateColumns: 0, "1": "gTemplateRows", gTemplateRows: 1};
  this.$rtti.$Enum("TGridStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TGridStyle});
  rtl.createClass(this,"TResponsiveLayoutItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FWidth = 0;
      this.FStyleType = 0;
      this.FStyle = "";
      this.FColumnGap = "";
      this.FRowGap = "";
      this.FTag = 0;
      this.FDescription = "";
      this.FMargins = null;
    };
    this.$final = function () {
      this.FMargins = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
      this.FCollection.Update(this);
    };
    this.SetColumnGap = function (Value) {
      if (this.FColumnGap !== Value) {
        this.FColumnGap = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetRowGap = function (Value) {
      if (this.FRowGap !== Value) {
        this.FRowGap = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetStyleType = function (Value) {
      if (this.FStyleType !== Value) {
        this.FStyleType = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetWidth = function (Value) {
      if (this.FWidth !== Value) {
        this.FWidth = Value;
        this.FCollection.Update(this);
      };
    };
    this.Create$1 = function (AOwner) {
      this.FMargins = pas["WEBLib.Controls"].TMargins.$create("Create$1");
      this.FMargins.SetLeft(0);
      this.FMargins.SetTop(0);
      this.FMargins.SetRight(0);
      this.FMargins.SetBottom(0);
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FMargins");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TResponsiveLayoutItem.isPrototypeOf(Source)) {
        this.FColumnGap = rtl.as(Source,$mod.TResponsiveLayoutItem).FColumnGap;
        this.FDescription = rtl.as(Source,$mod.TResponsiveLayoutItem).FDescription;
        this.FRowGap = rtl.as(Source,$mod.TResponsiveLayoutItem).FRowGap;
        this.FWidth = rtl.as(Source,$mod.TResponsiveLayoutItem).FWidth;
        this.FStyle = rtl.as(Source,$mod.TResponsiveLayoutItem).FStyle;
        this.FStyleType = rtl.as(Source,$mod.TResponsiveLayoutItem).FStyleType;
        this.FTag = rtl.as(Source,$mod.TResponsiveLayoutItem).FTag;
        this.FMargins.Assign(rtl.as(Source,$mod.TResponsiveLayoutItem).FMargins);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("ColumnGap",2,rtl.string,"FColumnGap","SetColumnGap");
    $r.addProperty("Description",0,rtl.string,"FDescription","FDescription");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("RowGap",2,rtl.string,"FRowGap","SetRowGap");
    $r.addProperty("StyleType",2,$mod.$rtti["TGridStyle"],"FStyleType","SetStyleType");
    $r.addProperty("Style",2,rtl.string,"FStyle","SetStyle");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag");
    $r.addProperty("Width",2,rtl.longint,"FWidth","SetWidth");
  });
  rtl.createClass(this,"TResponsiveLayout",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.GetLayoutForWidth = function (w) {
      var Result = null;
      var i = 0;
      var d = 0;
      var j = 0;
      var l = 0;
      var mx = 0;
      Result = null;
      if (this.GetCount() === 0) return Result;
      d = 0xFFFF;
      j = -1;
      mx = 0;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FWidth > mx) {
          mx = this.GetItem$1(i).FWidth;
          l = i;
        };
        if (w < this.GetItem$1(i).FWidth) {
          if ((this.GetItem$1(i).FWidth - w) < d) {
            d = this.GetItem$1(i).FWidth - w;
            j = i;
          };
        };
      };
      if (j === -1) j = l;
      Result = this.GetItem$1(j);
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TResponsiveLayoutItem);
      return this;
    };
    this.Add$1 = function (AWidth, AStyle) {
      var Result = null;
      Result = this.Add$2();
      Result.SetWidth(AWidth);
      Result.SetStyle(AStyle);
      return Result;
    };
    this.Add$2 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$MethodVar("TResponsiveLayoutChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ALayout",this.$rtti["TResponsiveLayoutItem"]]]), methodkind: 0});
  rtl.createClass(this,"TResponsiveGridPanel",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FLabel = null;
      this.FLayout = null;
      this.FActiveLayoutItem = null;
      this.FOldWidth = 0;
      this.FControlCollection = null;
      this.FOnLayoutChange = null;
      this.FResizePtr = null;
    };
    this.$final = function () {
      this.FLabel = undefined;
      this.FLayout = undefined;
      this.FActiveLayoutItem = undefined;
      this.FControlCollection = undefined;
      this.FOnLayoutChange = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetControlCollection = function (Value) {
      this.FControlCollection.Assign(Value);
    };
    this.HandleResize = function (Event) {
      var Result = false;
      var w = 0;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return Result;
      Result = true;
      w = this.GetWidth();
      if (this.FOldWidth !== w) {
        this.FOldWidth = w;
        this.Resize();
      };
      return Result;
    };
    this.SetResponsiveStyle = function () {
      var li = null;
      var w = 0;
      var lGap = "";
      if (!(this.FLayout != null)) return;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if (!(this.GetElementHandle() != null)) return;
      w = this.GetWidth();
      li = this.FLayout.GetLayoutForWidth(w);
      if (li != null) {
        if (li.FStyleType === $mod.TGridStyle.gTemplateColumns) {
          this.GetElementHandle().style.setProperty("grid-template-columns",li.FStyle);
          this.GetElementHandle().style.removeProperty("grid-template-rows");
        } else {
          this.GetElementHandle().style.removeProperty("grid-template-columns");
          this.GetElementHandle().style.setProperty("grid-template-rows",li.FStyle);
        };
        lGap = li.FRowGap;
        if (pas.SysUtils.TStringHelper.IsNumber.call({get: function () {
            return lGap;
          }, set: function (v) {
            lGap = v;
          }})) lGap = lGap + "px";
        this.GetElementHandle().style.setProperty("grid-row-gap",lGap);
        lGap = li.FColumnGap;
        if (pas.SysUtils.TStringHelper.IsNumber.call({get: function () {
            return lGap;
          }, set: function (v) {
            lGap = v;
          }})) lGap = lGap + "px";
        this.GetElementHandle().style.setProperty("grid-column-gap",lGap);
        this.GetElementHandle().style.setProperty("padding-left",pas.SysUtils.IntToStr(li.FMargins.FLeft) + "px");
        this.GetElementHandle().style.setProperty("padding-top",pas.SysUtils.IntToStr(li.FMargins.FTop) + "px");
        this.GetElementHandle().style.setProperty("padding-right",pas.SysUtils.IntToStr(li.FMargins.FRight) + "px");
        this.GetElementHandle().style.setProperty("padding-bottom",pas.SysUtils.IntToStr(li.FMargins.FBottom) + "px");
      };
      if (li !== this.FActiveLayoutItem) {
        this.FActiveLayoutItem = li;
        if (this.FOnLayoutChange != null) this.FOnLayoutChange(this,this.FActiveLayoutItem);
      };
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.FResizePtr = rtl.createCallback(this,"HandleResize");
      document.defaultView.addEventListener("resize",this.FResizePtr);
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.FResizePtr != null) {
        document.defaultView.removeEventListener("resize",this.FResizePtr);
        this.FResizePtr = null;
      };
    };
    this.UpdateControls = function () {
      var i = 0;
      var j = 0;
      var k = 0;
      var el = null;
      var sp = null;
      var fragment = null;
      var control = null;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if (this.IsUpdating()) return;
      if (!(this.GetElementHandle() != null)) return;
      if ((this.FControlCollection.GetCount() > 0) && (this.FLabel != null)) {
        this.GetElementHandle().removeChild(this.FLabel);
        this.FLabel = null;
        this.GetElementHandle().style.setProperty("display","grid");
      };
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        for (var $l = this.GetElementHandle().childElementCount - 1; $l >= 0; $l--) {
          i = $l;
          if (this.GetElementHandle().children.item(i).tagName === "SPAN") this.GetElementHandle().removeChild(this.GetElementHandle().children.item(i));
        };
        for (var $l1 = 0, $end = this.FLayout.GetCount() - 1; $l1 <= $end; $l1++) {
          i = $l1;
          sp = document.createElement("SPAN");
          sp.style.setProperty("position","absolute");
          sp.style.setProperty("width","4px");
          sp.style.setProperty("height","12px");
          sp.style.setProperty("background-color","red");
          sp.style.setProperty("top","0px");
          sp.style.setProperty("left",pas.SysUtils.IntToStr(this.FLayout.GetItem$1(i).FWidth) + "px");
          this.GetElementHandle().appendChild(sp);
        };
      };
      for (var $l2 = 0, $end1 = this.FControlCollection.GetCount() - 1; $l2 <= $end1; $l2++) {
        i = $l2;
        if (this.GridElementCount() <= i) {
          el = document.createElement("DIV");
          el.setAttribute("data","grid");
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) el.style.setProperty("border","1px silver dotted");
          this.GetElementHandle().appendChild(el);
        } else {
          k = 0;
          for (var $l3 = 0, $end2 = this.GetElementHandle().childElementCount - 1; $l3 <= $end2; $l3++) {
            j = $l3;
            el = this.GetElementHandle().children.item(j);
            if (el.getAttribute("data") === "grid") {
              if (k === i) {
                break}
               else k += 1;
            };
          };
        };
        fragment = document.createDocumentFragment();
        control = this.FControlCollection.GetItem$1(i).FControl;
        if (control != null) {
          control.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          control.SetChildOrderEx(-1);
          if (control.GetElementHandle() != null) {
            fragment.appendChild(control.GetElementHandle());
            el.appendChild(fragment);
          };
        };
      };
      this.UpdateElement();
    };
    this.CreateElement = function () {
      var Result = null;
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FControlCollection.GetCount() === 0)) {
        Result = document.createElement("DIV");
        this.FLabel = document.createElement("DIV");
        this.FLabel.innerHTML = this.$classname;
        this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
        this.FLabel.setAttribute("align","center");
        this.FLabel.style.setProperty("border","1px solid silver");
        this.FLabel.style.setProperty("vertical-align","middle");
        this.FLabel.style.setProperty("display","table-cell");
        Result.appendChild(this.FLabel);
      } else {
        Result = document.createElement("DIV");
      };
      return Result;
    };
    this.GridElementCount = function () {
      var Result = 0;
      var i = 0;
      var el = null;
      Result = 0;
      for (var $l = 0, $end = this.GetElementHandle().childElementCount - 1; $l <= $end; $l++) {
        i = $l;
        el = this.GetElementHandle().children.item(i);
        if (el.getAttribute("data") === "grid") Result += 1;
      };
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if (!(this.GetElementHandle() != null)) return;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        if (this.FControlCollection.GetCount() === 0) {
          this.GetElementHandle().style.setProperty("display","table");
          if (this.FColor === -1) this.GetElementHandle().style.setProperty("background-color","silver");
        };
      };
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.GetElementHandle().style.setProperty("border","1px silver dotted");
      };
      this.GetElementHandle().style.setProperty("display","grid");
      this.SetResponsiveStyle();
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateControls();
    };
    this.RegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.RegisterParent.apply(this,arguments);
      if (!this.IsUpdating() && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.FControlCollection.Add$1().FControl = AValue;
        this.UpdateControls();
      };
    };
    this.Notification = function (AComponent, Operation) {
      var i = 0;
      var upd = false;
      var el = null;
      upd = false;
      if ((Operation === pas.Classes.TOperation.opRemove) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FControlCollection.GetItem$1(i).FControl === AComponent) {
            el = this.GetElementHandle().children.item(i);
            while (el.childElementCount > 0) el.removeChild(el.firstChild);
            this.FControlCollection.GetItem$1(i).FControl = null;
            this.FControlCollection.Delete(i);
            upd = true;
          };
        };
      };
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if (upd) this.UpdateControls();
    };
    this.LayoutChanged = function (Sender) {
      if (this.IsUpdating() || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.UpdateControls();
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FResizePtr = null;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FControlCollection");
      rtl.free(this,"FLayout");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      var li = null;
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FControlCollection = $mod.TControlCollection.$create("Create$3",[this]);
      this.FControlCollection.FPropName = "ControlCollection";
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
      this.FLabel = null;
      this.FActiveLayoutItem = null;
      this.FLayout = $mod.TResponsiveLayout.$create("Create$3",[this]);
      this.FLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FLayout.FPropName = "Layout";
      if (this.FDesignTime$1) {
        li = this.FLayout.Add$2();
        li.FDescription = "Smartphone";
        li.SetWidth(575);
        li.SetStyle("1fr");
        li = this.FLayout.Add$2();
        li.FDescription = "Tablet";
        li.SetWidth(768);
        li.SetStyle("1fr 1fr");
        li = this.FLayout.Add$2();
        li.FDescription = "Desktop";
        li.SetWidth(991);
        li.SetStyle("1fr 1fr 1fr");
        li = this.FLayout.Add$2();
        li.FDescription = "Large Desktop";
        li.SetWidth(1199);
        li.SetStyle("1fr 1fr 1fr 1fr");
      };
    };
    this.AlignControls = function (AControl, Rect) {
      pas["WEBLib.Controls"].TControl.AlignControls.apply(this,arguments);
      this.Resize();
    };
    this.GetChildren = function (Proc, Root) {
      pas["WEBLib.Controls"].TControl.GetChildren.apply(this,arguments);
    };
    this.Resize = function () {
      pas["WEBLib.Controls"].TCustomControl.Resize.call(this);
      this.SetResponsiveStyle();
    };
    this.AddControl = function (AControl) {
      this.FControlCollection.Add$1().FControl = AControl;
      AControl.SetParent(this);
    };
    this.RemoveControl = function (AControl) {
      var i = 0;
      for (var $l = 0, $end = this.FControlCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControlCollection.GetItem$1(i).FControl === AControl) {
          if (AControl.GetElementHandle() != null) AControl.GetElementHandle().parentElement.removeChild(AControl.GetElementHandle());
          this.FControlCollection.Delete(i);
          break;
        };
      };
    };
    this.RemoveControls = function () {
      var i = 0;
      var AControl = null;
      for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        AControl = this.FControlCollection.GetItem$1(i).FControl;
        if ((AControl != null) && (AControl.GetElementHandle() != null)) AControl.GetElementHandle().parentElement.removeChild(AControl.GetElementHandle());
        this.FControlCollection.Delete(i);
      };
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.UpdateControls();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ControlCollection",2,$mod.$rtti["TControlCollection"],"FControlCollection","SetControlCollection");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",0,$mod.$rtti["TResponsiveLayout"],"FLayout","FLayout");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnLayoutChange",0,$mod.$rtti["TResponsiveLayoutChangeEvent"],"FOnLayoutChange","FOnLayoutChange");
  });
  rtl.createClass(this,"TWebResponsiveGridPanel",this.TResponsiveGridPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TLookupValueItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FValue = "";
      this.FDisplayText = "";
    };
    var $r = this.$rtti;
    $r.addProperty("Value",0,rtl.string,"FValue","FValue");
    $r.addProperty("DisplayText",0,rtl.string,"FDisplayText","FDisplayText");
  });
  rtl.createClass(this,"TLookupValues",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (Item === null) this.DoChange();
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TLookupValueItem);
      return this;
    };
    this.AddPair = function (AValue, ADisplayText) {
      var lv = null;
      lv = pas.Classes.TCollection.Add.call(this);
      lv.FValue = AValue;
      lv.FDisplayText = ADisplayText;
      if (this.FUpdateCount === 0) this.DoChange();
    };
    this.InsertPair = function (Index, AValue, ADisplayText) {
      var lv = null;
      lv = pas.Classes.TCollection.Insert.call(this,Index);
      lv.FValue = AValue;
      lv.FDisplayText = ADisplayText;
      if (this.FUpdateCount === 0) this.DoChange();
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  rtl.createClass(this,"TCustomLookupComboBox",pas["WEBLib.StdCtrls"].TCustomComboBox,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomComboBox.$init.call(this);
      this.FLookupValues = null;
    };
    this.$final = function () {
      this.FLookupValues = undefined;
      pas["WEBLib.StdCtrls"].TCustomComboBox.$final.call(this);
    };
    this.SetLookupValues = function (Value) {
      this.FLookupValues.Assign(Value);
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = "";
      if (this.GetItemIndex() >= 0) Result = this.FLookupValues.GetItem$1(this.GetItemIndex()).FDisplayText;
      return Result;
    };
    this.GetValue = function () {
      var Result = "";
      Result = "";
      if (this.GetItemIndex() >= 0) Result = this.FLookupValues.GetItem$1(this.GetItemIndex()).FValue;
      return Result;
    };
    this.SetDisplayText = function (Value) {
      var i = 0;
      var idx = 0;
      idx = -1;
      for (var $l = 0, $end = this.FLookupValues.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FLookupValues.GetItem$1(i).FDisplayText === Value) {
          idx = i;
          break;
        };
      };
      this.SetItemIndex(idx);
    };
    this.SetValue = function (Value) {
      var i = 0;
      var idx = 0;
      idx = -1;
      for (var $l = 0, $end = this.FLookupValues.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FLookupValues.GetItem$1(i).FValue === Value) {
          idx = i;
          break;
        };
      };
      this.SetItemIndex(idx);
    };
    this.ValuesChanged = function (Sender) {
      this.DoUpdateList();
    };
    this.DoUpdateList = function () {
      var i = 0;
      var opt = null;
      if (!(this.GetContainer() != null)) return;
      for (var $l = this.GetContainer().options.length - 1; $l >= 0; $l--) {
        i = $l;
        this.GetContainer().remove(i);
      };
      this.AddTextHint();
      for (var $l1 = 0, $end = this.FLookupValues.GetCount() - 1; $l1 <= $end; $l1++) {
        i = $l1;
        opt = document.createElement("OPTION");
        opt.setAttribute("value",this.FLookupValues.GetItem$1(i).FValue);
        opt.innerHTML = this.FLookupValues.GetItem$1(i).FDisplayText;
        this.GetContainer().appendChild(opt);
      };
      this.UpdateElement();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("custom-select");
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FLookupValues");
      pas["WEBLib.StdCtrls"].TCustomComboBox.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.StdCtrls"].TCustomComboBox.CreateInitialize.call(this);
      this.FLookupValues = $mod.TLookupValues.$create("Create$3",[this]);
      this.FLookupValues.FPropName = "LookupValues";
      this.FLookupValues.FOnChange = rtl.createCallback(this,"ValuesChanged");
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TLookupComboBox",this.TCustomLookupComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("LookupValues",2,$mod.$rtti["TLookupValues"],"FLookupValues","SetLookupValues");
  });
  rtl.createClass(this,"TWebLookupComboBox",this.TLookupComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomListBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FItemHeight = 0;
      this.FSorted = false;
      this.FOnChange = null;
      this.FHandleChangePtr = null;
      this.FElementItemClassName = "";
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetItemHeight = function (Value) {
      this.FItemHeight = Value;
    };
    this.SetSorted = function (Value) {
      this.FSorted = Value;
      this.FItems.Sort();
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FItems.GetCount();
      return Result;
    };
    this.GetItemElement = function (i) {
      var Result = null;
      Result = null;
      if ((this.GetContainer() != null) && (i < this.GetContainer().children.length)) Result = this.GetContainer().children.item(i);
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      if (Key.get() === 40) {
        this.SetItemIndex(this.GetItemIndex() + 1);
        Key.set(0);
      };
      if (Key.get() === 36) {
        this.SetItemIndex(0);
        Key.set(0);
      };
      if (Key.get() === 34) {
        this.SetItemIndex(this.GetItemIndex() + 4);
        Key.set(0);
      };
      if (Key.get() === 33) {
        this.SetItemIndex(this.GetItemIndex() - 4);
        Key.set(0);
      };
      if (Key.get() === 35) {
        this.SetItemIndex(this.FItems.GetCount() - 1);
        Key.set(0);
      };
      if (Key.get() === 38) {
        this.SetItemIndex(this.GetItemIndex() - 1);
        Key.set(0);
      };
    };
    this.DoUpdateList = function () {
      var i = 0;
      var opt = null;
      var chk = null;
      var txt = null;
      if (!(this.GetContainer() != null)) return;
      if (this.IsUpdating()) return;
      if (this.GetElementHandle().tagName !== "DIV") return;
      while (this.GetContainer().firstChild != null) this.GetContainer().removeChild(this.GetContainer().lastChild);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        opt = document.createElement("LABEL");
        chk = document.createElement("INPUT");
        chk.setAttribute("type","checkbox");
        chk.style.setProperty("vertical-align","middle");
        opt.style.setProperty("vertical-align","middle");
        opt.appendChild(chk);
        opt.style.setProperty("display","block");
        txt = document.createTextNode(this.FItems.Get(i));
        opt.appendChild(txt);
        if (this.FElementItemClassName !== "") opt.setAttribute("class",this.FElementItemClassName);
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) opt.setAttribute("draggable","true");
        this.GetContainer().appendChild(opt);
      };
      this.UpdateElementData();
    };
    this.PersistinHTML = function () {
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "DIV") return;
    };
    this.SetItemIndex = function (Value) {
      var el = null;
      el = this.GetItemElement(Value);
      if (el != null) el.firstChild.focus();
    };
    this.GetItemIndex = function () {
      var Result = 0;
      var i = 0;
      var el = null;
      Result = this.FItemIndex;
      if (this.GetContainer() != null) {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          el = this.GetItemElement(i);
          if (el != null) el = el.firstChild;
          if (el != null) {
            if (el === document.activeElement) {
              Result = i;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
      this.UpdateElement();
    };
    this.UpdateElementData = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("overflow","auto");
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("overflow","auto");
      };
    };
    this.UpdateParent = function () {
      pas["WEBLib.Controls"].TControl.UpdateParent.call(this);
      this.DoUpdateList();
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().addEventListener("change",this.FHandleChangePtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().removeEventListener("change",this.FHandleChangePtr);
      };
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.EnableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().options.item(I).setAttribute("draggable","true");
      };
    };
    this.DisableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().children.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().children.item(I).setAttribute("draggable","false");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.SetSkipLastLineBreak(true);
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FItemIndex = -1;
      this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
      this.FCustomBorder = true;
      this.SetShowFocus(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(160);
        this.SetHeight(180);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.AddItem = function (Item, AObject) {
      this.FItems.AddObject(Item,AObject);
    };
    this.SetFilter = function (AExpression, CaseSensitive) {
      var i = 0;
      var re = null;
      if (CaseSensitive) {
        re = new RegExp(AExpression)}
       else re = new RegExp(AExpression,"i");
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (!re.test(this.FItems.Get(i))) {
          this.GetItemElement(i).style.setProperty("display","none");
        } else this.GetItemElement(i).style.setProperty("display","block");
      };
    };
    this.RemoveFilter = function () {
      var i = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetItemElement(i).style.setProperty("display","block");
      };
    };
    this.Clear = function () {
      this.BeginUpdate();
      this.FItems.Clear();
      this.EndUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TImageListBox",this.TCustomListBox,function () {
    this.DoUpdateList = function () {
      var i = 0;
      var opt = null;
      var img = null;
      if (!(this.GetContainer() != null)) return;
      if (this.IsUpdating()) return;
      if (this.GetElementHandle().tagName !== "DIV") return;
      while (this.GetContainer().firstChild != null) this.GetContainer().removeChild(this.GetContainer().lastChild);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        opt = document.createElement("LABEL");
        img = document.createElement("IMG");
        img.setAttribute("src",this.FItems.Get(i));
        img.style.setProperty("display","inline-block");
        opt.appendChild(img);
        opt.style.setProperty("display","block");
        if (this.FElementItemClassName !== "") opt.setAttribute("class",this.FElementItemClassName);
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) opt.setAttribute("draggable","true");
        this.GetContainer().appendChild(opt);
      };
      this.UpdateElementData();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementItemClassName",0,rtl.string,"FElementItemClassName","FElementItemClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemHeight",2,rtl.longint,"FItemHeight","SetItemHeight");
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",4,{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebImageListBox",this.TImageListBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSearchEdit",pas["WEBLib.StdCtrls"].TCustomEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.$init.call(this);
      this.FSearchElement = null;
      this.FClearElement = null;
      this.FInputElement = null;
      this.FClearPtr = null;
      this.FSearchPtr = null;
      this.FOnSearchClick = null;
      this.FOnClearClick = null;
      this.FClearImageURL = "";
      this.FSearchImageURL = "";
    };
    this.$final = function () {
      this.FSearchElement = undefined;
      this.FClearElement = undefined;
      this.FInputElement = undefined;
      this.FOnSearchClick = undefined;
      this.FOnClearClick = undefined;
      pas["WEBLib.StdCtrls"].TCustomEdit.$final.call(this);
    };
    this.SetClearImageURL = function (Value) {
      this.FClearImageURL = Value;
    };
    this.SetSearchImageURL = function (Value) {
      this.FSearchImageURL = Value;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.StdCtrls"].TCustomInput.UpdateElementVisual.call(this);
      if (this.FSearchElement != null) {
        if (this.FSearchImageURL !== "") {
          this.FSearchElement.setAttribute("src",this.FSearchImageURL)}
         else this.FSearchElement.setAttribute("src",$impl.btnsearchres);
      };
      if (this.FClearElement != null) {
        if (this.FClearImageURL !== "") {
          this.FClearElement.setAttribute("src",this.FClearImageURL)}
         else this.FClearElement.setAttribute("src",$impl.btnclearres);
      };
    };
    this.CreateChildElements = function (AContainer) {
      var FTable = null;
      var FRow = null;
      var FCell = null;
      pas["WEBLib.Controls"].TControl.CreateChildElements.apply(this,arguments);
      this.FSearchElement = document.createElement("IMG");
      this.FClearElement = document.createElement("IMG");
      this.FInputElement = document.createElement("INPUT");
      FTable = document.createElement("TABLE");
      FTable.style.setProperty("height","100%");
      FRow = document.createElement("TR");
      AContainer.appendChild(FTable);
      FTable.appendChild(FRow);
      FCell = document.createElement("TD");
      FRow.appendChild(FCell);
      FCell.appendChild(this.FSearchElement);
      FCell = document.createElement("TD");
      FRow.appendChild(FCell);
      FCell.appendChild(this.FInputElement);
      FCell = document.createElement("TD");
      FRow.appendChild(FCell);
      FCell.appendChild(this.FClearElement);
      this.FSearchElement.setAttribute("src",$impl.btnsearchres);
      this.FClearElement.setAttribute("src",$impl.btnclearres);
    };
    this.BindEvents = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.BindEvents.call(this);
      if (this.FClearElement != null) this.FClearElement.addEventListener("click",this.FClearPtr);
      if (this.FSearchElement != null) this.FSearchElement.addEventListener("click",this.FSearchPtr);
    };
    this.HandleDoClear = function (Event) {
      var Result = false;
      if (this.FOnClearClick != null) this.FOnClearClick(this);
      this.FInputElement.value = '';
      this.FInputElement.focus();
      Result = true;
      return Result;
    };
    this.HandleDoSearch = function (Event) {
      var Result = false;
      if (this.FOnSearchClick != null) this.FOnSearchClick(this);
      Result = true;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement()) && !this.IsUpdating()) {
        if ((this.FElementClassName === "") && (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle)) {
          this.GetElementHandle().style.setProperty("border","1px solid gray");
          this.GetElementHandle().style.setProperty("border-radius","4px");
        };
        this.FInputElement.style.setProperty("border","none");
        this.FInputElement.style.setProperty("outline","none");
        this.FInputElement.parentElement.style.setProperty("vertical-align","middle");
        this.FInputElement.parentElement.style.setProperty("width","100%");
        this.FSearchElement.parentElement.style.setProperty("vertical-align","middle");
        this.FClearElement.parentElement.style.setProperty("vertical-align","middle");
        if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
          this.FInputElement.style.setProperty("width","100%")}
         else this.FInputElement.style.removeProperty("width");
      };
    };
    this.SetEnabled = function (Value) {
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      if (this.GetElementInputHandle() != null) {
        if (Value) {
          this.GetElementInputHandle().removeAttribute("disabled")}
         else this.GetElementInputHandle().setAttribute("disabled","");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.ClearMethodPointers.call(this);
      this.FClearPtr = null;
      this.FSearchPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.GetMethodPointers.call(this);
      if (this.FClearPtr === null) this.FClearPtr = rtl.createCallback(this,"HandleDoClear");
      if (this.FSearchPtr === null) this.FSearchPtr = rtl.createCallback(this,"HandleDoSearch");
    };
    this.SetFocus = function () {
      var eh = null;
      if (this.GetElementInputHandle() != null) {
        eh = this.GetElementInputHandle();
        eh.focus();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",4,{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",4,{Default: true});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",4,{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",4,{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",4,{Default: 0});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",4,{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addMethod("SetFocus",0,[],4);
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnClearClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClearClick","FOnClearClick");
    $r.addProperty("OnSearchClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSearchClick","FOnSearchClick");
  });
  rtl.createClass(this,"TWebSearchEdit",this.TSearchEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",4,{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",4,{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",4,{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",4,{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("ClearImageURL",2,rtl.string,"FClearImageURL","SetClearImageURL");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,pas["WEBLib.StdCtrls"].$rtti["TEditType"],"FEditType","SetEditType",4,{Default: pas["WEBLib.StdCtrls"].TEditType.weString});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",4,{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",4,{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("SearchImageURL",2,rtl.string,"FSearchImageURL","SetSearchImageURL");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnClearClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClearClick","FOnClearClick");
    $r.addProperty("OnSearchClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSearchClick","FOnSearchClick");
  });
  rtl.createClass(this,"TEditButton",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMaterialGlyph = "";
      this.FWidth = 0;
      this.FMaterialGlyphColor = 0;
      this.FCaption = "";
      this.FMaterialGlyphType = 0;
      this.FMaterialGlyphSize = 0;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetMaterialGlyph = function (Value) {
      this.FMaterialGlyph = Value;
      this.Changed();
    };
    this.SetMaterialGlyphSize = function (Value) {
      this.FMaterialGlyphSize = Value;
      this.Changed();
    };
    this.SetMaterialGlyphType = function (Value) {
      this.FMaterialGlyphType = Value;
      this.Changed();
    };
    this.SetMaterialGyphColor = function (Value) {
      this.FMaterialGlyphColor = Value;
      this.Changed();
    };
    this.SetCaption = function (Value) {
      this.FCaption = Value;
      this.Changed();
    };
    this.SetWidth = function (Value) {
      this.FWidth = Value;
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FWidth = 24;
      this.FCaption = "";
      this.FMaterialGlyphColor = -1;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TEditButton.isPrototypeOf(Source)) {
        this.FWidth = rtl.as(Source,$mod.TEditButton).FWidth;
        this.FMaterialGlyph = rtl.as(Source,$mod.TEditButton).FMaterialGlyph;
        this.FMaterialGlyphSize = rtl.as(Source,$mod.TEditButton).FMaterialGlyphSize;
        this.FMaterialGlyphColor = rtl.as(Source,$mod.TEditButton).FMaterialGlyphColor;
        this.FCaption = rtl.as(Source,$mod.TEditButton).FCaption;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",4,{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",4,{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",4,{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("Width",2,rtl.longint,"FWidth","SetWidth",4,{Default: 24});
  });
  rtl.createClass(this,"TEditBtn",pas["WEBLib.StdCtrls"].TCustomEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.$init.call(this);
      this.FBtnElement = null;
      this.FInputElement = null;
      this.FBtnClickPtr = null;
      this.FOnBtnClick = null;
      this.FButton = null;
      this.FElementInputClassName = "";
      this.FElementButtonClassName = "";
    };
    this.$final = function () {
      this.FBtnElement = undefined;
      this.FInputElement = undefined;
      this.FOnBtnClick = undefined;
      this.FButton = undefined;
      pas["WEBLib.StdCtrls"].TCustomEdit.$final.call(this);
    };
    this.SetButton = function (Value) {
      this.FButton.Assign(Value);
    };
    this.SetElementInputClassName = function (Value) {
      if (this.FElementInputClassName !== Value) {
        this.FElementInputClassName = Value;
        this.UpdateElement();
      };
    };
    this.SetElementButtonClassName = function (Value) {
      if (this.FElementButtonClassName !== Value) {
        this.FElementButtonClassName = Value;
        this.UpdateElement();
      };
    };
    this.HandleDoBtnClick = function (Event) {
      var Result = false;
      if (this.FOnBtnClick != null) this.FOnBtnClick(this);
      Result = true;
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      var FTable = null;
      var FRow = null;
      var FCell1 = null;
      var FCell2 = null;
      Result = document.createElement("DIV");
      this.FBtnElement = document.createElement("BUTTON");
      this.FInputElement = document.createElement("INPUT");
      FTable = document.createElement("TABLE");
      FRow = document.createElement("TR");
      Result.appendChild(FTable);
      FTable.appendChild(FRow);
      FCell1 = document.createElement("TD");
      FRow.appendChild(FCell1);
      FCell1.appendChild(this.FInputElement);
      FCell2 = document.createElement("TD");
      FRow.appendChild(FCell2);
      FCell2.appendChild(this.FBtnElement);
      this.FBtnElement.innerHTML = "&nbsp;";
      FTable.style.setProperty("border","none");
      FTable.style.setProperty("border-collapse","collapse");
      FTable.style.setProperty("height","100%");
      return Result;
    };
    this.UpdateElement = function () {
      var h = 0;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement()) && !this.IsUpdating()) {
        this.FInputElement.style.setProperty("outline","none");
        this.FInputElement.style.setProperty("box-sizing","unset");
        if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
          this.FInputElement.style.setProperty("width","100%")}
         else this.FInputElement.style.removeProperty("width");
        h = this.GetHeight() - 6 - 4;
        this.FInputElement.style.setProperty("height",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return h;
          }, set: function (v) {
            h = v;
          }}) + "px");
        if (this.FElementInputClassName !== "") {
          this.FInputElement.setAttribute("class",this.FElementInputClassName)}
         else this.FInputElement.removeAttribute("class");
        if (this.FElementButtonClassName !== "") {
          this.FBtnElement.setAttribute("class",this.FElementButtonClassName)}
         else this.FBtnElement.removeAttribute("class");
        h = this.GetHeight() - 4;
        this.FBtnElement.style.setProperty("width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this.FButton, get: function () {
            return this.p.FWidth;
          }, set: function (v) {
            this.p.FWidth = v;
          }}) + "px");
        this.FBtnElement.style.setProperty("padding","0");
        this.FBtnElement.style.setProperty("height",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return h;
          }, set: function (v) {
            h = v;
          }}) + "px");
        pas["WEBLib.Controls"].SetHTMLElementFont(this.FInputElement,this.FFont,this.FElementFont === pas["WEBLib.Controls"].TElementFont.efCSS);
        if (this.FButton.FCaption !== "") this.FBtnElement.innerHTML = this.FButton.FCaption;
        if (this.FButton.FMaterialGlyph !== "") {
          this.FBtnElement.innerHTML = pas["WEBLib.WebTools"].GetMaterialGlyph(this.FButton.FMaterialGlyph,this.FButton.FMaterialGlyphSize,this.FButton.FMaterialGlyphColor,this.FButton.FMaterialGlyphType);
        };
        this.GetElementHandle().style.setProperty("border","none");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.ClearMethodPointers.call(this);
      this.FBtnClickPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.GetMethodPointers.call(this);
      if (this.FBtnClickPtr === null) this.FBtnClickPtr = rtl.createCallback(this,"HandleDoBtnClick");
    };
    this.BindEvents = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.BindEvents.call(this);
      if (this.FBtnElement != null) this.FBtnElement.addEventListener("click",this.FBtnClickPtr);
    };
    this.ButtonChanged = function (Sender) {
      this.UpdateElement();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("");
        this.SetElementInputClassName("form-control");
        this.SetElementButtonClassName("btn btn-primary");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FButton = $mod.TEditButton.$create("Create$1");
      this.FButton.FOnChange = rtl.createCallback(this,"ButtonChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FButton");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWebEditBtn",this.TEditBtn,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",4,{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",4,{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",4,{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Button",2,$mod.$rtti["TEditButton"],"FButton","SetButton");
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",4,{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,pas["WEBLib.StdCtrls"].$rtti["TEditType"],"FEditType","SetEditType",4,{Default: pas["WEBLib.StdCtrls"].TEditType.weString});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",4,{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",4,{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",4,{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",4,{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",4,{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnBtnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnBtnClick","FOnBtnClick");
  });
  $mod.$implcode = function () {
    $impl.btnclearres = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA70lEQVQ4jbWSzQ2CQBCFl5OROgSKgAMmHExUDia2QUSswqg9GK1COfnTjCbagm/Cw2wQFw46yZcM+5jZ+Vml/mQ2iMEcpPTt" + "NoEWyMAdHMCaiH9jMssUvAcn0KvRHXAGu29JMgZ3DBWKdgGzqmCz7PLmAfA1PQAT+q4q2unqCcaq6LM0nz/1QcjkoabnYKgnWIBlpSq59QGeIKpoK1Vs6G0ZD9smkM2kphYClh21bUGGKD07/I4rATKTKX1P1QxRsSTZc9MaryCpE+VxyCORPbs1usfgrWp4jS" + "lLPIINyXmWmIJ1k/5GTJbS/+j5J/YC/YEx2smgMEoAAAAASUVORK5CYII=";
    $impl.btnsearchres = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAABNUlEQVQ4jZWSPU7DQBCFU5ECiEBU/AgEcmXJtvxbuAo0pOAE1CAaAigViFNBOAMRFengBNCCwgH4XrQrBXntkJGePLsz782" + "Pt9WqMc/z2mma9sEITAzk9xWr400tiqJtEsdJkjzwPfR9f0WQD4bcvyqnqfIY3OpcFMU+hHMIazaH2L1EnJ0QvFJl45/iX8dxvOXIG4LLigCEFwLdLMsO8G/qxiR2pJ24OpiYeS/AZp1AWZarynUJfElgdmaXsZsOXXy7BPSruk3keSMM7BKbjLynyhLZ9h6X" + "bwIidw3k6W9k1KUKmW8vz/MNEt45P+rxhGG4LMw+JHaw4ySbc890MgDPWiz4sU/5T2Uudk3LJ2Y5x6quFzhvD1ZgZMm2sjr6F9kIfARBsC6RhclG4AzypzpZmIz9Aj6Qcv0OcR9YAAAAAElFTkSuQmCC";
    $impl.emptyimgres = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
  };
},["WEBLib.Utils","Math"]);
rtl.module("WEBLib.TMSFNCEditorButton",["System","Classes","Types","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.StdCtrls","WEBLib.Forms","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","UITypes"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 1;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCEditorButtonAppearance");
  this.TTMSFNCEditorButtonPosition = {"0": "ebpAlone", ebpAlone: 0, "1": "ebpLeft", ebpLeft: 1, "2": "ebpTop", ebpTop: 2, "3": "ebpCenter", ebpCenter: 3, "4": "ebpRight", ebpRight: 4, "5": "ebpBottom", ebpBottom: 5};
  this.$rtti.$Enum("TTMSFNCEditorButtonPosition",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCEditorButtonPosition});
  rtl.createClass(this,"TTMSFNCCustomEditorButton",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FHover = false;
      this.FDown = false;
      this.FSelected = false;
      this.FAppearance = null;
      this.FText = "";
      this.FToggle = false;
      this.FButtonPosition = 0;
      this.FButtonPositionCorners = {};
      this.FModalResult = 0;
      this.FBitmap = null;
      this.FDisabledBitmap = null;
      this.FGroupName = "";
      this.FAcceleratorChar = "\x00";
      this.FAcceleratorCharPos = 0;
      this.FOnButtonClick = null;
      this.FBitmapMargins = null;
      this.FOnHandleAcceleratorKey = null;
      this.FDownBitmap = null;
    };
    this.$final = function () {
      this.FAppearance = undefined;
      this.FButtonPositionCorners = undefined;
      this.FBitmap = undefined;
      this.FDisabledBitmap = undefined;
      this.FOnButtonClick = undefined;
      this.FBitmapMargins = undefined;
      this.FOnHandleAcceleratorKey = undefined;
      this.FDownBitmap = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
      this.Invalidate();
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.SetAcceleratorChar(this.FText);
        this.Invalidate();
      };
    };
    this.SetToggle = function (Value) {
      if (this.FToggle !== Value) {
        this.FToggle = Value;
        this.Invalidate();
      };
    };
    this.SetSelected = function (Value) {
      if (this.FSelected !== Value) {
        this.FSelected = Value;
        if (this.FGroupName !== "") this.UpdateOtherGroupButtons();
        this.Invalidate();
      };
    };
    this.SetButtonPosition = function (Value) {
      if (this.FButtonPosition !== Value) {
        this.FButtonPosition = Value;
        this.SetButtonPositionCorners();
        this.Invalidate();
      };
    };
    this.SetButtonPositionCorners = function () {
      var $tmp = this.FButtonPosition;
      if ($tmp === $mod.TTMSFNCEditorButtonPosition.ebpLeft) {
        this.FButtonPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft)}
       else if ($tmp === $mod.TTMSFNCEditorButtonPosition.ebpCenter) {
        this.FButtonPositionCorners = {}}
       else if ($tmp === $mod.TTMSFNCEditorButtonPosition.ebpRight) {
        this.FButtonPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight)}
       else if ($tmp === $mod.TTMSFNCEditorButtonPosition.ebpTop) {
        this.FButtonPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight)}
       else if ($tmp === $mod.TTMSFNCEditorButtonPosition.ebpBottom) {
        this.FButtonPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight)}
       else {
        this.FButtonPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight);
      };
    };
    this.SetBitmap = function (Value) {
      this.FBitmap.Assign(Value);
      this.DoBitmapChanged$1(this);
    };
    this.SetDisabledBitmap = function (Value) {
      this.FDisabledBitmap.Assign(Value);
      this.DoBitmapChanged$1(this);
    };
    this.SetGroupName = function (Value) {
      if (this.FGroupName !== Value) {
        this.FGroupName = Value;
      };
    };
    this.UpdateOtherGroupButtons = function () {
      var I = 0;
      for (var $l = 0, $end = this.FParent.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ($mod.TTMSFNCCustomEditorButton.isPrototypeOf(this.FParent.GetControls(I)) && (this.FParent.GetControls(I).GetComponentIndex() !== this.GetComponentIndex())) {
          if ((rtl.as(this.FParent.GetControls(I),$mod.TTMSFNCCustomEditorButton).FGroupName === this.FGroupName) && rtl.as(this.FParent.GetControls(I),$mod.TTMSFNCCustomEditorButton).FToggle) {
            rtl.as(this.FParent.GetControls(I),$mod.TTMSFNCCustomEditorButton).SetSelectedByToggle(false);
          };
        };
      };
    };
    this.SetAcceleratorChar = function (AText) {
      var c = "\x00";
      this.FAcceleratorCharPos = pas.System.Pos("&",this.FText);
      if (this.FAcceleratorCharPos > 0) {
        c = pas.SysUtils.LowerCase(this.FText).charAt((this.FAcceleratorCharPos + 1) - 1);
        if (c !== this.FAcceleratorChar) {
          this.FAcceleratorChar = pas.SysUtils.LowerCase(this.FText).charAt((this.FAcceleratorCharPos + 1) - 1);
        };
      };
    };
    this.SetBitmapMargins = function (Value) {
      this.FBitmapMargins.Assign(Value);
    };
    this.SetDownBitmap = function (Value) {
      this.FDownBitmap.Assign(Value);
      this.DoBitmapChanged$1(this);
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FAppearance.FRounding = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FRounding,M,D);
      this.FAppearance.FSelectionLineWidth = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FSelectionLineWidth,M,D);
      this.FAppearance.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FFont.FHeight,M,D));
      this.FAppearance.FHoverFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FHoverFont.FHeight,M,D));
      this.FAppearance.FDownFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FDownFont.FHeight,M,D));
      this.FAppearance.FSelectedFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FSelectedFont.FHeight,M,D));
      this.FAppearance.FDisabledFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FDisabledFont.FHeight,M,D));
      this.FAppearance.FStroke.SetWidth((this.FAppearance.FStroke.FWidth * M) / D);
      this.FAppearance.FSelectedStroke.SetWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FSelectedStroke.FWidth,M,D));
      this.FAppearance.FHoverStroke.SetWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FHoverStroke.FWidth,M,D));
      this.FAppearance.FDownStroke.SetWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FDownStroke.FWidth,M,D));
      this.FAppearance.FDisabledStroke.SetWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FDisabledStroke.FWidth,M,D));
      this.FBitmapMargins.SetTop(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FBitmapMargins.FTop,M,D));
      this.FBitmapMargins.SetLeft(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FBitmapMargins.FLeft,M,D));
      this.FBitmapMargins.SetRight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FBitmapMargins.FRight,M,D));
      this.FBitmapMargins.SetBottom(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FBitmapMargins.FBottom,M,D));
      this.EndUpdate();
    };
    this.SetSelectedByToggle = function (AValue) {
      this.FSelected = AValue;
      this.Invalidate();
    };
    this.DoButtonClick = function () {
      if (this.FOnButtonClick != null) this.FOnButtonClick(this);
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if (this.FEnabled) {
        this.FDown = true;
        this.Invalidate();
      };
    };
    this.HandleMouseEnter = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseEnter.call(this);
      if (this.FEnabled) {
        this.FHover = true;
        this.Invalidate();
      };
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FHover = false;
      this.Invalidate();
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (this.FEnabled && !this.FHover) {
        this.FHover = true;
        this.Invalidate();
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      if (this.FEnabled) {
        if (this.FToggle) this.SetSelected(!this.FSelected);
        if (this.FDown) {
          if (this.FModalResult !== 0) ;
          this.DoButtonClick();
        };
      };
      this.FDown = false;
      this.Invalidate();
    };
    this.DoAppearanceChanged = function (Sender) {
      this.Invalidate();
    };
    this.DoBitmapChanged$1 = function (Sender) {
      this.Invalidate();
    };
    this.DoBitmapMarginsChanged = function (Sender) {
      this.Invalidate();
    };
    this.Draw = function (AGraphics, ARect) {
      this.DrawStandardBackGround(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.DrawSelectionLine(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.DrawButtonImage(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.DrawButtonText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DrawStandardBackGround = function (AGraphics, ARect) {
      var drect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rounding = 0;
      if (!this.FEnabled) {
        AGraphics.FFill.Assign(this.FAppearance.FDisabledFill);
        AGraphics.FStroke.Assign(this.FAppearance.FDisabledStroke);
      } else if (this.FAppearance.FSelectionLine) {
        AGraphics.FFill.Assign(this.FAppearance.FFill);
        AGraphics.FStroke.Assign(this.FAppearance.FStroke);
      } else if (this.FSelected) {
        AGraphics.FFill.Assign(this.FAppearance.FSelectedFill);
        AGraphics.FStroke.Assign(this.FAppearance.FSelectedStroke);
      } else if (this.FDown) {
        AGraphics.FFill.Assign(this.FAppearance.FDownFill);
        AGraphics.FStroke.Assign(this.FAppearance.FDownStroke);
      } else if (this.FHover) {
        AGraphics.FFill.Assign(this.FAppearance.FHoverFill);
        AGraphics.FStroke.Assign(this.FAppearance.FHoverStroke);
      } else {
        AGraphics.FFill.Assign(this.FAppearance.FFill);
        AGraphics.FStroke.Assign(this.FAppearance.FStroke);
      };
      AGraphics.FStroke.SetWidth(pas.System.Trunc(AGraphics.FStroke.FWidth));
      drect.$assign(ARect);
      rounding = Math.min(this.FAppearance.FRounding,Math.round(this.GetHeight() / 2));
      AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(drect),rounding,rtl.refSet(this.FButtonPositionCorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DrawSelectionLine = function (AGraphics, ARect) {
      var drect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rounding = 0;
      var sw = 0.0;
      if ((this.FSelected || this.FDown || this.FHover) && this.FAppearance.FSelectionLine) {
        if (this.FSelected) {
          AGraphics.FFill.Assign(this.FAppearance.FSelectedFill);
          AGraphics.FFont.Assign(this.FAppearance.FSelectedFont);
          AGraphics.FStroke.Assign(this.FAppearance.FSelectedStroke);
        } else if (this.FDown) {
          AGraphics.FFill.Assign(this.FAppearance.FDownFill);
          AGraphics.FFont.Assign(this.FAppearance.FDownFont);
          AGraphics.FStroke.Assign(this.FAppearance.FDownStroke);
        } else if (this.FHover) {
          AGraphics.FFill.Assign(this.FAppearance.FHoverFill);
          AGraphics.FFont.Assign(this.FAppearance.FHoverFont);
          AGraphics.FStroke.Assign(this.FAppearance.FHoverStroke);
        };
        AGraphics.FStroke.SetWidth(pas.System.Trunc(AGraphics.FStroke.FWidth));
        if (AGraphics.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone) {
          sw = AGraphics.FStroke.FWidth}
         else sw = 0;
        drect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Bottom - sw - pas.System.Trunc(this.FAppearance.FSelectionLineWidth),ARect.Right,ARect.Bottom - sw));
        rounding = Math.round(Math.min(this.FAppearance.FRounding / 2,(drect.Bottom - drect.Top) / 2));
        if (this.FButtonPosition in rtl.createSet($mod.TTMSFNCEditorButtonPosition.ebpAlone,$mod.TTMSFNCEditorButtonPosition.ebpLeft)) drect.Left = drect.Left + rounding;
        if (this.FButtonPosition in rtl.createSet($mod.TTMSFNCEditorButtonPosition.ebpAlone,$mod.TTMSFNCEditorButtonPosition.ebpRight)) drect.Right = drect.Right - rounding;
        AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(drect),rounding,rtl.refSet(this.FButtonPositionCorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      };
    };
    this.DrawBackground = function (AGraphics, ARect) {
    };
    this.DrawButtonText = function (AGraphics, ARect) {
      var txt = "";
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var va = 0;
      var ha = 0;
      var ww = false;
      var ro = 0;
      var cw = 0.0;
      var cs = 0.0;
      var rw = 0.0;
      var w = 0.0;
      var h = 0.0;
      if (this.FText !== "") {
        if (!this.FEnabled) {
          AGraphics.FFont.Assign(this.FAppearance.FDisabledFont)}
         else if (this.FAppearance.FSelectionLine) {
          AGraphics.FFont.Assign(this.FAppearance.FFont)}
         else if (this.FSelected) {
          AGraphics.FFont.Assign(this.FAppearance.FSelectedFont)}
         else if (this.FDown) {
          AGraphics.FFont.Assign(this.FAppearance.FDownFont)}
         else if (this.FHover) {
          AGraphics.FFont.Assign(this.FAppearance.FHoverFont)}
         else AGraphics.FFont.Assign(this.FAppearance.FFont);
        cs = 0;
        cw = 0;
        ww = false;
        ha = this.FAppearance.FTextAlignHorizontal;
        va = this.FAppearance.FTextAlignVertical;
        tr.$assign(ARect);
        if (this.FShowAcceleratorChar && (this.FAcceleratorCharPos > 0)) {
          txt = pas.SysUtils.StringReplace(this.FText,"&","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
          if (this.FAcceleratorCharPos > 1) cs = AGraphics.CalculateTextWidth$1(pas.System.Copy(txt,0,this.FAcceleratorCharPos - 1));
          cw = AGraphics.CalculateTextWidth$1(txt.charAt(this.FAcceleratorCharPos - 1));
        } else txt = this.FText;
        ro = Math.min(this.FAppearance.FRounding,Math.round(this.GetHeight() / 2));
        w = AGraphics.CalculateTextWidth$1(txt) + 2;
        h = AGraphics.CalculateTextHeight$1("Hg");
        tr.Left = tr.Left + (ro / 4);
        tr.Right = tr.Right - (ro / 4);
        tr.Top = tr.Top + (ro / 4);
        tr.Bottom = tr.Bottom - (ro / 4);
        var $tmp = ha;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          rw = tr.Right - tr.Left;
          tr.Left = Math.max(tr.Left,tr.Left + ((rw - w) / 2));
          tr.Right = Math.min(tr.Right,tr.Left + w);
        } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
          tr.Right = tr.Left + w;
        } else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
          tr.Left = tr.Right - w;
        };
        var $tmp1 = va;
        if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          rw = tr.Bottom - tr.Top;
          tr.Top = Math.max(tr.Top,tr.Top + ((rw - h) / 2));
          tr.Bottom = Math.min(tr.Bottom,tr.Top + h);
        } else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
          tr.Bottom = tr.Top + h;
        } else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
          tr.Top = tr.Bottom - h;
        };
        AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr),txt,ww,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
        if (this.FShowAcceleratorChar && (this.FAcceleratorCharPos > 0) && !(this.FSelected || this.FDown)) {
          AGraphics.FStroke.SetWidth(pas.System.Trunc(this.ScalePaintValue$1(1.0)));
          AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          AGraphics.FStroke.SetColor(AGraphics.FFont.FColor);
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(tr.Left + cs,tr.Bottom)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(tr.Left + cs + cw,tr.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        };
      };
    };
    this.DrawButtonImage = function (AGraphics, ARect) {
      var ir = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ar = false;
      var s = false;
      var ro = 0;
      var bmp = null;
      if (!this.FEnabled && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FDisabledBitmap)) {
        bmp = this.FDisabledBitmap}
       else if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FDownBitmap) && this.FDown) {
        bmp = this.FDownBitmap}
       else bmp = this.FBitmap;
      if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
        ar = true;
        s = true;
        ro = Math.min(this.FAppearance.FRounding,Math.round(Math.min(this.GetHeight() / 2,this.GetWidth() / 2)));
        ir.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left + Math.max(this.FBitmapMargins.FLeft,ro / 8),ARect.Top + Math.max(this.FBitmapMargins.FTop,ro / 8),ARect.Right - Math.max(this.FBitmapMargins.FRight,ro / 8),ARect.Bottom - Math.max(this.FBitmapMargins.FBottom,ro / 8)));
        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ir),bmp,ar,s,true,false);
      };
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
    };
    this.HandleAcceleratorKey = function () {
      if (this.FOnHandleAcceleratorKey != null) {
        this.FOnHandleAcceleratorKey(this)}
       else if (this.FOnClick != null) this.FOnClick(this);
    };
    this.SetEnabled = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetEnabled.apply(this,arguments);
      this.Invalidate();
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.FTransparent = true;
      this.FAppearance = $mod.TTMSFNCEditorButtonAppearance.$create("Create$1",[this]);
      this.FAppearance.FOnChanged = rtl.createCallback(this,"DoAppearanceChanged");
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"DoBitmapChanged$1");
      this.FDownBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"DoBitmapChanged$1");
      this.FBitmapMargins = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FBitmapMargins.FOnChange = rtl.createCallback(this,"DoBitmapMarginsChanged");
      this.FDisabledBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FDisabledBitmap.FOnChange = rtl.createCallback(this,"DoBitmapChanged$1");
      this.FText = "Button";
      this.FButtonPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight);
      this.FButtonPosition = $mod.TTMSFNCEditorButtonPosition.ebpAlone;
      this.SetWidth(80);
      this.SetHeight(25);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      rtl.free(this,"FBitmap");
      rtl.free(this,"FDownBitmap");
      rtl.free(this,"FBitmapMargins");
      rtl.free(this,"FDisabledBitmap");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.Invalidate();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCEditorButtonAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FDownStroke = null;
      this.FFont = null;
      this.FSelectedFill = null;
      this.FHoverFont = null;
      this.FFill = null;
      this.FSelectedStroke = null;
      this.FHoverFill = null;
      this.FStroke = null;
      this.FDownFont = null;
      this.FHoverStroke = null;
      this.FOnChanged = null;
      this.FDownFill = null;
      this.FSelectedFont = null;
      this.FRounding = 0;
      this.FTextAlignVertical = 0;
      this.FTextAlignHorizontal = 0;
      this.FSelectionLine = false;
      this.FSelectionLineWidth = 0.0;
      this.FDisabledFont = null;
      this.FDisabledFill = null;
      this.FDisabledStroke = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FDownStroke = undefined;
      this.FFont = undefined;
      this.FSelectedFill = undefined;
      this.FHoverFont = undefined;
      this.FFill = undefined;
      this.FSelectedStroke = undefined;
      this.FHoverFill = undefined;
      this.FStroke = undefined;
      this.FDownFont = undefined;
      this.FHoverStroke = undefined;
      this.FOnChanged = undefined;
      this.FDownFill = undefined;
      this.FSelectedFont = undefined;
      this.FDisabledFont = undefined;
      this.FDisabledFill = undefined;
      this.FDisabledStroke = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetDownFill = function (Value) {
      this.FDownFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetDownFont = function (Value) {
      this.FDownFont.Assign(Value);
      this.DoFontChanged(this);
    };
    this.SetDownStroke = function (Value) {
      this.FDownStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetFont = function (Value) {
      this.FFont.Assign(Value);
      this.DoFontChanged(this);
    };
    this.SetHoverFill = function (Value) {
      this.FHoverFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetHoverFont = function (Value) {
      this.FHoverFont.Assign(Value);
      this.DoFontChanged(this);
    };
    this.SetHoverStroke = function (Value) {
      this.FHoverStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetSelectedFill = function (Value) {
      this.FSelectedFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetSelectedFont = function (Value) {
      this.FSelectedFont.Assign(Value);
      this.DoFontChanged(this);
    };
    this.SetSelectedStroke = function (Value) {
      this.FSelectedStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetRounding = function (Value) {
      if (this.FRounding !== Value) {
        this.FRounding = Value;
        this.DoChanged(this);
      };
    };
    this.SetTextAlignHorizontal = function (Value) {
      if (this.FTextAlignHorizontal !== Value) {
        this.FTextAlignHorizontal = Value;
        this.DoChanged(this);
      };
    };
    this.SetTextAlignVertical = function (Value) {
      if (this.FTextAlignVertical !== Value) {
        this.FTextAlignVertical = Value;
        this.DoChanged(this);
      };
    };
    this.SetSelectionLine = function (Value) {
      if (this.FSelectionLine !== Value) {
        this.FSelectionLine = Value;
        this.DoChanged(this);
      };
    };
    this.SetSelectionLineWidth = function (Value) {
      if (this.FSelectionLineWidth !== Value) {
        this.FSelectionLineWidth = Value;
        this.DoChanged(this);
      };
    };
    this.SetDisabledFill = function (Value) {
      this.FDisabledFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetDisabledFont = function (Value) {
      this.FDisabledFont.Assign(Value);
      this.DoFontChanged(this);
    };
    this.SetDisabledStroke = function (Value) {
      this.FDisabledStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.DoChanged = function (Sender) {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.DoFillChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoFontChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoStrokeChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FSelectionLine = false;
      this.FSelectionLineWidth = 4;
      this.FRounding = 6;
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#4edbfa"),8421504,-1,-1]);
      this.FHoverFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FDownFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#4edbfa"),1.0]);
      this.FSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FSelectedFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FDisabledFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FDisabledFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FDisabledFont.SetColor(10789024);
      this.FDisabledStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,10789024,1.0]);
      this.FFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FFont.FOnChanged = rtl.createCallback(this,"DoFontChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      this.FDisabledFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FDisabledFont.FOnChanged = rtl.createCallback(this,"DoFontChanged");
      this.FDisabledStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      this.FHoverFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FHoverFont.FOnChanged = rtl.createCallback(this,"DoFontChanged");
      this.FHoverStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      this.FDownFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FDownFont.FOnChanged = rtl.createCallback(this,"DoFontChanged");
      this.FDownStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      this.FSelectedFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FSelectedFont.FOnChanged = rtl.createCallback(this,"DoFontChanged");
      this.FSelectedStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFill");
      rtl.free(this,"FFont");
      rtl.free(this,"FStroke");
      rtl.free(this,"FHoverFill");
      rtl.free(this,"FHoverFont");
      rtl.free(this,"FHoverStroke");
      rtl.free(this,"FDownFill");
      rtl.free(this,"FDownFont");
      rtl.free(this,"FDownStroke");
      rtl.free(this,"FSelectedFill");
      rtl.free(this,"FSelectedFont");
      rtl.free(this,"FSelectedStroke");
      rtl.free(this,"FDisabledFill");
      rtl.free(this,"FDisabledFont");
      rtl.free(this,"FDisabledStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCEditorButtonAppearance.isPrototypeOf(Source)) {
        this.FSelectionLine = rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FSelectionLine;
        this.FSelectionLineWidth = rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FSelectionLineWidth;
        this.FRounding = rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FRounding;
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FFill);
        this.FFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FFont);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FStroke);
        this.FHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FHoverFill);
        this.FHoverFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FHoverFont);
        this.FHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FHoverStroke);
        this.FDownFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FDownFill);
        this.FDownFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FDownFont);
        this.FDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FDownStroke);
        this.FSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FSelectedFill);
        this.FSelectedFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FSelectedFont);
        this.FSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FSelectedStroke);
        this.FDisabledFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FDisabledFill);
        this.FDisabledFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FDisabledFont);
        this.FDisabledStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorButtonAppearance).FDisabledStroke);
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("DisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDisabledFill","SetDisabledFill");
    $r.addProperty("DisabledFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FDisabledFont","SetDisabledFont");
    $r.addProperty("DisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDisabledStroke","SetDisabledStroke");
    $r.addProperty("HoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FHoverFill","SetHoverFill");
    $r.addProperty("HoverFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FHoverFont","SetHoverFont");
    $r.addProperty("HoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FHoverStroke","SetHoverStroke");
    $r.addProperty("DownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDownFill","SetDownFill");
    $r.addProperty("DownFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FDownFont","SetDownFont");
    $r.addProperty("DownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDownStroke","SetDownStroke");
    $r.addProperty("SelectedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FSelectedFill","SetSelectedFill");
    $r.addProperty("SelectedFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FSelectedFont","SetSelectedFont");
    $r.addProperty("SelectedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FSelectedStroke","SetSelectedStroke");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
    $r.addProperty("Rounding",2,rtl.longint,"FRounding","SetRounding");
    $r.addProperty("TextAlignHorizontal",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTextAlignHorizontal","SetTextAlignHorizontal",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("TextAlignVertical",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTextAlignVertical","SetTextAlignVertical",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("SelectionLine",2,rtl.boolean,"FSelectionLine","SetSelectionLine");
    $r.addProperty("SelectionLineWidth",2,rtl.double,"FSelectionLineWidth","SetSelectionLineWidth");
  });
  rtl.createClass(this,"TTMSFNCEditorButton",this.TTMSFNCCustomEditorButton,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCEditorButtonAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("DisabledBitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FDisabledBitmap","SetDisabledBitmap");
    $r.addProperty("GroupName",2,rtl.string,"FGroupName","SetGroupName");
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("Toggle",2,rtl.boolean,"FToggle","SetToggle");
    $r.addProperty("Selected",2,rtl.boolean,"FSelected","SetSelected");
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapMargins",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FBitmapMargins","SetBitmapMargins");
    $r.addProperty("ButtonPosition",2,$mod.$rtti["TTMSFNCEditorButtonPosition"],"FButtonPosition","SetButtonPosition",4,{Default: $mod.TTMSFNCEditorButtonPosition.ebpAlone});
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",4,{Default: 0});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnButtonClick","FOnButtonClick");
    $r.addProperty("OnHandleAcceleratorKey",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHandleAcceleratorKey","FOnHandleAcceleratorKey");
    $r.addProperty("DownBitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FDownBitmap","SetDownBitmap");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["TypInfo","SysUtils","WEBLib.TMSFNCUtils","Math","WEBLib.Graphics"]);
rtl.module("WEBLib.TMSFNCEditorPanel",["System","Classes","Types","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.StdCtrls","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCCustomEditorPanel");
  this.TTMSFNCEditorPanelPosition = {"0": "eppAlone", eppAlone: 0, "1": "eppLeft", eppLeft: 1, "2": "eppTop", eppTop: 2, "3": "eppCenter", eppCenter: 3, "4": "eppRight", eppRight: 4, "5": "eppBottom", eppBottom: 5};
  this.$rtti.$Enum("TTMSFNCEditorPanelPosition",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCEditorPanelPosition});
  rtl.createClass(this,"TTMSFNCEditorPanelAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FFill = null;
      this.FSelectedFill = null;
      this.FSelectedStroke = null;
      this.FStroke = null;
      this.FRounding = 0;
      this.FOnChanged = null;
      this.FStrokeSides = {};
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FFill = undefined;
      this.FSelectedFill = undefined;
      this.FSelectedStroke = undefined;
      this.FStroke = undefined;
      this.FOnChanged = undefined;
      this.FStrokeSides = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetSelectedFill = function (Value) {
      this.FSelectedFill.Assign(Value);
      this.DoFillChanged(this);
    };
    this.SetSelectedStroke = function (Value) {
      this.FSelectedStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetRounding = function (Value) {
      if (this.FRounding !== Value) {
        this.FRounding = Value;
        this.DoChanged(this);
      };
    };
    this.SetStrokeSides = function (Value) {
      if (rtl.neSet(this.FStrokeSides,Value)) {
        this.FStrokeSides = rtl.refSet(Value);
        this.DoStrokeChanged(this);
      };
    };
    this.DoChanged = function (Sender) {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.DoFillChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoStrokeChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FRounding = 0;
      this.FStrokeSides = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom);
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      this.FSelectedFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FSelectedStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FSelectedFill");
      rtl.free(this,"FSelectedStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCEditorPanelAppearance.isPrototypeOf(Source)) {
        this.FRounding = rtl.as(Source,$mod.TTMSFNCEditorPanelAppearance).FRounding;
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorPanelAppearance).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorPanelAppearance).FStroke);
        this.FSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorPanelAppearance).FSelectedFill);
        this.FSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorPanelAppearance).FSelectedStroke);
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("SelectedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FSelectedFill","SetSelectedFill");
    $r.addProperty("SelectedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FSelectedStroke","SetSelectedStroke");
    $r.addProperty("Rounding",2,rtl.longint,"FRounding","SetRounding");
    $r.addProperty("StrokeSides",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsSides"],"FStrokeSides","SetStrokeSides");
  });
  rtl.createClass(this,"TTMSFNCCustomEditorPanel",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FAppearance = null;
      this.FPanelPosition = 0;
      this.FPanelPositionCorners = {};
      this.FSelected = false;
    };
    this.$final = function () {
      this.FAppearance = undefined;
      this.FPanelPositionCorners = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
      this.Invalidate();
    };
    this.SetPanelPosition = function (Value) {
      if (this.FPanelPosition !== Value) {
        this.FPanelPosition = Value;
        this.SetPanelPositionCorners();
        this.Invalidate();
      };
    };
    this.SetPanelPositionCorners = function () {
      var $tmp = this.FPanelPosition;
      if ($tmp === $mod.TTMSFNCEditorPanelPosition.eppLeft) {
        this.FPanelPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft)}
       else if ($tmp === $mod.TTMSFNCEditorPanelPosition.eppCenter) {
        this.FPanelPositionCorners = {}}
       else if ($tmp === $mod.TTMSFNCEditorPanelPosition.eppRight) {
        this.FPanelPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight)}
       else if ($tmp === $mod.TTMSFNCEditorPanelPosition.eppTop) {
        this.FPanelPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight)}
       else if ($tmp === $mod.TTMSFNCEditorPanelPosition.eppBottom) {
        this.FPanelPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight)}
       else {
        this.FPanelPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight);
      };
    };
    this.SetSelected = function (Value) {
      if (this.FSelected !== Value) {
        this.FSelected = Value;
        this.Invalidate();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FAppearance.SetRounding(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FRounding,M,D));
      this.EndUpdate();
    };
    this.DoAppearanceChanged = function (Sender) {
      this.Invalidate();
    };
    this.Draw = function (AGraphics, ARect) {
      var drect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rounding = 0;
      if (!this.FSelected) {
        AGraphics.FFill.Assign(this.FAppearance.FFill);
        AGraphics.FStroke.Assign(this.FAppearance.FStroke);
      } else {
        AGraphics.FFill.Assign(this.FAppearance.FSelectedFill);
        AGraphics.FStroke.Assign(this.FAppearance.FSelectedStroke);
      };
      drect.$assign(ARect);
      rounding = Math.min(this.FAppearance.FRounding,Math.round(this.GetHeight() / 2));
      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(drect),rounding,rtl.refSet(this.FPanelPositionCorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DrawBackground = function (AGraphics, ARect) {
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.FAppearance = $mod.TTMSFNCEditorPanelAppearance.$create("Create$1",[this]);
      this.FAppearance.FOnChanged = rtl.createCallback(this,"DoAppearanceChanged");
      this.FPanelPositionCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight);
      this.FPanelPosition = $mod.TTMSFNCEditorPanelPosition.eppAlone;
      this.SetWidth(200);
      this.SetHeight(200);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.Invalidate();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCEditorPanel",this.TTMSFNCCustomEditorPanel,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCEditorPanelAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("PanelPosition",2,$mod.$rtti["TTMSFNCEditorPanelPosition"],"FPanelPosition","SetPanelPosition",4,{Default: $mod.TTMSFNCEditorPanelPosition.eppAlone});
    $r.addProperty("Selected",2,rtl.boolean,"FSelected","SetSelected");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["TypInfo","WEBLib.Forms","SysUtils","WEBLib.TMSFNCUtils","Math","WEBLib.Graphics"]);
rtl.module("WEBLib.TreeNodes",["System","Classes","Types","SysUtils","Web"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TTreeNode");
  this.$rtti.$Class("TTreeNodes");
  rtl.createClass(this,"TDbgList",pas.Classes.TList,function () {
    this.GetItemsEx = function (Index) {
      var Result = null;
      if (Index >= this.GetCount()) {
        throw pas.SysUtils.Exception.$create("Create$1",["Index out of bounds in list read access"]);
      };
      if (Index < this.GetCount()) {
        Result = rtl.getObject(this.Get(Index))}
       else Result = null;
      return Result;
    };
    this.SetItemsEx = function (Index, Value) {
      if (Index >= this.GetCount()) {
        throw pas.SysUtils.Exception.$create("Create$1",["Index out of bounds in list write access"]);
      };
      if (Index < this.GetCount()) this.Put(Index,Value);
    };
    this.AssignList = function (ListA) {
      var I = 0;
      this.Clear();
      for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.Add(ListA.Get(I));
      };
    };
  });
  this.TNodeType = {"0": "ntText", ntText: 0, "1": "ntCheckbox", ntCheckbox: 1, "2": "ntRadioButton", ntRadioButton: 2};
  this.$rtti.$Enum("TNodeType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TNodeType});
  this.$rtti.$Pointer("PNodeInfo",{reftype: this.$rtti["TNodeInfo"]});
  rtl.recNewT(this,"TNodeInfo",function () {
    this.SelectedIndex = 0;
    this.StateIndex = 0;
    this.OverlayIndex = 0;
    this.Data = null;
    this.Count = 0;
    this.Text = "";
    this.NodeType = 0;
    this.Checked = false;
    this.ImageURL = "";
    this.ImageCollapsedURL = "";
    this.URL = "";
    this.Tag = 0;
    this.Hint = "";
    this.IsExpanded = false;
    this.$eq = function (b) {
      return (this.SelectedIndex === b.SelectedIndex) && (this.StateIndex === b.StateIndex) && (this.OverlayIndex === b.OverlayIndex) && (this.Data === b.Data) && (this.Count === b.Count) && (this.Text === b.Text) && (this.NodeType === b.NodeType) && (this.Checked === b.Checked) && (this.ImageURL === b.ImageURL) && (this.ImageCollapsedURL === b.ImageCollapsedURL) && (this.URL === b.URL) && (this.Tag === b.Tag) && (this.Hint === b.Hint) && (this.IsExpanded === b.IsExpanded);
    };
    this.$assign = function (s) {
      this.SelectedIndex = s.SelectedIndex;
      this.StateIndex = s.StateIndex;
      this.OverlayIndex = s.OverlayIndex;
      this.Data = s.Data;
      this.Count = s.Count;
      this.Text = s.Text;
      this.NodeType = s.NodeType;
      this.Checked = s.Checked;
      this.ImageURL = s.ImageURL;
      this.ImageCollapsedURL = s.ImageCollapsedURL;
      this.URL = s.URL;
      this.Tag = s.Tag;
      this.Hint = s.Hint;
      this.IsExpanded = s.IsExpanded;
      return this;
    };
    var $r = $mod.$rtti.$Record("TNodeInfo",{},this);
    $r.addField("SelectedIndex",rtl.longint);
    $r.addField("StateIndex",rtl.longint);
    $r.addField("OverlayIndex",rtl.longint);
    $r.addField("Data",rtl.pointer);
    $r.addField("Count",rtl.longint);
    $r.addField("Text",rtl.string);
    $r.addField("NodeType",$mod.$rtti["TNodeType"]);
    $r.addField("Checked",rtl.boolean);
    $r.addField("ImageURL",rtl.string);
    $r.addField("ImageCollapsedURL",rtl.string);
    $r.addField("URL",rtl.string);
    $r.addField("Tag",rtl.longint);
    $r.addField("Hint",rtl.string);
    $r.addField("IsExpanded",rtl.boolean);
  });
  rtl.recNewT(this,"TNodeDataInfo",function () {
    this.SelectedIndex = 0;
    this.StateIndex = 0;
    this.OverlayIndex = 0;
    this.Data = null;
    this.Count = 0;
    this.NodeType = 0;
    this.Checked = false;
    this.Tag = 0;
    this.IsExpanded = false;
    this.TextLen = 0;
    this.HintLen = 0;
    this.URLLen = 0;
    this.ImageURLLen = 0;
    this.ImageCollapsedURLLen = 0;
    this.$eq = function (b) {
      return (this.SelectedIndex === b.SelectedIndex) && (this.StateIndex === b.StateIndex) && (this.OverlayIndex === b.OverlayIndex) && (this.Data === b.Data) && (this.Count === b.Count) && (this.NodeType === b.NodeType) && (this.Checked === b.Checked) && (this.Tag === b.Tag) && (this.IsExpanded === b.IsExpanded) && (this.TextLen === b.TextLen) && (this.HintLen === b.HintLen) && (this.URLLen === b.URLLen) && (this.ImageURLLen === b.ImageURLLen) && (this.ImageCollapsedURLLen === b.ImageCollapsedURLLen);
    };
    this.$assign = function (s) {
      this.SelectedIndex = s.SelectedIndex;
      this.StateIndex = s.StateIndex;
      this.OverlayIndex = s.OverlayIndex;
      this.Data = s.Data;
      this.Count = s.Count;
      this.NodeType = s.NodeType;
      this.Checked = s.Checked;
      this.Tag = s.Tag;
      this.IsExpanded = s.IsExpanded;
      this.TextLen = s.TextLen;
      this.HintLen = s.HintLen;
      this.URLLen = s.URLLen;
      this.ImageURLLen = s.ImageURLLen;
      this.ImageCollapsedURLLen = s.ImageCollapsedURLLen;
      return this;
    };
    var $r = $mod.$rtti.$Record("TNodeDataInfo",{},this);
    $r.addField("SelectedIndex",rtl.longint);
    $r.addField("StateIndex",rtl.longint);
    $r.addField("OverlayIndex",rtl.longint);
    $r.addField("Data",rtl.pointer);
    $r.addField("Count",rtl.longint);
    $r.addField("NodeType",$mod.$rtti["TNodeType"]);
    $r.addField("Checked",rtl.boolean);
    $r.addField("Tag",rtl.longint);
    $r.addField("IsExpanded",rtl.boolean);
    $r.addField("TextLen",rtl.byte);
    $r.addField("HintLen",rtl.byte);
    $r.addField("URLLen",rtl.byte);
    $r.addField("ImageURLLen",rtl.byte);
    $r.addField("ImageCollapsedURLLen",rtl.byte);
  });
  this.$rtti.$ClassRef("TTreeNodeClass",{instancetype: this.$rtti["TTreeNode"]});
  rtl.createClass(this,"TTreeNode",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FText = "";
      this.FData = null;
      this.FDeleting = false;
      this.FIsExpanded = false;
      this.FFirstChild = null;
      this.FNextSibling = null;
      this.FPrevSibling = null;
      this.FParentNode = null;
      this.FShowText = false;
      this.FImageCollapsedURL = "";
      this.FImageURL = "";
      this.FNodeType = 0;
      this.FURL = "";
      this.FChecked = false;
      this.FTag = 0;
      this.FHint = "";
      this.FSelected = false;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FData = undefined;
      this.FFirstChild = undefined;
      this.FNextSibling = undefined;
      this.FPrevSibling = undefined;
      this.FParentNode = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetLevel = function () {
      var Result = 0;
      var Node = null;
      Result = 0;
      Node = this.GetParent();
      while (Node !== null) {
        Result += 1;
        Node = Node.GetParent();
      };
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = this.FParentNode;
      return Result;
    };
    this.GetIndex = function () {
      var Result = 0;
      var Node = null;
      Result = -1;
      Node = this;
      while (Node != null) {
        Result += 1;
        Node = Node.GetPrevSibling();
      };
      return Result;
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = this.GetFirstChild();
      while ((Result !== null) && (Index > 0)) {
        Result = this.GetNextChild(Result);
        Index -= 1;
      };
      if (Result === null) throw pas.SysUtils.Exception.$create("Create$1",["Invalid index"]);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      var Node = null;
      Result = 0;
      Node = this.GetFirstChild();
      while (Node != null) {
        Result += 1;
        Node = Node.GetNextChild(Node);
      };
      return Result;
    };
    this.SetData = function (Value) {
      if (!this.FDeleting && (Value !== this.FData)) {
        this.FData = Value;
      };
    };
    this.SetItem = function (Index, Value) {
      this.GetItem(Index).Assign(Value);
    };
    this.SetText = function (S) {
      if (!this.FDeleting && (S !== this.FText)) {
        this.FText = S;
      };
    };
    this.GetHasChildren = function () {
      var Result = false;
      Result = this.FFirstChild != null;
      return Result;
    };
    this.SetShowText = function (Value) {
      this.FShowText = Value;
    };
    this.SetChecked = function (Value) {
      this.FChecked = Value;
    };
    this.SetImageCollapsedURL = function (Value) {
      this.FImageCollapsedURL = Value;
    };
    this.SetImageURL = function (Value) {
      this.FImageURL = Value;
    };
    this.SetNodeType = function (Value) {
      this.FNodeType = Value;
    };
    this.SetURL = function (Value) {
      this.FURL = Value;
    };
    this.SetTag = function (Value) {
      this.FTag = Value;
    };
    this.SetHint = function (Value) {
      this.FHint = Value;
    };
    this.SetIsExpanded = function (Value) {
      if (this.FIsExpanded !== Value) {
        this.FIsExpanded = Value;
        if (this.FOwner != null) if (this.FOwner.FOnExpandedChange != null) this.FOwner.FOnExpandedChange(this.FOwner,this);
      };
    };
    this.SetSelected = function (Value) {
      if (this.FSelected !== Value) {
        this.FSelected = Value;
        this.FOwner.SelectionChange(this,Value);
      };
    };
    this.GetAbsoluteIndex = function () {
      var Result = 0;
      var Node = null;
      if (this.IsFirstNode()) {
        Result = 0}
       else {
        Result = -1;
        Node = this;
        while (Node !== null) {
          Result += 1;
          Node = Node.GetPrev();
        };
      };
      return Result;
    };
    this.CompareCount = function (CompareMe) {
      var Result = false;
      var Count = 0;
      var Node = null;
      Count = 0;
      Result = false;
      Node = this.GetFirstChild();
      while (Node !== null) {
        Count += 1;
        Node = Node.GetNextChild(Node);
        if (Count > CompareMe) return Result;
      };
      if (Count === CompareMe) Result = true;
      return Result;
    };
    this.IsEqual = function (Node) {
      var Result = false;
      Result = (this.FText === Node.FText) && (this.FData === Node.FData);
      return Result;
    };
    this.Select = function () {
      this.FSelected = true;
    };
    this.UnSelect = function () {
      this.FSelected = false;
    };
    this.IndexOf = function (Value) {
      var Result = 0;
      var Node = null;
      Result = -1;
      Node = this.GetFirstChild();
      while (Node !== null) {
        Result += 1;
        if (Node === Value) break;
        Node = this.GetNextChild(Node);
      };
      if (Node === null) Result = -1;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.FOwner = AOwner;
      this.FShowText = true;
      this.FNodeType = $mod.TNodeType.ntText;
      this.FChecked = false;
      this.FIsExpanded = false;
      this.FTag = 0;
      return this;
    };
    this.Destroy = function () {
      var N = null;
      var PN = null;
      var NN = null;
      var i = 0;
      this.FDeleting = true;
      this.DeleteChildren();
      N = this.GetParent();
      if ((((N !== null) && !N.FDeleting) || (N === null)) && !this.FOwner.FDeleting && (this.FOwner != null) && (this.FOwner.FOwner != null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FOwner.FOwner.FComponentState)) {
        PN = this.GetPrevSibling();
        NN = this.GetNextSibling();
        if (!(NN != null)) {
          if (this.IsFirstNode()) {
            this.FOwner.FFirstNode = null}
           else if ((this.GetParent() != null) && this.IsFirstChild()) {
            this.GetParent().FFirstChild = null}
           else {
            if (PN != null) PN.FNextSibling = null;
          };
        } else if (!(PN != null)) {
          if (this.IsFirstNode()) {
            this.FOwner.FFirstNode = NN;
            NN.FPrevSibling = PN;
          } else if ((this.GetParent() != null) && this.IsFirstChild()) this.GetParent().FFirstChild = NN;
        } else {
          PN.FNextSibling = NN;
          NN.FPrevSibling = PN;
        };
      };
      if (!(this.GetParent() != null)) {
        i = this.FOwner.FNodeList.IndexOf(this);
        if (i >= 0) {
          this.FOwner.FNodeList.Delete(i);
        };
      };
      this.SetData(null);
      pas.System.TObject.Destroy.call(this);
    };
    this.AddFirstChild = function (S) {
      var Result = null;
      Result = this.AddFirstChild$1(S,null);
      return Result;
    };
    this.AddFirstChild$1 = function (S, Data) {
      var Result = null;
      if (!(this.FFirstChild != null)) {
        Result = this.FOwner.InsertNode(this,null,true)}
       else Result = this.FOwner.InsertNode(null,this.FFirstChild,true);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.AddChild = function (S) {
      var Result = null;
      Result = this.AddChild$1(S,null);
      return Result;
    };
    this.AddChild$1 = function (S, Data) {
      var Result = null;
      var N = null;
      N = this.GetLastChild();
      if (N != null) {
        Result = this.FOwner.InsertNode(null,N,false)}
       else Result = this.FOwner.InsertNode(this,null,false);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.Assign = function (Source) {
      var Node = null;
      if (!this.FDeleting && $mod.TTreeNode.isPrototypeOf(Source)) {
        Node = Source;
        this.SetText(Node.FText);
        this.SetData(Node.FData);
        this.SetShowText(Node.FShowText);
        this.SetNodeType(Node.FNodeType);
        this.SetChecked(Node.FChecked);
        this.SetURL(Node.FURL);
        this.SetHint(Node.FHint);
        this.SetImageURL(Node.FImageURL);
        this.SetImageCollapsedURL(Node.FImageCollapsedURL);
        this.SetTag(Node.FTag);
        this.FIsExpanded = Node.FIsExpanded;
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.Expand = function (Recurse) {
      var i = 0;
      this.SetIsExpanded(true);
      if (Recurse) {
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.GetItem(i).Expand(Recurse);
        };
      };
    };
    this.Collapse = function (Recurse) {
      var i = 0;
      this.SetIsExpanded(false);
      if (Recurse) {
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.GetItem(i).Collapse(Recurse);
        };
      };
    };
    this.Delete = function () {
      if (!this.FDeleting) this.Free();
    };
    this.DeleteChildren = function () {
      var ChildList = null;
      var N = null;
      var i = 0;
      ChildList = $mod.TDbgList.$create("Create$1");
      N = this.GetFirstChild();
      if (N !== null) {
        do {
          ChildList.Add(N);
          N = N.GetNextSibling();
        } while (!(N === null));
      };
      for (var $l = ChildList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        N = ChildList.GetItemsEx(i);
        N = rtl.freeLoc(N);
        ChildList.GetItemsEx(i).Delete();
      };
      ChildList = rtl.freeLoc(ChildList);
    };
    this.GetFirstChild = function () {
      var Result = null;
      Result = this.FFirstChild;
      return Result;
    };
    this.GetLastChild = function () {
      var Result = null;
      var Node = null;
      Result = this.GetFirstChild();
      if (Result !== null) {
        Node = Result;
        do {
          Result = Node;
          Node = Result.GetNextSibling();
        } while (!(Node === null));
      };
      return Result;
    };
    this.GetNextChild = function (Value) {
      var Result = null;
      if (Value !== null) {
        Result = Value.GetNextSibling()}
       else Result = null;
      return Result;
    };
    this.GetNextSibling = function () {
      var Result = null;
      Result = this.FNextSibling;
      return Result;
    };
    this.GetPrevChild = function (Value) {
      var Result = null;
      if (Value !== null) {
        Result = Value.GetPrevSibling()}
       else Result = null;
      return Result;
    };
    this.GetPrevSibling = function () {
      var Result = null;
      Result = this.FPrevSibling;
      return Result;
    };
    this.HasAsParent = function (Value) {
      var Result = false;
      if (Value !== null) {
        if (this.GetParent() === null) {
          Result = false}
         else if (this.GetParent() === Value) {
          Result = true}
         else Result = this.GetParent().HasAsParent(Value);
      } else Result = true;
      return Result;
    };
    this.IsFirstNode = function () {
      var Result = false;
      Result = this === this.FOwner.FFirstNode;
      return Result;
    };
    this.IsFirstChild = function () {
      var Result = false;
      Result = this.IsFirstNode() || ((this.GetParent() != null) && (this.GetParent().GetFirstChild() === this));
      return Result;
    };
    this.GetNext = function () {
      var Result = null;
      var p = null;
      Result = null;
      if (this.GetCount() > 0) {
        Result = this.GetItem(0)}
       else {
        Result = this.GetNextSibling();
        if (!(Result != null)) {
          p = this;
          do {
            p = p.GetParent();
            if (p != null) Result = p.GetNextSibling();
          } while (!(!(p != null) || (Result != null)));
        };
      };
      return Result;
    };
    this.GetPrev = function () {
      var Result = null;
      var cn = null;
      Result = this.GetPrevSibling();
      if (Result != null) {
        cn = Result;
        do {
          if (cn.GetCount() > 0) {
            Result = cn.GetItem(cn.GetCount() - 1);
            cn = Result;
          };
        } while (!(cn.GetCount() === 0));
      } else Result = this.GetParent();
      return Result;
    };
  });
  this.$rtti.$MethodVar("TSelectNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",this.$rtti["TTreeNode"]],["IsSelected",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",this.$rtti["TTreeNode"]]]), methodkind: 0});
  rtl.createClass(this,"TTreeNodes",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FFirstNode = null;
      this.FNodeList = null;
      this.FDeleting = false;
      this.FReading = false;
      this.FOnChange = null;
      this.FOnExpandedChange = null;
      this.FOnSelectionChange = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FFirstNode = undefined;
      this.FNodeList = undefined;
      this.FOnChange = undefined;
      this.FOnExpandedChange = undefined;
      this.FOnSelectionChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetNodeFromIndex = function (Index) {
      var Result = null;
      var i = 0;
      var idx = 0;
      var child = null;
      Result = null;
      idx = 0;
      for (var $l = 0, $end = this.FNodeList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        child = this.FNodeList.GetItemsEx(i);
        do {
          if (Index === idx) {
            Result = child;
            return Result;
          };
          child = child.GetNext();
          idx += 1;
        } while (!(child === null));
      };
      return Result;
    };
    this.GetSiblingCount = function () {
      var Result = 0;
      Result = this.FNodeList.GetCount();
      return Result;
    };
    this.GetSiblingFromIndex = function (Index) {
      var Result = null;
      Result = null;
      if ((Index >= 0) && (Index < this.FNodeList.GetCount())) Result = this.FNodeList.GetItemsEx(Index);
      return Result;
    };
    this.SetItem = function (Index, Value) {
      if ((Index >= 0) && (Index < this.FNodeList.GetCount())) this.GetNodeFromIndex(Index).Assign(Value);
    };
    this.GetCount = function () {
      var $Self = this;
      var Result = 0;
      var i = 0;
      function GetChildCount(tn) {
        var Result = 0;
        var j = 0;
        Result = tn.GetCount();
        for (var $l = 0, $end = tn.GetCount() - 1; $l <= $end; $l++) {
          j = $l;
          Result = Result + GetChildCount(tn.GetItem(j));
        };
        return Result;
      };
      Result = this.FNodeList.GetCount();
      for (var $l = 0, $end = this.FNodeList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        Result = Result + GetChildCount(this.FNodeList.GetItemsEx(i));
      };
      return Result;
    };
    this.InsertNode = function (ParentNode, DesNode, InsertBefore) {
      var Result = null;
      var N = null;
      Result = null;
      if (!(DesNode != null)) {
        if (ParentNode != null) {
          N = ParentNode.GetLastChild();
          if (N != null) {
            this.InsertNode(null,N,false);
            return Result;
          } else {
            Result = this.CreateNode();
            ParentNode.FFirstChild = Result;
            Result.FParentNode = ParentNode;
            return Result;
          };
        } else {
          if (!(this.FFirstNode != null)) {
            Result = this.CreateNode();
            this.FFirstNode = Result;
            this.FNodeList.Add(Result);
          };
        };
      } else {
        Result = this.CreateNode();
        if (InsertBefore) {
          if (this.IsVeryFirstNode(DesNode)) {
            this.FFirstNode = Result;
            Result.FNextSibling = DesNode;
            DesNode.FPrevSibling = Result;
            this.FNodeList.Insert(0,Result);
          } else {
            if (DesNode.IsFirstChild() && (DesNode.GetParent() != null)) {
              DesNode.GetParent().FFirstChild = Result;
              Result.FNextSibling = DesNode;
              DesNode.FPrevSibling = Result;
              Result.FParentNode = DesNode.GetParent();
            } else {
              Result.FPrevSibling = DesNode.FPrevSibling;
              Result.FNextSibling = DesNode;
              DesNode.FPrevSibling = Result;
              Result.FParentNode = DesNode.GetParent();
              if (Result.FPrevSibling != null) Result.FPrevSibling.FNextSibling = Result;
            };
          };
        } else {
          Result.FNextSibling = DesNode.FNextSibling;
          Result.FPrevSibling = DesNode;
          DesNode.FNextSibling = Result;
          if (Result.FNextSibling != null) Result.FNextSibling.FPrevSibling = Result;
          Result.FParentNode = DesNode.GetParent();
          if (!(DesNode.GetParent() != null)) this.FNodeList.Add(Result);
        };
      };
      return Result;
    };
    this.IsVeryFirstNode = function (Node) {
      var Result = false;
      Result = (Node != null) && (Node === this.FFirstNode);
      return Result;
    };
    this.SelectionChange = function (Node, IsSelected) {
      if (this.FOnSelectionChange != null) this.FOnSelectionChange(this,Node,IsSelected);
    };
    this.CreateNode = function () {
      var Result = null;
      var LClass = null;
      LClass = $mod.TTreeNode;
      Result = LClass.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.FOwner = AOwner;
      this.FFirstNode = null;
      this.FNodeList = $mod.TDbgList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      this.FDeleting = true;
      this.Clear();
      rtl.free(this,"FNodeList");
      pas.System.TObject.Destroy.call(this);
    };
    this.AddFirst = function (S) {
      var Result = null;
      Result = this.AddFirst$1(null,S);
      return Result;
    };
    this.AddFirst$1 = function (Data, S) {
      var Result = null;
      if (!(this.FFirstNode != null)) {
        Result = this.InsertNode(null,null,true);
      } else {
        Result = this.InsertNode(null,this.FFirstNode,true);
      };
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.Add = function (Sibling, S) {
      var Result = null;
      Result = this.Add$1(Sibling,S,null);
      return Result;
    };
    this.Add$1 = function (Sibling, S, Data) {
      var Result = null;
      Result = this.InsertNode(Sibling,this.GetLastNode(),false);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.Add$2 = function (S) {
      var Result = null;
      Result = this.Add$3(S,null);
      return Result;
    };
    this.Add$3 = function (S, Data) {
      var Result = null;
      Result = this.InsertNode(null,this.GetLastNode(),false);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.AddChild = function (Parent, S) {
      var Result = null;
      if (Parent === null) {
        Result = this.Add$3(S,null)}
       else Result = this.AddChild$1(Parent,S,null);
      return Result;
    };
    this.AddChild$1 = function (Parent, S, Data) {
      var Result = null;
      Result = null;
      if (Parent != null) {
        Result = Parent.AddChild$1(S,Data)}
       else Result = this.Add$3(S,Data);
      return Result;
    };
    this.AddChildFirst = function (Parent, S) {
      var Result = null;
      Result = this.AddChildFirst$1(Parent,S,null);
      return Result;
    };
    this.AddChildFirst$1 = function (Parent, S, Data) {
      var Result = null;
      Result = null;
      if (Parent != null) Result = Parent.AddFirstChild$1(S,Data);
      return Result;
    };
    this.Assign = function (Source) {
      if ($mod.TTreeNodes.isPrototypeOf(Source)) {
        this.Clear();
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.BeginUpdate = function () {
    };
    this.EndUpdate = function () {
    };
    this.Clear = function () {
      var i = 0;
      for (var $l = this.FNodeList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        this.FNodeList.GetItemsEx(i).Delete();
      };
      this.FNodeList.Clear();
    };
    this.Delete = function (Node) {
      Node.Delete();
    };
    this.GetFirstNode = function () {
      var Result = null;
      Result = this.FFirstNode;
      return Result;
    };
    this.GetLastNode = function () {
      var Result = null;
      Result = this.FFirstNode;
      if (Result != null) while (Result.GetNextSibling() !== null) Result = Result.GetNextSibling();
      return Result;
    };
    this.Insert = function (Sibling, S) {
      var Result = null;
      Result = this.InsertObject(Sibling,S,null);
      return Result;
    };
    this.InsertObject = function (Sibling, S, Data) {
      var Result = null;
      Result = this.InsertNode(null,Sibling,true);
      if (Result != null) {
        Result.SetText(S);
        Result.SetData(Data);
      };
      return Result;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
  });
},["Math"]);
rtl.module("WEBLib.Buttons",["System","Classes","SysUtils","WEBLib.Controls","Web","WEBLib.Graphics","WEBLib.StdCtrls","WEBLib.ComCtrls","WEBLib.ExtCtrls","WEBLib.Forms","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TButtonLayout = {"0": "blGlyphLeft", blGlyphLeft: 0, "1": "blGlyphRight", blGlyphRight: 1, "2": "blGlyphTop", blGlyphTop: 2, "3": "blGlyphBottom", blGlyphBottom: 3};
  this.$rtti.$Enum("TButtonLayout",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TButtonLayout});
  rtl.createClass(this,"TCustomSpeedButton",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FMaterialGlyph = "";
      this.FColor$1 = 0;
      this.FIntColor = 0;
      this.FDown = false;
      this.FFlat = false;
      this.FGroupIndex = 0;
      this.FAllowAllUp = false;
      this.FGlyph = null;
      this.FLayout = 0;
      this.FGlyphURL = "";
      this.FMaterialGlyphSize = 0;
      this.FMaterialGlyphColor = 0;
      this.FMaterialGlyphType = 0;
      this.FGlyphSize = 0;
    };
    this.$final = function () {
      this.FGlyph = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetMaterialGlyph = function (AValue) {
      if (this.FMaterialGlyph !== AValue) {
        this.FMaterialGlyph = AValue;
        this.UpdateElement();
      };
    };
    this.SetColorEx = function (AValue) {
      if (this.FColor$1 !== AValue) {
        this.FColor$1 = AValue;
        this.FIntColor = AValue;
        this.UpdateElement();
      };
    };
    this.SetIntColor = function (AValue) {
      if (this.FIntColor !== AValue) {
        this.FIntColor = AValue;
        this.UpdateElement();
      };
    };
    this.SetGroupIndex = function (AValue) {
      this.FGroupIndex = AValue;
    };
    this.SetDown = function (AValue) {
      if (this.FDown !== AValue) {
        this.FDown = AValue;
        this.UpdateElement();
      };
    };
    this.SetFlat = function (Value) {
      if (this.FFlat !== Value) {
        this.FFlat = Value;
        this.RecreateElement();
      };
    };
    this.SetGlyph = function (Value) {
      this.FGlyph.Assign(Value);
      this.UpdateElement();
    };
    this.SetGlyphURL = function (Value) {
      if (this.FGlyphURL !== Value) {
        this.FGlyphURL = Value;
        this.RecreateElement();
      };
    };
    this.SetMaterialGlyphSize = function (Value) {
      if ((Value > 0) && (Value < 100)) {
        this.FMaterialGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGyphColor = function (Value) {
      if (this.FMaterialGlyphColor !== Value) {
        this.FMaterialGlyphColor = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyphType = function (Value) {
      if (this.FMaterialGlyphType !== Value) {
        this.FMaterialGlyphType = Value;
        this.UpdateElement();
      };
    };
    this.SetGlyphSize = function (Value) {
      if (this.FGlyphSize !== Value) {
        this.FGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetEnabled = function (Value) {
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      this.UpdateElement();
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElement();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      if (this.FFlat) {
        Result = document.createElement("SPAN")}
       else {
        Result = document.createElement("BUTTON");
        Result.setAttribute("type","BUTTON");
      };
      return Result;
    };
    this.UpdateElement = function () {
      var s = "";
      var inactive = "";
      var noptr = "";
      var icn = "";
      var imgsrc = "";
      var gs = "";
      var matclr = "";
      var cap = "";
      var acc = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (!this.IsUpdating() && (this.FMaterialGlyph !== "")) this.AddControlLink("googlematerial","https://fonts.googleapis.com/icon?family=Material+Icons");
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("vertical-align","middle");
        this.GetElementHandle().style.setProperty("overflow","hidden");
        this.GetElementHandle().style.setProperty("padding","0px");
        this.GetElementHandle().style.setProperty("text-align","center");
        this.GetElementHandle().style.setProperty("min-width","32px");
        if (this.FFlat && this.FVisible) {
          this.GetElementHandle().style.setProperty("display","flex");
          this.GetElementHandle().style.setProperty("justify-content","center");
        };
        s = "";
        inactive = "";
        noptr = "";
        if (!this.FEnabled) inactive = " md-light md-inactive";
        noptr = "pointer-events:none";
        if (this.FMaterialGlyph !== "") {
          matclr = "";
          if (this.FMaterialGlyphColor !== -1) {
            if (this.FEnabled) {
              matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FMaterialGlyphColor)}
             else matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(0xA0A0A0);
          };
          icn = '<i class="' + pas["WEBLib.Controls"].GetMaterialClass(this.FMaterialGlyphType) + inactive + '" translate="no" style="' + noptr + ";font-size:" + pas.SysUtils.IntToStr(this.FMaterialGlyphSize) + "px" + matclr + '">' + this.FMaterialGlyph + "</i>";
        };
        if (this.FGlyph.GetData() !== "") {
          imgsrc = "data:image/jpeg;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FGlyph.GetData())}
         else if (this.FGlyph.FFilename !== "") {
          imgsrc = this.FGlyph.FFilename}
         else if (this.FGlyphURL !== "") imgsrc = this.FGlyphURL;
        gs = "";
        if (this.FGlyphSize !== 0) gs = "width:" + pas.SysUtils.TIntegerHelper.ToString$1.call({p: this, get: function () {
            return this.p.FGlyphSize;
          }, set: function (v) {
            this.p.FGlyphSize = v;
          }}) + "px";
        if (imgsrc !== "") icn = '<img style="' + noptr + ";vertical-align:middle;" + gs + '" src="' + imgsrc + '">';
        if ((this.GetElementHandle().childElementCount === 0) || !this.GetIsLinked()) cap = pas["WEBLib.WebTools"].ProcessAccelerator(this.FCaption,{get: function () {
            return acc;
          }, set: function (v) {
            acc = v;
          }});
        if (acc !== "") this.GetElementHandle().setAttribute("accesskey",acc);
        if (this.FTabStop) {
          this.GetElementHandle().setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder))}
         else this.GetElementHandle().setAttribute("tabindex","-1");
        var $tmp = this.FLayout;
        if ($tmp === $mod.TButtonLayout.blGlyphLeft) {
          s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + icn + '</td><td style="border:none">' + cap + "</td></tr></table>"}
         else if ($tmp === $mod.TButtonLayout.blGlyphRight) {
          s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + cap + '</td><td style="border:none">' + icn + "</td></tr></table>"}
         else if ($tmp === $mod.TButtonLayout.blGlyphTop) {
          s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + icn + '</td></tr><tr><td style="border:none">' + cap + "</td></tr></table>"}
         else if ($tmp === $mod.TButtonLayout.blGlyphBottom) s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + cap + '</td></tr><tr><td style="border:none">' + icn + "</td></tr></table>";
        this.GetElementHandle().innerHTML = s;
        pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle().firstChild,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        if (!this.IsEnabled()) {
          this.GetElementHandle().style.removeProperty("color")}
         else if ((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && (this.FElementClassName === "")) {
          this.GetElementHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.GetElementHandle().firstChild.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
        };
      };
    };
    this.UpdateElementVisual = function () {
      var clr = 0;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (this.FDown) {
          clr = 8421504}
         else clr = this.FIntColor;
        if ((clr !== -1) && (this.FElementClassName === "")) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(clr))}
         else this.GetElementHandle().style.setProperty("background-color","");
        if (this.GetElementHandle().firstChild != null) pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle().firstChild,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        if (!this.IsEnabled()) {
          this.GetElementHandle().style.removeProperty("color")}
         else if ((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && (this.FElementClassName === "")) {
          this.GetElementHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
          if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.GetElementHandle().firstChild != null)) this.GetElementHandle().firstChild.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
        };
      };
    };
    this.UpdateGroup = function () {
      var i = 0;
      if (this.FParent != null) {
        for (var $l = 0, $end = this.FParent.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ((this.FParent.GetControls(i) !== this) && $mod.TSpeedButton.isPrototypeOf(this.FParent.GetControls(i)) && (rtl.as(this.FParent.GetControls(i),$mod.TSpeedButton).FGroupIndex === this.FGroupIndex)) rtl.as(this.FParent.GetControls(i),$mod.TSpeedButton).SetDown(false);
        };
      };
    };
    this.DoMouseLeave = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.DoMouseLeave.call(this);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if ((frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && this.FShowHint && (this.FHint !== "")) return;
      this.SetIntColor(this.FColor$1);
    };
    this.DoMouseEnter = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.DoMouseEnter.call(this);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if ((frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && this.FShowHint && (this.FHint !== "")) return;
      if (this.FEnabled) this.SetIntColor(12632256);
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseUp.apply(this,arguments);
      if (this.FEnabled) this.SetIntColor(12632256);
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseDown.apply(this,arguments);
      if (!this.FEnabled) return;
      this.SetIntColor(8421504);
      if (this.FGroupIndex > 0) {
        if (this.FDown && this.FAllowAllUp) {
          this.SetDown(false)}
         else {
          this.SetDown(true);
          this.UpdateGroup();
        };
      };
    };
    this.GlyphChanged = function (Sender) {
      this.UpdateElement();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("btn btn-light");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FGlyph");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FColor$1 = -1;
      this.FIntColor = -1;
      this.FGroupIndex = 0;
      this.FDown = false;
      this.FFlat = false;
      this.FGlyph = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FGlyph.FOnChange = rtl.createCallback(this,"GlyphChanged");
      this.FGlyph.FOnDataChange = rtl.createCallback(this,"GlyphChanged");
      this.FLayout = $mod.TButtonLayout.blGlyphLeft;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphColor = -1;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
    };
    this.CanFocus = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSpeedButton",this.TCustomSpeedButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AllowAllUp",0,rtl.boolean,"FAllowAllUp","FAllowAllUp");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",4,{Default: -1});
    $r.addProperty("Down",2,rtl.boolean,"FDown","SetDown");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Flat",2,rtl.boolean,"FFlat","SetFlat",4,{Default: false});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Glyph",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FGlyph","SetGlyph");
    $r.addProperty("GlyphURL",2,rtl.string,"FGlyphURL","SetGlyphURL");
    $r.addProperty("GlyphSize",2,rtl.longint,"FGlyphSize","SetGlyphSize",4,{Default: 0});
    $r.addProperty("GroupIndex",2,rtl.longint,"FGroupIndex","SetGroupIndex");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",0,$mod.$rtti["TButtonLayout"],"FLayout","FLayout",4,{Default: $mod.TButtonLayout.blGlyphLeft});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",4,{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",4,{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",4,{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TWebSpeedButton",this.TSpeedButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomBitBtn",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FMaterialGlyph = "";
      this.FLayout = 0;
      this.FFlat = false;
      this.FGlyph = null;
      this.FColor$1 = 0;
      this.FIntColor = 0;
      this.FAlignment = 0;
      this.FGlyphURL = "";
      this.FMaterialGlyphSize = 0;
      this.FMaterialGlyphColor = 0;
      this.FMaterialGlyphType = 0;
      this.FGlyphSize = 0;
      this.FModalResult = 0;
      this.FDefault = false;
      this.FCancel = false;
    };
    this.$final = function () {
      this.FGlyph = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetFlat = function (Value) {
      if (this.FFlat !== Value) {
        this.FFlat = Value;
        this.RecreateElement();
      };
    };
    this.SetGlyph = function (Value) {
      this.FGlyph.Assign(Value);
      this.UpdateElement();
    };
    this.SetLayout = function (Value) {
      if (this.FLayout !== Value) {
        this.FLayout = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyph = function (Value) {
      if (this.FMaterialGlyph !== Value) {
        this.FMaterialGlyph = Value;
        this.UpdateElement();
      };
    };
    this.SetColorEx = function (Value) {
      if (this.FColor$1 !== Value) {
        this.FColor$1 = Value;
        this.SetColor(Value);
        this.UpdateElement();
      };
    };
    this.SetIntColor = function (Value) {
      this.FIntColor = Value;
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElement();
      };
    };
    this.SetGlyphURL = function (Value) {
      if (this.FGlyphURL !== Value) {
        this.FGlyphURL = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyphSize = function (Value) {
      if ((Value > 0) && (Value < 100)) {
        this.FMaterialGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGyphColor = function (Value) {
      if (this.FMaterialGlyphColor !== Value) {
        this.FMaterialGlyphColor = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyphType = function (Value) {
      if (this.FMaterialGlyphType !== Value) {
        this.FMaterialGlyphType = Value;
        this.UpdateElement();
      };
    };
    this.SetGlyphSize = function (Value) {
      if (this.FGlyphSize !== Value) {
        this.FGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElement();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      if (this.FFlat) {
        Result = document.createElement("SPAN")}
       else {
        Result = document.createElement("BUTTON");
        Result.setAttribute("type","BUTTON");
      };
      return Result;
    };
    this.UpdateElement = function () {
      var s = "";
      var inactive = "";
      var noptr = "";
      var matgl = "";
      var imgsrc = "";
      var matclr = "";
      var cap = "";
      var acc = "";
      var gs = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        if ((this.FColor$1 !== -1) && !this.FFlat) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor$1))}
         else this.GetElementHandle().style.setProperty("background-color","");
        this.GetElementHandle().style.setProperty("vertical-align","middle");
        if (this.FVisible) this.GetElementHandle().style.setProperty("display","table");
        this.GetElementHandle().style.setProperty("overflow","hidden");
        this.GetElementHandle().style.setProperty("padding","0px");
        var $tmp = this.FAlignment;
        if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
          this.GetElementHandle().style.setProperty("text-align","left")}
         else if ($tmp === pas.Classes.TAlignment.taCenter) {
          this.GetElementHandle().style.setProperty("text-align","center")}
         else if ($tmp === pas.Classes.TAlignment.taRightJustify) this.GetElementHandle().style.setProperty("text-align","right");
        s = "";
        inactive = "";
        noptr = "";
        matgl = "";
        if (!this.FEnabled) inactive = " md-light md-inactive";
        noptr = "pointer-events:none";
        if (this.FMaterialGlyph !== "") {
          matclr = "";
          if (this.FMaterialGlyphColor !== -1) matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FMaterialGlyphColor);
          matgl = '<i class="' + pas["WEBLib.Controls"].GetMaterialClass(this.FMaterialGlyphType) + inactive + '" translate="no" style="vertical-align:middle;' + noptr + ";font-size:" + pas.SysUtils.IntToStr(this.FMaterialGlyphSize) + "px" + matclr + '">' + this.FMaterialGlyph + "</i>";
        };
        if ((this.GetElementHandle().childElementCount === 0) || !this.GetIsLinked()) cap = pas["WEBLib.WebTools"].ProcessAccelerator(this.FCaption,{get: function () {
            return acc;
          }, set: function (v) {
            acc = v;
          }});
        if (acc !== "") this.GetElementHandle().setAttribute("accesskey",acc);
        if (cap !== "") s = '<span style="' + noptr + '">' + cap + "</span>";
        gs = "";
        if (this.FGlyphSize !== 0) gs = "width:" + pas.SysUtils.TIntegerHelper.ToString$1.call({p: this, get: function () {
            return this.p.FGlyphSize;
          }, set: function (v) {
            this.p.FGlyphSize = v;
          }}) + "px;";
        if (this.FGlyph.GetData() !== "") {
          imgsrc = "data:image/jpeg;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FGlyph.GetData())}
         else if (this.FGlyph.FFilename !== "") {
          imgsrc = this.FGlyph.FFilename}
         else if (this.FGlyphURL !== "") imgsrc = this.FGlyphURL;
        var $tmp1 = this.FLayout;
        if ($tmp1 === $mod.TButtonLayout.blGlyphLeft) {
          if (matgl !== "") {
            if (cap !== "") {
              s = matgl + "&nbsp;" + s}
             else s = matgl;
          };
          if (imgsrc !== "") s = '<img style="vertical-align:middle;' + gs + '" src="' + imgsrc + '">&nbsp;' + s;
        } else if ($tmp1 === $mod.TButtonLayout.blGlyphRight) {
          if (matgl !== "") {
            if (cap !== "") {
              s = s + "&nbsp;" + matgl}
             else s = matgl;
          };
          if (imgsrc !== "") s = s + '&nbsp;<img style="' + gs + '" src="' + imgsrc + '">';
        } else if ($tmp1 === $mod.TButtonLayout.blGlyphTop) {
          if (matgl !== "") {
            if (cap !== "") {
              s = matgl + "<br>" + s}
             else s = matgl;
          };
          if (imgsrc !== "") s = '<img style="' + gs + '" src="' + imgsrc + '"><br>' + s;
        } else if ($tmp1 === $mod.TButtonLayout.blGlyphBottom) {
          if (matgl !== "") {
            if (cap !== "") {
              s = s + "<br>" + matgl}
             else s = matgl;
          };
          if (imgsrc !== "") s = s + '<br><img style="' + gs + '" src="' + imgsrc + '">';
        };
        this.GetElementHandle().innerHTML = s;
        pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle(),this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.removeProperty("outline");
        this.GetElementHandle().style.removeProperty("user-select");
      };
    };
    this.Click = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (this.FModalResult !== 0) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if (frm != null) frm.SetModalResult(this.FModalResult);
      };
    };
    this.GlyphChanged = function (Sender) {
      this.UpdateElement();
    };
    this.HandleKeyPreview = function (Key) {
      pas["WEBLib.Controls"].TControl.HandleKeyPreview.apply(this,arguments);
      if (this.FDefault && (Key === 13)) {
        this.Click();
      };
      if (this.FCancel && (Key === 27)) {
        this.Click();
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("btn btn-light");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FGlyph");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FColor$1 = -1;
      this.FIntColor = -1;
      this.FFlat = false;
      this.SetWidth(80);
      this.SetHeight(25);
      this.FAlignment = pas.Classes.TAlignment.taCenter;
      this.FGlyph = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FGlyph.FOnChange = rtl.createCallback(this,"GlyphChanged");
      this.FGlyph.FOnDataChange = rtl.createCallback(this,"GlyphChanged");
      this.FGlyphSize = 0;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphColor = -1;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
      this.FModalResult = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TBitBtn",this.TCustomBitBtn,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Cancel",0,rtl.boolean,"FCancel","FCancel",4,{Default: false});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx");
    $r.addProperty("Default",0,rtl.boolean,"FDefault","FDefault",4,{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Flat",2,rtl.boolean,"FFlat","SetFlat",4,{Default: false});
    $r.addProperty("Glyph",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FGlyph","SetGlyph");
    $r.addProperty("GlyphURL",2,rtl.string,"FGlyphURL","SetGlyphURL");
    $r.addProperty("GlyphSize",2,rtl.longint,"FGlyphSize","SetGlyphSize",4,{Default: 0});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",2,$mod.$rtti["TButtonLayout"],"FLayout","SetLayout",4,{Default: $mod.TButtonLayout.blGlyphLeft});
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",4,{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",4,{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",4,{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",4,{Default: 0});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebBitBtn",this.TBitBtn,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomToolBar",pas["WEBLib.Controls"].TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      var el = null;
      Result = document.createElement("SPAN");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        el = document.createElement("DIV");
        el.style.setProperty("z-index","10");
        el.style.setProperty("width","100%");
        el.style.setProperty("height","100%");
        el.style.setProperty("webkit-user-select","none");
        el.style.setProperty("moz-user-select","none");
        el.style.setProperty("khtml-user-select","none");
        el.style.setProperty("ms-user-select","none");
        el.style.setProperty("user-select","none");
        el.style.setProperty("position","absolute");
        Result.appendChild(el);
      };
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("display","flex");
        this.GetElementHandle().style.setProperty("flex-wrap","wrap");
        this.GetElementHandle().style.setProperty("padding","2px");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(0xCFCFCF);
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetWidth(300);
      this.SetHeight(32);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TToolBar",this.TCustomToolBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: 13619151});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebToolBar",this.TToolBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TRichEditBtn = {"0": "reFont", reFont: 0, "1": "reFontSize", reFontSize: 1, "2": "reBold", reBold: 2, "3": "reItalic", reItalic: 3, "4": "reUnderline", reUnderline: 4, "5": "reStrikeThrough", reStrikeThrough: 5, "6": "reAlignLeft", reAlignLeft: 6, "7": "reAlignCenter", reAlignCenter: 7, "8": "reAlignRight", reAlignRight: 8, "9": "reUnorderedList", reUnorderedList: 9, "10": "reOrderedList", reOrderedList: 10, "11": "reForegroundColor", reForegroundColor: 11, "12": "reBackgroundColor", reBackgroundColor: 12, "13": "reHyperlink", reHyperlink: 13, "14": "reImageInsert", reImageInsert: 14, "15": "reLineSpacing", reLineSpacing: 15};
  this.$rtti.$Enum("TRichEditBtn",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TRichEditBtn});
  this.$rtti.$Set("TRichEditButtonSet",{comptype: this.$rtti["TRichEditBtn"]});
  rtl.createClass(this,"TRichEditToolBar",this.TToolBar,function () {
    this.$init = function () {
      $mod.TToolBar.$init.call(this);
      this.FBold = null;
      this.FItalic = null;
      this.FUnderline = null;
      this.FStrikeThrough = null;
      this.FAlignLeft = null;
      this.FAlignCenter = null;
      this.FAlignRight = null;
      this.FUList = null;
      this.FOList = null;
      this.FURL = null;
      this.FRichEdit = null;
      this.FFnt = null;
      this.FFntSize = null;
      this.FFgClr = null;
      this.FBkClr = null;
      this.FImage = null;
      this.FLineSpacing = null;
      this.FOnSpeedButtonClick = null;
      this.FTextColor = 0;
      this.FBackgroundColor = 0;
      this.FVisibleButtons = {};
      this.FHints = null;
      this.FBtnID = "";
      this.FFilePicker = null;
      this.FPtrFileLoad = null;
    };
    this.$final = function () {
      this.FBold = undefined;
      this.FItalic = undefined;
      this.FUnderline = undefined;
      this.FStrikeThrough = undefined;
      this.FAlignLeft = undefined;
      this.FAlignCenter = undefined;
      this.FAlignRight = undefined;
      this.FUList = undefined;
      this.FOList = undefined;
      this.FURL = undefined;
      this.FRichEdit = undefined;
      this.FFnt = undefined;
      this.FFntSize = undefined;
      this.FFgClr = undefined;
      this.FBkClr = undefined;
      this.FImage = undefined;
      this.FLineSpacing = undefined;
      this.FOnSpeedButtonClick = undefined;
      this.FVisibleButtons = undefined;
      this.FHints = undefined;
      this.FFilePicker = undefined;
      $mod.TToolBar.$final.call(this);
    };
    this.SetRichEdit = function (AValue) {
      if (AValue != null) {
        this.FRichEdit = AValue;
        this.FRichEdit.FOwner$1 = this;
        this.FRichEdit.FOnAttributesChanged = rtl.createCallback(this,"HandleAttributeChanged");
      };
    };
    this.GetRichEdit = function () {
      var Result = null;
      Result = this.FRichEdit;
      return Result;
    };
    this.SetTextColor = function (Value) {
      this.FTextColor = Value;
      this.FFgClr.SetColor$1(Value);
    };
    this.SetBackgroundColor = function (Value) {
      this.FBackgroundColor = Value;
      this.FBkClr.SetColor$1(Value);
    };
    this.SetVisibleButtons = function (Value) {
      this.FVisibleButtons = rtl.refSet(Value);
      this.UpdateButtons();
    };
    this.SetHints = function (Value) {
      this.FHints.Assign(Value);
    };
    this.HandleDoFileLoad = function (Event) {
      var $Self = this;
      var Result = false;
      function InsertImage(DataURL) {
        $Self.GetRichEdit().InsertImage(DataURL);
      };
      if (1 < 0) InsertImage("");
      var file = this.FFilePicker.files[0];
          var reader  = new FileReader();
      
          reader.addEventListener("load", function () {
              InsertImage(reader.result);
          }, false);
      
          if (file)
              reader.readAsDataURL(file);
      Result = true;
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FRichEdit)) {
        this.FRichEdit = null;
      };
    };
    this.CreateButton = function (btn, BtnID, Glyph, Hint) {
      btn.set($mod.TSpeedButton.$create("Create$2",[BtnID]));
      btn.get().SetName(BtnID);
      btn.get().SetFlat(true);
      btn.get().SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      btn.get().SetParent(this);
      btn.get().SetMaterialGlyph(Glyph);
      btn.get().SetTop(0);
      btn.get().SetWidth(32);
      btn.get().SetHeight(24);
      btn.get().SetHint(Hint);
      btn.get().SetShowHint(Hint !== "");
      btn.get().SetEnabled(true);
      btn.get().FOnClick = rtl.createCallback(this,"HandleSpeedButtonClick");
    };
    this.HandleSpeedButtonClick = function (Sender) {
      var BID = "";
      if (this.GetRichEdit() != null) {
        BID = Sender.GetID();
        if (BID === (this.FBtnID + "_bold")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsBold in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)));
        } else if (BID === (this.FBtnID + "_italic")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsItalic in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)));
        } else if (BID === (this.FBtnID + "_underline")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsUnderline in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
        } else if (BID === (this.FBtnID + "_strikethrough")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)));
        } else if (BID === (this.FBtnID + "_alignleft")) {
          this.GetRichEdit().FSelAttributes.SetAlignment(pas.Classes.TAlignment.taLeftJustify)}
         else if (BID === (this.FBtnID + "_aligncenter")) {
          this.GetRichEdit().FSelAttributes.SetAlignment(pas.Classes.TAlignment.taCenter)}
         else if (BID === (this.FBtnID + "_alignright")) {
          this.GetRichEdit().FSelAttributes.SetAlignment(pas.Classes.TAlignment.taRightJustify)}
         else if (BID === (this.FBtnID + "_olist")) {
          this.GetRichEdit().FSelAttributes.SetOrderedList(!this.GetRichEdit().FSelAttributes.FOrderedList)}
         else if (BID === (this.FBtnID + "_ulist")) {
          this.GetRichEdit().FSelAttributes.SetUnOrderedList(!this.GetRichEdit().FSelAttributes.FUnOrderedList)}
         else if (BID === (this.FBtnID + "_url")) {
          this.GetRichEdit().FSelAttributes.Link()}
         else if (BID === (this.FBtnID + "_image")) this.FFilePicker.click();
      };
      if (this.FOnSpeedButtonClick != null) this.FOnSpeedButtonClick(Sender);
    };
    this.FgSelect = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetColor(this.FFgClr.GetColor());
    };
    this.BkSelect = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetBackColor(this.FBkClr.GetColor());
    };
    this.FntChange = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetName(this.FFnt.FItems.Get(this.FFnt.GetItemIndex()));
    };
    this.FntSizeChange = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetHeight(this.FFntSize.GetItemIndex() + 1);
    };
    this.LineSpacingChange = function (Sender) {
      var spacing = 0.0;
      var $tmp = this.FLineSpacing.GetItemIndex();
      if ($tmp === 0) {
        spacing = 1}
       else if ($tmp === 1) {
        spacing = 1.5}
       else if ($tmp === 2) spacing = 2;
      this.FRichEdit.SetSelectionSpacing(spacing);
    };
    this.UpdateButtons = function () {
      if (this.IsUpdating()) return;
      this.FBold.SetVisible($mod.TRichEditBtn.reBold in this.FVisibleButtons);
      this.FItalic.SetVisible($mod.TRichEditBtn.reItalic in this.FVisibleButtons);
      this.FUnderline.SetVisible($mod.TRichEditBtn.reUnderline in this.FVisibleButtons);
      this.FStrikeThrough.SetVisible($mod.TRichEditBtn.reStrikeThrough in this.FVisibleButtons);
      this.FAlignLeft.SetVisible($mod.TRichEditBtn.reAlignLeft in this.FVisibleButtons);
      this.FAlignCenter.SetVisible($mod.TRichEditBtn.reAlignCenter in this.FVisibleButtons);
      this.FAlignRight.SetVisible($mod.TRichEditBtn.reAlignRight in this.FVisibleButtons);
      this.FUList.SetVisible($mod.TRichEditBtn.reUnorderedList in this.FVisibleButtons);
      this.FOList.SetVisible($mod.TRichEditBtn.reOrderedList in this.FVisibleButtons);
      this.FFnt.SetVisible($mod.TRichEditBtn.reFont in this.FVisibleButtons);
      this.FFntSize.SetVisible($mod.TRichEditBtn.reFontSize in this.FVisibleButtons);
      this.FFgClr.SetVisible($mod.TRichEditBtn.reForegroundColor in this.FVisibleButtons);
      this.FBkClr.SetVisible($mod.TRichEditBtn.reBackgroundColor in this.FVisibleButtons);
      this.FURL.SetVisible($mod.TRichEditBtn.reHyperlink in this.FVisibleButtons);
      this.FImage.SetVisible($mod.TRichEditBtn.reImageInsert in this.FVisibleButtons);
      this.FLineSpacing.SetVisible($mod.TRichEditBtn.reLineSpacing in this.FVisibleButtons);
      if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epRelative) {
        if (this.GetElementHandle() != null) {
          this.GetElementHandle().style.setProperty("display","flex");
          this.GetElementHandle().style.setProperty("flex-wrap","wrap");
          this.GetElementHandle().style.setProperty("padding","2px");
        };
      };
      while (this.FHints.GetCount() < 14) this.FHints.Add("");
      this.FBold.SetHint(this.FHints.Get(0));
      this.FItalic.SetHint(this.FHints.Get(1));
      this.FUnderline.SetHint(this.FHints.Get(2));
      this.FStrikeThrough.SetHint(this.FHints.Get(3));
      this.FFgClr.SetHint(this.FHints.Get(4));
      this.FBkClr.SetHint(this.FHints.Get(5));
      this.FAlignLeft.SetHint(this.FHints.Get(6));
      this.FAlignCenter.SetHint(this.FHints.Get(7));
      this.FAlignRight.SetHint(this.FHints.Get(8));
      this.FUList.SetHint(this.FHints.Get(9));
      this.FOList.SetHint(this.FHints.Get(10));
      this.FURL.SetHint(this.FHints.Get(11));
      this.FImage.SetHint(this.FHints.Get(12));
      this.FLineSpacing.SetHint(this.FHints.Get(13));
    };
    this.UpdateElement = function () {
      $mod.TCustomToolBar.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("height","32px");
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateButtons();
      this.InitButtons();
    };
    this.HandleAttributeChanged = function (Sender, Attributes) {
      this.FFnt.SetItemIndex(Math.max(0,this.FFnt.FItems.IndexOf(Attributes.FontName)));
      this.FFntSize.SetItemIndex(Math.max(0,this.FFntSize.FItems.IndexOf(Attributes.FontSize)));
      this.FBold.SetDown(Attributes.IsBold);
      this.FItalic.SetDown(Attributes.IsItalic);
      this.FUnderline.SetDown(Attributes.IsUnderline);
      this.FStrikeThrough.SetDown(Attributes.IsStrikeOut);
      this.FAlignLeft.SetDown(Attributes.IsLeft);
      this.FAlignRight.SetDown(Attributes.IsRight);
      this.FAlignCenter.SetDown(Attributes.IsCenter);
      if (Attributes.FontColor !== "") {
        this.FFgClr.SetColor$1(pas["WEBLib.Graphics"].HexToColor(Attributes.FontColor));
      };
      if (Attributes.BkColor !== "") {
        this.FBkClr.SetColor$1(pas["WEBLib.Graphics"].RGBToColor(Attributes.BkColor));
      };
    };
    this.GetChildren = function (Proc, Root) {
    };
    this.InitButtons = function () {
      var $Self = this;
      var Result = false;
      function HandleTimeOut() {
        var i = 0;
        for (var $l = 0, $end = $Self.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          $Self.GetControls(i).UpdateElement();
        };
      };
      Result = true;
      if (!this.GetIsLinked()) return Result;
      if (1 < 0) HandleTimeOut();
      setTimeout(function() {HandleTimeOut();}, 10);
      return Result;
    };
    this.SetParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.InitButtons();
    };
    this.CreateInitialize = function () {
      $mod.TCustomToolBar.CreateInitialize.call(this);
      this.FVisibleButtons = rtl.createSet($mod.TRichEditBtn.reFont,$mod.TRichEditBtn.reFontSize,$mod.TRichEditBtn.reBold,$mod.TRichEditBtn.reItalic,$mod.TRichEditBtn.reUnderline,$mod.TRichEditBtn.reStrikeThrough,$mod.TRichEditBtn.reAlignLeft,$mod.TRichEditBtn.reAlignCenter,$mod.TRichEditBtn.reAlignRight,$mod.TRichEditBtn.reUnorderedList,$mod.TRichEditBtn.reOrderedList,$mod.TRichEditBtn.reForegroundColor,$mod.TRichEditBtn.reBackgroundColor,$mod.TRichEditBtn.reHyperlink,$mod.TRichEditBtn.reImageInsert,$mod.TRichEditBtn.reLineSpacing);
      this.SetRichEdit(null);
      this.SetWidth(540);
      this.SetHeight(32);
      this.FPtrFileLoad = rtl.createCallback(this,"HandleDoFileLoad");
      this.FControlStyle = rtl.diffSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FTextColor = 0;
      this.FBackgroundColor = 16777215;
      this.FBtnID = pas["WEBLib.Controls"].FindUniqueName("RETBBtn");
      this.FHints = pas.Classes.TStringList.$create("Create$1");
      this.FHints.Add("Bold");
      this.FHints.Add("Italic");
      this.FHints.Add("Underline");
      this.FHints.Add("Strike Throught");
      this.FHints.Add("Text Color");
      this.FHints.Add("Background Color");
      this.FHints.Add("Align left");
      this.FHints.Add("Align center");
      this.FHints.Add("Align right");
      this.FHints.Add("Numbered list");
      this.FHints.Add("List");
      this.FHints.Add("Hyperlink");
      this.FHints.Add("Insert image");
      this.FHints.Add("Line spacing");
      this.FLineSpacing = pas["WEBLib.StdCtrls"].TLineSpacingPicker.$create("Create$1",[this]);
      this.FLineSpacing.SetName(this.FBtnID + "_linespacing");
      this.FLineSpacing.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FLineSpacing.SetParent(this);
      this.FLineSpacing.SetWidth(40);
      this.FLineSpacing.SetItemIndex(0);
      this.FLineSpacing.SetShowHint(true);
      this.FLineSpacing.SetHint(this.FHints.Get(13));
      this.FLineSpacing.FOnChange = rtl.createCallback(this,"LineSpacingChange");
      this.FFilePicker = document.createElement("INPUT");
      this.FFilePicker.setAttribute("type","file");
      this.FFilePicker.style.setProperty("visibility","hidden");
      this.FFilePicker.addEventListener("change",this.FPtrFileLoad);
      this.GetElementHandle().appendChild(this.FFilePicker);
      this.CreateButton({p: this, get: function () {
          return this.p.FImage;
        }, set: function (v) {
          this.p.FImage = v;
        }},this.FBtnID + "_image","&#xE3f4;",this.FHints.Get(12));
      this.CreateButton({p: this, get: function () {
          return this.p.FURL;
        }, set: function (v) {
          this.p.FURL = v;
        }},this.FBtnID + "_url","&#xE250;",this.FHints.Get(11));
      this.CreateButton({p: this, get: function () {
          return this.p.FUList;
        }, set: function (v) {
          this.p.FUList = v;
        }},this.FBtnID + "_ulist","&#xE241;",this.FHints.Get(10));
      this.CreateButton({p: this, get: function () {
          return this.p.FOList;
        }, set: function (v) {
          this.p.FOList = v;
        }},this.FBtnID + "_olist","&#xE242;",this.FHints.Get(9));
      this.CreateButton({p: this, get: function () {
          return this.p.FAlignRight;
        }, set: function (v) {
          this.p.FAlignRight = v;
        }},this.FBtnID + "_alignright","&#xE237;",this.FHints.Get(8));
      this.CreateButton({p: this, get: function () {
          return this.p.FAlignCenter;
        }, set: function (v) {
          this.p.FAlignCenter = v;
        }},this.FBtnID + "_aligncenter","&#xE234;",this.FHints.Get(7));
      this.CreateButton({p: this, get: function () {
          return this.p.FAlignLeft;
        }, set: function (v) {
          this.p.FAlignLeft = v;
        }},this.FBtnID + "_alignleft","&#xE236;",this.FHints.Get(6));
      this.FBkClr = pas["WEBLib.StdCtrls"].TWebColorPicker.$create("Create$1",[this]);
      this.FBkClr.SetName(this.FBtnID + "_bkclr");
      this.FBkClr.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FBkClr.SetParent(this);
      this.FBkClr.SetHint(this.FHints.Get(5));
      this.FBkClr.SetWidth(32);
      this.FBkClr.SetHeight(24);
      this.FBkClr.SetColor$1(16777215);
      this.FBkClr.FOnSelect = rtl.createCallback(this,"BkSelect");
      this.FBkClr.SetShowHint(true);
      this.FFgClr = pas["WEBLib.StdCtrls"].TWebColorPicker.$create("Create$1",[this]);
      this.FFgClr.SetName(this.FBtnID + "_fgclr");
      this.FFgClr.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FFgClr.SetParent(this);
      this.FFgClr.SetHint(this.FHints.Get(4));
      this.FFgClr.SetWidth(32);
      this.FFgClr.SetHeight(24);
      this.FFgClr.SetColor$1(0);
      this.FFgClr.FOnSelect = rtl.createCallback(this,"FgSelect");
      this.FFgClr.SetShowHint(true);
      this.CreateButton({p: this, get: function () {
          return this.p.FStrikeThrough;
        }, set: function (v) {
          this.p.FStrikeThrough = v;
        }},this.FBtnID + "_strikethrough","&#xE257;",this.FHints.Get(3));
      this.CreateButton({p: this, get: function () {
          return this.p.FUnderline;
        }, set: function (v) {
          this.p.FUnderline = v;
        }},this.FBtnID + "_underline","&#xE249;",this.FHints.Get(2));
      this.CreateButton({p: this, get: function () {
          return this.p.FItalic;
        }, set: function (v) {
          this.p.FItalic = v;
        }},this.FBtnID + "_italic","&#xE23F;",this.FHints.Get(1));
      this.CreateButton({p: this, get: function () {
          return this.p.FBold;
        }, set: function (v) {
          this.p.FBold = v;
        }},this.FBtnID + "_bold","&#xE238;",this.FHints.Get(0));
      this.FFntSize = pas["WEBLib.StdCtrls"].TFontSizePicker.$create("Create$1",[this]);
      this.FFntSize.SetName(this.FBtnID + "_fontsize");
      this.FFntSize.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FFntSize.SetParent(this);
      this.FFntSize.SetWidth(50);
      this.FFntSize.SetPickerMode(pas["WEBLib.StdCtrls"].TFontSizePickerMode.fmRelativeSize);
      this.FFntSize.SetItemIndex(0);
      this.FFntSize.FOnChange = rtl.createCallback(this,"FntSizeChange");
      this.FFnt = pas["WEBLib.StdCtrls"].TFontPicker.$create("Create$1",[this]);
      this.FFnt.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FFnt.SetName(this.FBtnID + "_fontname");
      this.FFnt.SetParent(this);
      this.FFnt.SetWidth(150);
      this.FFnt.SetItemIndex(0);
      this.FFnt.FOnChange = rtl.createCallback(this,"FntChange");
    };
    this.Destroy = function () {
      rtl.free(this,"FHints");
      if (this.FRichEdit != null) this.FRichEdit.FOnAttributesChanged = null;
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",4,{Default: 16777215});
    $r.addProperty("Hints",2,pas.Classes.$rtti["TStrings"],"FHints","SetHints");
    $r.addProperty("RichEdit",3,pas["WEBLib.ComCtrls"].$rtti["TRichEdit"],"GetRichEdit","SetRichEdit");
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor",4,{Default: 0});
    $r.addProperty("VisibleButtons",2,$mod.$rtti["TRichEditButtonSet"],"FVisibleButtons","SetVisibleButtons");
    $r.addProperty("OnSpeedButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSpeedButtonClick","FOnSpeedButtonClick");
  });
  rtl.createClass(this,"TWebRichEditToolBar",this.TRichEditToolBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TToggleButtonStyle = {"0": "tsRectangular", tsRectangular: 0, "1": "tsRounded", tsRounded: 1};
  this.$rtti.$Enum("TToggleButtonStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TToggleButtonStyle});
  rtl.createClass(this,"TToggleButton",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FChecked = false;
      this.FLabel = null;
      this.FInput = null;
      this.FSlider = null;
      this.FStyle = 0;
    };
    this.$final = function () {
      this.FLabel = undefined;
      this.FInput = undefined;
      this.FSlider = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        this.UpdateElement();
      };
    };
    this.GetChecked = function () {
      var Result = false;
      if (this.GetContainer() != null) this.FChecked = this.FInput.checked;
      Result = this.FChecked;
      return Result;
    };
    this.SetChecked = function (Value) {
      this.FChecked = Value;
      this.UpdateElement();
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      this.StopPropagation();
      if (Event.target === this.FInput) {
        if (this.FOnClick != null) this.FOnClick(this);
      };
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (!this.IsUpdating() && (this.FLabel != null)) {
        this.UpdateCSS();
        this.InjectCSS();
        this.FLabel.setAttribute("class",this.FName + "_switch");
        this.FInput.checked = this.FChecked;
        if (this.FStyle === $mod.TToggleButtonStyle.tsRectangular) {
          this.FSlider.setAttribute("class",this.FName + "_slider")}
         else this.FSlider.setAttribute("class",this.FName + "_slider round");
      };
    };
    this.UpdateCSS = function () {
      var css = "";
      var wpx = "";
      var hpx = "";
      var hwpx = "";
      var wspx = "";
      var hspx = "";
      wpx = pas.SysUtils.TIntegerHelper.ToString$1.call({p: this.GetWidth(), get: function () {
          return this.p;
        }, set: function (v) {
          this.p = v;
        }}) + "px";
      hpx = pas.SysUtils.TIntegerHelper.ToString$1.call({p: this.GetHeight(), get: function () {
          return this.p;
        }, set: function (v) {
          this.p = v;
        }}) + "px";
      hwpx = pas.SysUtils.TIntegerHelper.ToString$1.call({a: rtl.trunc(this.GetWidth() / 2), get: function () {
          return this.a;
        }, set: function (v) {
          this.a = v;
        }}) + "px";
      wspx = pas.SysUtils.TIntegerHelper.ToString$1.call({a: rtl.trunc(this.GetWidth() / 2) - 8, get: function () {
          return this.a;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "px";
      hspx = pas.SysUtils.TIntegerHelper.ToString$1.call({a: this.GetHeight() - 8, get: function () {
          return this.a;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "px";
      css = "." + this.FName + "_switch {" + "position: relative;" + "display: inline-block;" + "width: " + wpx + ";" + "height: " + hpx + ";" + "}" + ".switch input {display:none;}" + "." + this.FName + "_slider {" + "position: absolute;" + "cursor: pointer;" + "top: 0;" + "left: 0;" + "right: 0;" + "bottom: 0;" + "background-color: #ccc;" + "-webkit-transition: .4s;" + "transition: .4s;" + "}" + "." + this.FName + "_slider:before {" + "position: absolute;" + 'content: "";' + "height: " + hspx + ";" + "width: " + wspx + ";" + "left: 4px;" + "bottom: 4px;" + "background-color: white;" + "-webkit-transition: .4s;" + "transition: .4s;" + "}" + "input:checked + ." + this.FName + "_slider {" + "background-color: #2196F3;" + "}" + "input:focus + ." + this.FName + "_slider {" + "box-shadow: 0 0 1px #2196F3;" + "}" + "input:checked + ." + this.FName + "_slider:before {" + "-webkit-transform: translateX(" + hwpx + ");" + "-ms-transform: translateX(" + hwpx + ");" + "transform: translateX(" + hwpx + ");" + "}" + "/* Rounded sliders */" + "." + this.FName + "_slider.round {" + "border-radius: " + wspx + ";" + "}" + "." + this.FName + "_slider.round:before {" + "border-radius: 50%;" + "}";
      this.AddInstanceStyle(css);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("span");
      this.FLabel = document.createElement("label");
      this.FInput = document.createElement("input");
      this.FSlider = document.createElement("span");
      this.FInput.setAttribute("type","checkbox");
      this.FInput.style.setProperty("display","none");
      Result.appendChild(this.FLabel);
      this.FLabel.appendChild(this.FInput);
      this.FLabel.appendChild(this.FSlider);
      return Result;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.Resize = function () {
      pas["WEBLib.Controls"].TCustomControl.Resize.call(this);
      this.UpdateCSS();
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetWidth(48);
      this.SetHeight(24);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Style",2,$mod.$rtti["TToggleButtonStyle"],"FStyle","SetStyle",4,{Default: $mod.TToggleButtonStyle.tsRectangular});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebToggleButton",this.TToggleButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TRichEditorCracker",pas["WEBLib.ComCtrls"].TRichEdit,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
},["WEBLib.WebTools","Math"]);
rtl.module("WEBLib.ComCtrls",["System","Classes","SysUtils","Web","WEBLib.Controls","WEBLib.Graphics","WEBLib.ExtCtrls","WEBLib.TreeNodes","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TCustomRichEdit");
  rtl.createClass(this,"TTextAttributes",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.RichEdit = null;
      this.FAlignment = 0;
      this.FIsBold = false;
      this.FIsItalic = false;
      this.FIsUnderline = false;
      this.FIsStrikeOut = false;
      this.FBackColor = 0;
      this.FColor = 0;
      this.FHeight = 0;
      this.FName = "";
      this.FOrderedList = false;
      this.FSize = 0;
      this.FStyle = {};
      this.FUnOrderedList = false;
    };
    this.$final = function () {
      this.RichEdit = undefined;
      this.FStyle = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetAlignment = function (Value) {
      this.FAlignment = Value;
      var $tmp = this.FAlignment;
      if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
        this.RichEdit.DoEditAction("justifyleft")}
       else if ($tmp === pas.Classes.TAlignment.taCenter) {
        this.RichEdit.DoEditAction("justifycenter")}
       else if ($tmp === pas.Classes.TAlignment.taRightJustify) this.RichEdit.DoEditAction("justifyright");
    };
    this.SetBackColor = function (Value) {
      this.FColor = Value;
      this.RichEdit.DoEditAction$1("hiliteColor",pas["WEBLib.Graphics"].ColorToHTML(Value));
    };
    this.SetColor = function (Value) {
      this.FColor = Value;
      this.RichEdit.DoEditAction$1("foreColor",pas["WEBLib.Graphics"].ColorToHTML(Value));
    };
    this.SetHeight = function (Value) {
      var eh = null;
      var fs = "";
      if ((Value > 0) && (Value < 8)) {
        this.FSize = Value;
        this.FHeight = Value;
        fs = pas.SysUtils.IntToStr(Value);
        this.RichEdit.DoEditAction$1("fontSize",fs);
        fs = this.FontSizeToEM(Value);
        eh = this.RichEdit.GetElementHandle();
        var selection = window.getSelection();
        if (selection.rangeCount > 0) {
          var range = selection.getRangeAt(0);
          const selectedElements = eh.querySelectorAll('*');
          selectedElements.forEach(element => {
            if (range.intersectsNode(element)) {
              if (element.tagName == "LI") {
                element.style.setProperty("font-size",fs);
              }
            }
          });
        };
      };
    };
    this.SetName = function (Value) {
      this.FName = Value;
      this.RichEdit.DoEditAction$1("fontName",Value);
    };
    this.SetOrderedList = function (Value) {
      if (this.FOrderedList !== Value) this.RichEdit.DoEditAction("insertorderedlist");
      this.FOrderedList = Value;
    };
    this.SetSize = function (Value) {
      if ((Value > 0) && (Value < 8)) {
        this.FSize = Value;
        this.FHeight = Value;
        this.RichEdit.DoEditAction$1("fontSize",pas.SysUtils.IntToStr(Value));
        var selection = window.getSelection();
      };
    };
    this.SetStyle = function (Value) {
      this.FStyle = rtl.refSet(Value);
      if ((pas["WEBLib.Graphics"].TFontStyle.fsBold in this.FStyle) && !this.FIsBold) {
        this.RichEdit.DoEditAction("bold");
        this.FIsBold = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsBold in this.FStyle) && this.FIsBold) {
        this.RichEdit.DoEditAction("bold");
        this.FIsBold = false;
      };
      if ((pas["WEBLib.Graphics"].TFontStyle.fsItalic in this.FStyle) && !this.FIsItalic) {
        this.RichEdit.DoEditAction("italic");
        this.FIsItalic = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsItalic in this.FStyle) && this.FIsItalic) {
        this.RichEdit.DoEditAction("italic");
        this.FIsItalic = false;
      };
      if ((pas["WEBLib.Graphics"].TFontStyle.fsUnderline in this.FStyle) && !this.FIsUnderline) {
        this.RichEdit.DoEditAction("underline");
        this.FIsUnderline = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsUnderline in this.FStyle) && this.FIsUnderline) {
        this.RichEdit.DoEditAction("underline");
        this.FIsUnderline = false;
      };
      if ((pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in this.FStyle) && !this.FIsStrikeOut) {
        this.RichEdit.DoEditAction("strikethrough");
        this.FIsStrikeOut = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in this.FStyle) && this.FIsStrikeOut) {
        this.RichEdit.DoEditAction("strikethrough");
        this.FIsStrikeOut = false;
      };
    };
    this.SetUnOrderedList = function (Value) {
      if (this.FUnOrderedList !== Value) this.RichEdit.DoEditAction("insertunorderedlist");
      this.FUnOrderedList = Value;
    };
    this.AssignTo = function (Dest) {
      if (pas["WEBLib.Graphics"].TFont.isPrototypeOf(Dest)) {
        Dest.SetColor(this.FColor);
        Dest.SetName(this.FName);
        Dest.SetStyle(rtl.refSet(this.FStyle));
        Dest.SetSize(this.FSize);
      } else if ($mod.TTextAttributes.isPrototypeOf(Dest)) {
        Dest.SetColor(this.FColor);
        Dest.SetName(this.FName);
        Dest.SetStyle(rtl.refSet(this.FStyle));
      } else pas.Classes.TPersistent.AssignTo.call(this,Dest);
    };
    this.FontSizeToEM = function (Value) {
      var Result = "";
      Result = "0.63";
      var $tmp = Value;
      if ($tmp === 1) {
        Result = "0.63em"}
       else if ($tmp === 2) {
        Result = "0.82em"}
       else if ($tmp === 3) {
        Result = "1.0em"}
       else if ($tmp === 4) {
        Result = "1.13em"}
       else if ($tmp === 5) {
        Result = "1.5em"}
       else if ($tmp === 6) {
        Result = "2em"}
       else if ($tmp === 7) Result = "3em";
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.RichEdit = AOwner;
      this.FAlignment = pas.Classes.TAlignment.taLeftJustify;
      this.FIsBold = false;
      this.FIsItalic = false;
      this.FIsUnderline = false;
      this.FIsStrikeOut = false;
      this.FOrderedList = false;
      this.FUnOrderedList = false;
      return this;
    };
    this.Assign = function (Source) {
      if (pas["WEBLib.Graphics"].TFont.isPrototypeOf(Source)) {
        this.SetColor(Source.FColor);
        this.SetName(Source.FName);
        this.SetStyle(rtl.refSet(Source.FStyle));
        this.SetSize(Source.FSize);
      } else if ($mod.TTextAttributes.isPrototypeOf(Source)) {
        this.SetColor(Source.FColor);
        this.SetName(Source.FName);
        this.SetStyle(rtl.refSet(Source.FStyle));
        this.SetSize(Source.FSize);
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.Cut = function () {
      this.RichEdit.DoEditAction("cut");
    };
    this.Copy = function () {
      this.RichEdit.DoEditAction("copy");
    };
    this.Paste = function () {
      this.RichEdit.DoEditAction("paste");
    };
    this.Image = function () {
      this.RichEdit.DoImageAction();
    };
    this.Link = function () {
      this.RichEdit.DoLinkAction();
    };
  });
  rtl.recNewT(this,"TSelAttributes",function () {
    this.FontName = "";
    this.FontSize = "";
    this.FontColor = "";
    this.BkColor = "";
    this.IsBold = false;
    this.IsItalic = false;
    this.IsStrikeOut = false;
    this.IsUnderline = false;
    this.IsLeft = false;
    this.IsRight = false;
    this.IsCenter = false;
    this.$eq = function (b) {
      return (this.FontName === b.FontName) && (this.FontSize === b.FontSize) && (this.FontColor === b.FontColor) && (this.BkColor === b.BkColor) && (this.IsBold === b.IsBold) && (this.IsItalic === b.IsItalic) && (this.IsStrikeOut === b.IsStrikeOut) && (this.IsUnderline === b.IsUnderline) && (this.IsLeft === b.IsLeft) && (this.IsRight === b.IsRight) && (this.IsCenter === b.IsCenter);
    };
    this.$assign = function (s) {
      this.FontName = s.FontName;
      this.FontSize = s.FontSize;
      this.FontColor = s.FontColor;
      this.BkColor = s.BkColor;
      this.IsBold = s.IsBold;
      this.IsItalic = s.IsItalic;
      this.IsStrikeOut = s.IsStrikeOut;
      this.IsUnderline = s.IsUnderline;
      this.IsLeft = s.IsLeft;
      this.IsRight = s.IsRight;
      this.IsCenter = s.IsCenter;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSelAttributes",{},this);
    $r.addField("FontName",rtl.string);
    $r.addField("FontSize",rtl.string);
    $r.addField("FontColor",rtl.string);
    $r.addField("BkColor",rtl.string);
    $r.addField("IsBold",rtl.boolean);
    $r.addField("IsItalic",rtl.boolean);
    $r.addField("IsStrikeOut",rtl.boolean);
    $r.addField("IsUnderline",rtl.boolean);
    $r.addField("IsLeft",rtl.boolean);
    $r.addField("IsRight",rtl.boolean);
    $r.addField("IsCenter",rtl.boolean);
  });
  this.$rtti.$MethodVar("TAttributesChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Attributes",this.$rtti["TSelAttributes"]]]), methodkind: 0});
  rtl.createClass(this,"TCustomRichEdit",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FOwner$1 = null;
      this.FLines = null;
      this.FSelAttributes = null;
      this.FAutoSize = false;
      this.FOnSelectionChange = null;
      this.FShowFocus$1 = false;
      this.FInsertLineBreaks = false;
      this.FWantTabs = false;
      this.FReadOnly = false;
      this.FOnChange = null;
      this.FOnAttributesChanged = null;
      this.FWantImages = false;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FLines = undefined;
      this.FSelAttributes = undefined;
      this.FOnSelectionChange = undefined;
      this.FOnChange = undefined;
      this.FOnAttributesChanged = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      if (this.GetElementHandle() != null) this.FLines.SetTextStr(this.GetElementHandle().innerHTML);
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.GetPlainText = function () {
      var Result = "";
      Result = "";
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().innerText;
      return Result;
    };
    this.SetText = function (Value) {
      this.FLines.SetTextStr(Value);
      this.UpdateElement();
    };
    this.SetSelAttributes = function (Value) {
      this.FSelAttributes.Assign(Value);
    };
    this.SetAutoSize = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateElement();
      };
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        if (this.GetElementHandle() != null) {
          if (this.FReadOnly) {
            this.GetElementHandle().contentEditable = "false"}
           else this.GetElementHandle().contentEditable = "true";
        };
      };
    };
    this.GetLines = function () {
      var Result = null;
      Result = this.FLines;
      return Result;
    };
    this.GetSelStart = function () {
      var Result = 0;
      var res = 0;
      var el = null;
      el = this.GetElementHandle();
      const selection = window.getSelection();
      const range = selection.getRangeAt(0);
      const preSelectionRange = range.cloneRange();
      preSelectionRange.selectNodeContents(el);
      preSelectionRange.setEnd(range.startContainer, range.startOffset);
      res = preSelectionRange.toString().length;
      Result = res;
      return Result;
    };
    this.SetSelStart = function (Value) {
      var el = null;
      el = this.GetElementHandle();
      const range = document.createRange();
          const sel = window.getSelection();
      
          var i = 0;
          while (i < el.childNodes.length) {
            if (Value <=el.childNodes[i].textContent.length) {
              range.setStart(el.childNodes[i], Value);
            }
            else {
               Value = Value - el.childNodes[i].textContent.length;
            }
            i++;
          }
          range.collapse(true);
          sel.removeAllRanges();
          sel.addRange(range);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      Result.style.setProperty("white-space","normal");
      return Result;
    };
    this.ElementIFrameHandle = function () {
      var Result = null;
      Result = null;
      if (this.GetElementHandle() != null) {
        Result = document;
      };
      return Result;
    };
    this.UpdateElement = function () {
      var i = 0;
      var s = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.ElementIFrameHandle() != null) ;
      if (this.GetElementHandle() != null) {
        s = "";
        for (var $l = 0, $end = this.FLines.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (i > 0) s = s + "<br>";
          s = s + this.FLines.Get(i);
        };
        this.GetElementHandle().innerHTML = s;
        if (this.FReadOnly) {
          this.GetElementHandle().contentEditable = "false"}
         else this.GetElementHandle().contentEditable = "true";
        this.GetElementHandle().style.setProperty("overflow","auto");
        this.GetElementHandle().style.setProperty("padding","3px");
        if (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) {
          this.GetElementHandle().style.setProperty("border","1px solid silver")}
         else this.GetElementHandle().style.setProperty("border","");
      };
    };
    this.Loaded = function () {
      var doc = null;
      var el = null;
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.ElementIFrameHandle() != null) {
        doc = this.ElementIFrameHandle();
        el = this.GetElementHandle();
        el.onclick = rtl.createSafeCallback(this,"HandleDoClick");
        el.ondblclick = rtl.createSafeCallback(this,"HandleDoDblClick");
        el.addEventListener("mousedown",rtl.createSafeCallback(this,"HandleDoMouseDown"));
        el.addEventListener("mouseup",rtl.createSafeCallback(this,"HandleDoMouseUp"));
        el.addEventListener("mousemove",rtl.createSafeCallback(this,"HandleDoMouseMove"));
        el.addEventListener("keydown",rtl.createSafeCallback(this,"HandleDoKeyDown"));
        el.addEventListener("keyup",rtl.createSafeCallback(this,"HandleDoKeyUp"));
        el.addEventListener("keypress",rtl.createSafeCallback(this,"HandleDoKeyPress"));
        el.onfocus = rtl.createSafeCallback(this,"HandleDoEnter");
        el.onblur = rtl.createSafeCallback(this,"HandleDoExit");
        doc.onselectionchange = rtl.createSafeCallback(this,"HandleDoSelectionChange");
      };
    };
    this.SetShowFocus$1 = function (Value) {
      if (this.FShowFocus$1 !== Value) {
        this.FShowFocus$1 = Value;
        this.UpdateElement();
      };
    };
    this.CanShowFocus = function () {
      var Result = false;
      Result = this.FShowFocus$1;
      return Result;
    };
    this.DoHandleInput = function (Event) {
      this.DoChange();
    };
    this.DoHandlePaste = function (Event) {
      if (this.FWantImages) return;
      var pastedData = Event.clipboardData.getData('text');
      var regex = /^[a-zA-Z0-9@  `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
      if (regex.test(pastedData) !== true) {
              Event.preventDefault();
      };
    };
    this.HandleDoSelectionChange = function (Event) {
      var Result = false;
      var Attr = $mod.TSelAttributes.$new();
      if (this.FOwner$1 != null) {
        rtl.as(this.FOwner$1,pas["WEBLib.Buttons"].TRichEditToolBar).SetTextColor(0x1);
        rtl.as(this.FOwner$1,pas["WEBLib.Buttons"].TRichEditToolBar).SetBackgroundColor(0x1);
      };
      Attr.$assign(this.GetSelectionAttributes(document.getSelection()));
      this.FSelAttributes.SetStyle({});
      if (Attr.IsBold) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)));
      if (Attr.IsItalic) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)));
      if (Attr.IsUnderline) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
      if (Attr.IsStrikeOut) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)));
      if (this.FOnSelectionChange != null) this.FOnSelectionChange(this);
      Result = true;
      return Result;
    };
    this.HandleDoKeyDown = function (Event) {
      var Result = false;
      var AEvent = null;
      Result = false;
      AEvent = Event;
      if ((AEvent.ctrlKey === true) && (AEvent.key === "Control") && this.FReadOnly) {
        this.GetElementHandle().contentEditable = "false";
      };
      if ((this.GetKeyCode(AEvent.key,true) === 13) && this.FInsertLineBreaks) {
        this.InsertHTML("<br>")}
       else if ((this.GetKeyCode(AEvent.key,true) === 9) && this.FWantTabs) {
        this.InsertHTML("<span style=white-space:pre>&#9;</span>")}
       else {
        Result = true;
      };
      pas["WEBLib.Controls"].TControl.HandleDoKeyDown.apply(this,arguments);
      return Result;
    };
    this.HandleDoKeyUp = function (Event) {
      var Result = false;
      var AEvent = null;
      Result = false;
      AEvent = Event;
      if ((AEvent.ctrlKey === false) && (AEvent.key === "Control") && !this.FReadOnly) {
        this.GetElementHandle().contentEditable = "true";
      };
      pas["WEBLib.Controls"].TControl.HandleDoKeyUp.apply(this,arguments);
      return Result;
    };
    this.SetLines = function (ALines) {
      this.FLines.Assign(ALines);
    };
    this.DoLinesChange = function (Sender) {
      this.UpdateElement();
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.GetContainer().addEventListener("input",rtl.createSafeCallback(this,"DoHandleInput"));
      this.GetContainer().addEventListener("paste",rtl.createSafeCallback(this,"DoHandlePaste"));
    };
    this.GetSelectionAttributes = function (selnode) {
      var Result = $mod.TSelAttributes.$new();
      var el = null;
      var fn = "";
      var fs = "";
      var fc = "";
      var fbk = "";
      var found = false;
      var Attr = $mod.TSelAttributes.$new();
      el = null;
      if (selnode.focusNode) {
        el = selnode.focusNode.parentElement;
      };
      do {
        found = false;
        if (el != null) {
          if (el.tagName === "B") {
            found = true;
            Attr.IsBold = true;
          };
          if (el.tagName === "I") {
            found = true;
            Attr.IsItalic = true;
          };
          if (el.tagName === "U") {
            found = true;
            Attr.IsUnderline = true;
          };
          if (el.tagName === "STRIKE") {
            found = true;
            Attr.IsStrikeOut = true;
          };
          if (el.tagName === "SPAN") {
            fbk = el.style.getPropertyValue("background-color");
            if (fbk == null) {
            fbk = ''; };
            Attr.BkColor = fbk;
            found = true;
          };
          if (el.tagName === "DIV") {
            fbk = el.style.getPropertyValue("text-align");
            if (fbk == null) {
            fbk = ''; };
            if (fbk === "center") Attr.IsCenter = true;
            if (fbk === "right") Attr.IsRight = true;
            if (fbk === "left") Attr.IsLeft = true;
            found = true;
          };
          if (el.tagName === "FONT") {
            fn = el.getAttribute("face");
            if (fn == null) {
            fn = ''; };
            fs = el.getAttribute("size");
            if (fs == null) {
            fs = ''; };
            fc = el.getAttribute("color");
            if (fc == null) {
            fc = ''; };
            fbk = el.style.getPropertyValue("background-color");
            if (fbk == null) {
            fbk = ''; };
            found = true;
            Attr.FontName = fn;
            Attr.FontColor = fc;
            if (fs !== "") {
              if (fs === "7") fs = "36";
              if (fs === "6") fs = "24";
              if (fs === "5") fs = "18";
              if (fs === "4") fs = "14";
              if (fs === "3") fs = "10";
              if (fs === "2") fs = "9";
              if (fs === "1") fs = "8";
            };
            Attr.FontSize = fs;
            Attr.BkColor = fbk;
          };
          el = el.parentElement;
          if (el === this.GetElementHandle()) found = false;
        };
      } while (found);
      Result.$assign(Attr);
      if (this.FOnAttributesChanged != null) this.FOnAttributesChanged(this,$mod.TSelAttributes.$clone(Attr));
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FLines = pas.Classes.TStringList.$create("Create$1");
      this.FLines.FOnChange = rtl.createCallback(this,"DoLinesChange");
      this.FSelAttributes = $mod.TTextAttributes.$create("Create$1",[this]);
      this.FShowFocus$1 = true;
      this.FWantImages = true;
      this.FInsertLineBreaks = false;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FLines");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.GetContent = function () {
      var Result = "";
      Result = this.GetText();
      return Result;
    };
    this.GetSelection = function () {
      var Result = "";
      var res = "";
      res = "";
      // window.getSelection() gives you a Selection object representing the range of text selected by the user or the current position of the caret.
      if (window.getSelection) {
        res = window.getSelection().toString();
      };
      Result = res;
      return Result;
    };
    this.DoSelectAction = function (StartPosition, EndPosition) {
      var s = "";
      var sstart = 0;
      var send = 0;
      var el = null;
      var range = null;
      var textNodes = null;
      var textNode = null;
      var i = 0;
      var foundStart = false;
      var charCount = 0;
      var endCharCount = 0;
      var sel = null;
      s = this.GetID();
      sstart = StartPosition;
      send = EndPosition;
      el = document.getElementById(s);
      if (el != null) {
        range = document.createRange();
        range.selectNodeContents(el);
        textNodes = pas.Classes.TList.$create("Create$1");
        $impl.GetTextNodes(el,textNodes);
        foundStart = false;
        charCount = 0;
        endCharCount = 0;
        for (var $l = 0, $end = textNodes.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          textNode = textNodes.Get(i);
          endCharCount = charCount + textNode.nodeValue.length;
          if (!foundStart && (sstart >= charCount) && ((sstart < endCharCount) || ((sstart === endCharCount) && (i <= textNodes.GetCount())))) {
            range.setStart(textNode,sstart - charCount);
            foundStart = true;
          };
          if (foundStart && (send <= endCharCount)) {
            range.setEnd(textNode,send - charCount);
            break;
          };
          charCount = endCharCount;
        };
        sel = document.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
        textNodes = rtl.freeLoc(textNodes);
      };
    };
    this.DoEditAction = function (ActionString) {
      if (this.ElementIFrameHandle() != null) {
        this.ElementIFrameHandle().execCommand(ActionString,false);
      };
    };
    this.DoEditAction$1 = function (ActionString, Data) {
      if (this.ElementIFrameHandle() != null) {
        this.ElementIFrameHandle().execCommand(ActionString,false,Data);
      };
    };
    this.SelectText = function (StartPosition, EndPosition) {
      this.DoSelectAction(StartPosition,EndPosition);
    };
    this.SetSelectionSpacing = function (ASpacing) {
      var $Self = this;
      var sel = null;
      var range = null;
      var node = null;
      var pNode = null;
      var i = 0;
      var lh = "";
      function getNextNode(anode) {
        var Result = null;
        if (anode.firstChild != null) {
          Result = anode.firstChild}
         else while (anode != null) {
          if (anode.nextSibling != null) {
            Result = anode.nextSibling;
            break;
          };
          anode = anode.parentNode;
        };
        return Result;
      };
      sel = document.getSelection();
      if (!(sel != null)) return;
      lh = pas["WEBLib.Utils"].FormatProp("%g",pas.System.VarRecs(3,ASpacing));
      for (var $l = 0, $end = sel.rangeCount - 1; $l <= $end; $l++) {
        i = $l;
        range = sel.getRangeAt(i);
        node = range.startContainer;
        if (node.nodeName === "#text") {
          pNode = node.parentNode;
          if (pNode.nodeName === "DIV") pNode.style.setProperty("line-height",lh);
        };
        while (node !== range.endContainer) {
          node = getNextNode(node);
          if (node.nodeName === "DIV") node.style.setProperty("line-height",lh);
        };
      };
    };
    this.DoImageAction = function () {
      var url = "";
      if (this.GetElementHandle() != null) {
        url = window.prompt("Enter Image URL:","http://");
        if (pas.System.Assigned(url)) {
          if ((url !== "") && (url !== "http://") && (url !== "https://")) this.DoEditAction$1("insertImage",url);
        };
      };
    };
    this.DoLinkAction = function () {
      var url = "";
      if (this.GetElementHandle() != null) {
        url = window.prompt("Enter URL:","http://");
        if (pas.System.Assigned(url)) {
          if ((url !== "") && (url !== "http://") && (url !== "https://")) this.DoEditAction$1("createLink",url);
        };
      };
    };
    this.AppendHTML = function (HTML) {
      var sel = null;
      var range = null;
      var el = null;
      var frag = null;
      var node = null;
      var lastNode = null;
      sel = null;
      if (this.Focused()) {
        sel = document.getSelection();
        range = sel.getRangeAt(0);
        range.deleteContents();
      } else {
        range = document.createRange();
        node = this.GetElementHandle().firstChild;
        lastNode = node;
        while (node != null) {
          node = node.nextSibling;
          if (node != null) lastNode = node;
        };
        if (lastNode != null) {
          range.setStartAfter(lastNode);
          range.setEndAfter(lastNode);
        } else {
          range.setStart(this.GetElementHandle(),0);
          range.setEnd(this.GetElementHandle(),0);
        };
      };
      el = document.createElement("div");
      el.innerHTML = HTML;
      frag = document.createDocumentFragment();
      node = el.firstChild;
      while (node === el.firstChild) {
        lastNode = frag.appendChild(node);
        range.insertNode(frag);
      };
      if (lastNode != null) {
        range = range.cloneRange();
        range.setStartAfter(lastNode);
        range.collapse();
        if (sel != null) {
          sel.removeAllRanges();
          sel.addRange(range);
        };
      };
    };
    this.AppendLineBreak = function () {
      this.AppendHTML("<BR>");
    };
    this.InsertHTML = function (HTML) {
      var sel = null;
      var range = null;
      var el = null;
      var frag = null;
      var node = null;
      var lastNode = null;
      sel = null;
      if (this.Focused()) {
        sel = document.getSelection();
        range = sel.getRangeAt(0);
        range.deleteContents();
      } else {
        range = document.createRange();
        range.setStart(this.GetElementHandle(),0);
        range.setEnd(this.GetElementHandle(),0);
      };
      el = document.createElement("div");
      el.innerHTML = HTML;
      frag = document.createDocumentFragment();
      node = el.firstChild;
      while (node === el.firstChild) {
        lastNode = frag.appendChild(node);
        range.insertNode(frag);
      };
      if (lastNode != null) {
        range = range.cloneRange();
        range.setStartAfter(lastNode);
        range.collapse();
        if (sel != null) {
          sel.removeAllRanges();
          sel.addRange(range);
        };
      };
    };
    this.InsertLineBreak = function () {
      this.InsertHTML("<BR>");
    };
    this.InsertImage = function (DataURL) {
      this.DoEditAction$1("insertImage",DataURL);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TRichEdit",this.TCustomRichEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("InsertLineBreaks",0,rtl.boolean,"FInsertLineBreaks","FInsertLineBreaks",4,{Default: false});
    $r.addProperty("Lines",3,pas.Classes.$rtti["TStrings"],"GetLines","SetLines");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WantTabs",0,rtl.boolean,"FWantTabs","FWantTabs",4,{Default: false});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnSelectionChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSelectionChange","FOnSelectionChange");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebRichEdit",this.TRichEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTabSet",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FSelectedColor = 0;
      this.FOnChange = null;
      this.FSelectedTextColor = 0;
      this.FElementTabActiveClassName = "";
      this.FElementTabClassName = "";
      this.FElementTabItemClassName = "";
      this.FUseHash = false;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetSelectedColor = function (Value) {
      if (this.FSelectedColor !== Value) {
        this.FSelectedColor = Value;
        this.DoUpdateList();
      };
    };
    this.SetSelectedTextColor = function (Value) {
      if (this.FSelectedColor !== Value) {
        this.FSelectedTextColor = Value;
        this.DoUpdateList();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      var sid = "";
      var cid = "";
      var i = 0;
      var el = null;
      el = Event.target;
      sid = "";
      if (el.hasAttribute("id")) sid = el.getAttribute("id");
      if (sid !== "") {
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        sid = pas.SysUtils.StringReplace(sid,cid + "_","",{});
        if (pas.SysUtils.TryStrToInt(sid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          this.FItemIndex = i;
          this.DoUpdateList();
        };
        pas["WEBLib.Controls"].TControl.HandleDoClick.apply(this,arguments);
      };
      Result = true;
      return Result;
    };
    this.HandleDoChange = function (Event) {
      var Result = false;
      if (this.FOnChange != null) this.FOnChange(this);
      Result = true;
      return Result;
    };
    this.HandleDoItemMouseOut = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","");
      };
      return Result;
    };
    this.HandleDoItemMouseOver = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","lightgray");
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().onchange = rtl.createSafeCallback(this,"HandleDoChange");
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetItemIndex = function (AIndex) {
      if (this.FItemIndex !== AIndex) {
        this.FItemIndex = AIndex;
        this.DoUpdateList();
      };
    };
    this.DoUpdateList = function () {
      var i = 0;
      var s = "";
      var cid = "";
      var ul = null;
      var li = null;
      var a = null;
      if (!(this.GetContainer() != null)) return;
      while (this.GetContainer().firstChild != null) this.GetContainer().removeChild(this.GetContainer().firstChild);
      this.GetContainer().setAttribute("class","");
      ul = document.createElement("UL");
      ul.setAttribute("class",this.FElementClassName);
      if (this.FElementClassName !== "") {
        ul.setAttribute("role","tablist")}
       else {
        ul.style.setProperty("list-style-type","none");
        ul.style.setProperty("margin","0");
        ul.style.setProperty("padding","0");
        ul.style.setProperty("display","inline-block");
      };
      this.GetContainer().appendChild(ul);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        s = this.FItems.Get(i);
        li = document.createElement("LI");
        if (this.FElementClassName !== "") {
          if (this.FElementTabItemClassName === "") {
            li.setAttribute("class","nav-item")}
           else li.setAttribute("class",this.FElementTabItemClassName);
        } else {
          li.style.setProperty("float","left");
          li.style.setProperty("border-bottom","1px solid lightgray");
        };
        pas["WEBLib.Controls"].SetHTMLElementFont(li,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
        ul.appendChild(li);
        if (!this.FEnabled) {
          a = document.createElement("SPAN")}
         else {
          a = document.createElement("A");
          if (this.FUseHash) a.setAttribute("href","#" + s);
        };
        a.innerHTML = s;
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        a.setAttribute("id",cid + "_" + pas.SysUtils.IntToStr(i));
        if (this.FElementClassName !== "") {
          if (this.FItemIndex === i) {
            if (this.FElementTabActiveClassName === "") {
              a.setAttribute("class","nav-link active")}
             else a.setAttribute("class",this.FElementTabActiveClassName);
          } else {
            if (this.FElementTabClassName === "") {
              a.setAttribute("class","nav-link")}
             else a.setAttribute("class",this.FElementTabClassName);
          };
          a.setAttribute("role","tab");
          a.setAttribute("data-toggle","tab");
          a.setAttribute("aria-controls",s);
          if (this.FItemIndex === i) {
            a.setAttribute("aria-selected","true")}
           else a.setAttribute("aria-selected","false");
          if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) a.setAttribute("draggable","false");
        } else {
          a.style.setProperty("display","block");
          a.style.setProperty("text-align","center");
          a.style.setProperty("padding","3px 15px");
          a.style.setProperty("text-decoration","none");
          a.style.setProperty("min-width","50px");
          a.style.setProperty("color","inherit");
          a.style.setProperty("font-family","inherit");
          a.style.setProperty("font-style","inherit");
          a.style.setProperty("font-size","inherit");
          if (!this.FEnabled) a.style.setProperty("pointer-events","none");
          if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) a.setAttribute("draggable","false");
          if (this.FItemIndex === i) {
            if (this.FSelectedColor !== -1) a.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedColor));
            if (this.FSelectedTextColor !== -1) a.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedTextColor));
          };
        };
        li.appendChild(a);
      };
      if (!this.GetIsLinked() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.RenderDesigning("TWebTabSet",this.GetContainer(),this,this.FItems.GetCount() === 0,"");
      this.UpdateElement();
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
    };
    this.ItemsChanged = function (Sender) {
      this.DoUpdateList();
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else if (AElement.children.item(I).tagName === "A") {
            AElement.children.item(I).setAttribute("draggable","false")}
           else AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else if (AElement.children.item(I).tagName === "A") {
            AElement.children.item(I).removeAttribute("draggable")}
           else RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"ItemsChanged");
      this.FItemIndex = 0;
      this.FSelectedColor = 12632256;
      this.FSelectedTextColor = 0;
      this.FUseHash = true;
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.Clear = function () {
      this.FItems.Clear();
    };
    this.SelectNextTab = function (GoForward) {
      if (GoForward) {
        if (this.FItemIndex < (this.FItems.GetCount() - 1)) {
          this.SetItemIndex(this.FItemIndex + 1)}
         else this.SetItemIndex(0);
      } else {
        if (this.FItemIndex > 0) {
          this.SetItemIndex(this.FItemIndex - 1)}
         else this.SetItemIndex(this.FItems.GetCount() - 1);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementTabClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabClassName","FElementTabClassName");
    $r.addProperty("ElementTabActiveClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabActiveClassName","FElementTabActiveClassName");
    $r.addProperty("ElementTabItemClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabItemClassName","FElementTabItemClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",2,rtl.longint,"FItemIndex","SetItemIndex");
    $r.addProperty("Items",2,pas.Classes.$rtti["TStringList"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",4,{Default: 12632256});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",4,{Default: 0});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("UseHash",0,rtl.boolean,"FUseHash","FUseHash",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTabSet",this.TTabSet,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTabSheet",pas["WEBLib.ExtCtrls"].TCustomPanel,function () {
    this.$init = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.$init.call(this);
      this.FTabVisible = false;
      this.FTabEnabled = false;
      this.FPosUpdating = false;
      this.FOnShow = null;
      this.FOnHide = null;
      this.FMaterialGlyph = "";
      this.FMaterialGlyphColor = 0;
      this.FMaterialGlyphType = 0;
      this.FMaterialGlyphSize = 0;
    };
    this.$final = function () {
      this.FOnShow = undefined;
      this.FOnHide = undefined;
      pas["WEBLib.ExtCtrls"].TCustomPanel.$final.call(this);
    };
    this.SetTabVisible = function (Value) {
      if (this.FTabVisible !== Value) {
        this.FTabVisible = Value;
        if (this.FParent != null) {
          if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        };
      };
    };
    this.SetTabEnabled = function (Value) {
      if (this.FTabEnabled !== Value) {
        this.FTabEnabled = Value;
        if (this.FParent != null) {
          if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        };
      };
    };
    this.GetPageIndex = function () {
      var Result = 0;
      var i = 0;
      var j = 0;
      var FPageControl = null;
      Result = -1;
      if ($mod.TPageControl.isPrototypeOf(this.FParent)) {
        FPageControl = rtl.as(this.FParent,$mod.TPageControl);
        j = 0;
        for (var $l = 0, $end = FPageControl.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ($mod.TTabSheet.isPrototypeOf(FPageControl.GetControls(i))) {
            if (FPageControl.GetControls(i) === this) {
              Result = j;
            } else j += 1;
          };
        };
      };
      return Result;
    };
    this.SetPageIndex = function (Value) {
    };
    this.SetMaterialGlyph = function (Value) {
      if (this.FMaterialGlyph !== Value) {
        this.FMaterialGlyph = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetMaterialGlyphColor = function (Value) {
      if (this.FMaterialGlyphColor !== Value) {
        this.FMaterialGlyphColor = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetMaterialGlyphSize = function (Value) {
      if (this.FMaterialGlyphSize !== Value) {
        this.FMaterialGlyphSize = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetMaterialGlyphType = function (Value) {
      if (this.FMaterialGlyphType !== Value) {
        this.FMaterialGlyphType = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetCaption = function (AValue) {
      pas["WEBLib.ExtCtrls"].TCustomPanel.SetCaption.apply(this,arguments);
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetParent = function (AValue) {
      if ($mod.TTabSheet.isPrototypeOf(AValue)) {
        if ($mod.TPageControl.isPrototypeOf(rtl.as(AValue,$mod.TTabSheet).FParent)) AValue = rtl.as(AValue,$mod.TTabSheet).FParent;
      };
      pas["WEBLib.Controls"].TControl.SetParent.call(this,AValue);
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) {
          rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        };
      };
    };
    this.ResetUpdate = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.EndUpdate.call(this);
    };
    this.VisibleChanged = function () {
      var i = 0;
      pas["WEBLib.Controls"].TControl.VisibleChanged.call(this);
      if (this.FVisible) {
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ($mod.TPageControl.isPrototypeOf(this.GetControls(i))) {
            rtl.as(this.GetControls(i),$mod.TPageControl).DoUpdateList();
          };
        };
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.CreateInitialize.call(this);
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetColor(16777215);
      this.SetTabVisible(true);
      this.SetTabEnabled(true);
      this.SetShowCaption(false);
      this.FPosUpdating = false;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
      this.FMaterialGlyphColor = -1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.EndUpdate.call(this);
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.ExtCtrls"].TCustomPanel.SetBounds.apply(this,arguments);
      if ($mod.TPageControl.isPrototypeOf(this.FParent) && !this.FPosUpdating) {
        this.FPosUpdating = true;
        rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        this.FPosUpdating = false;
      };
    };
    this.Destroy = function () {
      var p = null;
      p = null;
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) {
          p = rtl.as(this.FParent,$mod.TPageControl);
        };
      };
      pas["WEBLib.ExtCtrls"].TCustomPanel.Destroy.call(this);
      if (p != null) {
        p.DoUpdateList();
        p.SetTabIndex(0);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",4,{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementBodyClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementBodyClassName","FElementBodyClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGlyphColor",4,{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",4,{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",4,{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("PageIndex",7,rtl.longint,"GetPageIndex","SetPageIndex");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("TabVisible",2,rtl.boolean,"FTabVisible","SetTabVisible",4,{Default: true});
    $r.addProperty("TabEnabled",2,rtl.boolean,"FTabEnabled","SetTabEnabled",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnHide",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHide","FOnHide");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnShow",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnShow","FOnShow");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTabSheet",this.TTabSheet,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPageControl",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FPrevTabIndex = 0;
      this.FItems = null;
      this.FTabIndex = 0;
      this.FSelectedColor = 0;
      this.FOnChange = null;
      this.FSelectedTextColor = 0;
      this.FDisabledTextColor = 0;
      this.FShowTabs = false;
      this.FOldVisible = false;
      this.FUseHash = false;
      this.FElementTabActiveClassName = "";
      this.FElementTabClassName = "";
      this.FElementTabItemClassName = "";
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetSelectedColor = function (AValue) {
      if (this.FSelectedColor !== AValue) {
        this.FSelectedColor = AValue;
        this.DoUpdateList();
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetTabIndex = function (AIndex) {
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) this.FTabIndex = AIndex;
      if ((this.FTabIndex !== AIndex) && (AIndex >= 0) && (AIndex < this.PageCount())) {
        this.FTabIndex = AIndex;
        this.FPrevTabIndex = this.FTabIndex;
        this.DoUpdateList();
      };
    };
    this.GetActivePage = function () {
      var Result = null;
      var pi = 0;
      Result = null;
      pi = this.GetActivePageIndex();
      if (pi >= 0) Result = this.GetPage(pi);
      return Result;
    };
    this.GetActivePageIndex = function () {
      var Result = 0;
      Result = -1;
      if ((this.PageCount() >= 0) && (this.FTabIndex >= 0) && (this.FTabIndex < this.PageCount())) Result = this.FTabIndex;
      return Result;
    };
    this.SetActivePageIndex = function (Value) {
      if ((Value >= 0) && (Value < this.PageCount())) this.SetTabIndex(Value);
    };
    this.SetSelectedTextColor = function (Value) {
      if (this.FSelectedTextColor !== Value) {
        this.FSelectedTextColor = Value;
        this.DoUpdateList();
      };
    };
    this.SetActivePage = function (Value) {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetControls(i) === Value) {
          this.SetActivePageIndex(i);
          break;
        };
      };
    };
    this.SetShowTabs = function (Value) {
      if (this.FShowTabs !== Value) {
        this.FShowTabs = Value;
        this.DoUpdateList();
      };
    };
    this.SetDisabledTextColor = function (Value) {
      if (this.FDisabledTextColor !== Value) {
        this.FDisabledTextColor = Value;
        this.DoUpdateList();
      };
    };
    this.GetPage = function (Index) {
      var Result = null;
      var c = 0;
      var i = 0;
      c = -1;
      Result = null;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) c += 1;
        if (c === Index) {
          Result = rtl.as(this.GetControls(i),$mod.TTabSheet);
          break;
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      var sid = "";
      var cid = "";
      var i = 0;
      var el = null;
      var ts = null;
      el = Event.target;
      sid = "";
      if (el.hasAttribute("id")) sid = el.getAttribute("id");
      if (sid !== "") {
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        sid = pas.SysUtils.StringReplace(sid,cid + "_","",{});
        if (pas.SysUtils.TryStrToInt(sid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          if (this.FTabIndex !== -1) {
            ts = this.GetPage(this.FTabIndex);
            if ((ts != null) && (ts.FOnHide != null)) ts.FOnHide(ts);
          };
          this.FTabIndex = i;
          this.DoUpdateList();
          if (this.FTabIndex !== -1) {
            ts = this.GetPage(this.FTabIndex);
            if ((ts != null) && (ts.FOnShow != null)) ts.FOnShow(ts);
          };
        };
        pas["WEBLib.Controls"].TControl.HandleDoClick.apply(this,arguments);
      };
      Result = true;
      return Result;
    };
    this.HandleDoChange = function (Event) {
      var Result = false;
      if (this.FPrevTabIndex !== this.FTabIndex) {
        this.FPrevTabIndex = this.FTabIndex;
        if (this.FOnChange != null) this.FOnChange(this);
      };
      Result = true;
      return Result;
    };
    this.HandleDoItemMouseOut = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","");
      };
      return Result;
    };
    this.HandleDoItemMouseOver = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","lightgray");
      };
      return Result;
    };
    this.CanAcceptChild = function (AValue) {
      var Result = null;
      Result = pas["WEBLib.Controls"].TControl.CanAcceptChild.apply(this,arguments);
      if ((AValue != null) && !$mod.TTabSheet.isPrototypeOf(AValue)) {
        Result = this.FParent;
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().onclick = rtl.createSafeCallback(this,"HandleDoChange");
      };
    };
    this.GetChildren = function (Proc, Root) {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
          Proc(this.GetControls(i));
        };
      };
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.DoUpdateList = function () {
      var i = 0;
      var vistabindex = 0;
      var ena = null;
      var s = "";
      var cid = "";
      var shidden = "";
      var n = null;
      var ul = null;
      var li = null;
      var a = null;
      var tabs = null;
      var tab = null;
      var LLabel = null;
      var LHasLabel = false;
      var matclr = "";
      var icn = "";
      var noptr = "";
      var inactive = "";
      var th = 0;
      if (!(this.GetContainer() != null)) return;
      if (!(this.GetElementHandle() != null) || this.IsUpdating()) return;
      tab = null;
      if (this.GetControlsCount() > 0) {
        this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        LLabel = this.GetElementHandle().firstChild;
        LHasLabel = (LLabel != null) && (LLabel.tagName === "DIV") && (LLabel.getAttribute("data-design") === "1");
        if (LHasLabel) {
          this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
          this.GetElementHandle().style.removeProperty("border");
        };
        tabs = pas.Classes.TStringList.$create("Create$1");
        shidden = "{#hidden#}";
        vistabindex = this.FTabIndex;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ((pas.Classes.TComponentStateItem.csDestroying in this.GetControls(i).FComponentState) && (i <= this.FTabIndex)) vistabindex += 1;
          if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i)) && !(pas.Classes.TComponentStateItem.csDestroying in this.GetControls(i).FComponentState)) {
            tab = this.GetControls(i);
            icn = "";
            if (tab.FTabEnabled) {
              ena = this}
             else ena = null;
            if (tab.FTabVisible) {
              if (tab.FMaterialGlyph !== "") {
                matclr = "";
                inactive = "";
                if (!tab.FEnabled) inactive = " md-light md-inactive";
                if (tab.FMaterialGlyphColor !== -1) matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(tab.FMaterialGlyphColor);
                noptr = "pointer-events:none";
                icn = '<i class="' + pas["WEBLib.Controls"].GetMaterialClass(tab.FMaterialGlyphType) + inactive + '" translate="no" style="' + noptr + ";font-size:" + pas.SysUtils.IntToStr(tab.FMaterialGlyphSize) + "px" + matclr + '">' + tab.FMaterialGlyph + "</i>&nbsp;";
              };
              tabs.AddObject(icn + tab.FCaption,ena);
            } else tabs.AddObject(shidden,ena);
            tab.BeginUpdate();
            if (vistabindex === i) {
              tab.SetAlign(pas["WEBLib.Controls"].TAlign.alClient)}
             else tab.SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
            tab.SetAlignWithMargins(true);
            tab.FMargins.SetLeft(0);
            tab.FMargins.SetRight(0);
            tab.FMargins.SetBottom(0);
            tab.SetVisible(vistabindex === i);
            tab.ResetUpdate();
            if (vistabindex === i) tab.GetElementHandle().parentElement.insertBefore(tab.GetElementHandle(),null);
            tab.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(tab.FColor));
          };
        };
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        for (var $l1 = 0, $end1 = this.GetContainer().childNodes.length - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          n = this.GetContainer().childNodes.item(i);
          if ((n != null) && (n.getAttribute("id") === (cid + "_UL"))) this.GetContainer().removeChild(n);
        };
        this.GetContainer().setAttribute("class","");
        if (!this.FEnabled) {
          this.GetElementHandle().style.setProperty("pointer-events","none")}
         else this.GetElementHandle().style.setProperty("pointer-events","auto");
        if (this.FShowTabs) {
          ul = document.createElement("UL");
          ul.setAttribute("class",this.FElementClassName);
          ul.setAttribute("id",cid + "_UL");
          if (this.FElementClassName !== "") {
            ul.setAttribute("role","tablist")}
           else {
            ul.style.setProperty("list-style-type","none");
            ul.style.setProperty("margin","0");
            ul.style.setProperty("padding","0");
            ul.style.setProperty("display","inline-block");
          };
          this.GetContainer().appendChild(ul);
        };
        for (var $l2 = 0, $end2 = tabs.GetCount() - 1; $l2 <= $end2; $l2++) {
          i = $l2;
          s = tabs.Get(i);
          if ((s !== shidden) && this.FShowTabs) {
            if (s === "") s = "tab" + pas.SysUtils.IntToStr(i);
            li = document.createElement("LI");
            if (this.FElementClassName !== "") {
              if (this.FElementTabItemClassName === "") {
                li.setAttribute("class","nav-item")}
               else li.setAttribute("class",this.FElementTabItemClassName);
            } else {
              li.style.setProperty("float","left");
              if (this.FBorderStyle !== pas["WEBLib.Controls"].TBorderStyle.bsNone) li.style.setProperty("border-bottom","1px solid lightgray");
            };
            if (tabs.GetObject(i) === null) {
              li.style.setProperty("pointer-events","none");
              li.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FDisabledTextColor));
            };
            if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
            pas["WEBLib.Controls"].SetHTMLElementFont(li,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
            ul.appendChild(li);
            if (!this.FEnabled) {
              a = document.createElement("SPAN")}
             else {
              a = document.createElement("A");
              if (this.FUseHash) a.setAttribute("href","#" + s);
            };
            if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) a.setAttribute("draggable","false");
            a.innerHTML = s;
            a.setAttribute("id",cid + "_" + pas.SysUtils.IntToStr(i));
            if (this.FElementClassName !== "") {
              if (this.FTabIndex === i) {
                if (this.FElementTabActiveClassName === "") {
                  a.setAttribute("class","nav-link active")}
                 else a.setAttribute("class",this.FElementTabActiveClassName);
              } else {
                if (this.FElementTabClassName === "") {
                  a.setAttribute("class","nav-link")}
                 else a.setAttribute("class",this.FElementTabClassName);
              };
              a.setAttribute("role","tab");
              a.setAttribute("data-toggle","tab");
              a.setAttribute("aria-controls",s);
              if (this.FTabIndex === i) {
                a.setAttribute("aria-selected","true")}
               else a.setAttribute("aria-selected","false");
            } else {
              a.style.setProperty("display","block");
              a.style.setProperty("text-align","center");
              a.style.setProperty("padding","3px 15px");
              a.style.setProperty("text-decoration","none");
              a.style.setProperty("min-width","50px");
              a.style.setProperty("color","inherit");
              a.style.setProperty("font-family","inherit");
              a.style.setProperty("font-style","inherit");
              a.style.setProperty("font-size","inherit");
              if (this.FTabIndex === i) {
                if (this.FSelectedColor !== -1) a.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedColor));
                if (this.FSelectedTextColor !== -1) a.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedTextColor));
              };
            };
            li.appendChild(a);
          };
        };
        for (var $l3 = 0, $end3 = this.GetControlsCount() - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
            if (this.FShowTabs) {
              th = Math.round(ul.offsetHeight) - 1;
            } else th = 0;
            if (th > 0) this.GetControls(i).FMargins.SetTop(th);
            this.GetControls(i).GetElementHandle().style.setProperty("white-space","");
          };
        };
        tabs = rtl.freeLoc(tabs);
      } else {
        if (!this.GetIsLinked()) {
          this.ClearChildElements();
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
            this.RenderDesigning("TWebPageControl",this.GetContainer(),this,true,"");
          };
        };
      };
      this.DoUpdateResize();
      if (tab != null) {
        tab.SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
        tab.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      };
      this.UpdateElement();
      if (!this.GetIsLinked() && (this.GetControlsCount() === 0)) {
        this.GetElementHandle().style.setProperty("border","1px solid lightgray");
      };
    };
    this.DoUpdateResize = function () {
      var i = 0;
      var vistabindex = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) this.GetControls(i).SetVisible(false);
      };
      for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
          this.GetControls(i).SetVisible(true);
          this.GetControls(i).SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
          this.GetControls(i).SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
          this.GetControls(i).SetVisible(false);
        };
      };
      vistabindex = this.FTabIndex;
      for (var $l2 = 0, $end2 = this.GetControlsCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if ((pas.Classes.TComponentStateItem.csDestroying in this.GetControls(i).FComponentState) && (i <= this.FTabIndex)) vistabindex += 1;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
          this.GetControls(i).SetVisible(vistabindex === i);
        };
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
      this.SetTabIndex(this.FTabIndex);
      this.FOldVisible = this.FVisible;
    };
    this.VisibleChanged = function () {
      pas["WEBLib.Controls"].TControl.VisibleChanged.call(this);
      if (this.FOldVisible !== this.FVisible) {
        this.DoUpdateList();
        this.FOldVisible = this.FVisible;
      };
    };
    this.ItemsChanged = function (Sender) {
      var i = 0;
      var ts = null;
      if ((this.PageCount() === 0) && (this.FItems.GetCount() > 0) && (this.GetElementHandle().childElementCount > 0)) {
        this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
      };
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.PageCount() <= i) {
          ts = $mod.TTabSheet.$create("Create$1",[this.FOwner]);
          ts.SetParent(this);
          ts.SetName(this.FName + "sheet" + pas.SysUtils.IntToStr(i + 1));
        };
        this.GetPage(i).SetCaption(this.FItems.Get(i));
      };
      for (var $l1 = this.PageCount() - 1; $l1 >= 0; $l1--) {
        i = $l1;
        if (i >= this.FItems.GetCount()) {
          ts = this.GetPage(i);
          ts = rtl.freeLoc(ts);
        };
      };
      this.DoUpdateList();
    };
    this.SetParent = function (AValue) {
      var ts = null;
      var frm = null;
      pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
      if (this.FDesignTime$1) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        this.FDesignTime$1 = false;
        ts = $mod.TWebTabSheet.$create("Create$1",[frm]);
        ts.SetParent(this);
        ts.SetCaption("Page1");
        ts.SetName(this.GetUniqueName());
        ts = $mod.TWebTabSheet.$create("Create$1",[frm]);
        ts.SetParent(this);
        ts.SetCaption("Page2");
        ts.SetName(this.GetUniqueName());
      };
      this.DoUpdateList();
    };
    this.GetUniqueName = function () {
      var Result = "";
      var i = 0;
      var id = 0;
      var found = false;
      var AName = "";
      id = 1;
      AName = this.FName + "sheet";
      do {
        Result = AName + pas.SysUtils.IntToStr(id);
        found = true;
        for (var $l = 0, $end = this.FOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.FOwner.GetComponent(i).FName === Result) {
            found = false;
            id += 1;
            break;
          };
        };
      } while (!found);
      return Result;
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        var tn = "";
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          tn = AElement.children.item(I).tagName;
          if (tn === "LI") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else if (tn === "A") {
            AElement.children.item(I).setAttribute("draggable","false")}
           else if (tn === "UL") AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        var tn = "";
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          tn = AElement.children.item(I).tagName;
          if (tn === "LI") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else if (tn === "A") {
            AElement.children.item(I).removeAttribute("draggable")}
           else if (tn === "UL") RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"ItemsChanged");
      this.FTabIndex = 0;
      this.FPrevTabIndex = this.FTabIndex;
      this.FShowTabs = true;
      this.FUseHash = true;
      this.SetTabStop(false);
      this.FSelectedColor = 12632256;
      this.FSelectedTextColor = 0;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
      this.FEnablePropagation = true;
      this.FOldVisible = true;
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.FItems.Clear();
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.SelectNextPage = function (GoForward) {
      if (GoForward) {
        if (this.FTabIndex < (this.PageCount() - 1)) {
          this.SetTabIndex(this.FTabIndex + 1)}
         else this.SetTabIndex(0);
      } else {
        if (this.FTabIndex > 0) {
          this.SetTabIndex(this.FTabIndex - 1)}
         else this.SetTabIndex(this.PageCount() - 1);
      };
    };
    this.PageCount = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) Result += 1;
      };
      return Result;
    };
    this.PageIndexFromElement = function (AElement) {
      var Result = 0;
      var sid = "";
      var cid = "";
      var i = 0;
      Result = -1;
      sid = "";
      if (AElement.tagName === "LI") AElement = AElement.firstChild;
      if (AElement.hasAttribute("id")) sid = AElement.getAttribute("id");
      if (sid !== "") {
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        sid = pas.SysUtils.StringReplace(sid,cid + "_","",{});
        if (pas.SysUtils.TryStrToInt(sid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) Result = i;
      };
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsNone});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("DisabledTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledTextColor","SetDisabledTextColor",4,{Default: 8421504});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementTabClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabClassName","FElementTabClassName");
    $r.addProperty("ElementTabActiveClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabActiveClassName","FElementTabActiveClassName");
    $r.addProperty("ElementTabItemClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabItemClassName","FElementTabItemClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("TabIndex",2,rtl.longint,"FTabIndex","SetTabIndex");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("ShowTabs",2,rtl.boolean,"FShowTabs","SetShowTabs",4,{Default: true});
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",4,{Default: 12632256});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",4,{Default: 0});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("UseHash",0,rtl.boolean,"FUseHash","FUseHash",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebPageControl",this.TPageControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TProgressBarStyle = {"0": "pbstNormal", pbstNormal: 0, "1": "pbstMarquee", pbstMarquee: 1, "2": "pbstDiv", pbstDiv: 2};
  this.$rtti.$Enum("TProgressBarStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TProgressBarStyle});
  this.TProgressBarValue = {"0": "pbvNone", pbvNone: 0, "1": "pbvPercentage", pbvPercentage: 1, "2": "pbvAbsolute", pbvAbsolute: 2};
  this.$rtti.$Enum("TProgressBarValue",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TProgressBarValue});
  rtl.createClass(this,"TProgressBar",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FMax = 0;
      this.FMin = 0;
      this.FPosition = 0;
      this.FStyle = 0;
      this.FElementBarClassName = "";
      this.FValue = 0;
      this.FValueColor = 0;
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        if (this.GetElementHandle() != null) {
          this.CreateProgressElement(this.GetElementHandle());
          this.DoUpdate();
        };
      };
    };
    this.SetElementBarClassName = function (Value) {
      this.FElementBarClassName = Value;
      this.DoUpdate();
    };
    this.SetValue = function (Value) {
      this.FValue = Value;
      this.DoUpdate();
    };
    this.SetValueColor = function (Value) {
      if (this.FValueColor !== Value) {
        this.FValueColor = Value;
        this.UpdateElementVisual();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      this.CreateProgressElement(Result);
      return Result;
    };
    this.SetMax = function (AValue) {
      this.FMax = AValue;
      this.DoUpdate();
    };
    this.SetMin = function (AValue) {
      this.FMin = AValue;
      this.DoUpdate();
    };
    this.SetPosition = function (AValue) {
      if ((AValue >= this.FMin) && (AValue <= this.FMax)) {
        this.FPosition = AValue;
        this.DoUpdate();
      };
    };
    this.DoUpdate = function () {
      var pvalue = 0;
      var maxvalue = 0;
      var el = null;
      var pos = 0;
      if (!(this.GetContainer() != null)) return;
      if (this.FMax !== this.FMin) {
        pos = Math.round(((this.FPosition - this.FMin) / (this.FMax - this.FMin)) * 100)}
       else pos = 0;
      if (this.GetIsLinked()) {
        if (this.GetElementHandle().tagName === "DIV") {
          if (this.GetElementHandle().getAttribute("role") === "progressbar") {
            this.GetElementHandle().style.setProperty("width",pas.SysUtils.IntToStr(pos) + "%")}
           else this.GetElementHandle().innerHTML = pas.SysUtils.IntToStr(pos);
        } else this.GetElementHandle().setAttribute("value",pas.SysUtils.IntToStr(pos));
        return;
      };
      if (this.FStyle === $mod.TProgressBarStyle.pbstDiv) {
        el = this.GetElementHandle().firstChild;
        if (this.FElementClassName !== "") {
          el.setAttribute("class",this.FElementClassName);
          this.GetElementHandle().removeAttribute("class");
        };
        el.style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()) + "px");
        if (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) el.style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()) + "px");
        el = el.firstChild;
        el.style.setProperty("background-color","#3397FD");
        if (this.FElementBarClassName !== "") el.setAttribute("class",this.FElementBarClassName);
        el.setAttribute("role","progressbar");
        el.style.setProperty("width",pas.SysUtils.IntToStr(pos) + "%");
        var $tmp = this.FValue;
        if ($tmp === $mod.TProgressBarValue.pbvPercentage) {
          el.innerHTML = pas.SysUtils.IntToStr(pos) + "%"}
         else if ($tmp === $mod.TProgressBarValue.pbvAbsolute) {
          el.innerHTML = pas.SysUtils.IntToStr(this.FPosition)}
         else if ($tmp === $mod.TProgressBarValue.pbvNone) el.innerHTML = "&nbsp;";
      } else {
        el = this.GetElementHandle().firstChild;
        el.style.setProperty("width","100%");
        el.style.setProperty("height","100%");
        pvalue = this.FPosition - this.FMin;
        maxvalue = this.FMax - this.FMin;
        el.setAttribute("max",pas.SysUtils.IntToStr(maxvalue));
        if (this.FStyle === $mod.TProgressBarStyle.pbstNormal) {
          el.setAttribute("value",pas.SysUtils.IntToStr(pvalue))}
         else el.removeAttribute("value");
      };
    };
    this.UpdateElementVisual = function () {
      var el = null;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.FValueColor !== -1) {
        if (this.FStyle === $mod.TProgressBarStyle.pbstDiv) {
          el = this.GetElementHandle().firstChild;
          el = el.firstChild;
          el.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FValueColor));
        } else {
          el = this.GetElementHandle().firstChild;
          el.style.setProperty("accent-color",pas["WEBLib.Graphics"].ColorToHTML(this.FValueColor));
        };
      };
    };
    this.CreateProgressElement = function (AElement) {
      var d = null;
      while (AElement.firstChild != null) AElement.removeChild(AElement.firstChild);
      if (this.FStyle === $mod.TProgressBarStyle.pbstDiv) {
        d = document.createElement("DIV");
        d.appendChild(document.createElement("DIV"));
      } else d = document.createElement("PROGRESS");
      AElement.appendChild(d);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FMax = 100;
      this.FMin = 0;
      this.FPosition = 0;
      this.FStyle = $mod.TProgressBarStyle.pbstNormal;
      this.FValueColor = -1;
    };
    this.AfterLoadDFMValues = function () {
      pas.Classes.TComponent.AfterLoadDFMValues.call(this);
      this.DoUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementBarClassName",2,rtl.string,"FElementBarClassName","SetElementBarClassName");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Max",2,rtl.longint,"FMax","SetMax");
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Position",2,rtl.longint,"FPosition","SetPosition");
    $r.addProperty("Style",2,$mod.$rtti["TProgressBarStyle"],"FStyle","SetStyle");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Value",2,$mod.$rtti["TProgressBarValue"],"FValue","SetValue");
    $r.addProperty("ValueColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FValueColor","SetValueColor",4,{Default: -1});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebProgressBar",this.TProgressBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TTreeViewNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTreeViewNodeStateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]],["AState",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TTreeViewNodeAllowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTreeViewNodeRenderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]],["AElement",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]]]), methodkind: 0});
  rtl.createClass(this,"TTreeView",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FSelected = null;
      this.FOnCollapsing = null;
      this.FOnExpanding = null;
      this.FOnCollapsed = null;
      this.FOnExpanded = null;
      this.FOnClickNode = null;
      this.FOnDblClickNode = null;
      this.FOnRenderNode = null;
      this.FAutoExpand = false;
      this.FOnChange = null;
      this.FOnChanging = null;
      this.FElementNodeSelectedClassName = "";
      this.FElementNodeClassName = "";
      this.FOnClickRadio = null;
      this.FOnClickCheckBox = null;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FSelected = undefined;
      this.FOnCollapsing = undefined;
      this.FOnExpanding = undefined;
      this.FOnCollapsed = undefined;
      this.FOnExpanded = undefined;
      this.FOnClickNode = undefined;
      this.FOnDblClickNode = undefined;
      this.FOnRenderNode = undefined;
      this.FOnChange = undefined;
      this.FOnChanging = undefined;
      this.FOnClickRadio = undefined;
      this.FOnClickCheckBox = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.GetSelected = function () {
      var Result = null;
      Result = this.FSelected;
      return Result;
    };
    this.SetSelected = function (Value) {
      var el = null;
      if (this.FSelected != null) {
        this.FSelected.UnSelect();
        el = this.GetNodeElement(this.FSelected);
        if (el != null) {
          el.classList.toggle("TVSELECTED");
          if (this.FElementNodeSelectedClassName !== "") el.classList.toggle(this.FElementNodeSelectedClassName);
        };
      };
      this.FSelected = Value;
      if (this.FSelected != null) this.FSelected.Select();
      el = this.GetNodeElement(this.FSelected);
      if (el != null) {
        el.classList.toggle("TVSELECTED");
        if (this.FElementNodeSelectedClassName !== "") el.classList.toggle(this.FElementNodeSelectedClassName);
      };
    };
    this.SetElementNodeClassName = function (Value) {
      if (this.FElementNodeClassName !== Value) {
        this.FElementNodeClassName = Value;
        this.UpdateElement();
      };
    };
    this.SetElementNodeSelectedClassName = function (Value) {
      if (this.FElementNodeSelectedClassName !== Value) {
        this.FElementNodeSelectedClassName = Value;
        this.UpdateElement();
      };
    };
    this.GetTopItem = function () {
      var Result = null;
      var el = null;
      var tn = null;
      var h = 0.0;
      Result = null;
      if (this.FItems.GetSiblingCount() === 0) return Result;
      h = this.GetElementHandle().getBoundingClientRect().top;
      tn = this.FItems.GetSiblingFromIndex(0);
      while (tn != null) {
        el = this.GetNodeElement(tn);
        if (el.getBoundingClientRect().top >= h) {
          Result = tn;
          break;
        };
        tn = tn.GetNext();
      };
      return Result;
    };
    this.SetTopItem = function (Value) {
      var el = null;
      var h = 0.0;
      var ch = 0.0;
      if (!(Value != null)) throw pas.SysUtils.Exception.$create("Create$1",["Value is not assigned"]);
      el = this.GetNodeElement(Value);
      h = el.getBoundingClientRect().top + this.GetElementHandle().scrollTop;
      ch = this.GetElementHandle().getBoundingClientRect().top;
      this.GetElementHandle().scrollTop = Math.round(h - ch);
    };
    this.DoRenderNode = function (ANode, AElement) {
      var LElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      if (this.FOnRenderNode != null) {
        LElementRec.element = AElement;
        this.FOnRenderNode(this,ANode,pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LElementRec));
      };
    };
    this.RenderControl = function (ANode, AElementName) {
      var Result = "";
      var chk = "";
      var rname = "";
      var l = 0;
      chk = "";
      if (ANode.FChecked) chk = " checked";
      rname = AElementName;
      l = rname.length;
      if (pas.System.Pos("_",rname) > 0) {
        while (rname.charAt(l - 1) !== "_") {
          l -= 1;
        };
        rname = pas.System.Copy(rname,1,l - 1);
      };
      var $tmp = ANode.FNodeType;
      if ($tmp === pas["WEBLib.TreeNodes"].TNodeType.ntCheckbox) {
        Result = '<input type="checkbox"' + chk + "></input>&nbsp;" + ANode.FText}
       else if ($tmp === pas["WEBLib.TreeNodes"].TNodeType.ntRadioButton) {
        Result = '<input type="radio"' + chk + ' name="' + rname + '"></input>&nbsp;' + ANode.FText}
       else if ($tmp === pas["WEBLib.TreeNodes"].TNodeType.ntText) Result = ANode.FText;
      return Result;
    };
    this.RenderNode = function (ANode, AElementName) {
      var Result = null;
      Result = document.createElement("SPAN");
      if (AElementName !== "") Result.setAttribute("id",AElementName);
      Result.innerHTML = this.RenderControl(ANode,AElementName);
      Result.classList.add("TVNODE");
      if (this.FElementNodeClassName !== "") Result.classList.add(this.FElementNodeClassName);
      if (this.GetSelected() != null) {
        if (this.GetSelected() === ANode) {
          Result.classList.add("TVSELECTED");
          if (this.FElementNodeSelectedClassName !== "") Result.classList.add(this.FElementNodeSelectedClassName);
        };
      };
      if (ANode.FHint !== "") Result.setAttribute("title",ANode.FHint);
      return Result;
    };
    this.RenderNodes = function () {
      var $Self = this;
      function RenderChildNode(LinkElement, ANode, AElementName) {
        var sp = null;
        var nd = null;
        sp = document.createElement("SPAN");
        if (AElementName !== "") sp.setAttribute("id",AElementName);
        sp.addEventListener("click",rtl.createSafeCallback($Self,"HandleNode"));
        sp.addEventListener("dblclick",rtl.createSafeCallback($Self,"HandleDblClick"));
        nd = document.createElement("SPAN");
        if ($Self.FAutoExpand) nd.style.setProperty("pointer-events","none");
        nd.innerHTML = $Self.RenderControl(ANode,AElementName);
        nd.classList.add("TVNODE");
        if ($Self.FElementNodeClassName !== "") nd.classList.add($Self.FElementNodeClassName);
        if (!$Self.FAutoExpand) nd.classList.add("TVNOCURSOR");
        if ($Self.GetSelected() != null) {
          if ($Self.GetSelected() === ANode) {
            nd.classList.add("TVSELECTED");
            if ($Self.FElementNodeSelectedClassName !== "") nd.classList.add($Self.FElementNodeSelectedClassName);
          };
        };
        if (ANode.FHint !== "") nd.setAttribute("title",ANode.FHint);
        LinkElement.appendChild(sp);
        sp.appendChild(nd);
        if (ANode.FIsExpanded) {
          sp.setAttribute("class","TVCARET TVCARET-DOWN")}
         else sp.setAttribute("class","TVCARET");
        $Self.DoRenderNode(ANode,nd);
      };
      function FillChilds(ParentElement, ParentName, ANode) {
        var i = 0;
        var ul = null;
        var nd = null;
        var li = null;
        var nn = "";
        ul = document.createElement("UL");
        ul.setAttribute("class","TVUL");
        ul.setAttribute("id",ParentName);
        if ($Self.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) ul.setAttribute("draggable","true");
        ParentElement.appendChild(ul);
        if (!(ANode != null)) {
          for (var $l = 0, $end = $Self.FItems.GetSiblingCount() - 1; $l <= $end; $l++) {
            i = $l;
            nn = ParentName + "_" + pas.SysUtils.IntToStr(i);
            li = document.createElement("LI");
            if ($Self.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
            ul.appendChild(li);
            if ($Self.FItems.GetSiblingFromIndex(i).GetCount() > 0) {
              RenderChildNode(li,$Self.FItems.GetSiblingFromIndex(i),nn);
              FillChilds(li,nn,$Self.FItems.GetSiblingFromIndex(i));
            } else {
              nd = $Self.RenderNode($Self.FItems.GetSiblingFromIndex(i),nn);
              li.appendChild(nd);
              $Self.DoRenderNode($Self.FItems.GetSiblingFromIndex(i),nd);
              nd.addEventListener("click",rtl.createSafeCallback($Self,"HandleClick"));
              nd.addEventListener("dblclick",rtl.createSafeCallback($Self,"HandleDblClick"));
            };
          };
        } else {
          if (ANode.FIsExpanded) {
            ul.setAttribute("class","TVNESTED TVUL TVACTIVE")}
           else ul.setAttribute("class","TVNESTED TVUL");
          for (var $l1 = 0, $end1 = ANode.GetCount() - 1; $l1 <= $end1; $l1++) {
            i = $l1;
            nn = ParentName + "_" + pas.SysUtils.IntToStr(i);
            li = document.createElement("LI");
            if ($Self.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
            ul.appendChild(li);
            if (ANode.GetItem(i).GetCount() > 0) {
              RenderChildNode(li,ANode.GetItem(i),nn);
              FillChilds(li,nn,ANode.GetItem(i));
            } else {
              nd = $Self.RenderNode(ANode.GetItem(i),nn);
              li.appendChild(nd);
              $Self.DoRenderNode(ANode.GetItem(i),nd);
              nd.addEventListener("click",rtl.createSafeCallback($Self,"HandleClick"));
              nd.addEventListener("dblclick",rtl.createSafeCallback($Self,"HandleDblClick"));
            };
          };
        };
      };
      if (!(this.GetElementHandle() != null)) return;
      while (this.GetElementHandle().childNodes.length > 0) this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
      FillChilds(this.GetElementHandle(),this.FormPrefix() + this.FName,null);
      this.GetElementHandle().style.setProperty("overflow","auto");
    };
    this.CreateNodes = function () {
      var Result = null;
      Result = pas["WEBLib.TreeNodes"].TTreeNodes.$create("Create$1",[this]);
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      var tn = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.BeginUpdate();
        tn = this.FItems.Add$2('<font color="#E5413C" style="font-size:10pt">&#x25FC;</font> Item 1');
        this.FItems.AddChild(tn,"Child Item 1");
        tn = this.FItems.Add$2('<font color="#F39527" style="font-size:10pt">&#x25FC;</font> Item 2');
        this.FItems.AddChild(tn,"Child Item 2");
        tn = this.FItems.Add$2('<font color="#BDC6CB" style="font-size:10pt">&#x25FC;</font> Item 3');
        this.FItems.AddChild(tn,"Child Item 3");
        this.EndUpdate();
      };
      Result = document.createElement("DIV");
      return Result;
    };
    this.DoNodesChanged = function (Sender) {
    };
    this.DoExpandedChanged = function (Sender, ANode) {
      var el = null;
      var su = null;
      var i = 0;
      if (ANode.GetCount() > 0) {
        el = this.GetNodeElement(ANode);
        if ((el != null) && (el.parentElement != null) && (el.parentElement.parentElement != null)) {
          su = el.parentElement.parentElement.querySelector(".TVNESTED");
          if (su != null) {
            if (ANode.FIsExpanded) {
              su.classList.add("TVACTIVE")}
             else su.classList.remove("TVACTIVE");
            el.parentElement.classList.toggle("TVCARET-DOWN");
          };
        };
        if (this.FAutoExpand) {
          for (var $l = 0, $end = ANode.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (ANode.GetItem(i).GetCount() > 0) {
              ANode.GetItem(i).SetIsExpanded(ANode.FIsExpanded);
            };
          };
        };
      };
    };
    this.DoSelectionChanged = function (Sender, ANode, IsSelected) {
      if (IsSelected) {
        this.SetSelected(ANode)}
       else this.SetSelected(null);
    };
    this.HandleNode = function (Event) {
      var Result = false;
      var el = null;
      var chk = null;
      var n = null;
      var Allow = false;
      var IsInput = false;
      el = Event.srcElement;
      IsInput = el.tagName === "INPUT";
      while ((el != null) && (el.tagName !== "SPAN")) el = el.parentElement;
      if (IsInput) el = el.parentElement;
      Allow = true;
      if ((el != null) && el.hasAttribute("id")) {
        n = this.GetNodeFromID(el.getAttribute("id"));
        if (IsInput && (n.FNodeType in rtl.createSet(pas["WEBLib.TreeNodes"].TNodeType.ntCheckbox,pas["WEBLib.TreeNodes"].TNodeType.ntRadioButton))) {
          chk = el.firstChild.firstChild;
          if (chk.tagName === "INPUT") {
            if (chk.getAttribute("type") === "radio") {
              this.ClickRadio(n,chk.checked)}
             else this.ClickCheck(n,chk.checked);
            n.SetChecked(chk.checked);
            Allow = false;
          };
        };
        if (n.FIsExpanded) {
          if (this.FOnCollapsing != null) this.FOnCollapsing(this,n,{get: function () {
              return Allow;
            }, set: function (v) {
              Allow = v;
            }});
        } else {
          if (this.FOnExpanding != null) this.FOnExpanding(this,n,{get: function () {
              return Allow;
            }, set: function (v) {
              Allow = v;
            }});
        };
        if (Allow) {
          n.SetIsExpanded(!n.FIsExpanded);
          if (n.FIsExpanded) {
            if (this.FOnExpanded != null) this.FOnExpanded(this,n);
          } else {
            if (this.FOnCollapsed != null) this.FOnCollapsed(this,n);
          };
        };
        this.DoChangeSelection(n);
        if (this.FOnClickNode != null) this.FOnClickNode(this,n);
        Result = true;
        if (!IsInput) Event.preventDefault();
      } else {
        if (el != null) {
          el = el.parentElement;
          if (el.hasAttribute("id")) {
            n = this.GetNodeFromID(el.getAttribute("id"));
            this.DoChangeSelection(n);
            if (this.FOnClickNode != null) this.FOnClickNode(this,n);
            Result = true;
            Event.preventDefault();
          };
        };
      };
      return Result;
    };
    this.HandleClick = function (Event) {
      var Result = false;
      var n = null;
      var el = null;
      var chk = null;
      Result = true;
      el = Event.srcElement;
      while ((el != null) && (el.tagName !== "SPAN")) el = el.parentElement;
      if (el != null) {
        if (el.hasAttribute("id")) {
          n = this.GetNodeFromID(el.getAttribute("id"));
          if (n.FNodeType in rtl.createSet(pas["WEBLib.TreeNodes"].TNodeType.ntCheckbox,pas["WEBLib.TreeNodes"].TNodeType.ntRadioButton)) {
            chk = el.firstChild;
            if (chk.tagName === "INPUT") {
              if (chk.getAttribute("type") === "radio") {
                this.ClickRadio(n,chk.checked)}
               else this.ClickCheck(n,chk.checked);
              n.SetChecked(chk.checked);
            };
          };
          if (this.FOnClick != null) this.FOnClick(this);
          if (n != null) {
            this.DoChangeSelection(n);
            if (this.FOnClickNode != null) this.FOnClickNode(this,n);
          };
        };
      };
      return Result;
    };
    this.HandleDblClick = function (Event) {
      var Result = false;
      var n = null;
      var c = null;
      var el = null;
      var Allow = false;
      Result = true;
      el = Event.srcElement;
      while ((el != null) && (el.tagName !== "SPAN")) el = el.parentElement;
      if (el != null) {
        if (!el.hasAttribute("id")) el = el.parentElement;
        if (el.hasAttribute("id")) {
          n = this.GetNodeFromID(el.getAttribute("id"));
          if (this.FOnDblClick != null) this.FOnDblClick(this);
          if (n != null) {
            this.DoChangeSelection(n);
            Allow = true;
            c = n.GetFirstChild();
            if (c != null) {
              if (n.FIsExpanded) {
                if (this.FOnCollapsing != null) this.FOnCollapsing(this,n,{get: function () {
                    return Allow;
                  }, set: function (v) {
                    Allow = v;
                  }});
              } else {
                if (this.FOnExpanding != null) this.FOnExpanding(this,n,{get: function () {
                    return Allow;
                  }, set: function (v) {
                    Allow = v;
                  }});
              };
              if (Allow) {
                n.SetIsExpanded(!n.FIsExpanded);
                if (n.FIsExpanded) {
                  if (this.FOnExpanded != null) this.FOnExpanded(this,n);
                } else if (!n.FIsExpanded) {
                  if (this.FOnCollapsed != null) this.FOnCollapsed(this,n);
                };
              };
            };
            if ((n != null) && (this.FOnDblClickNode != null)) this.FOnDblClickNode(this,n);
          };
        };
      };
      Event.stopPropagation();
      Result = true;
      return Result;
    };
    this.ClickCheck = function (ANode, AState) {
      if (this.FOnClickCheckBox != null) this.FOnClickCheckBox(this,ANode,AState);
    };
    this.ClickRadio = function (ANode, AState) {
      if (this.FOnClickRadio != null) this.FOnClickRadio(this,ANode,AState);
    };
    this.KeyDown = function (Key, Shift) {
      var tn = null;
      var sn = null;
      var ln = null;
      var c = null;
      var Allow = false;
      tn = this.GetSelected();
      if (Key.get() === 36) {
        if (this.FItems.GetSiblingFromIndex(0) != null) this.DoChangeSelection(this.FItems.GetSiblingFromIndex(0));
      };
      if ((Key.get() === 35) && (this.FItems.GetSiblingCount() > 0)) {
        tn = this.FItems.GetSiblingFromIndex(this.FItems.GetSiblingCount() - 1);
        while (tn.FIsExpanded) {
          if (tn.GetCount() > 0) tn = tn.GetItem(tn.GetCount() - 1);
        };
        this.DoChangeSelection(tn);
      };
      if (Key.get() === 40) {
        if (tn != null) {
          if (tn.FIsExpanded && (tn.GetCount() > 0)) {
            tn = tn.GetFirstChild();
          } else tn = tn.GetNextSibling();
          if (!(tn != null)) {
            tn = this.GetSelected();
            sn = tn;
            while (!(sn.GetNextSibling() != null) && (sn.GetParent() != null)) {
              sn = sn.GetParent();
              if (sn != null) ln = sn.GetNextSibling();
              if (ln != null) {
                tn = ln;
              };
            };
          };
          if (tn != null) this.DoChangeSelection(tn);
        };
      };
      if (Key.get() === 38) {
        if (tn != null) {
          tn = tn.GetPrevSibling();
          if (tn != null) {
            sn = tn;
            while ((sn != null) && sn.FIsExpanded && (sn.GetCount() > 0)) {
              sn = sn.GetItem(tn.GetCount() - 1);
              if (sn != null) tn = sn;
            };
            this.DoChangeSelection(tn);
          } else {
            tn = this.GetSelected().GetParent();
            if (tn != null) this.DoChangeSelection(tn);
          };
        };
      };
      if (Key.get() === 39) {
        if (tn != null) {
          c = tn.GetFirstChild();
          if (c != null) {
            Allow = true;
            if (this.FOnExpanding != null) this.FOnExpanding(this,this.GetSelected(),{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (Allow) {
              this.GetSelected().SetIsExpanded(true);
              if (this.FOnExpanded != null) this.FOnExpanded(this,this.GetSelected());
            };
          };
        };
      };
      if (Key.get() === 37) {
        if (tn != null) {
          c = tn.GetFirstChild();
          if (c != null) {
            Allow = true;
            if (this.FOnCollapsing != null) this.FOnCollapsing(this,this.GetSelected(),{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (Allow) {
              this.GetSelected().SetIsExpanded(false);
              if (this.FOnCollapsed != null) this.FOnCollapsed(this,this.GetSelected());
            };
          };
        };
      };
      if (Key.get() in rtl.createSet(37,39,40,38)) {
        Key.set(0);
        return;
      };
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
    };
    this.DoChangeSelection = function (NewNode) {
      var Allow = false;
      Allow = true;
      if ((this.FOnChanging != null) && (NewNode !== this.GetSelected())) this.FOnChanging(this,NewNode,{get: function () {
          return Allow;
        }, set: function (v) {
          Allow = v;
        }});
      if (Allow && (this.GetSelected() !== NewNode)) {
        this.SetSelected(NewNode);
        if (this.FOnChange != null) this.FOnChange(this,NewNode);
      };
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.FormPrefix = function () {
      var Result = "";
      var frm = null;
      Result = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) Result = frm.$classname;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      this.GetElementHandle().style.setProperty("overflow","auto");
    };
    this.CreateInitialize = function () {
      var css = "";
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FSelected = null;
      this.FItems = this.CreateNodes();
      this.FItems.FOnChange = rtl.createCallback(this,"DoNodesChanged");
      this.FItems.FOnExpandedChange = rtl.createCallback(this,"DoExpandedChanged");
      this.FItems.FOnSelectionChange = rtl.createCallback(this,"DoSelectionChanged");
      css = ".TVUL {" + " list-style-type: none;" + " margin: 0;" + " padding-left: 15px;" + "}" + "\r\n" + " .TVCARET {" + "  cursor: pointer;" + "  user-select: none;" + "}" + "\r\n" + ".TVCARET::before {" + 'content: "\\25B6";' + "display: inline-block;" + "margin-right: 6px;" + "}" + "\r\n" + ".TVCARET-DOWN::before {" + "transform: rotate(90deg);" + "}" + "\r\n" + ".TVNESTED {" + "  display: none;" + "}" + "\r\n" + ".TVACTIVE {" + "  display: block;" + "}" + "\r\n" + ".TVNODE {" + " padding: 3px;" + " display: inline-block;" + "}" + "\r\n" + ".TVNOCURSOR {" + " cursor: initial;" + "}" + "\r\n" + ".TVSELECTED {" + "  background-color: #0000ff;" + "  color: #ffffff;" + "}";
      this.AddControlStyle(css);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(200);
        this.SetHeight(200);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.BeginUpdate = function () {
      pas["WEBLib.Controls"].TControl.BeginUpdate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      if (!this.IsUpdating()) {
        this.SetSelected(null);
        this.RenderNodes();
      };
    };
    this.GetNodeFromID = function (AId) {
      var Result = null;
      var s = "";
      var sl = null;
      var n = null;
      var i = 0;
      var j = 0;
      var e = 0;
      Result = null;
      s = AId;
      s = pas.System.Copy(s,((this.FormPrefix() + this.FName)).length + 2,s.length);
      if (s !== "") {
        sl = pas.Classes.TStringList.$create("Create$1");
        sl.SetDelimiter("_");
        sl.FStrictDelimiter = true;
        sl.SetDelimitedText(s);
        n = null;
        for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          pas.System.val$6(sl.Get(i),{get: function () {
              return j;
            }, set: function (v) {
              j = v;
            }},{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          if (i === 0) {
            n = this.FItems.GetSiblingFromIndex(j)}
           else n = n.GetItem(j);
        };
        sl = rtl.freeLoc(sl);
        Result = n;
      };
      return Result;
    };
    this.GetNodeElement = function (ANode) {
      var Result = null;
      var s = "";
      var tn = null;
      Result = null;
      tn = ANode;
      if (!(tn != null)) return Result;
      s = "";
      do {
        if (s === "") {
          s = pas.SysUtils.IntToStr(tn.GetIndex())}
         else s = pas.SysUtils.IntToStr(tn.GetIndex()) + "_" + s;
        tn = tn.GetParent();
      } while (tn != null);
      s = this.FormPrefix() + this.FName + "_" + s;
      Result = document.getElementById(s);
      if (Result != null) {
        if (Result.classList.contains("TVCARET")) Result = Result.firstChild;
      };
      return Result;
    };
    this.Select = function (ANode) {
      this.SetSelected(ANode);
    };
    this.FullExpand = function () {
      var i = 0;
      for (var $l = 0, $end = this.FItems.GetSiblingCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FItems.GetSiblingFromIndex(i).Expand(true);
      };
    };
    this.FullCollapse = function () {
      var i = 0;
      for (var $l = 0, $end = this.FItems.GetSiblingCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FItems.GetSiblingFromIndex(i).Collapse(true);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoExpand",0,rtl.boolean,"FAutoExpand","FAutoExpand");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementNodeClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementNodeClassName","SetElementNodeClassName");
    $r.addProperty("ElementNodeSelectedClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementNodeSelectedClassName","SetElementNodeSelectedClassName");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Items",2,pas["WEBLib.TreeNodes"].$rtti["TTreeNodes"],"FItems","SetItems");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnClickCheckBox",0,$mod.$rtti["TTreeViewNodeStateEvent"],"FOnClickCheckBox","FOnClickCheckBox");
    $r.addProperty("OnClickRadio",0,$mod.$rtti["TTreeViewNodeStateEvent"],"FOnClickRadio","FOnClickRadio");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnClickNode",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnClickNode","FOnClickNode");
    $r.addProperty("OnDblClickNode",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnDblClickNode","FOnDblClickNode");
    $r.addProperty("OnRenderNode",0,$mod.$rtti["TTreeViewNodeRenderEvent"],"FOnRenderNode","FOnRenderNode");
    $r.addProperty("OnChange",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnChanging",0,$mod.$rtti["TTreeViewNodeAllowEvent"],"FOnChanging","FOnChanging");
    $r.addProperty("OnCollapsed",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnCollapsed","FOnCollapsed");
    $r.addProperty("OnCollapsing",0,$mod.$rtti["TTreeViewNodeAllowEvent"],"FOnCollapsing","FOnCollapsing");
    $r.addProperty("OnExpanded",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnExpanded","FOnExpanded");
    $r.addProperty("OnExpanding",0,$mod.$rtti["TTreeViewNodeAllowEvent"],"FOnExpanding","FOnExpanding");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTreeView",this.TTreeView,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTreeNodeEx",pas["WEBLib.TreeNodes"].TTreeNode,function () {
    });
    rtl.createClass($impl,"TTreeNodesEx",pas["WEBLib.TreeNodes"].TTreeNodes,function () {
    });
    $impl.GetTextNodes = function (node, nodes) {
      var children = null;
      var i = 0;
      var j = 0;
      var childlist = null;
      if (node.nodeType === 3) {
        nodes.Add(node)}
       else {
        children = node.childNodes;
        childlist = pas.Classes.TList.$create("Create$1");
        for (var $l = 0, $end = children.length - 1; $l <= $end; $l++) {
          i = $l;
          $impl.GetTextNodes(children.item(i),childlist);
          for (var $l1 = 0, $end1 = childlist.GetCount() - 1; $l1 <= $end1; $l1++) {
            j = $l1;
            nodes.Add(childlist.Get(j));
          };
        };
        childlist = rtl.freeLoc(childlist);
      };
    };
  };
},["WEBLib.Buttons","WEBLib.Forms","WEBLib.Utils"]);
rtl.module("WEBLib.TMSFNCEditorsTools",["System","Classes","Types","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphicsTypes","WEBLib.Graphics","WEBLib.TMSFNCEditorButton","WEBLib.TMSFNCEditorListView","WEBLib.TMSFNCEditorPanel","WEBLib.StdCtrls","WEBLib.Controls","WEBLib.ComCtrls","JS","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.EDITORBUTTONROUNDING = 5;
  this.EDITORPRIMCOLOR = 0xbe7700;
  this.EDITORSTROKECOLORLIGHT = 0xECDECE;
  this.EDITORSTROKECOLORDARK = 0x6B5E4F;
  this.EDITORCOUNTERCOLOR = 0x77be;
  this.EDITOROKFONTCOLOR = 16777215;
  this.EDITORAUTOCOLOR = -1;
  this.EDITORFONTCOLORLIGHT = 0x555555;
  this.EDITORFONTCOLORDARK = 0xAAAAAA;
  this.EDITORFONTCOLORDISABLED = 0x787878;
  this.EDITORMAINBACKCOLORLIGHT = 16777215;
  this.EDITORMAINBACKCOLORDARK = 0x2C2A2A;
  this.EDITORSUBBACKCOLORLIGHT = 16119285;
  this.EDITORSUBBACKCOLORDARK = 0x433E3E;
  this.TTMSFNCEditorDesignerTheme = {"0": "edtDefault", edtDefault: 0, "1": "edtLight", edtLight: 1, "2": "edtDark", edtDark: 2};
  this.$rtti.$Enum("TTMSFNCEditorDesignerTheme",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCEditorDesignerTheme});
  this.IsLightTheme = function () {
    var Result = false;
    var s = "";
    if ($mod.TMSFNCDesignerTheme !== $mod.TTMSFNCEditorDesignerTheme.edtDefault) {
      Result = $mod.TMSFNCDesignerTheme === $mod.TTMSFNCEditorDesignerTheme.edtLight;
      return Result;
    };
    Result = true;
    if ($impl.NoIDERunning()) return Result;
    s = pas["WEBLib.Forms"].Application.IDETheme();
    if (s === "vscode-light") {
      Result = true}
     else Result = false;
    return Result;
  };
  this.EditorDarkerShadeColor = function (AColor, AFactor, ATimes) {
    var Result = 0;
    var r = 0;
    var g = 0;
    var b = 0;
    var I = 0;
    r = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetColorRed(AColor);
    g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetColorGreen(AColor);
    b = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetColorBlue(AColor);
    for (var $l = 0, $end = ATimes; $l <= $end; $l++) {
      I = $l;
      r = Math.max(0,Math.round(r - ((r / 255) * AFactor)));
      g = Math.max(0,Math.round(g - ((g / 255) * AFactor)));
      b = Math.max(0,Math.round(b - ((b / 255) * AFactor)));
    };
    Result = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#" + pas.SysUtils.IntToHex(r,2) + pas.SysUtils.IntToHex(g,2) + pas.SysUtils.IntToHex(b,2));
    return Result;
  };
  this.EditorLighterShadeColor = function (AColor, AFactor, ATimes) {
    var Result = 0;
    var r = 0;
    var g = 0;
    var b = 0;
    var I = 0;
    r = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetColorRed(AColor);
    g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetColorGreen(AColor);
    b = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetColorBlue(AColor);
    for (var $l = 0, $end = ATimes; $l <= $end; $l++) {
      I = $l;
      r = Math.min(255,Math.round(r + ((r / 255) * AFactor)));
      g = Math.min(255,Math.round(g + ((g / 255) * AFactor)));
      b = Math.min(255,Math.round(b + ((b / 255) * AFactor)));
    };
    Result = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#" + pas.SysUtils.IntToHex(r,2) + pas.SysUtils.IntToHex(g,2) + pas.SysUtils.IntToHex(b,2));
    return Result;
  };
  this.SetTMSFNCDesignerTheme = function (ATheme) {
    $mod.TMSFNCDesignerTheme = ATheme;
  };
  this.GetTMSFNCDesignerTheme = function () {
    var Result = 0;
    Result = $mod.TMSFNCDesignerTheme;
    return Result;
  };
  this.SetEditorOKButtonAppearance = function (AButton, APrimaryColor, ARounding, AFontColor) {
    if (AButton != null) {
      AButton.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      AButton.FAppearance.FHoverStroke.SetColor(APrimaryColor);
      AButton.FAppearance.FDownStroke.SetColor(APrimaryColor);
      AButton.FAppearance.FFill.SetColor(APrimaryColor);
      AButton.FAppearance.FHoverFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      AButton.FAppearance.FHoverFill.SetColor(APrimaryColor);
      AButton.FAppearance.FDisabledStroke.SetColor(APrimaryColor);
      if ($mod.IsLightTheme()) {
        AButton.FAppearance.FDisabledFill.SetColor(16119285);
        AButton.FAppearance.FDisabledFont.SetColor(5592405);
      } else {
        AButton.FAppearance.FDisabledFill.SetColor(4406846);
        AButton.FAppearance.FDisabledFont.SetColor(11184810);
      };
      AButton.FAppearance.FHoverFill.SetColorTo($mod.EditorDarkerShadeColor(APrimaryColor,10,1));
      AButton.FAppearance.FDownFill.SetColor($mod.EditorLighterShadeColor(APrimaryColor,10,1));
      AButton.FAppearance.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      AButton.FAppearance.FHoverFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      AButton.FAppearance.FDownFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      AButton.FAppearance.FFont.SetColor(AFontColor);
      AButton.FAppearance.FHoverFont.SetColor(AFontColor);
      AButton.FAppearance.FDownFont.SetColor(AFontColor);
      AButton.FAppearance.SetRounding(ARounding);
    };
  };
  this.SetEditorCancelButtonAppearance = function (AButton, APrimaryColor, ARounding, AFontColor, ABackGroundColor) {
    var fc = 0;
    if (AButton != null) {
      if (AFontColor === -1) {
        if ($mod.IsLightTheme()) {
          fc = 5592405}
         else fc = 11184810;
      } else fc = AFontColor;
      AButton.FAppearance.FHoverFont.SetColor(APrimaryColor);
      AButton.FAppearance.FDownFont.SetColor(16777215);
      AButton.FAppearance.FHoverStroke.SetColor(APrimaryColor);
      AButton.FAppearance.FDownStroke.SetColor(APrimaryColor);
      AButton.FAppearance.FDownFill.SetColor($mod.EditorLighterShadeColor(APrimaryColor,10,1));
      AButton.FAppearance.FFont.SetColor(fc);
      AButton.FAppearance.FFill.SetColor(ABackGroundColor);
      AButton.FAppearance.FHoverFill.SetColor(ABackGroundColor);
      AButton.FAppearance.SetRounding(ARounding);
    };
  };
  this.SetEditorTabButtonAppearance = function (AButton, APrimaryColor, ARounding, AFontColor, ABackGroundColor) {
    var lc = 0;
    AButton.FAppearance.SetSelectionLine(true);
    AButton.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    AButton.FAppearance.FHoverStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    AButton.FAppearance.FDownStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    AButton.FAppearance.FDisabledFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
    AButton.FAppearance.FDisabledStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    AButton.FAppearance.FHoverFont.SetColor(APrimaryColor);
    AButton.FAppearance.FHoverFill.SetColor(APrimaryColor);
    lc = $mod.EditorLighterShadeColor(APrimaryColor,20,1);
    AButton.FAppearance.FDownFont.SetColor(lc);
    AButton.FAppearance.FDownFill.SetColor(lc);
    AButton.FAppearance.FSelectedFont.SetColor(lc);
    AButton.FAppearance.FSelectedFill.SetColor(lc);
    AButton.FAppearance.FSelectedStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    AButton.FAppearance.FDisabledFont.SetColor(7895160);
    AButton.FAppearance.SetRounding(ARounding);
    if (AFontColor === -1) {
      if ($mod.IsLightTheme()) {
        AButton.FAppearance.FFont.SetColor(5592405)}
       else AButton.FAppearance.FFont.SetColor(11184810);
    } else {
      AButton.FAppearance.FFont.SetColor(AFontColor);
    };
    if (ABackGroundColor === -1) {
      if ($mod.IsLightTheme()) {
        AButton.FAppearance.FFill.SetColor(16777215)}
       else AButton.FAppearance.FFill.SetColor(2894378);
    } else {
      AButton.FAppearance.FFill.SetColor(ABackGroundColor);
    };
  };
  this.SetEditorSubTabButtonAppearance = function (AButton, APrimaryColor, ARounding, AFontColor, ABackGroundColor) {
    var bc = 0;
    if (ABackGroundColor === -1) {
      if ($mod.IsLightTheme()) {
        bc = 16119285}
       else bc = 4406846;
      $mod.SetEditorTabButtonAppearance(AButton,APrimaryColor,ARounding,AFontColor,bc);
    } else $mod.SetEditorTabButtonAppearance(AButton,APrimaryColor,ARounding,AFontColor,ABackGroundColor);
  };
  this.SetEditorIconButtonAppearance = function (AButton, APrimaryColor, ARounding, AFontColor, ABackGroundColor) {
    var fc = 0;
    if (AButton != null) {
      if (AFontColor === -1) {
        if ($mod.IsLightTheme()) {
          fc = 5592405}
         else fc = 11184810;
      } else fc = AFontColor;
      AButton.FAppearance.SetRounding(ARounding);
      AButton.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      AButton.FAppearance.FDisabledFont.SetColor(7895160);
      AButton.FAppearance.FDisabledStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      AButton.FAppearance.FDisabledFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      AButton.FAppearance.FHoverStroke.SetColor(APrimaryColor);
      AButton.FAppearance.FDownStroke.SetColor(APrimaryColor);
      AButton.FAppearance.FHoverFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      AButton.FAppearance.FHoverFill.SetColor(ABackGroundColor);
      AButton.FAppearance.FDownFill.SetColor($mod.EditorDarkerShadeColor(APrimaryColor,10,1));
      AButton.FAppearance.FFill.SetColor(ABackGroundColor);
      AButton.FAppearance.FFont.SetColor(fc);
      AButton.FAppearance.FHoverFont.SetColor(APrimaryColor);
    };
  };
  this.SetEditorBitmapListAppearance = function (ABitmapListView, APrimaryColor, ARounding, AFontColor, ABackGroundColor) {
    var dc = 0;
    var fc = 0;
    if (ABitmapListView != null) {
      if (AFontColor === -1) {
        if ($mod.IsLightTheme()) {
          fc = 5592405}
         else fc = 11184810;
      } else fc = AFontColor;
      ABitmapListView.FAppearance.SetItemVerticalSpacing(ARounding);
      ABitmapListView.FAppearance.SetItemHorizontalSpacing(ARounding);
      ABitmapListView.FAppearance.SetItemRounding(ARounding);
      ABitmapListView.FAppearance.SetItemImageRounding(ARounding);
      ABitmapListView.FAppearance.FItemStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      ABitmapListView.FAppearance.FItemHoverFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      ABitmapListView.FAppearance.FItemHoverStroke.SetColor(APrimaryColor);
      ABitmapListView.FAppearance.FItemHoverFont.SetColor(APrimaryColor);
      ABitmapListView.FAppearance.FItemDownStroke.SetColor(APrimaryColor);
      dc = $mod.EditorLighterShadeColor(APrimaryColor,10,1);
      ABitmapListView.FAppearance.FItemDownFill.SetColor(dc);
      ABitmapListView.FAppearance.FItemSelectedStroke.SetColor($mod.EditorLighterShadeColor(dc,10,1));
      ABitmapListView.FAppearance.FItemSelectedFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      ABitmapListView.FAppearance.FItemSelectedFill.SetColor(APrimaryColor);
      ABitmapListView.FAppearance.FItemSelectedFill.SetColorTo($mod.EditorDarkerShadeColor(APrimaryColor,10,1));
      ABitmapListView.FAppearance.FItemSelectedFont.SetColor(16777215);
      ABitmapListView.FAppearance.FItemFill.SetColor(ABackGroundColor);
      ABitmapListView.FAppearance.FItemFont.SetColor(fc);
      ABitmapListView.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      ABitmapListView.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    };
  };
  this.SetEditorListAppearance = function (AEditorList, APrimaryColor, ARounding, AFontColor, ABackGroundColor) {
    var dc = 0;
    var fc = 0;
    if (AEditorList != null) {
      if (AFontColor === -1) {
        if ($mod.IsLightTheme()) {
          fc = 5592405}
         else fc = 11184810;
      } else fc = AFontColor;
      AEditorList.FAppearance.SetItemVerticalSpacing(ARounding);
      AEditorList.FAppearance.SetItemHorizontalSpacing(ARounding);
      AEditorList.FAppearance.SetItemRounding(ARounding);
      AEditorList.FAppearance.SetItemImageRounding(ARounding);
      AEditorList.FAppearance.FItemStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      AEditorList.FAppearance.FItemHoverFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      AEditorList.FAppearance.FItemHoverStroke.SetColor(APrimaryColor);
      AEditorList.FAppearance.FItemHoverFont.SetColor(APrimaryColor);
      AEditorList.FAppearance.FItemDownStroke.SetColor(APrimaryColor);
      dc = $mod.EditorLighterShadeColor(APrimaryColor,10,1);
      AEditorList.FAppearance.FItemDownFill.SetColor(dc);
      AEditorList.FAppearance.FItemSelectedStroke.SetColor($mod.EditorLighterShadeColor(dc,10,1));
      AEditorList.FAppearance.FItemSelectedFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      AEditorList.FAppearance.FItemSelectedFill.SetColor(APrimaryColor);
      AEditorList.FAppearance.FItemSelectedFill.SetColorTo($mod.EditorDarkerShadeColor(APrimaryColor,10,1));
      AEditorList.FAppearance.FItemSelectedFont.SetColor(16777215);
      AEditorList.FAppearance.FItemFill.SetColor(ABackGroundColor);
      AEditorList.FAppearance.FItemFont.SetColor(fc);
      if (ABackGroundColor !== -1) {
        AEditorList.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AEditorList.FAppearance.FFill.SetColor(ABackGroundColor);
      } else AEditorList.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      AEditorList.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    };
  };
  this.SetEditorBackPanelAppearance = function (APanel, ABackGroundColor, AStrokeColor, ARounding) {
    if (APanel != null) {
      APanel.FAppearance.SetRounding(ARounding);
      if (ABackGroundColor === -1) {
        if ($mod.IsLightTheme()) {
          APanel.FAppearance.FFill.SetColor(16777215);
        } else {
          APanel.FAppearance.FFill.SetColor(2894378);
        };
      } else APanel.FAppearance.FFill.SetColor(ABackGroundColor);
      if (AStrokeColor === -1) {
        if ($mod.IsLightTheme()) {
          APanel.FAppearance.FStroke.SetColor(15523534)}
         else APanel.FAppearance.FStroke.SetColor(7036495);
      } else APanel.FAppearance.FStroke.SetColor(AStrokeColor);
    };
  };
  this.SetEditorSubPanelAppearance = function (APanel, ABackGroundColor, AStrokeColor, ARounding) {
    if (APanel != null) {
      APanel.FAppearance.SetRounding(ARounding);
      if (ABackGroundColor === -1) {
        if ($mod.IsLightTheme()) {
          APanel.FAppearance.FFill.SetColor(16119285)}
         else APanel.FAppearance.FFill.SetColor(4406846);
      } else APanel.FAppearance.FFill.SetColor(ABackGroundColor);
      if (AStrokeColor === -1) {
        if ($mod.IsLightTheme()) {
          APanel.FAppearance.FStroke.SetColor(16119285)}
         else APanel.FAppearance.FStroke.SetColor(4406846);
      } else APanel.FAppearance.FStroke.SetColor(AStrokeColor);
    };
  };
  this.SetEditorLabelAppearance = function (ALabel, AFontColor) {
    if (ALabel != null) {
      if (AFontColor === -1) {
        if ($mod.IsLightTheme()) {
          ALabel.FFont.SetColor(5592405);
        } else {
          ALabel.FFont.SetColor(11184810);
        };
      } else {
        ALabel.FFont.SetColor(11184810);
      };
    };
  };
  this.SetEditorCheckBoxAppearance = function (ACheckBox, AFontColor) {
    if (ACheckBox != null) {
      if (AFontColor === -1) {
        if ($mod.IsLightTheme()) {
          ACheckBox.FFont.SetColor(5592405);
        } else {
          ACheckBox.FFont.SetColor(11184810);
        };
      } else {
        ACheckBox.FFont.SetColor(AFontColor);
      };
    };
  };
  this.SetEditorEditAppearance = function (AEdit, AFontColor, ABackGroundColor, AStrokeColor) {
    var fc = 0;
    var bc = 0;
    if (AFontColor === -1) {
      if ($mod.IsLightTheme()) {
        fc = 5592405}
       else fc = 11184810;
    } else fc = AFontColor;
    if (ABackGroundColor === -1) {
      if ($mod.IsLightTheme()) {
        bc = 16777215}
       else bc = 2894378;
    } else bc = ABackGroundColor;
    AEdit.SetColor(bc);
    AEdit.FFont.SetColor(fc);
  };
  this.GetEditorDefaultFontColor = function () {
    var Result = 0;
    if ($mod.IsLightTheme()) {
      Result = 5592405}
     else Result = 11184810;
    return Result;
  };
  this.SetEditorMemoAppearance = function (AMemo, AFontColor, ABackGroundColor, AStrokeColor) {
    var fc = 0;
    var bc = 0;
    if (AFontColor === -1) {
      if ($mod.IsLightTheme()) {
        fc = 5592405}
       else fc = 11184810;
    } else fc = AFontColor;
    if (ABackGroundColor === -1) {
      if ($mod.IsLightTheme()) {
        bc = 16777215}
       else bc = 2894378;
    } else bc = ABackGroundColor;
    AMemo.SetColor(bc);
    AMemo.FFont.SetColor(fc);
  };
  this.SetEditorDateTimeEditAppearance = function (ADateTimeEdit, AFontColor, ABackGroundColor, AStrokeColor) {
    var fc = 0;
    var bc = 0;
    if (AFontColor === -1) {
      if ($mod.IsLightTheme()) {
        fc = 5592405}
       else fc = 11184810;
    } else fc = AFontColor;
    if (ABackGroundColor === -1) {
      if ($mod.IsLightTheme()) {
        bc = 16777215}
       else bc = 2894378;
    } else bc = ABackGroundColor;
    ADateTimeEdit.SetColor(bc);
    ADateTimeEdit.FFont.SetColor(fc);
  };
  this.TMSFNCDesignerTheme = this.TTMSFNCEditorDesignerTheme.edtDefault;
  $mod.$implcode = function () {
    $impl.NoIDERunning = function () {
      var Result = false;
      if (pas["WEBLib.Forms"].Application.IDETheme() !== "") {
        Result = false;
        return Result;
      };
      Result = true;
      return Result;
    };
  };
},["WEBLib.TMSFNCGraphics","WEBLib.TMSFNCUtils","Math","SysUtils","WEBLib.Forms"]);
rtl.module("WEBLib.TMSFNCBitmapEditor",["System","Classes","WEBLib.TMSFNCCustomComponent","WEBLib.TMSFNCCustomControl","WEBLib.Controls","WEBLib.TMSFNCTypes","WEBLib.StdCtrls","WEBLib.ExtCtrls","WEBLib.TMSFNCBitmapContainer","WEBLib.Forms","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCEditorButton","WEBLib.TMSFNCEditorPanel","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 1;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCBitmapEditor");
  rtl.createClass(this,"TTMSFNCBitmapEditorComboBox",pas["WEBLib.StdCtrls"].TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCBitmapEditor",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.frm = null;
      this.FPanel = null;
      this.FTopPanel = null;
      this.FBitmap = null;
      this.FCopyBitmap = null;
      this.FButtonOk = null;
      this.FButtonCancel = null;
      this.FButtonOpen = null;
      this.FButtonClear = null;
      this.FImage = null;
      this.FBitmapContainer = null;
      this.FModified = false;
    };
    this.$final = function () {
      this.frm = undefined;
      this.FPanel = undefined;
      this.FTopPanel = undefined;
      this.FBitmap = undefined;
      this.FCopyBitmap = undefined;
      this.FButtonOk = undefined;
      this.FButtonCancel = undefined;
      this.FButtonOpen = undefined;
      this.FButtonClear = undefined;
      this.FImage = undefined;
      this.FBitmapContainer = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetBitmap = function (Value) {
      this.FBitmap = Value;
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.DoCopyBitmapChange = function (Sender) {
      this.FModified = true;
      if (this.FImage != null) this.FImage.Invalidate();
    };
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCBitmapEditor);
    };
    this.Notification = function (AComponent, AOperation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if ((AOperation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
    };
    this.BuildEditor = function (AParent) {
      if (AParent != null) {
        this.FTopPanel = pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanel.$create("Create$1",[AParent]);
        this.FTopPanel.SetPanelPosition(pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanelPosition.eppCenter);
        this.FTopPanel.SetAlign(pas["WEBLib.Controls"].TAlign.alTop);
        this.FTopPanel.SetTop(0);
        this.FTopPanel.SetParent(AParent);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorBackPanelAppearance(this.FTopPanel,-1,-1,5);
        this.FButtonClear = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FTopPanel]);
        this.FButtonClear.SetParent(this.FTopPanel);
        this.FButtonClear.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCBitmapEditorClear")));
        this.FButtonClear.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
        this.FButtonClear.SetLeft(30);
        this.FButtonClear.FMargins.SetRight(5);
        this.FButtonClear.FMargins.SetTop(5);
        this.FButtonClear.FMargins.SetBottom(5);
        this.FButtonClear.FMargins.SetLeft(5);
        this.FButtonClear.FOnClick = rtl.createCallback(this,"DoClearFile");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorTabButtonAppearance(this.FButtonClear,12482304,5,-1,-1);
        this.FButtonOpen = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FTopPanel]);
        this.FButtonOpen.SetParent(this.FTopPanel);
        this.FButtonOpen.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCBitmapEditorOpen")));
        this.FButtonOpen.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
        this.FButtonOpen.SetLeft(10);
        this.FButtonOpen.FMargins.SetRight(0);
        this.FButtonOpen.FMargins.SetTop(5);
        this.FButtonOpen.FMargins.SetBottom(5);
        this.FButtonOpen.FMargins.SetLeft(5);
        this.FButtonOpen.FOnClick = rtl.createCallback(this,"DoOpenFile");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorTabButtonAppearance(this.FButtonOpen,12482304,5,-1,-1);
        this.FTopPanel.SetHeight(37);
        this.FImage = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$create("Create$1",[AParent]);
        this.FImage.SetParent(AParent);
        this.FImage.SetControlAlignment(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient);
        this.FImage.DisableBackground();
        this.FImage.FOnClick = rtl.createCallback(this,"DoOpenFile");
        if (pas["WEBLib.TMSFNCEditorsTools"].IsLightTheme()) {
          this.FImage.SetColor(16119285);
        } else {
          this.FImage.SetColor(4406846);
        };
        this.FImage.DisableStroke();
        this.FImage.FOnAfterDraw = rtl.createCallback(this,"DoAfterDraw");
        this.FPanel = pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanel.$create("Create$1",[AParent]);
        this.FPanel.SetPanelPosition(pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanelPosition.eppCenter);
        this.FPanel.SetAlign(pas["WEBLib.Controls"].TAlign.alBottom);
        this.FPanel.SetParent(AParent);
        this.FPanel.SetHeight(37);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorBackPanelAppearance(this.FPanel,-1,-1,5);
        this.FButtonCancel = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FPanel]);
        this.FButtonCancel.FModalResult = 2;
        this.FButtonCancel.SetParent(this.FPanel);
        this.FButtonCancel.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCBitmapEditorCancel")));
        this.FButtonCancel.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
        this.FButtonCancel.SetLeft(99);
        this.FButtonCancel.SetAlignWithMargins(true);
        this.FButtonCancel.FMargins.SetRight(5);
        this.FButtonCancel.FMargins.SetTop(5);
        this.FButtonCancel.FMargins.SetBottom(5);
        this.FButtonCancel.FMargins.SetLeft(5);
        this.FButtonCancel.FOnClick = rtl.createCallback(this,"DoButtonCancelClick");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorCancelButtonAppearance(this.FButtonCancel,12482304,5,-1,-1);
        this.FButtonOk = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FPanel]);
        this.FButtonOk.FModalResult = 1;
        this.FButtonOk.SetParent(this.FPanel);
        this.FButtonOk.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCBitmapEditorOK")));
        this.FButtonOk.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
        this.FButtonOk.SetLeft(99);
        this.FButtonOk.SetAlignWithMargins(true);
        this.FButtonOk.FMargins.SetRight(0);
        this.FButtonOk.FMargins.SetTop(5);
        this.FButtonOk.FMargins.SetBottom(5);
        this.FButtonOk.FMargins.SetLeft(5);
        this.FButtonOk.FOnClick = rtl.createCallback(this,"DoButtonOKClick");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorOKButtonAppearance(this.FButtonOk,12482304,5,16777215);
      };
    };
    this.DoAfterDraw = function (Sender, AGraphics, ARect) {
      if (this.FCopyBitmap != null) {
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(ARect,-5,-5);
        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.FCopyBitmap,true,false,true,false);
      };
    };
    this.DoOpenFile = function (Sender) {
      var $Self = this;
      var od = null;
      var I = 0;
      var str = "";
      if (!(this.FImage != null)) return;
      od = pas["WEBLib.Dialogs"].TOpenDialog.$create("Create$1",[$Self]);
      od.Execute$1(function (AFileName) {
        for (var $l = 0, $end = od.FFiles.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          od.FFiles.GetItem$1(I).GetFileAsBase64$1(function (AValue) {
            str = "data:" + od.FFiles.GetItem$1(I).FMimeType + ";base64," + AValue;
            $Self.FCopyBitmap.LoadFromResource(str);
            $Self.FImage.Invalidate();
          });
        };
      });
    };
    this.DoFormKeyDown = function (Sender, Key, Shift) {
      if (Key.get() === 27) {
        this.frm.Close();
      } else if (Key.get() === 13) {
        this.frm.SetModalResult(1);
        this.frm.Close();
      };
    };
    this.ApplyCSS = function (ACSS) {
    };
    this.DoButtonOKClick = function (Sender) {
      if (this.frm != null) this.frm.SetModalResult(1);
    };
    this.DoButtonCancelClick = function (Sender) {
      if (this.frm != null) this.frm.SetModalResult(2);
    };
    this.DoClearFile = function (Sender) {
      this.FCopyBitmap.Assign(null);
      this.FImage.Invalidate();
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      this.FModified = false;
      this.FCopyBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FCopyBitmap.FOnChange = rtl.createCallback(this,"DoCopyBitmapChange");
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FCopyBitmap;
        }, set: function (v) {
          this.p.FCopyBitmap = v;
        }});
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Execute = function (AProc) {
      var $Self = this;
      this.FCopyBitmap.Assign(this.FBitmap);
      this.frm = $mod.TTMSFNCBitmapEditorForm.$create("CreateDialogNew$1",[$Self,"Bitmap Editor"]);
      this.frm.SetWidth(400);
      this.frm.SetHeight(500);
      this.frm.FOnKeyDown = rtl.createCallback($Self,"DoFormKeyDown");
      this.frm.SetPosition(pas["WEBLib.Forms"].TPosition.poScreenCenter);
      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ScaleForCurrentDPI(this.frm);
      this.frm.ShowModal$1(function (AResult) {
        if ((AResult === 1) && ($Self.FBitmap != null)) {
          $Self.FBitmap.Assign(null);
          $Self.FBitmap.Assign($Self.FCopyBitmap);
        };
        $Self.frm = null;
        if (AProc != null) AProc(AResult);
      });
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCBitmapEditor.isPrototypeOf(Source)) this.FBitmap = rtl.as(Source,$mod.TTMSFNCBitmapEditor).FBitmap;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapContainer",2,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"FBitmapContainer","SetBitmapContainer");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCBitmapEditorForm",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomDesignerForm,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomDesignerForm.$init.call(this);
      this.FBitmapEditor = null;
    };
    this.$final = function () {
      this.FBitmapEditor = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomDesignerForm.$final.call(this);
    };
    this.Loaded = function () {
      var css = "";
      pas["WEBLib.Forms"].TCustomForm.Loaded.call(this);
      css = pas["WEBLib.Forms"].Application.IDECSS();
      if (css !== "") {
        this.AddCSS("IDECSS",css);
        this.SetElementClassName("IDEBkg");
        this.FCaptionElement.setAttribute("class","IDECaption IDEFont");
        if (this.FBitmapEditor != null) this.FBitmapEditor.ApplyCSS(css);
      };
    };
    this.LoadDFMValues = function () {
      pas["WEBLib.Forms"].TCustomForm.LoadDFMValues.call(this);
      if (this.FBitmapEditor != null) {
        this.FBitmapEditor.BuildEditor(this);
        this.SetActiveControl(this.FBitmapEditor.FTopPanel);
      };
    };
    this.CreateDialogNew$1 = function (ABitmapEditor, ACaption) {
      this.FBitmapEditor = ABitmapEditor;
      pas["WEBLib.Forms"].TCustomForm.CreateDialogNew.call(this,ACaption);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$resourcestrings = {sTMSFNCBitmapEditorOK: {org: "OK"}, sTMSFNCBitmapEditorCancel: {org: "Cancel"}, sTMSFNCBitmapEditorOpen: {org: "&Open"}, sTMSFNCBitmapEditorSave: {org: "&Save"}, sTMSFNCBitmapEditorClear: {org: "&Clear"}};
  $mod.$implcode = function () {
    $impl.TranslateTextEx = function (AText) {
      var Result = "";
      Result = AText;
      return Result;
    };
  };
},["WEBLib.TMSFNCUtils","WEBLib.Graphics","SysUtils","WEBLib.Dialogs","WEBLib.TMSFNCEditorsTools","WEBLib.WebTools"]);
rtl.module("WEBLib.TMSFNCURLBitmapContainer",["System","Classes","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TTMSFNCURLBitmapContainer");
  rtl.createClass(this,"TTMSFNCURLBitmapItem",pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem.$init.call(this);
      this.FURL = "";
      this.FLoaded = false;
    };
    this.SetURL = function (Value) {
      if (this.FURL !== Value) {
        this.FURL = Value;
        this.FLoaded = false;
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCURLBitmapItem.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,$mod.TTMSFNCURLBitmapItem).FName;
        this.FTag = rtl.as(Source,$mod.TTMSFNCURLBitmapItem).FTag;
        this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCURLBitmapItem).FBitmap);
        this.SetURL(rtl.as(Source,$mod.TTMSFNCURLBitmapItem).FURL);
      } else if (pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem).FName;
        this.FTag = rtl.as(Source,pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem).FTag;
        this.FBitmap.Assign(rtl.as(Source,pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem).FBitmap);
      } else pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
  });
  rtl.createClass(this,"TTMSFNCURLBitmapCollection",pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapCollection,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItemEx(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetBitmapItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCURLBitmapItem;
      return Result;
    };
    this.Add$2 = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapCollection.Add$1.call(this);
      return Result;
    };
    this.Insert$2 = function (index) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapCollection.Insert$1.call(this,index);
      return Result;
    };
  });
  this.$rtti.$MethodVar("TTMSFNCURLBitmapContainerDownloadCompleteEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCURLBitmapContainerDownloadProgressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ItemIndex",rtl.longint],["Position",rtl.nativeint],["TotalSize",rtl.nativeint]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCURLBitmapContainer",pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapContainer,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapContainer.$init.call(this);
      this.FDefaultBitmap = null;
      this.FOnDownloadComplete = null;
      this.FOnDownloadProgress = null;
      this.FOnInternalDownloadComplete = null;
    };
    this.$final = function () {
      this.FDefaultBitmap = undefined;
      this.FOnDownloadComplete = undefined;
      this.FOnDownloadProgress = undefined;
      this.FOnInternalDownloadComplete = undefined;
      pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapContainer.$final.call(this);
    };
    this.SetDefaultBitmap = function (Value) {
      this.FDefaultBitmap.Assign(Value);
    };
    this.GetItems$1 = function () {
      var Result = null;
      Result = this.GetItems();
      return Result;
    };
    this.SetItems$1 = function (Value) {
      this.GetItems().Assign(Value);
    };
    this.DoProgress = function () {
    };
    this.DoComplete = function () {
    };
    this.ThreadTerminated = function (Sender) {
    };
    this.CreateItems = function () {
      var Result = null;
      Result = $mod.TTMSFNCURLBitmapCollection.$create("Create$3",[this]);
      return Result;
    };
    this.DoDownloadComplete = function (ItemIndex) {
      if (this.FOnInternalDownloadComplete != null) this.FOnInternalDownloadComplete(this,ItemIndex);
      if (this.FOnDownloadComplete != null) this.FOnDownloadComplete(this,ItemIndex);
      this.Changed();
    };
    this.DoDownloadProgress = function (ItemIndex, Position, TotalSize) {
      if (this.FOnDownloadProgress != null) this.FOnDownloadProgress(this,ItemIndex,Position,TotalSize);
    };
    this.RegisterRuntimeClasses = function () {
      pas.Classes.RegisterClass($mod.TTMSFNCURLBitmapContainer);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapContainer.Create$1.apply(this,arguments);
      this.FDefaultBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FDefaultBitmap");
      pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapContainer.Destroy.call(this);
    };
    this.FindBitmap$1 = function (s) {
      var Result = null;
      var it = null;
      var I = 0;
      Result = null;
      it = null;
      s = pas.SysUtils.UpperCase(s);
      I = 1;
      while (I <= this.GetItems$1().GetCount()) {
        if (pas.SysUtils.UpperCase(this.GetItems$1().GetItem$1(I - 1).FName) === s) {
          it = this.GetItems$1().GetItem$1(I - 1);
          break;
        };
        I += 1;
      };
      if (it != null) Result = it.FBitmap;
      if (pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(Result)) Result = this.FDefaultBitmap;
      return Result;
    };
    this.FindBitmapByURL = function (AURL) {
      var Result = null;
      var s = "";
      var i = 0;
      Result = null;
      s = pas.SysUtils.UpperCase(AURL);
      i = 1;
      while (i <= this.GetItems$1().GetCount()) {
        if (pas.SysUtils.UpperCase(this.GetItems$1().GetItem$1(i - 1).FURL) === s) {
          Result = this.GetItems$1().GetItem$1(i - 1).FBitmap;
          break;
        };
        i += 1;
      };
      return Result;
    };
    this.Download = function (URL) {
      var Result = null;
      this.DoProgress();
      return Result;
    };
    this.AddFromURL = function (URL, BitmapName) {
      pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapContainer.AddFromURL.apply(this,arguments);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainerGetItem);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCURLBitmapCollection"],"GetItems$1","SetItems$1");
    $r.addProperty("DefaultBitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FDefaultBitmap","SetDefaultBitmap");
    $r.addProperty("OnDownloadComplete",0,$mod.$rtti["TTMSFNCURLBitmapContainerDownloadCompleteEvent"],"FOnDownloadComplete","FOnDownloadComplete");
    $r.addProperty("OnDownloadProgress",0,$mod.$rtti["TTMSFNCURLBitmapContainerDownloadProgressEvent"],"FOnDownloadProgress","FOnDownloadProgress");
  });
},["SysUtils","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCEditorListView",["System","Classes","Types","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.StdCtrls","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCBitmapEditor","WEBLib.Forms","WEBLib.TMSFNCCustomControl"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 1;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.TTMSFNCListEditorItemRectType = {"0": "eirtNone", eirtNone: 0, "1": "eirtItem", eirtItem: 1, "2": "eirtImage", eirtImage: 2, "3": "eirtName", eirtName: 3, "4": "eirtNoteText", eirtNoteText: 4, "5": "eirtAccessory", eirtAccessory: 5};
  this.$rtti.$Enum("TTMSFNCListEditorItemRectType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCListEditorItemRectType});
  this.$rtti.$Class("TTMSFNCEditorListView");
  rtl.createClass(this,"TTMSFNCEditorListViewAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FItemDownStroke = null;
      this.FItemFont = null;
      this.FItemSelectedFill = null;
      this.FItemHoverFont = null;
      this.FEditFont = null;
      this.FItemFill = null;
      this.FItemSelectedStroke = null;
      this.FItemHoverFill = null;
      this.FItemStroke = null;
      this.FItemDownFont = null;
      this.FItemHoverStroke = null;
      this.FOnChanged = null;
      this.FFill = null;
      this.FItemDownFill = null;
      this.FItemSelectedFont = null;
      this.FStroke = null;
      this.FItemVerticalSpacing = 0.0;
      this.FItemRounding = 0;
      this.FItemImageHoverStroke = null;
      this.FItemImageDownFill = null;
      this.FItemImageDownStroke = null;
      this.FItemImageSelectedFill = null;
      this.FItemImageFill = null;
      this.FItemImageSelectedStroke = null;
      this.FItemImageHoverFill = null;
      this.FItemImageStroke = null;
      this.FItemImageRounding = 0;
      this.FUseImageAppearance = false;
      this.FItemHorizontalSpacing = 0.0;
      this.FItemHorizontalTextMargin = 0.0;
      this.FItemDisabledFill = null;
      this.FItemDisabledStroke = null;
      this.FItemDisabledFont = null;
      this.FSplitter = null;
      this.FSplitterMarginLeft = 0;
      this.FSplitterMarginRight = 0;
      this.FDrawItemImageStroke = false;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FItemDownStroke = undefined;
      this.FItemFont = undefined;
      this.FItemSelectedFill = undefined;
      this.FItemHoverFont = undefined;
      this.FEditFont = undefined;
      this.FItemFill = undefined;
      this.FItemSelectedStroke = undefined;
      this.FItemHoverFill = undefined;
      this.FItemStroke = undefined;
      this.FItemDownFont = undefined;
      this.FItemHoverStroke = undefined;
      this.FOnChanged = undefined;
      this.FFill = undefined;
      this.FItemDownFill = undefined;
      this.FItemSelectedFont = undefined;
      this.FStroke = undefined;
      this.FItemImageHoverStroke = undefined;
      this.FItemImageDownFill = undefined;
      this.FItemImageDownStroke = undefined;
      this.FItemImageSelectedFill = undefined;
      this.FItemImageFill = undefined;
      this.FItemImageSelectedStroke = undefined;
      this.FItemImageHoverFill = undefined;
      this.FItemImageStroke = undefined;
      this.FItemDisabledFill = undefined;
      this.FItemDisabledStroke = undefined;
      this.FItemDisabledFont = undefined;
      this.FSplitter = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetEditFont = function (Value) {
      this.FEditFont.Assign(Value);
      this.DoEditFontChanged(this);
    };
    this.SetItemDownFill = function (Value) {
      this.FItemDownFill.Assign(Value);
      this.DoItemFillChanged(this);
    };
    this.SetItemDownFont = function (Value) {
      this.FItemDownFont.Assign(Value);
      this.DoItemFontChanged(this);
    };
    this.SetItemDownStroke = function (Value) {
      this.FItemDownStroke.Assign(Value);
      this.DoItemStrokeChanged(this);
    };
    this.SetItemFill = function (Value) {
      this.FItemFill.Assign(Value);
      this.DoItemFillChanged(this);
    };
    this.SetItemFont = function (Value) {
      this.FItemFont.Assign(Value);
      this.DoItemFontChanged(this);
    };
    this.SetItemHoverFill = function (Value) {
      this.FItemHoverFill.Assign(Value);
      this.DoItemFillChanged(this);
    };
    this.SetItemHoverFont = function (Value) {
      this.FItemHoverFont.Assign(Value);
      this.DoItemFontChanged(this);
    };
    this.SetItemHoverStroke = function (Value) {
      this.FItemHoverStroke.Assign(Value);
      this.DoItemStrokeChanged(this);
    };
    this.SetItemSelectedFill = function (Value) {
      this.FItemSelectedFill.Assign(Value);
      this.DoItemFillChanged(this);
    };
    this.SetItemSelectedFont = function (Value) {
      this.FItemSelectedFont.Assign(Value);
      this.DoItemFontChanged(this);
    };
    this.SetItemSelectedStroke = function (Value) {
      this.FItemSelectedStroke.Assign(Value);
      this.DoItemFillChanged(this);
    };
    this.SetItemStroke = function (Value) {
      this.FItemStroke.Assign(Value);
      this.DoItemStrokeChanged(this);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetItemVerticalSpacing = function (Value) {
      if (this.FItemVerticalSpacing !== Value) {
        this.FItemVerticalSpacing = Value;
        this.DoChanged(this);
      };
    };
    this.SetItemRounding = function (Value) {
      if (this.FItemRounding !== Value) {
        this.FItemRounding = Value;
        this.DoChanged(this);
      };
    };
    this.SetItemImageDownFill = function (Value) {
      this.FItemImageDownFill.Assign(Value);
      this.DoItemImageFillChanged(this);
    };
    this.SetItemImageDownStroke = function (Value) {
      this.FItemImageDownStroke.Assign(Value);
      this.DoItemImageStrokeChanged(this);
    };
    this.SetItemImageFill = function (Value) {
      this.FItemImageFill.Assign(Value);
      this.DoItemImageFillChanged(this);
    };
    this.SetItemImageHoverFill = function (Value) {
      this.FItemImageHoverFill.Assign(Value);
      this.DoItemImageFillChanged(this);
    };
    this.SetItemImageHoverStroke = function (Value) {
      this.FItemImageHoverStroke.Assign(Value);
      this.DoItemImageStrokeChanged(this);
    };
    this.SetItemImageSelectedFill = function (Value) {
      this.FItemImageSelectedFill.Assign(Value);
      this.DoItemImageFillChanged(this);
    };
    this.SetItemImageSelectedStroke = function (Value) {
      this.FItemImageSelectedStroke.Assign(Value);
      this.DoItemImageStrokeChanged(this);
    };
    this.SetItemImageStroke = function (Value) {
      this.FItemImageStroke.Assign(Value);
      this.DoItemImageStrokeChanged(this);
    };
    this.SetItemImageRounding = function (Value) {
      if (this.FItemImageRounding !== Value) {
        this.FItemImageRounding = Value;
        this.DoImageChanged(this);
      };
    };
    this.SetUseImageAppearance = function (Value) {
      if (this.FUseImageAppearance !== Value) {
        this.FUseImageAppearance = Value;
        this.DoChanged(this);
      };
    };
    this.SetItemHorizontalSpacing = function (Value) {
      if (this.FItemHorizontalSpacing !== Value) {
        this.FItemHorizontalSpacing = Value;
        this.DoChanged(this);
      };
    };
    this.SetItemHorizontalTextMargin = function (Value) {
      if (this.FItemHorizontalTextMargin !== Value) {
        this.FItemHorizontalTextMargin = Value;
        this.DoChanged(this);
      };
    };
    this.IsItemHorizontalSpacingStored = function () {
      var Result = false;
      Result = this.FItemHorizontalSpacing !== 0;
      return Result;
    };
    this.IsItemHorizontalTextMarginStored = function () {
      var Result = false;
      Result = this.FItemHorizontalTextMargin !== 5;
      return Result;
    };
    this.IsItemVerticalSpacingStored = function () {
      var Result = false;
      Result = this.FItemVerticalSpacing !== 0;
      return Result;
    };
    this.SetItemDisabledFill = function (Value) {
      this.FItemDisabledFill.Assign(Value);
      this.DoItemFillChanged(this);
    };
    this.SetItemDisabledFont = function (Value) {
      this.FItemDisabledFont.Assign(Value);
      this.DoItemFontChanged(this);
    };
    this.SetItemDisabledStroke = function (Value) {
      this.FItemDisabledStroke.Assign(Value);
      this.DoItemStrokeChanged(this);
    };
    this.SetSplitter = function (Value) {
      this.FSplitter.Assign(Value);
      this.DoStrokeChanged(this);
    };
    this.SetSplitterMarginLeft = function (Value) {
      if (this.FSplitterMarginLeft !== Value) {
        this.FSplitterMarginLeft = Value;
        this.DoChanged(this);
      };
    };
    this.SetSplitterMarginRight = function (Value) {
      if (this.FSplitterMarginRight !== Value) {
        this.FSplitterMarginRight = Value;
        this.DoChanged(this);
      };
    };
    this.SetDrawItemImageStroke = function (Value) {
      if (this.FDrawItemImageStroke !== Value) {
        this.FDrawItemImageStroke = Value;
        this.DoChanged(this);
      };
    };
    this.DoChanged = function (Sender) {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.DoImageChanged = function (Sender) {
      this.DoChanged(this);
    };
    this.DoFillChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoEditFontChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoStrokeChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoItemFillChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoItemFontChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoItemStrokeChanged = function (Sender) {
      this.DoChanged(Sender);
    };
    this.DoItemImageFillChanged = function (Sender) {
      this.DoImageChanged(Sender);
    };
    this.DoItemImageStrokeChanged = function (Sender) {
      this.DoImageChanged(Sender);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FItemVerticalSpacing = 0;
      this.FItemHorizontalSpacing = 0;
      this.FItemHorizontalTextMargin = 5;
      this.FItemRounding = 0;
      this.FItemImageRounding = 0;
      this.FDrawItemImageStroke = true;
      this.FSplitterMarginLeft = 4;
      this.FSplitterMarginRight = 4;
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FEditFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FItemFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FItemFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FItemStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FItemHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#4edbfa"),8421504,-1,-1]);
      this.FItemHoverFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FItemHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FItemDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FItemDownFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FItemDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#4edbfa"),1.0]);
      this.FItemDisabledFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FItemDisabledFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FItemDisabledFont.SetColor(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#7a7a7a"));
      this.FItemDisabledStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#7a7a7a"),1.0]);
      this.FItemSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FItemSelectedFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FItemSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FItemImageFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FItemImageStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FItemImageHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#4edbfa"),8421504,-1,-1]);
      this.FItemImageHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FItemImageDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FItemImageDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#4edbfa"),1.0]);
      this.FItemImageSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),8421504,-1,-1]);
      this.FItemImageSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FSplitter = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8"),1.0]);
      this.FFill.FOnChanged = rtl.createCallback(this,"DoFillChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      this.FEditFont.FOnChanged = rtl.createCallback(this,"DoEditFontChanged");
      this.FItemFill.FOnChanged = rtl.createCallback(this,"DoItemFillChanged");
      this.FItemFont.FOnChanged = rtl.createCallback(this,"DoItemFontChanged");
      this.FItemStroke.FOnChanged = rtl.createCallback(this,"DoItemStrokeChanged");
      this.FItemHoverFill.FOnChanged = rtl.createCallback(this,"DoItemFillChanged");
      this.FItemHoverFont.FOnChanged = rtl.createCallback(this,"DoItemFontChanged");
      this.FItemHoverStroke.FOnChanged = rtl.createCallback(this,"DoItemStrokeChanged");
      this.FItemDownFill.FOnChanged = rtl.createCallback(this,"DoItemFillChanged");
      this.FItemDownFont.FOnChanged = rtl.createCallback(this,"DoItemFontChanged");
      this.FItemDownStroke.FOnChanged = rtl.createCallback(this,"DoItemStrokeChanged");
      this.FItemSelectedFill.FOnChanged = rtl.createCallback(this,"DoItemFillChanged");
      this.FItemSelectedFont.FOnChanged = rtl.createCallback(this,"DoItemFontChanged");
      this.FItemSelectedStroke.FOnChanged = rtl.createCallback(this,"DoItemStrokeChanged");
      this.FItemDisabledFill.FOnChanged = rtl.createCallback(this,"DoItemFillChanged");
      this.FItemDisabledFont.FOnChanged = rtl.createCallback(this,"DoItemFontChanged");
      this.FItemDisabledStroke.FOnChanged = rtl.createCallback(this,"DoItemStrokeChanged");
      this.FItemImageFill.FOnChanged = rtl.createCallback(this,"DoItemImageFillChanged");
      this.FItemImageStroke.FOnChanged = rtl.createCallback(this,"DoItemImageStrokeChanged");
      this.FItemImageHoverFill.FOnChanged = rtl.createCallback(this,"DoItemImageFillChanged");
      this.FItemImageHoverStroke.FOnChanged = rtl.createCallback(this,"DoItemImageStrokeChanged");
      this.FItemImageDownFill.FOnChanged = rtl.createCallback(this,"DoItemImageFillChanged");
      this.FItemImageDownStroke.FOnChanged = rtl.createCallback(this,"DoItemImageStrokeChanged");
      this.FItemImageSelectedFill.FOnChanged = rtl.createCallback(this,"DoItemImageFillChanged");
      this.FItemImageSelectedStroke.FOnChanged = rtl.createCallback(this,"DoItemImageStrokeChanged");
      this.FSplitter.FOnChanged = rtl.createCallback(this,"DoStrokeChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FEditFont");
      rtl.free(this,"FItemFill");
      rtl.free(this,"FItemFont");
      rtl.free(this,"FItemStroke");
      rtl.free(this,"FItemHoverFill");
      rtl.free(this,"FItemHoverFont");
      rtl.free(this,"FItemHoverStroke");
      rtl.free(this,"FItemDownFill");
      rtl.free(this,"FItemDownFont");
      rtl.free(this,"FItemDownStroke");
      rtl.free(this,"FItemSelectedFill");
      rtl.free(this,"FItemSelectedFont");
      rtl.free(this,"FItemSelectedStroke");
      rtl.free(this,"FItemDisabledFill");
      rtl.free(this,"FItemDisabledFont");
      rtl.free(this,"FItemDisabledStroke");
      rtl.free(this,"FSplitter");
      rtl.free(this,"FItemImageFill");
      rtl.free(this,"FItemImageStroke");
      rtl.free(this,"FItemImageHoverFill");
      rtl.free(this,"FItemImageHoverStroke");
      rtl.free(this,"FItemImageDownFill");
      rtl.free(this,"FItemImageDownStroke");
      rtl.free(this,"FItemImageSelectedFill");
      rtl.free(this,"FItemImageSelectedStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCEditorListViewAppearance.isPrototypeOf(Source)) {
        this.FUseImageAppearance = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FUseImageAppearance;
        this.FItemRounding = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemRounding;
        this.FItemImageRounding = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageRounding;
        this.FDrawItemImageStroke = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FDrawItemImageStroke;
        this.FItemVerticalSpacing = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemVerticalSpacing;
        this.FItemHorizontalSpacing = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemHorizontalSpacing;
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FStroke);
        this.FEditFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FEditFont);
        this.FItemFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemFill);
        this.FItemFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemFont);
        this.FItemStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemStroke);
        this.FItemHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemHoverFill);
        this.FItemHoverFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemHoverFont);
        this.FItemHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemHoverStroke);
        this.FItemDownFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemDownFill);
        this.FItemDownFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemDownFont);
        this.FItemDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemDownStroke);
        this.FItemSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemSelectedFill);
        this.FItemSelectedFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemSelectedFont);
        this.FItemSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemSelectedStroke);
        this.FItemDisabledFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemDisabledFill);
        this.FItemDisabledFont.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemDisabledFont);
        this.FItemDisabledStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemDisabledStroke);
        this.FSplitter.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FSplitter);
        this.FSplitterMarginLeft = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FSplitterMarginLeft;
        this.FSplitterMarginRight = rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FSplitterMarginRight;
        this.FItemImageFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageFill);
        this.FItemImageStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageStroke);
        this.FItemImageHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageHoverFill);
        this.FItemImageHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageHoverStroke);
        this.FItemImageDownFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageDownFill);
        this.FItemImageDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageDownStroke);
        this.FItemImageSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageSelectedFill);
        this.FItemImageSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCEditorListViewAppearance).FItemImageSelectedStroke);
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetItemFill");
    $r.addProperty("EditFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FEditFont","SetEditFont");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("ItemHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemHoverFill","SetItemHoverFill");
    $r.addProperty("ItemHoverFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FItemHoverFont","SetItemHoverFont");
    $r.addProperty("ItemHoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemHoverStroke","SetItemHoverStroke");
    $r.addProperty("ItemDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemDownFill","SetItemDownFill");
    $r.addProperty("ItemDownFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FItemDownFont","SetItemDownFont");
    $r.addProperty("ItemDownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemDownStroke","SetItemDownStroke");
    $r.addProperty("ItemSelectedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemSelectedFill","SetItemSelectedFill");
    $r.addProperty("ItemSelectedFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FItemSelectedFont","SetItemSelectedFont");
    $r.addProperty("ItemSelectedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemSelectedStroke","SetItemSelectedStroke");
    $r.addProperty("ItemDisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemDisabledFill","SetItemDisabledFill");
    $r.addProperty("ItemDisabledFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FItemDisabledFont","SetItemDisabledFont");
    $r.addProperty("ItemDisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemDisabledStroke","SetItemDisabledStroke");
    $r.addProperty("ItemFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemFill","SetItemFill");
    $r.addProperty("ItemFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FItemFont","SetItemFont");
    $r.addProperty("ItemStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemStroke","SetItemStroke");
    $r.addProperty("ItemImageHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemImageHoverFill","SetItemImageHoverFill");
    $r.addProperty("ItemImageHoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemImageHoverStroke","SetItemImageHoverStroke");
    $r.addProperty("ItemImageDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemImageDownFill","SetItemImageDownFill");
    $r.addProperty("ItemImageDownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemImageDownStroke","SetItemImageDownStroke");
    $r.addProperty("ItemImageSelectedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemImageSelectedFill","SetItemImageSelectedFill");
    $r.addProperty("ItemImageSelectedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemImageSelectedStroke","SetItemImageSelectedStroke");
    $r.addProperty("ItemImageFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FItemImageFill","SetItemImageFill");
    $r.addProperty("ItemImageStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FItemImageStroke","SetItemImageStroke");
    $r.addProperty("ItemVerticalSpacing",14,rtl.double,"FItemVerticalSpacing","SetItemVerticalSpacing",4,{stored: "IsItemVerticalSpacingStored"});
    $r.addProperty("ItemHorizontalTextMargin",14,rtl.double,"FItemHorizontalTextMargin","SetItemHorizontalTextMargin",4,{stored: "IsItemHorizontalTextMarginStored"});
    $r.addProperty("ItemHorizontalSpacing",14,rtl.double,"FItemHorizontalSpacing","SetItemHorizontalSpacing",4,{stored: "IsItemHorizontalSpacingStored"});
    $r.addProperty("ItemRounding",2,rtl.longint,"FItemRounding","SetItemRounding");
    $r.addProperty("ItemImageRounding",2,rtl.longint,"FItemImageRounding","SetItemImageRounding");
    $r.addProperty("UseImageAppearance",2,rtl.boolean,"FUseImageAppearance","SetUseImageAppearance");
    $r.addProperty("Splitter",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FSplitter","SetSplitter");
    $r.addProperty("SplitterMarginLeft",2,rtl.longint,"FSplitterMarginLeft","SetSplitterMarginLeft",4,{Default: 4});
    $r.addProperty("SplitterMarginRight",2,rtl.longint,"FSplitterMarginRight","SetSplitterMarginRight",4,{Default: 4});
    $r.addProperty("DrawItemImageStroke",2,rtl.boolean,"FDrawItemImageStroke","SetDrawItemImageStroke",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCEditorListItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FNameText = "";
      this.FAccelPos = 0;
      this.FDrawRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FControlRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FAccessoryRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FImgRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FNameRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FNameTextRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FNoteRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FNoteTextRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FBitmap = null;
      this.FTag = 0;
      this.FName = "";
      this.FDataObject = null;
      this.FNoteText = "";
      this.FOnChanged = null;
      this.FItemHeight = 0.0;
      this.FSelected = false;
      this.FFontColor = 0;
      this.FSelectedFontColor = 0;
      this.FControlAlignment = 0;
      this.FControl = null;
      this.FControlPosition = 0;
      this.FDataString = "";
      this.FIsSplitter = false;
      this.FEnabled = false;
      this.FHorizontalNoteAlign = 0;
      this.FHorizontalNameAlign = 0;
      this.FAccessoryBitmap = null;
      this.FAccessoryClickable = false;
    };
    this.$final = function () {
      this.FDrawRect = undefined;
      this.FControlRect = undefined;
      this.FAccessoryRect = undefined;
      this.FImgRect = undefined;
      this.FNameRect = undefined;
      this.FNameTextRect = undefined;
      this.FNoteRect = undefined;
      this.FNoteTextRect = undefined;
      this.FBitmap = undefined;
      this.FDataObject = undefined;
      this.FOnChanged = undefined;
      this.FControl = undefined;
      this.FAccessoryBitmap = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetBitmap = function (Value) {
      this.FBitmap.Assign(Value);
    };
    this.SetDataObject = function (Value) {
      if (this.FDataObject !== Value) {
        this.FDataObject = Value;
        this.DoChanged();
      };
    };
    this.SetNoteText = function (Value) {
      if (this.FNoteText !== Value) {
        this.FNoteText = Value;
        this.DoChanged();
      };
    };
    this.SetName = function (Value) {
      if (this.FName !== Value) {
        this.FName = Value;
        this.DoChanged();
      };
    };
    this.DoChanged = function () {
      if (this.FOnChanged != null) this.FOnChanged(this);
      if ($mod.TTMSFNCEditorListCollection.isPrototypeOf(this.FCollection)) {
        if (rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection) != null) rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).DoChanged();
      };
    };
    this.DoSelectItemChanged = function (AIndex, AItem, ASelected) {
      if ($mod.TTMSFNCEditorListCollection.isPrototypeOf(this.FCollection) && (rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).FOwner$1 != null) && $mod.TTMSFNCEditorListView.isPrototypeOf(rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).FOwner$1)) {
        rtl.as(rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).FOwner$1,$mod.TTMSFNCEditorListView).DoSelectItemChanged(AIndex,AItem,ASelected);
      };
    };
    this.SetItemHeight = function (Value) {
      if (this.FItemHeight !== Value) {
        this.FItemHeight = Value;
        this.DoChanged();
      };
    };
    this.SetSelected = function (Value) {
      if (this.FSelected !== Value) {
        this.FSelected = Value;
        this.DoSelectItemChanged(this.GetIndex(),this,this.FSelected);
      };
    };
    this.SetFontColor = function (Value) {
      if (this.FFontColor !== Value) {
        this.FFontColor = Value;
        this.DoChanged();
      };
    };
    this.SetSelectedFontColor = function (Value) {
      if (this.FSelectedFontColor !== Value) {
        this.FSelectedFontColor = Value;
        this.DoChanged();
      };
    };
    this.SetControl = function (Value) {
      if (this.FControl !== Value) {
        this.FControl = Value;
        this.DoChanged();
      };
    };
    this.SetControlAlignment = function (Value) {
      if (this.FControlAlignment !== Value) {
        this.FControlAlignment = Value;
        this.DoChanged();
      };
    };
    this.SetControlPosition = function (Value) {
      if (this.FControlPosition !== Value) {
        this.FControlPosition = Value;
        this.DoChanged();
      };
    };
    this.SetDataString = function (Value) {
      if (this.FDataString !== Value) {
        this.FDataString = Value;
        this.DoChanged();
      };
    };
    this.SetIsSplitter = function (Value) {
      if (this.FIsSplitter !== Value) {
        this.FIsSplitter = Value;
        this.DoChanged();
      };
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.DoChanged();
      };
    };
    this.IsItemHeightStored = function () {
      var Result = false;
      Result = this.FItemHeight !== 60;
      return Result;
    };
    this.SetHorizontalNameAlign = function (Value) {
      if (this.FHorizontalNameAlign !== Value) {
        this.FHorizontalNameAlign = Value;
        this.DoChanged();
      };
    };
    this.SetHorizontalNoteAlign = function (Value) {
      if (this.FHorizontalNoteAlign !== Value) {
        this.FHorizontalNoteAlign = Value;
        this.DoChanged();
      };
    };
    this.SetAccessoryBitmap = function (Value) {
      this.FAccessoryBitmap.Assign(Value);
    };
    this.SetAccessoryClickable = function (Value) {
      this.FAccessoryClickable = Value;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FControl = null;
      this.FControlAlignment = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone;
      this.FControlPosition = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterCenter;
      this.FDrawRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FAccessoryRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FImgRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FNameRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FNoteRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
      this.FAccessoryBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FAccessoryBitmap.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
      this.FName = "";
      this.FFontColor = -1;
      this.FSelectedFontColor = -1;
      this.FHorizontalNameAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FHorizontalNoteAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FSelected = false;
      this.FIsSplitter = false;
      this.FEnabled = true;
      if ((this.FCollection != null) && $mod.TTMSFNCEditorListCollection.isPrototypeOf(this.FCollection) && (rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).FOwner$1 != null) && $mod.TTMSFNCEditorListView.isPrototypeOf(rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).FOwner$1)) {
        this.FItemHeight = rtl.as(rtl.as(this.FCollection,$mod.TTMSFNCEditorListCollection).FOwner$1,$mod.TTMSFNCEditorListView).FDefaultItemHeight;
      } else this.FItemHeight = 60;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAccessoryBitmap");
      rtl.free(this,"FBitmap");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.DoBitmapChanged = function (Sender) {
      this.DoChanged();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCEditorListItem.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,$mod.TTMSFNCEditorListItem).FName;
        this.FTag = rtl.as(Source,$mod.TTMSFNCEditorListItem).FTag;
        this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCEditorListItem).FBitmap);
        this.FAccessoryBitmap.Assign(rtl.as(Source,$mod.TTMSFNCEditorListItem).FAccessoryBitmap);
        this.FDataObject = rtl.as(Source,$mod.TTMSFNCEditorListItem).FDataObject;
        this.FItemHeight = rtl.as(Source,$mod.TTMSFNCEditorListItem).FItemHeight;
      } else if (pas["WEBLib.TMSFNCURLBitmapContainer"].TTMSFNCURLBitmapItem.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,pas["WEBLib.TMSFNCURLBitmapContainer"].TTMSFNCURLBitmapItem).FName;
        this.FTag = rtl.as(Source,pas["WEBLib.TMSFNCURLBitmapContainer"].TTMSFNCURLBitmapItem).FTag;
        this.FBitmap.Assign(rtl.as(Source,pas["WEBLib.TMSFNCURLBitmapContainer"].TTMSFNCURLBitmapItem).FBitmap);
        this.FNoteText = rtl.as(Source,pas["WEBLib.TMSFNCURLBitmapContainer"].TTMSFNCURLBitmapItem).FURL;
      } else if (pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem).FName;
        this.FTag = rtl.as(Source,pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem).FTag;
        this.FBitmap.Assign(rtl.as(Source,pas["WEBLib.TMSFNCBitmapContainer"].TTMSFNCBitmapItem).FBitmap);
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("Control",2,pas["WEBLib.Controls"].$rtti["TControl"],"FControl","SetControl");
    $r.addProperty("ControlAlignment",2,pas["WEBLib.TMSFNCCustomControl"].$rtti["TTMSFNCControlAlignment"],"FControlAlignment","SetControlAlignment",4,{Default: pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone});
    $r.addProperty("ControlPosition",2,pas["WEBLib.TMSFNCCustomControl"].$rtti["TTMSFNCControlPosition"],"FControlPosition","SetControlPosition",4,{Default: pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterCenter});
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("AccessoryBitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FAccessoryBitmap","SetAccessoryBitmap");
    $r.addProperty("Name",2,rtl.string,"FName","SetName");
    $r.addProperty("DataObject",2,pas.System.$rtti["TObject"],"FDataObject","SetDataObject");
    $r.addProperty("DataString",2,rtl.string,"FDataString","SetDataString");
    $r.addProperty("NoteText",2,rtl.string,"FNoteText","SetNoteText");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag");
    $r.addProperty("OnChanged",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChanged","FOnChanged");
    $r.addProperty("ItemHeight",14,rtl.double,"FItemHeight","SetItemHeight",4,{stored: "IsItemHeightStored"});
    $r.addProperty("FontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FFontColor","SetFontColor");
    $r.addProperty("SelectedFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedFontColor","SetSelectedFontColor");
    $r.addProperty("Selected",2,rtl.boolean,"FSelected","SetSelected",4,{Default: false});
    $r.addProperty("IsSplitter",2,rtl.boolean,"FIsSplitter","SetIsSplitter",4,{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("HorizontalNameAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalNameAlign","SetHorizontalNameAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("HorizontalNoteAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalNoteAlign","SetHorizontalNoteAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("AccessoryClickable",2,rtl.boolean,"FAccessoryClickable","SetAccessoryClickable",4,{Default: false});
  });
  this.$rtti.$DynArray("TTMSFNCEditorListItemArray",{eltype: this.$rtti["TTMSFNCEditorListItem"]});
  rtl.createClass(this,"TTMSFNCEditorListCollection",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
      this.FOnChanged = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FOnChanged = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetEditorListItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCEditorListItem;
      return Result;
    };
    this.DoChanged = function () {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.CheckComponentRemove = function (AComponent) {
      var I = 0;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (AComponent === this.GetItemEx(I).FControl) this.GetItemEx(I).SetControl(null);
      };
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.GetEditorListItemClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Assign = function (Source) {
      pas.Classes.TCollection.Assign.apply(this,arguments);
      this.DoChanged();
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  rtl.recNewT(this,"TTMSFNCEditorListItemDrawingParams",function () {
    this.ItemRounding = 0;
    this.NameText = "";
    this.NoteText = "";
    this.$new = function () {
      var r = Object.create(this);
      r.DrawRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.NameRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.AccessoryRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.ImageRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.NoteRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.ItemRounding === b.ItemRounding) && this.DrawRect.$eq(b.DrawRect) && this.NameRect.$eq(b.NameRect) && this.AccessoryRect.$eq(b.AccessoryRect) && this.ImageRect.$eq(b.ImageRect) && this.NoteRect.$eq(b.NoteRect) && (this.NameText === b.NameText) && (this.NoteText === b.NoteText);
    };
    this.$assign = function (s) {
      this.ItemRounding = s.ItemRounding;
      this.DrawRect.$assign(s.DrawRect);
      this.NameRect.$assign(s.NameRect);
      this.AccessoryRect.$assign(s.AccessoryRect);
      this.ImageRect.$assign(s.ImageRect);
      this.NoteRect.$assign(s.NoteRect);
      this.NameText = s.NameText;
      this.NoteText = s.NoteText;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCEditorListItemDrawingParams",{},this);
    $r.addField("ItemRounding",rtl.longint);
    $r.addField("DrawRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("NameRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("AccessoryRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("ImageRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("NoteRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("NameText",rtl.string);
    $r.addField("NoteText",rtl.string);
  });
  rtl.recNewT(this,"TTMSFNCEditorListItemTextDrawingParams",function () {
    this.Text = "";
    this.$new = function () {
      var r = Object.create(this);
      r.DrawRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.TextRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.DrawRect.$eq(b.DrawRect) && this.TextRect.$eq(b.TextRect) && (this.Text === b.Text);
    };
    this.$assign = function (s) {
      this.DrawRect.$assign(s.DrawRect);
      this.TextRect.$assign(s.TextRect);
      this.Text = s.Text;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCEditorListItemTextDrawingParams",{},this);
    $r.addField("DrawRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("TextRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("Text",rtl.string);
  });
  rtl.recNewT(this,"TTMSFNCEditorListItemImageDrawingParams",function () {
    this.Bitmap = null;
    this.ImageStroke = false;
    this.ImageStrokeRounding = 0;
    this.DeflateImageX = 0;
    this.DeflateImageY = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.ImageRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.ImageRect.$eq(b.ImageRect) && (this.Bitmap === b.Bitmap) && (this.ImageStroke === b.ImageStroke) && (this.ImageStrokeRounding === b.ImageStrokeRounding) && (this.DeflateImageX === b.DeflateImageX) && (this.DeflateImageY === b.DeflateImageY);
    };
    this.$assign = function (s) {
      this.ImageRect.$assign(s.ImageRect);
      this.Bitmap = s.Bitmap;
      this.ImageStroke = s.ImageStroke;
      this.ImageStrokeRounding = s.ImageStrokeRounding;
      this.DeflateImageX = s.DeflateImageX;
      this.DeflateImageY = s.DeflateImageY;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCEditorListItemImageDrawingParams",{},this);
    $r.addField("ImageRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("Bitmap",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]);
    $r.addField("ImageStroke",rtl.boolean);
    $r.addField("ImageStrokeRounding",rtl.longint);
    $r.addField("DeflateImageX",rtl.longint);
    $r.addField("DeflateImageY",rtl.longint);
  });
  rtl.recNewT(this,"TTMSFNCEditorListItemAccessoryDrawingParams",function () {
    this.Bitmap = null;
    this.$new = function () {
      var r = Object.create(this);
      r.AccessoryRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.AccessoryRect.$eq(b.AccessoryRect) && (this.Bitmap === b.Bitmap);
    };
    this.$assign = function (s) {
      this.AccessoryRect.$assign(s.AccessoryRect);
      this.Bitmap = s.Bitmap;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCEditorListItemAccessoryDrawingParams",{},this);
    $r.addField("AccessoryRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("Bitmap",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]);
  });
  this.$rtti.$MethodVar("TTMSFNCEditorListOnDoubleClickEditorListItem",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AIndex",rtl.longint],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["X",rtl.double],["Y",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCEditorListOnSelectItemChanged",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AIndex",rtl.longint],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["ASelected",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnBeforeDrawListItem",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["AItemDrawingParams",this.$rtti["TTMSFNCEditorListItemDrawingParams"],1],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnAfterDrawListItem",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["AItemDrawingParams",this.$rtti["TTMSFNCEditorListItemDrawingParams"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnBeforeDrawListItemText",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["ATextDrawingParams",this.$rtti["TTMSFNCEditorListItemTextDrawingParams"],1],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnAfterDrawListItemText",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["ATextDrawingParams",this.$rtti["TTMSFNCEditorListItemTextDrawingParams"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnBeforeDrawListItemImage",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["AImageDrawingParams",this.$rtti["TTMSFNCEditorListItemImageDrawingParams"],1],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnAfterDrawListItemImage",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["AImageDrawingParams",this.$rtti["TTMSFNCEditorListItemImageDrawingParams"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnBeforeDrawListItemAccessory",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["AAccessoryDrawingParams",this.$rtti["TTMSFNCEditorListItemAccessoryDrawingParams"],1],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCOnAfterDrawListItemAccessory",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItem",this.$rtti["TTMSFNCEditorListItem"]],["AAccessoryDrawingParams",this.$rtti["TTMSFNCEditorListItemAccessoryDrawingParams"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCEditorListView",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FAcceleratorList = [];
      this.FItemsChanged = false;
      this.FLastSelectedItemIndex = 0;
      this.FKeyIndex = 0;
      this.FBitmapEditor = null;
      this.FEdit = null;
      this.FEditMode = false;
      this.FEditType = 0;
      this.FEditIndex = 0;
      this.FPrevText = "";
      this.FIntUpdateBlock = false;
      this.FUpdateBlock = false;
      this.FItems = null;
      this.FDefaultItemHeight = 0.0;
      this.FImgMargin = 0.0;
      this.FHoverIndex = 0;
      this.FDragStart = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      this.FMouseDown = false;
      this.FDownIndex = 0;
      this.FAddItemIndex = 0;
      this.FAddItemRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FOnItemsChanged = null;
      this.FOnDoubleClickItem = null;
      this.FOnAddNewItem = null;
      this.FOnItemSelectedChanged = null;
      this.FAppearance = null;
      this.FDrawNoteText = false;
      this.FItemsReadOnly = false;
      this.FMultiSelect = false;
      this.FCanUnselectItems = false;
      this.FImageSize = 0;
      this.FAccessoryWidth = 0;
      this.FOnBeforeDrawListItem = null;
      this.FOnAfterDrawListItem = null;
      this.FOnAfterDrawListItemNote = null;
      this.FOnBeforeDrawListItemName = null;
      this.FOnAfterDrawListItemName = null;
      this.FOnBeforeDrawListItemNote = null;
      this.FOnAfterDrawListItemImage = null;
      this.FOnBeforeDrawListItemImage = null;
      this.FOnBeforeDrawListItemAccessory = null;
      this.FOnAfterDrawListItemAccessory = null;
    };
    this.$final = function () {
      this.FAcceleratorList = undefined;
      this.FBitmapEditor = undefined;
      this.FEdit = undefined;
      this.FItems = undefined;
      this.FDragStart = undefined;
      this.FAddItemRect = undefined;
      this.FOnItemsChanged = undefined;
      this.FOnDoubleClickItem = undefined;
      this.FOnAddNewItem = undefined;
      this.FOnItemSelectedChanged = undefined;
      this.FAppearance = undefined;
      this.FOnBeforeDrawListItem = undefined;
      this.FOnAfterDrawListItem = undefined;
      this.FOnAfterDrawListItemNote = undefined;
      this.FOnBeforeDrawListItemName = undefined;
      this.FOnAfterDrawListItemName = undefined;
      this.FOnBeforeDrawListItemNote = undefined;
      this.FOnAfterDrawListItemImage = undefined;
      this.FOnBeforeDrawListItemImage = undefined;
      this.FOnBeforeDrawListItemAccessory = undefined;
      this.FOnAfterDrawListItemAccessory = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FItems;
      return Result;
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
      this.UpdateList();
    };
    this.SetDefaultItemHeight = function (Value) {
      if (this.FDefaultItemHeight !== Value) {
        this.FDefaultItemHeight = Value;
        this.UpdateList();
      };
    };
    this.GetItemIndex = function (X, Y) {
      var Result = 0;
      var I = 0;
      Result = -1;
      if ((this.FAddItemRect.Top < Y) && (this.FAddItemRect.Bottom > Y)) {
        Result = this.FAddItemIndex}
       else {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ((this.FItems.GetItemEx(I).FDrawRect.Top < Y) && (this.FItems.GetItemEx(I).FDrawRect.Bottom > Y)) {
            Result = I;
            break;
          };
        };
      };
      return Result;
    };
    this.GetItemRectType = function (X, Y, AIndex) {
      var Result = 0;
      if (AIndex < 0) AIndex = this.GetItemIndex(X,Y);
      if (AIndex >= 0) {
        if (pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.PointInRect(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(X,Y)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.FItems.GetItemEx(AIndex).FImgRect))) {
          Result = $mod.TTMSFNCListEditorItemRectType.eirtImage;
        } else if (pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.PointInRect(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(X,Y)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.FItems.GetItemEx(AIndex).FAccessoryRect))) {
          Result = $mod.TTMSFNCListEditorItemRectType.eirtAccessory;
        } else if (pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.PointInRect(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(X,Y)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.FItems.GetItemEx(AIndex).FNameRect))) {
          Result = $mod.TTMSFNCListEditorItemRectType.eirtName;
        } else if (pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.PointInRect(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(X,Y)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.FItems.GetItemEx(AIndex).FNoteRect))) {
          Result = $mod.TTMSFNCListEditorItemRectType.eirtNoteText;
        } else Result = $mod.TTMSFNCListEditorItemRectType.eirtItem;
      } else Result = $mod.TTMSFNCListEditorItemRectType.eirtNone;
      return Result;
    };
    this.AssignBitmap = function (AItem) {
      this.FBitmapEditor.SetBitmap(AItem.FBitmap);
      this.FEditIndex = AItem.GetIndex();
      this.FBitmapEditor.Execute(rtl.createCallback(this,"AssignBitmapCallBack"));
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
      this.Invalidate();
    };
    this.SetDrawNoteText = function (Value) {
      if (this.FDrawNoteText !== Value) {
        this.FDrawNoteText = Value;
        this.UpdateList();
      };
    };
    this.SetItemsReadOnly = function (Value) {
      if (this.FItemsReadOnly !== Value) {
        this.FItemsReadOnly = Value;
        this.UpdateList();
      };
    };
    this.SetMultiSelect = function (Value) {
      if (this.FMultiSelect !== Value) {
        this.FMultiSelect = Value;
        if (!this.FMultiSelect) this.UnselectAllItems();
        this.Invalidate();
      };
    };
    this.AssignBitmapCallBack = function (AValue) {
      if ((AValue === 1) && (this.FEditIndex >= 0)) {
        this.FItems.GetItemEx(this.FEditIndex).FBitmap.Assign(this.FBitmapEditor.FBitmap);
      };
      this.FEditIndex = -1;
      this.Invalidate();
    };
    this.SetImgMargin = function (Value) {
      if (this.FImgMargin !== Value) this.FImgMargin = Value;
    };
    this.SetImageSize = function (Value) {
      if (this.FImageSize !== Value) {
        this.FImageSize = Value;
      };
    };
    this.SetAccessoryWidth = function (Value) {
      if (this.FAccessoryWidth !== Value) {
        this.FAccessoryWidth = Math.min(0,Value);
      };
    };
    this.IsDefaultItemHeightStored = function () {
      var Result = false;
      Result = this.FDefaultItemHeight !== 60;
      return Result;
    };
    this.GetShowAccelChar = function () {
      var Result = false;
      Result = this.FShowAcceleratorChar;
      return Result;
    };
    this.SetShowAccelChar = function (Value) {
      var sac = false;
      sac = this.GetShowAccelChar();
      if (sac !== Value) {
        this.SetShowAcceleratorChar(Value);
        this.UpdateList();
      };
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.GetItems().CheckComponentRemove(AComponent);
    };
    this.ChangeDPIScale = function (M, D) {
      var I = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FAppearance.FItemFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FItemFont.FHeight,M,D));
      this.FAppearance.FItemHoverFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FItemHoverFont.FHeight,M,D));
      this.FAppearance.FItemDownFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FItemDownFont.FHeight,M,D));
      this.FAppearance.FItemSelectedFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FItemSelectedFont.FHeight,M,D));
      this.FAppearance.FItemImageRounding = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FItemImageRounding,M,D);
      this.FAppearance.FItemRounding = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FItemRounding,M,D);
      this.FAppearance.FEditFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FEditFont.FHeight,M,D));
      this.FAppearance.FItemVerticalSpacing = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FItemVerticalSpacing,M,D);
      this.FAppearance.FItemHorizontalSpacing = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FItemHorizontalSpacing,M,D);
      this.FAppearance.FItemHorizontalTextMargin = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FItemHorizontalTextMargin,M,D);
      this.FAppearance.FSplitterMarginLeft = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FSplitterMarginLeft,M,D);
      this.FAppearance.FSplitterMarginRight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FSplitterMarginRight,M,D);
      this.FDefaultItemHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDefaultItemHeight,M,D);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FItems.GetItemEx(I).FItemHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FItems.GetItemEx(I).FItemHeight,M,D);
      };
      this.EndUpdate();
    };
    this.MultiSelected = function () {
      var Result = false;
      var I = 0;
      var sec = false;
      Result = false;
      sec = false;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItemEx(I).FSelected) {
          if (!sec) {
            sec = true}
           else {
            Result = true;
            break;
          };
        };
      };
      return Result;
    };
    this.MoveItems = function (X, Y) {
      var mi = 0;
      var di = 0;
      var I = 0;
      var c = false;
      c = false;
      di = this.FDownIndex;
      mi = this.GetItemIndex(X,Y);
      if (mi === -1) {
        mi = this.FItems.GetCount() - 1;
      };
      if (di !== -1) {
        this.FItems.GetItemEx(di).SetIndex(mi);
        di = mi;
        c = true;
      };
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItemEx(I).FSelected && (di !== I)) {
          if (mi >= (this.FItems.GetCount() - 1)) {
            mi = this.FItems.GetCount() - 1}
           else mi += 1;
          this.FItems.GetItemEx(I).SetIndex(mi);
          c = true;
        };
      };
      if (c) this.DoItemsChanged(this);
    };
    this.DeleteSelectedItems = function () {
      var I = 0;
      if (this.FEditMode) this.EndEditMode(false);
      this.FIntUpdateBlock = true;
      for (var $l = this.FItems.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        if (this.FItems.GetItemEx(I).FSelected) this.FItems.Delete(I);
      };
      this.FIntUpdateBlock = false;
      this.UpdateList();
    };
    this.DoEditKeyDown = function (Sender, Key, Shift) {
      if (this.FEditMode) {
        if (Key.get() === 13) {
          this.EndEditMode(true);
          Key.set(0);
        } else if (Key.get() === 27) {
          this.EndEditMode(false);
          Key.set(0);
        };
      };
    };
    this.HandleKeyDown = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
    };
    this.HandleKeyUp = function (Key, Shift) {
      var rp = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyUp.apply(this,arguments);
      rp = false;
      if (Key.get() === 45) {
        this.DoAddNewItem();
        rp = true;
      } else if (Key.get() === 46) {
        this.DeleteSelectedItems();
        this.SetHeight(this.GetListHeight());
        rp = true;
      } else if (Key.get() === 38) {
        if ((pas.Classes.TShiftState$a.ssShift in Shift) && this.FMultiSelect) {
          if (this.FKeyIndex === -1) {
            if (this.FLastSelectedItemIndex === -1) {
              this.SelectItemInt(0)}
             else if (this.FLastSelectedItemIndex > (this.FItems.GetCount() - 1)) {
              this.SelectItemInt(this.FItems.GetCount() - 1)}
             else if (this.FItems.GetItemEx(this.FLastSelectedItemIndex).FSelected) {
              this.FKeyIndex = this.FLastSelectedItemIndex - 1}
             else this.FKeyIndex = this.FLastSelectedItemIndex;
          };
          if ((this.FKeyIndex >= 0) && (this.FKeyIndex < this.FItems.GetCount())) {
            if (this.FKeyIndex > this.FLastSelectedItemIndex) {
              this.FItems.GetItemEx(this.FKeyIndex).SetSelected(false)}
             else this.FItems.GetItemEx(this.FKeyIndex).SetSelected(true);
          };
          this.FKeyIndex = Math.max(0,this.FKeyIndex - 1);
        } else this.SelectItemInt(this.FLastSelectedItemIndex - 1);
        rp = true;
      } else if (Key.get() === 40) {
        if ((pas.Classes.TShiftState$a.ssShift in Shift) && this.FMultiSelect) {
          if (this.FKeyIndex === -1) {
            if (this.FLastSelectedItemIndex === -1) {
              this.SelectItemInt(0)}
             else if (this.FLastSelectedItemIndex > (this.FItems.GetCount() - 1)) {
              this.SelectItemInt(this.FItems.GetCount() - 1)}
             else if (this.FItems.GetItemEx(this.FLastSelectedItemIndex).FSelected) {
              this.FKeyIndex = this.FLastSelectedItemIndex + 1}
             else this.FKeyIndex = this.FLastSelectedItemIndex;
          };
          if ((this.FKeyIndex >= 0) && (this.FKeyIndex < this.FItems.GetCount())) {
            if (this.FKeyIndex < this.FLastSelectedItemIndex) {
              this.FItems.GetItemEx(this.FKeyIndex).SetSelected(false)}
             else this.FItems.GetItemEx(this.FKeyIndex).SetSelected(true);
          };
          this.FKeyIndex = Math.min(this.FItems.GetCount() - 1,this.FKeyIndex + 1);
        } else this.SelectItemInt(this.FLastSelectedItemIndex + 1);
        rp = true;
      } else if (pas.Classes.TShiftState$a.ssCtrl in Shift) {
        var $tmp = Key.get();
        if ($tmp === 65) {
          this.SelectAllItems();
          rp = true;
        } else if ($tmp === 68) {
          this.UnselectAllItems();
          rp = true;
        };
      };
      if (rp) this.Invalidate();
    };
    this.HandleKeyPress = function (Key) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyPress.apply(this,arguments);
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      var di = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      this.FKeyIndex = -1;
      if (!this.FEditMode) {
        this.FMouseDown = true;
        this.FDragStart.$assign(pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
        di = this.GetItemIndex(X,Y);
        if (di !== this.FDownIndex) {
          this.FDownIndex = di;
          this.Invalidate();
        };
      };
    };
    this.HandleMouseEnter = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseEnter.call(this);
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FHoverIndex = -1;
      this.FDownIndex = -1;
      this.Invalidate();
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var hi = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      hi = this.GetItemIndex(X,Y);
      if (hi !== this.FHoverIndex) {
        this.FHoverIndex = hi;
        this.Invalidate();
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var si = 0;
      var irt = 0;
      var I = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      if (this.FEditMode) {
        this.EndEditMode(true)}
       else if (this.FMouseDown && (this.FDownIndex !== -1)) {
        if ((Y < (this.FDragStart.Y + 5)) && (Y > (this.FDragStart.Y - 5))) {
          si = this.GetItemIndex(X,Y);
          if (si === this.FAddItemIndex) {
            this.DoAddNewItem()}
           else if (si >= 0) {
            if ((pas.Classes.TShiftState$a.ssShift in Shift) && this.FMultiSelect) {
              if (this.FLastSelectedItemIndex < 0) {
                this.FLastSelectedItemIndex = 0}
               else if (this.FLastSelectedItemIndex > (this.FItems.GetCount() - 1)) this.FLastSelectedItemIndex = this.FItems.GetCount() - 1;
              for (var $l = Math.min(si,this.FLastSelectedItemIndex), $end = Math.max(si,this.FLastSelectedItemIndex); $l <= $end; $l++) {
                I = $l;
                this.FItems.GetItemEx(I).SetSelected(true);
              };
              this.FLastSelectedItemIndex = si;
            } else {
              irt = this.GetItemRectType(X,Y,si);
              if (Button === pas["WEBLib.Controls"].TMouseButton.mbRight) irt = $mod.TTMSFNCListEditorItemRectType.eirtName;
              if (this.FItemsReadOnly && (irt in rtl.createSet($mod.TTMSFNCListEditorItemRectType.eirtName,$mod.TTMSFNCListEditorItemRectType.eirtNoteText))) irt = $mod.TTMSFNCListEditorItemRectType.eirtItem;
              var $tmp = irt;
              if ($tmp === $mod.TTMSFNCListEditorItemRectType.eirtItem) {
                this.DoItemClicked(this.FItems.GetItemEx(si),rtl.refSet(Shift))}
               else if ($tmp === $mod.TTMSFNCListEditorItemRectType.eirtImage) {
                this.DoItemImageClicked(this.FItems.GetItemEx(si))}
               else if (($tmp === $mod.TTMSFNCListEditorItemRectType.eirtName) || ($tmp === $mod.TTMSFNCListEditorItemRectType.eirtNoteText)) {
                this.DoItemTextClicked(this.FItems.GetItemEx(si),irt,rtl.refSet(Shift))}
               else if ($tmp === $mod.TTMSFNCListEditorItemRectType.eirtAccessory) this.DoItemAccessoryClicked(this.FItems.GetItemEx(si));
            };
          };
          this.Invalidate();
        } else {
          this.MoveItems(X,Y);
        };
      };
      this.FDownIndex = -1;
      this.FDragStart.$assign(pas["WEBLib.TMSFNCTypes"].PointF(-1,-1));
      this.FMouseDown = false;
    };
    this.HandleDblClick = function (X, Y) {
      var ci = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDblClick.apply(this,arguments);
      ci = this.GetItemIndex(X,Y);
      if ((ci >= 0) && (this.FItems.GetItemEx(ci) != null)) this.DoDblClickItem(ci,this.FItems.GetItemEx(ci),X,Y);
    };
    this.CreateItems = function () {
      var Result = null;
      Result = $mod.TTMSFNCEditorListCollection.$create("Create$3",[this]);
      return Result;
    };
    this.SetItemRect = function (AIndex, X, Y) {
      if (this.FItems.GetItemEx(AIndex).FIsSplitter) {
        this.FItems.GetItemEx(AIndex).FDrawRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FAppearance.FSplitterMarginLeft,Y,this.GetWidth() - this.FAppearance.FSplitterMarginRight,Y + this.FAppearance.FSplitter.FWidth))}
       else this.FItems.GetItemEx(AIndex).FDrawRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FAppearance.FItemHorizontalSpacing,Y,this.GetWidth() - this.FAppearance.FItemHorizontalSpacing,Y + this.FItems.GetItemEx(AIndex).FItemHeight));
    };
    this.SetControlPosition = function (AIndex) {
      var $Self = this;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var l = 0;
      var t = 0;
      var w = 0;
      var h = 0;
      function GetAvailableControlRect() {
        var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var bmpR = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var accR = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
        if ((AIndex >= 0) && (AIndex < $Self.FItems.GetCount())) {
          Result.$assign($Self.FItems.GetItemEx(AIndex).FDrawRect);
          bmpR.$assign($Self.FItems.GetItemEx(AIndex).FImgRect);
          accR.$assign($Self.FItems.GetItemEx(AIndex).FAccessoryRect);
          Result.Left = $Self.FItems.GetItemEx(AIndex).FImgRect.Right;
          Result.Right = $Self.FItems.GetItemEx(AIndex).FAccessoryRect.Left;
        };
        return Result;
      };
      this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      if ((this.GetItems().GetItemEx(AIndex) != null) && (this.GetItems().GetItemEx(AIndex).FControl != null)) {
        cr.$assign(GetAvailableControlRect());
        l = Math.round(cr.Left);
        t = Math.round(cr.Top);
        w = Math.round(Math.min(this.GetItems().GetItemEx(AIndex).FControl.GetWidth(),cr.Right - cr.Left));
        h = Math.round(Math.min(this.GetItems().GetItemEx(AIndex).FControl.GetHeight(),cr.Bottom - cr.Top));
        var $tmp = this.GetItems().GetItemEx(AIndex).FControlAlignment;
        if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone) {
          var $tmp1 = this.GetItems().GetItemEx(AIndex).FControlPosition;
          if (($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterLeft) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterCenter) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterRight)) {
            t = Math.round((cr.Bottom - cr.Top - h) / 2);
          } else if (($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomLeft) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomCenter) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomRight)) {
            t = Math.round(cr.Bottom - h);
          };
          var $tmp2 = this.GetItems().GetItemEx(AIndex).FControlPosition;
          if (($tmp2 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpTopCenter) || ($tmp2 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterCenter) || ($tmp2 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomCenter)) {
            l = Math.round((cr.Right - cr.Left - w) / 2);
          } else if (($tmp2 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpTopRight) || ($tmp2 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterRight) || ($tmp2 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomRight)) {
            l = Math.round(cr.Right - w);
          };
          this.GetItems().GetItemEx(AIndex).FControl.SetBounds(l,t,w,h);
          this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(l,t,l + w,t + h));
        } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient) {
          this.GetItems().GetItemEx(AIndex).FControl.SetBounds(l,t,Math.round(cr.Right - cr.Left),Math.round(cr.Bottom - cr.Top));
          this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(l,t,Math.round(cr.Right),Math.round(cr.Bottom)));
        } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caTop) {
          this.GetItems().GetItemEx(AIndex).FControl.SetBounds(l,t,Math.round(cr.Right - cr.Left),h);
          this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(l,t,Math.round(cr.Right),t + h));
        } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caBottom) {
          this.GetItems().GetItemEx(AIndex).FControl.SetBounds(l,Math.round(cr.Bottom - h),Math.round(cr.Right - cr.Left),h);
          this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(l,Math.round(cr.Bottom - h),Math.round(cr.Right),Math.round(cr.Bottom)));
        } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caLeft) {
          this.GetItems().GetItemEx(AIndex).FControl.SetBounds(l,t,w,Math.round(cr.Bottom - cr.Top));
          this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(l,t,l + w,Math.round(cr.Bottom)));
        } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caRight) {
          this.GetItems().GetItemEx(AIndex).FControl.SetBounds(Math.round(cr.Right - w),t,w,h);
          this.GetItems().GetItemEx(AIndex).FControlRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(cr.Right - w),t,Math.round(cr.Right),Math.round(cr.Bottom)));
        };
      };
    };
    this.SetItemImageRect = function (AIndex) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var s = 0.0;
      var w = 0.0;
      var h = 0.0;
      var hoff = 0.0;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        r.$assign(this.FItems.GetItemEx(AIndex).FDrawRect);
        if (this.FImageSize === 0) {
          r.Right = r.Left;
          this.FItems.GetItemEx(AIndex).FImgRect.$assign(r);
        } else {
          w = r.Right - this.FImgMargin - (r.Left + this.FImgMargin);
          h = r.Bottom - this.FImgMargin - (r.Top + this.FImgMargin);
          if (this.FImageSize === -1) {
            s = Math.min(w,h)}
           else s = Math.min(this.FImageSize,w);
          hoff = Math.max(this.FImgMargin,(r.Bottom - this.FImgMargin - (r.Top + this.FImgMargin) - s) / 2);
          this.FItems.GetItemEx(AIndex).FImgRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + this.FImgMargin,r.Top + hoff,r.Left + this.FImgMargin + s,Math.min(r.Bottom - this.FImgMargin,r.Top + hoff + s)));
        };
      };
    };
    this.SetAccessoryRect = function (AIndex) {
      var R = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpR = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        R.$assign(this.GetItems().GetItemEx(AIndex).FDrawRect);
        bmpR.$assign(this.GetItems().GetItemEx(AIndex).FImgRect);
        if (bmpR.Right > 0) R.Left = bmpR.Right;
        R.Left = Math.max(R.Left,R.Right - this.FAccessoryWidth);
        this.GetItems().GetItemEx(AIndex).FAccessoryRect.$assign(R);
      };
    };
    this.SetItemNameRect = function (AIndex) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      var noteTxt = "";
      var txtHeight = 0.0;
      var txtNameWidth = 0.0;
      var txtNoteWidth = 0.0;
      var h = 0.0;
      var NameLeft = 0.0;
      var NameRight = 0.0;
      var NoteLeft = 0.0;
      var NoteRight = 0.0;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        r.$assign(this.FItems.GetItemEx(AIndex).FDrawRect);
        r.Right = this.FItems.GetItemEx(AIndex).FAccessoryRect.Left - this.FAppearance.FItemHorizontalTextMargin;
        r.Left = this.FItems.GetItemEx(AIndex).FImgRect.Right + this.FAppearance.FItemHorizontalTextMargin;
        if (this.FItems.GetItemEx(AIndex).FControl != null) {
          var $tmp = this.FItems.GetItemEx(AIndex).FControlAlignment;
          if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone) {
            var $tmp1 = this.FItems.GetItemEx(AIndex).FControlPosition;
            if (($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpTopLeft) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpTopCenter) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpTopRight)) {
              r.Top = this.FItems.GetItemEx(AIndex).FControlRect.Bottom;
            } else if (($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomLeft) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomCenter) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpBottomRight)) {
              r.Bottom = this.FItems.GetItemEx(AIndex).FControlRect.Top;
            } else if ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterLeft) {
              r.Left = this.FItems.GetItemEx(AIndex).FControlRect.Right;
            } else if (($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterCenter) || ($tmp1 === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlPosition.cpCenterRight)) {
              r.Right = this.FItems.GetItemEx(AIndex).FControlRect.Left;
            };
          } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caLeft) {
            r.Left = this.FItems.GetItemEx(AIndex).FControlRect.Right;
          } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caRight) {
            r.Right = this.FItems.GetItemEx(AIndex).FControlRect.Left;
          } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caTop) {
            r.Top = this.FItems.GetItemEx(AIndex).FControlRect.Bottom;
          } else if ($tmp === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caBottom) {
            r.Bottom = this.FItems.GetItemEx(AIndex).FControlRect.Top;
          } else {
            this.FItems.GetItemEx(AIndex).FNameRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
            this.FItems.GetItemEx(AIndex).FNoteRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
            return;
          };
        };
        txtHeight = -this.FAppearance.FItemFont.FHeight;
        txtNameWidth = 0;
        txtNoteWidth = 0;
        noteTxt = this.FItems.GetItemEx(AIndex).FNoteText;
        if ((noteTxt === "") && (this.FItems.GetItemEx(AIndex).FDataString !== "")) noteTxt = this.FItems.GetItemEx(AIndex).FDataString;
        if (this.GetCanvas() != null) {
          g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[this.GetCanvas(),false]);
          try {
            g.FFont.Assign(this.FAppearance.FItemFont);
            txtHeight = g.CalculateTextHeight$1("Hg");
            if (this.FItems.GetItemEx(AIndex).FNameText !== "") txtNameWidth = g.CalculateTextWidth$1(this.FItems.GetItemEx(AIndex).FNameText) + this.ScalePaintValue$1(3.0);
            if (noteTxt !== "") txtNoteWidth = g.CalculateTextWidth$1(noteTxt) + this.ScalePaintValue$1(3.0);
          } finally {
            g = rtl.freeLoc(g);
          };
        };
        var $tmp2 = this.FItems.GetItemEx(AIndex).FHorizontalNameAlign;
        if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          NameLeft = Math.max(r.Left,r.Left + ((r.Right - r.Left - txtNameWidth) / 2));
          NameRight = Math.min(r.Right,NameLeft + txtNameWidth);
        } else if ($tmp2 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
          NameRight = r.Right;
          NameLeft = Math.max(r.Left,NameRight - txtNameWidth);
        } else {
          NameLeft = r.Left;
          NameRight = Math.min(r.Right,NameLeft + txtNameWidth);
        };
        var $tmp3 = this.FItems.GetItemEx(AIndex).FHorizontalNoteAlign;
        if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          NoteLeft = Math.max(r.Left,r.Left + ((r.Right - r.Left - txtNoteWidth) / 2));
          NoteRight = Math.min(r.Right,NoteLeft + txtNoteWidth);
        } else if ($tmp3 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) {
          NoteRight = r.Right;
          NoteLeft = Math.max(r.Left,NoteRight - txtNoteWidth);
        } else {
          NoteLeft = r.Left;
          NoteRight = Math.min(r.Right,NoteLeft + txtNoteWidth);
        };
        h = r.Bottom - r.Top;
        if (this.FDrawNoteText) {
          if ((NoteLeft < NameRight) && (this.FItems.GetItemEx(AIndex).FHorizontalNameAlign === this.FItems.GetItemEx(AIndex).FHorizontalNoteAlign)) {
            h = (r.Bottom - r.Top) / 2;
            this.FItems.GetItemEx(AIndex).FNoteTextRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(NoteLeft,r.Top + h + ((h - txtHeight) / 2),NoteRight,r.Top + h + ((h - txtHeight) / 2) + txtHeight));
          } else this.FItems.GetItemEx(AIndex).FNoteTextRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(NoteLeft,r.Top + ((h - txtHeight) / 2),NoteRight,r.Top + ((h - txtHeight) / 2) + txtHeight));
          this.FItems.GetItemEx(AIndex).FNoteRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,this.FItems.GetItemEx(AIndex).FNoteTextRect.Top,r.Right,this.FItems.GetItemEx(AIndex).FNoteTextRect.Bottom));
        } else {
          this.FItems.GetItemEx(AIndex).FNoteRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
          this.FItems.GetItemEx(AIndex).FNoteTextRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
        };
        this.FItems.GetItemEx(AIndex).FNameTextRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(NameLeft,r.Top + ((h - txtHeight) / 2),NameRight,r.Top + ((h - txtHeight) / 2) + txtHeight));
        this.FItems.GetItemEx(AIndex).FNameRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,this.FItems.GetItemEx(AIndex).FNameTextRect.Top,r.Right,this.FItems.GetItemEx(AIndex).FNameTextRect.Bottom));
        if (this.FDrawNoteText && !(NoteLeft < NameRight)) {
          this.FItems.GetItemEx(AIndex).FNoteRect.Left = NameRight + this.ScalePaintValue(4);
          this.FItems.GetItemEx(AIndex).FNameRect.Right = NoteLeft - this.ScalePaintValue(4);
        };
      };
    };
    this.InitializeItems = function () {
      var i = 0;
      var y = 0.0;
      y = this.FAppearance.FItemVerticalSpacing;
      this.FAcceleratorList = rtl.arraySetLength(this.FAcceleratorList,"\x00",this.FItems.GetCount());
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.SetItemAcceleratorKey(i);
        this.SetItemRect(i,0,y);
        this.SetItemImageRect(i);
        this.SetAccessoryRect(i);
        this.SetControlPosition(i);
        this.SetItemNameRect(i);
        y = this.FItems.GetItemEx(i).FDrawRect.Bottom + this.FAppearance.FItemVerticalSpacing;
      };
      this.SetHeight(Math.round(Math.max(this.GetHeight(),y)));
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
      this.UpdateList();
    };
    this.DoAppearanceChanged = function (Sender) {
      this.Invalidate();
    };
    this.DoAddNewItem = function () {
      if (this.FOnAddNewItem != null) this.FOnAddNewItem(this);
    };
    this.DoDblClickItem = function (AIndex, AItem, X, Y) {
      if (this.FOnDoubleClickItem != null) this.FOnDoubleClickItem(this,AIndex,AItem,X,Y);
    };
    this.DoItemsChanged = function (Sender) {
      if (this.FIntUpdateBlock || this.FUpdateBlock) {
        this.FItemsChanged = true;
        return;
      };
      if (this.FOnItemsChanged != null) this.FOnItemsChanged(this);
      this.UpdateList();
    };
    this.DoSelectItemChanged = function (AIndex, AItem, ASelected) {
      if (this.FOnItemSelectedChanged != null) this.FOnItemSelectedChanged(this,AIndex,AItem,ASelected);
    };
    this.Draw = function (AGraphics, ARect) {
      this.DrawItems(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.FItems);
    };
    this.DrawBackground = function (AGraphics, ARect) {
      AGraphics.FFill.Assign(this.FAppearance.FFill);
      AGraphics.FStroke.Assign(this.FAppearance.FStroke);
      AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DrawAccessory = function (AGraphics, ARect, AItem) {
      var a = false;
      var dd = false;
      var adp = $mod.TTMSFNCEditorListItemAccessoryDrawingParams.$new();
      if (ARect.Right > ARect.Left) {
        a = true;
        dd = true;
        adp.AccessoryRect.$assign(ARect);
        adp.Bitmap = AItem.FAccessoryBitmap;
        this.DoBeforeDrawListItemAccessory(AGraphics,AItem,adp,{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }},{get: function () {
            return dd;
          }, set: function (v) {
            dd = v;
          }});
        if (a) {
          if (dd) {
            if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(adp.Bitmap)) AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(adp.AccessoryRect),adp.Bitmap,true,false,true,false);
          };
          this.DoAfterDrawListItemAccessory(AGraphics,AItem,adp);
        };
      };
    };
    this.DrawBitmap = function (AGraphics, ARect, AItem) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bdp = $mod.TTMSFNCEditorListItemImageDrawingParams.$new();
      var a = false;
      var dd = false;
      if (ARect.Right > 0) {
        if (this.FAppearance.FUseImageAppearance) {
          if (AItem.FSelected) {
            AGraphics.FFill.Assign(this.FAppearance.FItemImageSelectedFill);
            AGraphics.FStroke.Assign(this.FAppearance.FItemImageSelectedStroke);
          } else if (AItem.GetIndex() === this.FDownIndex) {
            AGraphics.FFill.Assign(this.FAppearance.FItemImageDownFill);
            AGraphics.FStroke.Assign(this.FAppearance.FItemImageDownStroke);
          } else if (AItem.GetIndex() === this.FHoverIndex) {
            AGraphics.FFill.Assign(this.FAppearance.FItemImageHoverFill);
            AGraphics.FStroke.Assign(this.FAppearance.FItemImageHoverStroke);
          } else {
            AGraphics.FFill.Assign(this.FAppearance.FItemImageFill);
            AGraphics.FStroke.Assign(this.FAppearance.FItemImageStroke);
          };
        };
        a = true;
        dd = true;
        bdp.ImageRect.$assign(ARect);
        bdp.Bitmap = AItem.FBitmap;
        bdp.ImageStroke = this.FAppearance.FDrawItemImageStroke;
        bdp.ImageStrokeRounding = this.FAppearance.FItemImageRounding;
        bdp.DeflateImageX = 2;
        bdp.DeflateImageY = 2;
        this.DoBeforeDrawListItemImage(AGraphics,AItem,bdp,{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }},{get: function () {
            return dd;
          }, set: function (v) {
            dd = v;
          }});
        if (a) {
          if (dd) {
            r.$assign(bdp.ImageRect);
            if (bdp.ImageStroke) {
              AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),Math.round(Math.min(bdp.ImageStrokeRounding,(r.Bottom - r.Top) / 2)),rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-bdp.DeflateImageX,-bdp.DeflateImageY);
            };
            AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bdp.Bitmap,true,false,true,false);
          };
          this.DoAfterDrawListItemImage(AGraphics,AItem,bdp);
        };
      };
    };
    this.DrawItems = function (AGraphics, ARect, AItemCollection) {
      var I = 0;
      for (var $l = 0, $end = AItemCollection.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.DrawListItem(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItemCollection.GetItemEx(I).FDrawRect),I,AItemCollection.GetItemEx(I));
      };
    };
    this.DrawListItem = function (AGraphics, ARect, AIndex, AItem) {
      var a = false;
      var dd = false;
      var idp = $mod.TTMSFNCEditorListItemDrawingParams.$new();
      if (((ARect.Right - ARect.Left) > 0) && ((ARect.Bottom - ARect.Top) > 0)) {
        if (AItem.FIsSplitter) {
          AGraphics.FStroke.Assign(this.FAppearance.FSplitter);
        } else if (!AItem.FEnabled) {
          AGraphics.FFill.Assign(this.FAppearance.FItemDisabledFill);
          AGraphics.FFont.Assign(this.FAppearance.FItemDisabledFont);
          AGraphics.FStroke.Assign(this.FAppearance.FItemDisabledStroke);
        } else if (AItem.FSelected) {
          AGraphics.FFill.Assign(this.FAppearance.FItemSelectedFill);
          AGraphics.FFont.Assign(this.FAppearance.FItemSelectedFont);
          AGraphics.FStroke.Assign(this.FAppearance.FItemSelectedStroke);
        } else if (AIndex === this.FDownIndex) {
          AGraphics.FFill.Assign(this.FAppearance.FItemDownFill);
          AGraphics.FFont.Assign(this.FAppearance.FItemDownFont);
          AGraphics.FStroke.Assign(this.FAppearance.FItemDownStroke);
        } else if (AIndex === this.FHoverIndex) {
          AGraphics.FFill.Assign(this.FAppearance.FItemHoverFill);
          AGraphics.FFont.Assign(this.FAppearance.FItemHoverFont);
          AGraphics.FStroke.Assign(this.FAppearance.FItemHoverStroke);
        } else {
          AGraphics.FFill.Assign(this.FAppearance.FItemFill);
          AGraphics.FFont.Assign(this.FAppearance.FItemFont);
          AGraphics.FStroke.Assign(this.FAppearance.FItemStroke);
        };
        if (AItem.FSelected && (AItem.FSelectedFontColor !== -1)) {
          AGraphics.FFont.SetColor(AItem.FSelectedFontColor)}
         else if (AItem.FFontColor !== -1) AGraphics.FFont.SetColor(AItem.FFontColor);
        a = true;
        dd = true;
        idp.DrawRect.$assign(AItem.FDrawRect);
        idp.NameRect.$assign(AItem.FNameRect);
        idp.ImageRect.$assign(AItem.FImgRect);
        idp.AccessoryRect.$assign(AItem.FAccessoryRect);
        idp.NoteRect.$assign(AItem.FNoteRect);
        idp.NameText = AItem.FNameText;
        idp.NoteText = AItem.FNoteText;
        idp.ItemRounding = Math.round(Math.min(this.FAppearance.FItemRounding,(AItem.FDrawRect.Bottom - AItem.FDrawRect.Top) / 2));
        this.DoBeforeDrawListItem(AGraphics,AItem,idp,{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }},{get: function () {
            return dd;
          }, set: function (v) {
            dd = v;
          }});
        if (a) {
          if (dd) {
            if (AItem.FIsSplitter) {
              this.DrawSplitter(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(idp.DrawRect))}
             else {
              AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(idp.DrawRect),idp.ItemRounding,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              if (((idp.ImageRect.Right - idp.ImageRect.Left) > 0) && ((idp.ImageRect.Bottom - idp.ImageRect.Top) > 0)) this.DrawBitmap(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(idp.ImageRect),AItem);
              this.DrawAccessory(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItem.FAccessoryRect),AItem);
              this.DrawName(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(idp.NameRect),AItem);
              this.DrawNote(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(idp.NoteRect),AItem);
            };
          };
          this.DoAfterDrawListItem(AGraphics,AItem,$mod.TTMSFNCEditorListItemDrawingParams.$clone(idp));
        };
      };
    };
    this.DrawSplitter = function (AGraphics, ARect) {
      AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
    };
    this.DrawName = function (AGraphics, ARect, AItem) {
      var accelStart = 0.0;
      var accelWidth = 0.0;
      var tdp = $mod.TTMSFNCEditorListItemTextDrawingParams.$new();
      var a = false;
      var dd = false;
      accelStart = 0;
      accelWidth = 0;
      tdp.DrawRect.$assign(AItem.FNameRect);
      tdp.TextRect.$assign(AItem.FNameTextRect);
      tdp.Text = AItem.FNameText;
      a = true;
      dd = true;
      this.DoBeforeDrawListItemName(AGraphics,AItem,tdp,{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }},{get: function () {
          return dd;
        }, set: function (v) {
          dd = v;
        }});
      if (a) {
        if (dd) {
          if (((tdp.TextRect.Right - tdp.TextRect.Left) > 0) && ((tdp.TextRect.Bottom - tdp.TextRect.Top) > 0)) {
            if (AItem.FAccelPos > 0) {
              if (AItem.FAccelPos > 1) accelStart = AGraphics.CalculateTextWidth$1(pas.System.Copy(tdp.Text,0,AItem.FAccelPos - 1));
              accelWidth = AGraphics.CalculateTextWidth$1(tdp.Text.charAt(AItem.FAccelPos - 1));
            };
          };
          AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tdp.TextRect),tdp.Text,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          if (AItem.FAccelPos >= 0) {
            AGraphics.FStroke.SetWidth(pas.System.Trunc(this.ScalePaintValue$1(1.0)));
            AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
            AGraphics.FStroke.SetColor(AGraphics.FFont.FColor);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(AItem.FNameTextRect.Left + accelStart,AItem.FNameTextRect.Bottom)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(AItem.FNameTextRect.Left + accelStart + accelWidth,AItem.FNameTextRect.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          };
        };
        this.DoAfterDrawListItemName(AGraphics,AItem,$mod.TTMSFNCEditorListItemTextDrawingParams.$clone(tdp));
      };
    };
    this.DrawNote = function (AGraphics, ARect, AItem) {
      var tdp = $mod.TTMSFNCEditorListItemTextDrawingParams.$new();
      var a = false;
      var dd = false;
      if (this.FDrawNoteText) {
        tdp.DrawRect.$assign(AItem.FNoteRect);
        tdp.TextRect.$assign(AItem.FNoteTextRect);
        if ((AItem.FNoteText === "") && (AItem.FDataString !== "")) {
          tdp.Text = AItem.FDataString}
         else tdp.Text = AItem.FNoteText;
        a = true;
        dd = true;
        this.DoBeforeDrawListItemNote(AGraphics,AItem,tdp,{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }},{get: function () {
            return dd;
          }, set: function (v) {
            dd = v;
          }});
        if (a) {
          if (dd) AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tdp.TextRect),tdp.Text,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          this.DoAfterDrawListItemNote(AGraphics,AItem,$mod.TTMSFNCEditorListItemTextDrawingParams.$clone(tdp));
        };
      };
    };
    this.SelectItem = function (AIndex) {
      this.UnselectAllItems();
      this.FLastSelectedItemIndex = AIndex;
      this.FKeyIndex = -1;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        this.FItems.GetItemEx(AIndex).SetSelected(true);
      };
      this.Invalidate();
    };
    this.SelectItemInt = function (AIndex) {
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        this.UnselectAllItems();
        this.FLastSelectedItemIndex = AIndex;
        this.FKeyIndex = -1;
        this.FItems.GetItemEx(AIndex).SetSelected(true);
      };
    };
    this.GetSelectedItems = function () {
      var Result = [];
      var I = 0;
      Result = rtl.arraySetLength(Result,null,0);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItemEx(I).FSelected) {
          Result = rtl.arraySetLength(Result,null,rtl.length(Result) + 1);
          Result[rtl.length(Result) - 1] = this.FItems.GetItemEx(I);
        };
      };
      return Result;
    };
    this.SetItemAcceleratorKey = function (AIndex) {
      var c = "\x00";
      var posIdx = 0;
      var txt = "";
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        c = "\x00";
        posIdx = -1;
        txt = this.FItems.GetItemEx(AIndex).FName;
        if (this.GetShowAccelChar() && (pas.System.Pos("&",txt) > 0)) {
          if (this.FItems.GetItemEx(AIndex).FEnabled) {
            posIdx = pas.System.Pos("&",txt);
            c = pas.SysUtils.LowerCase(txt).charAt((posIdx + 1) - 1);
          };
          txt = pas.SysUtils.StringReplace(txt,"&","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        };
        this.FItems.GetItemEx(AIndex).FNameText = txt;
        this.FAcceleratorList[AIndex] = c;
        this.FItems.GetItemEx(AIndex).FAccelPos = posIdx;
      };
    };
    this.DoItemAccessoryClicked = function (AItem) {
    };
    this.DoItemImageClicked = function (AItem) {
      this.AssignBitmap(AItem);
    };
    this.DoItemClicked = function (AItem, Shift) {
      var sel = false;
      sel = AItem.FSelected;
      if (!(pas.Classes.TShiftState$a.ssCtrl in Shift) || !this.FMultiSelect) this.UnselectAllItems();
      this.FLastSelectedItemIndex = AItem.GetIndex();
      if (!this.FCanUnselectItems) {
        AItem.SetSelected(true)}
       else AItem.SetSelected(!sel);
    };
    this.DoItemTextClicked = function (AItem, AItemRectType, Shift) {
      this.FEditIndex = AItem.GetIndex();
      this.FEditType = AItemRectType;
      if (!(pas.Classes.TShiftState$a.ssCtrl in Shift)) this.UnselectAllItems();
      AItem.SetSelected(true);
      this.StartEditMode();
    };
    this.DoBeforeDrawListItem = function (AGraphics, AItem, AItemDrawingParams, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawListItem != null) this.FOnBeforeDrawListItem(this,AGraphics,AItem,AItemDrawingParams,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawListItem = function (AGraphics, AItem, AItemDrawingParams) {
      if (this.FOnAfterDrawListItem != null) this.FOnAfterDrawListItem(this,AGraphics,AItem,$mod.TTMSFNCEditorListItemDrawingParams.$clone(AItemDrawingParams));
    };
    this.DoBeforeDrawListItemName = function (AGraphics, AItem, ATextDrawingParams, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawListItemName != null) this.FOnBeforeDrawListItemName(this,AGraphics,AItem,ATextDrawingParams,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawListItemName = function (AGraphics, AItem, ATextDrawingParams) {
      if (this.FOnAfterDrawListItemName != null) this.FOnAfterDrawListItemName(this,AGraphics,AItem,$mod.TTMSFNCEditorListItemTextDrawingParams.$clone(ATextDrawingParams));
    };
    this.DoBeforeDrawListItemNote = function (AGraphics, AItem, ATextDrawingParams, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawListItemNote != null) this.FOnBeforeDrawListItemNote(this,AGraphics,AItem,ATextDrawingParams,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawListItemNote = function (AGraphics, AItem, ATextDrawingParams) {
      if (this.FOnAfterDrawListItemNote != null) this.FOnAfterDrawListItemNote(this,AGraphics,AItem,$mod.TTMSFNCEditorListItemTextDrawingParams.$clone(ATextDrawingParams));
    };
    this.DoBeforeDrawListItemImage = function (AGraphics, AItem, AImageDrawingParams, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawListItemImage != null) this.FOnBeforeDrawListItemImage(this,AGraphics,AItem,AImageDrawingParams,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawListItemImage = function (AGraphics, AItem, AImageDrawingParams) {
      if (this.FOnAfterDrawListItemImage != null) this.FOnAfterDrawListItemImage(this,AGraphics,AItem,$mod.TTMSFNCEditorListItemImageDrawingParams.$clone(AImageDrawingParams));
    };
    this.DoBeforeDrawListItemAccessory = function (AGraphics, AItem, AAccessoryDrawingParams, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawListItemAccessory != null) this.FOnBeforeDrawListItemAccessory(this,AGraphics,AItem,AAccessoryDrawingParams,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawListItemAccessory = function (AGraphics, AItem, AAccessoryDrawingParams) {
      if (this.FOnAfterDrawListItemAccessory != null) this.FOnAfterDrawListItemAccessory(this,AGraphics,AItem,$mod.TTMSFNCEditorListItemAccessoryDrawingParams.$clone(AAccessoryDrawingParams));
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FUpdateBlock = true;
      this.SetShowAccelChar(false);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.FMultiSelect = true;
      this.FCanUnselectItems = true;
      this.FItems = this.CreateItems();
      this.FItems.FOnChanged = rtl.createCallback(this,"DoItemsChanged");
      this.FItemsChanged = false;
      this.FDefaultItemHeight = 60;
      this.FImgMargin = 5;
      this.FImageSize = -1;
      this.FAccessoryWidth = 20;
      this.FHoverIndex = -1;
      this.FDownIndex = -1;
      this.FLastSelectedItemIndex = -1;
      this.FAddItemIndex = -10;
      this.FAddItemRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(-1,-1,-1,-1));
      this.FEdit = pas["WEBLib.StdCtrls"].TEdit.$create("Create$1",[this]);
      this.FEdit.SetParent(this);
      this.FEdit.SetVisible(false);
      this.FEdit.FOnKeyDown = rtl.createCallback(this,"DoEditKeyDown");
      this.FBitmapEditor = pas["WEBLib.TMSFNCBitmapEditor"].TTMSFNCBitmapEditor.$create("Create$1",[this]);
      this.FAppearance = $mod.TTMSFNCEditorListViewAppearance.$create("Create$1",[this]);
      this.FAppearance.FOnChanged = rtl.createCallback(this,"DoAppearanceChanged");
      this.SetWidth(300);
      this.SetHeight(400);
      this.FUpdateBlock = false;
      this.UpdateList();
      return this;
    };
    this.Destroy = function () {
      this.FAcceleratorList = rtl.arraySetLength(this.FAcceleratorList,"\x00",0);
      rtl.free(this,"FAppearance");
      rtl.free(this,"FItems");
      rtl.free(this,"FEdit");
      rtl.free(this,"FBitmapEditor");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
      this.FUpdateBlock = true;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.FUpdateBlock = false;
      this.UpdateList();
    };
    this.GetListHeight = function () {
      var Result = 0;
      var I = 0;
      var s = 0.0;
      s = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        s = s + this.FItems.GetItemEx(I).FItemHeight;
      };
      Result = Math.round(s);
      return Result;
    };
    this.UpdateList = function () {
      if (!this.FUpdateBlock && !this.FIntUpdateBlock) {
        this.InitializeItems();
        if (this.FItemsChanged) {
          this.FItemsChanged = false;
          this.DoItemsChanged(this);
        };
        this.Invalidate();
      };
    };
    this.UnselectAllItems = function () {
      var I = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FItems.GetItemEx(I).FSelected = false;
      };
    };
    this.SelectAllItems = function () {
      var I = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FItems.GetItemEx(I).SetSelected(true);
      };
      this.FKeyIndex = -1;
    };
    this.StartEditMode = function () {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!this.FItemsReadOnly) {
        this.FEditMode = true;
        this.FEdit.FFont.Assign(this.FAppearance.FEditFont);
        if (this.FEditType === $mod.TTMSFNCListEditorItemRectType.eirtName) {
          this.FEdit.SetText(this.FItems.GetItemEx(this.FEditIndex).FName);
          r.$assign(this.FItems.GetItemEx(this.FEditIndex).FNameRect);
        } else if (this.FEditType === $mod.TTMSFNCListEditorItemRectType.eirtNoteText) {
          this.FEdit.SetText(this.FItems.GetItemEx(this.FEditIndex).FNoteText);
          r.$assign(this.FItems.GetItemEx(this.FEditIndex).FNoteRect);
        };
        this.FPrevText = this.FEdit.GetText();
        this.FEdit.SetVisible(true);
        this.FEdit.SetFocus();
        this.FEdit.SetLeft(Math.round(r.Left));
        this.FEdit.SetTop(Math.round(r.Top + ((r.Bottom - r.Top - this.FEdit.GetHeight()) / 2)));
        this.FEdit.SetWidth(Math.round(r.Right - r.Left));
      };
    };
    this.EndEditMode = function (Execute) {
      var I = 0;
      var c = 0;
      var s = "";
      if (!Execute) {
        s = this.FPrevText}
       else s = this.FEdit.GetText();
      if (this.FEditType === $mod.TTMSFNCListEditorItemRectType.eirtName) {
        if (Execute && (this.FPrevText !== this.FEdit.GetText()) && this.MultiSelected()) {
          c = 1;
          this.FItems.GetItemEx(this.FEditIndex).SetName(s + pas.SysUtils.IntToStr(c));
          for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            if (this.FItems.GetItemEx(I).FSelected && (I !== this.FEditIndex) && (this.FEditType === $mod.TTMSFNCListEditorItemRectType.eirtName)) {
              c += 1;
              this.FItems.GetItemEx(I).SetName(s + pas.SysUtils.IntToStr(c));
            };
          };
        } else this.FItems.GetItemEx(this.FEditIndex).SetName(s);
      } else if (this.FEditType === $mod.TTMSFNCListEditorItemRectType.eirtNoteText) this.FItems.GetItemEx(this.FEditIndex).SetNoteText(s);
      this.FEditMode = false;
      this.FEdit.SetVisible(false);
      this.FEditIndex = -1;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TTMSFNCEditorListView.FAcceleratorList$a",{eltype: rtl.char});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCBitmapEditorListView",this.TTMSFNCEditorListView,function () {
    this.DeleteSelectedItems = function () {
      $mod.TTMSFNCEditorListView.DeleteSelectedItems.call(this);
    };
    this.SelectItem = function (AIndex) {
      $mod.TTMSFNCEditorListView.SelectItem.apply(this,arguments);
    };
    this.GetSelectedItems = function () {
      var Result = [];
      Result = $mod.TTMSFNCEditorListView.GetSelectedItems.call(this);
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DrawNoteText",2,rtl.boolean,"FDrawNoteText","SetDrawNoteText",4,{Default: false});
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCEditorListViewAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCEditorListCollection"],"GetItems","SetItems");
    $r.addProperty("DefaultItemHeight",14,rtl.double,"FDefaultItemHeight","SetDefaultItemHeight",4,{stored: "IsDefaultItemHeightStored"});
    $r.addProperty("ItemsReadOnly",2,rtl.boolean,"FItemsReadOnly","SetItemsReadOnly",4,{Default: false});
    $r.addProperty("OnAddNewItem",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnAddNewItem","FOnAddNewItem");
    $r.addProperty("OnItemsChanged",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnItemsChanged","FOnItemsChanged");
    $r.addProperty("OnDoubleClickItem",0,$mod.$rtti["TTMSFNCEditorListOnDoubleClickEditorListItem"],"FOnDoubleClickItem","FOnDoubleClickItem");
    $r.addProperty("OnItemSelectedChanged",0,$mod.$rtti["TTMSFNCEditorListOnSelectItemChanged"],"FOnItemSelectedChanged","FOnItemSelectedChanged");
  });
  rtl.createClass(this,"TTMSFNCEditorList",this.TTMSFNCEditorListView,function () {
    this.SetItemImageRect = function (AIndex) {
      this.FItems.GetItemEx(AIndex).FImgRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,-1,4,-1));
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCEditorListView.Create$1.apply(this,arguments);
      this.FImageSize = 0;
      return this;
    };
    this.GetSelectedItems = function () {
      var Result = [];
      Result = $mod.TTMSFNCEditorListView.GetSelectedItems.call(this);
      return Result;
    };
    this.SelectItem = function (AIndex) {
      $mod.TTMSFNCEditorListView.SelectItem.apply(this,arguments);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DrawNoteText",2,rtl.boolean,"FDrawNoteText","SetDrawNoteText",4,{Default: false});
    $r.addProperty("DrawDataString",2,rtl.boolean,"FDrawNoteText","SetDrawNoteText",4,{Default: false});
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCEditorListViewAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCEditorListCollection"],"GetItems","SetItems");
    $r.addProperty("DefaultItemHeight",14,rtl.double,"FDefaultItemHeight","SetDefaultItemHeight",4,{stored: "IsDefaultItemHeightStored"});
    $r.addProperty("ItemsReadOnly",2,rtl.boolean,"FItemsReadOnly","SetItemsReadOnly",4,{Default: false});
    $r.addProperty("LastSelectedItemIndex",0,rtl.longint,"FLastSelectedItemIndex","",4,{Default: -1});
    $r.addProperty("MultiSelect",2,rtl.boolean,"FMultiSelect","SetMultiSelect",4,{Default: true});
    $r.addProperty("CanUnselectItems",0,rtl.boolean,"FCanUnselectItems","FCanUnselectItems",4,{Default: true});
    $r.addProperty("OnAddNewItem",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnAddNewItem","FOnAddNewItem");
    $r.addProperty("OnItemsChanged",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnItemsChanged","FOnItemsChanged");
    $r.addProperty("OnDoubleClickItem",0,$mod.$rtti["TTMSFNCEditorListOnDoubleClickEditorListItem"],"FOnDoubleClickItem","FOnDoubleClickItem");
    $r.addProperty("OnItemSelectedChanged",0,$mod.$rtti["TTMSFNCEditorListOnSelectItemChanged"],"FOnItemSelectedChanged","FOnItemSelectedChanged");
  });
},["TypInfo","SysUtils","WEBLib.TMSFNCUtils","Math","WEBLib.Graphics","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCURLBitmapContainer"]);
rtl.module("fpexprpars",["System","Classes","SysUtils","contnrs","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TTokenType = {"0": "ttPlus", ttPlus: 0, "1": "ttMinus", ttMinus: 1, "2": "ttLessThan", ttLessThan: 2, "3": "ttLargerThan", ttLargerThan: 3, "4": "ttEqual", ttEqual: 4, "5": "ttDiv", ttDiv: 5, "6": "ttMod", ttMod: 6, "7": "ttMul", ttMul: 7, "8": "ttLeft", ttLeft: 8, "9": "ttRight", ttRight: 9, "10": "ttLessThanEqual", ttLessThanEqual: 10, "11": "ttLargerThanEqual", ttLargerThanEqual: 11, "12": "ttunequal", ttunequal: 12, "13": "ttNumber", ttNumber: 13, "14": "ttString", ttString: 14, "15": "ttIdentifier", ttIdentifier: 15, "16": "ttComma", ttComma: 16, "17": "ttAnd", ttAnd: 17, "18": "ttOr", ttOr: 18, "19": "ttXor", ttXor: 19, "20": "ttTrue", ttTrue: 20, "21": "ttFalse", ttFalse: 21, "22": "ttNot", ttNot: 22, "23": "ttif", ttif: 23, "24": "ttCase", ttCase: 24, "25": "ttPower", ttPower: 25, "26": "ttLike", ttLike: 26, "27": "ttEOF", ttEOF: 27};
  this.$rtti.$Enum("TTokenType",{minvalue: 0, maxvalue: 27, ordtype: 1, enumtype: this.TTokenType});
  this.ttDelimiters = rtl.createSet(this.TTokenType.ttPlus,this.TTokenType.ttMinus,this.TTokenType.ttLessThan,this.TTokenType.ttLargerThan,this.TTokenType.ttEqual,this.TTokenType.ttDiv,this.TTokenType.ttMul,this.TTokenType.ttLeft,this.TTokenType.ttRight,this.TTokenType.ttLessThanEqual,this.TTokenType.ttLargerThanEqual,this.TTokenType.ttunequal,this.TTokenType.ttPower);
  this.ttComparisons = rtl.createSet(this.TTokenType.ttLargerThan,this.TTokenType.ttLessThan,this.TTokenType.ttLargerThanEqual,this.TTokenType.ttLessThanEqual,this.TTokenType.ttEqual,this.TTokenType.ttunequal,this.TTokenType.ttLike);
  this.$rtti.$Class("TFPExpressionParser");
  this.$rtti.$Class("TExprBuiltInManager");
  this.$rtti.$Class("TFPExprFunction");
  this.$rtti.$ClassRef("TFPExprFunctionClass",{instancetype: this.$rtti["TFPExprFunction"]});
  this.TNumberKind = {"0": "nkDecimal", nkDecimal: 0, "1": "nkHex", nkHex: 1, "2": "nkOctal", nkOctal: 2, "3": "nkBinary", nkBinary: 3};
  this.$rtti.$Enum("TNumberKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TNumberKind});
  rtl.createClass(this,"TFPExpressionScanner",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FSource = "";
      this.LSource = 0;
      this.FPos = 0;
      this.FChar = "\x00";
      this.FToken = "";
      this.FTokenType = 0;
      this.FAllowLike = false;
    };
    this.GetCurrentChar = function () {
      var Result = "\x00";
      Result = this.FChar;
      return Result;
    };
    this.ScanError = function (Msg) {
      throw $mod.EExprScanner.$create("Create$1",[Msg]);
    };
    this.SetSource = function (AValue) {
      this.FSource = AValue;
      this.LSource = this.FSource.length;
      this.FTokenType = $mod.TTokenType.ttEOF;
      if (this.LSource === 0) {
        this.FPos = 0;
        this.FChar = $impl.cNull;
      } else {
        this.FPos = 1;
        this.FChar = this.FSource.charAt(0);
      };
      this.FToken = "";
    };
    this.DoIdentifier = function () {
      var Result = 0;
      var C = "\x00";
      var S = "";
      var IsBracket = false;
      C = this.GetCurrentChar();
      IsBracket = false;
      while ((!this.IsWordDelim(C) && (C !== $impl.cNull)) || (IsBracket && (C === " "))) {
        if (C === "[") IsBracket = true;
        if (C === "]") IsBracket = false;
        if (C !== '"') {
          this.FToken = this.FToken + C}
         else {
          C = this.NextPos();
          while (!(C.charCodeAt() in rtl.createSet($impl.cNull.charCodeAt(),34))) {
            this.FToken = this.FToken + C;
            C = this.NextPos();
          };
          if (C !== '"') this.ScanError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrUnterminatedIdentifier"),pas.System.VarRecs(18,this.FToken)));
        };
        C = this.NextPos();
      };
      S = pas.SysUtils.LowerCase(this.FToken);
      if (S === "or") {
        Result = $mod.TTokenType.ttOr}
       else if (S === "xor") {
        Result = $mod.TTokenType.ttXor}
       else if (S === "and") {
        Result = $mod.TTokenType.ttAnd}
       else if (S === "true") {
        Result = $mod.TTokenType.ttTrue}
       else if (S === "false") {
        Result = $mod.TTokenType.ttFalse}
       else if (S === "not") {
        Result = $mod.TTokenType.ttNot}
       else if (S === "if") {
        Result = $mod.TTokenType.ttif}
       else if (S === "case") {
        Result = $mod.TTokenType.ttCase}
       else if (S === "mod") {
        Result = $mod.TTokenType.ttMod}
       else if ((S === "like") && this.FAllowLike) {
        Result = $mod.TTokenType.ttLike}
       else Result = $mod.TTokenType.ttIdentifier;
      return Result;
    };
    this.DoNumber = function (AKind) {
      var $Self = this;
      var Result = 0;
      var C = "\x00";
      var X = 0.0;
      var I = 0;
      var prevC = "\x00";
      function ValidDigit(C, AKind) {
        var Result = false;
        Result = $Self.IsDigit(C,AKind);
        if (!Result) {
          var $tmp = AKind;
          if ($tmp === $mod.TNumberKind.nkDecimal) {
            Result = (($Self.FToken !== "") && (pas.System.upcase(C) === "E")) || (($Self.FToken !== "") && (C.charCodeAt() in rtl.createSet(43,45)) && (prevC === "E"))}
           else if ($tmp === $mod.TNumberKind.nkHex) {
            Result = (C === $impl.cHexIdentifier) && (prevC === "\x00")}
           else if ($tmp === $mod.TNumberKind.nkOctal) {
            Result = (C === $impl.cOctalIdentifier) && (prevC === "\x00")}
           else if ($tmp === $mod.TNumberKind.nkBinary) Result = (C === $impl.cBinaryIdentifier) && (prevC === "\x00");
        };
        return Result;
      };
      C = this.GetCurrentChar();
      prevC = "\x00";
      while (C !== $impl.cNull) {
        if (this.IsWordDelim(C)) {
          var $tmp = AKind;
          if ($tmp === $mod.TNumberKind.nkDecimal) {
            if (!(prevC.charCodeAt() in rtl.createSet(69,45,43))) break}
           else if (($tmp === $mod.TNumberKind.nkHex) || ($tmp === $mod.TNumberKind.nkOctal)) {
            break}
           else if ($tmp === $mod.TNumberKind.nkBinary) if (prevC !== "\x00") break;
        };
        if (!ValidDigit(C,AKind)) this.ScanError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrInvalidNumberChar"),pas.System.VarRecs(9,C)));
        this.FToken = this.FToken + C;
        prevC = pas.System.upcase(C);
        C = this.NextPos();
      };
      pas.System.val$8(this.FToken,{get: function () {
          return X;
        }, set: function (v) {
          X = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      if (I !== 0) this.ScanError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrInvalidNumber"),pas.System.VarRecs(18,this.FToken)));
      Result = $mod.TTokenType.ttNumber;
      return Result;
    };
    this.DoDelimiter = function () {
      var Result = 0;
      var B = false;
      var C = "\x00";
      var D = "\x00";
      C = this.FChar;
      this.FToken = C;
      B = C.charCodeAt() in rtl.createSet(60,62);
      D = C;
      C = this.NextPos();
      if (B && (C.charCodeAt() in rtl.createSet(61,62))) {
        this.FToken = this.FToken + C;
        this.NextPos();
        if (D === ">") {
          Result = $mod.TTokenType.ttLargerThanEqual}
         else if (C === ">") {
          Result = $mod.TTokenType.ttunequal}
         else Result = $mod.TTokenType.ttLessThanEqual;
      } else {
        var $tmp = D;
        if ($tmp === "+") {
          Result = $mod.TTokenType.ttPlus}
         else if ($tmp === "-") {
          Result = $mod.TTokenType.ttMinus}
         else if ($tmp === "<") {
          Result = $mod.TTokenType.ttLessThan}
         else if ($tmp === ">") {
          Result = $mod.TTokenType.ttLargerThan}
         else if ($tmp === "=") {
          Result = $mod.TTokenType.ttEqual}
         else if ($tmp === "/") {
          Result = $mod.TTokenType.ttDiv}
         else if ($tmp === "*") {
          Result = $mod.TTokenType.ttMul}
         else if ($tmp === "(") {
          Result = $mod.TTokenType.ttLeft}
         else if ($tmp === ")") {
          Result = $mod.TTokenType.ttRight}
         else if ($tmp === ",") {
          Result = $mod.TTokenType.ttComma}
         else if ($tmp === "^") {
          Result = $mod.TTokenType.ttPower}
         else {
          this.ScanError(pas.SysUtils.Format(rtl.getResStr($mod,"SUnknownDelimiter"),pas.System.VarRecs(9,D)));
        };
      };
      return Result;
    };
    this.DoString = function () {
      var $Self = this;
      var Result = 0;
      function TerminatingChar(C) {
        var Result = false;
        Result = (C === $impl.cNull) || ((C === $impl.cSingleQuote) && !(($Self.FPos < $Self.LSource) && ($Self.FSource.charAt(($Self.FPos + 1) - 1) === $impl.cSingleQuote)));
        return Result;
      };
      var C = "\x00";
      this.FToken = "";
      C = this.NextPos();
      while (!TerminatingChar(C)) {
        this.FToken = this.FToken + C;
        if (C === $impl.cSingleQuote) this.NextPos();
        C = this.NextPos();
      };
      if (C === $impl.cNull) this.ScanError(rtl.getResStr($mod,"SBadQuotes"));
      Result = $mod.TTokenType.ttString;
      this.FTokenType = Result;
      this.NextPos();
      return Result;
    };
    this.NextPos = function () {
      var Result = "\x00";
      this.FPos += 1;
      if (this.FPos > this.FSource.length) {
        this.FChar = $impl.cNull}
       else this.FChar = this.FSource.charAt(this.FPos - 1);
      Result = this.FChar;
      return Result;
    };
    this.SkipWhiteSpace = function () {
      while ((this.FChar.charCodeAt() in $impl.WhiteSpace) && (this.FPos <= this.LSource)) this.NextPos();
    };
    this.IsWordDelim = function (C) {
      var Result = false;
      Result = C.charCodeAt() in $impl.WordDelimiters;
      return Result;
    };
    this.IsDelim = function (C) {
      var Result = false;
      Result = C.charCodeAt() in $impl.Delimiters;
      return Result;
    };
    this.IsDigit = function (C, AKind) {
      var Result = false;
      var $tmp = AKind;
      if ($tmp === $mod.TNumberKind.nkDecimal) {
        Result = C.charCodeAt() in $impl.Digits}
       else if ($tmp === $mod.TNumberKind.nkHex) {
        Result = C.charCodeAt() in $impl.HexDigits}
       else if ($tmp === $mod.TNumberKind.nkOctal) {
        Result = C.charCodeAt() in $impl.OctalDigits}
       else if ($tmp === $mod.TNumberKind.nkBinary) Result = C.charCodeAt() in $impl.BinaryDigits;
      return Result;
    };
    this.IsAlpha = function (C) {
      var Result = false;
      Result = C.charCodeAt() in rtl.createSet(null,65,90,null,97,122);
      return Result;
    };
    this.Create$1 = function () {
      this.SetSource("");
      return this;
    };
    this.GetToken = function () {
      var Result = 0;
      var C = "\x00";
      this.FToken = "";
      this.SkipWhiteSpace();
      C = this.FChar;
      if (C === $impl.cNull) {
        Result = $mod.TTokenType.ttEOF}
       else if (this.IsDelim(C)) {
        Result = this.DoDelimiter()}
       else if (C === $impl.cSingleQuote) {
        Result = this.DoString()}
       else if (C === $impl.cHexIdentifier) {
        Result = this.DoNumber($mod.TNumberKind.nkHex)}
       else if (C === $impl.cOctalIdentifier) {
        Result = this.DoNumber($mod.TNumberKind.nkOctal)}
       else if (C === $impl.cBinaryIdentifier) {
        Result = this.DoNumber($mod.TNumberKind.nkBinary)}
       else if (this.IsDigit(C,$mod.TNumberKind.nkDecimal)) {
        Result = this.DoNumber($mod.TNumberKind.nkDecimal)}
       else if (this.IsAlpha(C) || (C === '"') || (C === "_") || (C === "[") || (C === "]")) {
        Result = this.DoIdentifier()}
       else this.ScanError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrUnknownCharacter"),pas.System.VarRecs(0,this.FPos,9,C)));
      this.FTokenType = Result;
      return Result;
    };
  });
  rtl.createClass(this,"EExprScanner",pas.SysUtils.Exception,function () {
  });
  this.TResultType = {"0": "rtBoolean", rtBoolean: 0, "1": "rtInteger", rtInteger: 1, "2": "rtFloat", rtFloat: 2, "3": "rtDateTime", rtDateTime: 3, "4": "rtString", rtString: 4, "5": "rtCurrency", rtCurrency: 5};
  this.$rtti.$Enum("TResultType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TResultType});
  this.$rtti.$Set("TResultTypes",{comptype: this.$rtti["TResultType"]});
  rtl.recNewT(this,"TFPExpressionResult",function () {
    this.ResultType = 0;
    this.resValue = undefined;
    this.$eq = function (b) {
      return (this.ResultType === b.ResultType) && (this.resValue === b.resValue);
    };
    this.$assign = function (s) {
      this.ResultType = s.ResultType;
      this.resValue = s.resValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TFPExpressionResult",{},this);
    $r.addField("ResultType",$mod.$rtti["TResultType"]);
    $r.addField("resValue",rtl.jsvalue);
  });
  this.$rtti.$Pointer("PFPExpressionResult",{reftype: this.$rtti["TFPExpressionResult"]});
  this.$rtti.$DynArray("TExprParameterArray",{eltype: this.$rtti["TFPExpressionResult"]});
  rtl.createClass(this,"TFPExprNode",pas.System.TObject,function () {
    this.CheckNodeType = function (Anode, Allowed) {
      var S = "";
      var A = 0;
      if (Anode === null) $impl.RaiseParserError(rtl.getResStr($mod,"SErrNoNodeToCheck"));
      if (!(Anode.NodeType() in Allowed)) {
        S = "";
        for (A = 0; A <= 5; A++) if (A in Allowed) {
          if (S !== "") S = S + ",";
          S = S + $mod.ResultTypeName(A);
        };
        $impl.RaiseParserError$1(rtl.getResStr($mod,"SInvalidNodeType"),pas.System.VarRecs(18,$mod.ResultTypeName(Anode.NodeType()),18,S,18,Anode.AsString()));
      };
    };
    this.InitAggregate = function () {
    };
    this.UpdateAggregate = function () {
    };
    this.IsAggregate = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.HasAggregate = function () {
      var Result = false;
      Result = this.$class.IsAggregate();
      return Result;
    };
    this.NodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.GetNodeValue());
      return Result;
    };
  });
  this.$rtti.$DynArray("TExprArgumentArray",{eltype: this.$rtti["TFPExprNode"]});
  rtl.createClass(this,"TFPBinaryOperation",this.TFPExprNode,function () {
    this.$init = function () {
      $mod.TFPExprNode.$init.call(this);
      this.FLeft = null;
      this.FRight = null;
    };
    this.$final = function () {
      this.FLeft = undefined;
      this.FRight = undefined;
      $mod.TFPExprNode.$final.call(this);
    };
    this.CheckSameNodeTypes = function () {
      var LT = 0;
      var RT = 0;
      LT = this.FLeft.NodeType();
      RT = this.FRight.NodeType();
      if (RT !== LT) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrTypesDoNotMatch"),pas.System.VarRecs(18,$mod.ResultTypeName(LT),18,$mod.ResultTypeName(RT),18,this.FLeft.AsString(),18,this.FRight.AsString()));
    };
    this.Create$1 = function (ALeft, ARight) {
      this.FLeft = ALeft;
      this.FRight = ARight;
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FLeft;
        }, set: function (v) {
          this.p.FLeft = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FRight;
        }, set: function (v) {
          this.p.FRight = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
    this.InitAggregate = function () {
      $mod.TFPExprNode.InitAggregate.call(this);
      if (this.FLeft != null) this.FLeft.InitAggregate();
      if (this.FRight != null) this.FRight.InitAggregate();
    };
    this.UpdateAggregate = function () {
      $mod.TFPExprNode.UpdateAggregate.call(this);
      if (this.FLeft != null) this.FLeft.UpdateAggregate();
      if (this.FRight != null) this.FRight.UpdateAggregate();
    };
    this.HasAggregate = function () {
      var Result = false;
      Result = $mod.TFPExprNode.HasAggregate.call(this);
      if (this.FLeft != null) Result = Result || this.FLeft.HasAggregate();
      if (this.FRight != null) Result = Result || this.FRight.HasAggregate();
      return Result;
    };
    this.Check = function () {
      if (!(this.FLeft != null)) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrNoleftOperand"),pas.System.VarRecs(18,this.$classname));
      if (!(this.FRight != null)) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrNoRightOperand"),pas.System.VarRecs(18,this.$classname));
    };
  });
  this.$rtti.$ClassRef("TFPBinaryOperationClass",{instancetype: this.$rtti["TFPBinaryOperation"]});
  rtl.createClass(this,"TFPBooleanOperation",this.TFPBinaryOperation,function () {
    this.Check = function () {
      $mod.TFPBinaryOperation.Check.call(this);
      this.CheckNodeType(this.FLeft,rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtBoolean));
      this.CheckNodeType(this.FRight,rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtBoolean));
      this.CheckSameNodeTypes();
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FLeft.NodeType();
      return Result;
    };
  });
  rtl.createClass(this,"TFPBinaryAndOperation",this.TFPBooleanOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtBoolean) {
        Result.resValue = !(Result.resValue == false) && !(RRes.resValue == false)}
       else if ($tmp === $mod.TResultType.rtInteger) Result.resValue = rtl.and(rtl.trunc(Result.resValue),rtl.trunc(RRes.resValue));
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " and " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPBinaryOrOperation",this.TFPBooleanOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtBoolean) {
        Result.resValue = !(Result.resValue == false) || !(RRes.resValue == false)}
       else if ($tmp === $mod.TResultType.rtInteger) Result.resValue = rtl.or(rtl.trunc(Result.resValue),rtl.trunc(RRes.resValue));
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " or " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPBinaryXOrOperation",this.TFPBooleanOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtBoolean) {
        Result.resValue = !(Result.resValue == false) ^ !(RRes.resValue == false)}
       else if ($tmp === $mod.TResultType.rtInteger) Result.resValue = rtl.xor(rtl.trunc(Result.resValue),rtl.trunc(RRes.resValue));
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " xor " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPBooleanResultOperation",this.TFPBinaryOperation,function () {
    this.Check = function () {
      $mod.TFPBinaryOperation.Check.call(this);
      this.CheckSameNodeTypes();
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtBoolean;
      return Result;
    };
  });
  this.$rtti.$ClassRef("TFPBooleanResultOperationClass",{instancetype: this.$rtti["TFPBooleanResultOperation"]});
  rtl.createClass(this,"TFPEqualOperation",this.TFPBooleanResultOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      Result.resValue = Result.resValue == RRes.resValue;
      Result.ResultType = $mod.TResultType.rtBoolean;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " = " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPLikeOperation",this.TFPBooleanResultOperation,function () {
    this.$init = function () {
      $mod.TFPBooleanResultOperation.$init.call(this);
      this.FRE = null;
      this.FLast = "";
    };
    this.$final = function () {
      this.FRE = undefined;
      $mod.TFPBooleanResultOperation.$final.call(this);
    };
    var RESpecials = "([\\$\\+\\[\\]\\(\\)\\\\\\.\\*\\^\\?\\|])";
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var S = "";
      var RE = null;
      S = "" + this.FRight.NodeValue().resValue;
      if ((this.FLast !== "") && (S === this.FLast)) {
        RE = this.FRE}
       else {
        this.FLast = S;
        S = S.replace(new RegExp(RESpecials,"g"),"\\$1");
        S = pas.SysUtils.StringReplace(S,"%","(.*)",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        S = pas.SysUtils.StringReplace(S,"_","(.)",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        S = "^" + S + "$";
        try {
          this.FRE = new RegExp(S,"i");
          RE = this.FRE;
        } catch ($e) {
          Result.resValue = false;
          return Result;
        };
      };
      Result.resValue = RE.test("" + this.FLeft.NodeValue().resValue);
      return Result;
    };
    this.Check = function () {
      if (this.FLeft.NodeType() !== $mod.TResultType.rtString) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrStringTypeRequired"),pas.System.VarRecs(18,$mod.ResultTypeName(this.FLeft.NodeType()),18,this.FLeft.AsString()));
      if (this.FRight.NodeType() !== $mod.TResultType.rtString) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrStringTypeRequired"),pas.System.VarRecs(18,$mod.ResultTypeName(this.FRight.NodeType()),18,this.FRight.AsString()));
      $mod.TFPBooleanResultOperation.Check.call(this);
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " LIKE " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPUnequalOperation",this.TFPEqualOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign($mod.TFPEqualOperation.GetNodeValue.call(this));
      Result.resValue = !Result.resValue;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " <> " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPOrderingOperation",this.TFPBooleanResultOperation,function () {
    var AllowedTypes = rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtFloat,$mod.TResultType.rtCurrency,$mod.TResultType.rtDateTime,$mod.TResultType.rtString);
    this.Check = function () {
      this.CheckNodeType(this.FLeft,AllowedTypes);
      this.CheckNodeType(this.FRight,AllowedTypes);
      $mod.TFPBooleanResultOperation.Check.call(this);
    };
  });
  rtl.createClass(this,"TFPLessThanOperation",this.TFPOrderingOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = rtl.trunc(Result.resValue) < rtl.trunc(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result.resValue = rtl.getNumber(Result.resValue) < rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) {
        Result.resValue = rtl.trunc(Result.resValue * 10000) < rtl.trunc(RRes.resValue * 10000)}
       else if ($tmp === $mod.TResultType.rtDateTime) {
        Result.resValue = rtl.getNumber(Result.resValue) < rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtString) Result.resValue = ("" + Result.resValue) < ("" + RRes.resValue);
      Result.ResultType = $mod.TResultType.rtBoolean;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " < " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPGreaterThanOperation",this.TFPOrderingOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        var $tmp1 = this.FRight.NodeType();
        if ($tmp1 === $mod.TResultType.rtInteger) {
          Result.resValue = rtl.trunc(Result.resValue) > rtl.trunc(RRes.resValue)}
         else if ($tmp1 === $mod.TResultType.rtFloat) {
          Result.resValue = rtl.trunc(Result.resValue) > rtl.getNumber(RRes.resValue)}
         else if ($tmp1 === $mod.TResultType.rtCurrency) Result.resValue = (rtl.trunc(Result.resValue) * 10000) > rtl.trunc(RRes.resValue * 10000);
      } else if ($tmp === $mod.TResultType.rtFloat) {
        var $tmp2 = this.FRight.NodeType();
        if ($tmp2 === $mod.TResultType.rtInteger) {
          Result.resValue = rtl.getNumber(Result.resValue) > rtl.trunc(RRes.resValue)}
         else if ($tmp2 === $mod.TResultType.rtFloat) {
          Result.resValue = rtl.getNumber(Result.resValue) > rtl.getNumber(RRes.resValue)}
         else if ($tmp2 === $mod.TResultType.rtCurrency) Result.resValue = (rtl.getNumber(Result.resValue) * 10000) > rtl.trunc(RRes.resValue * 10000);
      } else if ($tmp === $mod.TResultType.rtCurrency) {
        var $tmp3 = this.FRight.NodeType();
        if ($tmp3 === $mod.TResultType.rtInteger) {
          Result.resValue = rtl.trunc(Result.resValue * 10000) > (rtl.trunc(RRes.resValue) * 10000)}
         else if ($tmp3 === $mod.TResultType.rtFloat) {
          Result.resValue = rtl.trunc(Result.resValue * 10000) > (rtl.getNumber(RRes.resValue) * 10000)}
         else if ($tmp3 === $mod.TResultType.rtCurrency) Result.resValue = rtl.trunc(Result.resValue * 10000) > rtl.trunc(RRes.resValue * 10000);
      } else if ($tmp === $mod.TResultType.rtDateTime) {
        Result.resValue = rtl.getNumber(Result.resValue) > rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtString) Result.resValue = ("" + Result.resValue) > ("" + RRes.resValue);
      Result.ResultType = $mod.TResultType.rtBoolean;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " > " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPLessThanEqualOperation",this.TFPGreaterThanOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign($mod.TFPGreaterThanOperation.GetNodeValue.call(this));
      Result.resValue = !Result.resValue;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " <= " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPGreaterThanEqualOperation",this.TFPLessThanOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign($mod.TFPLessThanOperation.GetNodeValue.call(this));
      Result.resValue = !Result.resValue;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " >= " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TIfOperation",this.TFPBinaryOperation,function () {
    this.$init = function () {
      $mod.TFPBinaryOperation.$init.call(this);
      this.FCondition = null;
    };
    this.$final = function () {
      this.FCondition = undefined;
      $mod.TFPBinaryOperation.$final.call(this);
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FCondition.GetNodeValue());
      if (!(Result.resValue == false)) {
        Result.$assign(this.FLeft.GetNodeValue())}
       else Result.$assign(this.FRight.GetNodeValue());
      return Result;
    };
    this.Check = function () {
      $mod.TFPBinaryOperation.Check.call(this);
      if (this.FCondition.NodeType() !== $mod.TResultType.rtBoolean) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrIFNeedsBoolean"),pas.System.VarRecs(18,this.FCondition.AsString()));
      this.CheckSameNodeTypes();
    };
    this.InitAggregate = function () {
      $mod.TFPBinaryOperation.InitAggregate.call(this);
      if (this.FCondition != null) this.FCondition.InitAggregate();
    };
    this.UpdateAggregate = function () {
      $mod.TFPBinaryOperation.UpdateAggregate.call(this);
      if (this.FCondition != null) this.FCondition.UpdateAggregate();
    };
    this.HasAggregate = function () {
      var Result = false;
      Result = $mod.TFPBinaryOperation.HasAggregate.call(this);
      if (this.FCondition != null) Result = Result || this.FCondition.HasAggregate();
      return Result;
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FLeft.NodeType();
      return Result;
    };
    this.Create$2 = function (ACondition, ALeft, ARight) {
      $mod.TFPBinaryOperation.Create$1.call(this,ALeft,ARight);
      this.FCondition = ACondition;
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FCondition;
        }, set: function (v) {
          this.p.FCondition = v;
        }});
      $mod.TFPBinaryOperation.Destroy.call(this);
    };
    this.AsString = function () {
      var Result = "";
      Result = pas.SysUtils.Format("if(%s , %s , %s)",pas.System.VarRecs(18,this.FCondition.AsString(),18,this.FLeft.AsString(),18,this.FRight.AsString()));
      return Result;
    };
  });
  rtl.createClass(this,"TCaseOperation",this.TFPExprNode,function () {
    this.$init = function () {
      $mod.TFPExprNode.$init.call(this);
      this.FArgs = [];
      this.FCondition = null;
    };
    this.$final = function () {
      this.FArgs = undefined;
      this.FCondition = undefined;
      $mod.TFPExprNode.$final.call(this);
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var I = 0;
      var L = 0;
      var B = false;
      var RT = $mod.TFPExpressionResult.$new();
      var RV = $mod.TFPExpressionResult.$new();
      RT.$assign(this.FArgs[0].GetNodeValue());
      L = rtl.length(this.FArgs);
      I = 2;
      B = false;
      while (!B && (I < L)) {
        Result.$assign(this.FArgs[I].GetNodeValue());
        var $tmp = RT.ResultType;
        if ($tmp === $mod.TResultType.rtBoolean) {
          B = RT.resValue == RV.resValue}
         else if ($tmp === $mod.TResultType.rtInteger) {
          B = RT.resValue == RV.resValue}
         else if ($tmp === $mod.TResultType.rtFloat) {
          B = RT.resValue == RV.resValue}
         else if ($tmp === $mod.TResultType.rtCurrency) {
          B = RT.resValue == RV.resValue}
         else if ($tmp === $mod.TResultType.rtDateTime) {
          B = RT.resValue == RV.resValue}
         else if ($tmp === $mod.TResultType.rtString) B = RT.resValue == RV.resValue;
        if (!B) I += 2;
      };
      Result.ResultType = this.FArgs[1].NodeType();
      if (B) {
        Result.$assign(this.FArgs[I + 1].GetNodeValue())}
       else if ((L % 2) === 0) Result.$assign(this.FArgs[1].GetNodeValue());
      return Result;
    };
    this.Check = function () {
      var T = 0;
      var V = 0;
      var I = 0;
      var N = null;
      if (rtl.length(this.FArgs) < 3) $impl.RaiseParserError(rtl.getResStr($mod,"SErrCaseNeeds3"));
      if ((rtl.length(this.FArgs) % 2) === 1) $impl.RaiseParserError(rtl.getResStr($mod,"SErrCaseEvenCount"));
      T = this.FArgs[0].NodeType();
      V = this.FArgs[1].NodeType();
      for (var $l = 2, $end = rtl.length(this.FArgs) - 1; $l <= $end; $l++) {
        I = $l;
        N = this.FArgs[I];
        if ((I % 2) === 0) {
          if (!$mod.TFPConstExpression.isPrototypeOf(N)) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrCaseLabelNotAConst"),pas.System.VarRecs(0,rtl.trunc(I / 2),18,N.AsString()));
          if (N.NodeType() !== T) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrCaseLabelType"),pas.System.VarRecs(0,rtl.trunc(I / 2),18,N.AsString(),18,$mod.ResultTypeName(T),18,$mod.ResultTypeName(N.NodeType())));
        } else {
          if (N.NodeType() !== V) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrCaseValueType"),pas.System.VarRecs(0,rtl.trunc((I - 1) / 2),18,N.AsString(),18,$mod.ResultTypeName(V),18,$mod.ResultTypeName(N.NodeType())));
        };
      };
    };
    this.InitAggregate = function () {
      var I = 0;
      $mod.TFPExprNode.InitAggregate.call(this);
      if (this.FCondition != null) this.FCondition.InitAggregate();
      for (var $l = 0, $end = rtl.length(this.FArgs) - 1; $l <= $end; $l++) {
        I = $l;
        this.FArgs[I].InitAggregate();
      };
    };
    this.UpdateAggregate = function () {
      var I = 0;
      $mod.TFPExprNode.UpdateAggregate.call(this);
      if (this.FCondition != null) this.FCondition.UpdateAggregate();
      for (var $l = 0, $end = rtl.length(this.FArgs) - 1; $l <= $end; $l++) {
        I = $l;
        this.FArgs[I].InitAggregate();
      };
    };
    this.HasAggregate = function () {
      var Result = false;
      var I = 0;
      var L = 0;
      Result = $mod.TFPExprNode.HasAggregate.call(this);
      L = rtl.length(this.FArgs);
      I = 0;
      while (!Result && (I < L)) {
        Result = Result || this.FArgs[I].HasAggregate();
        I += 1;
      };
      return Result;
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FArgs[1].NodeType();
      return Result;
    };
    this.Create$1 = function (Args) {
      this.FArgs = rtl.arrayRef(Args);
      return this;
    };
    this.Destroy = function () {
      var I = 0;
      for (var $l = 0, $end = rtl.length(this.FArgs) - 1; $l <= $end; $l++) {
        I = $l;
        pas.SysUtils.FreeAndNil({a: I, p: this.FArgs, get: function () {
            return this.p[this.a];
          }, set: function (v) {
            this.p[this.a] = v;
          }});
      };
      pas.System.TObject.Destroy.call(this);
    };
    this.AsString = function () {
      var Result = "";
      var I = 0;
      Result = "";
      for (var $l = 0, $end = rtl.length(this.FArgs) - 1; $l <= $end; $l++) {
        I = $l;
        if (Result !== "") Result = Result + ", ";
        Result = Result + this.FArgs[I].AsString();
      };
      Result = "Case(" + Result + ")";
      return Result;
    };
  });
  rtl.createClass(this,"TMathOperation",this.TFPBinaryOperation,function () {
    var AllowedTypes = rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtFloat,$mod.TResultType.rtCurrency,$mod.TResultType.rtDateTime,$mod.TResultType.rtString);
    this.Check = function () {
      $mod.TFPBinaryOperation.Check.call(this);
      this.CheckNodeType(this.FLeft,AllowedTypes);
      this.CheckNodeType(this.FRight,AllowedTypes);
      this.CheckSameNodeTypes();
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FLeft.NodeType();
      return Result;
    };
  });
  rtl.createClass(this,"TFPAddOperation",this.TMathOperation,function () {
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = rtl.trunc(Result.resValue) + rtl.trunc(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtString) {
        Result.resValue = "" + Result.resValue + ("" + RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtDateTime) {
        Result.resValue = rtl.getNumber(Result.resValue) + rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result.resValue = rtl.getNumber(Result.resValue) + rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) Result.resValue = (rtl.trunc(Result.resValue * 10000) + rtl.trunc(RRes.resValue * 10000)) / 10000;
      Result.ResultType = this.NodeType();
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " + " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPSubtractOperation",this.TMathOperation,function () {
    var AllowedTypes$1 = rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtFloat,$mod.TResultType.rtCurrency,$mod.TResultType.rtDateTime);
    this.Check = function () {
      this.CheckNodeType(this.FLeft,AllowedTypes$1);
      this.CheckNodeType(this.FRight,AllowedTypes$1);
      $mod.TMathOperation.Check.call(this);
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = rtl.trunc(Result.resValue) - rtl.trunc(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtDateTime) {
        Result.resValue = rtl.getNumber(Result.resValue) - rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result.resValue = rtl.getNumber(Result.resValue) - rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) Result.resValue = (rtl.trunc(Result.resValue * 10000) - rtl.trunc(RRes.resValue * 10000)) / 10000;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " - " + this.FRight.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPMultiplyOperation",this.TMathOperation,function () {
    var AllowedTypes$1 = rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtCurrency,$mod.TResultType.rtFloat);
    this.Check = function () {
      this.CheckNodeType(this.FLeft,AllowedTypes$1);
      this.CheckNodeType(this.FRight,AllowedTypes$1);
      $mod.TMathOperation.Check.call(this);
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " * " + this.FRight.AsString();
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = rtl.trunc(Result.resValue) * rtl.trunc(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result.resValue = rtl.getNumber(Result.resValue) * rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) Result.resValue = ((rtl.trunc(Result.resValue * 10000) * rtl.trunc(RRes.resValue * 10000)) / 10000) / 10000;
      return Result;
    };
  });
  rtl.createClass(this,"TFPDivideOperation",this.TMathOperation,function () {
    var AllowedTypes$1 = rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtCurrency,$mod.TResultType.rtFloat);
    this.Check = function () {
      this.CheckNodeType(this.FLeft,AllowedTypes$1);
      this.CheckNodeType(this.FRight,AllowedTypes$1);
      $mod.TMathOperation.Check.call(this);
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " / " + this.FRight.AsString();
      return Result;
    };
    this.NodeType = function () {
      var Result = 0;
      if ((this.FLeft.NodeType() === $mod.TResultType.rtCurrency) && (this.FRight.NodeType() === $mod.TResultType.rtCurrency)) {
        Result = $mod.TResultType.rtCurrency}
       else Result = $mod.TResultType.rtFloat;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = rtl.trunc(Result.resValue) / rtl.trunc(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result.resValue = rtl.getNumber(Result.resValue) / rtl.getNumber(RRes.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) if (this.NodeType() === $mod.TResultType.rtCurrency) {
        Result.resValue = rtl.trunc((rtl.trunc(Result.resValue * 10000) / rtl.trunc(RRes.resValue * 10000)) * 10000) / 10000}
       else Result.resValue = rtl.getNumber(Result.resValue) / rtl.getNumber(RRes.resValue);
      Result.ResultType = this.NodeType();
      return Result;
    };
  });
  rtl.createClass(this,"TFPModuloOperation",this.TMathOperation,function () {
    this.Check = function () {
      this.CheckNodeType(this.FLeft,rtl.createSet($mod.TResultType.rtInteger));
      this.CheckNodeType(this.FRight,rtl.createSet($mod.TResultType.rtInteger));
      $mod.TMathOperation.Check.call(this);
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + " mod " + this.FRight.AsString();
      return Result;
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtInteger;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      Result.resValue = rtl.trunc(Result.resValue) % rtl.trunc(RRes.resValue);
      Result.ResultType = $mod.TResultType.rtInteger;
      return Result;
    };
  });
  rtl.createClass(this,"TFPPowerOperation",this.TMathOperation,function () {
    var AllowedTypes$1 = rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtCurrency,$mod.TResultType.rtFloat);
    this.Check = function () {
      this.CheckNodeType(this.FLeft,AllowedTypes$1);
      this.CheckNodeType(this.FRight,AllowedTypes$1);
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FLeft.AsString() + "^" + this.FRight.AsString();
      return Result;
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtFloat;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var RRes = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FLeft.GetNodeValue());
      RRes.$assign(this.FRight.GetNodeValue());
      Result.resValue = $impl.power($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Result)),$mod.ArgToFloat($mod.TFPExpressionResult.$clone(RRes)));
      Result.ResultType = $mod.TResultType.rtFloat;
      return Result;
    };
  });
  rtl.createClass(this,"TFPUnaryOperator",this.TFPExprNode,function () {
    this.$init = function () {
      $mod.TFPExprNode.$init.call(this);
      this.FOperand = null;
    };
    this.$final = function () {
      this.FOperand = undefined;
      $mod.TFPExprNode.$final.call(this);
    };
    this.Create$1 = function (AOperand) {
      this.FOperand = AOperand;
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FOperand;
        }, set: function (v) {
          this.p.FOperand = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
    this.InitAggregate = function () {
      $mod.TFPExprNode.InitAggregate.call(this);
      if (this.FOperand != null) this.FOperand.InitAggregate();
    };
    this.UpdateAggregate = function () {
      $mod.TFPExprNode.UpdateAggregate.call(this);
      if (this.FOperand != null) this.FOperand.UpdateAggregate();
    };
    this.HasAggregate = function () {
      var Result = false;
      Result = $mod.TFPExprNode.HasAggregate.call(this);
      if (this.FOperand != null) Result = Result || this.FOperand.HasAggregate();
      return Result;
    };
    this.Check = function () {
      if (!(this.FOperand != null)) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrNoOperand"),pas.System.VarRecs(18,this.$classname));
    };
  });
  rtl.createClass(this,"TFPConvertNode",this.TFPUnaryOperator,function () {
    this.AsString = function () {
      var Result = "";
      Result = this.FOperand.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TFPNotNode",this.TFPUnaryOperator,function () {
    this.Check = function () {
      if (!(this.FOperand.NodeType() in rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtBoolean))) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrNoNOTOperation"),pas.System.VarRecs(18,$mod.ResultTypeName(this.FOperand.NodeType()),18,this.FOperand.AsString()));
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FOperand.NodeType();
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = !Result.resValue}
       else if ($tmp === $mod.TResultType.rtBoolean) Result.resValue = !Result.resValue;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = "not " + this.FOperand.AsString();
      return Result;
    };
  });
  rtl.createClass(this,"TIntConvertNode",this.TFPConvertNode,function () {
    this.Check = function () {
      $mod.TFPUnaryOperator.Check.call(this);
      this.CheckNodeType(this.FOperand,rtl.createSet($mod.TResultType.rtInteger));
    };
  });
  rtl.createClass(this,"TIntToFloatNode",this.TIntConvertNode,function () {
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtFloat;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      Result.resValue = Result.resValue;
      Result.ResultType = $mod.TResultType.rtFloat;
      return Result;
    };
  });
  rtl.createClass(this,"TIntToCurrencyNode",this.TIntConvertNode,function () {
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtCurrency;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      Result.resValue = Result.resValue;
      Result.ResultType = $mod.TResultType.rtCurrency;
      return Result;
    };
  });
  rtl.createClass(this,"TIntToDateTimeNode",this.TIntConvertNode,function () {
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtDateTime;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      Result.ResultType = $mod.TResultType.rtDateTime;
      return Result;
    };
  });
  rtl.createClass(this,"TFloatToDateTimeNode",this.TFPConvertNode,function () {
    this.Check = function () {
      $mod.TFPUnaryOperator.Check.call(this);
      this.CheckNodeType(this.FOperand,rtl.createSet($mod.TResultType.rtFloat));
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtDateTime;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      Result.ResultType = $mod.TResultType.rtDateTime;
      return Result;
    };
  });
  rtl.createClass(this,"TFloatToCurrencyNode",this.TFPConvertNode,function () {
    this.Check = function () {
      this.CheckNodeType(this.FOperand,rtl.createSet($mod.TResultType.rtFloat));
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtCurrency;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      Result.ResultType = $mod.TResultType.rtCurrency;
      Result.resValue = Result.resValue;
      return Result;
    };
  });
  rtl.createClass(this,"TCurrencyToDateTimeNode",this.TFPConvertNode,function () {
    this.Check = function () {
      $mod.TFPUnaryOperator.Check.call(this);
      this.CheckNodeType(this.FOperand,rtl.createSet($mod.TResultType.rtCurrency));
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtDateTime;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      var R = $mod.TFPExpressionResult.$new();
      R.$assign(this.FOperand.GetNodeValue());
      Result.resValue = rtl.trunc(R.resValue * 10000) / 10000;
      Result.ResultType = $mod.TResultType.rtDateTime;
      return Result;
    };
  });
  rtl.createClass(this,"TCurrencyToFloatNode",this.TFPConvertNode,function () {
    this.Check = function () {
      $mod.TFPUnaryOperator.Check.call(this);
      this.CheckNodeType(this.FOperand,rtl.createSet($mod.TResultType.rtCurrency));
    };
    this.NodeType = function () {
      var Result = 0;
      Result = $mod.TResultType.rtFloat;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      Result.resValue = rtl.trunc(Result.resValue * 10000) / 10000;
      Result.ResultType = $mod.TResultType.rtFloat;
      return Result;
    };
  });
  rtl.createClass(this,"TFPNegateOperation",this.TFPUnaryOperator,function () {
    this.Check = function () {
      $mod.TFPUnaryOperator.Check.call(this);
      if (!(this.FOperand.NodeType() in rtl.createSet($mod.TResultType.rtInteger,$mod.TResultType.rtFloat,$mod.TResultType.rtCurrency))) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrNoNegation"),pas.System.VarRecs(18,$mod.ResultTypeName(this.FOperand.NodeType()),18,this.FOperand.AsString()));
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FOperand.NodeType();
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FOperand.GetNodeValue());
      var $tmp = Result.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result.resValue = -rtl.trunc(Result.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result.resValue = -rtl.getNumber(Result.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) Result.resValue = -rtl.trunc(Result.resValue * 10000) / 10000;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      Result = "-" + pas.SysUtils.TrimLeft(this.FOperand.AsString());
      return Result;
    };
  });
  rtl.createClass(this,"TFPConstExpression",this.TFPExprNode,function () {
    this.$init = function () {
      $mod.TFPExprNode.$init.call(this);
      this.FValue = $mod.TFPExpressionResult.$new();
    };
    this.$final = function () {
      this.FValue = undefined;
      $mod.TFPExprNode.$final.call(this);
    };
    this.CreateString = function (AValue) {
      this.FValue.ResultType = $mod.TResultType.rtString;
      this.FValue.resValue = AValue;
      return this;
    };
    this.CreateInteger = function (AValue) {
      this.FValue.ResultType = $mod.TResultType.rtInteger;
      this.FValue.resValue = AValue;
      return this;
    };
    this.CreateDateTime = function (AValue) {
      this.FValue.ResultType = $mod.TResultType.rtDateTime;
      this.FValue.resValue = AValue;
      return this;
    };
    this.CreateFloat = function (AValue) {
      pas.System.TObject.Create.call(this);
      this.FValue.ResultType = $mod.TResultType.rtFloat;
      this.FValue.resValue = AValue;
      return this;
    };
    this.CreateBoolean = function (AValue) {
      this.FValue.ResultType = $mod.TResultType.rtBoolean;
      this.FValue.resValue = AValue;
      return this;
    };
    this.CreateCurrency = function (AValue) {
      pas.System.TObject.Create.call(this);
      this.FValue.ResultType = $mod.TResultType.rtCurrency;
      this.FValue.resValue = AValue / 10000;
      return this;
    };
    this.Check = function () {
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FValue.ResultType;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FValue);
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      var $tmp = this.NodeType();
      if ($tmp === $mod.TResultType.rtString) {
        Result = "'" + ("" + this.FValue.resValue) + "'"}
       else if ($tmp === $mod.TResultType.rtInteger) {
        Result = pas.SysUtils.IntToStr(rtl.trunc(this.FValue.resValue))}
       else if ($tmp === $mod.TResultType.rtDateTime) {
        Result = "'" + pas.SysUtils.FormatDateTime("cccc",rtl.getNumber(this.FValue.resValue)) + "'"}
       else if ($tmp === $mod.TResultType.rtBoolean) {
        if (!(this.FValue.resValue == false)) {
          Result = "True"}
         else Result = "False"}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result = rtl.floatToStr(rtl.getNumber(this.FValue.resValue))}
       else if ($tmp === $mod.TResultType.rtCurrency) Result = rtl.floatToStr(rtl.trunc(this.FValue.resValue * 10000) / 10000);
      return Result;
    };
  });
  this.TIdentifierType = {"0": "itVariable", itVariable: 0, "1": "itFunctionHandler", itFunctionHandler: 1, "2": "itFunctionNode", itFunctionNode: 2};
  this.$rtti.$Enum("TIdentifierType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TIdentifierType});
  this.$rtti.$RefToProcVar("TFPExprFunctionEvent",{procsig: rtl.newTIProcSig([["Args",this.$rtti["TExprParameterArray"],2]],this.$rtti["TFPExpressionResult"])});
  this.$rtti.$RefToProcVar("TFPExprVariableEvent",{procsig: rtl.newTIProcSig([["AName",rtl.string,2]],this.$rtti["TFPExpressionResult"])});
  rtl.createClass(this,"TFPExprIdentifierDef",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FNodeType = null;
      this.FOnGetVarValue = null;
      this.FStringValue = "";
      this.FValue = $mod.TFPExpressionResult.$new();
      this.FArgumentTypes = "";
      this.FIDType = 0;
      this.FName = "";
      this.FOnGetValue = null;
    };
    this.$final = function () {
      this.FNodeType = undefined;
      this.FOnGetVarValue = undefined;
      this.FValue = undefined;
      this.FOnGetValue = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.GetAsBoolean = function () {
      var Result = false;
      this.CheckResultType($mod.TResultType.rtBoolean);
      this.CheckVariable();
      Result = !(this.FValue.resValue == false);
      return Result;
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      this.CheckResultType($mod.TResultType.rtDateTime);
      this.CheckVariable();
      Result = rtl.getNumber(this.FValue.resValue);
      return Result;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      this.CheckResultType($mod.TResultType.rtFloat);
      this.CheckVariable();
      Result = rtl.getNumber(this.FValue.resValue);
      return Result;
    };
    this.GetAsCurrency = function () {
      var Result = 0;
      this.CheckResultType($mod.TResultType.rtCurrency);
      this.CheckVariable();
      Result = rtl.trunc(this.FValue.resValue * 10000);
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      this.CheckResultType($mod.TResultType.rtInteger);
      this.CheckVariable();
      Result = rtl.trunc(this.FValue.resValue);
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      this.CheckResultType($mod.TResultType.rtString);
      this.CheckVariable();
      Result = "" + this.FValue.resValue;
      return Result;
    };
    this.GetResultType = function () {
      var Result = 0;
      Result = this.FValue.ResultType;
      return Result;
    };
    this.GetValue = function () {
      var Result = "";
      var $tmp = this.FValue.ResultType;
      if ($tmp === $mod.TResultType.rtBoolean) {
        if (this.FValue.resValue) {
          Result = "True"}
         else Result = "False"}
       else if ($tmp === $mod.TResultType.rtInteger) {
        Result = pas.SysUtils.IntToStr(rtl.trunc(this.FValue.resValue))}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result = pas.SysUtils.FloatToStr(rtl.getNumber(this.FValue.resValue))}
       else if ($tmp === $mod.TResultType.rtCurrency) {
        Result = pas.SysUtils.CurrToStr(rtl.trunc(this.FValue.resValue * 10000))}
       else if ($tmp === $mod.TResultType.rtDateTime) {
        Result = pas.SysUtils.FormatDateTime("cccc",rtl.getNumber(this.FValue.resValue))}
       else if ($tmp === $mod.TResultType.rtString) Result = "" + this.FValue.resValue;
      return Result;
    };
    this.SetArgumentTypes = function (AValue) {
      var I = 0;
      if (this.FArgumentTypes === AValue) return;
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        I = $l;
        $mod.CharToResultType(AValue.charAt(I - 1));
      };
      this.FArgumentTypes = AValue;
    };
    this.SetAsBoolean = function (AValue) {
      this.CheckVariable();
      this.CheckResultType($mod.TResultType.rtBoolean);
      this.FValue.resValue = AValue;
    };
    this.SetAsDateTime = function (AValue) {
      this.CheckVariable();
      this.CheckResultType($mod.TResultType.rtDateTime);
      this.FValue.resValue = AValue;
    };
    this.SetAsFloat = function (AValue) {
      this.CheckVariable();
      this.CheckResultType($mod.TResultType.rtFloat);
      this.FValue.resValue = AValue;
    };
    this.SetAsCurrency = function (AValue) {
      this.CheckVariable();
      this.CheckResultType($mod.TResultType.rtCurrency);
      this.FValue.resValue = AValue / 10000;
    };
    this.SetAsInteger = function (AValue) {
      this.CheckVariable();
      this.CheckResultType($mod.TResultType.rtInteger);
      this.FValue.resValue = AValue;
    };
    this.SetAsString = function (AValue) {
      this.CheckVariable();
      this.CheckResultType($mod.TResultType.rtString);
      this.FValue.resValue = AValue;
    };
    this.SetName = function (AValue) {
      if (this.FName === AValue) return;
      if (AValue !== "") if ((this.FCollection != null) && (this.FCollection.IndexOfIdentifier(AValue) !== -1)) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrDuplicateIdentifier"),pas.System.VarRecs(18,AValue));
      this.FName = AValue;
    };
    this.SetResultType = function (AValue) {
      if (AValue !== this.FValue.ResultType) {
        this.FValue.ResultType = AValue;
        this.SetValue(this.FStringValue);
      };
    };
    this.SetValue = function (AValue) {
      this.FStringValue = AValue;
      if (AValue !== "") {
        var $tmp = this.FValue.ResultType;
        if ($tmp === $mod.TResultType.rtBoolean) {
          this.FValue.resValue = this.FStringValue === "True"}
         else if ($tmp === $mod.TResultType.rtInteger) {
          this.FValue.resValue = pas.SysUtils.StrToInt(AValue)}
         else if ($tmp === $mod.TResultType.rtFloat) {
          this.FValue.resValue = pas.SysUtils.StrToFloat(AValue)}
         else if ($tmp === $mod.TResultType.rtCurrency) {
          this.FValue.resValue = pas.SysUtils.StrToCurr(AValue) / 10000}
         else if ($tmp === $mod.TResultType.rtDateTime) {
          this.FValue.resValue = pas.SysUtils.StrToDateTime(AValue)}
         else if ($tmp === $mod.TResultType.rtString) this.FValue.resValue = AValue;
      } else {
        var $tmp1 = this.FValue.ResultType;
        if ($tmp1 === $mod.TResultType.rtBoolean) {
          this.FValue.resValue = false}
         else if ($tmp1 === $mod.TResultType.rtInteger) {
          this.FValue.resValue = 0}
         else if ($tmp1 === $mod.TResultType.rtFloat) {
          this.FValue.resValue = 0.0}
         else if ($tmp1 === $mod.TResultType.rtCurrency) {
          this.FValue.resValue = 0.0}
         else if ($tmp1 === $mod.TResultType.rtDateTime) {
          this.FValue.resValue = 0}
         else if ($tmp1 === $mod.TResultType.rtString) this.FValue.resValue = "";
      };
    };
    this.CheckResultType = function (AType) {
      if (this.FValue.ResultType !== AType) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrInvalidResultType"),pas.System.VarRecs(18,$mod.ResultTypeName(AType)));
    };
    this.CheckVariable = function () {
      if (this.FIDType !== $mod.TIdentifierType.itVariable) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrNotVariable"),pas.System.VarRecs(18,this.FName));
      if (this.EventBasedVariable()) this.FetchValue();
    };
    this.FetchValue = function () {
      var RT = 0;
      var RT2 = 0;
      var I = 0;
      RT = this.GetResultType();
      if (this.FOnGetVarValue != null) this.FValue.$assign(this.FOnGetVarValue(this.FName));
      RT2 = this.FValue.ResultType;
      if (RT2 !== RT) {
        if ((RT2 === $mod.TResultType.rtInteger) && (RT === $mod.TResultType.rtFloat)) {
          this.FValue.ResultType = RT;
          I = rtl.trunc(this.FValue.resValue);
          this.FValue.resValue = I;
        } else {
          this.FValue.ResultType = RT;
          throw $mod.EExprParser.$create("CreateFmt",['Value handler for variable %s returned wrong type, expected "%s", got "%s"',pas.System.VarRecs(18,this.FName,18,pas.TypInfo.GetEnumName($mod.$rtti["TResultType"],RT),18,pas.TypInfo.GetEnumName($mod.$rtti["TResultType"],RT2))]);
        };
      };
    };
    this.ArgumentCount = function () {
      var Result = 0;
      Result = this.FArgumentTypes.length;
      return Result;
    };
    this.Assign = function (Source) {
      var EID = null;
      if ($mod.TFPExprIdentifierDef.isPrototypeOf(Source)) {
        EID = rtl.as(Source,$mod.TFPExprIdentifierDef);
        this.FStringValue = EID.FStringValue;
        this.FValue.$assign(EID.FValue);
        this.FArgumentTypes = EID.FArgumentTypes;
        this.FIDType = EID.FIDType;
        this.FName = EID.FName;
        this.FOnGetValue = EID.FOnGetValue;
        this.FOnGetVarValue = EID.FOnGetVarValue;
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.EventBasedVariable = function () {
      var Result = false;
      Result = this.FOnGetVarValue != null;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("IdentifierType",0,$mod.$rtti["TIdentifierType"],"FIDType","FIDType");
    $r.addProperty("Name",2,rtl.string,"FName","SetName");
    $r.addProperty("Value",3,rtl.string,"GetValue","SetValue");
    $r.addProperty("ParameterTypes",2,rtl.string,"FArgumentTypes","SetArgumentTypes");
    $r.addProperty("ResultType",3,$mod.$rtti["TResultType"],"GetResultType","SetResultType");
    $r.addProperty("OnGetFunctionValue",0,$mod.$rtti["TFPExprFunctionEvent"],"FOnGetValue","FOnGetValue");
    $r.addProperty("OnGetVariableValue",0,$mod.$rtti["TFPExprVariableEvent"],"FOnGetVarValue","FOnGetVarValue");
    $r.addProperty("NodeType",0,$mod.$rtti["TFPExprFunctionClass"],"FNodeType","FNodeType");
  });
  this.TBuiltInCategory = {"0": "bcStrings", bcStrings: 0, "1": "bcDateTime", bcDateTime: 1, "2": "bcMath", bcMath: 2, "3": "bcBoolean", bcBoolean: 3, "4": "bcConversion", bcConversion: 4, "5": "bcData", bcData: 5, "6": "bcVaria", bcVaria: 6, "7": "bcUser", bcUser: 7, "8": "bcAggregate", bcAggregate: 8};
  this.$rtti.$Enum("TBuiltInCategory",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TBuiltInCategory});
  this.$rtti.$Set("TBuiltInCategories",{comptype: this.$rtti["TBuiltInCategory"]});
  rtl.createClass(this,"TFPBuiltInExprIdentifierDef",this.TFPExprIdentifierDef,function () {
    this.$init = function () {
      $mod.TFPExprIdentifierDef.$init.call(this);
      this.FCategory = 0;
    };
    this.Assign = function (Source) {
      $mod.TFPExprIdentifierDef.Assign.call(this,Source);
      if ($mod.TFPBuiltInExprIdentifierDef.isPrototypeOf(Source)) this.FCategory = rtl.as(Source,$mod.TFPBuiltInExprIdentifierDef).FCategory;
    };
    var $r = this.$rtti;
    $r.addProperty("Category",0,$mod.$rtti["TBuiltInCategory"],"FCategory","FCategory");
  });
  rtl.createClass(this,"TFPExprIdentifierDefs",pas.Classes.TCollection,function () {
    this.$init = function () {
      pas.Classes.TCollection.$init.call(this);
      this.FParser = null;
    };
    this.$final = function () {
      this.FParser = undefined;
      pas.Classes.TCollection.$final.call(this);
    };
    this.GetI = function (AIndex) {
      var Result = null;
      Result = this.GetItem(AIndex);
      return Result;
    };
    this.SetI = function (AIndex, AValue) {
      this.SetItem(AIndex,AValue);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.call(this,Item);
      if (this.FParser != null) this.FParser.FDirty = true;
    };
    this.IndexOfIdentifier = function (AName) {
      var Result = 0;
      Result = this.GetCount() - 1;
      while ((Result >= 0) && (pas.SysUtils.CompareText(this.GetI(Result).FName,AName) !== 0)) Result -= 1;
      return Result;
    };
    this.FindIdentifier = function (AName) {
      var Result = null;
      var I = 0;
      I = this.IndexOfIdentifier(AName);
      if (I === -1) {
        Result = null}
       else Result = this.GetI(I);
      return Result;
    };
    this.IdentifierByName = function (AName) {
      var Result = null;
      Result = this.FindIdentifier(AName);
      if (Result === null) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrUnknownIdentifier"),pas.System.VarRecs(18,AName));
      return Result;
    };
    this.AddVariable = function (AName, AResultType, ACallback) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType(AResultType);
      Result.FOnGetVarValue = ACallback;
      return Result;
    };
    this.AddVariable$1 = function (AName, AResultType, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType(AResultType);
      Result.SetValue(AValue);
      return Result;
    };
    this.AddBooleanVariable = function (AName, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType($mod.TResultType.rtBoolean);
      Result.FValue.resValue = AValue;
      return Result;
    };
    this.AddIntegerVariable = function (AName, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType($mod.TResultType.rtInteger);
      Result.FValue.resValue = AValue;
      return Result;
    };
    this.AddFloatVariable = function (AName, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType($mod.TResultType.rtFloat);
      Result.FValue.resValue = AValue;
      return Result;
    };
    this.AddCurrencyVariable = function (AName, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType($mod.TResultType.rtCurrency);
      Result.FValue.resValue = AValue / 10000;
      return Result;
    };
    this.AddStringVariable = function (AName, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType($mod.TResultType.rtString);
      Result.FValue.resValue = AValue;
      return Result;
    };
    this.AddDateTimeVariable = function (AName, AValue) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.FIDType = $mod.TIdentifierType.itVariable;
      Result.SetName(AName);
      Result.SetResultType($mod.TResultType.rtDateTime);
      Result.FValue.resValue = AValue;
      return Result;
    };
    this.AddFunction = function (AName, AResultType, AParamTypes, ACallBack) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.SetName(AName);
      Result.FIDType = $mod.TIdentifierType.itFunctionHandler;
      Result.SetArgumentTypes(AParamTypes);
      Result.SetResultType($mod.CharToResultType(AResultType));
      Result.FOnGetValue = ACallBack;
      return Result;
    };
    this.AddFunction$1 = function (AName, AResultType, AParamTypes, ANodeClass) {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TFPExprIdentifierDef);
      Result.SetName(AName);
      Result.FIDType = $mod.TIdentifierType.itFunctionNode;
      Result.SetArgumentTypes(AParamTypes);
      Result.SetResultType($mod.CharToResultType(AResultType));
      Result.FNodeType = ANodeClass;
      return Result;
    };
  });
  rtl.createClass(this,"TFPExprIdentifierNode",this.TFPExprNode,function () {
    this.$init = function () {
      $mod.TFPExprNode.$init.call(this);
      this.FID = null;
      this.PResult = null;
      this.FResultType = 0;
    };
    this.$final = function () {
      this.FID = undefined;
      $mod.TFPExprNode.$final.call(this);
    };
    this.CreateIdentifier = function (AID) {
      pas.System.TObject.Create.call(this);
      this.FID = AID;
      this.PResult = this.FID.FValue;
      this.FResultType = this.FID.GetResultType();
      return this;
    };
    this.NodeType = function () {
      var Result = 0;
      Result = this.FResultType;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      if (this.FID.EventBasedVariable()) {
        this.FID.FetchValue();
        this.PResult = this.FID.FValue;
      };
      Result.$assign(this.PResult);
      Result.ResultType = this.FResultType;
      return Result;
    };
  });
  rtl.createClass(this,"TFPExprVariable",this.TFPExprIdentifierNode,function () {
    this.Check = function () {
    };
    this.AsString = function () {
      var Result = "";
      Result = this.FID.FName;
      return Result;
    };
  });
  rtl.createClass(this,"TFPExprFunction",this.TFPExprIdentifierNode,function () {
    this.$init = function () {
      $mod.TFPExprIdentifierNode.$init.call(this);
      this.FArgumentNodes = [];
      this.FargumentParams = [];
    };
    this.$final = function () {
      this.FArgumentNodes = undefined;
      this.FargumentParams = undefined;
      $mod.TFPExprIdentifierNode.$final.call(this);
    };
    this.CalcParams = function () {
      var I = 0;
      for (var $l = 0, $end = rtl.length(this.FargumentParams) - 1; $l <= $end; $l++) {
        I = $l;
        this.FargumentParams[I].$assign(this.FArgumentNodes[I].GetNodeValue());
      };
    };
    this.ConvertArgument = function (aIndex, aNode, aType) {
      var Result = null;
      var N = null;
      N = $mod.TFPExpressionParser.ConvertNode(aNode,aType);
      if (aNode === N) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrInvalidArgumentType"),pas.System.VarRecs(0,aIndex,18,$mod.ResultTypeName(aType),18,$mod.ResultTypeName(aNode.NodeType())));
      Result = N;
      return Result;
    };
    this.Check = function () {
      var I = 0;
      var rtp = 0;
      var rta = 0;
      if (rtl.length(this.FArgumentNodes) !== this.FID.ArgumentCount()) $impl.RaiseParserError$1(rtl.getResStr($mod,"ErrInvalidArgumentCount"),pas.System.VarRecs(18,this.FID.FName));
      for (var $l = 0, $end = rtl.length(this.FArgumentNodes) - 1; $l <= $end; $l++) {
        I = $l;
        rtp = $mod.CharToResultType(this.FID.FArgumentTypes.charAt((I + 1) - 1));
        rta = this.FArgumentNodes[I].NodeType();
        if (rtp !== rta) this.FArgumentNodes[I] = this.ConvertArgument(I + 1,this.FArgumentNodes[I],rtp);
      };
    };
    this.CreateFunction = function (AID, Args) {
      $mod.TFPExprIdentifierNode.CreateIdentifier.call(this,AID);
      this.FArgumentNodes = rtl.arrayRef(Args);
      this.FargumentParams = rtl.arraySetLength(this.FargumentParams,$mod.TFPExpressionResult,rtl.length(Args));
      return this;
    };
    this.Destroy = function () {
      var I = 0;
      for (var $l = 0, $end = rtl.length(this.FArgumentNodes) - 1; $l <= $end; $l++) {
        I = $l;
        pas.SysUtils.FreeAndNil({a: I, p: this.FArgumentNodes, get: function () {
            return this.p[this.a];
          }, set: function (v) {
            this.p[this.a] = v;
          }});
      };
      pas.System.TObject.Destroy.call(this);
    };
    this.InitAggregate = function () {
      var I = 0;
      for (var $l = 0, $end = rtl.length(this.FArgumentNodes) - 1; $l <= $end; $l++) {
        I = $l;
        this.FArgumentNodes[I].InitAggregate();
      };
    };
    this.UpdateAggregate = function () {
      var I = 0;
      for (var $l = 0, $end = rtl.length(this.FArgumentNodes) - 1; $l <= $end; $l++) {
        I = $l;
        this.FArgumentNodes[I].UpdateAggregate();
      };
    };
    this.HasAggregate = function () {
      var Result = false;
      var I = 0;
      Result = true;
      if (this.$class.IsAggregate()) return Result;
      for (var $l = 0, $end = rtl.length(this.FArgumentNodes) - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FArgumentNodes[I].HasAggregate()) return Result;
      };
      Result = false;
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      var S = "";
      var I = 0;
      S = "";
      for (var $l = 0, $end = rtl.length(this.FArgumentNodes) - 1; $l <= $end; $l++) {
        I = $l;
        if (S !== "") S = S + ",";
        S = S + this.FArgumentNodes[I].AsString();
      };
      if (S !== "") S = "(" + S + ")";
      Result = this.FID.FName + S;
      return Result;
    };
  });
  rtl.createClass(this,"TAggregateExpr",this.TFPExprFunction,function () {
    this.$init = function () {
      $mod.TFPExprFunction.$init.call(this);
      this.FResult = $mod.TFPExpressionResult.$new();
    };
    this.$final = function () {
      this.FResult = undefined;
      $mod.TFPExprFunction.$final.call(this);
    };
    this.IsAggregate = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign(this.FResult);
      return Result;
    };
  });
  rtl.createClass(this,"TAggregateMin",this.TAggregateExpr,function () {
    this.$init = function () {
      $mod.TAggregateExpr.$init.call(this);
      this.FFirst = false;
    };
    this.InitAggregate = function () {
      $mod.TFPExprFunction.InitAggregate.call(this);
      this.FFirst = true;
      this.FResult.ResultType = this.FArgumentNodes[0].NodeType();
      var $tmp = this.FResult.ResultType;
      if ($tmp === $mod.TResultType.rtFloat) {
        this.FResult.resValue = 0.0}
       else if ($tmp === $mod.TResultType.rtCurrency) {
        this.FResult.resValue = 0.0}
       else if ($tmp === $mod.TResultType.rtInteger) this.FResult.resValue = 0;
    };
    this.UpdateAggregate = function () {
      var OK = false;
      var N = $mod.TFPExpressionResult.$new();
      N.$assign(this.FArgumentNodes[0].GetNodeValue());
      if (this.FFirst) {
        this.FFirst = false;
        OK = true;
      } else {
        var $tmp = N.ResultType;
        if ($tmp === $mod.TResultType.rtFloat) {
          OK = rtl.getNumber(N.resValue) < rtl.getNumber(this.FResult.resValue)}
         else if ($tmp === $mod.TResultType.rtCurrency) {
          OK = rtl.trunc(N.resValue * 10000) < rtl.trunc(this.FResult.resValue * 10000)}
         else if ($tmp === $mod.TResultType.rtInteger) OK = rtl.trunc(N.resValue) < rtl.trunc(this.FResult.resValue);
      };
      if (OK) {
        var $tmp1 = this.FResult.ResultType;
        if ($tmp1 === $mod.TResultType.rtFloat) {
          this.FResult.resValue = N.resValue}
         else if ($tmp1 === $mod.TResultType.rtCurrency) {
          this.FResult.resValue = N.resValue}
         else if ($tmp1 === $mod.TResultType.rtInteger) this.FResult.resValue = N.resValue;
      };
      $mod.TFPExprFunction.UpdateAggregate.call(this);
    };
  });
  rtl.createClass(this,"TAggregateMax",this.TAggregateExpr,function () {
    this.$init = function () {
      $mod.TAggregateExpr.$init.call(this);
      this.FFirst = false;
    };
    this.InitAggregate = function () {
      $mod.TFPExprFunction.InitAggregate.call(this);
      this.FFirst = true;
      this.FResult.ResultType = this.FArgumentNodes[0].NodeType();
      var $tmp = this.FResult.ResultType;
      if ($tmp === $mod.TResultType.rtFloat) {
        this.FResult.resValue = 0.0}
       else if ($tmp === $mod.TResultType.rtCurrency) {
        this.FResult.resValue = 0.0}
       else if ($tmp === $mod.TResultType.rtInteger) this.FResult.resValue = 0;
    };
    this.UpdateAggregate = function () {
      var OK = false;
      var N = $mod.TFPExpressionResult.$new();
      N.$assign(this.FArgumentNodes[0].GetNodeValue());
      if (this.FFirst) {
        this.FResult.ResultType = N.ResultType;
        this.FFirst = false;
        OK = true;
      } else {
        var $tmp = N.ResultType;
        if ($tmp === $mod.TResultType.rtFloat) {
          OK = rtl.getNumber(N.resValue) > rtl.getNumber(this.FResult.resValue)}
         else if ($tmp === $mod.TResultType.rtCurrency) {
          OK = rtl.trunc(N.resValue * 10000) > rtl.trunc(this.FResult.resValue * 10000)}
         else if ($tmp === $mod.TResultType.rtInteger) OK = rtl.trunc(N.resValue) > rtl.trunc(this.FResult.resValue);
      };
      if (OK) {
        var $tmp1 = N.ResultType;
        if ($tmp1 === $mod.TResultType.rtFloat) {
          this.FResult.resValue = N.resValue}
         else if ($tmp1 === $mod.TResultType.rtInteger) {
          this.FResult.resValue = N.resValue}
         else if ($tmp1 === $mod.TResultType.rtCurrency) this.FResult.resValue = N.resValue;
      };
    };
  });
  rtl.createClass(this,"TAggregateSum",this.TAggregateExpr,function () {
    this.ConvertArgument = function (aIndex, aNode, aType) {
      var Result = null;
      if (!(aNode.NodeType() in rtl.createSet($mod.TResultType.rtFloat,$mod.TResultType.rtInteger,$mod.TResultType.rtCurrency))) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrInvalidArgumentType"),pas.System.VarRecs(0,aIndex,18,$mod.ResultTypeName(aType),18,$mod.ResultTypeName(aNode.NodeType())));
      Result = aNode;
      return Result;
    };
    this.InitAggregate = function () {
      this.FResult.ResultType = this.FArgumentNodes[0].NodeType();
      var $tmp = this.FResult.ResultType;
      if ($tmp === $mod.TResultType.rtFloat) {
        this.FResult.resValue = 0.0}
       else if ($tmp === $mod.TResultType.rtCurrency) {
        this.FResult.resValue = 0.0}
       else if ($tmp === $mod.TResultType.rtInteger) this.FResult.resValue = 0;
    };
    this.UpdateAggregate = function () {
      var R = $mod.TFPExpressionResult.$new();
      R.$assign(this.FArgumentNodes[0].GetNodeValue());
      var $tmp = this.FResult.ResultType;
      if ($tmp === $mod.TResultType.rtFloat) {
        this.FResult.resValue = rtl.getNumber(this.FResult.resValue) + rtl.getNumber(R.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) {
        this.FResult.resValue = (rtl.trunc(this.FResult.resValue * 10000) + rtl.trunc(R.resValue * 10000)) / 10000}
       else if ($tmp === $mod.TResultType.rtInteger) this.FResult.resValue = rtl.trunc(this.FResult.resValue) + rtl.trunc(R.resValue);
    };
  });
  rtl.createClass(this,"TAggregateAvg",this.TAggregateSum,function () {
    this.$init = function () {
      $mod.TAggregateSum.$init.call(this);
      this.FCount = 0;
    };
    this.InitAggregate = function () {
      $mod.TAggregateSum.InitAggregate.call(this);
    };
    this.UpdateAggregate = function () {
      $mod.TAggregateSum.UpdateAggregate.call(this);
      this.FCount += 1;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      Result.$assign($mod.TAggregateExpr.GetNodeValue.call(this));
      Result.ResultType = this.FResult.ResultType;
      if (this.FCount === 0) {
        var $tmp = this.FResult.ResultType;
        if ($tmp === $mod.TResultType.rtInteger) {
          Result.ResultType = $mod.TResultType.rtFloat;
          Result.resValue = 0.0;
        } else if ($tmp === $mod.TResultType.rtFloat) {
          Result.resValue = 0.0}
         else if ($tmp === $mod.TResultType.rtCurrency) Result.resValue = 0.0;
      } else {
        var $tmp1 = this.FResult.ResultType;
        if ($tmp1 === $mod.TResultType.rtInteger) {
          Result.ResultType = $mod.TResultType.rtFloat;
          Result.resValue = rtl.trunc(this.FResult.resValue) / this.FCount;
        } else if ($tmp1 === $mod.TResultType.rtFloat) {
          Result.resValue = rtl.getNumber(this.FResult.resValue) / this.FCount}
         else if ($tmp1 === $mod.TResultType.rtCurrency) Result.resValue = rtl.trunc(rtl.trunc(this.FResult.resValue * 10000) / this.FCount) / 10000;
      };
      return Result;
    };
  });
  rtl.createClass(this,"TAggregateCount",this.TAggregateExpr,function () {
    this.InitAggregate = function () {
      this.FResult.ResultType = $mod.TResultType.rtInteger;
      this.FResult.resValue = 0;
    };
    this.UpdateAggregate = function () {
      this.FResult.resValue = rtl.trunc(this.FResult.resValue) + 1;
    };
  });
  rtl.createClass(this,"TFPFunctionEventHandler",this.TFPExprFunction,function () {
    this.$init = function () {
      $mod.TFPExprFunction.$init.call(this);
      this.FCallBack = null;
    };
    this.$final = function () {
      this.FCallBack = undefined;
      $mod.TFPExprFunction.$final.call(this);
    };
    this.CreateFunction = function (AID, Args) {
      $mod.TFPExprFunction.CreateFunction.apply(this,arguments);
      this.FCallBack = AID.FOnGetValue;
      return this;
    };
    this.GetNodeValue = function () {
      var Result = $mod.TFPExpressionResult.$new();
      if (rtl.length(this.FargumentParams) > 0) this.CalcParams();
      Result.$assign(this.FCallBack(this.FargumentParams));
      Result.ResultType = this.NodeType();
      return Result;
    };
  });
  rtl.createClass(this,"TFPExpressionParser",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FBuiltIns = {};
      this.FExpression = "";
      this.FScanner = null;
      this.FExprNode = null;
      this.FIdentifiers = null;
      this.FHashList = null;
      this.FDirty = false;
    };
    this.$final = function () {
      this.FBuiltIns = undefined;
      this.FScanner = undefined;
      this.FExprNode = undefined;
      this.FIdentifiers = undefined;
      this.FHashList = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.CheckEOF = function () {
      if (this.TokenType() === $mod.TTokenType.ttEOF) this.ParserError(rtl.getResStr($mod,"SErrUnexpectedEndOfExpression"));
    };
    this.GetAsBoolean = function () {
      var Result = false;
      var Res = $mod.TFPExpressionResult.$new();
      this.EvaluateExpression(Res);
      this.CheckResultType(Res,$mod.TResultType.rtBoolean);
      Result = !(Res.resValue == false);
      return Result;
    };
    this.GetAsDateTime = function () {
      var Result = 0.0;
      var Res = $mod.TFPExpressionResult.$new();
      this.EvaluateExpression(Res);
      this.CheckResultType(Res,$mod.TResultType.rtDateTime);
      Result = rtl.getNumber(Res.resValue);
      return Result;
    };
    this.GetAsFloat = function () {
      var Result = 0.0;
      var Res = $mod.TFPExpressionResult.$new();
      this.EvaluateExpression(Res);
      this.CheckResultTypes(Res,rtl.createSet($mod.TResultType.rtFloat,$mod.TResultType.rtCurrency,$mod.TResultType.rtInteger));
      var $tmp = Res.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result = rtl.trunc(Res.resValue)}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result = rtl.getNumber(Res.resValue)}
       else if ($tmp === $mod.TResultType.rtCurrency) Result = rtl.trunc(Res.resValue * 10000) / 10000;
      return Result;
    };
    this.GetAsCurrency = function () {
      var Result = 0;
      var Res = $mod.TFPExpressionResult.$new();
      this.EvaluateExpression(Res);
      this.CheckResultTypes(Res,rtl.createSet($mod.TResultType.rtFloat,$mod.TResultType.rtCurrency,$mod.TResultType.rtInteger));
      var $tmp = Res.ResultType;
      if ($tmp === $mod.TResultType.rtInteger) {
        Result = rtl.trunc(Res.resValue) * 10000}
       else if ($tmp === $mod.TResultType.rtFloat) {
        Result = rtl.trunc(rtl.getNumber(Res.resValue) * 10000)}
       else if ($tmp === $mod.TResultType.rtCurrency) Result = rtl.trunc(Res.resValue * 10000);
      return Result;
    };
    this.GetAsInteger = function () {
      var Result = 0;
      var Res = $mod.TFPExpressionResult.$new();
      this.EvaluateExpression(Res);
      this.CheckResultType(Res,$mod.TResultType.rtInteger);
      Result = rtl.trunc(Res.resValue);
      return Result;
    };
    this.GetAsString = function () {
      var Result = "";
      var Res = $mod.TFPExpressionResult.$new();
      this.EvaluateExpression(Res);
      this.CheckResultType(Res,$mod.TResultType.rtString);
      Result = "" + Res.resValue;
      return Result;
    };
    this.GetAllowLike = function () {
      var Result = false;
      Result = this.FScanner.FAllowLike;
      return Result;
    };
    this.MatchNodes = function (Todo, Match) {
      var Result = null;
      var FromType = 0;
      var ToType = 0;
      Result = Todo;
      FromType = Todo.NodeType();
      ToType = Match.NodeType();
      if (FromType !== ToType) {
        var $tmp = FromType;
        if ($tmp === $mod.TResultType.rtInteger) {
          if (ToType in rtl.createSet($mod.TResultType.rtFloat,$mod.TResultType.rtCurrency,$mod.TResultType.rtDateTime)) Result = this.$class.ConvertNode(Todo,ToType)}
         else if ($tmp === $mod.TResultType.rtFloat) {
          if (ToType in rtl.createSet($mod.TResultType.rtCurrency,$mod.TResultType.rtDateTime)) Result = this.$class.ConvertNode(Todo,ToType)}
         else if ($tmp === $mod.TResultType.rtCurrency) if (ToType in rtl.createSet($mod.TResultType.rtFloat,$mod.TResultType.rtDateTime)) Result = this.$class.ConvertNode(Todo,ToType);
      };
      return Result;
    };
    this.CheckNodes = function (Left, Right) {
      Left.set(this.MatchNodes(Left.get(),Right.get()));
      Right.set(this.MatchNodes(Right.get(),Left.get()));
    };
    this.SetBuiltIns = function (AValue) {
      if (rtl.eqSet(this.FBuiltIns,AValue)) return;
      this.FBuiltIns = rtl.refSet(AValue);
      this.FDirty = true;
    };
    this.SetIdentifiers = function (AValue) {
      this.FIdentifiers.Assign(AValue);
    };
    this.SetAllowLike = function (AValue) {
      this.FScanner.FAllowLike = AValue;
    };
    this.ParserError = function (Msg) {
      throw $mod.EExprParser.$create("Create$1",[Msg]);
    };
    this.SetExpression = function (AValue) {
      if (this.FExpression === AValue) return;
      this.FExpression = AValue;
      this.FScanner.SetSource(AValue);
      if (this.FExprNode != null) pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FExprNode;
        }, set: function (v) {
          this.p.FExprNode = v;
        }});
      if (this.FExpression !== "") {
        this.GetToken();
        this.FExprNode = this.Level1();
        if (this.TokenType() !== $mod.TTokenType.ttEOF) this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrUnterminatedExpression"),pas.System.VarRecs(0,this.FScanner.FPos,18,this.CurrentToken())));
        this.FExprNode.Check();
      } else this.FExprNode = null;
    };
    this.CheckResultType = function (Res, AType) {
      if (Res.ResultType !== AType) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrInvalidResultType"),pas.System.VarRecs(18,$mod.ResultTypeName(Res.ResultType)));
    };
    this.CheckResultTypes = function (Res, ATypes) {
      if (!(Res.ResultType in ATypes)) $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrInvalidResultType"),pas.System.VarRecs(18,$mod.ResultTypeName(Res.ResultType)));
    };
    this.ConvertNode = function (Todo, ToType) {
      var Result = null;
      Result = Todo;
      var $tmp = Todo.NodeType();
      if ($tmp === $mod.TResultType.rtInteger) {
        var $tmp1 = ToType;
        if ($tmp1 === $mod.TResultType.rtFloat) {
          Result = $mod.TIntToFloatNode.$create("Create$1",[Result])}
         else if ($tmp1 === $mod.TResultType.rtCurrency) {
          Result = $mod.TIntToCurrencyNode.$create("Create$1",[Result])}
         else if ($tmp1 === $mod.TResultType.rtDateTime) Result = $mod.TIntToDateTimeNode.$create("Create$1",[Result]);
      } else if ($tmp === $mod.TResultType.rtFloat) {
        var $tmp2 = ToType;
        if ($tmp2 === $mod.TResultType.rtCurrency) {
          Result = $mod.TFloatToCurrencyNode.$create("Create$1",[Result])}
         else if ($tmp2 === $mod.TResultType.rtDateTime) Result = $mod.TFloatToDateTimeNode.$create("Create$1",[Result]);
      } else if ($tmp === $mod.TResultType.rtCurrency) {
        var $tmp3 = ToType;
        if ($tmp3 === $mod.TResultType.rtFloat) {
          Result = $mod.TCurrencyToFloatNode.$create("Create$1",[Result])}
         else if ($tmp3 === $mod.TResultType.rtDateTime) Result = $mod.TCurrencyToDateTimeNode.$create("Create$1",[Result]);
      };
      return Result;
    };
    this.BuiltinsManager = function () {
      var Result = null;
      Result = $mod.BuiltinIdentifiers();
      return Result;
    };
    this.Level1 = function () {
      var Result = null;
      var tt = 0;
      var Right = null;
      if (this.TokenType() === $mod.TTokenType.ttNot) {
        this.GetToken();
        this.CheckEOF();
        Right = this.Level2();
        Result = $mod.TFPNotNode.$create("Create$1",[Right]);
      } else Result = this.Level2();
      try {
        while (this.TokenType() in rtl.createSet($mod.TTokenType.ttAnd,$mod.TTokenType.ttOr,$mod.TTokenType.ttXor)) {
          tt = this.TokenType();
          this.GetToken();
          this.CheckEOF();
          Right = this.Level2();
          var $tmp = tt;
          if ($tmp === $mod.TTokenType.ttOr) {
            Result = $mod.TFPBinaryOrOperation.$create("Create$1",[Result,Right])}
           else if ($tmp === $mod.TTokenType.ttAnd) {
            Result = $mod.TFPBinaryAndOperation.$create("Create$1",[Result,Right])}
           else if ($tmp === $mod.TTokenType.ttXor) {
            Result = $mod.TFPBinaryXOrOperation.$create("Create$1",[Result,Right])}
           else {
            this.ParserError(rtl.getResStr($mod,"SErrUnknownBooleanOp"));
          };
        };
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.Level2 = function () {
      var Result = null;
      var Right = null;
      var tt = 0;
      var C = null;
      Result = this.Level3();
      try {
        if (this.TokenType() in $mod.ttComparisons) {
          tt = this.TokenType();
          this.GetToken();
          this.CheckEOF();
          Right = this.Level3();
          this.CheckNodes({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},{get: function () {
              return Right;
            }, set: function (v) {
              Right = v;
            }});
          var $tmp = tt;
          if ($tmp === $mod.TTokenType.ttLessThan) {
            C = $mod.TFPLessThanOperation}
           else if ($tmp === $mod.TTokenType.ttLessThanEqual) {
            C = $mod.TFPLessThanEqualOperation}
           else if ($tmp === $mod.TTokenType.ttLargerThan) {
            C = $mod.TFPGreaterThanOperation}
           else if ($tmp === $mod.TTokenType.ttLargerThanEqual) {
            C = $mod.TFPGreaterThanEqualOperation}
           else if ($tmp === $mod.TTokenType.ttEqual) {
            C = $mod.TFPEqualOperation}
           else if ($tmp === $mod.TTokenType.ttunequal) {
            C = $mod.TFPUnequalOperation}
           else if ($tmp === $mod.TTokenType.ttLike) {
            C = $mod.TFPLikeOperation}
           else {
            this.ParserError(rtl.getResStr($mod,"SErrUnknownComparison"));
          };
          Result = C.$create("Create$1",[Result,Right]);
        };
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.Level3 = function () {
      var Result = null;
      var tt = 0;
      var right = null;
      Result = this.Level4();
      try {
        while (this.TokenType() in rtl.createSet($mod.TTokenType.ttPlus,$mod.TTokenType.ttMinus)) {
          tt = this.TokenType();
          this.GetToken();
          this.CheckEOF();
          right = this.Level4();
          this.CheckNodes({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},{get: function () {
              return right;
            }, set: function (v) {
              right = v;
            }});
          var $tmp = tt;
          if ($tmp === $mod.TTokenType.ttPlus) {
            Result = $mod.TFPAddOperation.$create("Create$1",[Result,right])}
           else if ($tmp === $mod.TTokenType.ttMinus) Result = $mod.TFPSubtractOperation.$create("Create$1",[Result,right]);
        };
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.Level4 = function () {
      var Result = null;
      var tt = 0;
      var right = null;
      Result = this.Level5();
      try {
        while (this.TokenType() in rtl.createSet($mod.TTokenType.ttMul,$mod.TTokenType.ttDiv,$mod.TTokenType.ttMod)) {
          tt = this.TokenType();
          this.GetToken();
          right = this.Level5();
          this.CheckNodes({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},{get: function () {
              return right;
            }, set: function (v) {
              right = v;
            }});
          var $tmp = tt;
          if ($tmp === $mod.TTokenType.ttMul) {
            Result = $mod.TFPMultiplyOperation.$create("Create$1",[Result,right])}
           else if ($tmp === $mod.TTokenType.ttDiv) {
            Result = $mod.TFPDivideOperation.$create("Create$1",[Result,right])}
           else if ($tmp === $mod.TTokenType.ttMod) Result = $mod.TFPModuloOperation.$create("Create$1",[Result,right]);
        };
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.Level5 = function () {
      var Result = null;
      var B = false;
      B = false;
      if (this.TokenType() in rtl.createSet($mod.TTokenType.ttPlus,$mod.TTokenType.ttMinus)) {
        B = this.TokenType() === $mod.TTokenType.ttMinus;
        this.GetToken();
      };
      Result = this.Level6();
      if (B) Result = $mod.TFPNegateOperation.$create("Create$1",[Result]);
      return Result;
    };
    this.Level6 = function () {
      var Result = null;
      var right = null;
      Result = this.Level7();
      try {
        while (this.TokenType() === $mod.TTokenType.ttPower) {
          this.GetToken();
          right = this.Level5();
          this.CheckNodes({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},{get: function () {
              return right;
            }, set: function (v) {
              right = v;
            }});
          Result = $mod.TFPPowerOperation.$create("Create$1",[Result,right]);
        };
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.Level7 = function () {
      var Result = null;
      if (this.TokenType() === $mod.TTokenType.ttLeft) {
        this.GetToken();
        Result = this.Level1();
        try {
          if (this.TokenType() !== $mod.TTokenType.ttRight) this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrBracketExpected"),pas.System.VarRecs(0,this.FScanner.FPos,18,this.CurrentToken())));
          this.GetToken();
        } catch ($e) {
          Result = rtl.freeLoc(Result);
          throw $e;
        };
      } else Result = this.Primitive();
      return Result;
    };
    this.Primitive = function () {
      var Result = null;
      var I = 0;
      var C = 0;
      var X = 0.0;
      var ACount = 0;
      var IFF = false;
      var IFC = false;
      var ID = null;
      var Args = [];
      var AI = 0;
      Args = rtl.arraySetLength(Args,null,0);
      if (this.TokenType() === $mod.TTokenType.ttNumber) {
        if (pas.SysUtils.TryStrToInt64(this.CurrentToken(),{get: function () {
            return I;
          }, set: function (v) {
            I = v;
          }})) {
          Result = $mod.TFPConstExpression.$create("CreateInteger",[I])}
         else {
          pas.System.val$8(this.CurrentToken(),{get: function () {
              return X;
            }, set: function (v) {
              X = v;
            }},{get: function () {
              return C;
            }, set: function (v) {
              C = v;
            }});
          if (C === 0) {
            Result = $mod.TFPConstExpression.$create("CreateFloat",[X])}
           else this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrInvalidFloat"),pas.System.VarRecs(18,this.CurrentToken())));
        };
      } else if (this.TokenType() === $mod.TTokenType.ttString) {
        Result = $mod.TFPConstExpression.$create("CreateString",[this.CurrentToken()])}
       else if (this.TokenType() in rtl.createSet($mod.TTokenType.ttTrue,$mod.TTokenType.ttFalse)) {
        Result = $mod.TFPConstExpression.$create("CreateBoolean",[this.TokenType() === $mod.TTokenType.ttTrue])}
       else if (!(this.TokenType() in rtl.createSet($mod.TTokenType.ttIdentifier,$mod.TTokenType.ttif,$mod.TTokenType.ttCase))) {
        this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SerrUnknownTokenAtPos"),pas.System.VarRecs(0,this.FScanner.FPos,18,this.CurrentToken())))}
       else {
        IFF = this.TokenType() === $mod.TTokenType.ttif;
        IFC = this.TokenType() === $mod.TTokenType.ttCase;
        if (!(IFF || IFC)) {
          ID = this.IdentifierByName(this.CurrentToken());
          if (ID === null) this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrUnknownIdentifier"),pas.System.VarRecs(18,this.CurrentToken())));
        };
        if (IFF) {
          ACount = 3}
         else if (IFC) {
          ACount = -4}
         else if (ID.FIDType in rtl.createSet($mod.TIdentifierType.itFunctionHandler,$mod.TIdentifierType.itFunctionNode)) {
          ACount = ID.ArgumentCount()}
         else ACount = 0;
        if (ACount !== 0) {
          this.GetToken();
          if (this.TokenType() !== $mod.TTokenType.ttLeft) this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrLeftBracketExpected"),pas.System.VarRecs(0,this.FScanner.FPos,18,this.CurrentToken())));
          Args = rtl.arraySetLength(Args,null,Math.abs(ACount));
          AI = 0;
          try {
            do {
              this.GetToken();
              if ((ACount < 0) && (AI === rtl.length(Args))) {
                Args = rtl.arraySetLength(Args,null,AI + 1);
                Args[AI] = null;
              };
              Args[AI] = this.Level1();
              AI += 1;
              if (this.TokenType() !== $mod.TTokenType.ttComma) if (AI < Math.abs(ACount)) this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrCommaExpected"),pas.System.VarRecs(0,this.FScanner.FPos,18,this.CurrentToken())));
            } while (!((AI === ACount) || ((ACount < 0) && (this.TokenType() === $mod.TTokenType.ttRight))));
            if (this.TokenType() !== $mod.TTokenType.ttRight) this.ParserError(pas.SysUtils.Format(rtl.getResStr($mod,"SErrBracketExpected"),pas.System.VarRecs(0,this.FScanner.FPos,18,this.CurrentToken())));
          } catch ($e) {
            if (pas.SysUtils.Exception.isPrototypeOf($e)) {
              var E = $e;
              AI -= 1;
              while (AI >= 0) {
                pas.SysUtils.FreeAndNil({a: AI, p: Args, get: function () {
                    return this.p[this.a];
                  }, set: function (v) {
                    this.p[this.a] = v;
                  }});
                AI -= 1;
              };
              throw $e;
            } else throw $e
          };
        };
        if (IFF) {
          Result = $mod.TIfOperation.$create("Create$2",[Args[0],Args[1],Args[2]])}
         else if (IFC) {
          Result = $mod.TCaseOperation.$create("Create$1",[rtl.arrayRef(Args)])}
         else {
          var $tmp = ID.FIDType;
          if ($tmp === $mod.TIdentifierType.itVariable) {
            Result = $mod.TFPExprVariable.$create("CreateIdentifier",[ID])}
           else if ($tmp === $mod.TIdentifierType.itFunctionHandler) {
            Result = $mod.TFPFunctionEventHandler.$create("CreateFunction",[ID,Args])}
           else if ($tmp === $mod.TIdentifierType.itFunctionNode) Result = ID.FNodeType.$create("CreateFunction",[ID,Args]);
        };
      };
      this.GetToken();
      return Result;
    };
    this.GetToken = function () {
      var Result = 0;
      Result = this.FScanner.GetToken();
      return Result;
    };
    this.TokenType = function () {
      var Result = 0;
      Result = this.FScanner.FTokenType;
      return Result;
    };
    this.CurrentToken = function () {
      var Result = "";
      Result = this.FScanner.FToken;
      return Result;
    };
    this.CreateHashList = function () {
      var ID = null;
      var BID = null;
      var I = 0;
      var M = null;
      this.FHashList.Clear();
      M = this.$class.BuiltinsManager();
      if (rtl.neSet(this.FBuiltIns,{}) && (M != null)) for (var $l = 0, $end = M.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        BID = M.GetI(I);
        if (BID.FCategory in this.FBuiltIns) this.FHashList.Add(pas.SysUtils.LowerCase(BID.FName),BID);
      };
      for (var $l1 = 0, $end1 = this.FIdentifiers.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        ID = this.FIdentifiers.GetI(I);
        this.FHashList.Add(pas.SysUtils.LowerCase(ID.FName),ID);
      };
      this.FDirty = false;
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FIdentifiers = $mod.TFPExprIdentifierDefs.$create("Create$1",[$mod.TFPExprIdentifierDef]);
      this.FIdentifiers.FParser = this;
      this.FScanner = $mod.TFPExpressionScanner.$create("Create$1");
      this.FHashList = pas.contnrs.TFPObjectHashTable.$create("Create$2",[false]);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FHashList;
        }, set: function (v) {
          this.p.FHashList = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FExprNode;
        }, set: function (v) {
          this.p.FExprNode = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FIdentifiers;
        }, set: function (v) {
          this.p.FIdentifiers = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FScanner;
        }, set: function (v) {
          this.p.FScanner = v;
        }});
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.IdentifierByName = function (AName) {
      var Result = null;
      var s = "";
      if (this.FDirty) this.CreateHashList();
      s = AName;
      if (s.length > 2) {
        if ((s.charAt(0) === "[") && (s.charAt(s.length - 1) === "]")) {
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,1);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},s.length,1);
        };
      };
      Result = this.FHashList.GetData(pas.SysUtils.LowerCase(s));
      return Result;
    };
    this.Clear = function () {
      this.FExpression = "";
      this.FHashList.Clear();
      rtl.free(this,"FExprNode");
    };
    this.Evaluate = function (aExpression) {
      var Result = $mod.TFPExpressionResult.$new();
      var F = null;
      F = $mod.TFPExpressionParser.$create("Create$1",[null]);
      try {
        F.SetExpression(aExpression);
        Result.$assign(F.Evaluate$1());
      } finally {
        F = rtl.freeLoc(F);
      };
      return Result;
    };
    this.EvaluateExpression = function (Result) {
      Result.$assign(this.Evaluate$1());
    };
    this.ExtractNode = function (N) {
      var Result = false;
      Result = this.FExprNode != null;
      if (Result) {
        N.set(this.FExprNode);
        this.FExprNode = null;
        this.FExpression = "";
      };
      return Result;
    };
    this.Evaluate$1 = function () {
      var Result = $mod.TFPExpressionResult.$new();
      if (this.FExpression === "") this.ParserError(rtl.getResStr($mod,"SErrInExpressionEmpty"));
      if (!(this.FExprNode != null)) this.ParserError(rtl.getResStr($mod,"SErrInExpression"));
      Result.$assign(this.FExprNode.GetNodeValue());
      return Result;
    };
    this.ResultType = function () {
      var Result = 0;
      if (!(this.FExprNode != null)) this.ParserError(rtl.getResStr($mod,"SErrInExpression"));
      Result = this.FExprNode.NodeType();
      return Result;
    };
    this.HasAggregate = function () {
      var Result = false;
      Result = (this.FExprNode != null) && this.FExprNode.HasAggregate();
      return Result;
    };
    this.InitAggregate = function () {
      if (this.FExprNode != null) this.FExprNode.InitAggregate();
    };
    this.UpdateAggregate = function () {
      if (this.FExprNode != null) this.FExprNode.UpdateAggregate();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Expression",2,rtl.string,"FExpression","SetExpression");
    $r.addProperty("Identifiers",2,$mod.$rtti["TFPExprIdentifierDefs"],"FIdentifiers","SetIdentifiers");
    $r.addProperty("BuiltIns",2,$mod.$rtti["TBuiltInCategories"],"FBuiltIns","SetBuiltIns");
  });
  this.$rtti.$ClassRef("TFPExpressionParserClass",{instancetype: this.$rtti["TFPExpressionParser"]});
  rtl.createClass(this,"TExprBuiltInManager",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FDefs = null;
    };
    this.$final = function () {
      this.FDefs = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FDefs.GetCount();
      return Result;
    };
    this.GetI = function (AIndex) {
      var Result = null;
      Result = this.FDefs.GetI(AIndex);
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FDefs = $mod.TFPExprIdentifierDefs.$create("Create$1",[$mod.TFPBuiltInExprIdentifierDef]);
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FDefs;
        }, set: function (v) {
          this.p.FDefs = v;
        }});
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.IndexOfIdentifier = function (AName) {
      var Result = 0;
      Result = this.FDefs.IndexOfIdentifier(AName);
      return Result;
    };
    this.FindIdentifier = function (AName) {
      var Result = null;
      Result = this.FDefs.FindIdentifier(AName);
      return Result;
    };
    this.IdentifierByName = function (AName) {
      var Result = null;
      Result = this.FDefs.IdentifierByName(AName);
      return Result;
    };
    this.AddVariable = function (ACategory, AName, AResultType, AValue) {
      var Result = null;
      Result = this.FDefs.AddVariable$1(AName,AResultType,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddBooleanVariable = function (ACategory, AName, AValue) {
      var Result = null;
      Result = this.FDefs.AddBooleanVariable(AName,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddIntegerVariable = function (ACategory, AName, AValue) {
      var Result = null;
      Result = this.FDefs.AddIntegerVariable(AName,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddFloatVariable = function (ACategory, AName, AValue) {
      var Result = null;
      Result = this.FDefs.AddFloatVariable(AName,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddCurrencyVariable = function (ACategory, AName, AValue) {
      var Result = null;
      Result = this.FDefs.AddCurrencyVariable(AName,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddStringVariable = function (ACategory, AName, AValue) {
      var Result = null;
      Result = this.FDefs.AddStringVariable(AName,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddDateTimeVariable = function (ACategory, AName, AValue) {
      var Result = null;
      Result = this.FDefs.AddDateTimeVariable(AName,AValue);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddFunction = function (ACategory, AName, AResultType, AParamTypes, ACallBack) {
      var Result = null;
      Result = this.FDefs.AddFunction(AName,AResultType,AParamTypes,ACallBack);
      Result.FCategory = ACategory;
      return Result;
    };
    this.AddFunction$1 = function (ACategory, AName, AResultType, AParamTypes, ANodeClass) {
      var Result = null;
      Result = this.FDefs.AddFunction$1(AName,AResultType,AParamTypes,ANodeClass);
      Result.FCategory = ACategory;
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"EExprParser",pas.SysUtils.Exception,function () {
  });
  this.AllBuiltIns = rtl.createSet(this.TBuiltInCategory.bcStrings,this.TBuiltInCategory.bcDateTime,this.TBuiltInCategory.bcMath,this.TBuiltInCategory.bcBoolean,this.TBuiltInCategory.bcConversion,this.TBuiltInCategory.bcData,this.TBuiltInCategory.bcVaria,this.TBuiltInCategory.bcUser,this.TBuiltInCategory.bcAggregate);
  this.TokenName = function (AToken) {
    var Result = "";
    Result = pas.TypInfo.GetEnumName($mod.$rtti["TTokenType"],AToken);
    return Result;
  };
  this.ResultTypeName = function (AResult) {
    var Result = "";
    Result = pas.TypInfo.GetEnumName($mod.$rtti["TResultType"],AResult);
    return Result;
  };
  this.CharToResultType = function (C) {
    var Result = 0;
    var $tmp = pas.System.upcase(C);
    if ($tmp === "S") {
      Result = $mod.TResultType.rtString}
     else if ($tmp === "D") {
      Result = $mod.TResultType.rtDateTime}
     else if ($tmp === "B") {
      Result = $mod.TResultType.rtBoolean}
     else if ($tmp === "I") {
      Result = $mod.TResultType.rtInteger}
     else if ($tmp === "F") {
      Result = $mod.TResultType.rtFloat}
     else if ($tmp === "C") {
      Result = $mod.TResultType.rtCurrency}
     else {
      $impl.RaiseParserError$1(rtl.getResStr($mod,"SErrInvalidResultCharacter"),pas.System.VarRecs(9,C));
    };
    return Result;
  };
  this.BuiltinIdentifiers = function () {
    var Result = null;
    if ($impl.BuiltIns === null) $impl.BuiltIns = $mod.TExprBuiltInManager.$create("Create$1",[null]);
    Result = $impl.BuiltIns;
    return Result;
  };
  this.RegisterStdBuiltins = function (AManager, Categories) {
    if ($mod.TBuiltInCategory.bcMath in Categories) {
      AManager.AddFloatVariable($mod.TBuiltInCategory.bcMath,"pi",Math.PI);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"cos","F","F",$impl.BuiltInCos);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"sin","F","F",$impl.BuiltInSin);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"abs","F","F",$impl.BuiltInAbs);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"sqr","F","F",$impl.BuiltInSqr);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"sqrt","F","F",$impl.BuiltInSqrt);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"exp","F","F",$impl.BuiltInExp);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"ln","F","F",$impl.BuiltInLn);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"log","F","F",$impl.BuiltInLog);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"frac","F","F",$impl.BuiltInFrac);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"int","F","F",$impl.BuiltInInt);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"round","I","F",$impl.BuiltInRound);
      AManager.AddFunction($mod.TBuiltInCategory.bcMath,"trunc","I","F",$impl.BuiltInTrunc);
    };
    if ($mod.TBuiltInCategory.bcStrings in Categories) {
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"length","I","S",$impl.BuiltInLength);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"copy","S","SII",$impl.BuiltInCopy);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"delete","S","SII",$impl.BuiltInDelete);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"pos","I","SS",$impl.BuiltInPos);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"lowercase","S","S",$impl.BuiltInLowercase);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"uppercase","S","S",$impl.BuiltInUppercase);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"stringreplace","S","SSSBB",$impl.BuiltInStringReplace);
      AManager.AddFunction($mod.TBuiltInCategory.bcStrings,"comparetext","I","SS",$impl.BuiltInCompareText);
    };
    if ($mod.TBuiltInCategory.bcDateTime in Categories) {
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"date","D","",$impl.BuiltInDate);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"time","D","",$impl.BuiltInTime);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"now","D","",$impl.BuiltInNow);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"dayofweek","I","D",$impl.BuiltInDayofWeek);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extractyear","I","D",$impl.BuiltInExtractYear);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extractmonth","I","D",$impl.BuiltInExtractMonth);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extractday","I","D",$impl.BuiltInExtractDay);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extracthour","I","D",$impl.BuiltInExtractHour);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extractmin","I","D",$impl.BuiltInExtractMin);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extractsec","I","D",$impl.BuiltInExtractSec);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"extractmsec","I","D",$impl.BuiltInExtractMSec);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"encodedate","D","III",$impl.BuiltInEncodedate);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"encodetime","D","IIII",$impl.BuiltInEncodeTime);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"encodedatetime","D","IIIIIII",$impl.BuiltInEncodeDateTime);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"shortdayname","S","I",$impl.BuiltInShortDayName);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"shortmonthname","S","I",$impl.BuiltInShortMonthName);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"longdayname","S","I",$impl.BuiltInLongDayName);
      AManager.AddFunction($mod.TBuiltInCategory.bcDateTime,"longmonthname","S","I",$impl.BuiltInLongMonthName);
    };
    if ($mod.TBuiltInCategory.bcBoolean in Categories) {
      AManager.AddFunction($mod.TBuiltInCategory.bcBoolean,"shl","I","II",$impl.BuiltInShl);
      AManager.AddFunction($mod.TBuiltInCategory.bcBoolean,"shr","I","II",$impl.BuiltInShr);
      AManager.AddFunction($mod.TBuiltInCategory.bcBoolean,"IFS","S","BSS",$impl.BuiltinIFS);
      AManager.AddFunction($mod.TBuiltInCategory.bcBoolean,"IFF","F","BFF",$impl.BuiltinIFF);
      AManager.AddFunction($mod.TBuiltInCategory.bcBoolean,"IFD","D","BDD",$impl.BuiltinIFD);
      AManager.AddFunction($mod.TBuiltInCategory.bcBoolean,"IFI","I","BII",$impl.BuiltinIFI);
    };
    if ($mod.TBuiltInCategory.bcConversion in Categories) {
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"inttostr","S","I",$impl.BuiltInIntToStr);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtoint","I","S",$impl.BuiltInStrToInt);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtointdef","I","SI",$impl.BuiltInStrToIntDef);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"floattostr","S","F",$impl.BuiltInFloatToStr);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtofloat","F","S",$impl.BuiltInStrToFloat);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtofloatdef","F","SF",$impl.BuiltInStrToFloatDef);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"booltostr","S","B",$impl.BuiltInBoolToStr);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtobool","B","S",$impl.BuiltInStrToBool);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtobooldef","B","SB",$impl.BuiltInStrToBoolDef);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"datetostr","S","D",$impl.BuiltInDateToStr);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"timetostr","S","D",$impl.BuiltInTimeToStr);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtodate","D","S",$impl.BuiltInStrToDate);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtodatedef","D","SD",$impl.BuiltInStrToDateDef);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtotime","D","S",$impl.BuiltInStrToTime);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtotimedef","D","SD",$impl.BuiltInStrToTimeDef);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtodatetime","D","S",$impl.BuiltInStrToDateTime);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"strtodatetimedef","D","SD",$impl.BuiltInStrToDateTimeDef);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"formatfloat","S","SF",$impl.BuiltInFormatFloat);
      AManager.AddFunction($mod.TBuiltInCategory.bcConversion,"formatdatetime","S","SD",$impl.BuiltInFormatDateTime);
    };
    if ($mod.TBuiltInCategory.bcAggregate in Categories) {
      AManager.AddFunction$1($mod.TBuiltInCategory.bcAggregate,"count","I","",$mod.TAggregateCount);
      AManager.AddFunction$1($mod.TBuiltInCategory.bcAggregate,"sum","F","F",$mod.TAggregateSum);
      AManager.AddFunction$1($mod.TBuiltInCategory.bcAggregate,"avg","F","F",$mod.TAggregateAvg);
      AManager.AddFunction$1($mod.TBuiltInCategory.bcAggregate,"min","F","F",$mod.TAggregateMin);
      AManager.AddFunction$1($mod.TBuiltInCategory.bcAggregate,"max","F","F",$mod.TAggregateMax);
    };
  };
  this.ArgToFloat = function (Arg) {
    var Result = 0.0;
    if (Arg.ResultType === $mod.TResultType.rtInteger) {
      Result = rtl.trunc(Arg.resValue)}
     else if (Arg.ResultType === $mod.TResultType.rtCurrency) {
      Result = rtl.trunc(Arg.resValue * 10000) / 10000}
     else Result = rtl.getNumber(Arg.resValue);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.cNull = "\x00";
    $impl.cSingleQuote = "'";
    $impl.cHexIdentifier = "$";
    $impl.cOctalIdentifier = "&";
    $impl.cBinaryIdentifier = "%";
    $impl.Digits = rtl.createSet(null,48,57,46);
    $impl.HexDigits = rtl.createSet(null,48,57,null,65,70,null,97,102);
    $impl.OctalDigits = rtl.createSet(null,48,55);
    $impl.BinaryDigits = rtl.createSet(48,49);
    $impl.WhiteSpace = rtl.createSet(32,13,10,9);
    $impl.Operators = rtl.createSet(43,45,60,62,61,47,42,94);
    $impl.Delimiters = rtl.unionSet($impl.Operators,rtl.createSet(44,40,41));
    $impl.Symbols = rtl.unionSet(rtl.createSet(37),$impl.Delimiters);
    $impl.WordDelimiters = rtl.unionSet($impl.WhiteSpace,$impl.Symbols);
    $impl.FileFormatSettings = pas.SysUtils.TFormatSettings.$new();
    $impl.RaiseParserError = function (Msg) {
      throw $mod.EExprParser.$create("Create$1",[Msg]);
    };
    $impl.RaiseParserError$1 = function (Fmt, Args) {
      throw $mod.EExprParser.$create("CreateFmt",[Fmt,Args]);
    };
    $impl.BuiltIns = null;
    $impl.power = function (base, exponent) {
      var Result = 0.0;
      var ex = 0;
      if (exponent === 0.0) {
        Result = 1.0}
       else if ((base === 0.0) && (exponent > 0.0)) {
        Result = 0.0}
       else if ((base < 0.0) && (pas.System.Frac(exponent) === 0.0)) {
        ex = Math.round(exponent);
        Result = Math.exp(exponent * Math.log(-base));
        if (pas.System.Odd(ex)) Result = -Result;
      } else Result = Math.exp(exponent * Math.log(base));
      return Result;
    };
    $impl.BuiltInCos = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.cos($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInSin = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.sin($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInAbs = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.abs($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInSqr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = pas.System.Sqr$1($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInSqrt = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.sqrt($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInExp = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.exp($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInLn = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.log($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.L10 = 0.0;
    $impl.BuiltInLog = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = Math.log($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0]))) / $impl.L10;
      return Result;
    };
    $impl.BuiltInRound = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = Math.round($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInTrunc = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.System.Trunc($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInInt = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.System.Int($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInFrac = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = pas.System.Frac($mod.ArgToFloat($mod.TFPExpressionResult.$clone(Args[0])));
      return Result;
    };
    $impl.BuiltInLength = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = ("" + Args[0].resValue).length;
      return Result;
    };
    $impl.BuiltInCopy = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.System.Copy("" + Args[0].resValue,rtl.trunc(Args[1].resValue),rtl.trunc(Args[2].resValue));
      return Result;
    };
    $impl.BuiltInDelete = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var S = "";
      Result.ResultType = $mod.TResultType.rtString;
      S = "" + Args[0].resValue;
      pas.System.Delete({get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},rtl.trunc(Args[1].resValue),rtl.trunc(Args[2].resValue));
      Result.resValue = S;
      return Result;
    };
    $impl.BuiltInPos = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.System.Pos("" + Args[0].resValue,"" + Args[1].resValue);
      return Result;
    };
    $impl.BuiltInUppercase = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.UpperCase("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInLowercase = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.LowerCase("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStringReplace = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var F = {};
      Result.ResultType = $mod.TResultType.rtString;
      F = {};
      if (!(Args[3].resValue == false)) F = rtl.includeSet(F,pas.SysUtils.TStringReplaceFlag.rfReplaceAll);
      if (!(Args[4].resValue == false)) F = rtl.includeSet(F,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase);
      Result.resValue = pas.SysUtils.StringReplace("" + Args[0].resValue,"" + Args[1].resValue,"" + Args[2].resValue,rtl.refSet(F));
      return Result;
    };
    $impl.BuiltInCompareText = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.SysUtils.CompareText("" + Args[0].resValue,"" + Args[1].resValue);
      return Result;
    };
    $impl.BuiltInDate = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      if (rtl.length(Args) === 0) ;
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.Date();
      return Result;
    };
    $impl.BuiltInTime = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      if (rtl.length(Args) === 0) ;
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.Time();
      return Result;
    };
    $impl.BuiltInNow = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      if (rtl.length(Args) === 0) ;
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.Now();
      return Result;
    };
    $impl.BuiltInDayofWeek = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.SysUtils.DayOfWeek(rtl.getNumber(Args[0].resValue));
      return Result;
    };
    $impl.BuiltInExtractYear = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var Y = 0;
      var M = 0;
      var D = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeDate(rtl.getNumber(Args[0].resValue),{get: function () {
          return Y;
        }, set: function (v) {
          Y = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }});
      Result.resValue = Y;
      return Result;
    };
    $impl.BuiltInExtractMonth = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var Y = 0;
      var M = 0;
      var D = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeDate(rtl.getNumber(Args[0].resValue),{get: function () {
          return Y;
        }, set: function (v) {
          Y = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }});
      Result.resValue = M;
      return Result;
    };
    $impl.BuiltInExtractDay = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var Y = 0;
      var M = 0;
      var D = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeDate(rtl.getNumber(Args[0].resValue),{get: function () {
          return Y;
        }, set: function (v) {
          Y = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }});
      Result.resValue = D;
      return Result;
    };
    $impl.BuiltInExtractHour = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var H = 0;
      var M = 0;
      var S = 0;
      var MS = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeTime(rtl.getNumber(Args[0].resValue),{get: function () {
          return H;
        }, set: function (v) {
          H = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},{get: function () {
          return MS;
        }, set: function (v) {
          MS = v;
        }});
      Result.resValue = H;
      return Result;
    };
    $impl.BuiltInExtractMin = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var H = 0;
      var M = 0;
      var S = 0;
      var MS = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeTime(rtl.getNumber(Args[0].resValue),{get: function () {
          return H;
        }, set: function (v) {
          H = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},{get: function () {
          return MS;
        }, set: function (v) {
          MS = v;
        }});
      Result.resValue = M;
      return Result;
    };
    $impl.BuiltInExtractSec = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var H = 0;
      var M = 0;
      var S = 0;
      var MS = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeTime(rtl.getNumber(Args[0].resValue),{get: function () {
          return H;
        }, set: function (v) {
          H = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},{get: function () {
          return MS;
        }, set: function (v) {
          MS = v;
        }});
      Result.resValue = S;
      return Result;
    };
    $impl.BuiltInExtractMSec = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      var H = 0;
      var M = 0;
      var S = 0;
      var MS = 0;
      Result.ResultType = $mod.TResultType.rtInteger;
      pas.SysUtils.DecodeTime(rtl.getNumber(Args[0].resValue),{get: function () {
          return H;
        }, set: function (v) {
          H = v;
        }},{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }},{get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},{get: function () {
          return MS;
        }, set: function (v) {
          MS = v;
        }});
      Result.resValue = MS;
      return Result;
    };
    $impl.BuiltInEncodedate = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.EncodeDate(rtl.trunc(Args[0].resValue),rtl.trunc(Args[1].resValue),rtl.trunc(Args[2].resValue));
      return Result;
    };
    $impl.BuiltInEncodeTime = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.EncodeTime(rtl.trunc(Args[0].resValue),rtl.trunc(Args[1].resValue),rtl.trunc(Args[2].resValue),rtl.trunc(Args[3].resValue));
      return Result;
    };
    $impl.BuiltInEncodeDateTime = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.EncodeDate(rtl.trunc(Args[0].resValue),rtl.trunc(Args[1].resValue),rtl.trunc(Args[2].resValue)) + pas.SysUtils.EncodeTime(rtl.trunc(Args[3].resValue),rtl.trunc(Args[4].resValue),rtl.trunc(Args[5].resValue),rtl.trunc(Args[6].resValue));
      return Result;
    };
    $impl.BuiltInShortDayName = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.FormatSettings.ShortDayNames[rtl.trunc(Args[0].resValue) - 1];
      return Result;
    };
    $impl.BuiltInShortMonthName = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.FormatSettings.ShortMonthNames[rtl.trunc(Args[0].resValue) - 1];
      return Result;
    };
    $impl.BuiltInLongDayName = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.resValue = pas.SysUtils.FormatSettings.LongDayNames[rtl.trunc(Args[0].resValue) - 1];
      return Result;
    };
    $impl.BuiltInLongMonthName = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.FormatSettings.LongMonthNames[rtl.trunc(Args[0].resValue) - 1];
      return Result;
    };
    $impl.BuiltInFormatDateTime = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.FormatDateTime("" + Args[0].resValue,rtl.getNumber(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInIntToStr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.IntToStr(rtl.trunc(Args[0].resValue));
      return Result;
    };
    $impl.BuiltInStrToInt = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.SysUtils.StrToInt("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStrToIntDef = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = pas.SysUtils.StrToIntDef$1("" + Args[0].resValue,rtl.trunc(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInFloatToStr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.FloatToStr(rtl.getNumber(Args[0].resValue));
      return Result;
    };
    $impl.BuiltInStrToFloat = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = pas.SysUtils.StrToFloat("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStrToFloatDef = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      Result.resValue = pas.SysUtils.StrToFloatDef("" + Args[0].resValue,rtl.getNumber(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInDateToStr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.DateToStr(rtl.getNumber(Args[0].resValue));
      return Result;
    };
    $impl.BuiltInTimeToStr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.TimeToStr(rtl.getNumber(Args[0].resValue));
      return Result;
    };
    $impl.BuiltInStrToDate = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.StrToDate("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStrToDateDef = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.StrToDateDef("" + Args[0].resValue,rtl.getNumber(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInStrToTime = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.StrToTime("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStrToTimeDef = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.StrToTimeDef("" + Args[0].resValue,rtl.getNumber(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInStrToDateTime = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.StrToDateTime("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStrToDateTimeDef = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      Result.resValue = pas.SysUtils.StrToDateTimeDef("" + Args[0].resValue,rtl.getNumber(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInFormatFloat = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.FormatFloat("" + Args[0].resValue,rtl.getNumber(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInBoolToStr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      Result.resValue = pas.SysUtils.BoolToStr(!(Args[0].resValue == false),false);
      return Result;
    };
    $impl.BuiltInStrToBool = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtBoolean;
      Result.resValue = pas.SysUtils.StrToBool("" + Args[0].resValue);
      return Result;
    };
    $impl.BuiltInStrToBoolDef = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.resValue = pas.SysUtils.StrToBoolDef("" + Args[0].resValue,!(Args[1].resValue == false));
      Result.ResultType = $mod.TResultType.rtBoolean;
      return Result;
    };
    $impl.BuiltInShl = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = rtl.shl(rtl.trunc(Args[0].resValue),rtl.trunc(Args[1].resValue));
      return Result;
    };
    $impl.BuiltInShr = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      Result.resValue = rtl.shr(rtl.trunc(Args[0].resValue),rtl.trunc(Args[1].resValue));
      return Result;
    };
    $impl.BuiltinIFS = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtString;
      if (!(Args[0].resValue == false)) {
        Result.resValue = Args[1].resValue}
       else Result.resValue = Args[2].resValue;
      return Result;
    };
    $impl.BuiltinIFI = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtInteger;
      if (!(Args[0].resValue == false)) {
        Result.resValue = Args[1].resValue}
       else Result.resValue = Args[2].resValue;
      return Result;
    };
    $impl.BuiltinIFF = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtFloat;
      if (!(Args[0].resValue == false)) {
        Result.resValue = Args[1].resValue}
       else Result.resValue = Args[2].resValue;
      return Result;
    };
    $impl.BuiltinIFD = function (Args) {
      var Result = $mod.TFPExpressionResult.$new();
      Result.ResultType = $mod.TResultType.rtDateTime;
      if (!(Args[0].resValue == false)) {
        Result.resValue = Args[1].resValue}
       else Result.resValue = Args[2].resValue;
      return Result;
    };
    $impl.InitFileFormatSettings = function () {
      $impl.FileFormatSettings.$assign(pas.SysUtils.FormatSettings);
      $impl.FileFormatSettings.DecimalSeparator = ".";
      $impl.FileFormatSettings.DateSeparator = "-";
      $impl.FileFormatSettings.TimeSeparator = ":";
      $impl.FileFormatSettings.ShortDateFormat = "yyyy-mm-dd";
      $impl.FileFormatSettings.LongTimeFormat = "hh:nn:ss";
    };
    $mod.$resourcestrings = {SBadQuotes: {org: "Unterminated string"}, SUnknownDelimiter: {org: 'Unknown delimiter character: "%s"'}, SErrUnknownCharacter: {org: 'Unknown character at pos %d: "%s"'}, SErrUnexpectedEndOfExpression: {org: "Unexpected end of expression"}, SErrUnknownComparison: {org: "Internal error: Unknown comparison"}, SErrUnknownBooleanOp: {org: "Internal error: Unknown boolean operation"}, SErrBracketExpected: {org: "Expected ) bracket at position %d, but got %s"}, SerrUnknownTokenAtPos: {org: "Unknown token at pos %d : %s"}, SErrLeftBracketExpected: {org: "Expected ( bracket at position %d, but got %s"}, SErrInvalidFloat: {org: "%s is not a valid floating-point value"}, SErrUnknownIdentifier: {org: "Unknown identifier: %s"}, SErrInExpression: {org: "Cannot evaluate: error in expression"}, SErrInExpressionEmpty: {org: "Cannot evaluate: empty expression"}, SErrCommaExpected: {org: "Expected comma (,) at position %d, but got %s"}, SErrInvalidNumberChar: {org: "Unexpected character in number : %s"}, SErrInvalidNumber: {org: "Invalid numerical value : %s"}, SErrUnterminatedIdentifier: {org: "Unterminated quoted identifier: %s"}, SErrNoOperand: {org: "No operand for unary operation %s"}, SErrNoleftOperand: {org: "No left operand for binary operation %s"}, SErrNoRightOperand: {org: "No right operand for binary operation %s"}, SErrNoNegation: {org: "Cannot negate expression of type %s : %s"}, SErrNoNOTOperation: {org: 'Cannot perform "not" on expression of type %s: %s'}, SErrTypesDoNotMatch: {org: 'Type mismatch: %s<>%s for expressions "%s" and "%s".'}, SErrNoNodeToCheck: {org: "Internal error: No node to check !"}, SInvalidNodeType: {org: "Node type (%s) not in allowed types (%s) for expression: %s"}, SErrUnterminatedExpression: {org: "Badly terminated expression. Found token at position %d : %s"}, SErrDuplicateIdentifier: {org: 'An identifier with name "%s" already exists.'}, SErrInvalidResultCharacter: {org: '"%s" is not a valid return type indicator'}, ErrInvalidArgumentCount: {org: "Invalid argument count for function %s"}, SErrInvalidArgumentType: {org: "Invalid type for argument %d: Expected %s, got %s"}, SErrInvalidResultType: {org: "Invalid result type: %s"}, SErrNotVariable: {org: "Identifier %s is not a variable"}, SErrIFNeedsBoolean: {org: "First argument to IF must be of type boolean: %s"}, SErrCaseNeeds3: {org: "Case statement needs to have at least 4 arguments"}, SErrCaseEvenCount: {org: "Case statement needs to have an even number of arguments"}, SErrCaseLabelNotAConst: {org: 'Case label %d "%s" is not a constant expression'}, SErrCaseLabelType: {org: 'Case label %d "%s" needs type %s, but has type %s'}, SErrCaseValueType: {org: 'Case value %d "%s" needs type %s, but has type %s'}, SErrStringTypeRequired: {org: 'Expression requires string type, got type "%s" for %s'}};
  };
  $mod.$init = function () {
    $impl.L10 = Math.log(10);
    $mod.RegisterStdBuiltins($mod.BuiltinIdentifiers(),$mod.AllBuiltIns);
    $impl.InitFileFormatSettings();
  };
},["TypInfo"]);
rtl.module("JSONDataset",["System","Types","JS","DB","Classes","SysUtils","TypInfo","fpexprpars","Web"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TBaseJSONDataSet");
  this.$rtti.$Class("TJSONIndexDef");
  this.TJSONRowType = {"0": "rtJSONObject", rtJSONObject: 0, "1": "rtJSONArray", rtJSONArray: 1};
  this.$rtti.$Enum("TJSONRowType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TJSONRowType});
  rtl.createClass(this,"TJSONFieldMapper",pas.System.TObject,function () {
    this.CopyRow = function (aRow) {
      var Result = undefined;
      Result = JSON.parse(JSON.stringify(aRow));
      return Result;
    };
    this.GetJSONDataForField$1 = function (F, Row) {
      var Result = undefined;
      Result = this.GetJSONDataForField(F.FFieldName,F.GetIndex(),Row);
      return Result;
    };
    this.SetJSONDataForField$1 = function (F, Row, Data) {
      this.SetJSONDataForField(F.FFieldName,F.GetIndex(),Row,Data);
    };
  });
  rtl.createClass(this,"TJSONDateField",pas.DB.TDateField,function () {
    this.$init = function () {
      pas.DB.TDateField.$init.call(this);
      this.FDateFormat = "";
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DateFormat",0,rtl.string,"FDateFormat","FDateFormat");
  });
  rtl.createClass(this,"TJSONTimeField",pas.DB.TTimeField,function () {
    this.$init = function () {
      pas.DB.TTimeField.$init.call(this);
      this.FTimeFormat = "";
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("TimeFormat",0,rtl.string,"FTimeFormat","FTimeFormat");
  });
  rtl.createClass(this,"TJSONDateTimeField",pas.DB.TDateTimeField,function () {
    this.$init = function () {
      pas.DB.TDateTimeField.$init.call(this);
      this.FDateTimeFormat = "";
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DateTimeFormat",0,rtl.string,"FDateTimeFormat","FDateTimeFormat");
  });
  rtl.createClass(this,"TFieldComparer",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FDesc = false;
      this.FValue = undefined;
      this.FField = null;
      this.FOptions = {};
      this.FDataset = null;
    };
    this.$final = function () {
      this.FField = undefined;
      this.FOptions = undefined;
      this.FDataset = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (aDataset, aField, aValue, aOptions) {
      this.FField = aField;
      this.FValue = aValue;
      this.FOptions = rtl.refSet(aOptions);
      this.FDataset = aDataset;
      return this;
    };
    this.GetFieldValue = function (RowIndex) {
      var Result = undefined;
      Result = this.FDataset.FFieldMapper.GetJSONDataForField$1(this.FField,this.FDataset.FRows[RowIndex]);
      return Result;
    };
    this.CompareRows = function (RowIndex1, RowIndex2) {
      var Result = 0;
      Result = this.Compare(RowIndex1,this.GetFieldValue(RowIndex2));
      return Result;
    };
    this.Compare$1 = function (RowIndex) {
      var Result = 0;
      Result = this.Compare(RowIndex,this.FValue);
      return Result;
    };
  });
  this.$rtti.$ClassRef("TFieldComparerClass",{instancetype: this.$rtti["TFieldComparer"]});
  rtl.createClass(this,"TStringFieldComparer",this.TFieldComparer,function () {
    this.Compare = function (RowIndex, aValue) {
      var Result = 0;
      var S1 = "";
      var S2 = "";
      S1 = "" + this.GetFieldValue(RowIndex);
      S2 = "" + aValue;
      if (pas.DB.TLocateOption.loPartialKey in this.FOptions) S1 = pas.System.Copy(S1,1,S2.length);
      if (pas.DB.TLocateOption.loCaseInsensitive in this.FOptions) {
        Result = pas.SysUtils.CompareText(S1,S2)}
       else Result = pas.SysUtils.CompareStr(S1,S2);
      return Result;
    };
  });
  rtl.createClass(this,"TNativeIntFieldComparer",this.TFieldComparer,function () {
    this.Compare = function (RowIndex, aValue) {
      var Result = 0;
      var I1 = 0;
      var I2 = 0;
      I1 = rtl.trunc(this.GetFieldValue(RowIndex));
      I2 = rtl.trunc(aValue);
      Result = I1 - I2;
      return Result;
    };
  });
  rtl.createClass(this,"TBooleanFieldComparer",this.TFieldComparer,function () {
    this.Compare = function (RowIndex, aValue) {
      var Result = 0;
      var B1 = false;
      var B2 = false;
      B1 = !(this.GetFieldValue(RowIndex) == false);
      B2 = !(aValue == false);
      Result = (B1 + 0) - (B2 + 0);
      return Result;
    };
  });
  rtl.createClass(this,"TDateTimeFieldComparer",this.TFieldComparer,function () {
    this.Compare = function (RowIndex, aValue) {
      var $Self = this;
      var Result = 0;
      var D1 = 0.0;
      var D2 = 0.0;
      function ToDate(v) {
        var Result = 0.0;
        if (pas.JS.isDate(v)) {
          Result = pas.SysUtils.JSDateToDateTime(v)}
         else Result = $Self.FDataset.ConvertDateTimeField("" + v,$Self.FField);
        return Result;
      };
      D1 = ToDate(this.GetFieldValue(RowIndex));
      D2 = ToDate(aValue);
      Result = Math.round(D1 - D2);
      return Result;
    };
  });
  rtl.createClass(this,"TFloatFieldComparer",this.TFieldComparer,function () {
    this.Compare = function (RowIndex, aValue) {
      var Result = 0;
      var D1 = 0.0;
      var D2 = 0.0;
      D1 = rtl.getNumber(this.GetFieldValue(RowIndex));
      D2 = rtl.getNumber(aValue);
      Result = Math.round(D1 - D2);
      return Result;
    };
  });
  rtl.createClass(this,"TRecordComparer",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FDataset = null;
      this.FIndexBased = false;
      this.FItems = [];
      this.FOptions = {};
      this.FValues = [];
    };
    this.$final = function () {
      this.FDataset = undefined;
      this.FItems = undefined;
      this.FOptions = undefined;
      this.FValues = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetFieldComparer = function (Index) {
      var Result = null;
      if ((Index < 0) || (Index >= rtl.length(this.FItems))) throw pas.Classes.EListError.$create("CreateFmt",["Index out of bounds: %d not in [%d,%d]",pas.System.VarRecs(0,Index,0,0,19,rtl.length(this.FItems) - 1)]);
      Result = this.GetFieldComparer(Index);
      return Result;
    };
    this.ConstructItems = function (aFields) {
      var L = null;
      var FCC = null;
      var F = null;
      var I = 0;
      L = pas.Classes.TFPList.$create("Create");
      try {
        this.FDataset.GetFieldList$1(L,aFields);
        if (!this.FIndexBased && (L.FCount !== rtl.length(this.FValues))) throw pas.DB.EDatabaseError.$create("CreateFmt",["Array of values has different length (%d) from array of fields (%d)",pas.System.VarRecs(19,rtl.length(this.FValues),0,L.FCount)]);
        this.FItems = rtl.arraySetLength(this.FItems,null,L.FCount);
        for (var $l = 0, $end = L.FCount - 1; $l <= $end; $l++) {
          I = $l;
          F = rtl.getObject(L.Get(I));
          FCC = this.DataTypeToComparerClass(F.FDataType);
          if (FCC === null) throw pas.DB.EDatabaseError.$create("CreateFmt",["Cannot locate on field %s of type %s)",pas.System.VarRecs(18,F.FFieldName,18,pas.TypInfo.GetEnumName(pas.DB.$rtti["TFieldType"],F.FDataType))]);
          if (this.FIndexBased) {
            this.FItems[I] = FCC.$create("Create$1",[this.FDataset,F,null,rtl.refSet(this.FOptions)])}
           else this.FItems[I] = FCC.$create("Create$1",[this.FDataset,F,this.FValues[I],rtl.refSet(this.FOptions)]);
        };
      } finally {
        L = rtl.freeLoc(L);
      };
    };
    this.DataTypeToComparerClass = function (aFieldType) {
      var Result = null;
      var $tmp = aFieldType;
      if (($tmp === pas.DB.TFieldType.ftMemo) || ($tmp === pas.DB.TFieldType.ftFixedChar) || ($tmp === pas.DB.TFieldType.ftString)) {
        Result = $mod.TStringFieldComparer}
       else if (($tmp === pas.DB.TFieldType.ftAutoInc) || ($tmp === pas.DB.TFieldType.ftInteger) || ($tmp === pas.DB.TFieldType.ftLargeint)) {
        Result = $mod.TNativeIntFieldComparer}
       else if ($tmp === pas.DB.TFieldType.ftBoolean) {
        Result = $mod.TBooleanFieldComparer}
       else if ($tmp === pas.DB.TFieldType.ftFloat) {
        Result = $mod.TFloatFieldComparer}
       else if (($tmp === pas.DB.TFieldType.ftDate) || ($tmp === pas.DB.TFieldType.ftTime) || ($tmp === pas.DB.TFieldType.ftDateTime)) {
        Result = $mod.TDateTimeFieldComparer}
       else {
        Result = null;
      };
      return Result;
    };
    this.Compare = function (aRowindex) {
      var Result = 0;
      var I = 0;
      var L = 0;
      Result = 0;
      I = 0;
      L = rtl.length(this.FItems);
      while ((Result === 0) && (I < L)) {
        Result = this.FItems[I].Compare$1(aRowindex);
        I += 1;
      };
      return Result;
    };
    this.CompareRows = function (aRowindex1, aRowIndex2) {
      var Result = 0;
      var I = 0;
      var L = 0;
      Result = 0;
      I = 0;
      L = rtl.length(this.FItems);
      while ((Result === 0) && (I < L)) {
        Result = this.FItems[I].CompareRows(aRowindex1,aRowIndex2);
        if ((Result !== 0) && this.FItems[I].FDesc) Result = -Result;
        I += 1;
      };
      return Result;
    };
    this.updateFromIndex = function (aIndex) {
      var L = null;
      var I = 0;
      L = pas.Classes.TFPList.$create("Create");
      try {
        if (aIndex.FCaseinsFields !== "") {
          this.FDataset.GetFieldList$1(L,aIndex.FCaseinsFields);
          for (var $l = 0, $end = rtl.length(this.FItems) - 1; $l <= $end; $l++) {
            I = $l;
            if (L.IndexOf(this.FItems[I].FField) !== -1) this.FItems[I].FOptions = rtl.unionSet(this.FItems[I].FOptions,rtl.createSet(pas.DB.TLocateOption.loCaseInsensitive));
          };
        };
        L.Clear();
        this.FDataset.GetFieldList$1(L,aIndex.FDescFields);
        for (var $l1 = 0, $end1 = rtl.length(this.FItems) - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          this.FItems[I].FDesc = (pas.DB.TIndexOption.ixDescending in aIndex.FOptions) || (L.IndexOf(this.FItems[I].FField) !== -1);
        };
      } finally {
        L = rtl.freeLoc(L);
      };
    };
    this.Create$1 = function (aDataset, aFields, aValues, aOptions) {
      this.FDataset = aDataset;
      if (rtl.isArray(aValues)) {
        this.FValues = aValues}
       else {
        this.FValues = rtl.arraySetLength(this.FValues,undefined,1);
        this.FValues[0] = aValues;
      };
      this.FOptions = rtl.refSet(aOptions);
      this.ConstructItems(aFields);
      return this;
    };
    this.Create$2 = function (aDataset, aIndex) {
      this.FDataset = aDataset;
      this.FIndexBased = true;
      if (pas.DB.TIndexOption.ixCaseInsensitive in aIndex.FOptions) this.FOptions = rtl.createSet(pas.DB.TLocateOption.loCaseInsensitive);
      this.ConstructItems(aIndex.FFields);
      this.updateFromIndex(aIndex);
      return this;
    };
    this.Destroy = function () {
      var I = 0;
      for (var $l = 0, $end = rtl.length(this.FItems) - 1; $l <= $end; $l++) {
        I = $l;
        rtl.free(this.FItems,I);
      };
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TRecordComparer.FItems$a",{eltype: $mod.$rtti["TFieldComparer"]});
  });
  this.$rtti.$ClassRef("TRecordComparerClass",{instancetype: this.$rtti["TRecordComparer"]});
  rtl.createClass(this,"TJSONIndex",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
      this.FRows = null;
      this.FDataset = null;
    };
    this.$final = function () {
      this.FList = undefined;
      this.FRows = undefined;
      this.FDataset = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetRecordIndex = function (aListIndex) {
      var Result = 0;
      if (pas.JS.isUndefined(this.FList[aListIndex])) {
        Result = -1}
       else Result = rtl.trunc(this.FList[aListIndex]);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FList.length;
      return Result;
    };
    this.ClearIndex = function () {
      this.FList.length = 0;
    };
    this.Create$1 = function (aDataset, aRows) {
      this.FRows = aRows;
      this.FList = new Array(this.FRows.length);
      this.FDataset = aDataset;
      this.CreateIndex();
      return this;
    };
    this.Delete = function (aListIndex) {
      var Result = 0;
      var a = null;
      a = this.FList.splice(aListIndex,1);
      if (a.length > 0) {
        Result = rtl.trunc(a[0])}
       else Result = -1;
      return Result;
    };
    this.DeleteByRowIndex = function (aRowIndex) {
      var Result = 0;
      Result = this.IndexOfRow(aRowIndex);
      if (Result !== -1) this.FList.splice(Result,1);
      return Result;
    };
    this.Insert = function (aCurrentIndex, aRecordIndex) {
      var Result = 0;
      Result = this.Append(aRecordIndex);
      return Result;
    };
    this.IndexOfRow = function (aRowIndex) {
      var Result = 0;
      Result = this.FList.indexOf(aRowIndex);
      return Result;
    };
  });
  rtl.createClass(this,"TDefaultJSONIndex",this.TJSONIndex,function () {
    this.CreateIndex = function () {
      var I = 0;
      for (var $l = 0, $end = this.FRows.length - 1; $l <= $end; $l++) {
        I = $l;
        this.FList[I] = I;
      };
    };
    this.AppendToIndex = function () {
      var I = 0;
      var L = 0;
      L = this.FList.length;
      this.FList.length = this.FRows.length;
      for (var $l = L, $end = this.FRows.length - 1; $l <= $end; $l++) {
        I = $l;
        this.FList[I] = I;
      };
    };
    this.Append = function (aRecordIndex) {
      var Result = 0;
      Result = this.FList.push(aRecordIndex) - 1;
      return Result;
    };
    this.Insert = function (aCurrentIndex, aRecordIndex) {
      var Result = 0;
      this.FList.splice(aCurrentIndex,0,aRecordIndex);
      Result = aCurrentIndex;
      return Result;
    };
    this.FindRecord = function (aRecordIndex) {
      var Result = 0;
      Result = this.FList.indexOf(aRecordIndex);
      return Result;
    };
    this.Update = function (aRecordIndex) {
      var Result = 0;
      Result = aRecordIndex;
      return Result;
    };
  });
  rtl.createClass(this,"TSortedJSONIndex",this.TJSONIndex,function () {
    this.$init = function () {
      $mod.TJSONIndex.$init.call(this);
      this.FComparer = null;
      this.FUnique = false;
    };
    this.$final = function () {
      this.FComparer = undefined;
      $mod.TJSONIndex.$final.call(this);
    };
    this.FindPos = function (aRecordIndex) {
      var Result = 0;
      var L = 0;
      var R = 0;
      var I = 0;
      var CompareRes = 0;
      if (!(this.FComparer != null)) return Result;
      L = 0;
      R = this.GetCount() - 1;
      while (L <= R) {
        I = L + rtl.trunc((R - L) / 2);
        CompareRes = this.FComparer.CompareRows(aRecordIndex,rtl.trunc(this.FList[I]));
        if (CompareRes > 0) {
          L = I + 1}
         else {
          R = I - 1;
          if (CompareRes === 0) {
            if (this.FUnique) L = I;
          };
        };
      };
      Result = L;
      return Result;
    };
    this.MergeSort = function (aList) {
      var Result = null;
      var temp = null;
      var l = 0;
      var p = 0;
      var q = 0;
      var e = 0;
      var tail = 0;
      var insize = 0;
      var nmerges = 0;
      var psize = 0;
      var qsize = 0;
      if (aList === null) return null;
      l = aList.length;
      Result = new Array(l);
      if (l === 0) return Result;
      insize = 1;
      do {
        p = 0;
        tail = 0;
        nmerges = 0;
        while (p < l) {
          nmerges += 1;
          psize = l - p;
          if (insize < psize) psize = insize;
          q = p + psize;
          qsize = insize;
          while ((psize > 0) || ((qsize > 0) && (q < l))) {
            if (psize === 0) {
              e = q;
              q += 1;
              qsize -= 1;
            } else if ((qsize === 0) || (q >= l)) {
              e = p;
              p += 1;
              psize -= 1;
            } else if (this.FComparer.CompareRows(rtl.trunc(aList[p]),rtl.trunc(aList[q])) <= 0) {
              e = p;
              p += 1;
              psize -= 1;
            } else {
              e = q;
              q += 1;
              qsize -= 1;
            };
            Result[tail] = aList[e];
            tail += 1;
          };
          p = q;
        };
        if (nmerges <= 1) return Result;
        insize = insize * 2;
        temp = Result;
        Result = aList;
        aList = temp;
      } while (!false);
      return Result;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FComparer;
        }, set: function (v) {
          this.p.FComparer = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
    this.CreateComparer = function (aIndex) {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FComparer;
        }, set: function (v) {
          this.p.FComparer = v;
        }});
      this.FComparer = $mod.TRecordComparer.$create("Create$2",[this.FDataset,aIndex]);
    };
    this.CreateIndex = function () {
      var Lst = [];
      var I = 0;
      var SrcLen = 0;
      var Destlen = 0;
      if (this.FComparer === null) return;
      SrcLen = this.FRows.length;
      Lst = rtl.arraySetLength(Lst,0,SrcLen);
      Destlen = 0;
      for (var $l = 0, $end = SrcLen - 1; $l <= $end; $l++) {
        I = $l;
        if (!pas.JS.isUndefined(this.FRows[I])) {
          Lst[Destlen] = I;
          Destlen += 1;
        };
      };
      Lst = rtl.arraySetLength(Lst,0,Destlen);
      this.FList = this.MergeSort(Lst);
    };
    this.AppendToIndex = function () {
      this.CreateIndex();
    };
    this.Append = function (aRecordIndex) {
      var Result = 0;
      Result = this.FindPos(aRecordIndex);
      this.FList.splice(Result,0,aRecordIndex);
      return Result;
    };
    this.FindRecord = function (aRecordIndex) {
      var Result = 0;
      Result = this.FList.indexOf(aRecordIndex);
      return Result;
    };
    this.Update = function (aRecordIndex) {
      var Result = 0;
      var aCurrentIndex = 0;
      aCurrentIndex = this.FindRecord(aRecordIndex);
      Result = this.FindPos(aRecordIndex);
      if (Result !== aCurrentIndex) this.FList.splice(Result,0,this.FList.splice(aCurrentIndex,1)[0]);
      return Result;
    };
  });
  rtl.createClass(this,"TJSONIndexDef",pas.DB.TIndexDef,function () {
    this.$init = function () {
      pas.DB.TIndexDef.$init.call(this);
      this.FIndex = null;
    };
    this.$final = function () {
      this.FIndex = undefined;
      pas.DB.TIndexDef.$final.call(this);
    };
    this.ClearIndex = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FIndex;
        }, set: function (v) {
          this.p.FIndex = v;
        }});
    };
    this.BuildIndex = function (aDataset) {
      if (this.FIndex === null) {
        this.FIndex = $mod.TSortedJSONIndex.$create("Create$1",[aDataset,aDataset.FRows])}
       else this.FIndex.ClearIndex();
      this.FIndex.CreateComparer(this);
      this.FIndex.CreateIndex();
    };
  });
  rtl.createClass(this,"TJSONIndexDefs",pas.DB.TIndexDefs,function () {
    this.GetD = function (aIndex) {
      var Result = null;
      Result = rtl.as(this.GetItem$1(aIndex),$mod.TJSONIndexDef);
      return Result;
    };
    this.SetD = function (aIndex, AValue) {
      this.SetItem$1(aIndex,AValue);
    };
    this.AddJSONIndexDef = function () {
      var Result = null;
      Result = rtl.as(this.Add(),$mod.TJSONIndexDef);
      return Result;
    };
  });
  this.TBlobFormat = {"0": "bfHex", bfHex: 0, "1": "bfBase64", bfBase64: 1, "2": "bfBytes", bfBytes: 2, "3": "bfCustom", bfCustom: 3};
  this.$rtti.$Enum("TBlobFormat",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBlobFormat});
  this.$rtti.$Set("TBlobFormats",{comptype: this.$rtti["TBlobFormat"]});
  this.$rtti.$MethodVar("TOnDecodeBlobBytesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.DB.$rtti["TDataSet"]],["aValue",rtl.jsvalue],["aData",pas.SysUtils.$rtti["TBytes"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TOnEncodeBlobBytesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.DB.$rtti["TDataSet"]],["aData",pas.SysUtils.$rtti["TBytes"]],["aValue",rtl.jsvalue,1]]), methodkind: 0});
  rtl.createClass(this,"TBaseJSONDataSet",pas.DB.TDataSet,function () {
    this.$init = function () {
      pas.DB.TDataSet.$init.call(this);
      this.FActiveIndex = "";
      this.FBlobFormat = 0;
      this.FIndexes = null;
      this.FMUS = false;
      this.FOnDecodeBlobValue = null;
      this.FOnEncodeBlobValue = null;
      this.FOwnsData = false;
      this.FDefaultIndex = null;
      this.FCurrentIndex = null;
      this.FCurrent = 0;
      this.FMetaData = null;
      this.FRows = null;
      this.FDeletedRows = null;
      this.FFieldMapper = null;
      this.FEditIdx = 0;
      this.FEditRow = undefined;
      this.FFilterRow = undefined;
      this.FUseDateTimeFormatFields = false;
      this.FRowType = 0;
      this.FFilterExpression = null;
    };
    this.$final = function () {
      this.FIndexes = undefined;
      this.FOnDecodeBlobValue = undefined;
      this.FOnEncodeBlobValue = undefined;
      this.FDefaultIndex = undefined;
      this.FCurrentIndex = undefined;
      this.FMetaData = undefined;
      this.FRows = undefined;
      this.FDeletedRows = undefined;
      this.FFieldMapper = undefined;
      this.FFilterExpression = undefined;
      pas.DB.TDataSet.$final.call(this);
    };
    this.GetFilterField = function (AName) {
      var Result = pas.fpexprpars.TFPExpressionResult.$new();
      var F = null;
      var C = 0;
      F = this.FieldByName(AName);
      Result.ResultType = this.FieldTypeToExpressionType(F.FDataType);
      var $tmp = Result.ResultType;
      if ($tmp === pas.fpexprpars.TResultType.rtBoolean) {
        Result.resValue = F.GetAsBoolean()}
       else if ($tmp === pas.fpexprpars.TResultType.rtInteger) {
        Result.resValue = F.GetAsLargeInt()}
       else if ($tmp === pas.fpexprpars.TResultType.rtFloat) {
        Result.resValue = F.GetAsFloat()}
       else if ($tmp === pas.fpexprpars.TResultType.rtDateTime) {
        Result.resValue = F.GetAsDateTime()}
       else if ($tmp === pas.fpexprpars.TResultType.rtString) {
        Result.resValue = F.GetAsString()}
       else if ($tmp === pas.fpexprpars.TResultType.rtCurrency) {
        C = F.GetAsFloat() * 10000;
        Result.resValue = C / 10000;
      };
      return Result;
    };
    this.SetActiveIndex = function (AValue) {
      if (this.FActiveIndex === AValue) return;
      this.FActiveIndex = AValue;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      this.ActivateIndex(this.GetActive());
    };
    this.SetIndexes = function (AValue) {
      if (this.FIndexes === AValue) return;
      this.FIndexes.Assign(AValue);
      if (this.GetActive()) this.BuildIndexes();
    };
    this.SetMetaData = function (AValue) {
      this.CheckInactive();
      this.FMetaData = AValue;
    };
    this.SetRows = function (AValue) {
      if (AValue === this.FRows) return;
      this.CheckInactive();
      this.FRows = null;
      this.AddToRows(AValue);
    };
    this.SetRowType = function (AValue) {
      if (this.FRowType === AValue) return;
      this.CheckInactive();
      this.FRowType = AValue;
    };
    this.RemoveCalcFields = function (Buf) {
      var i = 0;
      for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FFieldList.GetField(i).FFieldKind in rtl.createSet(pas.DB.TFieldKind.fkCalculated,pas.DB.TFieldKind.fkInternalCalc,pas.DB.TFieldKind.fkLookup)) this.FFieldMapper.RemoveField(this.FFieldList.GetField(i).FFieldName,this.FFieldList.GetField(i).GetIndex(),Buf);
      };
    };
    this.ActivateIndex = function (Build) {
      var Idx = null;
      if (this.FActiveIndex !== "") {
        Idx = rtl.as(this.FIndexes.Find$1(this.FActiveIndex),$mod.TJSONIndexDef)}
       else Idx = null;
      if (Idx === null) {
        this.FCurrentIndex = this.FDefaultIndex}
       else {
        if ((Idx.FIndex === null) && Build) Idx.BuildIndex(this);
        this.FCurrentIndex = Idx.FIndex;
      };
      if (this.GetActive()) this.Resync(rtl.createSet(pas.DB.TResyncMode$a.rmCenter));
    };
    this.FieldTypeToExpressionType = function (aDataType) {
      var Result = 0;
      var $tmp = aDataType;
      if (($tmp === pas.DB.TFieldType.ftMemo) || ($tmp === pas.DB.TFieldType.ftFixedChar) || ($tmp === pas.DB.TFieldType.ftString)) {
        Result = pas.fpexprpars.TResultType.rtString}
       else if (($tmp === pas.DB.TFieldType.ftInteger) || ($tmp === pas.DB.TFieldType.ftAutoInc) || ($tmp === pas.DB.TFieldType.ftLargeint)) {
        Result = pas.fpexprpars.TResultType.rtInteger}
       else if ($tmp === pas.DB.TFieldType.ftBoolean) {
        Result = pas.fpexprpars.TResultType.rtBoolean}
       else if ($tmp === pas.DB.TFieldType.ftFloat) {
        Result = pas.fpexprpars.TResultType.rtFloat}
       else if (($tmp === pas.DB.TFieldType.ftDate) || ($tmp === pas.DB.TFieldType.ftTime) || ($tmp === pas.DB.TFieldType.ftDateTime)) {
        Result = pas.fpexprpars.TResultType.rtDateTime}
       else {
        pas.DB.DatabaseErrorFmt$1("Fields of type %s are not supported in filter expressions.",pas.System.VarRecs(18,pas.DB.FieldTypeNames[aDataType]),this);
      };
      return Result;
    };
    this.GetFilterIsNull = function (Args) {
      var Result = pas.fpexprpars.TFPExpressionResult.$new();
      Result.ResultType = pas.fpexprpars.TResultType.rtBoolean;
      Result.resValue = this.FieldByName("" + Args[0].resValue).GetIsNull();
      return Result;
    };
    this.FilterExpressionClass = function () {
      var Result = null;
      Result = pas.fpexprpars.TFPExpressionParser;
      return Result;
    };
    this.CreateFilterExpression = function () {
      var Result = null;
      var I = 0;
      Result = this.FilterExpressionClass().$create("Create$1",[this]);
      Result.SetAllowLike(true);
      for (var $l = 0, $end = this.FFieldList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (!(this.FFieldList.GetField(I).FDataType in rtl.createSet(pas.DB.TFieldType.ftBlob,pas.DB.TFieldType.ftMemo))) Result.FIdentifiers.AddVariable(this.FFieldList.GetField(I).FFieldName,this.FieldTypeToExpressionType(this.FFieldList.GetField(I).FDataType),rtl.createCallback(this,"GetFilterField"));
      };
      Result.FIdentifiers.AddFunction("IsNull","B","S",rtl.createCallback(this,"GetFilterIsNull"));
      Result.SetExpression(this.FFilterText);
      return Result;
    };
    this.DoFilterRecord = function () {
      var Result = false;
      var DS = 0;
      Result = true;
      DS = this.SetTempState(pas.DB.TDataSetState.dsFilter);
      try {
        if (this.FOnFilterRecord != null) {
          this.FOnFilterRecord(this,{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }});
          if (!Result) return Result;
        };
        if (!this.FFiltered || (this.FFilterText === "")) return Result;
        if (this.FFilterExpression === null) this.FFilterExpression = this.CreateFilterExpression();
        Result = this.FFilterExpression.GetAsBoolean();
      } finally {
        this.RestoreState(DS);
      };
      return Result;
    };
    this.CreateIndexDefs = function () {
      var Result = null;
      Result = $mod.TJSONIndexDefs.$create("create$3",[this,this,$mod.TJSONIndexDef]);
      return Result;
    };
    this.RecordComparerClass = function () {
      var Result = null;
      Result = $mod.TRecordComparer;
      return Result;
    };
    this.LocateRecordIndex = function (KeyFields, KeyValues, Options) {
      var Result = 0;
      var Comp = null;
      var RI = 0;
      var I = 0;
      Result = -1;
      Comp = this.RecordComparerClass().$create("Create$1",[this,KeyFields,KeyValues,rtl.refSet(Options)]);
      try {
        if (pas.DB.TLocateOption.loFromCurrent in Options) {
          I = this.FCurrent}
         else I = 0;
        RI = this.FCurrentIndex.GetRecordIndex(I);
        while ((Result === -1) && (RI !== -1)) {
          if (Comp.Compare(RI) === 0) Result = RI;
          I += 1;
          RI = this.FCurrentIndex.GetRecordIndex(I);
        };
      } finally {
        Comp = rtl.freeLoc(Comp);
      };
      return Result;
    };
    this.AllocRecordBuffer = function () {
      var Result = pas.DB.TDataRecord.$new();
      Result.data = new Object();
      Result.bookmark = null;
      Result.state = pas.DB.TRecordState.rsNew;
      return Result;
    };
    this.FreeRecordBuffer = function (Buffer) {
      Buffer.data = null;
      Buffer.bookmark = null;
      Buffer.state = pas.DB.TRecordState.rsNew;
    };
    this.InternalInitRecord = function (Buffer) {
      Buffer.data = this.FFieldMapper.CreateRow();
      Buffer.bookmark = null;
      Buffer.state = pas.DB.TRecordState.rsNew;
    };
    this.GetRecord = function (Buffer, GetMode, DoCheck) {
      var Result = 0;
      var BkmIdx = 0;
      var recordAccepted = false;
      Result = pas.DB.TGetResult.grOK;
      do {
        recordAccepted = true;
        var $tmp = GetMode;
        if ($tmp === pas.DB.TGetMode.gmNext) {
          if (this.FCurrent < (this.FCurrentIndex.GetCount() - 1)) {
            this.FCurrent += 1}
           else Result = pas.DB.TGetResult.grEOF}
         else if ($tmp === pas.DB.TGetMode.gmPrior) {
          if (this.FCurrent > 0) {
            this.FCurrent -= 1}
           else Result = pas.DB.TGetResult.grBOF}
         else if ($tmp === pas.DB.TGetMode.gmCurrent) if ((this.FCurrent < 0) || (this.FCurrent >= this.FCurrentIndex.GetCount())) Result = pas.DB.TGetResult.grEOF;
        if (Result === pas.DB.TGetResult.grOK) {
          BkmIdx = this.FCurrentIndex.GetRecordIndex(this.FCurrent);
          Buffer.data = this.FRows[BkmIdx];
          Buffer.bookmarkFlag = pas.DB.TBookmarkFlag.bfCurrent;
          Buffer.bookmark = BkmIdx;
          this.GetCalcFields(Buffer);
          if (this.FFiltered) {
            this.FFilterRow = Buffer.data;
            recordAccepted = this.DoFilterRecord();
            if (!recordAccepted && (GetMode === pas.DB.TGetMode.gmCurrent)) {
              recordAccepted = true;
              Result = pas.DB.TGetResult.grEOF;
            };
          };
        };
      } while (!recordAccepted);
      return Result;
    };
    this.GetRecordSize = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.AddToRows = function (AValue) {
      if (this.FRows === null) {
        this.FRows = AValue}
       else {
        this.FRows = this.FRows.concat(AValue);
        this.AppendToIndexes();
      };
    };
    this.InternalClose = function () {
      this.BindFields(false);
      if (this.FDefaultFields) this.DestroyFields();
      this.FreeData();
    };
    this.InternalDelete = function () {
      var I = 0;
      var RowIdx = 0;
      var aIndex = null;
      RowIdx = this.FCurrentIndex.Delete(this.FCurrent);
      if (RowIdx !== -1) {
        for (var $l = 0, $end = this.FIndexes.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          aIndex = this.FIndexes.GetD(I).FIndex;
          if (aIndex !== this.FCurrentIndex) aIndex.DeleteByRowIndex(RowIdx);
        };
        if (!(this.FDeletedRows != null)) {
          this.FDeletedRows = new Array(this.FRows[RowIdx])}
         else this.FDeletedRows.push(this.FRows[RowIdx]);
        this.FRows[RowIdx] = undefined;
      };
    };
    this.InternalFirst = function () {
      this.FCurrent = -1;
    };
    this.InternalLast = function () {
      this.FCurrent = this.FCurrentIndex.GetCount();
    };
    this.InternalOpen = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFieldMapper;
        }, set: function (v) {
          this.p.FFieldMapper = v;
        }});
      this.FFieldMapper = this.CreateFieldMapper();
      if (this.FRows === null) {
        this.FRows = new Array();
        this.FOwnsData = true;
      };
      this.CreateIndexes();
      this.InternalInitFieldDefs();
      if (this.FDefaultFields) this.CreateFields();
      this.BindFields(true);
      this.InitDateTimeFields();
      if (this.FActiveIndex !== "") this.ActivateIndex(true);
      this.FCurrent = -1;
    };
    this.InternalPost = function () {
      var I = 0;
      var NewIdx = 0;
      var NewCurrent = 0;
      var Idx = 0;
      var B = pas.DB.TBookmark.$new();
      pas.DB.TDataSet.InternalPost.call(this);
      NewCurrent = -1;
      this.GetBookmarkData(pas.DB.TDataRecord.$clone(this.ActiveBuffer()),B);
      if (this.FState === pas.DB.TDataSetState.dsInsert) {
        Idx = this.FRows.push(this.FEditRow) - 1;
        if (this.GetBookmarkFlag(pas.DB.TDataRecord.$clone(this.ActiveBuffer())) === pas.DB.TBookmarkFlag.bfEOF) {
          this.FDefaultIndex.Append(Idx);
          for (var $l = 0, $end = this.FIndexes.GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            if (this.FIndexes.GetD(I).FIndex != null) {
              NewIdx = this.FIndexes.GetD(I).FIndex.Append(Idx);
              if (this.FIndexes.GetD(I).FIndex === this.FCurrentIndex) NewCurrent = NewIdx;
            };
          };
        } else {
          this.FCurrent = this.FDefaultIndex.Insert(this.FCurrent,Idx);
          for (var $l1 = 0, $end1 = this.FIndexes.GetCount() - 1; $l1 <= $end1; $l1++) {
            I = $l1;
            if (this.FIndexes.GetD(I).FIndex != null) {
              NewIdx = this.FIndexes.GetD(I).FIndex.Append(Idx);
              if (this.FIndexes.GetD(I).FIndex === this.FCurrentIndex) NewCurrent = NewIdx;
            };
          };
        };
      } else {
        if (this.FEditIdx === -1) pas.DB.DatabaseErrorFmt("Failed to retrieve record index for record %d",pas.System.VarRecs(0,this.FCurrent));
        Idx = this.FEditIdx;
        this.FRows[Idx] = this.FEditRow;
        this.FDefaultIndex.Update(Idx);
        for (var $l2 = 0, $end2 = this.FIndexes.GetCount() - 1; $l2 <= $end2; $l2++) {
          I = $l2;
          NewIdx = this.FCurrentIndex.Update(Idx);
          if (this.FIndexes.GetD(I).FIndex != null) if (this.FIndexes.GetD(I).FIndex === this.FCurrentIndex) NewCurrent = NewIdx;
        };
      };
      if (NewCurrent !== -1) this.FCurrent = NewCurrent;
      this.FEditIdx = -1;
      this.FEditRow = null;
    };
    this.InternalInsert = function () {
      var I = 0;
      var D = null;
      this.FEditRow = this.ActiveBuffer().data;
      for (var $l = 0, $end = this.FFieldDefs.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        D = this.FFieldDefs.GetItem$1(I);
        this.FFieldMapper.SetJSONDataForField(D.FName,D.GetIndex(),this.FEditRow,null);
      };
    };
    this.InternalEdit = function () {
      this.FEditIdx = this.FCurrentIndex.GetRecordIndex(this.FCurrent);
      if (!pas.JS.isUndefined(this.FRows[this.FEditIdx])) {
        this.FEditRow = this.FFieldMapper.CopyRow(this.FRows[this.FEditIdx]);
      } else this.FEditRow = this.FFieldMapper.CreateRow();
    };
    this.InternalCancel = function () {
      this.FEditIdx = -1;
      this.FEditRow = null;
    };
    this.InternalInitFieldDefs = function () {
      if (this.FMetaData != null) this.MetaDataToFieldDefs();
      if (this.FFieldDefs.GetCount() === 0) throw $mod.EJSONDataset.$create("Create$1",["No fields found"]);
    };
    this.InternalSetToRecord = function (Buffer) {
      this.FCurrent = this.FCurrentIndex.FindRecord(rtl.trunc(Buffer.bookmark));
    };
    this.SetFilterText = function (Value) {
      pas.DB.TDataSet.SetFilterText.call(this,Value);
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFilterExpression;
        }, set: function (v) {
          this.p.FFilterExpression = v;
        }});
      if (this.GetActive()) this.Resync(rtl.createSet(pas.DB.TResyncMode$a.rmCenter));
    };
    this.SetFiltered = function (Value) {
      pas.DB.TDataSet.SetFiltered.call(this,Value);
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFilterExpression;
        }, set: function (v) {
          this.p.FFilterExpression = v;
        }});
      if (this.GetActive()) this.Resync(rtl.createSet(pas.DB.TResyncMode$a.rmCenter));
    };
    this.GetFieldClass = function (FieldType) {
      var Result = null;
      if (this.FUseDateTimeFormatFields && (FieldType in rtl.createSet(pas.DB.TFieldType.ftDate,pas.DB.TFieldType.ftDateTime,pas.DB.TFieldType.ftTime))) {
        var $tmp = FieldType;
        if ($tmp === pas.DB.TFieldType.ftDate) {
          Result = $mod.TJSONDateField}
         else if ($tmp === pas.DB.TFieldType.ftDateTime) {
          Result = $mod.TJSONDateTimeField}
         else if ($tmp === pas.DB.TFieldType.ftTime) Result = $mod.TJSONTimeField;
      } else Result = pas.DB.TDataSet.GetFieldClass.call(this,FieldType);
      return Result;
    };
    this.GetApplyUpdateData = function (Buffer) {
      var Result = undefined;
      Result = this.FFieldMapper.CopyRow(Buffer.data);
      this.RemoveCalcFields(Result);
      return Result;
    };
    this.IsCursorOpen = function () {
      var Result = false;
      Result = this.FDefaultIndex != null;
      return Result;
    };
    this.GetBookmarkData = function (Buffer, Data) {
      Data.Data = Buffer.bookmark;
    };
    this.GetBookmarkFlag = function (Buffer) {
      var Result = 0;
      Result = Buffer.bookmarkFlag;
      return Result;
    };
    this.InternalGotoBookmark = function (ABookmark) {
      if (rtl.isNumber(ABookmark.Data)) this.FCurrent = this.FCurrentIndex.FindRecord(rtl.trunc(ABookmark.Data));
    };
    this.SetBookmarkFlag = function (Buffer, Value) {
      Buffer.bookmarkFlag = Value;
    };
    this.SetBookmarkData = function (Buffer, Data) {
      Buffer.bookmark = Data.Data;
    };
    this.GetRecordCount = function () {
      var Result = 0;
      if (this.FCurrentIndex != null) {
        Result = this.FCurrentIndex.GetCount()}
       else Result = 0;
      return Result;
    };
    this.SetRecNo = function (Value) {
      this.CheckBrowseMode();
      this.DoBeforeScroll();
      if ((Value < 1) || (Value > this.FCurrentIndex.GetCount())) throw $mod.EJSONDataset.$create("CreateFmt",["%s: SetRecNo: index %d out of range",pas.System.VarRecs(18,this.FName,0,Value)]);
      this.FCurrent = Value - 1;
      this.Resync({});
      this.DoAfterScroll();
    };
    this.GetRecNo = function () {
      var Result = 0;
      var bkmIdx = 0;
      bkmIdx = rtl.trunc(this.ActiveBuffer().bookmark);
      Result = this.FCurrentIndex.FindRecord(bkmIdx) + 1;
      return Result;
    };
    this.BuildIndexes = function () {
      var I = 0;
      for (var $l = 0, $end = this.FIndexes.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FIndexes.GetD(I).BuildIndex(this);
      };
    };
    this.FreeData = function () {
      var I = 0;
      if (this.FOwnsData) {
        this.FRows = null;
        this.FMetaData = null;
      };
      for (var $l = 0, $end = this.FIndexes.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FIndexes.GetD(I).ClearIndex();
      };
      this.FCurrentIndex = null;
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FDefaultIndex;
        }, set: function (v) {
          this.p.FDefaultIndex = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFieldMapper;
        }, set: function (v) {
          this.p.FFieldMapper = v;
        }});
      this.FCurrentIndex = null;
      this.FDeletedRows = null;
    };
    this.AppendToIndexes = function () {
      this.FDefaultIndex.AppendToIndex();
      if ((this.FCurrentIndex != null) && (this.FCurrentIndex !== this.FDefaultIndex)) this.FCurrentIndex.AppendToIndex();
    };
    this.Clone = function (Source) {
      if (Source.FFieldDefs.GetCount() > 0) {
        this.FFieldDefs.Assign$2(Source.FFieldDefs);
        this.CreateFields();
      } else {
        Source.InitFieldDefsFromfields();
        this.FFieldDefs.Assign$2(Source.FFieldDefs);
        this.CreateFields();
      };
      this.SetRows(Source.FRows);
    };
    this.CreateIndexes = function () {
      this.FDefaultIndex = $mod.TDefaultJSONIndex.$create("Create$1",[this,this.FRows]);
      this.AppendToIndexes();
      if (this.FCurrentIndex === null) this.FCurrentIndex = this.FDefaultIndex;
    };
    this.MetaDataToFieldDefs = function () {
    };
    this.InitDateTimeFields = function () {
    };
    this.ConvertDateTimeField = function (S, F) {
      var Result = 0.0;
      var Ptrn = "";
      Result = 0;
      Ptrn = "";
      var $tmp = F.FDataType;
      if ($tmp === pas.DB.TFieldType.ftDate) {
        if ($mod.TJSONDateField.isPrototypeOf(F)) Ptrn = rtl.as(F,$mod.TJSONDateField).FDateFormat}
       else if ($tmp === pas.DB.TFieldType.ftTime) {
        if ($mod.TJSONTimeField.isPrototypeOf(F)) Ptrn = rtl.as(F,$mod.TJSONTimeField).FTimeFormat}
       else if ($tmp === pas.DB.TFieldType.ftDateTime) if ($mod.TJSONDateTimeField.isPrototypeOf(F)) Ptrn = rtl.as(F,$mod.TJSONDateTimeField).FDateTimeFormat;
      if (Ptrn === "") {
        Result = this.$class.DefaultConvertToDateTime(F,S,true)}
       else Result = pas.DateUtils.ScanDateTime(Ptrn,S,1);
      return Result;
    };
    this.FormatDateTimeField = function (DT, F) {
      var Result = "";
      var Ptrn = "";
      Result = "";
      Ptrn = "";
      var $tmp = F.FDataType;
      if ($tmp === pas.DB.TFieldType.ftDate) {
        if ($mod.TJSONDateField.isPrototypeOf(F)) Ptrn = F.FDateFormat}
       else if ($tmp === pas.DB.TFieldType.ftTime) {
        if ($mod.TJSONTimeField.isPrototypeOf(F)) Ptrn = F.FTimeFormat}
       else if ($tmp === pas.DB.TFieldType.ftDateTime) if ($mod.TJSONDateTimeField.isPrototypeOf(F)) Ptrn = F.FDateTimeFormat;
      if (Ptrn === "") {
        Result = pas.DateUtils.DateTimeToRFC3339(DT)}
       else Result = pas.SysUtils.FormatDateTime(Ptrn,DT);
      return Result;
    };
    this.CreateFieldMapper = function () {
      var Result = null;
      if (this.FRowType === $mod.TJSONRowType.rtJSONArray) {
        Result = $mod.TJSONArrayFieldMapper.$create("Create")}
       else Result = $mod.TJSONObjectFieldMapper.$create("Create");
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.DB.TDataSet.Create$1.apply(this,arguments);
      this.FOwnsData = true;
      this.FUseDateTimeFormatFields = false;
      this.FEditIdx = -1;
      this.FIndexes = this.CreateIndexDefs();
      return this;
    };
    this.Destroy = function () {
      this.Close();
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFilterExpression;
        }, set: function (v) {
          this.p.FFilterExpression = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FIndexes;
        }, set: function (v) {
          this.p.FIndexes = v;
        }});
      this.FEditIdx = -1;
      pas.DB.TDataSet.Destroy.call(this);
    };
    this.BlobDataToBytes = function (aValue) {
      var Result = [];
      Result = [];
      var $tmp = this.FBlobFormat;
      if ($tmp === $mod.TBlobFormat.bfHex) {
        Result = this.$class.DefaultBlobDataToBytes(aValue)}
       else if ($tmp === $mod.TBlobFormat.bfBase64) {
        Result = pas.SysUtils.BytesOf(atob("" + aValue))}
       else if ($tmp === $mod.TBlobFormat.bfBytes) {
        Result = aValue}
       else if ($tmp === $mod.TBlobFormat.bfCustom) if (this.FOnDecodeBlobValue != null) this.FOnDecodeBlobValue(this,aValue,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.BytesToBlobData = function (aValue) {
      var Result = undefined;
      Result = "";
      var $tmp = this.FBlobFormat;
      if ($tmp === $mod.TBlobFormat.bfHex) {
        Result = this.$class.DefaultBytesToBlobData(rtl.arrayRef(aValue))}
       else if ($tmp === $mod.TBlobFormat.bfBase64) {
        Result = btoa(pas.SysUtils.StringOf(aValue));
      } else if ($tmp === $mod.TBlobFormat.bfBytes) {
        Result = aValue}
       else if ($tmp === $mod.TBlobFormat.bfCustom) if (this.FOnEncodeBlobValue != null) this.FOnEncodeBlobValue(this,rtl.arrayRef(aValue),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ConvertDateTimeToNative = function (aField, aValue) {
      var Result = undefined;
      if (isNaN(aValue)) {
        Result = null}
       else Result = this.FormatDateTimeField(aValue,aField);
      return Result;
    };
    this.Locate = function (KeyFields, KeyValues, Options) {
      var Result = false;
      var I = 0;
      var BM = pas.DB.TBookmark.$new();
      Result = pas.DB.TDataSet.Locate.apply(this,arguments);
      I = this.LocateRecordIndex(KeyFields,KeyValues,rtl.refSet(Options));
      Result = I !== -1;
      if (Result) {
        BM.Data = I;
        BM.Flag = pas.DB.TBookmarkFlag.bfCurrent;
        this.GotoBookmark(BM);
      };
      return Result;
    };
    this.Lookup = function (KeyFields, KeyValues, ResultFields) {
      var Result = undefined;
      var RI = 0;
      var I = 0;
      var l = null;
      var Vals = [];
      Result = null;
      l = pas.Classes.TFPList.$create("Create");
      try {
        this.GetFieldList$1(l,ResultFields);
        Result = pas.DB.TDataSet.Lookup.call(this,KeyFields,KeyValues,ResultFields);
        RI = this.LocateRecordIndex(KeyFields,KeyValues,{});
        if (RI !== -1) {
          Vals = rtl.arraySetLength(Vals,undefined,l.FCount);
          for (var $l = 0, $end = l.FCount - 1; $l <= $end; $l++) {
            I = $l;
            Vals[I] = this.FFieldMapper.GetJSONDataForField$1(rtl.getObject(l.Get(I)),this.FRows[RI]);
          };
          if (l.FCount === 1) {
            Result = Vals[I]}
           else Result = Vals;
        };
      } finally {
        l = rtl.freeLoc(l);
      };
      return Result;
    };
    this.GetFieldData$1 = function (Field, Buffer) {
      var Result = undefined;
      var R = undefined;
      if (this.FState in rtl.createSet(pas.DB.TDataSetState.dsCalcFields,pas.DB.TDataSetState.dsInternalCalc)) {
        R = this.FCalcBuffer.data}
       else if (this.FState === pas.DB.TDataSetState.dsFilter) {
        R = this.FFilterRow}
       else if (this.FEditIdx == Buffer.bookmark) {
        if (this.FState === pas.DB.TDataSetState.dsOldValue) {
          R = Buffer.data}
         else R = this.FEditRow;
      } else {
        if (this.FState === pas.DB.TDataSetState.dsOldValue) {
          return null}
         else R = Buffer.data;
      };
      Result = this.FFieldMapper.GetJSONDataForField$1(Field,R);
      if (pas.JS.isUndefined(Result)) Result = null;
      return Result;
    };
    this.SetFieldData$1 = function (Field, Buffer, AValue) {
      var R = undefined;
      if (this.FState in rtl.createSet(pas.DB.TDataSetState.dsCalcFields,pas.DB.TDataSetState.dsInternalCalc)) {
        R = this.FCalcBuffer.data}
       else R = this.FEditRow;
      this.FFieldMapper.SetJSONDataForField$1(Field,R,AValue);
      if (!(this.FState in rtl.createSet(pas.DB.TDataSetState.dsCalcFields,pas.DB.TDataSetState.dsInternalCalc,pas.DB.TDataSetState.dsFilter,pas.DB.TDataSetState.dsNewValue))) this.DataEvent(pas.DB.TDataEvent.deFieldChange,Field);
      this.SetModified(true);
    };
    this.GetClonedDataSet = function (WithSettings) {
      var Result = null;
      var DS = null;
      Result = this.FNestedDataSetClass.$create("Create$1",[null]);
      try {
        DS = rtl.as(Result,$mod.TBaseJSONDataSet);
        if (WithSettings) {
          DS.SetFilterText(this.FFilterText);
          DS.SetOnFilterRecord(this.FOnFilterRecord);
          DS.SetFilterOptions(rtl.refSet(this.FFilterOptions));
          DS.SetFiltered(this.FFiltered);
        };
        DS.Clone(this);
        DS.SetActive(this.GetActive());
      } catch ($e) {
        Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.BookmarkValid = function (ABookmark) {
      var Result = false;
      Result = rtl.isNumber(ABookmark.Data);
      return Result;
    };
    this.CompareBookmarks = function (Bookmark1, Bookmark2) {
      var Result = 0;
      if (rtl.isNumber(Bookmark1.Data) && rtl.isNumber(Bookmark2.Data)) {
        Result = rtl.trunc(Bookmark2.Data) - rtl.trunc(Bookmark1.Data)}
       else {
        if (rtl.isNumber(Bookmark1.Data)) {
          Result = -1}
         else if (rtl.isNumber(Bookmark2.Data)) {
          Result = 1}
         else Result = 0;
      };
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TJSONDataset",this.TBaseJSONDataSet,function () {
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("FieldDefs",2,pas.DB.$rtti["TFieldDefs"],"FFieldDefs","SetFieldDefs");
    $r.addProperty("RowType",2,$mod.$rtti["TJSONRowType"],"FRowType","SetRowType");
    $r.addProperty("UseDateTimeFormatFields",0,rtl.boolean,"FUseDateTimeFormatFields","FUseDateTimeFormatFields");
    $r.addProperty("Indexes",2,$mod.$rtti["TJSONIndexDefs"],"FIndexes","SetIndexes");
    $r.addProperty("ActiveIndex",2,rtl.string,"FActiveIndex","SetActiveIndex");
    $r.addProperty("Active",3,rtl.boolean,"GetActive","SetActive",4,{Default: false});
    $r.addProperty("BeforeOpen",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeOpen","FBeforeOpen");
    $r.addProperty("AfterOpen",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterOpen","FAfterOpen");
    $r.addProperty("BeforeClose",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeClose","FBeforeClose");
    $r.addProperty("AfterClose",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterClose","FAfterClose");
    $r.addProperty("BeforeInsert",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeInsert","FBeforeInsert");
    $r.addProperty("AfterInsert",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterInsert","FAfterInsert");
    $r.addProperty("BeforeEdit",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeEdit","FBeforeEdit");
    $r.addProperty("AfterEdit",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterEdit","FAfterEdit");
    $r.addProperty("BeforePost",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforePost","FBeforePost");
    $r.addProperty("AfterPost",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterPost","FAfterPost");
    $r.addProperty("BeforeCancel",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeCancel","FBeforeCancel");
    $r.addProperty("AfterCancel",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterCancel","FAfterCancel");
    $r.addProperty("BeforeDelete",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeDelete","FBeforeDelete");
    $r.addProperty("AfterDelete",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterDelete","FAfterDelete");
    $r.addProperty("BeforeScroll",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FBeforeScroll","FBeforeScroll");
    $r.addProperty("AfterScroll",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FAfterScroll","FAfterScroll");
    $r.addProperty("OnCalcFields",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FOnCalcFields","FOnCalcFields");
    $r.addProperty("OnDeleteError",0,pas.DB.$rtti["TDataSetErrorEvent"],"FOnDeleteError","FOnDeleteError");
    $r.addProperty("OnEditError",0,pas.DB.$rtti["TDataSetErrorEvent"],"FOnEditError","FOnEditError");
    $r.addProperty("OnFilterRecord",2,pas.DB.$rtti["TFilterRecordEvent"],"FOnFilterRecord","SetOnFilterRecord");
    $r.addProperty("OnNewRecord",0,pas.DB.$rtti["TDataSetNotifyEvent"],"FOnNewRecord","FOnNewRecord");
    $r.addProperty("OnPostError",0,pas.DB.$rtti["TDataSetErrorEvent"],"FOnPostError","FOnPostError");
    $r.addProperty("OnRecordResolved",0,pas.DB.$rtti["TOnRecordResolveEvent"],"FOnRecordResolved","FOnRecordResolved");
    $r.addProperty("OnLoadFail",0,pas.DB.$rtti["TDatasetLoadFailEvent"],"FOnLoadFail","FOnLoadFail");
    $r.addProperty("BlobFormat",0,$mod.$rtti["TBlobFormat"],"FBlobFormat","FBlobFormat");
    $r.addProperty("OnDecodeBlobValue",0,$mod.$rtti["TOnDecodeBlobBytesEvent"],"FOnDecodeBlobValue","FOnDecodeBlobValue");
    $r.addProperty("OnEncodeBlobValue",0,$mod.$rtti["TOnEncodeBlobBytesEvent"],"FOnEncodeBlobValue","FOnEncodeBlobValue");
  });
  rtl.createClass(this,"TJSONObjectFieldMapper",this.TJSONFieldMapper,function () {
    this.RemoveField = function (FieldName, FieldIndex, Row) {
      pas.JS.JSDelete(Row,FieldName);
    };
    this.SetJSONDataForField = function (FieldName, FieldIndex, Row, Data) {
      Row[FieldName] = Data;
    };
    this.GetJSONDataForField = function (FieldName, FieldIndex, Row) {
      var Result = undefined;
      Result = Row[FieldName];
      return Result;
    };
    this.CreateRow = function () {
      var Result = undefined;
      Result = new Object();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONArrayFieldMapper",this.TJSONFieldMapper,function () {
    this.RemoveField = function (FieldName, FieldIndex, Row) {
      Row.splice(FieldIndex,1);
    };
    this.SetJSONDataForField = function (FieldName, FieldIndex, Row, Data) {
      Row[FieldIndex] = Data;
    };
    this.GetJSONDataForField = function (FieldName, FieldIndex, Row) {
      var Result = undefined;
      Result = Row[FieldIndex];
      return Result;
    };
    this.CreateRow = function () {
      var Result = undefined;
      Result = new Array();
      return Result;
    };
  });
  rtl.createClass(this,"EJSONDataset",pas.DB.EDatabaseError,function () {
  });
},["DateUtils"]);
rtl.module("WEBLib.DB",["System","Classes","DB","JSONDataset"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TWebDataSource",pas.DB.TDataSource,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
});
rtl.module("WEBLib.TMSFNCDataBindingEditor",["System","Classes","WEBLib.TMSFNCCustomComponent","WEBLib.TMSFNCDataBinding","WEBLib.TMSFNCCustomControl","WEBLib.Controls","WEBLib.TMSFNCTypes","WEBLib.StdCtrls","WEBLib.Graphics","WEBLib.ExtCtrls","WEBLib.Forms","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCEditorButton","WEBLib.TMSFNCEditorPanel","WEBLib.TMSFNCEditorListView","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TTMSFNCDataBindingEditor");
  rtl.createClass(this,"TTMSFNCDataBindingEditorComboBox",pas["WEBLib.StdCtrls"].TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCDataBindingEditorComboBoxSub",pas["WEBLib.StdCtrls"].TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$DynArray("TTMSFNCDataBindingTRectFArray",{eltype: pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]});
  this.$rtti.$DynArray("TTMSFNCDataBindingStringArray",{eltype: rtl.string});
  this.$rtti.$DynArray("TTMSFNCDataBindingTComboArray",{eltype: this.$rtti["TTMSFNCDataBindingEditorComboBoxSub"]});
  rtl.recNewT(this,"TTMSFNCDataBindingEditorBuildItem",function () {
    this.BindComponentText = "";
    this.FieldNameText = "";
    this.PropertyNameText = "";
    this.ColumnsPropertyNameText = "";
    this.ColumnsSubPropertyNameText = "";
    this.Item = null;
    this.$new = function () {
      var r = Object.create(this);
      r.BindComponentRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.FieldNameRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.PropertyNameRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.ColumnsPropertyNameRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.ColumnsSubPropertyNameRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.SubPropertyNamesRects = [];
      r.SubFieldNamesRects = [];
      r.SubPropertyNamesTexts = [];
      r.SubFieldNamesTexts = [];
      r.SubPropertyNamesCombos = [];
      r.SubFieldNamesCombos = [];
      return r;
    };
    this.$eq = function (b) {
      return this.BindComponentRect.$eq(b.BindComponentRect) && (this.BindComponentText === b.BindComponentText) && this.FieldNameRect.$eq(b.FieldNameRect) && (this.FieldNameText === b.FieldNameText) && this.PropertyNameRect.$eq(b.PropertyNameRect) && (this.PropertyNameText === b.PropertyNameText) && this.ColumnsPropertyNameRect.$eq(b.ColumnsPropertyNameRect) && (this.ColumnsPropertyNameText === b.ColumnsPropertyNameText) && this.ColumnsSubPropertyNameRect.$eq(b.ColumnsSubPropertyNameRect) && (this.ColumnsSubPropertyNameText === b.ColumnsSubPropertyNameText) && (this.Item === b.Item) && (this.SubPropertyNamesRects === b.SubPropertyNamesRects) && (this.SubFieldNamesRects === b.SubFieldNamesRects) && (this.SubPropertyNamesTexts === b.SubPropertyNamesTexts) && (this.SubFieldNamesTexts === b.SubFieldNamesTexts) && (this.SubPropertyNamesCombos === b.SubPropertyNamesCombos) && (this.SubFieldNamesCombos === b.SubFieldNamesCombos);
    };
    this.$assign = function (s) {
      this.BindComponentRect.$assign(s.BindComponentRect);
      this.BindComponentText = s.BindComponentText;
      this.FieldNameRect.$assign(s.FieldNameRect);
      this.FieldNameText = s.FieldNameText;
      this.PropertyNameRect.$assign(s.PropertyNameRect);
      this.PropertyNameText = s.PropertyNameText;
      this.ColumnsPropertyNameRect.$assign(s.ColumnsPropertyNameRect);
      this.ColumnsPropertyNameText = s.ColumnsPropertyNameText;
      this.ColumnsSubPropertyNameRect.$assign(s.ColumnsSubPropertyNameRect);
      this.ColumnsSubPropertyNameText = s.ColumnsSubPropertyNameText;
      this.Item = s.Item;
      this.SubPropertyNamesRects = rtl.arrayRef(s.SubPropertyNamesRects);
      this.SubFieldNamesRects = rtl.arrayRef(s.SubFieldNamesRects);
      this.SubPropertyNamesTexts = rtl.arrayRef(s.SubPropertyNamesTexts);
      this.SubFieldNamesTexts = rtl.arrayRef(s.SubFieldNamesTexts);
      this.SubPropertyNamesCombos = rtl.arrayRef(s.SubPropertyNamesCombos);
      this.SubFieldNamesCombos = rtl.arrayRef(s.SubFieldNamesCombos);
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCDataBindingEditorBuildItem",{},this);
    $r.addField("BindComponentRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("BindComponentText",rtl.string);
    $r.addField("FieldNameRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("FieldNameText",rtl.string);
    $r.addField("PropertyNameRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("PropertyNameText",rtl.string);
    $r.addField("ColumnsPropertyNameRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("ColumnsPropertyNameText",rtl.string);
    $r.addField("ColumnsSubPropertyNameRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("ColumnsSubPropertyNameText",rtl.string);
    $r.addField("Item",pas["WEBLib.TMSFNCDataBinding"].$rtti["TTMSFNCDataBinderItem"]);
    $r.addField("SubPropertyNamesRects",$mod.$rtti["TTMSFNCDataBindingTRectFArray"]);
    $r.addField("SubFieldNamesRects",$mod.$rtti["TTMSFNCDataBindingTRectFArray"]);
    $r.addField("SubPropertyNamesTexts",$mod.$rtti["TTMSFNCDataBindingStringArray"]);
    $r.addField("SubFieldNamesTexts",$mod.$rtti["TTMSFNCDataBindingStringArray"]);
    $r.addField("SubPropertyNamesCombos",$mod.$rtti["TTMSFNCDataBindingTComboArray"]);
    $r.addField("SubFieldNamesCombos",$mod.$rtti["TTMSFNCDataBindingTComboArray"]);
  });
  this.TTMSFNCDataBindingEditorMode = {"0": "dbemView", dbemView: 0, "1": "dbemEdit", dbemEdit: 1};
  this.$rtti.$Enum("TTMSFNCDataBindingEditorMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCDataBindingEditorMode});
  rtl.createClass(this,"TTMSFNCDataBindingEditor",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FCachedComponentScreenShot = null;
      this.FBlockUpdate = false;
      this.FBlockChange = false;
      this.FMode = 0;
      this.FBuildItem = $mod.TTMSFNCDataBindingEditorBuildItem.$new();
      this.FListBox = null;
      this.frm = null;
      this.FPanel = null;
      this.FTopPanel = null;
      this.FButtonOk = null;
      this.FButtonCancel = null;
      this.FButtonEdit = null;
      this.FButtonDelete = null;
      this.FButtonAdd = null;
      this.FButtonDuplicate = null;
      this.FVScrlBox = null;
      this.FPreview = null;
      this.FDataBinder = null;
      this.FCheckBoxActive = null;
      this.FComboBoxBindType = null;
      this.FComboboxBindComponent = null;
      this.FComboBoxFieldName = null;
      this.FComboBoxPropertyName = null;
      this.FComboBoxColumnsPropertyName = null;
      this.FComboBoxColumnsSubPropertyName = null;
      this.FComboBoxDataSource = null;
      this.FSubAdd = null;
      this.FSubDelete = null;
      this.FObject = null;
      this.FComponentEvent = null;
    };
    this.$final = function () {
      this.FCachedComponentScreenShot = undefined;
      this.FBuildItem = undefined;
      this.FListBox = undefined;
      this.frm = undefined;
      this.FPanel = undefined;
      this.FTopPanel = undefined;
      this.FButtonOk = undefined;
      this.FButtonCancel = undefined;
      this.FButtonEdit = undefined;
      this.FButtonDelete = undefined;
      this.FButtonAdd = undefined;
      this.FButtonDuplicate = undefined;
      this.FVScrlBox = undefined;
      this.FPreview = undefined;
      this.FDataBinder = undefined;
      this.FCheckBoxActive = undefined;
      this.FComboBoxBindType = undefined;
      this.FComboboxBindComponent = undefined;
      this.FComboBoxFieldName = undefined;
      this.FComboBoxPropertyName = undefined;
      this.FComboBoxColumnsPropertyName = undefined;
      this.FComboBoxColumnsSubPropertyName = undefined;
      this.FComboBoxDataSource = undefined;
      this.FSubAdd = undefined;
      this.FSubDelete = undefined;
      this.FObject = undefined;
      this.FComponentEvent = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCDataBindingEditor);
    };
    this.MakeComponentScreenShot = function () {
      if (this.FCachedComponentScreenShot != null) {
        rtl.free(this,"FCachedComponentScreenShot");
        this.FCachedComponentScreenShot = null;
      };
      if ((this.FBuildItem.Item != null) && (this.FBuildItem.Item.GetObject() != null) && pas["WEBLib.Controls"].TControl.isPrototypeOf(this.FBuildItem.Item.GetObject())) {
        if (pas["WEBLib.Controls"].TCustomControl.isPrototypeOf(this.FBuildItem.Item.GetObject())) {
          this.FComponentEvent = rtl.as(this.FBuildItem.Item.GetObject(),pas["WEBLib.Controls"].TCustomControl).FOnScreenShot;
          rtl.as(this.FBuildItem.Item.GetObject(),pas["WEBLib.Controls"].TCustomControl).FOnScreenShot = rtl.createCallback(this,"DoScreenShot");
        };
        this.FCachedComponentScreenShot = rtl.as(this.FBuildItem.Item.GetObject(),pas["WEBLib.Controls"].TControl).MakeScreenshot();
      };
    };
    this.DoScreenShot = function (Sender, ABitmap) {
      if (pas["WEBLib.Controls"].TCustomControl.isPrototypeOf(Sender)) rtl.as(Sender,pas["WEBLib.Controls"].TCustomControl).FOnScreenShot = this.FComponentEvent;
      if (this.FPreview != null) this.FPreview.Invalidate();
    };
    this.Notification = function (AComponent, AOperation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if (AOperation === pas.Classes.TOperation.opRemove) {
        if (AComponent === this.FDataBinder) this.FDataBinder = null;
        if (AComponent === this.FObject) this.FObject = null;
      };
    };
    this.BuildEditor = function (AParent) {
      var sl = null;
      var I = 0;
      if (AParent != null) {
        this.FTopPanel = pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanel.$create("Create$1",[AParent]);
        this.FTopPanel.SetAlign(pas["WEBLib.Controls"].TAlign.alTop);
        this.FTopPanel.SetTop(0);
        this.FTopPanel.SetParent(AParent);
        this.FTopPanel.SetHeight(37);
        this.FTopPanel.SetPanelPosition(pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanelPosition.eppTop);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorBackPanelAppearance(this.FTopPanel,-1,-1,5);
        this.FButtonEdit = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FTopPanel]);
        this.FButtonEdit.SetParent(this.FTopPanel);
        this.FButtonEdit.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorEditMode")));
        this.FButtonEdit.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
        this.FButtonEdit.SetAlignWithMargins(true);
        this.FButtonEdit.FMargins.SetRight(5);
        this.FButtonEdit.FMargins.SetTop(5);
        this.FButtonEdit.FMargins.SetBottom(5);
        this.FButtonEdit.FMargins.SetLeft(5);
        this.FButtonEdit.FOnClick = rtl.createCallback(this,"DoEdit");
        this.FButtonEdit.SetWidth(100);
        this.FButtonEdit.SetToggle(true);
        this.FButtonEdit.SetEnabled(false);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorTabButtonAppearance(this.FButtonEdit,12482304,5,-1,-1);
        this.FButtonAdd = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FTopPanel]);
        this.FButtonAdd.SetParent(this.FTopPanel);
        this.FButtonAdd.SetWidth(50);
        this.FButtonAdd.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorAdd")));
        this.FButtonAdd.SetAlignWithMargins(true);
        this.FButtonAdd.FMargins.SetRight(5);
        this.FButtonAdd.FMargins.SetTop(5);
        this.FButtonAdd.FMargins.SetBottom(5);
        this.FButtonAdd.FMargins.SetLeft(5);
        this.FButtonAdd.FOnClick = rtl.createCallback(this,"DoAdd");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorIconButtonAppearance(this.FButtonAdd,12482304,5,-1,-1);
        this.FButtonAdd.FAppearance.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
        this.FButtonDelete = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FTopPanel]);
        this.FButtonDelete.SetParent(this.FTopPanel);
        this.FButtonDelete.SetWidth(50);
        this.FButtonDelete.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorDelete")));
        this.FButtonDelete.SetAlignWithMargins(true);
        this.FButtonDelete.FMargins.SetRight(5);
        this.FButtonDelete.FMargins.SetTop(5);
        this.FButtonDelete.FMargins.SetBottom(5);
        this.FButtonDelete.FMargins.SetLeft(0);
        this.FButtonDelete.FOnClick = rtl.createCallback(this,"DoDelete");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorIconButtonAppearance(this.FButtonDelete,12482304,5,-1,-1);
        this.FButtonDelete.FAppearance.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
        this.FButtonDuplicate = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FTopPanel]);
        this.FButtonDuplicate.SetParent(this.FTopPanel);
        this.FButtonDuplicate.SetWidth(75);
        this.FButtonDuplicate.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorDuplicate")));
        this.FButtonDuplicate.SetAlignWithMargins(true);
        this.FButtonDuplicate.FMargins.SetRight(5);
        this.FButtonDuplicate.FMargins.SetTop(5);
        this.FButtonDuplicate.FMargins.SetBottom(5);
        this.FButtonDuplicate.FMargins.SetLeft(0);
        this.FButtonDuplicate.FOnClick = rtl.createCallback(this,"DoDuplicate");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorIconButtonAppearance(this.FButtonDuplicate,12482304,5,-1,-1);
        this.FButtonDuplicate.FAppearance.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
        this.FButtonAdd.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
        this.FButtonDelete.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
        this.FButtonDuplicate.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
        this.FVScrlBox = pas["WEBLib.ExtCtrls"].TScrollBox.$create("Create$1",[AParent]);
        this.FVScrlBox.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
        this.FVScrlBox.SetTop(0);
        this.FVScrlBox.SetParent(AParent);
        this.FVScrlBox.SetWidth(300);
        this.FVScrlBox.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        if (pas["WEBLib.TMSFNCEditorsTools"].IsLightTheme()) {
          this.FVScrlBox.SetColor(16119285)}
         else this.FVScrlBox.SetColor(4406846);
        this.FListBox = pas["WEBLib.TMSFNCEditorListView"].TTMSFNCEditorList.$create("Create$1",[this.FVScrlBox]);
        this.FListBox.SetParent(this.FVScrlBox);
        this.FListBox.SetAlign(pas["WEBLib.Controls"].TAlign.alTop);
        this.FListBox.SetMultiSelect(false);
        this.FListBox.SetDefaultItemHeight(28);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorListAppearance(this.FListBox,12482304,5,-1,-1);
        this.FListBox.SetItemsReadOnly(true);
        this.FListBox.FOnItemSelectedChanged = rtl.createCallback(this,"DoListBoxItemSelectedChange");
        this.FPreview = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$create("Create$1",[AParent]);
        this.FPreview.SetParent(AParent);
        this.FPreview.SetControlAlignment(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient);
        this.FPreview.DisableBackground();
        if (pas["WEBLib.TMSFNCEditorsTools"].IsLightTheme()) {
          this.FPreview.SetColor(16119285)}
         else this.FPreview.SetColor(4406846);
        this.FPreview.FOnAfterDraw = rtl.createCallback(this,"DoAfterDraw");
        this.FPanel = pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanel.$create("Create$1",[AParent]);
        this.FPanel.SetAlign(pas["WEBLib.Controls"].TAlign.alBottom);
        this.FPanel.SetHeight(37);
        this.FPanel.SetParent(AParent);
        this.FPanel.SetPanelPosition(pas["WEBLib.TMSFNCEditorPanel"].TTMSFNCEditorPanelPosition.eppBottom);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorBackPanelAppearance(this.FPanel,-1,-1,5);
        this.FButtonCancel = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FPanel]);
        this.FButtonCancel.FModalResult = 2;
        this.FButtonCancel.SetParent(this.FPanel);
        this.FButtonCancel.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorCancel")));
        this.FButtonCancel.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
        this.FButtonCancel.SetLeft(100);
        this.FButtonCancel.SetAlignWithMargins(true);
        this.FButtonCancel.FMargins.SetRight(5);
        this.FButtonCancel.FMargins.SetTop(5);
        this.FButtonCancel.FMargins.SetBottom(5);
        this.FButtonCancel.FMargins.SetLeft(5);
        this.FButtonCancel.FOnClick = rtl.createCallback(this,"DoButtonCancelClick");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorCancelButtonAppearance(this.FButtonCancel,12482304,5,-1,-1);
        this.FButtonOk = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FPanel]);
        this.FButtonOk.FModalResult = 1;
        this.FButtonOk.SetParent(this.FPanel);
        this.FButtonOk.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorOK")));
        this.FButtonOk.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
        this.FButtonOk.SetLeft(99);
        this.FButtonOk.SetAlignWithMargins(true);
        this.FButtonOk.FMargins.SetRight(0);
        this.FButtonOk.FMargins.SetTop(5);
        this.FButtonOk.FMargins.SetBottom(5);
        this.FButtonOk.FMargins.SetLeft(5);
        this.FButtonOk.FOnClick = rtl.createCallback(this,"DoButtonOKClick");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorOKButtonAppearance(this.FButtonOk,12482304,5,16777215);
        this.FComboBoxBindType = pas["WEBLib.StdCtrls"].TComboBox.$create("Create$1",[AParent]);
        this.FComboBoxBindType.SetParent(AParent);
        this.FComboBoxBindType.SetStyle(pas["WEBLib.StdCtrls"].TComboBoxStyle.csDropDownList);
        this.FComboBoxBindType.FItems.Add("Single Value");
        this.FComboBoxBindType.FItems.Add("List");
        this.FComboBoxBindType.FItems.Add("Column List");
        this.FComboBoxBindType.FItems.Add("Grid");
        this.FComboBoxBindType.FOnChange = rtl.createCallback(this,"DoBindTypeChanged");
        this.FComboBoxDataSource = pas["WEBLib.StdCtrls"].TComboBox.$create("Create$1",[AParent]);
        this.FComboBoxDataSource.SetParent(AParent);
        sl = pas.Classes.TStringList.$create("Create$1");
        try {
          if (this.FDataBinder != null) this.FDataBinder.GetDataSources(sl);
          sl.Insert(0,"");
          this.FComboBoxDataSource.FItems.Assign(sl);
        } finally {
          sl = rtl.freeLoc(sl);
        };
        this.FComboBoxDataSource.SetStyle(pas["WEBLib.StdCtrls"].TComboBoxStyle.csDropDownList);
        this.FComboBoxDataSource.FOnChange = rtl.createCallback(this,"DoDataSourceChanged");
        this.FCheckBoxActive = pas["WEBLib.StdCtrls"].TCheckBox.$create("Create$1",[AParent]);
        this.FCheckBoxActive.SetParent(AParent);
        this.FCheckBoxActive.SetCaption($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorActive")));
        this.FCheckBoxActive.FOnClick = rtl.createCallback(this,"DoActiveChanged");
        if (pas["WEBLib.TMSFNCEditorsTools"].IsLightTheme()) {
          this.FCheckBoxActive.FFont.SetColor(5592405)}
         else this.FCheckBoxActive.FFont.SetColor(11184810);
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorCheckBoxAppearance(this.FCheckBoxActive,-1);
        this.FCheckBoxActive.SetWidth(60);
        this.FComboBoxFieldName = $mod.TTMSFNCDataBindingEditorComboBox.$create("Create$1",[AParent]);
        this.FComboBoxFieldName.FOnChange = rtl.createCallback(this,"DoFieldNameChanged");
        this.FComboBoxPropertyName = $mod.TTMSFNCDataBindingEditorComboBox.$create("Create$1",[AParent]);
        this.FComboBoxPropertyName.FOnChange = rtl.createCallback(this,"DoPropertyNameChanged");
        this.FComboBoxColumnsPropertyName = $mod.TTMSFNCDataBindingEditorComboBox.$create("Create$1",[AParent]);
        this.FComboBoxColumnsPropertyName.FOnChange = rtl.createCallback(this,"DoColumnsPropertyNameChanged");
        this.FComboBoxColumnsSubPropertyName = $mod.TTMSFNCDataBindingEditorComboBox.$create("Create$1",[AParent]);
        this.FComboBoxColumnsSubPropertyName.FOnChange = rtl.createCallback(this,"DoColumnsSubPropertyNameChanged");
        this.FComboBoxPropertyName = $mod.TTMSFNCDataBindingEditorComboBox.$create("Create$1",[AParent]);
        this.FComboBoxPropertyName.FOnChange = rtl.createCallback(this,"DoPropertyNameChanged");
        this.FComboboxBindComponent = pas["WEBLib.StdCtrls"].TComboBox.$create("Create$1",[AParent]);
        this.FComboboxBindComponent.FOnChange = rtl.createCallback(this,"DoBindComponentChanged");
        this.FComboboxBindComponent.SetStyle(pas["WEBLib.StdCtrls"].TComboBoxStyle.csDropDownList);
        this.FSubAdd = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FPreview]);
        this.FSubAdd.SetWidth(30);
        this.FSubAdd.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorAdd")));
        this.FSubAdd.FOnClick = rtl.createCallback(this,"DoSubAdd");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorIconButtonAppearance(this.FSubAdd,12482304,5,-1,-1);
        this.FSubAdd.FAppearance.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
        this.FSubDelete = pas["WEBLib.TMSFNCEditorButton"].TTMSFNCEditorButton.$create("Create$1",[this.FPreview]);
        this.FSubDelete.SetWidth(30);
        this.FSubDelete.SetText($impl.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCDataBindingEditorDelete")));
        this.FSubDelete.FOnClick = rtl.createCallback(this,"DoSubDelete");
        pas["WEBLib.TMSFNCEditorsTools"].SetEditorIconButtonAppearance(this.FSubDelete,12482304,5,-1,-1);
        this.FSubDelete.FAppearance.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
        this.FillControls();
        this.FBlockUpdate = true;
        if (this.FListBox.GetItems().GetCount() > 0) {
          for (var $l = 0, $end = this.FListBox.GetItems().GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            if (this.FListBox.GetItems().GetItemEx(I).FDataObject.GetObject() === this.FObject) {
              this.FListBox.SelectItem(I);
              break;
            };
          };
        };
        this.FBlockUpdate = false;
        this.BuildItem(true);
      };
    };
    this.BuildItem = function (AUpdate) {
      var x = 0.0;
      var xm = 0.0;
      var y = 0.0;
      var sc = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var str = "";
      var it = null;
      var g = null;
      var fa = [];
      var pa = [];
      var fb = [];
      var pb = [];
      var fc = [];
      var pc = [];
      var I = 0;
      var cbo = null;
      this.FBuildItem.BindComponentRect.$assign(pas["WEBLib.TMSFNCTypes"].EmptyRect());
      this.FBuildItem.BindComponentText = "";
      this.FBuildItem.FieldNameRect.$assign(pas["WEBLib.TMSFNCTypes"].EmptyRect());
      this.FBuildItem.FieldNameText = "";
      this.FBuildItem.PropertyNameRect.$assign(pas["WEBLib.TMSFNCTypes"].EmptyRect());
      this.FBuildItem.PropertyNameText = "";
      this.FBuildItem.ColumnsPropertyNameRect.$assign(pas["WEBLib.TMSFNCTypes"].EmptyRect());
      this.FBuildItem.ColumnsPropertyNameText = "";
      this.FBuildItem.ColumnsSubPropertyNameRect.$assign(pas["WEBLib.TMSFNCTypes"].EmptyRect());
      this.FBuildItem.ColumnsSubPropertyNameText = "";
      if (AUpdate) {
        fa = rtl.arraySetLength(fa,pas["WEBLib.TMSFNCTypes"].TRectF,0);
        fb = rtl.arraySetLength(fb,"",0);
        fc = rtl.arraySetLength(fc,null,0);
        pa = rtl.arraySetLength(pa,pas["WEBLib.TMSFNCTypes"].TRectF,0);
        pb = rtl.arraySetLength(pb,"",0);
        pc = rtl.arraySetLength(pc,null,0);
        this.FBuildItem.SubPropertyNamesRects = rtl.arrayRef(pa);
        this.FBuildItem.SubPropertyNamesTexts = rtl.arrayRef(pb);
        this.FBuildItem.SubPropertyNamesCombos = rtl.arrayRef(pc);
        this.FBuildItem.SubFieldNamesRects = rtl.arrayRef(fa);
        this.FBuildItem.SubFieldNamesTexts = rtl.arrayRef(fb);
        this.FBuildItem.SubFieldNamesCombos = rtl.arrayRef(fc);
      };
      this.FBuildItem.Item = null;
      if (AUpdate) {
        for (var $l = this.FPreview.GetComponentCount() - 1; $l >= 0; $l--) {
          I = $l;
          if ($mod.TTMSFNCDataBindingEditorComboBoxSub.isPrototypeOf(this.FPreview.GetComponent(I))) {
            cbo = this.FPreview.GetComponent(I);
            cbo = rtl.freeLoc(cbo);
          };
        };
      };
      if ((this.FListBox.FLastSelectedItemIndex >= 0) && (this.FListBox.FLastSelectedItemIndex <= (this.FListBox.GetItems().GetCount() - 1))) {
        it = this.FListBox.GetItems().GetItemEx(this.FListBox.FLastSelectedItemIndex).FDataObject;
        this.FCheckBoxActive.SetChecked(it.FActive);
        this.FBlockChange = true;
        this.FComboBoxBindType.SetItemIndex(it.FBindType);
        this.FComboBoxDataSource.SetItemIndex(this.FComboBoxDataSource.FItems.IndexOfObject(it.GetDataSource()));
        this.FBlockChange = false;
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.BeginScene();
        try {
          if (this.frm != null) {
            sc = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(this.frm,96)}
           else sc = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(this,96);
          g.FFont.SetHeight(Math.round(sc * -11));
          if (it.GetObject() != null) {
            if (pas.Classes.TComponent.isPrototypeOf(it.GetObject()) && (rtl.as(it.GetObject(),pas.Classes.TComponent).FName !== "")) {
              str = "Bind component: " + rtl.as(it.GetObject(),pas.Classes.TComponent).FName}
             else str = "Bind component: " + it.GetObject().$classname;
          } else str = "Bind component not assigned!";
          x = 20;
          y = 10;
          r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
          rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,y,x + (r.Right - r.Left) + 6,y + (r.Bottom - r.Top) + 6));
          this.FBuildItem.BindComponentRect.$assign(rt);
          this.FBuildItem.BindComponentText = str;
          this.FBuildItem.Item = it;
          if (it.FBindType !== pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtGrid) {
            y = y + 40;
            x = x + 40;
            if (it.FFieldName !== "") {
              str = "Field name: " + it.FFieldName}
             else if (it.FHTMLTemplate !== "") {
              str = "HTML template: " + it.FHTMLTemplate}
             else str = "Field name: " + "[Not bound]";
            r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
            rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,y,x + (r.Right - r.Left) + 6,y + (r.Bottom - r.Top) + 6));
            this.FBuildItem.FieldNameRect.$assign(rt);
            this.FBuildItem.FieldNameText = str;
            if (it.FColumnsPropertyName !== "") {
              str = "Columns property name: " + it.FColumnsPropertyName}
             else str = "Columns property name: " + "[Not bound]";
            r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
            rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,y,x + (r.Right - r.Left) + 6,y + (r.Bottom - r.Top) + 6));
            this.FBuildItem.ColumnsPropertyNameRect.$assign(rt);
            this.FBuildItem.ColumnsPropertyNameText = str;
            if (it.FColumnsSubPropertyName !== "") {
              str = "Columns sub property name: " + it.FColumnsSubPropertyName}
             else str = "Columns sub property name: " + "[Not bound]";
            r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
            rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Right + 20,(y + ((rt.Bottom - rt.Top) / 2)) - (((r.Bottom - r.Top) + 6) / 2),rt.Right + 20 + (r.Right - r.Left) + 6,y + ((rt.Bottom - rt.Top) / 2) + (((r.Bottom - r.Top) + 6) / 2)));
            this.FBuildItem.ColumnsSubPropertyNameRect.$assign(rt);
            this.FBuildItem.ColumnsSubPropertyNameText = str;
            var $tmp = it.FBindType;
            if ($tmp === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtSingleValue) {
              if (it.FPropertyName !== "") {
                str = "Property name: " + it.FPropertyName}
               else str = "Property name: " + "[Not bound]";
            } else if (($tmp === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList) || ($tmp === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtColumnList)) {
              if (it.FPropertyName !== "") {
                str = "List property name: " + it.FPropertyName}
               else str = "List property name: " + "[Not bound]";
            };
            r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
            var $tmp1 = it.FBindType;
            if (($tmp1 === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtSingleValue) || ($tmp1 === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList)) {
              rt.$assign(this.FBuildItem.FieldNameRect);
              rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Right + 20,(y + ((rt.Bottom - rt.Top) / 2)) - (((r.Bottom - r.Top) + 6) / 2),rt.Right + 20 + (r.Right - r.Left) + 6,y + ((rt.Bottom - rt.Top) / 2) + (((r.Bottom - r.Top) + 6) / 2)));
              x = rt.Left;
            } else if ($tmp1 === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtColumnList) {
              rt.$assign(this.FBuildItem.ColumnsSubPropertyNameRect);
              rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,rt.Bottom + 10,x + (r.Right - r.Left) + 6,rt.Bottom + 10 + (r.Bottom - r.Top) + 6));
            };
            this.FBuildItem.PropertyNameRect.$assign(rt);
            this.FBuildItem.PropertyNameText = str;
            if (AUpdate) {
              fa = rtl.arraySetLength(fa,pas["WEBLib.TMSFNCTypes"].TRectF,it.FSubFieldNames.GetCount());
              fb = rtl.arraySetLength(fb,"",it.FSubFieldNames.GetCount());
              fc = rtl.arraySetLength(fc,null,it.FSubFieldNames.GetCount());
              pa = rtl.arraySetLength(pa,pas["WEBLib.TMSFNCTypes"].TRectF,it.FSubPropertyNames.GetCount());
              pb = rtl.arraySetLength(pb,"",it.FSubPropertyNames.GetCount());
              pc = rtl.arraySetLength(pc,null,it.FSubPropertyNames.GetCount());
            } else {
              fa = this.FBuildItem.SubFieldNamesRects;
              fb = this.FBuildItem.SubFieldNamesTexts;
              fc = this.FBuildItem.SubFieldNamesCombos;
              pa = this.FBuildItem.SubPropertyNamesRects;
              pb = this.FBuildItem.SubPropertyNamesTexts;
              pc = this.FBuildItem.SubPropertyNamesCombos;
            };
            xm = 0;
            y = rt.Bottom + 50;
            for (var $l1 = 0, $end = it.FSubFieldNames.GetCount() - 1; $l1 <= $end; $l1++) {
              I = $l1;
              if (it.FSubFieldNames.GetItemEx(I).FValue !== "") {
                str = "Field name: " + it.FSubFieldNames.GetItemEx(I).FValue}
               else if (it.FSubFieldNames.GetItemEx(I).FHTMLTemplate !== "") {
                str = "HTML template: " + it.FSubFieldNames.GetItemEx(I).FHTMLTemplate}
               else str = "Field name: " + "[Not bound]";
              fb[I] = str;
              r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
              fa[I].$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,y,x + (r.Right - r.Left) + 6,y + (r.Bottom - r.Top) + 6));
              xm = Math.max(fa[I].Right - fa[I].Left,xm);
              y = y + (fa[I].Bottom - fa[I].Top) + 10;
              if (AUpdate) fc[I] = $mod.TTMSFNCDataBindingEditorComboBoxSub.$create("Create$1",[this.FPreview]);
              fc[I].FTag$1 = I;
              fc[I].SetBounds(Math.round(fa[I].Left),Math.round(fa[I].Top),Math.round(fa[I].Right - fa[I].Left),Math.round(fa[I].Bottom - fa[I].Top));
              fc[I].FOnChange = rtl.createCallback(this,"DoComboSubFieldChanged");
            };
            if (xm > 0) xm = xm + 20;
            y = rt.Bottom + 50;
            for (var $l2 = 0, $end1 = it.FSubPropertyNames.GetCount() - 1; $l2 <= $end1; $l2++) {
              I = $l2;
              if (it.FSubPropertyNames.GetItemEx(I).FValue !== "") {
                str = "Property name: " + it.FSubPropertyNames.GetItemEx(I).FValue}
               else str = "Property name: " + "[Not bound]";
              pb[I] = str;
              r.$assign(g.CalculateText(str,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,400,10000)),true,false));
              pa[I].$assign(pas["WEBLib.TMSFNCTypes"].RectF(x + xm,y,x + xm + (r.Right - r.Left) + 6,y + (r.Bottom - r.Top) + 6));
              y = y + (pa[I].Bottom - pa[I].Top) + 10;
              if (AUpdate) pc[I] = $mod.TTMSFNCDataBindingEditorComboBoxSub.$create("Create$1",[this.FPreview]);
              pc[I].FTag$1 = I;
              pc[I].SetBounds(Math.round(pa[I].Left),Math.round(pa[I].Top),Math.round(pa[I].Right - pa[I].Left),Math.round(pa[I].Bottom - pa[I].Top));
              pc[I].FOnChange = rtl.createCallback(this,"DoComboSubPropertyChanged");
            };
            this.FBuildItem.SubPropertyNamesRects = rtl.arrayRef(pa);
            this.FBuildItem.SubPropertyNamesTexts = rtl.arrayRef(pb);
            this.FBuildItem.SubPropertyNamesCombos = rtl.arrayRef(pc);
            this.FBuildItem.SubFieldNamesRects = rtl.arrayRef(fa);
            this.FBuildItem.SubFieldNamesTexts = rtl.arrayRef(fb);
            this.FBuildItem.SubFieldNamesCombos = rtl.arrayRef(fc);
          };
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      this.MakeComponentScreenShot();
      this.FPreview.Invalidate();
    };
    this.FillControls = function () {
      var I = 0;
      var it = null;
      var li = null;
      var s = "";
      if (this.FDataBinder != null) {
        this.FBlockUpdate = true;
        this.FListBox.GetItems().Clear();
        this.FListBox.BeginUpdate();
        for (var $l = 0, $end = this.FDataBinder.GetItems().GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = this.FDataBinder.GetItems().GetItemEx(I);
          s = it.FName;
          if ((it.GetObject() != null) && (s === "")) {
            if (pas.Classes.TComponent.isPrototypeOf(it.GetObject()) && (rtl.as(it.GetObject(),pas.Classes.TComponent).FName !== "")) {
              s = rtl.as(it.GetObject(),pas.Classes.TComponent).FName}
             else s = it.GetObject().$classname;
          };
          li = this.FListBox.GetItems().Add$1();
          if (s === "") s = "[Empty Object]";
          li.SetName(s);
          li.SetDataObject(it);
        };
        this.FListBox.EndUpdate();
        this.FBlockUpdate = false;
      };
    };
    this.FillEditControls = function (AUpdate) {
      var $Self = this;
      var I = 0;
      var c = null;
      var str = "";
      var idx = 0;
      var slc = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var f = null;
      var cbo = null;
      function FillPropertyNames(obj, pp, cbo, IncludePublic) {
        var k = 0;
        var j = 0;
        var a = [];
        var propNames = [];
        var o = null;
        var oi = null;
        if (pp !== "") {
          a = pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinder.GetPropertyList(obj);
          for (var $l = 0, $end = rtl.length(a) - 1; $l <= $end; $l++) {
            k = $l;
            if ((a[k] != null) && (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(a[k]) === pp)) {
              if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(a[k]) === pas.System.TTypeKind.tkClass) {
                o = pas.TypInfo.GetObjectProp(obj,pp);
                if (o != null) {
                  if (pas.Classes.TCollection.isPrototypeOf(o)) {
                    oi = rtl.as(o,pas.Classes.TCollection).FItemClass.$create("Create$1",[null]);
                    try {
                      propNames = pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinder.GetPropertyNames(oi,IncludePublic);
                      for (var $l1 = 0, $end1 = rtl.length(propNames) - 1; $l1 <= $end1; $l1++) {
                        j = $l1;
                        cbo.Add(propNames[j]);
                      };
                    } finally {
                      oi = rtl.freeLoc(oi);
                    };
                  } else {
                    propNames = pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinder.GetPropertyNames(o,IncludePublic);
                    for (var $l2 = 0, $end2 = rtl.length(propNames) - 1; $l2 <= $end2; $l2++) {
                      j = $l2;
                      cbo.Add(propNames[j]);
                    };
                  };
                  break;
                };
              };
            };
          };
        } else {
          propNames = pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinder.GetPropertyNames(obj,IncludePublic);
          for (var $l3 = 0, $end3 = rtl.length(propNames) - 1; $l3 <= $end3; $l3++) {
            k = $l3;
            cbo.Add(propNames[k]);
          };
        };
      };
      function FillFieldNames(ds, cbo) {
        if ((ds != null) && (ds.FDataSet != null)) ds.FDataSet.GetFieldNames(cbo);
      };
      if (this.FBlockUpdate) return;
      this.FBlockChange = true;
      if (this.FMode === $mod.TTMSFNCDataBindingEditorMode.dbemEdit) {
        if (this.FBuildItem.Item != null) {
          this.FComboboxBindComponent.SetParent(this.FPreview)}
         else this.FComboboxBindComponent.SetParent(null);
        if (((this.FBuildItem.Item != null) && (this.FBuildItem.Item.FBindType !== pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtGrid)) || !(this.FBuildItem.Item != null)) {
          if (this.FBuildItem.Item != null) {
            this.FComboBoxPropertyName.SetParent(this.FPreview)}
           else this.FComboBoxPropertyName.SetParent(null);
          if ((this.FBuildItem.Item != null) && (this.FBuildItem.Item.FBindType in rtl.createSet(pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtSingleValue,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList))) {
            this.FComboBoxFieldName.SetParent(this.FPreview)}
           else this.FComboBoxFieldName.SetParent(null);
          if ((this.FBuildItem.Item != null) && (this.FBuildItem.Item.FBindType in rtl.createSet(pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtColumnList))) {
            this.FComboBoxColumnsPropertyName.SetParent(this.FPreview);
            this.FComboBoxColumnsSubPropertyName.SetParent(this.FPreview);
          } else {
            this.FComboBoxColumnsPropertyName.SetParent(null);
            this.FComboBoxColumnsSubPropertyName.SetParent(null);
          };
          if ((this.FBuildItem.Item != null) && (this.FBuildItem.Item.FBindType in rtl.createSet(pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtColumnList))) {
            for (var $l = 0, $end = rtl.length(this.FBuildItem.SubFieldNamesCombos) - 1; $l <= $end; $l++) {
              I = $l;
              this.FBuildItem.SubFieldNamesCombos[I].SetParent(this.FPreview);
            };
            for (var $l1 = 0, $end1 = rtl.length(this.FBuildItem.SubPropertyNamesCombos) - 1; $l1 <= $end1; $l1++) {
              I = $l1;
              this.FBuildItem.SubPropertyNamesCombos[I].SetParent(this.FPreview);
            };
          };
          if ((this.FBuildItem.Item != null) && (this.FBuildItem.Item.FBindType in rtl.createSet(pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtColumnList))) {
            this.FSubAdd.SetParent(this.FPreview);
            if ((rtl.length(this.FBuildItem.SubPropertyNamesRects) > 0) || (rtl.length(this.FBuildItem.SubFieldNamesRects) > 0)) {
              this.FSubDelete.SetParent(this.FPreview)}
             else this.FSubDelete.SetParent(null);
            if (rtl.length(this.FBuildItem.SubPropertyNamesRects) > 0) {
              r.$assign(this.FBuildItem.SubPropertyNamesRects[rtl.length(this.FBuildItem.SubPropertyNamesRects) - 1])}
             else if (rtl.length(this.FBuildItem.SubFieldNamesRects) > 0) {
              r.$assign(this.FBuildItem.SubFieldNamesRects[rtl.length(this.FBuildItem.SubFieldNamesRects) - 1])}
             else r.$assign(this.FBuildItem.PropertyNameRect);
            this.FSubAdd.SetBounds(Math.round(r.Right + 20),Math.round(r.Top),Math.round(this.FSubAdd.GetWidth()),Math.round(this.FSubAdd.GetHeight()));
            this.FSubDelete.SetBounds(Math.round(r.Right + 30 + this.FSubAdd.GetWidth()),Math.round(r.Top),Math.round(this.FSubDelete.GetWidth()),Math.round(this.FSubDelete.GetHeight()));
          };
        };
        if (AUpdate) {
          if (this.FComboBoxPropertyName.FParent != null) this.FComboBoxPropertyName.FItems.Clear();
          if (this.FComboBoxColumnsPropertyName.FParent != null) this.FComboBoxColumnsPropertyName.FItems.Clear();
          if (this.FComboBoxColumnsSubPropertyName.FParent != null) this.FComboBoxColumnsSubPropertyName.FItems.Clear();
          if (this.FComboBoxFieldName.FParent != null) this.FComboBoxFieldName.FItems.Clear();
          if (this.FComboboxBindComponent.FParent != null) this.FComboboxBindComponent.FItems.Clear();
          this.FButtonEdit.SetText(rtl.getResStr($mod,"sTMSFNCDataBindingEditorCloseEditMode"));
          f = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetOwnerForm($Self);
          if (f != null) {
            idx = -1;
            if (this.FComboboxBindComponent.FParent != null) this.FComboboxBindComponent.FItems.Add("");
            for (var $l2 = 0, $end2 = f.GetComponentCount() - 1; $l2 <= $end2; $l2++) {
              I = $l2;
              c = f.GetComponent(I);
              if (c.FName !== "") {
                str = c.FName}
               else str = c.$classname;
              if (this.FComboboxBindComponent.FParent != null) this.FComboboxBindComponent.FItems.AddObject(str,c);
              if ((this.FBuildItem.Item != null) && (c === this.FBuildItem.Item.GetBindComponent())) idx = I;
            };
            if (this.FComboboxBindComponent.FParent != null) this.FComboboxBindComponent.SetItemIndex(idx + 1);
          };
          slc = pas.Classes.TStringList.$create("Create$1");
          try {
            if (this.FBuildItem.Item != null) FillPropertyNames(this.FBuildItem.Item.GetBindComponent(),"",slc,true);
            slc.Insert(0,"");
            if (this.FComboBoxPropertyName.FParent != null) this.FComboBoxPropertyName.FItems.Assign(slc);
            if (this.FComboBoxColumnsPropertyName.FParent != null) this.FComboBoxColumnsPropertyName.FItems.Assign(slc);
            slc.Clear();
            if (this.FBuildItem.Item != null) FillPropertyNames(this.FBuildItem.Item.GetBindComponent(),this.FBuildItem.Item.FPropertyName,slc,true);
            slc.Insert(0,"");
            for (var $l3 = 0, $end3 = rtl.length(this.FBuildItem.SubPropertyNamesCombos) - 1; $l3 <= $end3; $l3++) {
              I = $l3;
              if (this.FBuildItem.SubPropertyNamesCombos[I].FParent != null) {
                this.FBuildItem.SubPropertyNamesCombos[I].FItems.Assign(slc);
                this.FBuildItem.SubPropertyNamesCombos[I].SetItemIndex(-1);
                this.FBuildItem.SubPropertyNamesCombos[I].SetText(this.FBuildItem.Item.FSubPropertyNames.GetItemEx(I).FValue);
                this.FBuildItem.SubPropertyNamesCombos[I].SetItemIndex(this.FBuildItem.SubPropertyNamesCombos[I].FItems.IndexOf(this.FBuildItem.SubPropertyNamesCombos[I].GetText()));
              };
            };
            slc.Clear();
            if (this.FBuildItem.Item != null) FillPropertyNames(this.FBuildItem.Item.GetBindComponent(),this.FBuildItem.Item.FColumnsPropertyName,slc,true);
            slc.Insert(0,"");
            if (this.FComboBoxColumnsSubPropertyName.FParent != null) this.FComboBoxColumnsSubPropertyName.FItems.Assign(slc);
            slc.Clear();
            if (this.FBuildItem.Item != null) FillFieldNames(this.FBuildItem.Item.GetDataSource(),slc);
            for (var $l4 = 0, $end4 = rtl.length(this.FBuildItem.SubFieldNamesCombos) - 1; $l4 <= $end4; $l4++) {
              I = $l4;
              if (this.FBuildItem.SubFieldNamesCombos[I].FParent != null) {
                this.FBuildItem.SubFieldNamesCombos[I].FItems.Assign(slc);
                this.FBuildItem.SubFieldNamesCombos[I].SetItemIndex(-1);
                if (this.FBuildItem.Item.FSubFieldNames.GetItemEx(I).FHTMLTemplate !== "") {
                  this.FBuildItem.SubFieldNamesCombos[I].SetText(this.FBuildItem.Item.FSubFieldNames.GetItemEx(I).FHTMLTemplate)}
                 else {
                  this.FBuildItem.SubFieldNamesCombos[I].SetText(this.FBuildItem.Item.FSubFieldNames.GetItemEx(I).FValue);
                  this.FBuildItem.SubFieldNamesCombos[I].SetItemIndex(this.FBuildItem.SubFieldNamesCombos[I].FItems.IndexOf(this.FBuildItem.SubFieldNamesCombos[I].GetText()));
                };
              };
            };
            slc.Insert(0,"");
            if (this.FComboBoxFieldName.FParent != null) this.FComboBoxFieldName.FItems.Assign(slc);
          } finally {
            slc = rtl.freeLoc(slc);
          };
        };
        if (this.FComboBoxColumnsPropertyName.FParent != null) {
          this.FComboBoxColumnsPropertyName.SetItemIndex(-1);
          this.FComboBoxColumnsPropertyName.SetText(this.FBuildItem.Item.FColumnsPropertyName);
          this.FComboBoxColumnsPropertyName.SetItemIndex(this.FComboBoxColumnsPropertyName.FItems.IndexOf(this.FComboBoxColumnsPropertyName.GetText()));
        };
        if (this.FComboBoxColumnsSubPropertyName.FParent != null) {
          this.FComboBoxColumnsSubPropertyName.SetItemIndex(-1);
          this.FComboBoxColumnsSubPropertyName.SetText(this.FBuildItem.Item.FColumnsSubPropertyName);
          this.FComboBoxColumnsSubPropertyName.SetItemIndex(this.FComboBoxColumnsSubPropertyName.FItems.IndexOf(this.FComboBoxColumnsSubPropertyName.GetText()));
        };
        if (this.FComboBoxPropertyName.FParent != null) {
          this.FComboBoxPropertyName.SetItemIndex(-1);
          this.FComboBoxPropertyName.SetText(this.FBuildItem.Item.FPropertyName);
          this.FComboBoxPropertyName.SetItemIndex(this.FComboBoxPropertyName.FItems.IndexOf(this.FComboBoxPropertyName.GetText()));
        };
        if (this.FComboBoxFieldName.FParent != null) {
          this.FComboBoxFieldName.SetItemIndex(-1);
          if (this.FBuildItem.Item.FHTMLTemplate !== "") {
            this.FComboBoxFieldName.SetText(this.FBuildItem.Item.FHTMLTemplate)}
           else {
            this.FComboBoxFieldName.SetText(this.FBuildItem.Item.FFieldName);
            this.FComboBoxFieldName.SetItemIndex(this.FComboBoxFieldName.FItems.IndexOf(this.FComboBoxFieldName.GetText()));
          };
        };
        this.FComboboxBindComponent.SetBounds(Math.round(this.FBuildItem.BindComponentRect.Left),Math.round(this.FBuildItem.BindComponentRect.Top),Math.round(this.FBuildItem.BindComponentRect.Right - this.FBuildItem.BindComponentRect.Left),Math.round(this.FBuildItem.BindComponentRect.Bottom - this.FBuildItem.BindComponentRect.Top));
        this.FComboBoxFieldName.SetBounds(Math.round(this.FBuildItem.FieldNameRect.Left),Math.round(this.FBuildItem.FieldNameRect.Top),Math.round(this.FBuildItem.FieldNameRect.Right - this.FBuildItem.FieldNameRect.Left),Math.round(this.FBuildItem.FieldNameRect.Bottom - this.FBuildItem.FieldNameRect.Top));
        this.FComboBoxPropertyName.SetBounds(Math.round(this.FBuildItem.PropertyNameRect.Left),Math.round(this.FBuildItem.PropertyNameRect.Top),Math.round(this.FBuildItem.PropertyNameRect.Right - this.FBuildItem.PropertyNameRect.Left),Math.round(this.FBuildItem.PropertyNameRect.Bottom - this.FBuildItem.PropertyNameRect.Top));
        this.FComboBoxColumnsPropertyName.SetBounds(Math.round(this.FBuildItem.ColumnsPropertyNameRect.Left),Math.round(this.FBuildItem.ColumnsPropertyNameRect.Top),Math.round(this.FBuildItem.ColumnsPropertyNameRect.Right - this.FBuildItem.ColumnsPropertyNameRect.Left),Math.round(this.FBuildItem.ColumnsPropertyNameRect.Bottom - this.FBuildItem.ColumnsPropertyNameRect.Top));
        this.FComboBoxColumnsSubPropertyName.SetBounds(Math.round(this.FBuildItem.ColumnsSubPropertyNameRect.Left),Math.round(this.FBuildItem.ColumnsSubPropertyNameRect.Top),Math.round(this.FBuildItem.ColumnsSubPropertyNameRect.Right - this.FBuildItem.ColumnsSubPropertyNameRect.Left),Math.round(this.FBuildItem.ColumnsSubPropertyNameRect.Bottom - this.FBuildItem.ColumnsSubPropertyNameRect.Top));
      } else {
        this.FButtonEdit.SetText(rtl.getResStr($mod,"sTMSFNCDataBindingEditorEditMode"));
        this.FComboboxBindComponent.SetParent(null);
        this.FComboBoxFieldName.SetParent(null);
        this.FComboBoxPropertyName.SetParent(null);
        this.FComboBoxColumnsPropertyName.SetParent(null);
        this.FComboBoxColumnsSubPropertyName.SetParent(null);
        this.FSubAdd.SetParent(null);
        this.FSubDelete.SetParent(null);
        for (var $l5 = this.FPreview.GetComponentCount() - 1; $l5 >= 0; $l5--) {
          I = $l5;
          if ($mod.TTMSFNCDataBindingEditorComboBoxSub.isPrototypeOf(this.FPreview.GetComponent(I))) {
            cbo = this.FPreview.GetComponent(I);
            cbo.SetParent(null);
          };
        };
      };
      this.FBlockChange = false;
    };
    this.DoResizeForm = function (Sender) {
      if ((this.FCheckBoxActive != null) && (this.FComboBoxBindType != null)) {
        this.FCheckBoxActive.SetBounds((this.FPreview.GetLeft() + this.FPreview.GetWidth()) - this.FCheckBoxActive.GetWidth() - 10,this.FPreview.GetTop() + 10,this.FCheckBoxActive.GetWidth(),this.FCheckBoxActive.GetHeight());
        this.FComboBoxBindType.SetBounds(this.FCheckBoxActive.GetLeft() - this.FComboBoxBindType.GetWidth() - 10,this.FPreview.GetTop() + 10,this.FComboBoxBindType.GetWidth(),this.FComboBoxBindType.GetHeight());
        this.FComboBoxDataSource.SetBounds(this.FComboBoxBindType.GetLeft() - this.FComboBoxDataSource.GetWidth() - 10,this.FPreview.GetTop() + 10,this.FComboBoxDataSource.GetWidth(),this.FComboBoxDataSource.GetHeight());
      };
    };
    this.DoEdit = function (Sender) {
      var $tmp = this.FMode;
      if ($tmp === $mod.TTMSFNCDataBindingEditorMode.dbemView) {
        this.FMode = $mod.TTMSFNCDataBindingEditorMode.dbemEdit}
       else if ($tmp === $mod.TTMSFNCDataBindingEditorMode.dbemEdit) this.FMode = $mod.TTMSFNCDataBindingEditorMode.dbemView;
      this.FillEditControls(true);
    };
    this.DoAdd = function (Sender) {
      if (this.FDataBinder.GetItemByObject(null,"") != null) {
        pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Message('Please select and edit/remove the "[Empty Object]" item, before adding a new item');
        return;
      };
      if (this.FDataBinder != null) this.FDataBinder.GetItems().Add$1();
      this.FillControls();
      this.FBlockUpdate = true;
      if (this.FListBox.GetItems().GetCount() > 0) this.FListBox.SelectItem(this.FListBox.GetItems().GetCount() - 1);
      this.FBlockUpdate = false;
      this.BuildItem(true);
      this.FMode = $mod.TTMSFNCDataBindingEditorMode.dbemEdit;
      this.FillEditControls(true);
    };
    this.DoDuplicate = function (Sender) {
      if (this.FDataBinder.GetItemByObject(null,"") != null) {
        pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Message('Please select and edit/remove the "[Empty Object]" item, before adding a new item');
        return;
      };
      if (!(this.FBuildItem.Item != null)) {
        this.DoAdd(Sender);
        return;
      };
      if (this.FDataBinder != null) this.FDataBinder.GetItems().Add$1().Assign(this.FBuildItem.Item);
      this.FillControls();
      this.FBlockUpdate = true;
      if (this.FListBox.GetItems().GetCount() > 0) this.FListBox.SelectItem(this.FListBox.GetItems().GetCount() - 1);
      this.FBlockUpdate = false;
      this.BuildItem(true);
      this.FMode = $mod.TTMSFNCDataBindingEditorMode.dbemEdit;
      this.FillEditControls(true);
    };
    this.DoDelete = function (Sender) {
      var io = 0;
      if ((this.FListBox.FLastSelectedItemIndex >= 0) && (this.FListBox.FLastSelectedItemIndex <= (this.FListBox.GetItems().GetCount() - 1)) && (this.FListBox.GetItems().GetItemEx(this.FListBox.FLastSelectedItemIndex).FSelected === true)) {
        io = this.FListBox.FLastSelectedItemIndex;
        this.FDataBinder.GetItems().Delete(this.FListBox.FLastSelectedItemIndex);
        this.FillControls();
        this.FBlockUpdate = true;
        if (this.FListBox.GetItems().GetCount() > 0) {
          if ((io - 1) >= 0) {
            this.FListBox.SelectItem(io - 1)}
           else this.FListBox.SelectItem(io);
        } else this.FListBox.UnselectAllItems();
        this.FBlockUpdate = false;
        this.BuildItem(true);
        this.FillEditControls(true);
      };
    };
    this.DoSubAdd = function (Sender) {
      if (this.FBuildItem.Item != null) {
        this.FBuildItem.Item.FSubFieldNames.Add$1();
        this.FBuildItem.Item.FSubPropertyNames.Add$1();
        this.BuildItem(true);
        this.FillEditControls(true);
      };
    };
    this.DoSubDelete = function (Sender) {
      if (this.FBuildItem.Item != null) {
        if (this.FBuildItem.Item.FSubFieldNames.GetCount() > 0) this.FBuildItem.Item.FSubFieldNames.Delete(this.FBuildItem.Item.FSubFieldNames.GetCount() - 1);
        if (this.FBuildItem.Item.FSubPropertyNames.GetCount() > 0) this.FBuildItem.Item.FSubPropertyNames.Delete(this.FBuildItem.Item.FSubPropertyNames.GetCount() - 1);
        this.BuildItem(true);
        this.FillEditControls(true);
      };
    };
    this.DoActiveChanged = function (Sender) {
      if (this.FBuildItem.Item != null) {
        this.FBuildItem.Item.SetActive(this.FCheckBoxActive.GetChecked());
        this.MakeComponentScreenShot();
        this.FPreview.Invalidate();
      };
    };
    this.DoBindTypeChanged = function (Sender) {
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) this.FBuildItem.Item.SetBindType(this.FComboBoxBindType.GetItemIndex());
      this.BuildItem(false);
      this.FillEditControls(false);
    };
    this.DoDataSourceChanged = function (Sender) {
      var obj = null;
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) {
        if ((this.FComboBoxDataSource.GetItemIndex() >= 0) && (this.FComboBoxDataSource.GetItemIndex() <= (this.FComboBoxDataSource.FItems.GetCount() - 1))) {
          obj = this.FComboBoxDataSource.FItems.GetObject(this.FComboBoxDataSource.GetItemIndex());
          if (pas.DB.TDataSource.isPrototypeOf(obj)) {
            this.FBuildItem.Item.SetDataSource(rtl.as(obj,pas.DB.TDataSource))}
           else this.FBuildItem.Item.SetDataSource(null);
        };
      };
      this.BuildItem(false);
      this.FillEditControls(true);
    };
    this.DoListBoxChange = function (Sender) {
      this.BuildItem(true);
      this.FillEditControls(true);
    };
    this.DoListBoxItemSelectedChange = function (Sender, AIndex, AItem, ASelected) {
      if (rtl.length(this.FListBox.GetSelectedItems()) > 0) {
        this.FButtonEdit.SetEnabled(true)}
       else {
        this.FMode = $mod.TTMSFNCDataBindingEditorMode.dbemView;
        this.FButtonEdit.SetSelected(false);
        this.FButtonEdit.SetEnabled(false);
      };
      if (ASelected) this.DoListBoxChange(Sender);
    };
    this.DoBindComponentChanged = function (Sender) {
      var I = 0;
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) {
        this.FBuildItem.Item.SetActive(false);
        if ((this.FComboboxBindComponent.GetItemIndex() >= 0) && (this.FComboboxBindComponent.GetItemIndex() <= (this.FComboboxBindComponent.FItems.GetCount() - 1))) this.FBuildItem.Item.SetObject(this.FComboboxBindComponent.FItems.GetObject(this.FComboboxBindComponent.GetItemIndex()));
        this.BuildItem(false);
        this.FillControls();
        this.FBlockUpdate = true;
        if (this.FListBox.GetItems().GetCount() > 0) {
          for (var $l = 0, $end = this.FListBox.GetItems().GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            if (this.FListBox.GetItems().GetItemEx(I).FDataObject.GetObject() === this.FBuildItem.Item.GetObject()) {
              this.FListBox.SelectItem(I);
              break;
            };
          };
        };
        this.FBlockUpdate = false;
        this.FillEditControls(true);
      };
    };
    this.DoPropertyNameChanged = function (Sender) {
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) {
        this.FBuildItem.Item.SetPropertyName(this.FComboBoxPropertyName.GetText());
        this.BuildItem(false);
        this.FillEditControls(false);
      };
    };
    this.DoFieldNameChanged = function (Sender) {
      var s = "";
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) {
        s = this.FComboBoxFieldName.GetText();
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(s)) {
          this.FBuildItem.Item.SetHTMLTemplate(s);
          this.FBuildItem.Item.SetFieldName("");
        } else {
          this.FBuildItem.Item.SetHTMLTemplate("");
          this.FBuildItem.Item.SetFieldName(s);
        };
        this.BuildItem(false);
        this.FillEditControls(false);
      };
    };
    this.DoComboSubPropertyChanged = function (Sender) {
      var i = 0;
      if (this.FBlockChange) return;
      if ((this.FBuildItem.Item != null) && $mod.TTMSFNCDataBindingEditorComboBoxSub.isPrototypeOf(Sender)) {
        i = rtl.as(Sender,$mod.TTMSFNCDataBindingEditorComboBoxSub).FTag$1;
        if ((i >= 0) && (i <= (this.FBuildItem.Item.FSubPropertyNames.GetCount() - 1))) {
          this.FBuildItem.Item.FSubPropertyNames.GetItemEx(rtl.as(Sender,$mod.TTMSFNCDataBindingEditorComboBoxSub).FTag$1).SetValue(rtl.as(Sender,$mod.TTMSFNCDataBindingEditorComboBoxSub).GetText());
          this.BuildItem(false);
          this.FillEditControls(false);
        };
      };
    };
    this.DoComboSubFieldChanged = function (Sender) {
      var i = 0;
      var s = "";
      if (this.FBlockChange) return;
      if ((this.FBuildItem.Item != null) && $mod.TTMSFNCDataBindingEditorComboBoxSub.isPrototypeOf(Sender)) {
        i = rtl.as(Sender,$mod.TTMSFNCDataBindingEditorComboBoxSub).FTag$1;
        if ((i >= 0) && (i <= (this.FBuildItem.Item.FSubFieldNames.GetCount() - 1))) {
          s = rtl.as(Sender,$mod.TTMSFNCDataBindingEditorComboBoxSub).GetText();
          if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(s)) {
            this.FBuildItem.Item.FSubFieldNames.GetItemEx(i).SetHTMLTemplate(s);
            this.FBuildItem.Item.FSubFieldNames.GetItemEx(i).SetValue("");
          } else {
            this.FBuildItem.Item.FSubFieldNames.GetItemEx(i).SetHTMLTemplate("");
            this.FBuildItem.Item.FSubFieldNames.GetItemEx(i).SetValue(s);
          };
          this.BuildItem(false);
          this.FillEditControls(false);
        };
      };
    };
    this.DoColumnsPropertyNameChanged = function (Sender) {
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) {
        this.FBuildItem.Item.SetColumnsPropertyName(this.FComboBoxColumnsPropertyName.GetText());
        this.BuildItem(false);
        this.FillEditControls(false);
      };
    };
    this.DoColumnsSubPropertyNameChanged = function (Sender) {
      if (this.FBlockChange) return;
      if (this.FBuildItem.Item != null) {
        this.FBuildItem.Item.SetColumnsSubPropertyName(this.FComboBoxColumnsSubPropertyName.GetText());
        this.BuildItem(false);
        this.FillEditControls(false);
      };
    };
    this.DoAfterDraw = function (Sender, AGraphics, ARect) {
      var $Self = this;
      var bcr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var fnr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var pnr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cnr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cnsr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmp = null;
      var x = 0.0;
      var y = 0.0;
      var I = 0;
      var str = "";
      var c = 0;
      var sc = 0.0;
      function DrawSplittedText(ATextRect, AText) {
        var sl = null;
        var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var rtt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var x = 0.0;
        var ft = 0;
        var fk = 0;
        var K = 0;
        var spc = 0.0;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(AText)) {
          AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ATextRect),AText,true,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,false,false,-1,-1);
          return;
        };
        ft = AGraphics.FFont.FColor;
        fk = AGraphics.FFill.FKind;
        sl = pas.Classes.TStringList.$create("Create$1");
        try {
          x = ATextRect.Left;
          pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Split(":",AText,sl,false);
          spc = Math.round(sc * 6);
          if (sl.GetCount() > 0) spc = spc / sl.GetCount();
          for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
            K = $l;
            rc.$assign(AGraphics.CalculateText$1(sl.Get(K)));
            rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,ATextRect.Top,x + (rc.Right - rc.Left) + spc,ATextRect.Bottom));
            if (K > 0) {
              AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left,rt.Top,rt.Right + spc,rt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              AGraphics.FFont.SetColor(16777215);
            };
            rtt.$assign(rt);
            AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rtt),sl.Get(K),true,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,false,false,-1,-1);
            x = rt.Right + spc;
          };
        } finally {
          sl = rtl.freeLoc(sl);
          AGraphics.FFont.SetColor(ft);
          AGraphics.FFill.SetKind(fk);
        };
      };
      if (this.FBuildItem.Item != null) {
        sc = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(this.frm,96);
        c = 12482304;
        AGraphics.FFont.SetHeight(Math.round(-11 * sc));
        AGraphics.FStroke.SetColor(c);
        AGraphics.FFill.SetColor(c);
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
        AGraphics.FFont.SetColor(c);
        y = 0;
        if (this.FBuildItem.Item.FBindType === pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtGrid) {
          bcr.$assign(this.FBuildItem.BindComponentRect);
          if (this.FMode === $mod.TTMSFNCDataBindingEditorMode.dbemView) {
            AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bcr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
            DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bcr),this.FBuildItem.BindComponentText);
          };
          y = bcr.Bottom;
        } else {
          if (this.FBuildItem.Item.FBindType in rtl.createSet(pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtSingleValue,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList)) {
            bcr.$assign(this.FBuildItem.BindComponentRect);
            fnr.$assign(this.FBuildItem.FieldNameRect);
            pnr.$assign(this.FBuildItem.PropertyNameRect);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left,bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),fnr.Top + ((fnr.Bottom - fnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),fnr.Top + ((fnr.Bottom - fnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(fnr.Left,fnr.Top + ((fnr.Bottom - fnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(fnr.Right,fnr.Top + ((fnr.Bottom - fnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Left,pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            if (this.FMode === $mod.TTMSFNCDataBindingEditorMode.dbemView) {
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bcr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(fnr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pnr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bcr),this.FBuildItem.BindComponentText);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(fnr),this.FBuildItem.FieldNameText);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pnr),this.FBuildItem.PropertyNameText);
            };
          } else {
            bcr.$assign(this.FBuildItem.BindComponentRect);
            cnr.$assign(this.FBuildItem.ColumnsPropertyNameRect);
            cnsr.$assign(this.FBuildItem.ColumnsSubPropertyNameRect);
            pnr.$assign(this.FBuildItem.PropertyNameRect);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left,bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),cnr.Top + ((cnr.Bottom - cnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),bcr.Top + ((bcr.Bottom - bcr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),cnsr.Top + ((cnsr.Bottom - cnsr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),cnr.Top + ((cnr.Bottom - cnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cnr.Left,cnr.Top + ((cnr.Bottom - cnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bcr.Left - Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Left,pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cnr.Right,cnr.Top + ((cnr.Bottom - cnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cnsr.Left,cnsr.Top + ((cnsr.Bottom - cnsr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            if (this.FMode === $mod.TTMSFNCDataBindingEditorMode.dbemView) {
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bcr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cnr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cnsr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pnr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bcr),this.FBuildItem.BindComponentText);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cnr),this.FBuildItem.ColumnsPropertyNameText);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cnsr),this.FBuildItem.ColumnsSubPropertyNameText);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pnr),this.FBuildItem.PropertyNameText);
            };
          };
          x = 40;
          for (var $l = 0, $end = rtl.length(this.FBuildItem.SubFieldNamesRects) - 1; $l <= $end; $l++) {
            I = $l;
            r.$assign(this.FBuildItem.SubFieldNamesRects[I]);
            str = this.FBuildItem.SubFieldNamesTexts[I];
            if (this.FMode === $mod.TTMSFNCDataBindingEditorMode.dbemView) {
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),str);
            };
            y = Math.max(r.Bottom,y);
            x = Math.max(r.Right,x);
          };
          if (((rtl.length(this.FBuildItem.SubFieldNamesRects) > 0) || (rtl.length(this.FBuildItem.SubPropertyNamesRects) > 0)) && (this.FBuildItem.Item.FBindType in rtl.createSet(pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtColumnList,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderBindType.dbbtList))) {
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Right,pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Right + Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Right + Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Right + Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          };
          if (rtl.length(this.FBuildItem.SubFieldNamesRects) > 0) {
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(Math.max(pnr.Right + Math.round(sc * 10),x),pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,pnr.Bottom + Math.round(sc * 25))),"Sub field names",0,true,false,-1,-1);
          };
          if (rtl.length(this.FBuildItem.SubPropertyNamesRects) > 0) AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(x + Math.round(sc * 20),pnr.Bottom + Math.round(sc * 25))),"Sub property names",0,true,false,-1,-1);
          x = 0;
          for (var $l1 = 0, $end1 = rtl.length(this.FBuildItem.SubPropertyNamesRects) - 1; $l1 <= $end1; $l1++) {
            I = $l1;
            r.$assign(this.FBuildItem.SubPropertyNamesRects[I]);
            str = this.FBuildItem.SubPropertyNamesTexts[I];
            if (this.FMode === $mod.TTMSFNCDataBindingEditorMode.dbemView) {
              AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
              DrawSplittedText(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),str);
            };
            y = Math.max(r.Bottom,y);
            x = Math.max(r.Right,x);
          };
          if (rtl.length(this.FBuildItem.SubPropertyNamesRects) > 0) {
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Left,pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Right + Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pnr.Right + Math.round(sc * 10),pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(x,pnr.Top + ((pnr.Bottom - pnr.Top) / 2) + Math.round(sc * 30))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          };
        };
        if (y === 0) y = Math.max(fnr.Bottom,pnr.Bottom);
        y = y + Math.round(sc * 10);
      };
    };
    this.DoFormKeyDown = function (Sender, Key, Shift) {
      if (Key.get() === 27) {
        this.frm.Close();
      } else if (Key.get() === 13) {
        this.frm.SetModalResult(1);
        this.frm.Close();
      };
    };
    this.ApplyCSS = function (ACSS) {
    };
    this.DoButtonOKClick = function (Sender) {
      if (this.frm != null) this.frm.SetModalResult(1);
    };
    this.DoButtonCancelClick = function (Sender) {
      if (this.frm != null) this.frm.SetModalResult(2);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      return this;
    };
    this.Destroy = function () {
      if (this.FCachedComponentScreenShot != null) {
        rtl.free(this,"FCachedComponentScreenShot");
        this.FCachedComponentScreenShot = null;
      };
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Execute = function (AProc) {
      var $Self = this;
      this.frm = $mod.TTMSFNCDataBindingEditorForm.$create("CreateDialogNew$1",[$Self,"Database Binding Editor"]);
      this.frm.SetWidth(1000);
      this.frm.SetHeight(500);
      this.frm.FOnKeyDown = rtl.createCallback($Self,"DoFormKeyDown");
      this.frm.FOnResize = rtl.createCallback($Self,"DoResizeForm");
      this.frm.SetPosition(pas["WEBLib.Forms"].TPosition.poScreenCenter);
      if (pas["WEBLib.TMSFNCEditorsTools"].IsLightTheme()) {
        this.frm.SetColor(16119285)}
       else this.frm.SetColor(4406846);
      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ScaleForCurrentDPI(this.frm);
      this.frm.ShowModal$1(function (AResult) {
        $Self.frm = null;
        if (AProc != null) AProc(AResult);
      });
    };
    this.Assign = function (Source) {
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DataBinder",0,pas["WEBLib.TMSFNCDataBinding"].$rtti["TTMSFNCDataBinder"],"FDataBinder","FDataBinder");
    $r.addProperty("Object",0,pas.System.$rtti["TObject"],"FObject","FObject");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCDataBindingEditorForm",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomDesignerForm,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomDesignerForm.$init.call(this);
      this.FDataBindingEditor = null;
    };
    this.$final = function () {
      this.FDataBindingEditor = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomDesignerForm.$final.call(this);
    };
    this.Loaded = function () {
      var css = "";
      pas["WEBLib.Forms"].TCustomForm.Loaded.call(this);
      css = pas["WEBLib.Forms"].Application.IDECSS();
      if (css !== "") {
        this.AddCSS("IDECSS",css);
        this.SetElementClassName("IDEBkg");
        this.FCaptionElement.setAttribute("class","IDECaption IDEFont");
        if (this.FDataBindingEditor != null) this.FDataBindingEditor.ApplyCSS(css);
      };
    };
    this.LoadDFMValues = function () {
      pas["WEBLib.Forms"].TCustomForm.LoadDFMValues.call(this);
      if (this.FDataBindingEditor != null) {
        this.FDataBindingEditor.BuildEditor(this);
        this.SetActiveControl(this.FDataBindingEditor.FTopPanel);
      };
    };
    this.CreateDialogNew$1 = function (ADataBindingEditor, ACaption) {
      this.FDataBindingEditor = ADataBindingEditor;
      pas["WEBLib.Forms"].TCustomForm.CreateDialogNew.call(this,ACaption);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$resourcestrings = {sTMSFNCDataBindingEditorOK: {org: "OK"}, sTMSFNCDataBindingEditorCancel: {org: "Cancel"}, sTMSFNCDataBindingEditorEditMode: {org: "&Edit Mode"}, sTMSFNCDataBindingEditorCloseEditMode: {org: "&Close Edit Mode"}, sTMSFNCDataBindingEditorActive: {org: "Active"}, sTMSFNCDataBindingEditorAdd: {org: "Add"}, sTMSFNCDataBindingEditorDelete: {org: "Delete"}, sTMSFNCDataBindingEditorDuplicate: {org: "Duplicate"}};
  $mod.$implcode = function () {
    $impl.TranslateTextEx = function (AText) {
      var Result = "";
      Result = AText;
      return Result;
    };
  };
},["Math","TypInfo","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCUtils","SysUtils","WEBLib.Dialogs","WEBLib.TMSFNCEditorsTools","WEBLib.WebTools","DB","WEBLib.DB"]);
rtl.module("WEBLib.TMSFNCDataBinding",["System","Classes","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCTypes","WEBLib.TMSFNCCustomComponent","WEBLib.Controls","TypInfo","Generics.Collections","DB"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 2;
  rtl.createInterface(this,"ITMSFNCDataBinderBase","{778B63C9-34E3-4B65-A6B8-85E3EB1D17C3}",["DataBeginUpdate","DataEndUpdate"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("DataBeginUpdate",0,[]);
    $r.addMethod("DataEndUpdate",0,[]);
  });
  rtl.createInterface(this,"ITMSFNCDataBinderGrid","{D23BDEAA-49B1-451A-9401-0D0D11A9957A}",["SetDataColumnCount","SetDataRowCount","ClearData","GetDataRowCount","SetDataValue","SetDataHeader","DataInsertRow"],this.ITMSFNCDataBinderBase,function () {
    var $r = this.$rtti;
    $r.addMethod("SetDataColumnCount",0,[["AValue",rtl.longint]]);
    $r.addMethod("SetDataRowCount",0,[["AValue",rtl.longint]]);
    $r.addMethod("ClearData",0,[]);
    $r.addMethod("GetDataRowCount",1,[],2,rtl.longint);
    $r.addMethod("SetDataValue",0,[["AColumn",rtl.longint],["ARow",rtl.longint],["AValue",rtl.string]]);
    $r.addMethod("SetDataHeader",0,[["AColumn",rtl.longint],["AValue",rtl.string]]);
    $r.addMethod("DataInsertRow",0,[["AInsertPosition",rtl.longint]]);
  });
  rtl.createInterface(this,"ITMSFNCDataBinderSelection","{F7D3F4D2-F202-48C0-9036-3F03E642F1E5}",["DataGetItemIndex","DataSetItemIndex"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("DataGetItemIndex",1,[],2,rtl.longint);
    $r.addMethod("DataSetItemIndex",0,[["AValue",rtl.longint]]);
  });
  this.TTMSFNCDataBinderNotificationType = {"0": "dbntUpdate", dbntUpdate: 0, "1": "dbntEdit", dbntEdit: 1, "2": "dbntPost", dbntPost: 2, "3": "dbntValueChanged", dbntValueChanged: 3, "4": "dbntSetActiveRecord", dbntSetActiveRecord: 4};
  this.$rtti.$Enum("TTMSFNCDataBinderNotificationType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCDataBinderNotificationType});
  rtl.createInterface(this,"ITMSFNCDataBinderNotification","{3CEED28B-A125-4B26-B765-72785F2B0180}",["GetObject","SetObject","Notify"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetObject",1,[],2,pas.System.$rtti["TObject"]);
    $r.addMethod("SetObject",0,[["Value",pas.System.$rtti["TObject"],2]]);
    $r.addMethod("Notify",0,[["AType",$mod.$rtti["TTMSFNCDataBinderNotificationType"]]]);
    $r.addProperty("Object",3,pas.System.$rtti["TObject"],"GetObject","SetObject",2);
  });
  rtl.createInterface(this,"ITMSFNCDataBinderNotificationManager","{AFAFFAD9-AA33-4063-9BCB-6A17EC97D5C1}",["Notify"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Notify",0,[["AControl",pas.System.$rtti["TObject"]],["AType",$mod.$rtti["TTMSFNCDataBinderNotificationType"]]]);
  });
  rtl.createInterface(this,"ITMSFNCDataBinderNotificationManagerReference","{AFAFFAD9-AA33-4063-9BCB-6A17EC97D5C1}",["AddManager","RemoveManager"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("AddManager",0,[["AManager",$mod.$rtti["ITMSFNCDataBinderNotificationManager"]]]);
    $r.addMethod("RemoveManager",0,[]);
  });
  rtl.createClass(this,"TTMSFNCDataBinderNotificationManager",pas.Classes.TList,function () {
    this.$init = function () {
      pas.Classes.TList.$init.call(this);
      this.FOwnerInterface = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FOwnerInterface",null);
      pas.Classes.TList.$final.call(this);
    };
    this._AddRef = function () {
      var Result = 0;
      if (this.FOwnerInterface !== null) {
        Result = this.FOwnerInterface._AddRef()}
       else Result = -1;
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      if (this.FOwnerInterface !== null) {
        Result = this.FOwnerInterface._Release()}
       else Result = -1;
      return Result;
    };
    this.HasObject = function (AObject) {
      var Result = false;
      var I = 0;
      var ifn = null;
      try {
        Result = false;
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          ifn = rtl.setIntfL(ifn,rtl.getObject(this.Get(I)));
          if (ifn.GetObject() === AObject) {
            Result = true;
            break;
          };
        };
      } finally {
        rtl._Release(ifn);
      };
      return Result;
    };
    var E_NOINTERFACE = 0x80004002;
    this.QueryInterface = function (IID, Obj) {
      var Result = 0;
      if (this.GetInterface(IID,Obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    this.Notify$1 = function (AObject, AType) {
      var I = 0;
      var ifn = null;
      try {
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          ifn = rtl.setIntfL(ifn,rtl.getObject(this.Get(I)));
          if (ifn.GetObject() === AObject) ifn.Notify(AType);
        };
      } finally {
        rtl._Release(ifn);
      };
    };
    rtl.addIntf(this,$mod.ITMSFNCDataBinderNotificationManager,{Notify: "Notify$1"});
  });
  this.$rtti.$Class("TTMSFNCDataBinder");
  this.$rtti.$Class("TTMSFNCDataBinderItem");
  this.TTMSFNCDataBinderDataLinkMode = {"0": "dlmActiveChanged", dlmActiveChanged: 0, "1": "dlmDataSetChanged", dlmDataSetChanged: 1, "2": "dlmDataSetScrolled", dlmDataSetScrolled: 2, "3": "dlmRecordChanged", dlmRecordChanged: 3, "4": "dlmUpdateData", dlmUpdateData: 4};
  this.$rtti.$Enum("TTMSFNCDataBinderDataLinkMode",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCDataBinderDataLinkMode});
  rtl.createClass(this,"TTMSFNCDataBinderDataLink",pas.DB.TDataLink,function () {
    this.$init = function () {
      pas.DB.TDataLink.$init.call(this);
      this.FDataBinderItem = null;
    };
    this.$final = function () {
      this.FDataBinderItem = undefined;
      pas.DB.TDataLink.$final.call(this);
    };
    this.ActiveChanged = function () {
      this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
    };
    this.DataSetChanged = function () {
      this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetChanged,-1,null);
    };
    this.DataSetScrolled = function (Distance) {
      this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetScrolled,Distance,null);
    };
    this.RecordChanged = function (Field) {
      if (Field != null) this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmRecordChanged,-1,Field);
    };
    this.UpdateData = function () {
      this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData,-1,null);
    };
    this.Create$2 = function (ADataBinderItem) {
      this.FDataBinderItem = ADataBinderItem;
      this.FVisualControl = true;
      return this;
    };
    this.Destroy = function () {
      pas.DB.TDataLink.Destroy.call(this);
    };
  });
  this.TTMSFNCDataBinderBindType = {"0": "dbbtSingleValue", dbbtSingleValue: 0, "1": "dbbtList", dbbtList: 1, "2": "dbbtColumnList", dbbtColumnList: 2, "3": "dbbtGrid", dbbtGrid: 3};
  this.$rtti.$Enum("TTMSFNCDataBinderBindType",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCDataBinderBindType});
  rtl.createClass(this,"TTMSFNCDataBinderPropertyName",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FDataBinderItem = null;
      this.FValue = "";
    };
    this.$final = function () {
      this.FDataBinderItem = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetValue = function (Value) {
      if (this.FValue !== Value) {
        this.FValue = Value;
        if (this.FDataBinderItem != null) this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FDataBinderItem = rtl.as(this.FCollection,$mod.TTMSFNCDataBinderPropertyNames).FOwner$1;
      return this;
    };
    this.Destroy = function () {
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCDataBinderPropertyName.isPrototypeOf(Source)) {
        this.FValue = rtl.as(Source,$mod.TTMSFNCDataBinderPropertyName).FValue;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Value",2,rtl.string,"FValue","SetValue");
  });
  rtl.createClass(this,"TTMSFNCDataBinderPropertyNames",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetDataBinderPropertyNameClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCDataBinderPropertyName;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.GetDataBinderPropertyNameClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCDataBinderFieldName",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FDataBinderItem = null;
      this.FValue = "";
      this.FHTMLTemplate = "";
    };
    this.$final = function () {
      this.FDataBinderItem = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetValue = function (Value) {
      if (this.FValue !== Value) {
        this.FValue = Value;
        if (this.FDataBinderItem != null) this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetHTMLTemplate = function (Value) {
      if (this.FHTMLTemplate !== Value) {
        this.FHTMLTemplate = Value;
        if (this.FDataBinderItem != null) this.FDataBinderItem.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FDataBinderItem = rtl.as(this.FCollection,$mod.TTMSFNCDataBinderFieldNames).FOwner$1;
      return this;
    };
    this.Destroy = function () {
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCDataBinderFieldName.isPrototypeOf(Source)) {
        this.FValue = rtl.as(Source,$mod.TTMSFNCDataBinderFieldName).FValue;
        this.FHTMLTemplate = rtl.as(Source,$mod.TTMSFNCDataBinderFieldName).FHTMLTemplate;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Value",2,rtl.string,"FValue","SetValue");
    $r.addProperty("HTMLTemplate",2,rtl.string,"FHTMLTemplate","SetHTMLTemplate");
  });
  rtl.createClass(this,"TTMSFNCDataBinderFieldNames",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetDataBinderFieldNameClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCDataBinderFieldName;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.GetDataBinderFieldNameClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  this.TTMSFNCDataBinderFindType = {"0": "bftDontCare", bftDontCare: 0, "1": "bftClass", bftClass: 1, "2": "bftString", bftString: 2};
  this.$rtti.$Enum("TTMSFNCDataBinderFindType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCDataBinderFindType});
  rtl.createClass(this,"TTMSFNCDataBinderControlValueMonitor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FActive = false;
      this.FBinderItem = null;
    };
    this.$final = function () {
      this.FBinderItem = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (ABinderItem) {
      pas.System.TObject.Create.call(this);
      this.FActive = false;
      this.FBinderItem = ABinderItem;
      return this;
    };
    this.Destroy = function () {
      this.StopMonitoring();
      pas.System.TObject.Destroy.call(this);
    };
    this.StartMonitoring = function () {
    };
    this.StopMonitoring = function () {
    };
  });
  rtl.createClass(this,"TTMSFNCDataBinderEditLinkMonitor",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FActive = false;
      this.FBinderItem = null;
    };
    this.$final = function () {
      this.FBinderItem = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (ABinderItem) {
      pas.System.TObject.Create.call(this);
      this.FActive = false;
      this.FBinderItem = ABinderItem;
      return this;
    };
    this.Destroy = function () {
      this.StopMonitoring();
      pas.System.TObject.Destroy.call(this);
    };
    this.StartMonitoring = function () {
    };
    this.StopMonitoring = function () {
    };
  });
  rtl.createClass(this,"TTMSFNCDataBinderItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FControlValueMonitor = null;
      this.FEditLinkMonitor = null;
      this.FOwnerInterface = null;
      this.FDirty = false;
      this.FUpdating = false;
      this.FDataBinder = null;
      this.FDataLink = null;
      this.FActive = false;
      this.FBindType = 0;
      this.FObject = null;
      this.FPropertyName = "";
      this.FFieldName = "";
      this.FSubPropertyNames = null;
      this.FSubFieldNames = null;
      this.FColumnsPropertyName = "";
      this.FColumnsSubPropertyName = "";
      this.FBufferCount = 0;
      this.FBooleanStringValue = "";
      this.FHTMLTemplate = "";
      this.FName = "";
    };
    this.$final = function () {
      this.FControlValueMonitor = undefined;
      this.FEditLinkMonitor = undefined;
      rtl.setIntfP(this,"FOwnerInterface",null);
      this.FDataBinder = undefined;
      this.FDataLink = undefined;
      this.FObject = undefined;
      this.FSubPropertyNames = undefined;
      this.FSubFieldNames = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.GetField = function () {
      var Result = null;
      Result = null;
      if (this.CheckDataSet()) {
        if (this.FFieldName !== "") Result = this.FDataLink.GetDataset().FieldByName(this.FFieldName);
      };
      return Result;
    };
    this.GetDataSource = function () {
      var Result = null;
      Result = this.FDataLink.FDataSource;
      return Result;
    };
    this.SetDataSource = function (Value) {
      if (Value === this.FDataLink.FDataSource) return;
      this.FDataLink.SetDataSource(Value);
      if (!(this.FDataLink.FDataSource != null)) {
        this.FSubFieldNames.Clear();
        this.FSubPropertyNames.Clear();
        this.FFieldName = "";
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
      if (Value !== null) Value.FreeNotification(this.FDataBinder);
    };
    this.SetActive = function (Value) {
      if (this.FActive !== Value) {
        this.FActive = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetBindType = function (Value) {
      if (this.FBindType !== Value) {
        this.FBindType = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetObject = function (Value) {
      var m = null;
      var $ir = rtl.createIntfRefs();
      try {
        if ((this.FObject != null) && !(Value != null)) {
          $impl.FManager.Remove(this);
          if (!$impl.FManager.HasObject(this.FObject) && pas.SysUtils.Supports$3(this.FObject,$mod.ITMSFNCDataBinderNotificationManagerReference.$guid,{get: function () {
              return m;
            }, set: function (v) {
              m = v;
            }})) m.RemoveManager();
        };
        if ((this.FObject != null) && (this.FObject !== Value)) this.DestroyMonitors();
        this.FObject = Value;
        if (this.FObject != null) {
          $impl.FManager.Add(this);
          if (pas.SysUtils.Supports$3(this.FObject,$mod.ITMSFNCDataBinderNotificationManagerReference.$guid,{get: function () {
              return m;
            }, set: function (v) {
              m = v;
            }})) m.AddManager($ir.ref(1,rtl.queryIntfT($impl.FManager,$mod.ITMSFNCDataBinderNotificationManager)));
        };
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      } finally {
        $ir.free();
        rtl._Release(m);
      };
    };
    this.SetPropertyName = function (Value) {
      if (this.FPropertyName !== Value) {
        this.FPropertyName = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetFieldName = function (Value) {
      if (this.FFieldName !== Value) {
        this.FFieldName = Value;
        this.DestroyMonitors();
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData,-1,null);
      };
    };
    this.SetColumnsPropertyName = function (Value) {
      if (this.FColumnsPropertyName !== Value) {
        this.FColumnsPropertyName = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetColumnsSubPropertyName = function (Value) {
      if (this.FColumnsSubPropertyName !== Value) {
        this.FColumnsSubPropertyName = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetBufferCount = function (Value) {
      if (this.FBufferCount !== Value) {
        this.FBufferCount = Value;
        if (this.FDataLink != null) this.FDataLink.SetBufferCount(this.FBufferCount);
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.GetBindComponent = function () {
      var Result = null;
      Result = null;
      if ((this.FObject != null) && pas.Classes.TComponent.isPrototypeOf(this.FObject)) Result = this.FObject;
      return Result;
    };
    this.SetBindComponent = function (Value) {
      this.SetObject(Value);
    };
    this.SetBooleanStringValue = function (Value) {
      if (this.FBooleanStringValue !== Value) {
        this.FBooleanStringValue = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.SetHTMLTemplate = function (Value) {
      if (this.FHTMLTemplate !== Value) {
        this.FHTMLTemplate = Value;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.GetObjectInstance = function () {
      var Result = null;
      Result = this.GetObject();
      return Result;
    };
    this.SetObjectInstance = function (Value) {
      this.SetObject(Value);
    };
    this.GetObject = function () {
      var Result = null;
      Result = this.FObject;
      return Result;
    };
    this.GetControlValueMonitor = function () {
      var Result = null;
      if (!(this.FControlValueMonitor != null) && !this.FDataBinder.HasEditLinkMonitor(this.GetObject()) && !this.FDataBinder.HasControlValueMonitor(this.GetObject())) {
        this.FControlValueMonitor = $mod.TTMSFNCDataBinderControlValueMonitor.$create("Create$1",[this]);
        this.FControlValueMonitor.StartMonitoring();
      };
      Result = this.FControlValueMonitor;
      return Result;
    };
    this.GetEditLinkMonitor = function () {
      var Result = null;
      if (!(this.FEditLinkMonitor != null) && !this.FDataBinder.HasEditLinkMonitor(this.GetObject())) {
        this.FEditLinkMonitor = $mod.TTMSFNCDataBinderEditLinkMonitor.$create("Create$1",[this]);
        this.FEditLinkMonitor.StartMonitoring();
      };
      Result = this.FEditLinkMonitor;
      return Result;
    };
    this.Reset = function () {
    };
    this.SetIsReadOnly = function (AValue) {
    };
    this.Modified = function () {
      this.FDirty = true;
    };
    this.GetCanModify = function () {
      var Result = false;
      var f = null;
      Result = false;
      f = this.GetField();
      if (f != null) Result = f.GetCanModify();
      return Result;
    };
    this.IsValidChar = function (AChar) {
      var Result = false;
      var f = null;
      Result = false;
      f = this.GetField();
      if (f != null) {
        if (AChar === "\x00") {
          Result = f.GetCanModify()}
         else Result = f.IsValidChar(AChar);
      };
      return Result;
    };
    this.IsRequired = function () {
      var Result = false;
      var f = null;
      Result = false;
      f = this.GetField();
      if (f != null) Result = f.FRequired;
      return Result;
    };
    this.GetComponent = function () {
      var Result = null;
      Result = null;
      if ((this.GetObject() != null) && pas.Classes.TComponent.isPrototypeOf(this.GetObject())) Result = rtl.as(this.GetObject(),pas.Classes.TComponent);
      return Result;
    };
    this.DestroyMonitors = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FControlValueMonitor;
        }, set: function (v) {
          this.p.FControlValueMonitor = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FEditLinkMonitor;
        }, set: function (v) {
          this.p.FEditLinkMonitor = v;
        }});
    };
    this.DoChanged = function (Sender) {
      this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
    };
    this.Notify = function (AType) {
      var bs = null;
      var r = 0;
      try {
        if (this.CheckDataSet() && !this.FUpdating && !$impl.FGlobalUpdating) {
          var $tmp = AType;
          if ($tmp === $mod.TTMSFNCDataBinderNotificationType.dbntSetActiveRecord) {
            this.FUpdating = true;
            try {
              if (pas.SysUtils.Supports$3(this.GetObject(),$mod.ITMSFNCDataBinderSelection.$guid,{get: function () {
                  return bs;
                }, set: function (v) {
                  bs = v;
                }})) {
                r = bs.DataGetItemIndex() + 1;
                if (r >= 1) this.FDataLink.FDataSource.FDataSet.SetRecNo(r);
              };
            } finally {
              this.FUpdating = false;
            };
          } else if ($tmp === $mod.TTMSFNCDataBinderNotificationType.dbntUpdate) {
            this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData,-1,null)}
           else if ($tmp === $mod.TTMSFNCDataBinderNotificationType.dbntEdit) {
            this.DataSetEdit()}
           else if ($tmp === $mod.TTMSFNCDataBinderNotificationType.dbntValueChanged) {
            this.WriteValueToField()}
           else if ($tmp === $mod.TTMSFNCDataBinderNotificationType.dbntPost) this.DataSetPost();
        };
      } finally {
        rtl._Release(bs);
      };
    };
    this.HasControlValueMonitor = function () {
      var Result = false;
      Result = this.FControlValueMonitor != null;
      return Result;
    };
    this.HasEditLinkMonitor = function () {
      var Result = false;
      Result = this.FEditLinkMonitor != null;
      return Result;
    };
    this.TryGetObjectStringValue = function (AObject, AValue) {
      var Result = false;
      var p = null;
      Result = false;
      AValue.set("");
      if (!(AObject != null)) return Result;
      p = this.InternalFindProperty(AObject,"Text",$mod.TTMSFNCDataBinderFindType.bftString,true);
      if ((p != null) && !pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
        AValue.set(pas.TypInfo.GetStrProp$1(AObject,p));
        Result = true;
        return Result;
      };
      p = this.InternalFindProperty(AObject,"AsString",$mod.TTMSFNCDataBinderFindType.bftString,true);
      if ((p != null) && !pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
        AValue.set(pas.TypInfo.GetStrProp$1(AObject,p));
        Result = true;
      };
      return Result;
    };
    this.TrySetObjectStringValue = function (AObject, AValue) {
      var Result = false;
      var p = null;
      Result = false;
      if (!(AObject != null)) return Result;
      p = this.InternalFindProperty(AObject,"Text",$mod.TTMSFNCDataBinderFindType.bftString,true);
      if ((p != null) && !pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
        pas.TypInfo.SetStrProp$1(AObject,p,AValue);
        Result = true;
        return Result;
      };
      p = this.InternalFindProperty(AObject,"AsString",$mod.TTMSFNCDataBinderFindType.bftString,true);
      if ((p != null) && !pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
        pas.TypInfo.SetStrProp$1(AObject,p,AValue);
        Result = true;
      };
      return Result;
    };
    this.HTMLDBReplace = function (AValue, ADataset) {
      var Result = "";
      var beforetag = "";
      var aftertag = "";
      var fld = "";
      var dbfld = "";
      var i = 0;
      var j = 0;
      var AField = null;
      beforetag = "";
      while (pas.System.Pos("<#",AValue) > 0) {
        i = pas.System.Pos("<#",AValue);
        beforetag = beforetag + pas.System.Copy(AValue,1,i - 1);
        aftertag = pas.System.Copy(AValue,i,AValue.length);
        j = pas.System.Pos(">",aftertag);
        fld = pas.System.Copy(aftertag,1,j - 1);
        pas.System.Delete({get: function () {
            return fld;
          }, set: function (v) {
            fld = v;
          }},1,2);
        pas.System.Delete({get: function () {
            return AValue;
          }, set: function (v) {
            AValue = v;
          }},1,(i + j) - 1);
        dbfld = "";
        if (ADataset != null) {
          if (ADataset.GetActive()) {
            AField = ADataset.FindField(fld);
            if (AField != null) {
              if (AField.$class.IsBlob()) {
                if (AField.FOnGetText != null) {
                  dbfld = AField.GetDisplayText()}
                 else dbfld = AField.GetAsString();
              } else dbfld = AField.GetDisplayText();
            };
          } else dbfld = "(" + fld + ")";
        } else dbfld = "(" + fld + ")";
        beforetag = beforetag + dbfld;
      };
      Result = beforetag + AValue;
      return Result;
    };
    this.GetDisplayName = function () {
      var Result = "";
      if (this.FName !== "") {
        Result = this.FName}
       else Result = "";
      return Result;
    };
    this.InternalFindProperty = function (AObject, AName, AFindType, IncludePublic) {
      var Result = null;
      var ci = null;
      var a = [];
      var p = null;
      var pName = "";
      var I = 0;
      var k = 0;
      Result = null;
      if (!(AObject != null)) return Result;
      ci = AObject.$rtti;
      try {
        a = pas.TypInfo.GetPropList(ci,pas.System.tkProperties,true);
        for (var $l = 0, $end = rtl.length(a) - 1; $l <= $end; $l++) {
          I = $l;
          p = a[I];
          pName = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(p);
          k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
          if ((pas.SysUtils.UpperCase(pName) === pas.SysUtils.UpperCase(AName)) && ((AFindType === $mod.TTMSFNCDataBinderFindType.bftDontCare) || ((AFindType === $mod.TTMSFNCDataBinderFindType.bftClass) && (k === pas.System.TTypeKind.tkClass)) || ((AFindType === $mod.TTMSFNCDataBinderFindType.bftString) && (k in rtl.createSet(pas.System.TTypeKind.tkChar,pas.System.TTypeKind.tkString))))) {
            Result = p;
            break;
          };
        };
      } finally {
      };
      return Result;
    };
    this.FindProperty = function (AObject, AName, AIndex, AFindType) {
      var Result = null;
      var sl = null;
      var I = 0;
      var p = null;
      var o = null;
      o = AObject.get();
      Result = null;
      if (!(o != null)) return Result;
      sl = pas.Classes.TStringList.$create("Create$1");
      try {
        pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Split(".",AName,sl,false);
        for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          p = this.InternalFindProperty(o,sl.Get(I),AFindType,true);
          if (p != null) {
            if ((I === 0) && (sl.GetCount() > 1) && (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p) === pas.System.TTypeKind.tkClass)) {
              o = pas.TypInfo.GetObjectProp$2(o,p);
              if (pas.Classes.TCollection.isPrototypeOf(o)) {
                if ((AIndex >= 0) && (AIndex <= (rtl.as(o,pas.Classes.TCollection).GetCount() - 1))) {
                  o = rtl.as(o,pas.Classes.TCollection).GetItem(AIndex)}
                 else o = rtl.as(o,pas.Classes.TCollection).Add();
              };
            } else {
              Result = p;
              break;
            };
          };
        };
        AObject.set(o);
      } finally {
        sl = rtl.freeLoc(sl);
      };
      return Result;
    };
    this.DoBeforeWriteFieldToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField, AAllow) {
      if (this.FDataBinder != null) this.FDataBinder.DoBeforeWriteFieldToProperty(AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField,AAllow);
    };
    this.DoAfterWriteFieldToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField) {
      if (this.FDataBinder != null) this.FDataBinder.DoAfterWriteFieldToProperty(AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField);
    };
    this.DoBeforeWritePropertyToField = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField, AAllow) {
      if (this.FDataBinder != null) this.FDataBinder.DoBeforeWritePropertyToField(AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField,AAllow);
    };
    this.DoAfterWritePropertyToField = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField) {
      if (this.FDataBinder != null) this.FDataBinder.DoAfterWritePropertyToField(AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField);
    };
    this.DoBeforeWriteHTMLTemplateToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AHTMLTemplate, AAllow) {
      if (this.FDataBinder != null) this.FDataBinder.DoBeforeWriteHTMLTemplateToProperty(AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AHTMLTemplate,AAllow);
    };
    this.DoAfterWriteHTMLTemplateToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AHTMLTemplate) {
      if (this.FDataBinder != null) this.FDataBinder.DoAfterWriteHTMLTemplateToProperty(AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AHTMLTemplate);
    };
    this.WriteFieldToProperty = function (AObject, APropInfo, AField) {
      var a = false;
      var pName = "";
      var cn = "";
      var k = 0;
      var p = null;
      var o = null;
      var i = 0;
      var s = "";
      var dt = 0.0;
      var ui = 0;
      var ob = null;
      var bt = null;
      var ms = null;
      var sl = null;
      var useDisplayText = false;
      if (!(AField != null) || !(AObject != null) || !(APropInfo != null)) return;
      o = AObject;
      p = APropInfo;
      pName = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(p);
      k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
      a = true;
      this.DoBeforeWriteFieldToProperty(o,this,p,pName,k,AField,{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (!a) return;
      try {
        var $tmp = k;
        if ($tmp === pas.System.TTypeKind.tkClass) {
          cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(p);
          ob = pas.TypInfo.GetObjectProp(AObject,pName);
          if (!(ob != null)) return;
          if (pas.Classes.TStrings.isPrototypeOf(ob)) {
            var $tmp1 = AField.FDataType;
            if (($tmp1 === pas.DB.TFieldType.ftString) || ($tmp1 === pas.DB.TFieldType.ftWideString) || ($tmp1 === pas.DB.TFieldType.ftFixedChar) || ($tmp1 === pas.DB.TFieldType.ftFixedWideChar)) {
              if (AField.FOnGetText != null) {
                rtl.as(ob,pas.Classes.TStrings).SetTextStr(AField.GetDisplayText())}
               else rtl.as(ob,pas.Classes.TStrings).SetTextStr(AField.GetAsString())}
             else if (($tmp1 === pas.DB.TFieldType.ftMemo) || ($tmp1 === pas.DB.TFieldType.ftFmtMemo) || ($tmp1 === pas.DB.TFieldType.ftWideMemo) || ($tmp1 === pas.DB.TFieldType.ftOraClob)) {
              if (AField.FOnGetText != null) {
                rtl.as(ob,pas.Classes.TStrings).SetTextStr(AField.GetDisplayText())}
               else rtl.as(ob,pas.Classes.TStrings).SetTextStr(AField.GetAsString())}
             else if (($tmp1 === pas.DB.TFieldType.ftBlob) || ($tmp1 === pas.DB.TFieldType.ftOraBlob)) {
              rtl.as(ob,pas.Classes.TStrings).SetTextStr(AField.GetAsString());
            } else {
              rtl.as(ob,pas.Classes.TStrings).SetTextStr(AField.GetDisplayText());
            };
          } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(ob.$class.ClassType(),"String")) {
            var $tmp2 = AField.FDataType;
            if (($tmp2 === pas.DB.TFieldType.ftString) || ($tmp2 === pas.DB.TFieldType.ftWideString) || ($tmp2 === pas.DB.TFieldType.ftMemo) || ($tmp2 === pas.DB.TFieldType.ftWideMemo)) {
              ob.Clear();
              sl = pas.Classes.TStringList.$create("Create$1");
              try {
                if (AField.FOnGetText != null) {
                  sl.SetTextStr(AField.GetDisplayText())}
                 else sl.SetTextStr(AField.GetAsString());
                for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
                  i = $l;
                  ob.Add(sl.Get(i));
                };
              } finally {
                sl = rtl.freeLoc(sl);
              };
            };
          } else if (pas.Classes.TPersistent.isPrototypeOf(ob)) {
            var $tmp3 = AField.FDataType;
            if (($tmp3 === pas.DB.TFieldType.ftString) || ($tmp3 === pas.DB.TFieldType.ftWideString) || ($tmp3 === pas.DB.TFieldType.ftMemo) || ($tmp3 === pas.DB.TFieldType.ftWideMemo) || ($tmp3 === pas.DB.TFieldType.ftFixedChar)) {
              if (AField.FOnGetText != null) {
                this.TrySetObjectStringValue(ob,AField.GetDisplayText())}
               else this.TrySetObjectStringValue(ob,AField.GetAsString())}
             else {
              this.TrySetObjectStringValue(ob,AField.GetDisplayText());
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkInteger) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
            useDisplayText = (AField.FOnGetText != null) && (AField.FDataType in rtl.createSet(pas.DB.TFieldType.ftString,pas.DB.TFieldType.ftWideString,pas.DB.TFieldType.ftFixedChar,pas.DB.TFieldType.ftFixedWideChar));
            var $tmp4 = AField.FDataType;
            if (($tmp4 === pas.DB.TFieldType.ftSmallint) || ($tmp4 === pas.DB.TFieldType.ftInteger) || ($tmp4 === pas.DB.TFieldType.ftWord)) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger())}
             else if ($tmp4 === pas.DB.TFieldType.ftAutoInc) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger())}
             else if ($tmp4 === pas.DB.TFieldType.ftLongWord) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger());
            } else if ($tmp4 === pas.DB.TFieldType.ftShortint) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger())}
             else if ($tmp4 === pas.DB.TFieldType.ftByte) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger())}
             else if ($tmp4 === pas.DB.TFieldType.ftBoolean) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsBoolean() + 0)}
             else if (($tmp4 === pas.DB.TFieldType.ftFloat) || ($tmp4 === pas.DB.TFieldType.ftCurrency) || ($tmp4 === pas.DB.TFieldType.ftBCD) || ($tmp4 === pas.DB.TFieldType.ftFMTBcd) || ($tmp4 === pas.DB.TFieldType.ftExtended) || ($tmp4 === pas.DB.TFieldType.ftSingle)) {
              pas.TypInfo.SetOrdProp$1(o,p,Math.round(AField.GetAsFloat()))}
             else if (($tmp4 === pas.DB.TFieldType.ftString) || ($tmp4 === pas.DB.TFieldType.ftWideString) || ($tmp4 === pas.DB.TFieldType.ftFixedChar) || ($tmp4 === pas.DB.TFieldType.ftFixedWideChar)) {
              if (useDisplayText) {
                pas.TypInfo.SetOrdProp$1(o,p,pas.SysUtils.StrToIntDef(AField.GetDisplayText(),0))}
               else pas.TypInfo.SetOrdProp$1(o,p,pas.SysUtils.StrToIntDef(AField.GetAsString(),0))}
             else {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger());
            };
          };
        } else if (($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkString)) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
            useDisplayText = AField.FOnGetText != null;
            var $tmp5 = AField.FDataType;
            if (($tmp5 === pas.DB.TFieldType.ftString) || ($tmp5 === pas.DB.TFieldType.ftWideString) || ($tmp5 === pas.DB.TFieldType.ftFixedChar) || ($tmp5 === pas.DB.TFieldType.ftFixedWideChar)) {
              if (useDisplayText) {
                pas.TypInfo.SetStrProp$1(o,p,AField.GetDisplayText())}
               else pas.TypInfo.SetStrProp$1(o,p,AField.GetAsString())}
             else if (($tmp5 === pas.DB.TFieldType.ftMemo) || ($tmp5 === pas.DB.TFieldType.ftFmtMemo) || ($tmp5 === pas.DB.TFieldType.ftWideMemo)) {
              if (AField.FOnGetText != null) {
                pas.TypInfo.SetStrProp$1(o,p,AField.GetDisplayText())}
               else pas.TypInfo.SetStrProp$1(o,p,AField.GetAsString())}
             else if ($tmp5 === pas.DB.TFieldType.ftOraClob) {
              pas.TypInfo.SetStrProp$1(o,p,AField.GetAsString())}
             else if ($tmp5 === pas.DB.TFieldType.ftGuid) {
              if (useDisplayText) {
                pas.TypInfo.SetStrProp$1(o,p,AField.GetDisplayText())}
               else pas.TypInfo.SetStrProp$1(o,p,AField.GetAsString())}
             else {
              pas.TypInfo.SetStrProp$1(o,p,AField.GetDisplayText());
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoDataTypeInfo(p) === rtl.boolean) {
            if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
              var $tmp6 = AField.FDataType;
              if ($tmp6 === pas.DB.TFieldType.ftBoolean) {
                pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsBoolean() + 0)}
               else if (($tmp6 === pas.DB.TFieldType.ftString) || ($tmp6 === pas.DB.TFieldType.ftWideString) || ($tmp6 === pas.DB.TFieldType.ftFixedChar)) {
                if (AField.FOnGetText != null) {
                  s = pas.SysUtils.Trim(pas.SysUtils.UpperCase(AField.GetDisplayText()))}
                 else s = pas.SysUtils.Trim(pas.SysUtils.UpperCase(AField.GetAsString()));
                if (this.FBooleanStringValue !== "") {
                  pas.TypInfo.SetOrdProp$1(o,p,(s === pas.SysUtils.UpperCase(this.FBooleanStringValue)) + 0)}
                 else pas.TypInfo.SetOrdProp$1(o,p,((s === "TRUE") || (s === "T") || (s === "YES") || (s === "Y") || (s === "1")) + 0);
              } else if (($tmp6 === pas.DB.TFieldType.ftInteger) || ($tmp6 === pas.DB.TFieldType.ftSmallint) || ($tmp6 === pas.DB.TFieldType.ftWord) || ($tmp6 === pas.DB.TFieldType.ftShortint) || ($tmp6 === pas.DB.TFieldType.ftByte)) {
                pas.TypInfo.SetOrdProp$1(o,p,(AField.GetAsInteger() !== 0) + 0)}
               else if ($tmp6 === pas.DB.TFieldType.ftLongWord) {
                pas.TypInfo.SetOrdProp$1(o,p,(AField.GetAsInteger() !== 0) + 0);
              } else {
                pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsBoolean() + 0);
              };
            };
          } else {
            if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
              var $tmp7 = AField.FDataType;
              if (($tmp7 === pas.DB.TFieldType.ftString) || ($tmp7 === pas.DB.TFieldType.ftWideString) || ($tmp7 === pas.DB.TFieldType.ftFixedChar)) {
                if (AField.FOnGetText != null) {
                  s = pas.SysUtils.Trim(AField.GetDisplayText())}
                 else s = pas.SysUtils.Trim(AField.GetAsString());
                i = pas.TypInfo.GetEnumValue(pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoDataTypeInfo(p),s);
                if (i >= 0) {
                  pas.TypInfo.SetOrdProp$1(o,p,i)}
                 else pas.TypInfo.SetOrdProp$1(o,p,0);
              } else if (($tmp7 === pas.DB.TFieldType.ftInteger) || ($tmp7 === pas.DB.TFieldType.ftSmallint) || ($tmp7 === pas.DB.TFieldType.ftWord) || ($tmp7 === pas.DB.TFieldType.ftShortint) || ($tmp7 === pas.DB.TFieldType.ftByte)) {
                pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger())}
               else if ($tmp7 === pas.DB.TFieldType.ftLongWord) {
                pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger());
              } else {
                pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger());
              };
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkBool) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
            var $tmp8 = AField.FDataType;
            if ($tmp8 === pas.DB.TFieldType.ftBoolean) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsBoolean() + 0)}
             else if (($tmp8 === pas.DB.TFieldType.ftString) || ($tmp8 === pas.DB.TFieldType.ftWideString)) {
              if (AField.FOnGetText != null) {
                s = pas.SysUtils.Trim(pas.SysUtils.UpperCase(AField.GetDisplayText()))}
               else s = pas.SysUtils.Trim(pas.SysUtils.UpperCase(AField.GetAsString()));
              pas.TypInfo.SetOrdProp$1(o,p,((s === "TRUE") || (s === "T") || (s === "YES") || (s === "Y") || (s === "1")) + 0);
            } else if (($tmp8 === pas.DB.TFieldType.ftInteger) || ($tmp8 === pas.DB.TFieldType.ftSmallint) || ($tmp8 === pas.DB.TFieldType.ftWord)) {
              pas.TypInfo.SetOrdProp$1(o,p,(AField.GetAsInteger() !== 0) + 0)}
             else if ($tmp8 === pas.DB.TFieldType.ftLongWord) {
              pas.TypInfo.SetOrdProp$1(o,p,(AField.GetAsInteger() !== 0) + 0);
            } else {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsBoolean() + 0);
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkDouble) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
            cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(p);
            if ((pas.SysUtils.CompareText(cn,"TDateTime") === 0) || (pas.SysUtils.CompareText(cn,"TDate") === 0) || (pas.SysUtils.CompareText(cn,"TTime") === 0)) {
              var $tmp9 = AField.FDataType;
              if ($tmp9 === pas.DB.TFieldType.ftDate) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsDateTime())}
               else if ($tmp9 === pas.DB.TFieldType.ftTime) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsDateTime())}
               else if (($tmp9 === pas.DB.TFieldType.ftDateTime) || ($tmp9 === pas.DB.TFieldType.ftTimeStamp)) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsDateTime())}
               else if (($tmp9 === pas.DB.TFieldType.ftString) || ($tmp9 === pas.DB.TFieldType.ftWideString)) {
                if (AField.FOnGetText != null) {
                  dt = pas.SysUtils.StrToDateTimeDef(AField.GetDisplayText(),0)}
                 else dt = pas.SysUtils.StrToDateTimeDef(AField.GetAsString(),0);
                pas.TypInfo.SetFloatProp$1(o,p,dt);
              } else if (($tmp9 === pas.DB.TFieldType.ftFloat) || ($tmp9 === pas.DB.TFieldType.ftExtended)) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsFloat())}
               else {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsFloat());
              };
            } else {
              var $tmp10 = AField.FDataType;
              if (($tmp10 === pas.DB.TFieldType.ftFloat) || ($tmp10 === pas.DB.TFieldType.ftCurrency) || ($tmp10 === pas.DB.TFieldType.ftBCD) || ($tmp10 === pas.DB.TFieldType.ftFMTBcd) || ($tmp10 === pas.DB.TFieldType.ftExtended) || ($tmp10 === pas.DB.TFieldType.ftSingle)) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsFloat())}
               else if (($tmp10 === pas.DB.TFieldType.ftInteger) || ($tmp10 === pas.DB.TFieldType.ftSmallint) || ($tmp10 === pas.DB.TFieldType.ftWord)) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsInteger())}
               else if ($tmp10 === pas.DB.TFieldType.ftLongWord) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsFloat());
              } else if ($tmp10 === pas.DB.TFieldType.ftLargeint) {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsLargeInt())}
               else {
                pas.TypInfo.SetFloatProp$1(o,p,AField.GetAsFloat());
              };
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkSet) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) {
            var $tmp11 = AField.FDataType;
            if (($tmp11 === pas.DB.TFieldType.ftInteger) || ($tmp11 === pas.DB.TFieldType.ftSmallint) || ($tmp11 === pas.DB.TFieldType.ftWord)) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger())}
             else if ($tmp11 === pas.DB.TFieldType.ftLongWord) {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger());
            } else if (($tmp11 === pas.DB.TFieldType.ftString) || ($tmp11 === pas.DB.TFieldType.ftWideString)) {}
            else {
              pas.TypInfo.SetOrdProp$1(o,p,AField.GetAsInteger());
            };
          };
        };
        this.DoAfterWriteFieldToProperty(o,this,p,pName,k,AField);
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
        } else throw $e
      };
    };
    this.WritePropertyToField = function (AObject, APropInfo, AField) {
      var a = false;
      var pName = "";
      var cn = "";
      var k = 0;
      var p = null;
      var o = null;
      var b = false;
      var ob = null;
      var bt = null;
      var ms = null;
      var i = 0;
      var s = "";
      var d = 0.0;
      var dt = 0.0;
      var ii = 0;
      var ui = 0;
      var useText = false;
      if (!(AField != null) || !(AObject != null) || !(APropInfo != null)) return;
      if (!AField.GetCanModify()) return;
      o = AObject;
      p = APropInfo;
      pName = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(p);
      k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
      a = true;
      this.DoBeforeWritePropertyToField(o,this,p,pName,k,AField,{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (!a) return;
      try {
        var $tmp = k;
        if ($tmp === pas.System.TTypeKind.tkClass) {
          cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(p);
          ob = pas.TypInfo.GetObjectProp(AObject,pName);
          if (!(ob != null)) return;
          if (pas.Classes.TStrings.isPrototypeOf(ob)) {
            useText = AField.FOnSetText != null;
            var $tmp1 = AField.FDataType;
            if (($tmp1 === pas.DB.TFieldType.ftString) || ($tmp1 === pas.DB.TFieldType.ftWideString) || ($tmp1 === pas.DB.TFieldType.ftFixedChar) || ($tmp1 === pas.DB.TFieldType.ftFixedWideChar)) {
              if (rtl.as(ob,pas.Classes.TStrings).GetCount() > 0) {
                s = rtl.as(ob,pas.Classes.TStrings).Get(0)}
               else s = "";
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s);
            } else if (($tmp1 === pas.DB.TFieldType.ftMemo) || ($tmp1 === pas.DB.TFieldType.ftFmtMemo) || ($tmp1 === pas.DB.TFieldType.ftWideMemo) || ($tmp1 === pas.DB.TFieldType.ftOraClob)) {
              if (useText) {
                AField.SetEditText(rtl.as(ob,pas.Classes.TStrings).GetTextStr())}
               else AField.SetAsString(rtl.as(ob,pas.Classes.TStrings).GetTextStr())}
             else {
              if (useText) {
                AField.SetEditText(rtl.as(ob,pas.Classes.TStrings).GetTextStr())}
               else AField.SetAsString(rtl.as(ob,pas.Classes.TStrings).GetTextStr());
            };
          } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(ob.$class.ClassType(),"String")) {
            useText = AField.FOnSetText != null;
            var $tmp2 = AField.FDataType;
            if (($tmp2 === pas.DB.TFieldType.ftString) || ($tmp2 === pas.DB.TFieldType.ftWideString)) {
              s = "";
              for (var $l = 0, $end = ob.FLength - 1; $l <= $end; $l++) {
                i = $l;
                if (i > 0) s = s + ",";
                s = s + ob.GetItem(i);
              };
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s);
            } else if (($tmp2 === pas.DB.TFieldType.ftMemo) || ($tmp2 === pas.DB.TFieldType.ftWideMemo)) {
              s = "";
              for (var $l1 = 0, $end1 = ob.FLength - 1; $l1 <= $end1; $l1++) {
                i = $l1;
                if (i > 0) s = s + "\r\n";
                s = s + ob.GetItem(i);
              };
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s);
            };
          } else if (pas.Classes.TPersistent.isPrototypeOf(ob)) {
            if (this.TryGetObjectStringValue(ob,{get: function () {
                return s;
              }, set: function (v) {
                s = v;
              }})) {
              useText = AField.FOnSetText != null;
              var $tmp3 = AField.FDataType;
              if (($tmp3 === pas.DB.TFieldType.ftString) || ($tmp3 === pas.DB.TFieldType.ftWideString) || ($tmp3 === pas.DB.TFieldType.ftFixedChar)) {
                if (useText) {
                  AField.SetEditText(s)}
                 else AField.SetAsString(s)}
               else if (($tmp3 === pas.DB.TFieldType.ftMemo) || ($tmp3 === pas.DB.TFieldType.ftWideMemo)) {
                AField.SetAsString(s)}
               else {
                if (s !== "") {
                  if (useText) {
                    AField.SetEditText(s)}
                   else AField.SetAsString(s);
                };
              };
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkInteger) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
            i = pas.TypInfo.GetOrdProp$1(o,p);
            useText = AField.FOnSetText != null;
            var $tmp4 = AField.FDataType;
            if (($tmp4 === pas.DB.TFieldType.ftInteger) || ($tmp4 === pas.DB.TFieldType.ftSmallint) || ($tmp4 === pas.DB.TFieldType.ftWord) || ($tmp4 === pas.DB.TFieldType.ftAutoInc)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsInteger(i)}
             else if ($tmp4 === pas.DB.TFieldType.ftLargeint) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsLargeInt(i)}
             else if ($tmp4 === pas.DB.TFieldType.ftLongWord) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsInteger(i);
            } else if (($tmp4 === pas.DB.TFieldType.ftFloat) || ($tmp4 === pas.DB.TFieldType.ftCurrency) || ($tmp4 === pas.DB.TFieldType.ftBCD) || ($tmp4 === pas.DB.TFieldType.ftFMTBcd)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsFloat(i)}
             else if ($tmp4 === pas.DB.TFieldType.ftBoolean) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.BoolToStr(i !== 0,true))}
               else AField.SetAsBoolean(i !== 0)}
             else if (($tmp4 === pas.DB.TFieldType.ftString) || ($tmp4 === pas.DB.TFieldType.ftWideString)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsString(pas.SysUtils.IntToStr(i))}
             else {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsInteger(i);
            };
          };
        } else if (($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkString)) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
            s = pas.TypInfo.GetStrProp$1(o,p);
            useText = AField.FOnSetText != null;
            var $tmp5 = AField.FDataType;
            if (($tmp5 === pas.DB.TFieldType.ftString) || ($tmp5 === pas.DB.TFieldType.ftWideString) || ($tmp5 === pas.DB.TFieldType.ftFixedChar) || ($tmp5 === pas.DB.TFieldType.ftFixedWideChar)) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s)}
             else if (($tmp5 === pas.DB.TFieldType.ftMemo) || ($tmp5 === pas.DB.TFieldType.ftFmtMemo) || ($tmp5 === pas.DB.TFieldType.ftWideMemo)) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s)}
             else if ($tmp5 === pas.DB.TFieldType.ftGuid) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s)}
             else if (($tmp5 === pas.DB.TFieldType.ftInteger) || ($tmp5 === pas.DB.TFieldType.ftSmallint) || ($tmp5 === pas.DB.TFieldType.ftWord)) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsInteger(pas.SysUtils.StrToIntDef(s,0))}
             else if ($tmp5 === pas.DB.TFieldType.ftLongWord) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsInteger(pas.SysUtils.StrToIntDef(s,0));
            } else if (($tmp5 === pas.DB.TFieldType.ftFloat) || ($tmp5 === pas.DB.TFieldType.ftCurrency)) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsFloat(pas.SysUtils.StrToFloatDef(s,0))}
             else if ($tmp5 === pas.DB.TFieldType.ftBoolean) {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsBoolean((pas.SysUtils.UpperCase(s) === "TRUE") || (s === "1"))}
             else {
              if (useText) {
                AField.SetEditText(s)}
               else AField.SetAsString(s);
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoDataTypeInfo(p) === rtl.boolean) {
            if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
              b = pas.TypInfo.GetOrdProp$1(o,p) != 0;
              useText = AField.FOnSetText != null;
              var $tmp6 = AField.FDataType;
              if ($tmp6 === pas.DB.TFieldType.ftBoolean) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.BoolToStr(b,true))}
                 else AField.SetAsBoolean(b)}
               else if (($tmp6 === pas.DB.TFieldType.ftString) || ($tmp6 === pas.DB.TFieldType.ftWideString)) {
                if (this.FBooleanStringValue !== "") {
                  if (b) {
                    s = this.FBooleanStringValue}
                   else s = "";
                } else s = pas.SysUtils.BoolToStr(b,true);
                if (useText) {
                  AField.SetEditText(s)}
                 else AField.SetAsString(s);
              } else if (($tmp6 === pas.DB.TFieldType.ftInteger) || ($tmp6 === pas.DB.TFieldType.ftSmallint) || ($tmp6 === pas.DB.TFieldType.ftWord)) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(b + 0))}
                 else AField.SetAsInteger(b + 0)}
               else if ($tmp6 === pas.DB.TFieldType.ftLongWord) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(b + 0))}
                 else AField.SetAsInteger(b + 0);
              } else {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.BoolToStr(b,true))}
                 else AField.SetAsBoolean(b);
              };
            };
          } else {
            if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
              i = pas.TypInfo.GetOrdProp$1(o,p);
              useText = AField.FOnSetText != null;
              var $tmp7 = AField.FDataType;
              if (($tmp7 === pas.DB.TFieldType.ftString) || ($tmp7 === pas.DB.TFieldType.ftWideString)) {
                s = pas.TypInfo.GetEnumName(pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoDataTypeInfo(p),i);
                if (useText) {
                  AField.SetEditText(s)}
                 else AField.SetAsString(s);
              } else if ($tmp7 === pas.DB.TFieldType.ftLongWord) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(i))}
                 else AField.SetAsInteger(i);
              } else {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(i))}
                 else AField.SetAsInteger(i);
              };
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkBool) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
            b = pas.TypInfo.GetOrdProp$1(o,p) != 0;
            useText = AField.FOnSetText != null;
            var $tmp8 = AField.FDataType;
            if ($tmp8 === pas.DB.TFieldType.ftBoolean) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.BoolToStr(b,true))}
               else AField.SetAsBoolean(b)}
             else if (($tmp8 === pas.DB.TFieldType.ftString) || ($tmp8 === pas.DB.TFieldType.ftWideString)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.BoolToStr(b,true))}
               else AField.SetAsString(pas.SysUtils.BoolToStr(b,true))}
             else if (($tmp8 === pas.DB.TFieldType.ftInteger) || ($tmp8 === pas.DB.TFieldType.ftSmallint) || ($tmp8 === pas.DB.TFieldType.ftWord)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(b + 0))}
               else AField.SetAsInteger(b + 0)}
             else if ($tmp8 === pas.DB.TFieldType.ftLongWord) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(b + 0))}
               else AField.SetAsInteger(b + 0);
            } else {
              if (useText) {
                AField.SetEditText(pas.SysUtils.BoolToStr(b,true))}
               else AField.SetAsBoolean(b);
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkDouble) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
            d = pas.TypInfo.GetFloatProp$1(o,p);
            useText = AField.FOnSetText != null;
            cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(p);
            if ((pas.SysUtils.CompareText(cn,"TDateTime") === 0) || (pas.SysUtils.CompareText(cn,"TDate") === 0) || (pas.SysUtils.CompareText(cn,"TTime") === 0)) {
              dt = d;
              var $tmp9 = AField.FDataType;
              if (($tmp9 === pas.DB.TFieldType.ftDate) || ($tmp9 === pas.DB.TFieldType.ftDateTime)) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.DateTimeToStr(dt,false))}
                 else AField.SetAsDateTime(dt)}
               else if ($tmp9 === pas.DB.TFieldType.ftTime) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.TimeToStr(pas.System.Frac(dt)))}
                 else AField.SetAsDateTime(pas.System.Frac(dt))}
               else if ($tmp9 === pas.DB.TFieldType.ftTimeStamp) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.DateTimeToStr(dt,false))}
                 else AField.SetAsDateTime(dt)}
               else if (($tmp9 === pas.DB.TFieldType.ftString) || ($tmp9 === pas.DB.TFieldType.ftWideString)) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.DateTimeToStr(dt,false))}
                 else AField.SetAsString(pas.SysUtils.DateTimeToStr(dt,false))}
               else {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.FloatToStr(dt))}
                 else AField.SetAsFloat(dt);
              };
            } else {
              var $tmp10 = AField.FDataType;
              if (($tmp10 === pas.DB.TFieldType.ftFloat) || ($tmp10 === pas.DB.TFieldType.ftCurrency) || ($tmp10 === pas.DB.TFieldType.ftBCD) || ($tmp10 === pas.DB.TFieldType.ftFMTBcd)) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.FloatToStr(d))}
                 else AField.SetAsFloat(d)}
               else if (($tmp10 === pas.DB.TFieldType.ftInteger) || ($tmp10 === pas.DB.TFieldType.ftSmallint) || ($tmp10 === pas.DB.TFieldType.ftWord)) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(Math.round(d)))}
                 else AField.SetAsInteger(Math.round(d))}
               else if ($tmp10 === pas.DB.TFieldType.ftLongWord) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(Math.round(d)))}
                 else AField.SetAsInteger(Math.round(d));
              } else if ($tmp10 === pas.DB.TFieldType.ftLargeint) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.IntToStr(Math.round(d)))}
                 else AField.SetAsLargeInt(Math.round(d))}
               else if (($tmp10 === pas.DB.TFieldType.ftString) || ($tmp10 === pas.DB.TFieldType.ftWideString)) {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.FloatToStr(d))}
                 else AField.SetAsString(pas.SysUtils.FloatToStr(d))}
               else {
                if (useText) {
                  AField.SetEditText(pas.SysUtils.FloatToStr(d))}
                 else AField.SetAsFloat(d);
              };
            };
          };
        } else if ($tmp === pas.System.TTypeKind.tkSet) {
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsWriteOnly(p)) {
            i = pas.TypInfo.GetOrdProp$1(o,p);
            useText = AField.FOnSetText != null;
            var $tmp11 = AField.FDataType;
            if (($tmp11 === pas.DB.TFieldType.ftInteger) || ($tmp11 === pas.DB.TFieldType.ftSmallint) || ($tmp11 === pas.DB.TFieldType.ftWord)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsInteger(i)}
             else if ($tmp11 === pas.DB.TFieldType.ftLongWord) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsInteger(i);
            } else if (($tmp11 === pas.DB.TFieldType.ftString) || ($tmp11 === pas.DB.TFieldType.ftWideString)) {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsString(pas.SysUtils.IntToStr(i))}
             else {
              if (useText) {
                AField.SetEditText(pas.SysUtils.IntToStr(i))}
               else AField.SetAsInteger(i);
            };
          };
        };
        this.DoAfterWritePropertyToField(o,this,p,pName,k,AField);
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
        } else throw $e
      };
    };
    this.WriteHTMLTemplateToProperty = function (AObject, APropInfo, AHTMLTemplate) {
      var a = false;
      var pName = "";
      var k = 0;
      var p = null;
      var o = null;
      var s = "";
      var t = "";
      if ((AHTMLTemplate === "") || !(AObject != null) || !(APropInfo != null)) return;
      o = AObject;
      p = APropInfo;
      pName = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(p);
      k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
      a = true;
      t = AHTMLTemplate;
      this.DoBeforeWriteHTMLTemplateToProperty(o,this,p,pName,k,{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }},{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) {
        var $tmp = k;
        if (($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkString)) {
          s = this.HTMLDBReplace(t,this.FDataLink.GetDataset());
          if (!pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) pas.TypInfo.SetStrProp$1(o,p,s);
        };
        this.DoAfterWriteHTMLTemplateToProperty(o,this,p,pName,k,t);
      };
    };
    this.ClearProperty = function (AObject, APropInfo) {
      var pName = "";
      var cn = "";
      var k = 0;
      var p = null;
      var o = null;
      var i = 0;
      var s = "";
      var b = false;
      var d = 0.0;
      var dt = 0.0;
      var ii = 0;
      var ob = null;
      var bt = null;
      var pic = null;
      if (!(AObject != null) || !(APropInfo != null)) return;
      o = AObject;
      p = APropInfo;
      pName = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(p);
      k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
      try {
        var $tmp = k;
        if ($tmp === pas.System.TTypeKind.tkClass) {
          ob = pas.TypInfo.GetObjectProp$2(o,p);
          if (ob != null) {
            cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(p);
            if (pas.Classes.TCollection.isPrototypeOf(ob)) {
              rtl.as(ob,pas.Classes.TCollection).Clear();
            } else if (pas.Classes.TStrings.isPrototypeOf(ob)) {
              rtl.as(ob,pas.Classes.TStrings).Clear();
            } else if (pas.Classes.TStream.isPrototypeOf(ob)) {
              rtl.as(ob,pas.Classes.TStream).SetSize64(0);
              rtl.as(ob,pas.Classes.TStream).SetPosition(0);
            } else if (pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.isPrototypeOf(ob)) {
              bt = rtl.as(ob,pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap);
              bt.Assign(null);
            } else if (pas["WEBLib.Graphics"].TBitmap.isPrototypeOf(ob)) {
              pic = rtl.as(ob,pas["WEBLib.Graphics"].TBitmap);
              pic.Assign(null);
            } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(ob.$class.ClassType(),"String")) {
              ob.Clear();
            } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(ob.$class.ClassType(),"Integer")) {
              ob.Clear();
            } else if (pas.Classes.TPersistent.isPrototypeOf(ob)) ;
          };
        } else if ($tmp === pas.System.TTypeKind.tkInteger) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          i = 0;
          pas.TypInfo.SetOrdProp$1(o,p,i);
        } else if (($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkString)) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          s = "";
          pas.TypInfo.SetStrProp$1(o,p,s);
        } else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoDataTypeInfo(p) === rtl.boolean) {
            b = false;
            pas.TypInfo.SetOrdProp$1(o,p,b + 0);
          } else {
            i = 0;
            pas.TypInfo.SetOrdProp$1(o,p,i);
          };
        } else if ($tmp === pas.System.TTypeKind.tkBool) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          b = false;
          pas.TypInfo.SetOrdProp$1(o,p,b + 0);
        } else if ($tmp === pas.System.TTypeKind.tkDouble) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(p);
          if ((pas.SysUtils.CompareText(cn,"TDateTime") === 0) || (pas.SysUtils.CompareText(cn,"TDate") === 0) || (pas.SysUtils.CompareText(cn,"TTime") === 0)) {
            dt = 0;
            pas.TypInfo.SetFloatProp$1(o,p,dt);
          } else {
            d = 0.0;
            pas.TypInfo.SetFloatProp$1(o,p,d);
          };
        } else if ($tmp === pas.System.TTypeKind.tkSet) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          i = 0;
          pas.TypInfo.SetOrdProp$1(o,p,i);
        } else if (($tmp === pas.System.TTypeKind.tkArray) || ($tmp === pas.System.TTypeKind.tkDynArray)) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
        } else if ($tmp === pas.System.TTypeKind.tkRecord) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
        } else if ($tmp === pas.System.TTypeKind.tkInterface) {
          if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsReadOnly(p)) return;
          pas.TypInfo.SetInterfaceProp$1(o,p,null);
        };
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
        } else throw $e
      };
    };
    this._AddRef = function () {
      var Result = 0;
      if (this.FOwnerInterface !== null) {
        Result = this.FOwnerInterface._AddRef()}
       else Result = -1;
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      if (this.FOwnerInterface !== null) {
        Result = this.FOwnerInterface._Release()}
       else Result = -1;
      return Result;
    };
    var E_NOINTERFACE = 0x80004002;
    this.QueryInterface = function (IID, Obj) {
      var Result = 0;
      if (this.GetInterface(IID,Obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FDirty = false;
      this.FActive = true;
      this.FBufferCount = 0;
      this.FDataBinder = rtl.as(this.FCollection,$mod.TTMSFNCDataBinderItems).FOwner$1;
      this.FDataLink = $mod.TTMSFNCDataBinderDataLink.$create("Create$2",[this]);
      this.FSubPropertyNames = $mod.TTMSFNCDataBinderPropertyNames.$create("Create$3",[this]);
      this.FSubFieldNames = $mod.TTMSFNCDataBinderFieldNames.$create("Create$3",[this]);
      if ((this.FDataBinder != null) && (this.FDataBinder.GetDataSource() != null)) this.SetDataSource(this.FDataBinder.GetDataSource());
      return this;
    };
    this.Destroy = function () {
      this.DestroyMonitors();
      if ((this.FDataBinder != null) && !this.FDataBinder.IsDestroying()) {
        this.SetObject(null)}
       else {
        this.FObject = null;
        $impl.FManager.Remove(this);
      };
      this.FDataBinder = null;
      rtl.free(this,"FSubPropertyNames");
      rtl.free(this,"FSubFieldNames");
      rtl.free(this,"FDataLink");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      this.FActive = rtl.as(Source,$mod.TTMSFNCDataBinderItem).FActive;
      this.FSubPropertyNames.Assign(rtl.as(Source,$mod.TTMSFNCDataBinderItem).FSubPropertyNames);
      this.FSubFieldNames.Assign(rtl.as(Source,$mod.TTMSFNCDataBinderItem).FSubFieldNames);
      this.FBindType = rtl.as(Source,$mod.TTMSFNCDataBinderItem).FBindType;
      this.FFieldName = rtl.as(Source,$mod.TTMSFNCDataBinderItem).FFieldName;
      this.FHTMLTemplate = rtl.as(Source,$mod.TTMSFNCDataBinderItem).FHTMLTemplate;
      this.FPropertyName = rtl.as(Source,$mod.TTMSFNCDataBinderItem).FPropertyName;
      this.FObject = rtl.as(Source,$mod.TTMSFNCDataBinderItem).GetObject();
      this.FColumnsPropertyName = rtl.as(Source,$mod.TTMSFNCDataBinderItem).FColumnsPropertyName;
      this.SetDataSource(rtl.as(Source,$mod.TTMSFNCDataBinderItem).GetDataSource());
    };
    this.CheckDataSet = function () {
      var Result = false;
      Result = this.FActive && (this.FDataLink.GetDataset() != null) && this.FDataLink.GetDataset().GetActive();
      return Result;
    };
    this.GetRecordCount = function () {
      var Result = 0;
      Result = 0;
      if (!this.CheckDataSet()) return Result;
      if (this.GetDataSource().FState === pas.DB.TDataSetState.dsSetKey) {
        Result = 1}
       else {
        Result = this.GetDataSource().FDataSet.GetRecordCount();
        if (this.FDataLink.GetDataset().FState in rtl.createSet(pas.DB.TDataSetState.dsInsert)) Result = Result + 1;
      };
      return Result;
    };
    this.HasDirty = function () {
      var Result = false;
      var I = 0;
      Result = false;
      if (this.FDataBinder != null) {
        for (var $l = 0, $end = this.FDataBinder.ItemCount() - 1; $l <= $end; $l++) {
          I = $l;
          if (this.FDataBinder.GetItems().GetItemEx(I).FDirty) {
            Result = true;
            break;
          };
        };
      };
      return Result;
    };
    this.UpdateDataLink = function (AMode, ADistance, AField) {
      var $Self = this;
      var p = null;
      var pcol = null;
      var psub = null;
      var f = null;
      var h = "";
      var k = 0;
      var o = null;
      var oc = null;
      var no = null;
      var its = null;
      var sl = null;
      var gls = null;
      var gli = null;
      var itv = null;
      var it = null;
      var cit = null;
      var col = null;
      var colit = null;
      var I = 0;
      var J = 0;
      var L = 0;
      var cb = pas.DB.TBookmark.$new();
      var ai = 0;
      var dbb = null;
      var dbg = null;
      var em = false;
      var um = false;
      var elm = null;
      var cvm = null;
      function UpdateItem(AItem) {
        var kj = 0;
        for (var $l = 0, $end = $Self.FSubPropertyNames.GetCount() - 1; $l <= $end; $l++) {
          kj = $l;
          if ((kj >= 0) && (kj <= ($Self.FSubFieldNames.GetCount() - 1))) {
            f = null;
            if ($Self.FSubFieldNames.GetItemEx(kj).FValue !== "") f = $Self.FDataLink.GetDataset().FieldByName($Self.FSubFieldNames.GetItemEx(kj).FValue);
            if (f != null) {
              itv = AItem;
              psub = $Self.FindProperty({get: function () {
                  return itv;
                }, set: function (v) {
                  itv = v;
                }},$Self.FSubPropertyNames.GetItemEx(kj).FValue,kj,$mod.TTMSFNCDataBinderFindType.bftDontCare);
              if (psub != null) $Self.WriteFieldToProperty(itv,psub,f);
            } else if ($Self.FSubFieldNames.GetItemEx(kj).FHTMLTemplate !== "") {
              itv = AItem;
              psub = $Self.FindProperty({get: function () {
                  return itv;
                }, set: function (v) {
                  itv = v;
                }},$Self.FSubPropertyNames.GetItemEx(kj).FValue,kj,$mod.TTMSFNCDataBinderFindType.bftDontCare);
              if (psub != null) $Self.WriteHTMLTemplateToProperty(itv,psub,$Self.FSubFieldNames.GetItemEx(kj).FHTMLTemplate);
            };
          } else if ($Self.FFieldName !== "") {
            f = $Self.FDataLink.GetDataset().FieldByName($Self.FFieldName);
            if (f != null) {
              itv = AItem;
              psub = $Self.FindProperty({get: function () {
                  return itv;
                }, set: function (v) {
                  itv = v;
                }},$Self.FSubPropertyNames.GetItemEx(kj).FValue,kj,$mod.TTMSFNCDataBinderFindType.bftDontCare);
              if (psub != null) $Self.WriteFieldToProperty(itv,psub,f);
            };
          } else if ($Self.FHTMLTemplate !== "") {
            itv = AItem;
            psub = $Self.FindProperty({get: function () {
                return itv;
              }, set: function (v) {
                itv = v;
              }},$Self.FSubPropertyNames.GetItemEx(kj).FValue,kj,$mod.TTMSFNCDataBinderFindType.bftDontCare);
            if (psub != null) $Self.WriteHTMLTemplateToProperty(itv,psub,$Self.FHTMLTemplate);
          };
        };
      };
      function DoBeginUpdate() {
        try {
          $Self.FUpdating = true;
          $impl.FGlobalUpdating = true;
          if (pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.isPrototypeOf(no)) {
            rtl.as(no,pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent).BeginUpdate()}
           else if (pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.isPrototypeOf(no)) {
            rtl.as(no,pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl).BeginUpdate()}
           else if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderGrid.$guid,{get: function () {
              return dbg;
            }, set: function (v) {
              dbg = v;
            }})) {
            dbg.DataBeginUpdate()}
           else if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderBase.$guid,{get: function () {
              return dbb;
            }, set: function (v) {
              dbb = v;
            }})) dbb.DataBeginUpdate();
        } finally {
          rtl._Release(dbg);
          rtl._Release(dbb);
        };
      };
      function DoEndUpdate() {
        try {
          if (pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.isPrototypeOf(no)) {
            rtl.as(no,pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent).EndUpdate()}
           else if (pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.isPrototypeOf(no)) {
            rtl.as(no,pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl).EndUpdate()}
           else if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderGrid.$guid,{get: function () {
              return dbg;
            }, set: function (v) {
              dbg = v;
            }})) {
            dbg.DataEndUpdate()}
           else if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderBase.$guid,{get: function () {
              return dbb;
            }, set: function (v) {
              dbb = v;
            }})) dbb.DataEndUpdate();
          $Self.FUpdating = false;
          $impl.FGlobalUpdating = false;
        } finally {
          rtl._Release(dbg);
          rtl._Release(dbb);
        };
      };
      function SetActiveItemIndex() {
        var bs = null;
        try {
          if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderSelection.$guid,{get: function () {
              return bs;
            }, set: function (v) {
              bs = v;
            }})) {
            if (!$Self.DataSetIsInserting()) {
              bs.DataSetItemIndex($Self.FDataLink.FDataSource.FDataSet.GetRecNo() - 1)}
             else bs.DataSetItemIndex(bs.DataGetItemIndex());
          };
        } finally {
          rtl._Release(bs);
        };
      };
      function GetActiveItemIndex() {
        var Result = 0;
        var bs = null;
        try {
          Result = -1;
          if (!$Self.DataSetIsInserting()) {
            Result = $Self.FDataLink.FDataSource.FDataSet.GetRecNo() - 1}
           else {
            if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderSelection.$guid,{get: function () {
                return bs;
              }, set: function (v) {
                bs = v;
              }})) Result = bs.DataGetItemIndex();
          };
        } finally {
          rtl._Release(bs);
        };
        return Result;
      };
      try {
        if (this.FUpdating || $impl.FGlobalUpdating) return;
        if ((pas.Classes.TComponentStateItem.csDestroying in this.FDataBinder.FComponentState) || (this.FDataBinder.FUpdateCount$1 > 0)) return;
        if (!(this.GetObject() != null)) return;
        if ((this.FPropertyName === "") && (this.FBindType !== $mod.TTMSFNCDataBinderBindType.dbbtGrid)) return;
        p = null;
        no = this.GetObject();
        if (!(this.FBindType === $mod.TTMSFNCDataBinderBindType.dbbtGrid)) {
          p = this.FindProperty({get: function () {
              return no;
            }, set: function (v) {
              no = v;
            }},this.FPropertyName,-1,$mod.TTMSFNCDataBinderFindType.bftDontCare);
          if (!(p != null)) return;
        };
        DoBeginUpdate();
        try {
          if (this.CheckDataSet() && this.FDataBinder.FActive) {
            if (this.FDataLink.FReadOnly && (AMode === $mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData)) {
              DoEndUpdate();
              return;
            };
            em = (this.FDataLink.GetDataset().FState in rtl.createSet(pas.DB.TDataSetState.dsEdit,pas.DB.TDataSetState.dsInsert)) && (AMode === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetChanged);
            um = (this.FDataLink.GetDataset().FState in rtl.createSet(pas.DB.TDataSetState.dsEdit,pas.DB.TDataSetState.dsInsert)) && (AMode === $mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData) && this.FDirty;
            ai = GetActiveItemIndex();
            var $tmp = this.FBindType;
            if ($tmp === $mod.TTMSFNCDataBinderBindType.dbbtSingleValue) {
              elm = this.GetEditLinkMonitor();
              if ((elm != null) && !elm.FActive) elm.StartMonitoring();
              cvm = this.GetControlValueMonitor();
              if ((cvm != null) && !cvm.FActive) cvm.StartMonitoring();
              if (this.FFieldName !== "") {
                f = this.FDataLink.GetDataset().FieldByName(this.FFieldName);
                if (f != null) {
                  if (um) {
                    this.WritePropertyToField(no,p,f);
                    this.FDirty = false;
                  } else if (em) {
                    this.ClearProperty(no,p)}
                   else this.WriteFieldToProperty(no,p,f);
                };
              } else if ((this.FHTMLTemplate !== "") && (AMode !== $mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData)) this.WriteHTMLTemplateToProperty(no,p,this.FHTMLTemplate);
            } else if ($tmp === $mod.TTMSFNCDataBinderBindType.dbbtColumnList) {
              var $tmp1 = AMode;
              if (($tmp1 === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetChanged) || ($tmp1 === $mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged)) {
                k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
                var $tmp2 = k;
                if ($tmp2 === pas.System.TTypeKind.tkClass) {
                  o = pas.TypInfo.GetObjectProp$2(no,p);
                  pcol = this.FindProperty({get: function () {
                      return no;
                    }, set: function (v) {
                      no = v;
                    }},this.FColumnsPropertyName,-1,$mod.TTMSFNCDataBinderFindType.bftDontCare);
                  oc = null;
                  if (pcol != null) oc = pas.TypInfo.GetObjectProp$2(no,pcol);
                  if (oc != null) {
                    its = null;
                    if ((o != null) && pas.Classes.TCollection.isPrototypeOf(o)) {
                      its = rtl.as(o,pas.Classes.TCollection);
                      if (em) {
                        if (ai > -1) {
                          its.Insert(ai);
                          SetActiveItemIndex();
                        };
                        DoEndUpdate();
                        return;
                      };
                      its.Clear();
                    };
                    if (pas.Classes.TCollection.isPrototypeOf(oc)) {
                      col = rtl.as(oc,pas.Classes.TCollection);
                      col.Clear();
                      for (var $l = 0, $end = this.FDataLink.GetDataset().GetfieldCount() - 1; $l <= $end; $l++) {
                        I = $l;
                        colit = col.Add();
                        f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                        if (f != null) {
                          if (this.FColumnsSubPropertyName !== "") {
                            psub = this.FindProperty({get: function () {
                                return colit;
                              }, set: function (v) {
                                colit = v;
                              }},this.FColumnsSubPropertyName,-1,$mod.TTMSFNCDataBinderFindType.bftString);
                            if (psub != null) pas.TypInfo.SetStrProp$1(colit,psub,f.FFieldName);
                          };
                        };
                      };
                      if (its != null) {
                        this.FDataLink.GetDataset().DisableControls();
                        cb.$assign(this.FDataLink.GetDataset().GetBookmark());
                        this.FDataLink.GetDataset().First();
                        try {
                          while (!this.FDataLink.GetDataset().GetEOF()) {
                            it = its.Add();
                            cit = it;
                            for (var $l1 = 0, $end1 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l1 <= $end1; $l1++) {
                              I = $l1;
                              f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                              if (f != null) {
                                for (var $l2 = 0, $end2 = this.FSubPropertyNames.GetCount() - 1; $l2 <= $end2; $l2++) {
                                  J = $l2;
                                  itv = cit;
                                  psub = this.FindProperty({get: function () {
                                      return itv;
                                    }, set: function (v) {
                                      itv = v;
                                    }},this.FSubPropertyNames.GetItemEx(J).FValue,-1,$mod.TTMSFNCDataBinderFindType.bftDontCare);
                                  if (psub != null) this.WriteFieldToProperty(itv,psub,f);
                                };
                              };
                            };
                            this.FDataLink.GetDataset().Next();
                          };
                        } finally {
                          this.FDataLink.GetDataset().GotoBookmark(cb);
                          this.FDataLink.GetDataset().FreeBookmark(pas.DB.TBookmark.$clone(cb));
                          this.FDataLink.GetDataset().EnableControls();
                        };
                        SetActiveItemIndex();
                      };
                    };
                  };
                };
              } else if ($tmp1 === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetScrolled) {
                SetActiveItemIndex()}
               else if ($tmp1 === $mod.TTMSFNCDataBinderDataLinkMode.dlmRecordChanged) {
                k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
                var $tmp3 = k;
                if ($tmp3 === pas.System.TTypeKind.tkClass) {
                  o = pas.TypInfo.GetObjectProp$2(no,p);
                  pcol = this.FindProperty({get: function () {
                      return no;
                    }, set: function (v) {
                      no = v;
                    }},this.FColumnsPropertyName,-1,$mod.TTMSFNCDataBinderFindType.bftDontCare);
                  oc = null;
                  if (pcol != null) oc = pas.TypInfo.GetObjectProp$2(no,pcol);
                  if (oc != null) {
                    its = null;
                    if ((o != null) && pas.Classes.TCollection.isPrototypeOf(o)) its = rtl.as(o,pas.Classes.TCollection);
                    if (pas.Classes.TCollection.isPrototypeOf(oc)) {
                      col = rtl.as(oc,pas.Classes.TCollection);
                      for (var $l3 = 0, $end3 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l3 <= $end3; $l3++) {
                        I = $l3;
                        if ((I >= 0) && (I <= (col.GetCount() - 1))) {
                          colit = col.GetItem(I);
                          f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                          if (f != null) {
                            if (this.FColumnsSubPropertyName !== "") {
                              psub = this.FindProperty({get: function () {
                                  return colit;
                                }, set: function (v) {
                                  colit = v;
                                }},this.FColumnsSubPropertyName,0,$mod.TTMSFNCDataBinderFindType.bftString);
                              if (psub != null) pas.TypInfo.SetStrProp$1(colit,psub,f.FFieldName);
                            };
                          };
                        };
                      };
                      if (its != null) {
                        try {
                          if ((ai >= 0) && (ai <= (its.GetCount() - 1))) {
                            it = its.GetItem(ai);
                            cit = it;
                            for (var $l4 = 0, $end4 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l4 <= $end4; $l4++) {
                              I = $l4;
                              f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                              if (f != null) {
                                for (var $l5 = 0, $end5 = this.FSubPropertyNames.GetCount() - 1; $l5 <= $end5; $l5++) {
                                  J = $l5;
                                  itv = cit;
                                  psub = this.FindProperty({get: function () {
                                      return itv;
                                    }, set: function (v) {
                                      itv = v;
                                    }},this.FSubPropertyNames.GetItemEx(J).FValue,I,$mod.TTMSFNCDataBinderFindType.bftDontCare);
                                  if (psub != null) this.WriteFieldToProperty(itv,psub,f);
                                };
                              };
                            };
                          };
                        } finally {
                        };
                      };
                    };
                  };
                };
              } else if ($tmp1 === $mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData) this.FDirty = false;
            } else if ($tmp === $mod.TTMSFNCDataBinderBindType.dbbtGrid) {
              var $tmp4 = AMode;
              if (($tmp4 === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetChanged) || ($tmp4 === $mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged)) {
                if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderGrid.$guid,{get: function () {
                    return dbg;
                  }, set: function (v) {
                    dbg = v;
                  }})) {
                  if (em) {
                    if (ai > -1) {
                      dbg.DataInsertRow(ai);
                      SetActiveItemIndex();
                    };
                    DoEndUpdate();
                    return;
                  };
                  dbg.SetDataColumnCount(this.FDataLink.GetDataset().GetfieldCount());
                  dbg.SetDataRowCount(this.GetRecordCount());
                  for (var $l6 = 0, $end6 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l6 <= $end6; $l6++) {
                    I = $l6;
                    f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                    if (f != null) dbg.SetDataHeader(I,f.FFieldName);
                  };
                  this.FDataLink.GetDataset().DisableControls();
                  cb.$assign(this.FDataLink.GetDataset().GetBookmark());
                  this.FDataLink.GetDataset().First();
                  try {
                    L = 0;
                    while (!this.FDataLink.GetDataset().GetEOF()) {
                      for (var $l7 = 0, $end7 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l7 <= $end7; $l7++) {
                        I = $l7;
                        f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                        if (f != null) dbg.SetDataValue(I,L,f.GetDisplayText());
                      };
                      this.FDataLink.GetDataset().Next();
                      L += 1;
                    };
                  } finally {
                    this.FDataLink.GetDataset().GotoBookmark(cb);
                    this.FDataLink.GetDataset().FreeBookmark(pas.DB.TBookmark.$clone(cb));
                    this.FDataLink.GetDataset().EnableControls();
                  };
                  SetActiveItemIndex();
                };
              } else if ($tmp4 === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetScrolled) {
                SetActiveItemIndex()}
               else if ($tmp4 === $mod.TTMSFNCDataBinderDataLinkMode.dlmRecordChanged) {
                if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderGrid.$guid,{get: function () {
                    return dbg;
                  }, set: function (v) {
                    dbg = v;
                  }})) {
                  dbg.SetDataColumnCount(this.FDataLink.GetDataset().GetfieldCount());
                  for (var $l8 = 0, $end8 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l8 <= $end8; $l8++) {
                    I = $l8;
                    f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                    if (f != null) dbg.SetDataHeader(I,f.FFieldName);
                  };
                  try {
                    if ((ai >= 0) && (ai <= (dbg.GetDataRowCount() - 1))) {
                      for (var $l9 = 0, $end9 = this.FDataLink.GetDataset().GetfieldCount() - 1; $l9 <= $end9; $l9++) {
                        I = $l9;
                        f = this.FDataLink.GetDataset().FFieldList.GetField(I);
                        if (f != null) dbg.SetDataValue(I,ai,f.GetDisplayText());
                      };
                    };
                  } finally {
                  };
                };
              } else if ($tmp4 === $mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData) this.FDirty = false;
            } else if ($tmp === $mod.TTMSFNCDataBinderBindType.dbbtList) {
              var $tmp5 = AMode;
              if (($tmp5 === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetChanged) || ($tmp5 === $mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged)) {
                if ((this.FSubFieldNames.GetCount() > 0) || (this.FFieldName !== "") || (this.FHTMLTemplate !== "")) {
                  k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
                  var $tmp6 = k;
                  if ($tmp6 === pas.System.TTypeKind.tkClass) {
                    o = pas.TypInfo.GetObjectProp$2(no,p);
                    if (o != null) {
                      its = null;
                      sl = null;
                      gls = null;
                      gli = null;
                      if (pas.Classes.TCollection.isPrototypeOf(o)) {
                        its = rtl.as(o,pas.Classes.TCollection);
                        if (em) {
                          if (ai > -1) {
                            its.Insert(ai);
                            SetActiveItemIndex();
                          };
                          DoEndUpdate();
                          return;
                        };
                        its.Clear();
                      } else if (pas.Classes.TStrings.isPrototypeOf(o)) {
                        sl = rtl.as(o,pas.Classes.TStrings);
                        if (em) {
                          if (ai > -1) {
                            sl.Insert(ai,"");
                            SetActiveItemIndex();
                          };
                          DoEndUpdate();
                          return;
                        };
                        sl.Clear();
                      } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(o.$class.ClassType(),"String")) {
                        gls = o;
                        if (em) {
                          if (ai > -1) {
                            gls.Insert(ai,"");
                            SetActiveItemIndex();
                          };
                          DoEndUpdate();
                          return;
                        };
                        gls.Clear();
                      } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(o.$class.ClassType(),"Integer")) {
                        gli = o;
                        if (em) {
                          if (ai > -1) {
                            gli.Insert(ai,0);
                            SetActiveItemIndex();
                          };
                          DoEndUpdate();
                          return;
                        };
                        gli.Clear();
                      };
                      this.FDataLink.GetDataset().DisableControls();
                      cb.$assign(this.FDataLink.GetDataset().GetBookmark());
                      this.FDataLink.GetDataset().First();
                      try {
                        while (!this.FDataLink.GetDataset().GetEOF()) {
                          if (its != null) {
                            it = its.Add();
                            UpdateItem(it);
                          } else if ((this.FSubFieldNames.GetCount() > 0) || (this.FFieldName !== "") || (this.FHTMLTemplate !== "")) {
                            f = null;
                            if ((this.FSubFieldNames.GetCount() > 0) && (this.FSubFieldNames.GetItemEx(0).FValue !== "")) {
                              f = this.FDataLink.GetDataset().FieldByName(this.FSubFieldNames.GetItemEx(0).FValue)}
                             else if (this.FFieldName !== "") f = this.FDataLink.GetDataset().FieldByName(this.FFieldName);
                            if (f != null) {
                              if (sl != null) {
                                sl.Add(f.GetAsString())}
                               else if (gls != null) {
                                gls.Add(f.GetAsString())}
                               else if (gli != null) gli.Add(f.GetAsInteger());
                            } else {
                              if ((this.FSubFieldNames.GetCount() > 0) && (this.FSubFieldNames.GetItemEx(0).FHTMLTemplate !== "")) {
                                h = this.HTMLDBReplace(this.FSubFieldNames.GetItemEx(0).FHTMLTemplate,this.FDataLink.GetDataset())}
                               else h = this.HTMLDBReplace(this.FHTMLTemplate,this.FDataLink.GetDataset());
                              if (sl != null) {
                                sl.Add(h)}
                               else if (gls != null) gls.Add(h);
                            };
                          };
                          this.FDataLink.GetDataset().Next();
                        };
                      } finally {
                        this.FDataLink.GetDataset().GotoBookmark(cb);
                        this.FDataLink.GetDataset().FreeBookmark(pas.DB.TBookmark.$clone(cb));
                        this.FDataLink.GetDataset().EnableControls();
                      };
                      SetActiveItemIndex();
                    };
                  };
                };
              } else if ($tmp5 === $mod.TTMSFNCDataBinderDataLinkMode.dlmDataSetScrolled) {
                SetActiveItemIndex()}
               else if ($tmp5 === $mod.TTMSFNCDataBinderDataLinkMode.dlmRecordChanged) {
                if ((this.FSubFieldNames.GetCount() > 0) || (this.FFieldName !== "") || (this.FHTMLTemplate !== "")) {
                  k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
                  var $tmp7 = k;
                  if ($tmp7 === pas.System.TTypeKind.tkClass) {
                    o = pas.TypInfo.GetObjectProp$2(no,p);
                    if (o != null) {
                      its = null;
                      sl = null;
                      gls = null;
                      gli = null;
                      if (pas.Classes.TCollection.isPrototypeOf(o)) {
                        its = rtl.as(o,pas.Classes.TCollection)}
                       else if (pas.Classes.TStrings.isPrototypeOf(o)) {
                        sl = rtl.as(o,pas.Classes.TStrings)}
                       else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(o.$class.ClassType(),"String")) {
                        gls = o}
                       else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(o.$class.ClassType(),"Integer")) gli = o;
                      try {
                        if (its != null) {
                          if ((ai >= 0) && (ai <= (its.GetCount() - 1))) {
                            it = its.GetItem(ai);
                            UpdateItem(it);
                          };
                        } else if ((this.FSubFieldNames.GetCount() > 0) || (this.FFieldName !== "") || (this.FHTMLTemplate !== "")) {
                          if ((this.FSubFieldNames.GetCount() > 0) && (this.FSubFieldNames.GetItemEx(0).FValue !== "")) {
                            f = this.FDataLink.GetDataset().FieldByName(this.FSubFieldNames.GetItemEx(0).FValue)}
                           else f = this.FDataLink.GetDataset().FieldByName(this.FFieldName);
                          if (f != null) {
                            if (sl != null) {
                              if ((ai >= 0) && (ai <= (sl.GetCount() - 1))) sl.Put(ai,f.GetAsString());
                            } else if (gls != null) {
                              if ((ai >= 0) && (ai <= (gls.FLength - 1))) gls.SetItem(ai,f.GetAsString());
                            } else if (gli != null) {
                              if ((ai >= 0) && (ai <= (gli.FLength - 1))) gli.SetItem(ai,f.GetAsInteger());
                            };
                          } else {
                            h = this.HTMLDBReplace(this.FHTMLTemplate,this.FDataLink.GetDataset());
                            if (sl != null) {
                              if ((ai >= 0) && (ai <= (sl.GetCount() - 1))) sl.Put(ai,h);
                            } else if (gls != null) {
                              if ((ai >= 0) && (ai <= (gls.FLength - 1))) gls.SetItem(ai,h);
                            };
                          };
                        };
                      } finally {
                      };
                    };
                  };
                };
              } else if ($tmp5 === $mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData) this.FDirty = false;
            };
          } else {
            var $tmp8 = this.FBindType;
            if ($tmp8 === $mod.TTMSFNCDataBinderBindType.dbbtSingleValue) {
              this.ClearProperty(no,p)}
             else if ($tmp8 === $mod.TTMSFNCDataBinderBindType.dbbtColumnList) {
              k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
              var $tmp9 = k;
              if ($tmp9 === pas.System.TTypeKind.tkClass) {
                o = pas.TypInfo.GetObjectProp$2(no,p);
                pcol = this.FindProperty({get: function () {
                    return no;
                  }, set: function (v) {
                    no = v;
                  }},this.FColumnsPropertyName,-1,$mod.TTMSFNCDataBinderFindType.bftDontCare);
                oc = null;
                if (pcol != null) oc = pas.TypInfo.GetObjectProp$2(no,pcol);
                if ((o != null) && pas.Classes.TCollection.isPrototypeOf(o)) {
                  its = rtl.as(o,pas.Classes.TCollection);
                  its.Clear();
                };
                if ((oc != null) && pas.Classes.TCollection.isPrototypeOf(oc)) {
                  col = rtl.as(oc,pas.Classes.TCollection);
                  col.Clear();
                };
              };
            } else if ($tmp8 === $mod.TTMSFNCDataBinderBindType.dbbtGrid) {
              if (pas.SysUtils.Supports$3(no,$mod.ITMSFNCDataBinderGrid.$guid,{get: function () {
                  return dbg;
                }, set: function (v) {
                  dbg = v;
                }})) dbg.ClearData();
            } else if ($tmp8 === $mod.TTMSFNCDataBinderBindType.dbbtList) {
              k = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoType(p);
              var $tmp10 = k;
              if ($tmp10 === pas.System.TTypeKind.tkClass) {
                o = pas.TypInfo.GetObjectProp$2(no,p);
                if (o != null) {
                  if (pas.Classes.TCollection.isPrototypeOf(o)) {
                    col = rtl.as(o,pas.Classes.TCollection);
                    col.Clear();
                  } else if (pas.Classes.TStrings.isPrototypeOf(o)) {
                    sl = rtl.as(o,pas.Classes.TStrings);
                    sl.Clear();
                  } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(o.$class.ClassType(),"String")) {
                    gls = o;
                    gls.Clear();
                  } else if (pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.IsGenericList(o.$class.ClassType(),"Integer")) {
                    gli = o;
                    gli.Clear();
                  };
                };
              };
            };
          };
        } finally {
          DoEndUpdate();
        };
      } finally {
        rtl._Release(dbg);
      };
    };
    this.WriteValueToField = function () {
      if (this.CheckDataSet() && (this.DataSetIsEditing() || this.DataSetIsInserting())) {
        this.FDirty = true;
        this.UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmUpdateData,-1,null);
      };
    };
    this.DataSetLocate = function (AKeyFieldNames, AKeyValues) {
      var Result = false;
      Result = false;
      if (this.CheckDataSet()) Result = this.FDataLink.GetDataset().Locate(AKeyFieldNames,AKeyValues,{});
      return Result;
    };
    this.DataSetIsEditing = function () {
      var Result = false;
      Result = false;
      if (this.CheckDataSet()) Result = this.FDataLink.GetDataset().FState === pas.DB.TDataSetState.dsEdit;
      return Result;
    };
    this.DataSetIsInserting = function () {
      var Result = false;
      Result = false;
      if (this.CheckDataSet()) Result = this.FDataLink.GetDataset().FState === pas.DB.TDataSetState.dsInsert;
      return Result;
    };
    this.NotifyValueChanged = function () {
      this.Notify($mod.TTMSFNCDataBinderNotificationType.dbntValueChanged);
    };
    this.NotifyEdit = function () {
      this.Notify($mod.TTMSFNCDataBinderNotificationType.dbntEdit);
    };
    this.NotifyPost = function () {
      this.Notify($mod.TTMSFNCDataBinderNotificationType.dbntPost);
    };
    this.NotifyUpdate = function () {
      this.Notify($mod.TTMSFNCDataBinderNotificationType.dbntUpdate);
    };
    this.NotifySetActiveRecord = function () {
      this.Notify($mod.TTMSFNCDataBinderNotificationType.dbntSetActiveRecord);
    };
    this.DataSetEdit = function () {
      if (this.CheckDataSet() && !this.DataSetIsEditing()) this.FDataLink.GetDataset().Edit();
    };
    this.DataSetPost = function () {
      if (this.CheckDataSet() && this.DataSetIsEditing()) {
        if (!this.HasDirty()) this.FDataLink.GetDataset().Post();
      };
    };
    this.DataSetInsert = function () {
      if (this.CheckDataSet()) this.FDataLink.GetDataset().Insert$1();
    };
    this.DataSetDelete = function () {
      if (this.CheckDataSet()) this.FDataLink.GetDataset().Delete();
    };
    this.DataSetCancel = function () {
      if (this.CheckDataSet()) this.FDataLink.GetDataset().Cancel();
    };
    this.DataSetEnableControls = function () {
      if (this.CheckDataSet()) this.FDataLink.GetDataset().EnableControls();
    };
    this.DataSetDisableControls = function () {
      if (this.CheckDataSet()) this.FDataLink.GetDataset().DisableControls();
    };
    this.BeginUpdate = function () {
      this.FUpdating = true;
    };
    this.EndUpdate = function () {
      this.FUpdating = false;
    };
    this.DataSetCanModify = function () {
      var Result = false;
      Result = false;
      if (this.CheckDataSet()) Result = this.FDataLink.GetDataset().GetCanModify();
      return Result;
    };
    rtl.addIntf(this,$mod.ITMSFNCDataBinderNotification);
    var $r = this.$rtti;
    $r.addProperty("BindComponent",3,pas.Classes.$rtti["TComponent"],"GetBindComponent","SetBindComponent");
    $r.addProperty("PropertyName",2,rtl.string,"FPropertyName","SetPropertyName");
    $r.addProperty("ColumnsPropertyName",2,rtl.string,"FColumnsPropertyName","SetColumnsPropertyName");
    $r.addProperty("ColumnsSubPropertyName",2,rtl.string,"FColumnsSubPropertyName","SetColumnsSubPropertyName");
    $r.addProperty("SubPropertyNames",0,$mod.$rtti["TTMSFNCDataBinderPropertyNames"],"FSubPropertyNames","FSubPropertyNames");
    $r.addProperty("SubFieldNames",0,$mod.$rtti["TTMSFNCDataBinderFieldNames"],"FSubFieldNames","FSubFieldNames");
    $r.addProperty("DataSource",3,pas.DB.$rtti["TDataSource"],"GetDataSource","SetDataSource");
    $r.addProperty("Active",2,rtl.boolean,"FActive","SetActive",4,{Default: true});
    $r.addProperty("BindType",2,$mod.$rtti["TTMSFNCDataBinderBindType"],"FBindType","SetBindType",4,{Default: $mod.TTMSFNCDataBinderBindType.dbbtSingleValue});
    $r.addProperty("FieldName",2,rtl.string,"FFieldName","SetFieldName");
    $r.addProperty("HTMLTemplate",2,rtl.string,"FHTMLTemplate","SetHTMLTemplate");
    $r.addProperty("BooleanStringValue",2,rtl.string,"FBooleanStringValue","SetBooleanStringValue");
    $r.addProperty("Name",0,rtl.string,"FName","FName");
  });
  rtl.createClass(this,"TTMSFNCDataBinderItems",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetDataBinderItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCDataBinderItem;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.GetDataBinderItemClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  this.$rtti.$DynArray("TTMSFNCDataBinderStringArray",{eltype: rtl.string});
  this.$rtti.$DynArray("TTMSFNCDataBinderPropertyList",{eltype: pas.TypInfo.$rtti["TTypeMemberProperty"]});
  this.$rtti.$MethodVar("TTMSFNCDataBinderBeforeWriteFieldToPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCDataBinderItem"]],["APropertyInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AField",pas.DB.$rtti["TField"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCDataBinderAfterWriteFieldToPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCDataBinderItem"]],["APropertyInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AField",pas.DB.$rtti["TField"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCDataBinderBeforeWritePropertyToFieldEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCDataBinderItem"]],["APropertyInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AField",pas.DB.$rtti["TField"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCDataBinderAfterWritePropertyToFieldEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCDataBinderItem"]],["APropertyInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AField",pas.DB.$rtti["TField"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCDataBinderBeforeWriteHTMLTemplateToPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCDataBinderItem"]],["APropertyInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AHTMLTemplate",rtl.string,1],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCDataBinderAfterWriteHTMLTemplateToPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCDataBinderItem"]],["APropertyInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["APropertyName",rtl.string],["APropertyKind",pas.System.$rtti["TTypeKind"]],["AHTMLTemplate",rtl.string]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCDataBinder",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FDataSource = null;
      this.FUpdateCount$1 = 0;
      this.FItems = null;
      this.FActive = false;
      this.FOnAfterWriteFieldToProperty = null;
      this.FOnBeforeWriteFieldToProperty = null;
      this.FOnAfterWritePropertyToField = null;
      this.FOnBeforeWritePropertyToField = null;
      this.FOnAfterWriteHTMLTemplateToProperty = null;
      this.FOnBeforeWriteHTMLTemplateToProperty = null;
    };
    this.$final = function () {
      this.FDataSource = undefined;
      this.FItems = undefined;
      this.FOnAfterWriteFieldToProperty = undefined;
      this.FOnBeforeWriteFieldToProperty = undefined;
      this.FOnAfterWritePropertyToField = undefined;
      this.FOnBeforeWritePropertyToField = undefined;
      this.FOnAfterWriteHTMLTemplateToProperty = undefined;
      this.FOnBeforeWriteHTMLTemplateToProperty = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FItems;
      return Result;
    };
    this.SetActive = function (Value) {
      var I = 0;
      if (this.FActive !== Value) {
        this.FActive = Value;
        for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.GetItems().GetItemEx(I).FActive = this.FActive;
        };
        this.UpdateDataLinks();
      };
    };
    this.GetItemByName = function (AName) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ((this.GetItems().GetItemEx(I).FName !== "") && (this.GetItems().GetItemEx(I).FName === AName)) {
          Result = this.GetItems().GetItemEx(I);
          break;
        };
      };
      return Result;
    };
    this.GetItemByObject = function (AObject, APropertyName) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ((this.GetItems().GetItemEx(I).GetObject() === AObject) && ((this.GetItems().GetItemEx(I).FPropertyName === APropertyName) || (APropertyName === ""))) {
          Result = this.GetItems().GetItemEx(I);
          break;
        };
      };
      return Result;
    };
    this.GetDataSource = function () {
      var Result = null;
      Result = this.FDataSource;
      return Result;
    };
    this.SetDataSource = function (Value) {
      var I = 0;
      if (this.FDataSource !== Value) {
        this.FDataSource = Value;
        if (this.FDataSource != null) {
          for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
            I = $l;
            if (this.GetItems().GetItemEx(I).GetDataSource() === null) this.GetItems().GetItemEx(I).SetDataSource(this.FDataSource);
          };
        };
      };
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfnccore/components/ttmsfncdatabinding/";
      return Result;
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,2);
      return Result;
    };
    this.CreateItems = function () {
      var Result = null;
      Result = $mod.TTMSFNCDataBinderItems.$create("Create$3",[this]);
      return Result;
    };
    this.DoBeforeWriteFieldToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField, AAllow) {
      if (this.FOnBeforeWriteFieldToProperty != null) this.FOnBeforeWriteFieldToProperty(this,AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField,AAllow);
    };
    this.DoAfterWriteFieldToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField) {
      if (this.FOnAfterWriteFieldToProperty != null) this.FOnAfterWriteFieldToProperty(this,AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField);
    };
    this.DoBeforeWritePropertyToField = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField, AAllow) {
      if (this.FOnBeforeWritePropertyToField != null) this.FOnBeforeWritePropertyToField(this,AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField,AAllow);
    };
    this.DoAfterWritePropertyToField = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AField) {
      if (this.FOnAfterWritePropertyToField != null) this.FOnAfterWritePropertyToField(this,AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AField);
    };
    this.DoBeforeWriteHTMLTemplateToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AHTMLTemplate, AAllow) {
      if (this.FOnBeforeWriteHTMLTemplateToProperty != null) this.FOnBeforeWriteHTMLTemplateToProperty(this,AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AHTMLTemplate,AAllow);
    };
    this.DoAfterWriteHTMLTemplateToProperty = function (AObject, AItem, APropertyInfo, APropertyName, APropertyKind, AHTMLTemplate) {
      if (this.FOnAfterWriteHTMLTemplateToProperty != null) this.FOnAfterWriteHTMLTemplateToProperty(this,AObject,AItem,APropertyInfo,APropertyName,APropertyKind,AHTMLTemplate);
    };
    this.RegisterRuntimeClasses = function () {
      pas.Classes.RegisterClass($mod.TTMSFNCDataBinder);
    };
    this.UpdateDataLinks = function () {
      var I = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FItems.GetItemEx(I).UpdateDataLink($mod.TTMSFNCDataBinderDataLinkMode.dlmActiveChanged,-1,null);
      };
    };
    this.Notification = function (AComponent, AOperation) {
      var i = 0;
      if ((AOperation === pas.Classes.TOperation.opRemove) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (this.FDataSource === AComponent) this.FDataSource = null;
        i = this.FItems.GetCount() - 1;
        while (i >= 0) {
          if (this.FItems.GetItemEx(i).GetDataSource() === AComponent) this.FItems.GetItemEx(i).SetDataSource(null);
          if (this.FItems.GetItemEx(i).GetObject() === AComponent) this.FItems.GetItemEx(i).SetObject(null);
          i -= 1;
        };
      };
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
    };
    this.Create$5 = function () {
      this.Create$1(null);
      return this;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      this.FItems = this.CreateItems();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.BeginUpdate.call(this);
      this.FUpdateCount$1 += 1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.EndUpdate.call(this);
      this.FUpdateCount$1 -= 1;
      if (this.FUpdateCount$1 === 0) this.UpdateDataLinks();
    };
    this.ItemCount = function () {
      var Result = 0;
      Result = this.GetItems().GetCount();
      return Result;
    };
    this.HasEditLinkMonitor = function (AObject) {
      var Result = false;
      var I = 0;
      Result = false;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ((this.GetItems().GetItemEx(I).GetObject() === AObject) && this.GetItems().GetItemEx(I).HasEditLinkMonitor()) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.HasControlValueMonitor = function (AObject) {
      var Result = false;
      var I = 0;
      Result = false;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ((this.GetItems().GetItemEx(I).GetObject() === AObject) && this.GetItems().GetItemEx(I).HasControlValueMonitor()) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.GetDataSources = function (AStrings) {
      var f = null;
      var i = 0;
      var K = 0;
      f = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetOwnerForm(this);
      if (f != null) {
        for (var $l = 0, $end = f.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (pas["WEBLib.Forms"].TFrame.isPrototypeOf(f.GetComponent(i))) {
            for (var $l1 = 0, $end1 = rtl.as(f.GetComponent(i),pas["WEBLib.Forms"].TFrame).GetComponentCount() - 1; $l1 <= $end1; $l1++) {
              K = $l1;
              if (pas.DB.TDataSource.isPrototypeOf(rtl.as(f.GetComponent(i),pas["WEBLib.Forms"].TFrame).GetComponent(K))) {
                AStrings.AddObject(rtl.as(f.GetComponent(i),pas["WEBLib.Forms"].TFrame).GetComponent(K).FName,rtl.as(f.GetComponent(i),pas["WEBLib.Forms"].TFrame).GetComponent(K));
              };
            };
          } else {
            if (pas.DB.TDataSource.isPrototypeOf(f.GetComponent(i))) {
              AStrings.AddObject(f.GetComponent(i).FName,f.GetComponent(i));
            };
          };
        };
      };
    };
    this.GetPropertyList = function (AObject) {
      var Result = [];
      Result = this.GetPropertyList$1(AObject,false);
      return Result;
    };
    this.GetPropertyNames = function (AObject, IncludePublic) {
      var Result = [];
      var ci = null;
      var a = [];
      var I = 0;
      Result = rtl.arraySetLength(Result,"",0);
      if (AObject != null) {
        ci = AObject.$rtti;
        a = pas.TypInfo.GetPropList(ci,pas.System.tkProperties,true);
        Result = rtl.arraySetLength(Result,"",rtl.length(a));
        for (var $l = 0, $end = rtl.length(a) - 1; $l <= $end; $l++) {
          I = $l;
          Result[I] = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(a[I]);
        };
      };
      return Result;
    };
    this.GetPropertyList$1 = function (AObject, IncludePublic) {
      var Result = [];
      var ci = null;
      var p = null;
      var a = [];
      var I = 0;
      Result = rtl.arraySetLength(Result,null,0);
      if (!(AObject != null)) return Result;
      ci = AObject.$rtti;
      a = pas.TypInfo.GetPropList(ci,pas.System.tkProperties,true);
      for (var $l = 0, $end = rtl.length(a) - 1; $l <= $end; $l++) {
        I = $l;
        Result = rtl.arraySetLength(Result,null,rtl.length(Result) + 1);
        Result[rtl.length(Result) - 1] = a[I];
      };
      return Result;
    };
    this.BlobFieldToBitmap = function (AField, ABitmap) {
      if (!(AField != null)) return;
      if (!(AField.FDataSet != null)) return;
      ABitmap.LoadFromURL(AField.GetAsString(),null);
    };
    this.BitmapToBlobField = function (AField, ABitmap) {
      if (!(AField != null)) return;
      if (!(AField.FDataSet != null)) return;
    };
    this.NotifyEdit = function () {
      var I = 0;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.GetItems().GetItemEx(I).NotifyEdit();
      };
    };
    this.NotifyValueChanged = function () {
      var I = 0;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.GetItems().GetItemEx(I).NotifyValueChanged();
      };
    };
    this.NotifyPost = function () {
      var I = 0;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.GetItems().GetItemEx(I).NotifyPost();
      };
    };
    this.NotifyUpdate = function () {
      var I = 0;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.GetItems().GetItemEx(I).NotifyUpdate();
      };
    };
    this.NotifySetActiveRecord = function () {
      var I = 0;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.GetItems().GetItemEx(I).NotifySetActiveRecord();
      };
    };
    this.IsConnected = function (AObject) {
      var Result = false;
      var I = 0;
      Result = false;
      for (var $l = 0, $end = this.ItemCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.GetItems().GetItemEx(I).GetObject() === AObject) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.ConnectSingleHTMLTemplate = function (AObject, ADataSource, APropertyName, AHTMLTemplate) {
      var Result = null;
      Result = this.Connect(AObject,ADataSource,APropertyName,"",AHTMLTemplate,null,null,null,$mod.TTMSFNCDataBinderBindType.dbbtSingleValue);
      return Result;
    };
    this.ConnectSingle = function (AObject, ADataSource, APropertyName, AFieldName) {
      var Result = null;
      Result = this.Connect(AObject,ADataSource,APropertyName,AFieldName,"",null,null,null,$mod.TTMSFNCDataBinderBindType.dbbtSingleValue);
      return Result;
    };
    this.ConnectListHTMLTemplate = function (AObject, ADataSource, APropertyName, ASubPropertyNames, ASubHTMLTemplates) {
      var Result = null;
      Result = this.Connect(AObject,ADataSource,APropertyName,"","",rtl.arrayRef(ASubPropertyNames),[],rtl.arrayRef(ASubHTMLTemplates),$mod.TTMSFNCDataBinderBindType.dbbtList);
      return Result;
    };
    this.ConnectList = function (AObject, ADataSource, APropertyName, ASubPropertyNames, ASubFieldNames) {
      var Result = null;
      Result = this.Connect(AObject,ADataSource,APropertyName,"","",rtl.arrayRef(ASubPropertyNames),rtl.arrayRef(ASubFieldNames),[],$mod.TTMSFNCDataBinderBindType.dbbtList);
      return Result;
    };
    this.ConnectListHTMLTemplate$1 = function (AObject, ADataSource, APropertyName, AHTMLTemplate) {
      var Result = null;
      Result = this.Connect(AObject,ADataSource,APropertyName,"",AHTMLTemplate,[],[],[],$mod.TTMSFNCDataBinderBindType.dbbtList);
      return Result;
    };
    this.ConnectList$1 = function (AObject, ADataSource, APropertyName, AFieldName) {
      var Result = null;
      Result = this.Connect(AObject,ADataSource,APropertyName,AFieldName,"",[],[],[],$mod.TTMSFNCDataBinderBindType.dbbtList);
      return Result;
    };
    this.ConnectColumnList = function (AObject, ADataSource, AListPropertyName, AColumnsPropertyName, AColumnsSubPropertyName, AListSubPropertyName) {
      var Result = null;
      Result = this.FItems.Add$1();
      Result.SetDataSource(ADataSource);
      Result.SetBindType($mod.TTMSFNCDataBinderBindType.dbbtColumnList);
      Result.SetColumnsPropertyName(AColumnsPropertyName);
      Result.SetColumnsSubPropertyName(AColumnsSubPropertyName);
      Result.SetObject(AObject);
      Result.SetPropertyName(AListPropertyName);
      Result.FSubPropertyNames.Add$1().SetValue(AListSubPropertyName);
      return Result;
    };
    this.Connect = function (AObject, ADataSource, APropertyName, AFieldName, AHTMLTemplate, ASubPropertyNames, ASubFieldNames, ASubHTMLTemplates, ABindType) {
      var Result = null;
      var I = 0;
      Result = this.FItems.Add$1();
      Result.SetDataSource(ADataSource);
      Result.SetBindType(ABindType);
      Result.SetFieldName(AFieldName);
      Result.SetObject(AObject);
      Result.SetPropertyName(APropertyName);
      Result.SetHTMLTemplate(AHTMLTemplate);
      if (rtl.length(ASubPropertyNames) > 0) {
        for (var $l = 0, $end = rtl.length(ASubPropertyNames) - 1; $l <= $end; $l++) {
          I = $l;
          Result.FSubPropertyNames.Add$1().SetValue(ASubPropertyNames[I]);
        };
      };
      if (rtl.length(ASubFieldNames) > 0) {
        for (var $l1 = 0, $end1 = rtl.length(ASubFieldNames) - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          Result.FSubFieldNames.Add$1().SetValue(ASubFieldNames[I]);
        };
      };
      if (rtl.length(ASubHTMLTemplates) > 0) {
        for (var $l2 = 0, $end2 = rtl.length(ASubHTMLTemplates) - 1; $l2 <= $end2; $l2++) {
          I = $l2;
          Result.FSubFieldNames.Add$1().SetHTMLTemplate(ASubHTMLTemplates[I]);
        };
      };
      return Result;
    };
    this.ConnectGrid = function (AObject, ADatasource) {
      var Result = null;
      Result = this.FItems.Add$1();
      Result.SetDataSource(ADatasource);
      Result.SetBindType($mod.TTMSFNCDataBinderBindType.dbbtGrid);
      Result.SetObject(AObject);
      return Result;
    };
    this.StartEditor = function (AObject) {
      var $Self = this;
      var e = null;
      e = pas["WEBLib.TMSFNCDataBindingEditor"].TTMSFNCDataBindingEditor.$create("Create$1",[$Self]);
      try {
        e.FDataBinder = $Self;
        e.FObject = AObject;
        e.Execute(function (AResult) {
          e = rtl.freeLoc(e);
        });
      } finally {
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DataSource",3,pas.DB.$rtti["TDataSource"],"GetDataSource","SetDataSource");
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCDataBinderItems"],"GetItems","SetItems");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("Active",2,rtl.boolean,"FActive","SetActive",4,{Default: false});
    $r.addProperty("OnBeforeWriteFieldToProperty",0,$mod.$rtti["TTMSFNCDataBinderBeforeWriteFieldToPropertyEvent"],"FOnBeforeWriteFieldToProperty","FOnBeforeWriteFieldToProperty");
    $r.addProperty("OnAfterWriteFieldToProperty",0,$mod.$rtti["TTMSFNCDataBinderAfterWriteFieldToPropertyEvent"],"FOnAfterWriteFieldToProperty","FOnAfterWriteFieldToProperty");
    $r.addProperty("OnBeforeWritePropertyToField",0,$mod.$rtti["TTMSFNCDataBinderBeforeWritePropertyToFieldEvent"],"FOnBeforeWritePropertyToField","FOnBeforeWritePropertyToField");
    $r.addProperty("OnAfterWritePropertyToField",0,$mod.$rtti["TTMSFNCDataBinderAfterWritePropertyToFieldEvent"],"FOnAfterWritePropertyToField","FOnAfterWritePropertyToField");
    $r.addProperty("OnBeforeWriteHTMLTemplateToProperty",0,$mod.$rtti["TTMSFNCDataBinderBeforeWriteHTMLTemplateToPropertyEvent"],"FOnBeforeWriteHTMLTemplateToProperty","FOnBeforeWriteHTMLTemplateToProperty");
    $r.addProperty("OnAfterWriteHTMLTemplateToProperty",0,$mod.$rtti["TTMSFNCDataBinderAfterWriteHTMLTemplateToPropertyEvent"],"FOnAfterWriteHTMLTemplateToProperty","FOnAfterWriteHTMLTemplateToProperty");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    $impl.FGlobalUpdating = false;
    $impl.FManager = null;
    $impl.DataBinderNotificationManager = function () {
      var Result = null;
      Result = $impl.FManager;
      return Result;
    };
  };
  $mod.$init = function () {
    if (!($impl.FManager != null)) $impl.FManager = $mod.TTMSFNCDataBinderNotificationManager.$create("Create$1");
  };
},["WEBLib.Graphics","WEBLib.Forms","WEBLib.TMSFNCUtils","WEBLib.TMSFNCCustomControl","SysUtils","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCDataBindingEditor"]);
rtl.module("WEBLib.TMSFNCCustomControl",["System","Classes","WEBLib.Controls","WEBLib.TMSFNCGraphics","WEBLib.Graphics","WEBLib.TMSFNCStyles","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCUndo","WEBLib.TMSFNCDataBinding","Types","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCTypes","TypInfo","WEBLib.Forms","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.FPC_FULLVERSION = 0;
  rtl.createClass(this,"TTMSFNCCustomDesignerForm",pas["WEBLib.Forms"].TForm,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TTMSFNCCustomControl");
  this.TTMSFNCControlAlignment = {"0": "caNone", caNone: 0, "1": "caTop", caTop: 1, "2": "caBottom", caBottom: 2, "3": "caLeft", caLeft: 3, "4": "caRight", caRight: 4, "5": "caClient", caClient: 5};
  this.$rtti.$Enum("TTMSFNCControlAlignment",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCControlAlignment});
  this.TTMSFNCControlPosition = {"0": "cpTopLeft", cpTopLeft: 0, "1": "cpTopCenter", cpTopCenter: 1, "2": "cpTopRight", cpTopRight: 2, "3": "cpCenterLeft", cpCenterLeft: 3, "4": "cpCenterCenter", cpCenterCenter: 4, "5": "cpCenterRight", cpCenterRight: 5, "6": "cpBottomLeft", cpBottomLeft: 6, "7": "cpBottomCenter", cpBottomCenter: 7, "8": "cpBottomRight", cpBottomRight: 8};
  this.$rtti.$Enum("TTMSFNCControlPosition",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TTMSFNCControlPosition});
  rtl.createClass(this,"TTMSFNCCustomControlDropFiles",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FFiles = null;
    };
    this.$final = function () {
      this.FFiles = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetFiles = function () {
      var Result = null;
      if (!(this.FFiles != null)) this.FFiles = pas.Classes.TStringList.$create("Create$1");
      Result = this.FFiles;
      return Result;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFiles;
        }, set: function (v) {
          this.p.FFiles = v;
        }});
    };
  });
  rtl.createClass(this,"TTMSFNCCustomControlBaseCommon",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FResourceScaleFactor = 0.0;
      this.FPaintScaleFactor = 0.0;
      this.FDesigntimeFormPixelsPerInch = 0;
      this.FAllowFocus = false;
      this.FShortCutHint = "";
      this.FAcceptDropFiles = false;
      this.FAllowGetChildren = false;
      this.FAdaptToStyle = false;
      this.FAdaptedToStyle = false;
      this.FTransparent = false;
      this.FBufferedPainting = false;
      this.FNativeCanvas = false;
      this.FAntiAliasing = false;
      this.FOptimizedHTMLDrawing = false;
      this.FShowAcceleratorChar = false;
      this.FTextQuality = 0;
      this.FOnInternalDblClick = null;
      this.FOnInternalMouseDown = null;
      this.FOnInternalMouseMove = null;
      this.FOnInternalMouseUp = null;
    };
    this.$final = function () {
      this.FOnInternalDblClick = undefined;
      this.FOnInternalMouseDown = undefined;
      this.FOnInternalMouseMove = undefined;
      this.FOnInternalMouseUp = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetAllowFocus = function () {
      var Result = false;
      Result = this.FAllowFocus;
      return Result;
    };
    this.GetShortCutHint = function () {
      var Result = "";
      Result = this.FShortCutHint;
      return Result;
    };
    this.GetControlAlignment = function () {
      var Result = 0;
      Result = $mod.TTMSFNCControlAlignment.caNone;
      var $tmp = this.FAlign;
      if ($tmp === pas["WEBLib.Controls"].TAlign.alNone) {
        Result = $mod.TTMSFNCControlAlignment.caNone}
       else if ($tmp === pas["WEBLib.Controls"].TAlign.alTop) {
        Result = $mod.TTMSFNCControlAlignment.caTop}
       else if ($tmp === pas["WEBLib.Controls"].TAlign.alBottom) {
        Result = $mod.TTMSFNCControlAlignment.caBottom}
       else if ($tmp === pas["WEBLib.Controls"].TAlign.alLeft) {
        Result = $mod.TTMSFNCControlAlignment.caLeft}
       else if ($tmp === pas["WEBLib.Controls"].TAlign.alRight) {
        Result = $mod.TTMSFNCControlAlignment.caRight}
       else if ($tmp === pas["WEBLib.Controls"].TAlign.alClient) Result = $mod.TTMSFNCControlAlignment.caClient;
      return Result;
    };
    this.SetAcceptDropFiles = function (Value) {
      if (this.FAcceptDropFiles !== Value) {
        this.FAcceptDropFiles = Value;
      };
    };
    this.SetAllowFocus = function (Value) {
      this.FAllowFocus = Value;
    };
    this.SetControlAlignment = function (Value) {
      var $tmp = Value;
      if ($tmp === $mod.TTMSFNCControlAlignment.caNone) {
        this.SetAlign(pas["WEBLib.Controls"].TAlign.alNone)}
       else if ($tmp === $mod.TTMSFNCControlAlignment.caTop) {
        this.SetAlign(pas["WEBLib.Controls"].TAlign.alTop)}
       else if ($tmp === $mod.TTMSFNCControlAlignment.caBottom) {
        this.SetAlign(pas["WEBLib.Controls"].TAlign.alBottom)}
       else if ($tmp === $mod.TTMSFNCControlAlignment.caLeft) {
        this.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft)}
       else if ($tmp === $mod.TTMSFNCControlAlignment.caRight) {
        this.SetAlign(pas["WEBLib.Controls"].TAlign.alRight)}
       else if ($tmp === $mod.TTMSFNCControlAlignment.caClient) this.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
    };
    this.SetAntiAliasing = function (Value) {
      if (this.FAntiAliasing !== Value) {
        this.FAntiAliasing = Value;
        this.Invalidate();
      };
    };
    this.SetOptimizedHTMLDrawing = function (Value) {
      if (this.FOptimizedHTMLDrawing !== Value) {
        this.FOptimizedHTMLDrawing = Value;
        this.Invalidate();
      };
    };
    this.SetShowAcceleratorChar = function (Value) {
      if (this.FShowAcceleratorChar !== Value) {
        this.FShowAcceleratorChar = Value;
        this.Invalidate();
      };
    };
    this.SetNativeCanvas = function (Value) {
      if (this.FNativeCanvas !== Value) {
        this.FNativeCanvas = Value;
        this.Invalidate();
      };
    };
    this.SetTextQuality = function (Value) {
      if (this.FTextQuality !== Value) {
        this.FTextQuality = Value;
        this.Invalidate();
      };
    };
    this.SetShortCutHint = function (Value) {
      this.FShortCutHint = Value;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL;
      return Result;
    };
    this.GetTipsURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseTipsURL;
      return Result;
    };
    this.HandleDesignHitTest = function (APoint) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetClientMousePos = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      Result.$assign(this.ConvertScreenToClient(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetMousePos())));
      return Result;
    };
    this.ConvertScreenToClient = function (APoint) {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var p = pas.Types.TPoint.$new();
      p.$assign(this.ScreenToClient(pas.Types.Point(Math.round(APoint.X),Math.round(APoint.Y))));
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(p.x,p.y));
      return Result;
    };
    this.ConvertClientToScreen = function (APoint) {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var p = pas.Types.TPoint.$new();
      p.$assign(this.ClientToScreen(pas.Types.Point(Math.round(APoint.X),Math.round(APoint.Y))));
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(p.x,p.y));
      return Result;
    };
    this.GetDragObjectScreenShot = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetAdaptToStyle = function () {
      var Result = false;
      Result = this.FAdaptToStyle;
      return Result;
    };
    this.SetEnabled = function (Value) {
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      this.Invalidate();
    };
    this.CalcFactor = function () {
      this.FResourceScaleFactor = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(this,96);
      this.FPaintScaleFactor = this.FResourceScaleFactor;
    };
    this.ChangeDPIScale = function (M, D) {
    };
    this.SetDefaultGraphicColors = function () {
      var c = 0;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupFillColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupFillColor = 16777215;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundStrokeColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupStrokeColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupStrokeColor = 12632256;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleDefaultButtonFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor = 11119017;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultTextFontColor = c}
       else pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultTextFontColor = 0;
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor = c;
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].Blend(c,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor,25);
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].Blend(c,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor,30);
      } else {
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor = 0;
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251);
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177);
      };
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorDisabled = 11119017;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorDisabled = 13882323;
    };
    this.SetAdaptToStyle = function (Value) {
      this.FAdaptToStyle = Value;
      this.InitializeStyle();
    };
    this.CancelHint = function () {
    };
    this.BeginDrag$1 = function () {
    };
    this.InitializeStyle = function () {
      this.SetDefaultGraphicColors();
      this.DestroyGraphicElements();
      if (this.GetAdaptToStyle()) {
        this.FAdaptedToStyle = true;
        this.ApplyStyle();
      } else if (this.FAdaptedToStyle) {
        this.ResetToDefaultStyle();
        this.FAdaptedToStyle = false;
      };
      this.Invalidate();
    };
    this.ApplyStyle = function () {
    };
    this.ResetToDefaultStyle = function () {
    };
    this.HandleMouseLeave = function () {
    };
    this.HandleMouseEnter = function () {
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
    };
    this.HandleMouseMove = function (Shift, X, Y) {
    };
    this.HandleDblClick = function (X, Y) {
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
    };
    this.HandleKeyPress = function (Key) {
    };
    this.HandleKeyDown = function (Key, Shift) {
    };
    this.HandleDialogKey = function (Key, Shift) {
    };
    this.HandleKeyUp = function (Key, Shift) {
    };
    this.HandleMouseWheel = function (Shift, WheelDelta, Handled) {
    };
    this.HandleDragOver = function (Source, Point, Accept) {
    };
    this.HandleDragDrop = function (Source, Point) {
    };
    this.Create$1 = function (AOwner) {
      var ppi = 0;
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      ppi = 96;
      this.FDesigntimeFormPixelsPerInch = ppi;
      this.FPaintScaleFactor = 1.0;
      this.FResourceScaleFactor = 1.0;
      this.SetDefaultGraphicColors();
      this.FAdaptToStyle = false;
      this.FAdaptedToStyle = false;
      this.FAcceptDropFiles = false;
      this.FTransparent = false;
      this.FNativeCanvas = false;
      this.FBufferedPainting = false;
      this.FAntiAliasing = true;
      this.FOptimizedHTMLDrawing = true;
      this.FShowAcceleratorChar = true;
      this.FTextQuality = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextQuality.gtqAntiAliasing;
      this.FAllowFocus = true;
      return this;
    };
    this.Destroy = function () {
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.SetControlMargins = function (ALeft, ATop, ARight, ABottom) {
      this.SetAlignWithMargins(true);
      this.FMargins.SetLeft(Math.round(ALeft));
      this.FMargins.SetTop(Math.round(ATop));
      this.FMargins.SetRight(Math.round(ARight));
      this.FMargins.SetBottom(Math.round(ABottom));
    };
    this.GetControlMargins = function (ALeft, ATop, ARight, ABottom) {
      if (!this.FAlignWithMargins) return;
      ALeft.set(this.FMargins.FLeft);
      ATop.set(this.FMargins.FTop);
      ARight.set(this.FMargins.FRight);
      ABottom.set(this.FMargins.FBottom);
    };
    this.ScaleResourceValue = function (Value) {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(Value,Math.round(this.FResourceScaleFactor * 100),100);
      return Result;
    };
    this.ScaleResourceValue$1 = function (Value) {
      var Result = 0.0;
      Result = Value * this.FResourceScaleFactor;
      return Result;
    };
    this.ScalePaintValue = function (Value) {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(Value,Math.round(this.FPaintScaleFactor * 100),100);
      return Result;
    };
    this.ScalePaintValue$1 = function (Value) {
      var Result = 0.0;
      Result = Value * this.FPaintScaleFactor;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomControlBase",this.TTMSFNCCustomControlBaseCommon,function () {
    this.$init = function () {
      $mod.TTMSFNCCustomControlBaseCommon.$init.call(this);
      this.FStored = false;
      this.FHitTest = false;
    };
    this.MouseWheel = function (Shift, WheelDelta, Handled) {
      pas["WEBLib.Controls"].TControl.MouseWheel.apply(this,arguments);
      this.HandleMouseWheel(rtl.refSet(Shift),WheelDelta,Handled);
    };
    this.DoMouseLeave = function () {
      pas["WEBLib.Controls"].TControl.DoMouseLeave.call(this);
      this.HandleMouseLeave();
    };
    this.DoMouseEnter = function () {
      pas["WEBLib.Controls"].TControl.DoMouseEnter.call(this);
      this.HandleMouseEnter();
    };
    this.GetLocalRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth(),this.GetHeight()));
      return Result;
    };
    this.GetHintString = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.HasHint = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseDown.apply(this,arguments);
      this.HandleMouseDown(Button,rtl.refSet(Shift),X,Y);
      if (this.FOnInternalMouseDown != null) this.FOnInternalMouseDown(this);
    };
    this.MouseMove = function (Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseMove.apply(this,arguments);
      this.HandleMouseMove(rtl.refSet(Shift),X,Y);
      if (this.FOnInternalMouseMove != null) this.FOnInternalMouseMove(this);
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseUp.apply(this,arguments);
      this.HandleMouseUp(Button,rtl.refSet(Shift),X,Y);
      if (this.FOnInternalMouseUp != null) this.FOnInternalMouseUp(this);
    };
    this.DragOver = function (Source, X, Y, State, Accept) {
      pas["WEBLib.Controls"].TControl.DragOver.apply(this,arguments);
      this.HandleDragOver(Source,pas["WEBLib.TMSFNCTypes"].PointF(X,Y),Accept);
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      this.HandleDialogKey(Key,rtl.refSet(Shift));
      this.HandleKeyDown(Key,rtl.refSet(Shift));
      if (Key.get() === 9) ;
    };
    this.KeyPress = function (Key) {
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
      this.HandleKeyPress(Key);
    };
    this.KeyUp = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyUp.apply(this,arguments);
      this.HandleKeyUp(Key,rtl.refSet(Shift));
    };
    this.DblClick = function () {
      var pf = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      pas["WEBLib.Controls"].TControl.DblClick.call(this);
      pf.$assign(this.ConvertScreenToClient(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetMousePos())));
      this.HandleDblClick(pf.X,pf.Y);
      if (this.FOnInternalDblClick != null) this.FOnInternalDblClick(this);
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomControlBaseCommon.Create$1.apply(this,arguments);
      this.FHitTest = true;
      this.FStored = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      return this;
    };
    this.BeginUpdate = function () {
      pas["WEBLib.Controls"].TControl.BeginUpdate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
    };
    this.DragDrop = function (Source, X, Y) {
      pas["WEBLib.Controls"].TControl.DragDrop.apply(this,arguments);
      this.HandleDragDrop(Source,pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
    };
    this.CanFocus = function () {
      var Result = false;
      Result = pas["WEBLib.Controls"].TControl.CanFocus.call(this);
      Result = Result && this.GetAllowFocus();
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TTMSFNCCustomControlBeforeDrawEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlAfterDrawEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlCanSavePropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]],["ACanSave",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlCanLoadPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]],["ACanLoad",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomControl",this.TTMSFNCCustomControlBase,function () {
    this.FBlockPersistenceInterface = false;
    this.$init = function () {
      $mod.TTMSFNCCustomControlBase.$init.call(this);
      this.FBlockInvalidate = false;
      this.FAppearancePersisting = false;
      this.FExporting = false;
      this.FExportRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FOnBeforeDraw = null;
      this.FOnAfterDraw = null;
      this.FOnCanSaveProperty = null;
      this.FOnCanLoadProperty = null;
      this.FFill = null;
      this.FManager = null;
      this.FStroke = null;
      this.FDataPointer = null;
      this.FDataBoolean = false;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FUndoManager = null;
    };
    this.$final = function () {
      this.FExportRect = undefined;
      this.FOnBeforeDraw = undefined;
      this.FOnAfterDraw = undefined;
      this.FOnCanSaveProperty = undefined;
      this.FOnCanLoadProperty = undefined;
      this.FFill = undefined;
      rtl.setIntfP(this,"FManager",null);
      this.FStroke = undefined;
      this.FDataObject = undefined;
      this.FUndoManager = undefined;
      $mod.TTMSFNCCustomControlBase.$final.call(this);
    };
    this.GetUndoManager = function () {
      var Result = null;
      if (!(this.FUndoManager != null)) this.FUndoManager = pas["WEBLib.TMSFNCUndo"].TTMSFNCUndoManager.$create("Create$2",[this]);
      Result = this.FUndoManager;
      return Result;
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.GetVersionNumber = function (AMaj, AMin, ARel, ABld) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.DataGetItemIndex = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.DataSetItemIndex = function (AValue) {
    };
    this.IsAppearanceProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      var Prop = null;
      var pName = "";
      var cn = "";
      Result = false;
      Prop = pas.TypInfo.GetPropInfo$2(AObject,APropertyName);
      if (Prop != null) {
        pName = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoName(Prop);
        cn = pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.GetPropInfoTypeName(Prop);
        Result = (cn === "TAlphaColor") || (cn === "TColor") || (cn === "TGraphicsColor") || (cn === "TTMSFNCGraphicsFill") || (cn === "TTMSFNCGraphicsStroke") || (pas.System.Pos("Appearance",pName) > 0);
        Result = Result || (APropertyName === "Fill") || (APropertyName === "Stroke") || (APropertyName === "Font");
      };
      return Result;
    };
    this.CanSaveProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      if ((AObject === this) && !this.FBlockPersistenceInterface) {
        Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(APropertyName,pas["WEBLib.TMSFNCPersistence"].ExcludePropertyList) === -1}
       else Result = true;
      if (this.FAppearancePersisting) Result = Result && this.IsAppearanceProperty(AObject,APropertyName,APropertyType);
      this.DoCanSaveProperty(AObject,APropertyName,APropertyType,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.CanLoadProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      if ((AObject === this) && !this.FBlockPersistenceInterface) {
        Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IndexOfTextInArray(APropertyName,pas["WEBLib.TMSFNCPersistence"].ExcludePropertyList) === -1}
       else Result = true;
      this.DoCanLoadProperty(AObject,APropertyName,APropertyType,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.LocalToScreenEx = function (APoint) {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var pt = pas.Types.TPoint.$new();
      pt.$assign(this.ClientToScreen(pas.Types.Point(Math.round(APoint.X),Math.round(APoint.Y))));
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(pt.x,pt.y));
      return Result;
    };
    this.ScreenToLocalEx = function (APoint) {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var pt = pas.Types.TPoint.$new();
      pt.$assign(this.ScreenToClient(pas.Types.Point(Math.round(APoint.X),Math.round(APoint.Y))));
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(pt.x,pt.y));
      return Result;
    };
    this.GetContentRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetControlRect());
      return Result;
    };
    this.GetControlRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.IsExporting()) {
        Result.$assign(this.FExportRect)}
       else Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth(),this.GetHeight()));
      return Result;
    };
    this.GetLocalRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.IsExporting()) {
        Result.$assign(this.FExportRect)}
       else Result.$assign($mod.TTMSFNCCustomControlBase.GetLocalRect.call(this));
      return Result;
    };
    this.IsExporting = function () {
      var Result = false;
      Result = this.FExporting;
      return Result;
    };
    this.SetColor = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetColor.apply(this,arguments);
      if (this.FFill != null) this.FFill.SetColor(AValue);
      this.Invalidate();
    };
    this.ChangeDPIScale = function (M, D) {
      $mod.TTMSFNCCustomControlBaseCommon.ChangeDPIScale.apply(this,arguments);
      if (!this.IsLoading()) {
        this.CreateCheckBoxBitmaps();
        this.CreateRadioButtonBitmaps();
      };
    };
    this.RegisterRuntimeClasses = function () {
    };
    this.Export = function (AGraphics, ARect) {
      this.FExporting = true;
      this.SetExportRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.BeforeExport();
      this.DrawBackground(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.Draw(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.FExporting = false;
      this.AfterExport();
    };
    this.SetExportRect = function (ARect) {
      this.FExportRect.$assign(ARect);
    };
    this.ApplyExportScale = function (AScale) {
    };
    this.ResetExportScale = function () {
    };
    this.BeforeExport = function () {
    };
    this.AfterExport = function () {
    };
    this.ApplyStyle = function () {
      var c = 0;
      $mod.TTMSFNCCustomControlBaseCommon.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFill.SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FStroke.SetColor(c);
    };
    this.DoExit = function () {
      pas["WEBLib.Controls"].TControl.DoExit.call(this);
      this.NotifyDataBinderUpdate();
    };
    this.AddManager = function (AManager) {
      rtl._AddRef(AManager);
      try {
        rtl.setIntfP(this,"FManager",AManager);
      } finally {
        rtl._Release(AManager);
      };
    };
    this.RemoveManager = function () {
      rtl.setIntfP(this,"FManager",null);
    };
    this.ResetToDefaultStyle = function () {
      $mod.TTMSFNCCustomControlBaseCommon.ResetToDefaultStyle.call(this);
      this.FFill.SetColor(16777215);
      this.FStroke.SetColor(12632256);
    };
    this.DestroyGraphicElements = function () {
      if ($impl.FDownBtn != null) {
        rtl.free($impl,"FDownBtn");
        $impl.FDownBtn = null;
      };
      if ($impl.FNormalBtn != null) {
        rtl.free($impl,"FNormalBtn");
        $impl.FNormalBtn = null;
      };
      if ($impl.FDownFocusBtn != null) {
        rtl.free($impl,"FDownFocusBtn");
        $impl.FDownFocusBtn = null;
      };
      if ($impl.FNormalFocusBtn != null) {
        rtl.free($impl,"FNormalFocusBtn");
        $impl.FNormalFocusBtn = null;
      };
      if ($impl.FNormalDisabledBtn != null) {
        rtl.free($impl,"FNormalDisabledBtn");
        $impl.FNormalDisabledBtn = null;
      };
      if ($impl.FCheckedChk != null) {
        rtl.free($impl,"FCheckedChk");
        $impl.FCheckedChk = null;
      };
      if ($impl.FCheckedFocusChk != null) {
        rtl.free($impl,"FCheckedFocusChk");
        $impl.FCheckedFocusChk = null;
      };
      if ($impl.FUnCheckedDisabledChk != null) {
        rtl.free($impl,"FUnCheckedDisabledChk");
        $impl.FUnCheckedDisabledChk = null;
      };
      if ($impl.FCheckedDisabledChk != null) {
        rtl.free($impl,"FCheckedDisabledChk");
        $impl.FCheckedDisabledChk = null;
      };
      if ($impl.FUnCheckedChk != null) {
        rtl.free($impl,"FUnCheckedChk");
        $impl.FUnCheckedChk = null;
      };
      if ($impl.FUnCheckedFocusChk != null) {
        rtl.free($impl,"FUnCheckedFocusChk");
        $impl.FUnCheckedFocusChk = null;
      };
      if ($impl.FCheckedRd != null) {
        rtl.free($impl,"FCheckedRd");
        $impl.FCheckedRd = null;
      };
      if ($impl.FCheckedFocusRd != null) {
        rtl.free($impl,"FCheckedFocusRd");
        $impl.FCheckedFocusRd = null;
      };
      if ($impl.FUnCheckedRd != null) {
        rtl.free($impl,"FUnCheckedRd");
        $impl.FUnCheckedRd = null;
      };
      if ($impl.FUnCheckedFocusRd != null) {
        rtl.free($impl,"FUnCheckedFocusRd");
        $impl.FUnCheckedFocusRd = null;
      };
      if ($impl.FUnCheckedDisabledRd != null) {
        rtl.free($impl,"FUnCheckedDisabledRd");
        $impl.FUnCheckedDisabledRd = null;
      };
      if ($impl.FCheckedDisabledRd != null) {
        rtl.free($impl,"FCheckedDisabledRd");
        $impl.FCheckedDisabledRd = null;
      };
    };
    this.UpdateControlAfterResize = function () {
    };
    this.CreateCheckBoxBitmaps = function () {
      var g = null;
      var bmp = null;
      var sc = 0.0;
      sc = this.FResourceScaleFactor;
      if ($impl.FCheckedFocusChk != null) {
        rtl.free($impl,"FCheckedFocusChk");
        $impl.FCheckedFocusChk = null;
      };
      if ($impl.FUnCheckedChk != null) {
        rtl.free($impl,"FUnCheckedChk");
        $impl.FUnCheckedChk = null;
      };
      if ($impl.FCheckedChk != null) {
        rtl.free($impl,"FCheckedChk");
        $impl.FCheckedChk = null;
      };
      if ($impl.FUnCheckedFocusChk != null) {
        rtl.free($impl,"FUnCheckedFocusChk");
        $impl.FUnCheckedFocusChk = null;
      };
      if ($impl.FUnCheckedDisabledChk != null) {
        rtl.free($impl,"FUnCheckedDisabledChk");
        $impl.FUnCheckedDisabledChk = null;
      };
      if ($impl.FCheckedDisabledChk != null) {
        rtl.free($impl,"FCheckedDisabledChk");
        $impl.FCheckedDisabledChk = null;
      };
      bmp = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[bmp.GetCanvas(),false]);
      try {
        bmp.SetSize(Math.round(16 * sc),Math.round(16 * sc));
        $impl.FUnCheckedChk = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FUnCheckedChk.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,false,true,1.0);
        $impl.FUnCheckedChk.Assign(bmp);
        $impl.FCheckedChk = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FCheckedChk.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,false,true,1.0);
        $impl.FCheckedChk.Assign(bmp);
        $impl.FUnCheckedFocusChk = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FUnCheckedFocusChk.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,true,true,1.0);
        $impl.FUnCheckedFocusChk.Assign(bmp);
        $impl.FCheckedFocusChk = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FCheckedFocusChk.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,true,true,1.0);
        $impl.FCheckedFocusChk.Assign(bmp);
        $impl.FUnCheckedDisabledChk = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FUnCheckedDisabledChk.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,false,false,1.0);
        $impl.FUnCheckedDisabledChk.Assign(bmp);
        $impl.FCheckedDisabledChk = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FCheckedDisabledChk.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawCheckBox(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,false,false,1.0);
        $impl.FCheckedDisabledChk.Assign(bmp);
      } finally {
        g = rtl.freeLoc(g);
        bmp = rtl.freeLoc(bmp);
      };
    };
    this.CreateRadioButtonBitmaps = function () {
      var g = null;
      var bmp = null;
      var sc = 0.0;
      sc = this.FResourceScaleFactor;
      if ($impl.FCheckedFocusRd != null) {
        rtl.free($impl,"FCheckedFocusRd");
        $impl.FCheckedFocusRd = null;
      };
      if ($impl.FUnCheckedRd != null) {
        rtl.free($impl,"FUnCheckedRd");
        $impl.FUnCheckedRd = null;
      };
      if ($impl.FCheckedRd != null) {
        rtl.free($impl,"FCheckedRd");
        $impl.FCheckedRd = null;
      };
      if ($impl.FUnCheckedFocusRd != null) {
        rtl.free($impl,"FUnCheckedFocusRd");
        $impl.FUnCheckedFocusRd = null;
      };
      if ($impl.FUnCheckedDisabledRd != null) {
        rtl.free($impl,"FUnCheckedDisabledRd");
        $impl.FUnCheckedDisabledRd = null;
      };
      if ($impl.FCheckedDisabledRd != null) {
        rtl.free($impl,"FCheckedDisabledRd");
        $impl.FCheckedDisabledRd = null;
      };
      bmp = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[bmp.GetCanvas(),false]);
      try {
        bmp.SetSize(Math.round(16 * sc),Math.round(16 * sc));
        $impl.FUnCheckedRd = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FUnCheckedRd.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,false,true,1.0);
        $impl.FUnCheckedRd.Assign(bmp);
        $impl.FCheckedRd = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FCheckedRd.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,false,true,1.0);
        $impl.FCheckedRd.Assign(bmp);
        $impl.FUnCheckedFocusRd = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FUnCheckedFocusRd.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,true,true,1.0);
        $impl.FUnCheckedFocusRd.Assign(bmp);
        $impl.FCheckedFocusRd = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FCheckedFocusRd.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,true,true,1.0);
        $impl.FCheckedFocusRd.Assign(bmp);
        $impl.FUnCheckedDisabledRd = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FUnCheckedDisabledRd.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,false,false,1.0);
        $impl.FUnCheckedDisabledRd.Assign(bmp);
        $impl.FCheckedDisabledRd = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FCheckedDisabledRd.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawRadioButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,false,false,1.0);
        $impl.FCheckedDisabledRd.Assign(bmp);
      } finally {
        g = rtl.freeLoc(g);
        bmp = rtl.freeLoc(bmp);
      };
    };
    this.CreateButtonBitmaps = function (AWidth, AHeight) {
      var g = null;
      var bmp = null;
      var sc = 0.0;
      sc = this.FResourceScaleFactor;
      if ($impl.FDownBtn != null) {
        rtl.free($impl,"FDownBtn");
        $impl.FDownBtn = null;
      };
      if ($impl.FNormalBtn != null) {
        rtl.free($impl,"FNormalBtn");
        $impl.FNormalBtn = null;
      };
      if ($impl.FDownFocusBtn != null) {
        rtl.free($impl,"FDownFocusBtn");
        $impl.FDownFocusBtn = null;
      };
      if ($impl.FNormalFocusBtn != null) {
        rtl.free($impl,"FNormalFocusBtn");
        $impl.FNormalFocusBtn = null;
      };
      if ($impl.FNormalDisabledBtn != null) {
        rtl.free($impl,"FNormalDisabledBtn");
        $impl.FNormalDisabledBtn = null;
      };
      bmp = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[bmp.GetCanvas(),false]);
      try {
        bmp.SetSize(Math.round(AWidth * sc),Math.round(AHeight * sc));
        $impl.FNormalBtn = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FNormalBtn.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,false,true,this.GetAdaptToStyle(),1.0);
        $impl.FNormalBtn.Assign(bmp);
        $impl.FDownBtn = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FDownBtn.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,false,true,this.GetAdaptToStyle(),1.0);
        $impl.FDownBtn.Assign(bmp);
        $impl.FNormalFocusBtn = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FNormalFocusBtn.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),true,true,true,this.GetAdaptToStyle(),1.0);
        $impl.FNormalFocusBtn.Assign(bmp);
        $impl.FDownFocusBtn = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FDownFocusBtn.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,true,true,this.GetAdaptToStyle(),1.0);
        $impl.FDownFocusBtn.Assign(bmp);
        $impl.FNormalDisabledBtn = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        $impl.FNormalDisabledBtn.FOnChange = rtl.createCallback(this,"DoBitmapChanged");
        g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        g.FFill.SetColor(16777215);
        g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        g.FStroke.SetColor(16777215);
        g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        g.DrawButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),false,false,false,this.GetAdaptToStyle(),1.0);
        $impl.FNormalDisabledBtn.Assign(bmp);
      } finally {
        g = rtl.freeLoc(g);
        bmp = rtl.freeLoc(bmp);
      };
    };
    this.DoBeforeDraw = function (AGraphics, ARect, ADefaultDraw) {
      if (this.FOnBeforeDraw != null) this.FOnBeforeDraw(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADefaultDraw);
    };
    this.DoAfterDraw = function (AGraphics, ARect) {
      if (this.FOnAfterDraw != null) this.FOnAfterDraw(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DoCanSaveProperty = function (AObject, APropertyName, APropertyType, ACanSave) {
      if (this.FOnCanSaveProperty != null) this.FOnCanSaveProperty(this,AObject,APropertyName,APropertyType,ACanSave);
    };
    this.DoCanLoadProperty = function (AObject, APropertyName, APropertyType, ACanLoad) {
      if (this.FOnCanLoadProperty != null) this.FOnCanLoadProperty(this,AObject,APropertyName,APropertyType,ACanLoad);
    };
    this.DrawBackground = function (AGraphics, ARect) {
      AGraphics.FFill.Assign(this.FFill);
      AGraphics.FFill.SetColor(this.FColor);
      AGraphics.FStroke.Assign(this.FStroke);
      AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.StrokeChanged = function (Sender) {
      this.Invalidate();
    };
    this.FillChanged = function (Sender) {
      if ((this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone) && (this.FFill.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkTexture) && (this.FFill.FColor !== -1)) {
        this.SetColor(this.FFill.FColor)}
       else this.SetColor(-1);
      this.Invalidate();
    };
    this.Draw = function (AGraphics, ARect) {
    };
    this.DrawControl = function () {
      var g = null;
      var gbmp = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var df = false;
      var bmp = null;
      if (this.FBufferedPainting) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[this.GetWidth(),this.GetHeight(),this.FNativeCanvas,true]);
        try {
          if (!g.BeginScene()) {
            pas.SysUtils.FreeAndNil({get: function () {
                return g;
              }, set: function (v) {
                g = v;
              }});
            return;
          };
        } catch ($e) {
          pas.SysUtils.FreeAndNil({get: function () {
              return g;
            }, set: function (v) {
              g = v;
            }});
          return;
        };
      } else g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[this.GetCanvas(),this.FNativeCanvas]);
      g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
      g.GetContext().SetSize(this.GetWidth(),this.GetHeight());
      g.GetContext().SetAntiAliasing(this.FAntiAliasing);
      g.GetContext().SetShowAcceleratorChar(this.FShowAcceleratorChar);
      g.GetContext().SetTextQuality(this.FTextQuality);
      try {
        r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth(),this.GetHeight()));
        df = true;
        this.DoBeforeDraw(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),{get: function () {
            return df;
          }, set: function (v) {
            df = v;
          }});
        if (df) {
          this.DrawBackground(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
          this.Draw(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
          this.DoAfterDraw(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        };
        if (this.FBufferedPainting) g.EndScene();
        g.GetContext().Render();
        if (this.FBufferedPainting) {
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
          try {
            bmp.Assign(g.FBitmap);
            gbmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[this.GetCanvas(),false]);
            try {
              gbmp.GetContext().SetSize(this.GetWidth(),this.GetHeight());
              gbmp.GetContext().SetAntiAliasing(this.FAntiAliasing);
              gbmp.GetContext().SetShowAcceleratorChar(this.FShowAcceleratorChar);
              gbmp.GetContext().SetTextQuality(this.FTextQuality);
              gbmp.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
            } finally {
              gbmp = rtl.freeLoc(gbmp);
            };
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        };
      } finally {
        g = rtl.freeLoc(g);
      };
    };
    this.DoBitmapChanged = function (Sender) {
      if (this.FBlockInvalidate) return;
      this.FBlockInvalidate = true;
      this.Invalidate();
      this.FBlockInvalidate = false;
    };
    this.CaptureEx = function () {
      this.Capture();
    };
    this.ReleaseCaptureEx = function () {
      this.ReleaseCapture();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomControl.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCCustomControl).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomControl).FStroke);
      } else pas["WEBLib.Controls"].TControl.Assign.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomControlBase.Create$1.apply(this,arguments);
      this.SetColor(16777215);
      this.FLinkTouchEvents = true;
      this.FAllowTouch = false;
      this.SetTabStop(true);
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      if (!this.IsDesignerForm()) this.RegisterRuntimeClasses();
      return this;
    };
    this.Destroy = function () {
      if (this.FUndoManager != null) {
        rtl.free(this,"FUndoManager");
        this.FUndoManager = null;
      };
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      $mod.TTMSFNCCustomControlBaseCommon.Destroy.call(this);
    };
    this.GetCheckBoxBitmap = function (AChecked, AFocused, AEnabled) {
      var Result = null;
      if (!($impl.FCheckedChk != null) || !($impl.FCheckedFocusChk != null) || !($impl.FUnCheckedChk != null) || !($impl.FUnCheckedFocusChk != null) || !($impl.FCheckedDisabledChk != null) || !($impl.FUnCheckedDisabledChk != null)) this.CreateCheckBoxBitmaps();
      if (AChecked) {
        if (AEnabled) {
          if (AFocused) {
            Result = $impl.FCheckedFocusChk}
           else Result = $impl.FCheckedChk;
        } else Result = $impl.FCheckedDisabledChk;
      } else {
        if (AEnabled) {
          if (AFocused) {
            Result = $impl.FUnCheckedFocusChk}
           else Result = $impl.FUnCheckedChk;
        } else Result = $impl.FUnCheckedDisabledChk;
      };
      return Result;
    };
    this.GetRadioButtonBitmap = function (AChecked, AFocused, AEnabled) {
      var Result = null;
      if (!($impl.FCheckedRd != null) || !($impl.FCheckedFocusRd != null) || !($impl.FUnCheckedRd != null) || !($impl.FUnCheckedFocusRd != null) || !($impl.FCheckedDisabledRd != null) || !($impl.FUnCheckedDisabledRd != null)) this.CreateRadioButtonBitmaps();
      if (AChecked) {
        if (AEnabled) {
          if (AFocused) {
            Result = $impl.FCheckedFocusRd}
           else Result = $impl.FCheckedRd;
        } else Result = $impl.FCheckedDisabledRd;
      } else {
        if (AEnabled) {
          if (AFocused) {
            Result = $impl.FUnCheckedFocusRd}
           else Result = $impl.FUnCheckedRd;
        } else Result = $impl.FUnCheckedDisabledRd;
      };
      return Result;
    };
    this.GetButtonBitmap = function (AWidth, AHeight, ADown, AFocused, AEnabled) {
      var Result = null;
      this.CreateButtonBitmaps(AWidth,AHeight);
      if (ADown) {
        if (AEnabled) {
          if (AFocused) {
            Result = $impl.FDownFocusBtn}
           else Result = $impl.FDownBtn;
        } else Result = $impl.FNormalDisabledBtn;
      } else {
        if (AEnabled) {
          if (AFocused) {
            Result = $impl.FNormalFocusBtn}
           else Result = $impl.FNormalBtn;
        } else Result = $impl.FNormalDisabledBtn;
      };
      return Result;
    };
    this.IsDesignTime = function () {
      var Result = false;
      Result = false;
      if (this.FOwner != null) Result = this.IsDesigning() && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      return Result;
    };
    this.IsLoading = function () {
      var Result = false;
      Result = false;
      if (this.FOwner != null) Result = pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState;
      return Result;
    };
    this.IsReading = function () {
      var Result = false;
      Result = false;
      if (this.FOwner != null) Result = pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState;
      return Result;
    };
    this.IsDesigning = function () {
      var Result = false;
      Result = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) || (pas["WEBLib.Forms"].VSIDE != null);
      return Result;
    };
    this.IsDesignerForm = function () {
      var Result = false;
      var frm = null;
      frm = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetOwnerForm(this);
      Result = this.IsDesigning();
      if (frm != null) Result = Result || $mod.TTMSFNCCustomDesignerForm.isPrototypeOf(frm);
      return Result;
    };
    this.IsDestroying = function () {
      var Result = false;
      Result = pas.Classes.TComponentStateItem.csDestroying in this.FComponentState;
      return Result;
    };
    this.NotifyDataBinderEdit = function () {
      if (this.FManager != null) this.FManager.Notify(this,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderNotificationType.dbntEdit);
    };
    this.NotifyDataBinderValueChanged = function () {
      if (this.FManager != null) this.FManager.Notify(this,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderNotificationType.dbntValueChanged);
    };
    this.NotifyDataBinderPost = function () {
      if (this.FManager != null) this.FManager.Notify(this,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderNotificationType.dbntPost);
    };
    this.NotifyDataBinderUpdate = function () {
      if (this.FManager != null) this.FManager.Notify(this,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderNotificationType.dbntUpdate);
    };
    this.NotifyDataBinderSetActiveRecord = function () {
      if (this.FManager != null) this.FManager.Notify(this,pas["WEBLib.TMSFNCDataBinding"].TTMSFNCDataBinderNotificationType.dbntSetActiveRecord);
    };
    this.SaveSettingsToFile = function (AFileName, AAppearanceOnly) {
      this.FAppearancePersisting = AAppearanceOnly;
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToFile(this,AFileName);
      this.FAppearancePersisting = false;
    };
    this.LoadSettingsFromFile = function (AFileName) {
      this.BeginUpdate();
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromFile(this,AFileName);
      this.EndUpdate();
      this.Invalidate();
    };
    this.SaveSettingsToStream = function (AStream, AAppearanceOnly) {
      this.FAppearancePersisting = AAppearanceOnly;
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.SaveSettingsToStream(this,AStream);
      this.FAppearancePersisting = false;
    };
    this.LoadSettingsFromStream = function (AStream) {
      this.BeginUpdate();
      pas["WEBLib.TMSFNCPersistence"].TTMSFNCPersistence.LoadSettingsFromStream(this,AStream);
      this.EndUpdate();
      this.Invalidate();
    };
    this.DisableBackground = function () {
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.SetColor(-1);
    };
    this.EnableBackground = function () {
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
    };
    this.DisableFill = function () {
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
    };
    this.EnableFill = function () {
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
    };
    this.DisableStroke = function () {
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
    };
    this.EnableStroke = function () {
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
    };
    this.Resize = function () {
      pas["WEBLib.Controls"].TCustomControl.Resize.call(this);
      this.UpdateControlAfterResize();
    };
    this.Paint = function () {
      pas["WEBLib.Controls"].TCustomControl.Paint.call(this);
      this.DrawControl();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AdaptToStyle",3,rtl.boolean,"GetAdaptToStyle","SetAdaptToStyle",4,{Default: false});
    $r.addProperty("AllowFocus",3,rtl.boolean,"GetAllowFocus","SetAllowFocus",4,{Default: true});
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",4,{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",4,{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",4,{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",4,{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("DoubleBuffered",0,rtl.boolean,"FDoubleBuffered","FDoubleBuffered",4,{Default: false});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",4,{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",4,{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",4,{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ParentDoubleBuffered",0,rtl.boolean,"FParentDoubleBuffered","FParentDoubleBuffered",4,{Default: true});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",4,{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",4,{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",4,{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnMouseWheelUp",0,pas["WEBLib.Controls"].$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelUp","FOnMouseWheelUp");
    $r.addProperty("OnMouseWheelDown",0,pas["WEBLib.Controls"].$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelDown","FOnMouseWheelDown");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("ShowAcceleratorChar",2,rtl.boolean,"FShowAcceleratorChar","SetShowAcceleratorChar",4,{Default: true});
    $r.addProperty("OnBeforeDraw",0,$mod.$rtti["TTMSFNCCustomControlBeforeDrawEvent"],"FOnBeforeDraw","FOnBeforeDraw");
    $r.addProperty("OnAfterDraw",0,$mod.$rtti["TTMSFNCCustomControlAfterDrawEvent"],"FOnAfterDraw","FOnAfterDraw");
    $r.addProperty("OnCanSaveProperty",0,$mod.$rtti["TTMSFNCCustomControlCanSavePropertyEvent"],"FOnCanSaveProperty","FOnCanSaveProperty");
    $r.addProperty("OnCanLoadProperty",0,$mod.$rtti["TTMSFNCCustomControlCanLoadPropertyEvent"],"FOnCanLoadProperty","FOnCanLoadProperty");
  });
  this.$rtti.$ClassRef("TTMSFNCCustomControlClass",{instancetype: this.$rtti["TTMSFNCCustomControl"]});
  rtl.createClass(this,"TTMSFNCControl",this.TTMSFNCCustomControl,function () {
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCControl);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.IsSourceDropFiles = function (ASource) {
    var Result = false;
    Result = $mod.TTMSFNCCustomControlDropFiles.isPrototypeOf(ASource);
    return Result;
  };
  this.AsSourceDropFiles = function (ASource) {
    var Result = null;
    Result = rtl.as(ASource,$mod.TTMSFNCCustomControlDropFiles);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.FCheckedChk = null;
    $impl.FUnCheckedChk = null;
    $impl.FCheckedFocusChk = null;
    $impl.FUnCheckedFocusChk = null;
    $impl.FCheckedDisabledChk = null;
    $impl.FUnCheckedDisabledChk = null;
    $impl.FCheckedRd = null;
    $impl.FUnCheckedRd = null;
    $impl.FCheckedFocusRd = null;
    $impl.FUnCheckedFocusRd = null;
    $impl.FCheckedDisabledRd = null;
    $impl.FUnCheckedDisabledRd = null;
    $impl.FDownBtn = null;
    $impl.FNormalBtn = null;
    $impl.FDownFocusBtn = null;
    $impl.FNormalFocusBtn = null;
    $impl.FNormalDisabledBtn = null;
  };
},["WEBLib.TMSFNCUtils","SysUtils","WEBLib.StdCtrls"]);
rtl.module("WEBLib.TMSFNCScrollBar",["System","Classes","WEBLib.TMSFNCCustomControl","WEBLib.ExtCtrls","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphics","WEBLib.Controls","WEBLib.TMSFNCGraphicsTypes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TTMSFNCCustomScrollBar");
  rtl.createClass(this,"TTMSFNCScrollBarAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FScrollButtonSize = 0.0;
      this.FThumbButtonSize = 0.0;
      this.FOnChange = null;
      this.FFixedThumb = false;
      this.FArrowColor = 0;
      this.FThumbStroke = null;
      this.FThumbButtonRightDownStroke = null;
      this.FThumbFill = null;
      this.FThumbButtonLeftFill = null;
      this.FScrollButtonLeftHoverFill = null;
      this.FScrollButtonLeftStroke = null;
      this.FScrollButtonRightFill = null;
      this.FThumbButtonLeftHoverFill = null;
      this.FThumbButtonLeftStroke = null;
      this.FScrollButtonLeftHoverStroke = null;
      this.FThumbButtonRightFill = null;
      this.FScrollButtonRightHoverFill = null;
      this.FScrollButtonRightStroke = null;
      this.FThumbButtonLeftHoverStroke = null;
      this.FScrollButtonLeftDownFill = null;
      this.FThumbButtonRightHoverFill = null;
      this.FThumbButtonRightStroke = null;
      this.FScrollButtonRightHoverStroke = null;
      this.FThumbButtonLeftDownFill = null;
      this.FScrollButtonLeftDownStroke = null;
      this.FThumbButtonRightHoverStroke = null;
      this.FScrollButtonRightDownFill = null;
      this.FThumbButtonLeftDownStroke = null;
      this.FThumbButtonRightDownFill = null;
      this.FScrollButtonRightDownStroke = null;
      this.FScrollButtonLeftFill = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FOnChange = undefined;
      this.FThumbStroke = undefined;
      this.FThumbButtonRightDownStroke = undefined;
      this.FThumbFill = undefined;
      this.FThumbButtonLeftFill = undefined;
      this.FScrollButtonLeftHoverFill = undefined;
      this.FScrollButtonLeftStroke = undefined;
      this.FScrollButtonRightFill = undefined;
      this.FThumbButtonLeftHoverFill = undefined;
      this.FThumbButtonLeftStroke = undefined;
      this.FScrollButtonLeftHoverStroke = undefined;
      this.FThumbButtonRightFill = undefined;
      this.FScrollButtonRightHoverFill = undefined;
      this.FScrollButtonRightStroke = undefined;
      this.FThumbButtonLeftHoverStroke = undefined;
      this.FScrollButtonLeftDownFill = undefined;
      this.FThumbButtonRightHoverFill = undefined;
      this.FThumbButtonRightStroke = undefined;
      this.FScrollButtonRightHoverStroke = undefined;
      this.FThumbButtonLeftDownFill = undefined;
      this.FScrollButtonLeftDownStroke = undefined;
      this.FThumbButtonRightHoverStroke = undefined;
      this.FScrollButtonRightDownFill = undefined;
      this.FThumbButtonLeftDownStroke = undefined;
      this.FThumbButtonRightDownFill = undefined;
      this.FScrollButtonRightDownStroke = undefined;
      this.FScrollButtonLeftFill = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetThumbButtonSize = function (Value) {
      if (this.FThumbButtonSize !== Value) {
        this.FThumbButtonSize = Value;
        this.Changed();
      };
    };
    this.SetFixedThumb = function (Value) {
      if (this.FFixedThumb !== Value) {
        this.FFixedThumb = Value;
        this.Changed();
      };
    };
    this.SetArrowColor = function (Value) {
      if (this.FArrowColor !== Value) {
        this.FArrowColor = Value;
        this.Changed();
      };
    };
    this.SetScrollButtonLeftDownFill = function (Value) {
      this.FScrollButtonLeftDownFill.Assign(Value);
    };
    this.SetScrollButtonLeftDownStroke = function (Value) {
      this.FScrollButtonLeftDownStroke.Assign(Value);
    };
    this.SetScrollButtonLeftFill = function (Value) {
      this.FScrollButtonLeftFill.Assign(Value);
    };
    this.SetScrollButtonLeftHoverFill = function (Value) {
      this.FScrollButtonLeftHoverFill.Assign(Value);
    };
    this.SetScrollButtonLeftHoverStroke = function (Value) {
      this.FScrollButtonLeftHoverStroke.Assign(Value);
    };
    this.SetScrollButtonLeftStroke = function (Value) {
      this.FScrollButtonLeftStroke.Assign(Value);
    };
    this.SetScrollButtonRightDownFill = function (Value) {
      this.FScrollButtonRightDownFill.Assign(Value);
    };
    this.SetScrollButtonRightDownStroke = function (Value) {
      this.FScrollButtonRightDownStroke.Assign(Value);
    };
    this.SetScrollButtonRightFill = function (Value) {
      this.FScrollButtonRightFill.Assign(Value);
    };
    this.SetScrollButtonRightHoverFill = function (Value) {
      this.FScrollButtonRightHoverFill.Assign(Value);
    };
    this.SetScrollButtonRightHoverStroke = function (Value) {
      this.FScrollButtonRightHoverStroke.Assign(Value);
    };
    this.SetScrollButtonRightStroke = function (Value) {
      this.FScrollButtonRightStroke.Assign(Value);
    };
    this.SetScrollButtonSize = function (Value) {
      if (this.FScrollButtonSize !== Value) {
        this.FScrollButtonSize = Value;
        this.Changed();
      };
    };
    this.SetThumbButtonLeftDownFill = function (Value) {
      this.FThumbButtonLeftDownFill.Assign(Value);
    };
    this.SetThumbButtonLeftDownStroke = function (Value) {
      this.FThumbButtonLeftDownStroke.Assign(Value);
    };
    this.SetThumbButtonLeftFill = function (Value) {
      this.FThumbButtonLeftFill.Assign(Value);
    };
    this.SetThumbButtonLeftHoverFill = function (Value) {
      this.FThumbButtonLeftHoverFill.Assign(Value);
    };
    this.SetThumbButtonLeftHoverStroke = function (Value) {
      this.FThumbButtonLeftHoverStroke.Assign(Value);
    };
    this.SetThumbButtonLeftStroke = function (Value) {
      this.FThumbButtonLeftStroke.Assign(Value);
    };
    this.SetThumbButtonRightDownFill = function (Value) {
      this.FThumbButtonRightDownFill.Assign(Value);
    };
    this.SetThumbButtonRightDownStroke = function (Value) {
      this.FThumbButtonRightDownStroke.Assign(Value);
    };
    this.SetThumbButtonRightFill = function (Value) {
      this.FThumbButtonRightFill.Assign(Value);
    };
    this.SetThumbButtonRightHoverFill = function (Value) {
      this.FThumbButtonRightHoverFill.Assign(Value);
    };
    this.SetThumbButtonRightHoverStroke = function (Value) {
      this.FThumbButtonRightHoverStroke.Assign(Value);
    };
    this.SetThumbButtonRightStroke = function (Value) {
      this.FThumbButtonRightStroke.Assign(Value);
    };
    this.SetThumbFill = function (Value) {
      this.FThumbFill.Assign(Value);
    };
    this.SetThumbStroke = function (Value) {
      this.FThumbStroke.Assign(Value);
    };
    this.IsScrollButtonSizeStored = function () {
      var Result = false;
      Result = this.FScrollButtonSize !== 18;
      return Result;
    };
    this.IsThumbButtonSizeStored = function () {
      var Result = false;
      Result = this.FThumbButtonSize !== 18;
      return Result;
    };
    this.Changed = function () {
      this.FOwner.Changed();
    };
    this.FillChanged = function (Sender) {
      this.Changed();
    };
    this.StrokeChanged = function (Sender) {
      this.Changed();
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FThumbFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225),8421504,-1,-1]);
      this.FThumbFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbButtonLeftFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225),8421504,-1,-1]);
      this.FThumbButtonLeftFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbButtonRightFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225),8421504,-1,-1]);
      this.FThumbButtonRightFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbButtonLeftHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),8421504,-1,-1]);
      this.FThumbButtonLeftHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbButtonRightHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),8421504,-1,-1]);
      this.FThumbButtonRightHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbButtonLeftDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),40),8421504,-1,-1]);
      this.FThumbButtonLeftDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbButtonRightDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),40),8421504,-1,-1]);
      this.FThumbButtonRightDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FScrollButtonLeftFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225),8421504,-1,-1]);
      this.FScrollButtonLeftFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FScrollButtonRightFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225),8421504,-1,-1]);
      this.FScrollButtonRightFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FScrollButtonLeftHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),8421504,-1,-1]);
      this.FScrollButtonLeftHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FScrollButtonRightHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),8421504,-1,-1]);
      this.FScrollButtonRightHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FScrollButtonLeftDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),40),8421504,-1,-1]);
      this.FScrollButtonLeftDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FScrollButtonRightDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,241,251),40),8421504,-1,-1]);
      this.FScrollButtonRightDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FThumbStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(11119017,40),1.0]);
      this.FThumbStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FThumbButtonLeftStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(11119017,40),1.0]);
      this.FThumbButtonLeftStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FThumbButtonRightStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(11119017,40),1.0]);
      this.FThumbButtonRightStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FThumbButtonLeftHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FThumbButtonLeftHoverStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FThumbButtonRightHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FThumbButtonRightHoverStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FThumbButtonLeftDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FThumbButtonLeftDownStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FThumbButtonRightDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FThumbButtonRightDownStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FScrollButtonLeftStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(11119017,40),1.0]);
      this.FScrollButtonLeftStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FScrollButtonRightStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].Darker(11119017,40),1.0]);
      this.FScrollButtonRightStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FScrollButtonLeftHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FScrollButtonLeftHoverStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FScrollButtonRightHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FScrollButtonRightHoverStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FScrollButtonLeftDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FScrollButtonLeftDownStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FScrollButtonRightDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(60,127,177),1.0]);
      this.FScrollButtonRightDownStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FArrowColor = 0;
      this.FFixedThumb = false;
      this.FThumbButtonSize = 18;
      this.FScrollButtonSize = 18;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FThumbFill");
      rtl.free(this,"FScrollButtonLeftFill");
      rtl.free(this,"FScrollButtonRightFill");
      rtl.free(this,"FScrollButtonLeftHoverFill");
      rtl.free(this,"FScrollButtonRightHoverFill");
      rtl.free(this,"FScrollButtonLeftDownFill");
      rtl.free(this,"FScrollButtonRightDownFill");
      rtl.free(this,"FThumbButtonLeftFill");
      rtl.free(this,"FThumbButtonRightFill");
      rtl.free(this,"FThumbButtonLeftHoverFill");
      rtl.free(this,"FThumbButtonRightHoverFill");
      rtl.free(this,"FThumbButtonLeftDownFill");
      rtl.free(this,"FThumbButtonRightDownFill");
      rtl.free(this,"FThumbStroke");
      rtl.free(this,"FScrollButtonLeftStroke");
      rtl.free(this,"FScrollButtonRightStroke");
      rtl.free(this,"FScrollButtonLeftHoverStroke");
      rtl.free(this,"FScrollButtonRightHoverStroke");
      rtl.free(this,"FScrollButtonLeftDownStroke");
      rtl.free(this,"FScrollButtonRightDownStroke");
      rtl.free(this,"FThumbButtonLeftStroke");
      rtl.free(this,"FThumbButtonRightStroke");
      rtl.free(this,"FThumbButtonLeftHoverStroke");
      rtl.free(this,"FThumbButtonRightHoverStroke");
      rtl.free(this,"FThumbButtonLeftDownStroke");
      rtl.free(this,"FThumbButtonRightDownStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCScrollBarAppearance.isPrototypeOf(Source)) {
        this.FThumbFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbFill);
        this.FScrollButtonSize = rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonSize;
        this.FThumbButtonSize = rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonSize;
        this.FThumbStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbStroke);
        this.FThumbButtonLeftFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonLeftFill);
        this.FThumbButtonLeftHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonLeftHoverFill);
        this.FThumbButtonLeftDownFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonLeftDownFill);
        this.FThumbButtonRightFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonRightFill);
        this.FThumbButtonRightDownFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonRightDownFill);
        this.FThumbButtonRightHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonRightHoverFill);
        this.FScrollButtonLeftFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonLeftFill);
        this.FScrollButtonLeftHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonLeftHoverFill);
        this.FScrollButtonLeftDownFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonLeftDownFill);
        this.FScrollButtonRightFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonRightFill);
        this.FScrollButtonRightDownFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonRightDownFill);
        this.FScrollButtonRightHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonRightHoverFill);
        this.FThumbButtonLeftStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonLeftStroke);
        this.FThumbButtonLeftHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonLeftHoverStroke);
        this.FThumbButtonLeftDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonLeftDownStroke);
        this.FThumbButtonRightStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonRightStroke);
        this.FThumbButtonRightDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonRightDownStroke);
        this.FThumbButtonRightHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FThumbButtonRightHoverStroke);
        this.FScrollButtonLeftStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonLeftStroke);
        this.FScrollButtonLeftHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonLeftHoverStroke);
        this.FScrollButtonLeftDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonLeftDownStroke);
        this.FScrollButtonRightStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonRightStroke);
        this.FScrollButtonRightDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonRightDownStroke);
        this.FScrollButtonRightHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCScrollBarAppearance).FScrollButtonRightHoverStroke);
        this.Changed();
      };
    };
    this.GetThumbButtonSize = function () {
      var Result = 0.0;
      if (this.FFixedThumb) {
        Result = 0}
       else Result = this.FThumbButtonSize;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("ThumbFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbFill","SetThumbFill");
    $r.addProperty("ScrollButtonLeftFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FScrollButtonLeftFill","SetScrollButtonLeftFill");
    $r.addProperty("ScrollButtonRightFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FScrollButtonRightFill","SetScrollButtonRightFill");
    $r.addProperty("ScrollButtonLeftHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FScrollButtonLeftHoverFill","SetScrollButtonLeftHoverFill");
    $r.addProperty("ScrollButtonRightHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FScrollButtonRightHoverFill","SetScrollButtonRightHoverFill");
    $r.addProperty("ScrollButtonLeftDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FScrollButtonLeftDownFill","SetScrollButtonLeftDownFill");
    $r.addProperty("ScrollButtonRightDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FScrollButtonRightDownFill","SetScrollButtonRightDownFill");
    $r.addProperty("ThumbButtonLeftFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbButtonLeftFill","SetThumbButtonLeftFill");
    $r.addProperty("ThumbButtonRightFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbButtonRightFill","SetThumbButtonRightFill");
    $r.addProperty("ThumbButtonLeftHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbButtonLeftHoverFill","SetThumbButtonLeftHoverFill");
    $r.addProperty("ThumbButtonRightHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbButtonRightHoverFill","SetThumbButtonRightHoverFill");
    $r.addProperty("ThumbButtonLeftDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbButtonLeftDownFill","SetThumbButtonLeftDownFill");
    $r.addProperty("ThumbButtonRightDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FThumbButtonRightDownFill","SetThumbButtonRightDownFill");
    $r.addProperty("ThumbStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbStroke","SetThumbStroke");
    $r.addProperty("ScrollButtonLeftStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FScrollButtonLeftStroke","SetScrollButtonLeftStroke");
    $r.addProperty("ScrollButtonRightStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FScrollButtonRightStroke","SetScrollButtonRightStroke");
    $r.addProperty("ScrollButtonLeftHoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FScrollButtonLeftHoverStroke","SetScrollButtonLeftHoverStroke");
    $r.addProperty("ScrollButtonRightHoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FScrollButtonRightHoverStroke","SetScrollButtonRightHoverStroke");
    $r.addProperty("ScrollButtonLeftDownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FScrollButtonLeftDownStroke","SetScrollButtonLeftDownStroke");
    $r.addProperty("ScrollButtonRightDownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FScrollButtonRightDownStroke","SetScrollButtonRightDownStroke");
    $r.addProperty("ThumbButtonLeftStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbButtonLeftStroke","SetThumbButtonLeftStroke");
    $r.addProperty("ThumbButtonRightStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbButtonRightStroke","SetThumbButtonRightStroke");
    $r.addProperty("ThumbButtonLeftHoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbButtonLeftHoverStroke","SetThumbButtonLeftHoverStroke");
    $r.addProperty("ThumbButtonRightHoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbButtonRightHoverStroke","SetThumbButtonRightHoverStroke");
    $r.addProperty("ThumbButtonLeftDownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbButtonLeftDownStroke","SetThumbButtonLeftDownStroke");
    $r.addProperty("ThumbButtonRightDownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FThumbButtonRightDownStroke","SetThumbButtonRightDownStroke");
    $r.addProperty("ThumbButtonSize",14,rtl.double,"FThumbButtonSize","SetThumbButtonSize",4,{stored: "IsThumbButtonSizeStored"});
    $r.addProperty("ScrollButtonSize",14,rtl.double,"FScrollButtonSize","SetScrollButtonSize",4,{stored: "IsScrollButtonSizeStored"});
    $r.addProperty("FixedThumb",2,rtl.boolean,"FFixedThumb","SetFixedThumb",4,{Default: false});
    $r.addProperty("ArrowColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FArrowColor","SetArrowColor",4,{Default: 0});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  this.TTMSFNCScrollBarMode = {"0": "sbmNone", sbmNone: 0, "1": "sbmScroll", sbmScroll: 1, "2": "sbmChangePageSize", sbmChangePageSize: 2};
  this.$rtti.$Enum("TTMSFNCScrollBarMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCScrollBarMode});
  this.TTMSFNCScrollBarHoveredButton = {"0": "shbNone", shbNone: 0, "1": "shbScrollMin", shbScrollMin: 1, "2": "shbScrollMax", shbScrollMax: 2, "3": "shbThumbMin", shbThumbMin: 3, "4": "shbThumbMax", shbThumbMax: 4};
  this.$rtti.$Enum("TTMSFNCScrollBarHoveredButton",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCScrollBarHoveredButton});
  this.TTMSFNCScrollBarDownButton = {"0": "sdbNone", sdbNone: 0, "1": "sdbScrollMin", sdbScrollMin: 1, "2": "sdbScrollMax", sdbScrollMax: 2, "3": "sdbThumbMin", sdbThumbMin: 3, "4": "sdbThumbMax", sdbThumbMax: 4};
  this.$rtti.$Enum("TTMSFNCScrollBarDownButton",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCScrollBarDownButton});
  this.TTMSFNCScrollButtonChange = {"0": "sbcNone", sbcNone: 0, "1": "sbcSmallSubstract", sbcSmallSubstract: 1, "2": "sbcSmallAdd", sbcSmallAdd: 2, "3": "sbcLargeSubstract", sbcLargeSubstract: 3, "4": "sbcLargeAdd", sbcLargeAdd: 4};
  this.$rtti.$Enum("TTMSFNCScrollButtonChange",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCScrollButtonChange});
  this.$rtti.$MethodVar("TTMSFNCScrollBarValueChanged",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Value",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCScrollBarPageSizeChanged",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["PageSize",rtl.double]]), methodkind: 0});
  this.TTMSFNCScrollBarKind = {"0": "sbkHorizontal", sbkHorizontal: 0, "1": "sbkVertical", sbkVertical: 1};
  this.$rtti.$Enum("TTMSFNCScrollBarKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCScrollBarKind});
  rtl.createClass(this,"TTMSFNCCustomScrollBar",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FBlockChange = false;
      this.FNeedsChange = false;
      this.FSavedPageSize = 0.0;
      this.FDesignTime$1 = false;
      this.FMinThumb = false;
      this.FMaxThumb = false;
      this.FMx = 0.0;
      this.FMy = 0.0;
      this.FCx = 0.0;
      this.FCy = 0.0;
      this.FTimer = null;
      this.FTime = 0;
      this.FScrollBarMode = 0;
      this.FScrollButtonChange = 0;
      this.FHoveredButton = 0;
      this.FDownButton = 0;
      this.FKind = 0;
      this.FValue = 0.0;
      this.FTempValue = 0.0;
      this.FMin = 0.0;
      this.FMax = 0.0;
      this.FPageSize = 0.0;
      this.FSmallChange = 0.0;
      this.FLargeChange = 0.0;
      this.FAppearance = null;
      this.FOnValueChange = null;
      this.FOnPageSizeChanged = null;
      this.FTracking = false;
    };
    this.$final = function () {
      this.FTimer = undefined;
      this.FAppearance = undefined;
      this.FOnValueChange = undefined;
      this.FOnPageSizeChanged = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      if (this.FAppearance !== Value) {
        this.FAppearance.Assign(Value);
        this.Changed();
      };
    };
    this.SetKind = function (Value) {
      if (this.FKind !== Value) {
        this.FKind = Value;
        this.SetBounds(this.GetLeft(),this.GetTop(),this.GetHeight(),this.GetWidth());
        this.Changed();
      };
    };
    this.SetMax = function (Value) {
      if (this.FMax !== Value) {
        this.FMax = Value;
        this.Changed();
      };
    };
    this.SetMin = function (Value) {
      if (this.FMin !== Value) {
        this.FMin = Value;
        this.Changed();
      };
    };
    this.SetValue = function (Value) {
      if (this.FBlockChange) return;
      if (this.FValue !== Value) {
        this.FValue = Math.min(Math.max(Value,this.FMin),this.FMax - this.FPageSize);
        this.FTempValue = this.FValue;
        if (this.FOnValueChange != null) {
          this.FBlockChange = true;
          this.FOnValueChange(this,this.FValue);
          this.FBlockChange = false;
        };
        this.Changed();
      };
    };
    this.SetPageSize = function (Value) {
      if (this.FBlockChange) return;
      if (this.FPageSize !== Value) {
        this.FPageSize = Math.max(Math.min(this.GetRange(),Value),0);
        if (this.FOnPageSizeChanged != null) {
          this.FBlockChange = true;
          this.FOnPageSizeChanged(this,this.FPageSize);
          this.FBlockChange = false;
        };
        this.Changed();
      };
    };
    this.IsLargeChangeStored = function () {
      var Result = false;
      Result = this.FLargeChange !== 20;
      return Result;
    };
    this.IsMaxStored = function () {
      var Result = false;
      Result = this.FMax !== 100;
      return Result;
    };
    this.IsMinStored = function () {
      var Result = false;
      Result = this.FMin !== 0;
      return Result;
    };
    this.IsPageSizeStored = function () {
      var Result = false;
      Result = this.FPageSize !== 20;
      return Result;
    };
    this.IsSmallChangeStored = function () {
      var Result = false;
      Result = this.FSmallChange !== 1;
      return Result;
    };
    this.IsValueStored = function () {
      var Result = false;
      Result = this.FValue !== 0;
      return Result;
    };
    this.SetTracking = function (Value) {
      if (this.FTracking !== Value) {
        this.FTracking = Value;
        this.Changed();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FAppearance.FScrollButtonSize = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FScrollButtonSize,M,D);
      this.FAppearance.FThumbButtonSize = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FThumbButtonSize,M,D);
      this.EndUpdate();
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FThumbFill.SetColor(c);
        this.FAppearance.FThumbButtonLeftFill.SetColor(c);
        this.FAppearance.FThumbButtonRightFill.SetColor(c);
        this.FAppearance.FScrollButtonLeftFill.SetColor(c);
        this.FAppearance.FScrollButtonRightFill.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FThumbStroke.SetColor(c);
        this.FAppearance.FThumbButtonLeftStroke.SetColor(c);
        this.FAppearance.FThumbButtonRightStroke.SetColor(c);
        this.FAppearance.FScrollButtonLeftStroke.SetColor(c);
        this.FAppearance.FScrollButtonRightStroke.SetColor(c);
        this.FAppearance.FThumbButtonLeftHoverStroke.SetColor(c);
        this.FAppearance.FThumbButtonRightHoverStroke.SetColor(c);
        this.FAppearance.FScrollButtonLeftHoverStroke.SetColor(c);
        this.FAppearance.FScrollButtonRightHoverStroke.SetColor(c);
        this.FAppearance.FThumbButtonLeftDownStroke.SetColor(c);
        this.FAppearance.FThumbButtonRightDownStroke.SetColor(c);
        this.FAppearance.FScrollButtonLeftDownStroke.SetColor(c);
        this.FAppearance.FScrollButtonRightDownStroke.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FThumbButtonLeftHoverFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,70));
        this.FAppearance.FThumbButtonRightHoverFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,70));
        this.FAppearance.FScrollButtonLeftHoverFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,70));
        this.FAppearance.FScrollButtonRightHoverFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,70));
        this.FAppearance.FThumbButtonLeftDownFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,50));
        this.FAppearance.FThumbButtonRightDownFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,50));
        this.FAppearance.FScrollButtonLeftDownFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,50));
        this.FAppearance.FScrollButtonRightDownFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FFill.FColor,c,50));
        this.FAppearance.SetArrowColor(c);
      };
    };
    this.ResetToDefaultStyle = function () {
      var ia = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      ia = $mod.TTMSFNCScrollBarAppearance.$create("Create$1",[null]);
      try {
        this.FAppearance.Assign(ia);
      } finally {
        ia = rtl.freeLoc(ia);
      };
    };
    this.HandleKeyDown = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      var $tmp = Key.get();
      if (($tmp === 38) || ($tmp === 37)) {
        this.SetValue(this.FValue - this.FSmallChange)}
       else if (($tmp === 40) || ($tmp === 39)) {
        this.SetValue(this.FValue + this.FSmallChange)}
       else if ($tmp === 36) {
        this.SetValue(this.FMin)}
       else if ($tmp === 35) {
        this.SetValue(this.FMax)}
       else if ($tmp === 33) {
        this.SetValue(this.FValue - this.FLargeChange)}
       else if ($tmp === 34) this.SetValue(this.FValue + this.FLargeChange);
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if (this.FParent != null) this.CaptureEx();
      this.FCx = Math.abs((X - this.GetThumbRectangle().Left) + this.GetScrollRectangle().Left);
      this.FCy = Math.abs((Y - this.GetThumbRectangle().Top) + this.GetScrollRectangle().Top);
      this.FMx = X;
      this.FMy = Y;
      this.FSavedPageSize = this.FPageSize;
      this.FTime = 0;
      this.FTimer.SetEnabled(true);
      if (this.MouseOnThumbButtons(X,Y)) {
        this.FScrollBarMode = $mod.TTMSFNCScrollBarMode.sbmChangePageSize;
        this.FMinThumb = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
        this.FMaxThumb = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
      } else if (this.MouseOnThumb(X,Y)) {
        this.FScrollBarMode = $mod.TTMSFNCScrollBarMode.sbmScroll}
       else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.FScrollButtonChange = $mod.TTMSFNCScrollButtonChange.sbcSmallSubstract}
       else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.FScrollButtonChange = $mod.TTMSFNCScrollButtonChange.sbcSmallAdd}
       else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetScrollAreaMin(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.FScrollButtonChange = $mod.TTMSFNCScrollButtonChange.sbcLargeSubstract}
       else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetScrollAreaMax(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) this.FScrollButtonChange = $mod.TTMSFNCScrollButtonChange.sbcLargeAdd;
      if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbThumbMin)) {
        this.FDownButton = $mod.TTMSFNCScrollBarDownButton.sdbThumbMin;
        this.Changed();
      } else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbThumbMax)) {
        this.FDownButton = $mod.TTMSFNCScrollBarDownButton.sdbThumbMax;
        this.Changed();
      } else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbScrollMin)) {
        this.FDownButton = $mod.TTMSFNCScrollBarDownButton.sdbScrollMin;
        this.Changed();
      } else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbScrollMax)) {
        this.FDownButton = $mod.TTMSFNCScrollBarDownButton.sdbScrollMax;
        this.Changed();
      };
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var pos = 0.0;
      var v = 0.0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (this.FScrollBarMode === $mod.TTMSFNCScrollBarMode.sbmChangePageSize) {
        var $tmp = this.FKind;
        if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
          this.SetControlCursor(9)}
         else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) this.SetControlCursor(7);
        var $tmp1 = this.FKind;
        if ($tmp1 === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
          pos = (this.GetRange() / (this.GetScrollRectangle().Right - this.GetScrollRectangle().Left)) * (X - this.FMx)}
         else if ($tmp1 === $mod.TTMSFNCScrollBarKind.sbkVertical) {
          pos = (this.GetRange() / (this.GetScrollRectangle().Bottom - this.GetScrollRectangle().Top)) * (Y - this.FMy)}
         else {
          pos = 0;
        };
        if (this.FMinThumb) {
          if ((this.FValue - this.FMin) > 0) {
            this.SetPageSize(this.FSavedPageSize - (pos * (this.GetRange() / (this.FValue - this.FMin))))}
           else this.SetPageSize(this.FSavedPageSize - pos);
        } else if (this.FMaxThumb) {
          if ((this.FValue - this.FMin) < this.GetRange()) {
            this.SetPageSize(this.FSavedPageSize + (pos * (this.GetRange() / (this.FMax - this.FValue))))}
           else this.SetPageSize(this.FSavedPageSize + pos);
        };
      } else if (this.FScrollBarMode === $mod.TTMSFNCScrollBarMode.sbmScroll) {
        var $tmp2 = this.FKind;
        if ($tmp2 === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
          pos = X - this.FCx}
         else if ($tmp2 === $mod.TTMSFNCScrollBarKind.sbkVertical) {
          pos = Y - this.FCy}
         else {
          pos = 0;
        };
        v = this.GetValue$1(pos);
        if (this.FTracking) {
          this.SetValue(v)}
         else {
          this.FTempValue = v;
          this.Changed();
        };
      } else if (this.MouseOnThumbButtons(X,Y)) {
        var $tmp3 = this.FKind;
        if ($tmp3 === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
          this.SetControlCursor(9)}
         else if ($tmp3 === $mod.TTMSFNCScrollBarKind.sbkVertical) this.SetControlCursor(7);
      } else {
        this.SetControlCursor(0);
      };
      if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbThumbMin)) {
        this.FHoveredButton = $mod.TTMSFNCScrollBarHoveredButton.shbThumbMin;
        this.Changed();
      } else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbThumbMax)) {
        this.FHoveredButton = $mod.TTMSFNCScrollBarHoveredButton.shbThumbMax;
        this.Changed();
      } else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbScrollMin)) {
        this.FHoveredButton = $mod.TTMSFNCScrollBarHoveredButton.shbScrollMin;
        this.Changed();
      } else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !(this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbScrollMax)) {
        this.FHoveredButton = $mod.TTMSFNCScrollBarHoveredButton.shbScrollMax;
        this.Changed();
      } else if (!pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && !pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && (this.FHoveredButton !== $mod.TTMSFNCScrollBarHoveredButton.shbNone)) {
        this.FHoveredButton = $mod.TTMSFNCScrollBarHoveredButton.shbNone;
        this.Changed();
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      if (this.FParent != null) this.ReleaseCaptureEx();
      if ((this.FScrollBarMode === $mod.TTMSFNCScrollBarMode.sbmScroll) && !this.FTracking) this.SetValue(this.FTempValue);
      if (this.FScrollBarMode === $mod.TTMSFNCScrollBarMode.sbmNone) {
        if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
          this.SetValue(this.FValue - this.FSmallChange)}
         else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxScrollButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
          this.SetValue(this.FValue + this.FSmallChange)}
         else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetScrollAreaMin(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
          this.SetValue(this.FValue - this.FLargeChange)}
         else if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetScrollAreaMax(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) this.SetValue(this.FValue + this.FLargeChange);
      };
      this.FDownButton = $mod.TTMSFNCScrollBarDownButton.sdbNone;
      this.FMinThumb = false;
      this.FMaxThumb = false;
      this.FTimer.SetEnabled(false);
      this.FTime = 0;
      this.FScrollBarMode = $mod.TTMSFNCScrollBarMode.sbmNone;
      this.SetControlCursor(0);
      this.FScrollButtonChange = $mod.TTMSFNCScrollButtonChange.sbcNone;
      this.Changed();
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FTimer.SetEnabled(false);
      this.FTime = 0;
      this.FScrollBarMode = $mod.TTMSFNCScrollBarMode.sbmNone;
      this.FScrollButtonChange = $mod.TTMSFNCScrollButtonChange.sbcNone;
      this.FMinThumb = false;
      this.FMaxThumb = false;
      this.FDownButton = $mod.TTMSFNCScrollBarDownButton.sdbNone;
      this.FHoveredButton = $mod.TTMSFNCScrollBarHoveredButton.shbNone;
      this.Changed();
    };
    this.HandleMouseEnter = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseEnter.call(this);
    };
    this.HandleMouseWheel = function (Shift, WheelDelta, Handled) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseWheel.apply(this,arguments);
      if (WheelDelta < 0) {
        this.SetValue(this.FValue + this.FLargeChange)}
       else this.SetValue(this.FValue - this.FLargeChange);
    };
    this.Changed = function () {
      this.Invalidate();
    };
    this.AppearanceChanged = function (Sender) {
      this.Changed();
    };
    this.TimerChanged = function (Sender) {
      this.FTime += 1;
      if (this.FTime >= 4) {
        if (this.FScrollButtonChange === $mod.TTMSFNCScrollButtonChange.sbcSmallSubstract) {
          this.SetValue(this.FValue - this.FSmallChange);
          this.Changed();
        } else if (this.FScrollButtonChange === $mod.TTMSFNCScrollButtonChange.sbcSmallAdd) {
          this.SetValue(this.FValue + this.FSmallChange);
          this.Changed();
        } else if (this.FScrollButtonChange === $mod.TTMSFNCScrollButtonChange.sbcLargeSubstract) {
          this.SetValue(this.FValue - this.FLargeChange);
          this.Changed();
        } else if (this.FScrollButtonChange === $mod.TTMSFNCScrollButtonChange.sbcLargeAdd) {
          this.SetValue(this.FValue + this.FLargeChange);
          this.Changed();
        };
      };
    };
    this.GetCalculationRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetLocalRect());
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack";
      return Result;
    };
    this.GetMinScrollButton = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetCalculationRect());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,this.FAppearance.FScrollButtonSize,r.Bottom - r.Top))}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left,this.FAppearance.FScrollButtonSize));
      return Result;
    };
    this.GetMaxScrollButton = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetCalculationRect());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - this.FAppearance.FScrollButtonSize,r.Top,this.FAppearance.FScrollButtonSize,r.Bottom - r.Top))}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Bottom - this.FAppearance.FScrollButtonSize,r.Right - r.Left,this.FAppearance.FScrollButtonSize));
      return Result;
    };
    this.GetMinThumbButton = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetThumbRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,this.FAppearance.GetThumbButtonSize(),r.Bottom - r.Top))}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left,this.FAppearance.GetThumbButtonSize()));
      return Result;
    };
    this.GetMaxThumbButton = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetThumbRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF((r.Left + (r.Right - r.Left)) - this.FAppearance.GetThumbButtonSize(),r.Top,this.FAppearance.GetThumbButtonSize(),r.Bottom - r.Top))}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,(r.Top + (r.Bottom - r.Top)) - this.FAppearance.GetThumbButtonSize(),r.Right - r.Left,this.FAppearance.GetThumbButtonSize()));
      return Result;
    };
    this.GetScrollRectangle = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.Left = this.GetMinScrollButton().Left + (this.GetMinScrollButton().Right - this.GetMinScrollButton().Left);
        Result.Top = this.GetMinScrollButton().Top;
        Result.Bottom = Result.Top + (this.GetMinScrollButton().Bottom - this.GetMinScrollButton().Top);
        Result.Right = this.GetMaxScrollButton().Left;
      } else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        Result.Left = this.GetMinScrollButton().Left;
        Result.Top = this.GetMinScrollButton().Top + (this.GetMinScrollButton().Bottom - this.GetMinScrollButton().Top);
        Result.Bottom = this.GetMaxScrollButton().Top;
        Result.Right = Result.Left + (this.GetMinScrollButton().Right - this.GetMinScrollButton().Left);
      };
      return Result;
    };
    this.GetScrollSize = function () {
      var Result = 0.0;
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result = this.GetScrollRectangle().Right - this.GetScrollRectangle().Left - (this.GetThumbRectangle().Right - this.GetThumbRectangle().Left)}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        Result = this.GetScrollRectangle().Bottom - this.GetScrollRectangle().Top - (this.GetThumbRectangle().Bottom - this.GetThumbRectangle().Top)}
       else {
        Result = 0;
      };
      return Result;
    };
    this.GetScrollAreaMin = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var scr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var thr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      scr.$assign(this.GetScrollRectangle());
      thr.$assign(this.GetThumbRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.Left = scr.Left;
        Result.Top = scr.Top;
        Result.Right = Result.Left + (thr.Left - scr.Left);
        Result.Bottom = Result.Top + (scr.Bottom - scr.Top);
      } else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        Result.Left = scr.Left;
        Result.Top = scr.Top;
        Result.Right = Result.Left + (scr.Right - scr.Left);
        Result.Bottom = Result.Top + (thr.Top - scr.Top);
      };
      return Result;
    };
    this.GetScrollAreaMax = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var scr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var thr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      scr.$assign(this.GetScrollRectangle());
      thr.$assign(this.GetThumbRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        Result.Left = thr.Left + (thr.Right - thr.Left);
        Result.Top = scr.Top;
        Result.Right = ((Result.Left + (scr.Right - scr.Left)) - (thr.Right - thr.Left) - thr.Left) + scr.Left;
        Result.Bottom = Result.Top + (scr.Bottom - scr.Top);
      } else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        Result.Left = scr.Left;
        Result.Top = thr.Top + (thr.Bottom - thr.Top);
        Result.Right = Result.Left + (scr.Right - scr.Left);
        Result.Bottom = ((Result.Top + (scr.Bottom - scr.Top)) - (thr.Bottom - thr.Top) - thr.Top) + scr.Top;
      };
      return Result;
    };
    this.GetThumbRectangle = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var scr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var s = 0.0;
      scr.$assign(this.GetScrollRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        s = ((scr.Right - scr.Left) / this.GetRange()) * this.FPageSize;
        Result.Left = scr.Left + this.GetValue();
        Result.Top = scr.Top;
        Result.Right = Result.Left + Math.max((this.FAppearance.GetThumbButtonSize() * 2) + this.ScalePaintValue(10),s);
        Result.Bottom = Result.Top + (scr.Bottom - scr.Top);
      } else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        s = ((scr.Bottom - scr.Top) / this.GetRange()) * this.FPageSize;
        Result.Left = scr.Left;
        Result.Top = scr.Top + this.GetValue();
        Result.Right = Result.Left + (scr.Right - scr.Left);
        Result.Bottom = Result.Top + Math.max((this.FAppearance.GetThumbButtonSize() * 2) + this.ScalePaintValue(10),s);
      };
      return Result;
    };
    this.GetValue = function () {
      var Result = 0.0;
      var s = 0.0;
      var scr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result = 0;
      scr.$assign(this.GetScrollRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        s = scr.Right - scr.Left - Math.max((this.FAppearance.GetThumbButtonSize() * 2) + 10,((scr.Right - scr.Left) / this.GetRange()) * this.FPageSize)}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        s = scr.Bottom - scr.Top - Math.max((this.FAppearance.GetThumbButtonSize() * 2) + 10,((scr.Bottom - scr.Top) / this.GetRange()) * this.FPageSize)}
       else {
        s = 0;
      };
      if (s <= 0) return Result;
      if ((this.FMax - this.FMin) > 0) {
        if (this.FTracking) {
          Result = Math.min(((this.FValue - this.FMin) / (this.FMax - this.FMin - this.FPageSize)) * s,s)}
         else Result = Math.min(((this.FTempValue - this.FMin) / (this.FMax - this.FMin - this.FPageSize)) * s,s);
      } else Result = this.FMin;
      return Result;
    };
    this.GetValue$1 = function (XYPos) {
      var Result = 0.0;
      var v = 0.0;
      var s = 0.0;
      var scr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      scr.$assign(this.GetScrollRectangle());
      var $tmp = this.FKind;
      if ($tmp === $mod.TTMSFNCScrollBarKind.sbkHorizontal) {
        s = scr.Right - scr.Left - Math.max((this.FAppearance.GetThumbButtonSize() * 2) + 10,((scr.Right - scr.Left) / this.GetRange()) * this.FPageSize)}
       else if ($tmp === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        s = scr.Bottom - scr.Top - Math.max((this.FAppearance.GetThumbButtonSize() * 2) + 10,((scr.Bottom - scr.Top) / this.GetRange()) * this.FPageSize)}
       else {
        s = 0;
      };
      if (((this.FMax - this.FMin) > 0) && (s > 0)) {
        v = ((XYPos / s) * (this.FMax - this.FMin - this.FPageSize)) + this.FMin;
        Result = Math.max(Math.min(v,this.FMax - this.FPageSize),this.FMin);
      } else Result = 0;
      return Result;
    };
    this.GetRange = function () {
      var Result = 0.0;
      Result = Math.max(2,this.FMax - this.FMin);
      return Result;
    };
    this.MouseOnThumbButtons = function (X, Y) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMinThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) || pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetMaxThumbButton(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
      Result = Result && !this.FAppearance.FFixedThumb;
      return Result;
    };
    this.MouseOnThumb = function (X, Y) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetThumbRectangle(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
      return Result;
    };
    this.DrawScrollButtons = function (g) {
      var flmin = null;
      var flmax = null;
      var stmin = null;
      var stmax = null;
      if (this.FAppearance.FScrollButtonSize <= 0) return;
      flmin = this.FAppearance.FScrollButtonLeftFill;
      flmax = this.FAppearance.FScrollButtonRightFill;
      stmin = this.FAppearance.FScrollButtonLeftStroke;
      stmax = this.FAppearance.FScrollButtonRightStroke;
      if (this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbScrollMin) {
        flmin = this.FAppearance.FScrollButtonLeftDownFill;
        stmin = this.FAppearance.FScrollButtonLeftDownStroke;
      } else if (this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbScrollMin) {
        flmin = this.FAppearance.FScrollButtonLeftHoverFill;
        stmin = this.FAppearance.FScrollButtonLeftHoverStroke;
      };
      g.FFill.Assign(flmin);
      g.FStroke.Assign(stmin);
      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMinScrollButton()),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      if (this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbScrollMax) {
        flmax = this.FAppearance.FScrollButtonRightDownFill;
        stmax = this.FAppearance.FScrollButtonRightDownStroke;
      } else if (this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbScrollMax) {
        flmax = this.FAppearance.FScrollButtonRightHoverFill;
        stmax = this.FAppearance.FScrollButtonRightHoverStroke;
      };
      g.FFill.Assign(flmax);
      g.FStroke.Assign(stmax);
      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMaxScrollButton()),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      this.DrawArrow(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMinScrollButton()),true);
      this.DrawArrow(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMaxScrollButton()),false);
    };
    this.DrawThumb = function (g) {
      g.FFill.Assign(this.FAppearance.FThumbFill);
      g.FStroke.Assign(this.FAppearance.FThumbStroke);
      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetThumbRectangle()),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      if (!this.FAppearance.FFixedThumb) this.DrawThumbButtons(g);
    };
    this.DrawThumbButtons = function (g) {
      var flmin = null;
      var flmax = null;
      var stmin = null;
      var stmax = null;
      if (this.FAppearance.FThumbButtonSize <= 0) return;
      flmin = this.FAppearance.FThumbButtonLeftFill;
      flmax = this.FAppearance.FThumbButtonRightFill;
      stmin = this.FAppearance.FThumbButtonLeftStroke;
      stmax = this.FAppearance.FThumbButtonRightStroke;
      if (this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbThumbMin) {
        flmin = this.FAppearance.FThumbButtonLeftDownFill;
        stmin = this.FAppearance.FThumbButtonLeftDownStroke;
      } else if (this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbThumbMin) {
        flmin = this.FAppearance.FThumbButtonLeftHoverFill;
        stmin = this.FAppearance.FThumbButtonLeftHoverStroke;
      };
      g.FFill.Assign(flmin);
      g.FStroke.Assign(stmin);
      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMinThumbButton()),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      if (this.FDownButton === $mod.TTMSFNCScrollBarDownButton.sdbThumbMax) {
        flmax = this.FAppearance.FThumbButtonRightDownFill;
        stmax = this.FAppearance.FThumbButtonRightDownStroke;
      } else if (this.FHoveredButton === $mod.TTMSFNCScrollBarHoveredButton.shbThumbMax) {
        flmax = this.FAppearance.FThumbButtonRightHoverFill;
        stmax = this.FAppearance.FThumbButtonRightHoverStroke;
      };
      g.FFill.Assign(flmax);
      g.FStroke.Assign(stmax);
      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMaxThumbButton()),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      this.DrawArrow(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMinThumbButton()),true);
      this.DrawArrow(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetMaxThumbButton()),false);
    };
    this.DrawArrow = function (g, r, ALeft) {
      g.FStroke.SetColor(this.FAppearance.FArrowColor);
      if (this.FKind === $mod.TTMSFNCScrollBarKind.sbkVertical) {
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,0,-4);
        if (!ALeft) {
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 2),r.Top + (((r.Bottom - r.Top) / 3) * 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 3),r.Top + ((r.Bottom - r.Top) / 3))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 2),r.Top + (((r.Bottom - r.Top) / 3) * 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + (((r.Right - r.Left) / 3) * 2),r.Top + ((r.Bottom - r.Top) / 3))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        } else {
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 2),r.Top + ((r.Bottom - r.Top) / 3))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 3),r.Top + (((r.Bottom - r.Top) / 3) * 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 2),r.Top + ((r.Bottom - r.Top) / 3))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + (((r.Right - r.Left) / 3) * 2),r.Top + (((r.Bottom - r.Top) / 3) * 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        };
      } else {
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-4,0);
        if (!ALeft) {
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 3),r.Top + ((r.Bottom - r.Top) / 3))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + (((r.Right - r.Left) / 3) * 2),r.Top + ((r.Bottom - r.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 3),r.Top + (((r.Bottom - r.Top) / 3) * 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + (((r.Right - r.Left) / 3) * 2),r.Top + ((r.Bottom - r.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        } else {
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + (((r.Right - r.Left) / 3) * 2),r.Top + ((r.Bottom - r.Top) / 3))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 3),r.Top + ((r.Bottom - r.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + (((r.Right - r.Left) / 3) * 2),r.Top + (((r.Bottom - r.Top) / 3) * 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left + ((r.Right - r.Left) / 3),r.Top + ((r.Bottom - r.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        };
      };
    };
    this.Draw = function (AGraphics, ARect) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      this.DrawThumb(AGraphics);
      this.DrawScrollButtons(AGraphics);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FTracking = true;
      this.FDesignTime$1 = this.IsDesignTime();
      if (this.FDesignTime$1) {
        this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(225,225,225),40));
        this.FStroke.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Darker(11119017,40));
      };
      this.SetHeight(121);
      this.SetWidth(18);
      this.FKind = $mod.TTMSFNCScrollBarKind.sbkVertical;
      this.FValue = 0;
      this.FMin = 0;
      this.FMax = 100;
      this.FSmallChange = 1;
      this.FLargeChange = 20;
      this.FAppearance = $mod.TTMSFNCScrollBarAppearance.$create("Create$1",[this]);
      this.FAppearance.FOnChange = rtl.createCallback(this,"AppearanceChanged");
      this.FPageSize = 20;
      this.FTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[null]);
      this.FTimer.FOnTimer = rtl.createCallback(this,"TimerChanged");
      this.FTimer.SetInterval(100);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      rtl.free(this,"FTimer");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCScrollBar.isPrototypeOf(Source)) {
        this.FKind = rtl.as(Source,$mod.TTMSFNCScrollBar).FKind;
        this.FValue = rtl.as(Source,$mod.TTMSFNCScrollBar).FValue;
        this.FMin = rtl.as(Source,$mod.TTMSFNCScrollBar).FMin;
        this.FMax = rtl.as(Source,$mod.TTMSFNCScrollBar).FMax;
        this.FPageSize = rtl.as(Source,$mod.TTMSFNCScrollBar).FPageSize;
        this.FSmallChange = rtl.as(Source,$mod.TTMSFNCScrollBar).FSmallChange;
        this.FLargeChange = rtl.as(Source,$mod.TTMSFNCScrollBar).FLargeChange;
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCScrollBar).FAppearance);
        this.FTracking = rtl.as(Source,$mod.TTMSFNCScrollBar).FTracking;
        this.Changed();
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCScrollBar",this.TTMSFNCCustomScrollBar,function () {
    this.RegisterRuntimeClasses = function () {
      pas.Classes.RegisterClass($mod.TTMSFNCScrollBar);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCScrollBarAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("Kind",2,$mod.$rtti["TTMSFNCScrollBarKind"],"FKind","SetKind",4,{Default: $mod.TTMSFNCScrollBarKind.sbkVertical});
    $r.addProperty("LargeChange",12,rtl.double,"FLargeChange","FLargeChange",4,{stored: "IsLargeChangeStored"});
    $r.addProperty("Max",14,rtl.double,"FMax","SetMax",4,{stored: "IsMaxStored"});
    $r.addProperty("Tracking",2,rtl.boolean,"FTracking","SetTracking",4,{Default: true});
    $r.addProperty("Min",14,rtl.double,"FMin","SetMin",4,{stored: "IsMinStored"});
    $r.addProperty("PageSize",14,rtl.double,"FPageSize","SetPageSize",4,{stored: "IsPageSizeStored"});
    $r.addProperty("Value",14,rtl.double,"FValue","SetValue",4,{stored: "IsValueStored"});
    $r.addProperty("SmallChange",12,rtl.double,"FSmallChange","FSmallChange",4,{stored: "IsSmallChangeStored"});
    $r.addProperty("OnValueChanged",0,$mod.$rtti["TTMSFNCScrollBarValueChanged"],"FOnValueChange","FOnValueChange");
    $r.addProperty("OnPageSizeChanged",0,$mod.$rtti["TTMSFNCScrollBarPageSizeChanged"],"FOnPageSizeChanged","FOnPageSizeChanged");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["Math","SysUtils","WEBLib.TMSFNCStyles","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCCustomScrollControl",["System","Classes","WEBLib.TMSFNCCustomControl","WEBLib.StdCtrls","WEBLib.TMSFNCScrollBar","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCTypes","WEBLib.ExtCtrls","Types","WEBLib.Controls"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.SCROLLINGDELAY = 0;
  this.SWIPECOUNT = 300;
  this.DOWNCOUNT = 100;
  this.TTMSFNCCustomScrollControlMode = {"0": "scmPixelScrolling", scmPixelScrolling: 0, "1": "scmItemScrolling", scmItemScrolling: 1};
  this.$rtti.$Enum("TTMSFNCCustomScrollControlMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCCustomScrollControlMode});
  this.TTMSFNCCustomScrollControlUpdate = {"0": "scuContinuous", scuContinuous: 0, "1": "scuOnce", scuOnce: 1};
  this.$rtti.$Enum("TTMSFNCCustomScrollControlUpdate",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCCustomScrollControlUpdate});
  rtl.createClass(this,"TTMSFNCCustomScrollControl",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FDownTime = 0;
      this.FMouseUp = false;
      this.FAnimateVerticalPos = false;
      this.FAnimateHorizontalPos = false;
      this.FAnimating = false;
      this.FSpX = 0.0;
      this.FSpY = 0.0;
      this.FDoubleSelection = false;
      this.FRangeSelection = false;
      this.FScrolling = false;
      this.FScrollX = 0.0;
      this.FScrollY = 0.0;
      this.FDownX = 0.0;
      this.FDownY = 0.0;
      this.FMouseX = 0.0;
      this.FMouseY = 0.0;
      this.FScrollVTo = 0.0;
      this.FScrollHTo = 0.0;
      this.FTimeStart = 0.0;
      this.FTimeStop = 0.0;
      this.FAnimateTimer = null;
      this.FDownTimer = null;
      this.FSaveHScrollPos = 0.0;
      this.FSaveVScrollPos = 0.0;
      this.FBlockScrollingUpdate = false;
      this.FIsMouseDown = false;
      this.FStretchScrollBars = false;
      this.FUpdateCount$1 = 0;
      this.FVerticalScrollBar = null;
      this.FHorizontalScrollBar = null;
      this.FCustomVerticalScrollBar = null;
      this.FCustomHorizontalScrollBar = null;
      this.FVerticalScrollBarVisible = false;
      this.FHorizontalScrollBarVisible = false;
      this.FScrollMode = 0;
      this.FApplyClipRect = false;
      this.FScrollUpdate = 0;
      this.FCustomScrollBars = false;
      this.FTouchScrolling = false;
    };
    this.$final = function () {
      this.FAnimateTimer = undefined;
      this.FDownTimer = undefined;
      this.FVerticalScrollBar = undefined;
      this.FHorizontalScrollBar = undefined;
      this.FCustomVerticalScrollBar = undefined;
      this.FCustomHorizontalScrollBar = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetStretchScrollBars = function (Value) {
      if (this.FStretchScrollBars !== Value) {
        this.FStretchScrollBars = Value;
        this.UpdateControl(true,true);
      };
    };
    this.SetScrollMode = function (Value) {
      if (this.FScrollMode !== Value) {
        this.FScrollMode = Value;
        this.UpdateControl(true,true);
      };
    };
    this.SetApplyClipRect = function (Value) {
      if (this.FApplyClipRect !== Value) {
        this.FApplyClipRect = Value;
        this.Invalidate();
      };
    };
    this.SetScrollUpdate = function (Value) {
      if (this.FScrollUpdate !== Value) {
        this.FScrollUpdate = Value;
        if (this.FCustomVerticalScrollBar != null) this.FCustomVerticalScrollBar.SetTracking(this.FScrollUpdate === $mod.TTMSFNCCustomScrollControlUpdate.scuContinuous);
        if (this.FCustomHorizontalScrollBar != null) this.FCustomHorizontalScrollBar.SetTracking(this.FScrollUpdate === $mod.TTMSFNCCustomScrollControlUpdate.scuContinuous);
        this.UpdateControl(true,true);
      };
    };
    this.SetCustomScrollBars = function (Value) {
      if (this.FCustomScrollBars !== Value) {
        this.FCustomScrollBars = Value;
        this.UpdateControl(true,true);
      };
    };
    this.GetVersion = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetCanvasHeightOffset = function () {
      var Result = 0;
      var hs = null;
      var hsc = null;
      Result = 0;
      hs = this.HorizontalScrollBar();
      hsc = this.CustomHorizontalScrollBar();
      if ((hs != null) && (hsc != null)) {
        if (this.FCustomScrollBars && hsc.FVisible && (hsc.FParent != null)) {
          Result = hsc.GetHeight()}
         else if (!this.FCustomScrollBars && hs.FVisible && (hs.FParent != null)) Result = hs.GetHeight();
      };
      return Result;
    };
    this.GetCanvasWidthOffset = function () {
      var Result = 0;
      var vs = null;
      var vsc = null;
      Result = 0;
      vs = this.VerticalScrollBar();
      vsc = this.CustomVerticalScrollBar();
      if ((vs != null) && (vsc != null)) {
        if (this.FCustomScrollBars && vsc.FVisible && (vsc.FParent != null)) {
          Result = vsc.GetWidth()}
         else if (!this.FCustomScrollBars && vs.FVisible && (vs.FParent != null)) Result = vs.GetWidth();
      };
      return Result;
    };
    this.SetHorizontalScrollBarVisible = function (Value) {
      if (this.FHorizontalScrollBarVisible !== Value) {
        this.FHorizontalScrollBarVisible = Value;
        this.UpdateControl(true,true);
      };
    };
    this.SetVerticalScrollBarVisible = function (Value) {
      if (this.FVerticalScrollBarVisible !== Value) {
        this.FVerticalScrollBarVisible = Value;
        this.UpdateControl(true,true);
      };
    };
    this.Animate = function (Sender) {
      var dx = 0.0;
      var dy = 0.0;
      var posx = 0.0;
      var posy = 0.0;
      var animh = false;
      var animv = false;
      posy = this.GetVScrollValue();
      posx = this.GetHScrollValue();
      dx = Math.abs(this.FScrollHTo - posx) / Math.max(1,Math.abs(this.FSpX) * 6);
      dy = Math.abs(this.FScrollVTo - posy) / Math.max(1,Math.abs(this.FSpY) * 6);
      animv = false;
      if (this.FAnimateVerticalPos) animv = $impl.AnimateDouble({get: function () {
          return posy;
        }, set: function (v) {
          posy = v;
        }},{p: this, get: function () {
          return this.p.FScrollVTo;
        }, set: function (v) {
          this.p.FScrollVTo = v;
        }},dy,0.01);
      animh = false;
      if (this.FAnimateHorizontalPos) animh = $impl.AnimateDouble({get: function () {
          return posx;
        }, set: function (v) {
          posx = v;
        }},{p: this, get: function () {
          return this.p.FScrollHTo;
        }, set: function (v) {
          this.p.FScrollHTo = v;
        }},dx,0.01);
      this.FAnimating = animv || animh;
      if (this.FAnimating) {
        this.Scroll(posx,posy)}
       else {
        this.FAnimateVerticalPos = false;
        this.FAnimateTimer.SetEnabled(false);
        this.FAnimateHorizontalPos = false;
      };
    };
    this.DownTime = function (Sender) {
      this.FDownTime += 1;
      if ((this.FDownTime === 100) || !this.FTouchScrolling) {
        this.FRangeSelection = true;
        this.FDownTimer.SetEnabled(false);
      };
    };
    this.UpdateControlAfterResize = function () {
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.SaveScrollPosition();
      this.UpdateControl(false,true);
      this.RestoreScrollPosition();
    };
    this.FillChanged$1 = function (Sender) {
      this.Invalidate();
    };
    this.StrokeChanged$1 = function (Sender) {
      this.Invalidate();
    };
    this.Scroll = function (AHorizontalPos, AVerticalPos) {
      var AOldHorizontalPos = 0.0;
      var AOldVerticalPos = 0.0;
      this.FBlockScrollingUpdate = true;
      AOldHorizontalPos = this.GetHScrollValue();
      AOldVerticalPos = this.GetVScrollValue();
      this.SetHScrollValue(AHorizontalPos);
      this.SetVScrollValue(AVerticalPos);
      this.FBlockScrollingUpdate = false;
      this.UpdateControlScroll(AOldHorizontalPos,AOldVerticalPos,AHorizontalPos,AVerticalPos);
    };
    this.UpdateControlScroll = function (AHorizontalPos, AVerticalPos, ANewHorizontalPos, ANewVerticalPos) {
    };
    this.VerticalScrollPositionChanged = function () {
    };
    this.HorizontalScrollPositionChanged = function () {
    };
    this.VScrollChanged = function (Sender) {
      if (this.FBlockScrollingUpdate || this.FCustomScrollBars) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.VerticalScrollPositionChanged();
      this.SetVScrollValue(this.GetVScrollValue());
    };
    this.HScrollChanged = function (Sender) {
      if (this.FBlockScrollingUpdate || this.FCustomScrollBars) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.HorizontalScrollPositionChanged();
      this.SetHScrollValue(this.GetHScrollValue());
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if ((!(this.FPopupMenu != null) && (pas["WEBLib.Controls"].TMouseButton.mbRight === Button)) || (pas["WEBLib.Controls"].TMouseButton.mbRight !== Button)) this.CaptureEx();
      if (!this.ProcessTouchScrolling(X,Y)) return;
      this.FIsMouseDown = true;
      this.FTimeStart = $impl.GetTickCountX();
      this.FTimeStop = this.FTimeStart;
      this.FScrollVTo = this.GetVScrollValue();
      this.FScrollHTo = this.GetHScrollValue();
      this.FScrollX = X;
      this.FScrollY = Y;
      this.FDownX = X;
      this.FDownY = Y;
      this.FMouseX = X;
      this.FMouseY = Y;
      this.FMouseUp = false;
      this.FDownTimer.SetEnabled(true);
      this.FDoubleSelection = !this.FAnimateTimer.FEnabled;
      this.FRangeSelection = false;
      this.FScrolling = false;
      this.FDownTime = 0;
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var f = 0.0;
      var doscroll = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (!this.ProcessTouchScrolling(X,Y)) return;
      if (this.FIsMouseDown) {
        doscroll = true;
        if (doscroll) {
          f = 1;
          if ((this.FScrolling || (Math.abs(this.FMouseX - X) > 3) || (Math.abs(this.FMouseY - Y) > 3)) && !this.FRangeSelection && this.FTouchScrolling) {
            if ((Math.abs(X - this.FDownX) > 0) || (Math.abs(Y - this.FDownY) > 0)) {
              this.FScrolling = true;
              this.FDownTimer.SetEnabled(false);
              this.FDoubleSelection = false;
              if (this.FIsMouseDown && !this.FMouseUp) {
                this.Scroll(this.GetHScrollValue() - ((X - this.FDownX) * f),this.GetVScrollValue() - ((Y - this.FDownY) * f));
                this.FDownY = Y;
                this.FDownX = X;
              };
            };
          };
        } else if (this.FRangeSelection) ;
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var f = 0.0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      this.ReleaseCaptureEx();
      if (!this.ProcessTouchScrolling(X,Y)) return;
      if (!this.FIsMouseDown) return;
      f = 1;
      this.FIsMouseDown = false;
      this.FMouseUp = true;
      this.FScrolling = false;
      this.FDownTimer.SetEnabled(false);
      if (!this.FDoubleSelection && this.FTouchScrolling) {
        this.FTimeStop = $impl.GetTickCountX();
        if (((this.FTimeStop - this.FTimeStart) < 300) && ((this.FTimeStop - this.FTimeStart) > 0)) {
          this.FSpY = Math.abs(Y - this.FScrollY) / (this.FTimeStop - this.FTimeStart);
          if (this.FSpY > 0) {
            if ((Y - this.FScrollY) > 0) {
              this.FScrollVTo = Math.max(0,Math.min(this.VerticalScrollBar().FMax - this.GetVViewPortSize(),this.FScrollVTo - Math.round(Math.abs(Y - this.FScrollY) * this.FSpY * f * 3)))}
             else this.FScrollVTo = Math.max(0,Math.min(this.VerticalScrollBar().FMax - this.GetVViewPortSize(),this.FScrollVTo + Math.round(Math.abs(Y - this.FScrollY) * this.FSpY * f * 3)));
            this.FAnimateVerticalPos = true;
            this.FAnimateTimer.SetEnabled(true);
          };
          this.FSpX = Math.abs(X - this.FScrollX) / (this.FTimeStop - this.FTimeStart);
          if (this.FSpX > 0) {
            if ((X - this.FScrollX) > 0) {
              this.FScrollHTo = Math.max(0,Math.min(this.HorizontalScrollBar().FMax - this.GetHViewPortSize(),this.FScrollHTo - Math.round(Math.abs(X - this.FScrollX) * this.FSpX * f * 3)))}
             else this.FScrollHTo = Math.max(0,Math.min(this.HorizontalScrollBar().FMax - this.GetHViewPortSize(),this.FScrollHTo + Math.round(Math.abs(X - this.FScrollX) * this.FSpX * f * 3)));
            this.FAnimateHorizontalPos = true;
            this.FAnimateTimer.SetEnabled(true);
          };
        };
      } else this.HandleSelection(Button,rtl.refSet(Shift),X,Y);
      this.FRangeSelection = false;
    };
    this.HandleSelection = function (Button, Shift, X, Y) {
    };
    this.HCustomScrollChanged = function (Sender, AValue) {
      if (this.FBlockScrollingUpdate || !this.FCustomScrollBars) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.HorizontalScrollPositionChanged();
      this.SetHScrollValue(this.GetHScrollValue());
    };
    this.VCustomScrollChanged = function (Sender, AValue) {
      if (this.FBlockScrollingUpdate || !this.FCustomScrollBars) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.VerticalScrollPositionChanged();
      this.SetVScrollValue(this.GetVScrollValue());
    };
    this.UpdateControlScrollBarCalculations = function () {
    };
    this.UpdateControlScrollBars = function (AUpdate, ACalculate) {
      var vs = null;
      var hs = null;
      var vsc = null;
      var hsc = null;
      var w = 0.0;
      var h = 0.0;
      var cw = 0.0;
      var ch = 0.0;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var vmgr = null;
      var hmgr = null;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.FBlockScrollingUpdate = true;
      if (ACalculate) {
        this.UpdateControlScrollBarCalculations();
      };
      vs = this.VerticalScrollBar();
      hs = this.HorizontalScrollBar();
      vsc = this.CustomVerticalScrollBar();
      hsc = this.CustomHorizontalScrollBar();
      if ((vs != null) && (hs != null) && (vsc != null) && (hsc != null)) {
        if (ACalculate) {
          cr.$assign(this.GetCalculationRect())}
         else cr.$assign(this.GetContentRect());
        cw = cr.Right - cr.Left;
        ch = cr.Bottom - cr.Top;
        w = this.GetTotalContentWidth();
        h = this.GetTotalContentHeight();
        hs.SetVisible((w > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(w,cw,0) === 1) && this.FHorizontalScrollBarVisible && !this.ColumnStretchingActive() && !this.FCustomScrollBars);
        vs.SetVisible((h > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(h,ch,0) === 1) && this.FVerticalScrollBarVisible && !this.FCustomScrollBars);
        hsc.SetVisible((w > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(w,cw,0) === 1) && this.FHorizontalScrollBarVisible && !this.ColumnStretchingActive() && this.FCustomScrollBars);
        vsc.SetVisible((h > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(h,ch,0) === 1) && this.FVerticalScrollBarVisible && this.FCustomScrollBars);
        if (vsc.FVisible && this.FCustomScrollBars) {
          vsc.SetParent(this)}
         else vsc.SetParent(null);
        if (hsc.FVisible && this.FCustomScrollBars) {
          hsc.SetParent(this)}
         else hsc.SetParent(null);
        if (vs.FVisible && !this.FCustomScrollBars) {
          vs.SetParent(this)}
         else vs.SetParent(null);
        if (hs.FVisible && !this.FCustomScrollBars) {
          hs.SetParent(this)}
         else hs.SetParent(null);
        vmgr = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
        hmgr = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
        if (this.FCustomScrollBars) {
          if (vsc.FVisible && this.FStretchScrollBars) {
            hmgr.SetRight(vsc.GetWidth() + 1)}
           else hmgr.SetRight(1);
        } else {
          if (vs.FVisible && this.FStretchScrollBars) {
            hmgr.SetRight(vs.GetWidth() + 1)}
           else hmgr.SetRight(1);
        };
        vmgr.SetTop(1);
        vmgr.SetRight(1);
        hmgr.SetBottom(1);
        hmgr.SetLeft(1);
        if (this.FCustomScrollBars) {
          if (hsc.FVisible) {
            vmgr.SetBottom(hsc.GetHeight() + 1)}
           else vmgr.SetBottom(1);
        } else {
          if (hs.FVisible) {
            vmgr.SetBottom(hs.GetHeight() + 1)}
           else vmgr.SetBottom(1);
        };
        if (!this.FStretchScrollBars) {
          cr.$assign(this.GetCalculationRect());
          hmgr.SetLeft(hmgr.FLeft + cr.Left);
          hmgr.SetRight(hmgr.FRight + (this.GetWidth() - cr.Right));
          vmgr.SetTop(vmgr.FTop + cr.Top);
          vmgr.SetBottom(vmgr.FBottom + (this.GetHeight() - cr.Bottom));
        };
        hs.SetLeft(Math.round(hmgr.FLeft));
        hs.SetTop(Math.round(this.GetHeight() - hmgr.FBottom - hs.GetHeight()));
        vs.SetLeft(Math.round(this.GetWidth() - vmgr.FRight - vs.GetWidth()));
        vs.SetTop(Math.round(vmgr.FTop));
        hs.SetWidth(Math.round(Math.max(0,this.GetWidth() - hmgr.FRight - hmgr.FLeft)));
        vs.SetHeight(Math.round(Math.max(0,this.GetHeight() - vmgr.FBottom - vmgr.FTop)));
        hsc.SetLeft(Math.round(hmgr.FLeft));
        hsc.SetTop(Math.round(this.GetHeight() - hmgr.FBottom - hsc.GetHeight()));
        vsc.SetLeft(Math.round(this.GetWidth() - vmgr.FRight - vsc.GetWidth()));
        vsc.SetTop(Math.round(vmgr.FTop));
        hsc.SetWidth(Math.round(Math.max(0,this.GetWidth() - hmgr.FRight - hmgr.FLeft)));
        vsc.SetHeight(Math.round(Math.max(0,this.GetHeight() - vmgr.FBottom - vmgr.FTop)));
        hmgr = rtl.freeLoc(hmgr);
        vmgr = rtl.freeLoc(vmgr);
        cr.$assign(this.GetContentRect());
        cw = cr.Right - cr.Left;
        ch = cr.Bottom - cr.Top;
        if (this.FScrollMode === $mod.TTMSFNCCustomScrollControlMode.scmItemScrolling) {
          vs.SetPageSize(Math.round(Math.max(0,this.GetVerticalContentViewPortSize())));
          vs.SetMax(Math.max(vs.GetPageSize(),this.GetVerticalContentCount()));
        } else {
          vs.SetPageSize(Math.round(Math.max(0,Math.min(h,ch))));
          vs.SetMax(Math.round(Math.max(vs.GetPageSize(),h)));
          vs.SetPosition(Math.min(vs.GetPosition(),vs.FMax));
        };
        vs.FSmallChange = Math.max(-2147483648,rtl.trunc(vs.GetPageSize() / 5));
        vs.FLargeChange = Math.max(-2147483648,vs.GetPageSize());
        if (this.FScrollMode === $mod.TTMSFNCCustomScrollControlMode.scmItemScrolling) {
          hs.SetPageSize(Math.round(Math.max(0,this.GetHorizontalContentViewPortSize())));
          hs.SetMax(Math.max(hs.GetPageSize(),this.GetHorizontalContentCount()));
        } else {
          hs.SetPageSize(Math.round(Math.max(0,Math.min(w,cw))));
          hs.SetMax(Math.round(Math.max(hs.GetPageSize(),w)));
          hs.SetPosition(Math.min(hs.GetPosition(),hs.FMax));
        };
        hs.FSmallChange = Math.max(-2147483648,rtl.trunc(hs.GetPageSize() / 5));
        hs.FLargeChange = Math.max(-2147483648,hs.GetPageSize());
        if (this.FScrollMode === $mod.TTMSFNCCustomScrollControlMode.scmItemScrolling) {
          vsc.SetPageSize(this.GetVerticalContentViewPortSize());
          vsc.SetMax(this.GetVerticalContentCount());
        } else {
          vsc.SetPageSize(Math.min(h,ch));
          vsc.SetMax(h);
          vsc.SetValue(Math.min(vsc.FValue,vsc.FMax - vsc.FPageSize));
        };
        vsc.FSmallChange = vsc.FPageSize / 5;
        vsc.FLargeChange = vsc.FPageSize;
        if (this.FScrollMode === $mod.TTMSFNCCustomScrollControlMode.scmItemScrolling) {
          hsc.SetPageSize(this.GetHorizontalContentViewPortSize());
          hsc.SetMax(this.GetHorizontalContentCount());
        } else {
          hsc.SetPageSize(Math.min(w,cw));
          hsc.SetMax(w);
          hsc.SetValue(Math.min(hsc.FValue,hsc.FMax - hsc.FPageSize));
        };
        hsc.FSmallChange = hsc.FPageSize / 5;
        hsc.FLargeChange = hsc.FPageSize;
      };
      this.FBlockScrollingUpdate = false;
      if (AUpdate) this.UpdateControlScrollBars(false,false);
    };
    this.UpdateControl = function (AUpdate, ARealign) {
      this.UpdateControlCache();
      this.UpdateControlScrollBars(true,true);
      this.UpdateControlDisplay();
    };
    this.UpdateControlCache = function () {
    };
    this.UpdateControlDisplay = function () {
    };
    this.StopAnimationTimer = function () {
      this.FAnimateTimer.SetEnabled(false);
      this.FAnimating = false;
    };
    this.SetHScrollValue = function (AValue) {
      if (this.FCustomScrollBars) {
        if (this.CustomHorizontalScrollBar().FPageSize > 0) this.CustomHorizontalScrollBar().SetValue(Math.min(this.CustomHorizontalScrollBar().FMax - this.CustomHorizontalScrollBar().FPageSize,Math.max(0,AValue)));
      } else {
        if (this.HorizontalScrollBar().GetPageSize() > 0) this.HorizontalScrollBar().SetPosition(Math.round(Math.min(this.HorizontalScrollBar().FMax - this.HorizontalScrollBar().GetPageSize(),Math.max(0,AValue))));
      };
    };
    this.SetVScrollValue = function (AValue) {
      if (this.FCustomScrollBars) {
        if (this.CustomVerticalScrollBar().FPageSize > 0) this.CustomVerticalScrollBar().SetValue(Math.min(this.CustomVerticalScrollBar().FMax - this.CustomVerticalScrollBar().FPageSize,Math.max(0,AValue)));
      } else {
        if (this.VerticalScrollBar().GetPageSize() > 0) this.VerticalScrollBar().SetPosition(Math.round(Math.min(this.VerticalScrollBar().FMax - this.VerticalScrollBar().GetPageSize(),Math.max(0,AValue))));
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateControl(true,true);
    };
    this.Draw = function (AGraphics, ARect) {
      var st = null;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      cr.$assign(this.GetContentClipRect());
      st = null;
      if (this.FApplyClipRect) {
        st = AGraphics.SaveState(false);
        AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr));
      };
      this.DrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr));
      if (this.FApplyClipRect) AGraphics.RestoreState(st,false);
    };
    this.DrawContent = function (AGraphics, ARect) {
    };
    this.UpdateScrollingMode = function (AMode) {
      this.FScrollMode = AMode;
    };
    this.GetTotalContentWidth = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetTotalContentHeight = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetHorizontalContentViewPortSize = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetVerticalContentViewPortSize = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetHorizontalContentCount = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetVerticalContentCount = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetCalculationRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetLocalRect());
      return Result;
    };
    this.GetContentClipRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetContentRect());
      return Result;
    };
    this.GetContentRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.GetContentRect.call(this));
      if (this.FCustomScrollBars) {
        if (this.CustomHorizontalScrollBar().FVisible) Result.Bottom = Result.Bottom - this.CustomHorizontalScrollBar().GetHeight() - 1;
        if (this.CustomVerticalScrollBar().FVisible) Result.Right = Result.Right - this.CustomVerticalScrollBar().GetWidth() - 1;
      } else {
        if (this.HorizontalScrollBar().FVisible) Result.Bottom = Result.Bottom - this.HorizontalScrollBar().GetHeight() - 1;
        if (this.VerticalScrollBar().FVisible) Result.Right = Result.Right - this.VerticalScrollBar().GetWidth() - 1;
      };
      return Result;
    };
    this.GetHScrollValue = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = Math.min(this.CustomHorizontalScrollBar().FMax - this.CustomHorizontalScrollBar().FPageSize,Math.max(0,this.CustomHorizontalScrollBar().FValue))}
       else {
        Result = Math.min(this.HorizontalScrollBar().FMax - this.HorizontalScrollBar().GetPageSize(),Math.max(0,Math.round(this.HorizontalScrollBar().GetPosition())));
      };
      return Result;
    };
    this.GetVScrollValue = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = Math.min(this.CustomVerticalScrollBar().FMax - this.CustomVerticalScrollBar().FPageSize,Math.max(0,this.CustomVerticalScrollBar().FValue))}
       else {
        Result = Math.min(this.VerticalScrollBar().FMax - this.VerticalScrollBar().GetPageSize(),Math.max(0,Math.round(this.VerticalScrollBar().GetPosition())));
      };
      return Result;
    };
    this.GetVViewPortSize = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = this.CustomVerticalScrollBar().FPageSize}
       else {
        Result = this.VerticalScrollBar().GetPageSize();
      };
      return Result;
    };
    this.GetHViewPortSize = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = this.CustomHorizontalScrollBar().FPageSize}
       else {
        Result = this.HorizontalScrollBar().GetPageSize();
      };
      return Result;
    };
    this.GetVMax = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = this.CustomVerticalScrollBar().FMax}
       else Result = this.VerticalScrollBar().FMax;
      return Result;
    };
    this.GetHMax = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = this.CustomHorizontalScrollBar().FMax}
       else Result = this.HorizontalScrollBar().FMax;
      return Result;
    };
    this.GetHVisible = function () {
      var Result = false;
      if (this.FCustomScrollBars) {
        Result = this.CustomHorizontalScrollBar().FVisible}
       else Result = this.HorizontalScrollBar().FVisible;
      return Result;
    };
    this.GetVVisible = function () {
      var Result = false;
      if (this.FCustomScrollBars) {
        Result = this.CustomVerticalScrollBar().FVisible}
       else Result = this.VerticalScrollBar().FVisible;
      return Result;
    };
    this.ProcessTouchScrolling = function (X, Y) {
      var Result = false;
      Result = this.FTouchScrolling;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FTouchScrolling = false;
      this.FAnimateTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FAnimateTimer.SetInterval(1);
      this.FAnimateTimer.SetEnabled(false);
      this.FAnimateTimer.FOnTimer = rtl.createCallback(this,"Animate");
      this.FDownTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FDownTimer.SetInterval(1);
      this.FDownTimer.SetEnabled(false);
      this.FDownTimer.FOnTimer = rtl.createCallback(this,"DownTime");
      this.FApplyClipRect = true;
      this.FStretchScrollBars = true;
      this.FScrollMode = $mod.TTMSFNCCustomScrollControlMode.scmPixelScrolling;
      this.FScrollUpdate = $mod.TTMSFNCCustomScrollControlUpdate.scuContinuous;
      this.FCustomVerticalScrollBar = pas["WEBLib.TMSFNCScrollBar"].TTMSFNCScrollBar.$create("Create$1",[this]);
      this.FCustomVerticalScrollBar.SetParent(this);
      this.FCustomHorizontalScrollBar = pas["WEBLib.TMSFNCScrollBar"].TTMSFNCScrollBar.$create("Create$1",[this]);
      this.FCustomHorizontalScrollBar.SetParent(this);
      this.FVerticalScrollBar = pas["WEBLib.StdCtrls"].TScrollBar.$create("Create$1",[this]);
      this.FVerticalScrollBar.SetParent(this);
      this.FHorizontalScrollBar = pas["WEBLib.StdCtrls"].TScrollBar.$create("Create$1",[this]);
      this.FHorizontalScrollBar.SetParent(this);
      this.FCustomVerticalScrollBar.FAppearance.SetThumbButtonSize(0);
      this.FCustomHorizontalScrollBar.FAppearance.SetThumbButtonSize(0);
      this.FCustomHorizontalScrollBar.SetKind(pas["WEBLib.TMSFNCScrollBar"].TTMSFNCScrollBarKind.sbkHorizontal);
      this.FVerticalScrollBar.FDoubleBuffered = false;
      this.FHorizontalScrollBar.FDoubleBuffered = false;
      this.FVerticalScrollBar.SetKind(pas["WEBLib.Controls"].TScrollBarKind.sbVertical);
      this.FVerticalScrollBar.SetVisible(true);
      this.FHorizontalScrollBar.SetVisible(true);
      this.FCustomVerticalScrollBar.SetVisible(false);
      this.FCustomHorizontalScrollBar.SetVisible(false);
      this.FVerticalScrollBar.FOnChange = rtl.createCallback(this,"VScrollChanged");
      this.FHorizontalScrollBar.FOnChange = rtl.createCallback(this,"HScrollChanged");
      this.FCustomHorizontalScrollBar.FOnValueChange = rtl.createCallback(this,"HCustomScrollChanged");
      this.FCustomVerticalScrollBar.FOnValueChange = rtl.createCallback(this,"VCustomScrollChanged");
      this.FVerticalScrollBarVisible = true;
      this.FHorizontalScrollBarVisible = true;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCustomVerticalScrollBar");
      rtl.free(this,"FCustomHorizontalScrollBar");
      rtl.free(this,"FVerticalScrollBar");
      rtl.free(this,"FHorizontalScrollBar");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomScrollControl.isPrototypeOf(Source)) {
        this.FStretchScrollBars = rtl.as(Source,$mod.TTMSFNCCustomScrollControl).FStretchScrollBars;
        this.FScrollMode = rtl.as(Source,$mod.TTMSFNCCustomScrollControl).FScrollMode;
        this.FScrollUpdate = rtl.as(Source,$mod.TTMSFNCCustomScrollControl).FScrollUpdate;
        this.FApplyClipRect = rtl.as(Source,$mod.TTMSFNCCustomScrollControl).FApplyClipRect;
      };
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
      this.FUpdateCount$1 += 1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.FUpdateCount$1 -= 1;
      if (this.FUpdateCount$1 === 0) this.UpdateControl(true,true);
    };
    this.SaveScrollPosition = function () {
      this.FSaveHScrollPos = this.GetHScrollValue();
      this.FSaveVScrollPos = this.GetVScrollValue();
    };
    this.RestoreScrollPosition = function () {
      this.Scroll(this.FSaveHScrollPos,this.FSaveVScrollPos);
    };
    this.GetVerticalScrollPosition = function () {
      var Result = 0.0;
      var vVal = 0.0;
      vVal = this.GetVScrollValue();
      Result = vVal;
      return Result;
    };
    this.GetHorizontalScrollPosition = function () {
      var Result = 0.0;
      var hVal = 0.0;
      hVal = this.GetHScrollValue();
      Result = hVal;
      return Result;
    };
    this.GetHorizontalScrollMax = function () {
      var Result = 0.0;
      Result = this.GetHMax();
      return Result;
    };
    this.GetVerticalScrollMax = function () {
      var Result = 0.0;
      Result = this.GetVMax();
      return Result;
    };
    this.HorizontalScrollBar = function () {
      var Result = null;
      Result = this.FHorizontalScrollBar;
      return Result;
    };
    this.VerticalScrollBar = function () {
      var Result = null;
      Result = this.FVerticalScrollBar;
      return Result;
    };
    this.CustomHorizontalScrollBar = function () {
      var Result = null;
      Result = this.FCustomHorizontalScrollBar;
      return Result;
    };
    this.CustomVerticalScrollBar = function () {
      var Result = null;
      Result = this.FCustomVerticalScrollBar;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    $impl.GetTickCountX = function () {
      var Result = 0;
      var h = 0;
      var m = 0;
      var s = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(pas.SysUtils.Now(),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }},{get: function () {
          return m;
        }, set: function (v) {
          m = v;
        }},{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = ms + (s * 1000) + (m * 60 * 1000) + (h * 60 * 60 * 1000);
      return Result;
    };
    $impl.AnimateDouble = function (Start, Stop, Delta, Margin) {
      var Result = false;
      Result = true;
      if ((Start.get() > (Stop.get() - Margin)) && (Start.get() < (Stop.get() + Margin))) {
        Start.set(Stop.get());
        Result = false;
      } else {
        Delta = Math.max(Margin,Delta);
        if (Start.get() < Stop.get()) {
          Start.set(Start.get() + Delta)}
         else Start.set(Start.get() - Delta);
      };
      return Result;
    };
  };
},["WEBLib.Forms","Math","WEBLib.TMSFNCGraphicsTypes","SysUtils"]);
rtl.module("WEBLib.TMSFNCGridData",["System","Classes","SysUtils","WEBLib.Controls","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCDataBinding","WEBLib.TMSFNCGridCell","WEBLib.TMSFNCGridDataUtil","WEBLib.Graphics","WEBLib.TMSFNCTypes","WEBLib.TMSFNCCustomScrollControl","Types","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCGridOptions","WEBLib.TMSFNCGraphicsTypes","Web","contnrs","WEBLib.StdCtrls"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$StaticArray("CSVSeparators$a",{dims: [10], eltype: rtl.char});
  this.CSVSeparators = [",",";","#","\t","|","@","*","-","+","&"];
  this.$rtti.$ClassRef("TTMSFNCGridEditorClass",{instancetype: pas["WEBLib.Controls"].$rtti["TWinControl"]});
  rtl.createHelper(this,"TJSNodeListHelper",null,function () {
    this.FindNode = function (ANodeName) {
      var Result = null;
      var Index = 0;
      Index = $mod.TJSNodeListHelper.IndexOf.call(this,ANodeName);
      if (Index >= 0) {
        Result = this.item(Index)}
       else Result = null;
      return Result;
    };
    this.IndexOf = function (Name) {
      var Result = 0;
      var n = null;
      for (var $l = 0, $end = $mod.TJSNodeListHelper.GetCount.call(this) - 1; $l <= $end; $l++) {
        Result = $l;
        n = this.item(Result);
        if (n.nodeName === Name) return Result;
      };
      Result = -1;
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.length;
      return Result;
    };
  });
  this.$rtti.$Class("TTMSFNCGridData");
  rtl.recNewT(this,"TTMSFNCGridCellRec",function () {
    this.Col = 0;
    this.Row = 0;
    this.$eq = function (b) {
      return (this.Col === b.Col) && (this.Row === b.Row);
    };
    this.$assign = function (s) {
      this.Col = s.Col;
      this.Row = s.Row;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCGridCellRec",{},this);
    $r.addField("Col",rtl.longint);
    $r.addField("Row",rtl.longint);
  });
  rtl.recNewT(this,"TTMSFNCGridCellRecRange",function () {
    this.StartCol = 0;
    this.StartRow = 0;
    this.EndCol = 0;
    this.EndRow = 0;
    this.$eq = function (b) {
      return (this.StartCol === b.StartCol) && (this.StartRow === b.StartRow) && (this.EndCol === b.EndCol) && (this.EndRow === b.EndRow);
    };
    this.$assign = function (s) {
      this.StartCol = s.StartCol;
      this.StartRow = s.StartRow;
      this.EndCol = s.EndCol;
      this.EndRow = s.EndRow;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCGridCellRecRange",{},this);
    $r.addField("StartCol",rtl.longint);
    $r.addField("StartRow",rtl.longint);
    $r.addField("EndCol",rtl.longint);
    $r.addField("EndRow",rtl.longint);
  });
  this.TTMSFNCGridCellState = {"0": "csNormal", csNormal: 0, "1": "csFocused", csFocused: 1, "2": "csFixed", csFixed: 2, "3": "csFixedSelected", csFixedSelected: 3, "4": "csSelected", csSelected: 4};
  this.$rtti.$Enum("TTMSFNCGridCellState",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCGridCellState});
  this.TTMSFNCGridSortDirection = {"0": "sdAscending", sdAscending: 0, "1": "sdDescending", sdDescending: 1};
  this.$rtti.$Enum("TTMSFNCGridSortDirection",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridSortDirection});
  this.TTMSFNCGridSortFormat = {"0": "ssAutomatic", ssAutomatic: 0, "1": "ssAlphabetic", ssAlphabetic: 1, "2": "ssAlphabeticNoCase", ssAlphabeticNoCase: 2, "3": "ssNumeric", ssNumeric: 3, "4": "ssDate", ssDate: 4, "5": "ssHTML", ssHTML: 5, "6": "ssCheckBox", ssCheckBox: 6, "7": "ssCustom", ssCustom: 7, "8": "ssRaw", ssRaw: 8};
  this.$rtti.$Enum("TTMSFNCGridSortFormat",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TTMSFNCGridSortFormat});
  this.$rtti.$MethodVar("TTMSFNCGridSortFormatEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["SortFormat",this.$rtti["TTMSFNCGridSortFormat"],1],["APrefix",rtl.string,1],["ASuffix",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridCustomCompareEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Value1",rtl.string],["Value2",rtl.string],["res",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridRawCompareEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Row1",rtl.longint],["Row2",rtl.longint],["res",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridClipboardBeforePasteEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Row",rtl.longint],["Value",rtl.string,1],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridClipboardAfterPasteEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Row",rtl.longint],["Value",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridNeedFilterDropDownEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Row",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridNeedFilterDropDownDataEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Row",rtl.longint],["AValues",pas.Classes.$rtti["TStrings"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridFilterSelectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Condition",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridAfterApplyFilterEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Condition",rtl.string],["UpdateCalculations",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridCellsChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Cells",this.$rtti["TTMSFNCGridCellRecRange"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridColumnCalcEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["FromRow",rtl.longint],["ToRow",rtl.longint],["Res",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnSelectCell",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnSelectedCell",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint]]), methodkind: 0});
  this.TTMSFNCGridColumnCalculation = {"0": "ccNone", ccNone: 0, "1": "ccSum", ccSum: 1, "2": "ccAvg", ccAvg: 2, "3": "ccCount", ccCount: 3, "4": "ccMin", ccMin: 4, "5": "ccMax", ccMax: 5, "6": "ccCUSTOM", ccCUSTOM: 6, "7": "ccDistinct", ccDistinct: 7, "8": "ccStdDev", ccStdDev: 8};
  this.$rtti.$Enum("TTMSFNCGridColumnCalculation",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TTMSFNCGridColumnCalculation});
  this.TTMSFNCGridCellCalcState = {"0": "csNoCalc", csNoCalc: 0, "1": "csCalcOk", csCalcOk: 1, "2": "csCalcErr", csCalcErr: 2};
  this.$rtti.$Enum("TTMSFNCGridCellCalcState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridCellCalcState});
  rtl.createClass(this,"TTMSFNCGridCellProperty",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FDefaultFont = null;
      this.FColor = 0;
      this.FBaseCol = 0;
      this.FBaseRow = 0;
      this.FColSpan = 0;
      this.FRowSpan = 0;
      this.FAlignHorz = 0;
      this.FAlignVert = 0;
      this.FControl = null;
      this.FObject = null;
      this.FReadOnly = false;
      this.FPrintPageNr = 0;
      this.FFontStyle = {};
      this.FFontSize = 0.0;
      this.FFontName = "";
      this.FFontColor = 0;
      this.FAngle = 0;
      this.FComment = "";
      this.FCommentColor = 0;
      this.FBorderColor = 0;
      this.FBorderWidth = 0;
      this.FWordWrap = false;
      this.FFixed = false;
      this.FCalcState = 0;
      this.FCalcValue = undefined;
      this.FNameIndex = 0;
    };
    this.$final = function () {
      this.FDefaultFont = undefined;
      this.FControl = undefined;
      this.FObject = undefined;
      this.FFontStyle = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Assign = function (Source) {
      this.FColSpan = Source.FColSpan;
      this.FRowSpan = Source.FRowSpan;
      this.FBaseCol = Source.FBaseCol;
      this.FBaseRow = Source.FBaseRow;
      this.FColor = Source.FColor;
      this.FAlignHorz = Source.FAlignHorz;
      this.FAlignVert = Source.FAlignVert;
      this.FFontStyle = rtl.refSet(Source.FFontStyle);
      this.FReadOnly = false;
      this.FCalcState = Source.FCalcState;
    };
    this.Create$1 = function (DefaultFont) {
      pas.System.TObject.Create.call(this);
      this.FDefaultFont = DefaultFont;
      this.FColSpan = -1;
      this.FRowSpan = -1;
      this.FBaseCol = -1;
      this.FBaseRow = -1;
      this.FColor = -1;
      this.FBorderColor = -1;
      this.FControl = null;
      this.FPrintPageNr = -1;
      this.FBorderWidth = 1;
      this.FAngle = 0;
      this.FAlignHorz = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FAlignVert = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FFontSize = DefaultFont.FSize;
      this.FFontStyle = rtl.refSet(DefaultFont.FStyle);
      this.FCommentColor = -1;
      this.FComment = "";
      this.FCalcState = $mod.TTMSFNCGridCellCalcState.csNoCalc;
      this.FNameIndex = -1;
      return this;
    };
    this.Destroy = function () {
      if (this.FControl != null) pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FControl;
        }, set: function (v) {
          this.p.FControl = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
    this.IsBaseCell = function (Col, Row) {
      var Result = false;
      Result = ((Col === this.FBaseCol) && (Row === this.FBaseRow)) || ((this.FBaseCol === -1) && (this.FBaseRow === -1));
      return Result;
    };
    this.FreeControl = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FControl;
        }, set: function (v) {
          this.p.FControl = v;
        }});
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellCheckBox",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FChecked = false;
      this.FHeader = false;
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellDataCheckBox",pas.System.TObject,function () {
  });
  rtl.createClass(this,"TTMSFNCGridCellRadioButton",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FChecked = false;
      this.FIndex = 0;
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellButton",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FText = "";
      this.FWidth = 0;
      this.FHeight = 0;
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellBitmapName",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBitmapName = "";
      this.FData = false;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FBitmapName = "";
      this.FData = false;
      return this;
    };
  });
  this.$rtti.$Class("TTMSFNCGridCellBitmap");
  rtl.createClass(this,"TTMSFNCGridCellBitmap",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBitmap = null;
    };
    this.$final = function () {
      this.FBitmap = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetBitmap = function (Value) {
      this.FBitmap.Assign(Value);
    };
    this.Create$1 = function (AOwner) {
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellNode",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FState = 0;
      this.FSpan = 0;
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellSummary",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FMerged = false;
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellProgressBar",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FValue = 0.0;
      this.FData = false;
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellCombo",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FItems = null;
    };
    this.$final = function () {
      this.FItems = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCGridSortIndexList",pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridIntList,function () {
    this.GetSortColumns = function (i) {
      var Result = 0;
      Result = this.GetInteger(i) & 0x7FFFFFFF;
      return Result;
    };
    this.GetSortDirections = function (i) {
      var Result = false;
      Result = !((this.GetInteger(i) & 0x80000000) === 0x80000000);
      return Result;
    };
    this.SetSortColumns = function (i, Value) {
      this.SetInteger(i,rtl.lw((Value >>> 0) & 0x7FFFFFFF) + (this.GetInteger(i) & 0x80000000));
    };
    this.SetSortDirections = function (i, Value) {
      if (Value) {
        this.SetInteger(i,this.GetInteger(i) & 0x7FFFFFFF)}
       else this.SetInteger(i,rtl.lw((this.GetInteger(i) >>> 0) | 0x80000000));
    };
    this.SaveToString = function () {
      var Result = "";
      var i = 0;
      var s = "";
      var a = "";
      s = "";
      a = "";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ((this.GetInteger(i) & 0x80000000) === 0x80000000) {
          a = "d" + pas.SysUtils.IntToStr(0xFFFF & this.GetInteger(i));
        } else {
          a = "u" + pas.SysUtils.IntToStr(0xFFFF & this.GetInteger(i));
        };
        if (s === "") {
          s = a}
         else s = s + ";" + a;
      };
      Result = s;
      return Result;
    };
    this.LoadFromString = function (s) {
      var a = "";
      var i = 0;
      var e = 0;
      this.Clear();
      while (s.length > 0) {
        if (pas.System.Pos(";",s) > 0) {
          a = pas.System.Copy(s,1,pas.System.Pos(";",s) - 1);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,pas.System.Pos(";",s));
        } else {
          a = s;
          s = "";
        };
        if (a.length > 1) {
          pas.System.val$6(pas.System.Copy(a,2,a.length),{get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }},{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          if (a.charAt(0) === "u") {
            this.AddIndex(i,$mod.TTMSFNCGridSortDirection.sdAscending)}
           else this.AddIndex(i,$mod.TTMSFNCGridSortDirection.sdDescending);
        };
      };
    };
    this.AddIndex = function (ColumnIndex, ADirection) {
      if (ADirection === $mod.TTMSFNCGridSortDirection.sdAscending) {
        this.Add$1(ColumnIndex)}
       else this.Add$1(0x80000000 | ColumnIndex);
    };
    this.FindIndex = function (ColumnIndex) {
      var Result = 0;
      var i = 0;
      Result = -1;
      i = 0;
      while (i < this.GetCount()) {
        if ((this.GetInteger(i) & 0x7FFFFFFF) === ColumnIndex) {
          Result = i;
          break;
        };
        i += 1;
      };
      return Result;
    };
    this.ToggleIndex = function (ColumnIndex) {
      var i = 0;
      i = 0;
      while (i < this.GetCount()) {
        if ((this.GetInteger(i) & 0x7FFFFFFF) === ColumnIndex) {
          if ((this.GetInteger(i) & 0x80000000) === 0x80000000) {
            this.SetInteger(i,this.GetInteger(i) & 0x7FFFFFFF)}
           else this.SetInteger(i,this.GetInteger(i) | 0x80000000);
          break;
        };
        i += 1;
      };
    };
  });
  this.TTMSFNCGridFilterCells = {"0": "fcVirtual", fcVirtual: 0, "1": "fcNormal", fcNormal: 1, "2": "fcStripHTML", fcStripHTML: 2, "3": "fcRow", fcRow: 3};
  this.$rtti.$Enum("TTMSFNCGridFilterCells",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGridFilterCells});
  this.TTMSFNCGridFilterOperation = {"0": "foSHORT", foSHORT: 0, "1": "foNONE", foNONE: 1, "2": "foAND", foAND: 2, "3": "foXOR", foXOR: 3, "4": "foOR", foOR: 4};
  this.$rtti.$Enum("TTMSFNCGridFilterOperation",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCGridFilterOperation});
  this.TTMSFNCGridRowState = {"0": "rsDefault", rsDefault: 0, "1": "rsSelected", rsSelected: 1};
  this.$rtti.$Enum("TTMSFNCGridRowState",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridRowState});
  this.TTMSFNCClipOperation = {"0": "coCut", coCut: 0, "1": "coCopy", coCopy: 1, "2": "coNone", coNone: 2};
  this.$rtti.$Enum("TTMSFNCClipOperation",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCClipOperation});
  rtl.createClass(this,"TTMSFNCGridDataList",pas.Classes.TStringList,function () {
  });
  rtl.createClass(this,"TTMSFNCGridRowInfo",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FData = null;
      this.FState = 0;
    };
    this.$final = function () {
      this.FData = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetState = function (Value) {
      this.FState = Value;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FData = $mod.TTMSFNCGridDataList.$create("Create$1");
      this.FState = $mod.TTMSFNCGridRowState.rsDefault;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FData");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCGridFilterData",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FColumn = 0;
      this.FCondition = "";
      this.FCaseSensitive = false;
      this.FSuffix = "";
      this.FPrefix = "";
      this.FOperation = 0;
      this.FData = 0;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FCaseSensitive = true;
      this.FData = $mod.TTMSFNCGridFilterCells.fcVirtual;
      return this;
    };
    this.Assign = function (Source) {
      var ASrcFilterData = null;
      ASrcFilterData = rtl.as(Source,$mod.TTMSFNCGridFilterData);
      if (ASrcFilterData != null) {
        this.FColumn = ASrcFilterData.FColumn;
        this.FCondition = ASrcFilterData.FCondition;
        this.FCaseSensitive = ASrcFilterData.FCaseSensitive;
        this.FData = ASrcFilterData.FData;
        this.FPrefix = ASrcFilterData.FPrefix;
        this.FSuffix = ASrcFilterData.FSuffix;
        this.FOperation = ASrcFilterData.FOperation;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Column",0,rtl.smallint,"FColumn","FColumn");
    $r.addProperty("Condition",0,rtl.string,"FCondition","FCondition");
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive",4,{Default: true});
    $r.addProperty("Data",0,$mod.$rtti["TTMSFNCGridFilterCells"],"FData","FData",4,{Default: $mod.TTMSFNCGridFilterCells.fcVirtual});
    $r.addProperty("Prefix",0,rtl.string,"FPrefix","FPrefix");
    $r.addProperty("Suffix",0,rtl.string,"FSuffix","FSuffix");
    $r.addProperty("Operation",0,$mod.$rtti["TTMSFNCGridFilterOperation"],"FOperation","FOperation");
  });
  rtl.createClass(this,"TTMSFNCGridFilter",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.GetItem.call(this,Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetColFilter = function (Col) {
      var Result = null;
      var i = 0;
      for (var $l = 1, $end = this.GetCount(); $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i - 1).FColumn === Col) {
          Result = this.GetItem$1(i - 1);
          return Result;
        };
      };
      Result = this.Add$1();
      Result.FColumn = Col;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCGridFilterData);
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      if (this.GetCount() === 1) {
        Result.FOperation = $mod.TTMSFNCGridFilterOperation.foNONE}
       else Result.FOperation = $mod.TTMSFNCGridFilterOperation.foAND;
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
    this.HasFilter = function (Col) {
      var Result = false;
      var i = 0;
      Result = false;
      for (var $l = 1, $end = this.GetCount(); $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i - 1).FColumn === Col) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.RemoveColumnFilter = function (Col) {
      var i = 0;
      i = this.GetCount();
      while (i > 0) {
        i -= 1;
        if (this.GetItem$1(i).FColumn === Col) this.Delete(i);
      };
    };
  });
  rtl.recNewT(this,"TTMSFNCGridCellCoordinate",function () {
    this.Col = 0;
    this.Row = 0;
    this.$eq = function (b) {
      return (this.Col === b.Col) && (this.Row === b.Row);
    };
    this.$assign = function (s) {
      this.Col = s.Col;
      this.Row = s.Row;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCGridCellCoordinate",{},this);
    $r.addField("Col",rtl.longint);
    $r.addField("Row",rtl.longint);
  });
  rtl.createClass(this,"TTMSFNCGridFileStringList",pas.Classes.TStringList,function () {
    this.$init = function () {
      pas.Classes.TStringList.$init.call(this);
      this.fp = 0;
      this.cache = "";
    };
    this.GetEOF = function () {
      var Result = false;
      Result = this.fp >= this.GetCount();
      return Result;
    };
    this.Reset = function () {
      this.fp = 0;
      this.cache = "";
    };
    this.ReadLn = function (s) {
      s.set(this.Get(this.fp));
      this.fp += 1;
    };
    this.Write = function (s) {
      this.cache = this.cache + s;
    };
    this.WriteLn = function (s) {
      this.Add(this.cache + s);
      this.cache = "";
    };
  });
  this.TTMSFNCGridFindParameters = {"0": "fnMatchCase", fnMatchCase: 0, "1": "fnMatchFull", fnMatchFull: 1, "2": "fnMatchRegular", fnMatchRegular: 2, "3": "fnDirectionLeftRight", fnDirectionLeftRight: 3, "4": "fnMatchStart", fnMatchStart: 4, "5": "fnFindInCurrentRow", fnFindInCurrentRow: 5, "6": "fnFindInCurrentCol", fnFindInCurrentCol: 6, "7": "fnIncludeFixed", fnIncludeFixed: 7, "8": "fnAutoGoto", fnAutoGoto: 8, "9": "fnIgnoreHTMLTags", fnIgnoreHTMLTags: 9, "10": "fnBackward", fnBackward: 10, "11": "fnIncludeHiddenColumns", fnIncludeHiddenColumns: 11, "12": "fnFindInPresetCol", fnFindInPresetCol: 12, "13": "fnFindInPresetRow", fnFindInPresetRow: 13, "14": "fnSelectedCells", fnSelectedCells: 14, "15": "fnIncludeHiddenRows", fnIncludeHiddenRows: 15};
  this.$rtti.$Enum("TTMSFNCGridFindParameters",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TTMSFNCGridFindParameters});
  this.$rtti.$Set("TTMSFNCGridFindParams",{comptype: this.$rtti["TTMSFNCGridFindParameters"]});
  rtl.createClass(this,"TTMSFNCGridSingleListItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FOwner = null;
      this.FValue = 0.0;
      this.FCellVal = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetValue = function (Value) {
      this.FValue = Value;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner = rtl.as(this.FCollection,$mod.TTMSFNCGridSingleList).FOwner$1;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Value",2,rtl.double,"FValue","SetValue");
    $r.addProperty("CellVal",0,rtl.longint,"FCellVal","FCellVal");
  });
  rtl.createClass(this,"TTMSFNCGridSingleList",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.IndexOf = function (ACellVal) {
      var Result = 0;
      var r = 0;
      Result = -1;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        r = $l;
        if (this.GetItem$1(r).FCellVal === ACellVal) {
          Result = r;
          return Result;
        };
      };
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCGridSingleListItem);
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.TTMSFNCGridMarkType = {"0": "mtHighlight", mtHighlight: 0, "1": "mtError", mtError: 1};
  this.$rtti.$Enum("TTMSFNCGridMarkType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCGridMarkType});
  rtl.createClass(this,"TTMSFNCGridCellMarkItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCellRange = $mod.TTMSFNCGridCellRecRange.$new();
      this.FValue = "";
      this.FCaseSensitive = false;
      this.FMarkType = 0;
    };
    this.$final = function () {
      this.FCellRange = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive");
    $r.addProperty("Value",0,rtl.string,"FValue","FValue");
    $r.addProperty("MarkType",0,$mod.$rtti["TTMSFNCGridMarkType"],"FMarkType","FMarkType");
  });
  rtl.createClass(this,"TTMSFNCGridCellMarkList",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCGridCellMarkItem);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.RemoveMarker = function (CellRange, MarkerType) {
      var i = 0;
      for (var $l = this.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        if ($mod.EqualsCellRange($mod.TTMSFNCGridCellRecRange.$clone(this.GetItem$1(i).FCellRange),$mod.TTMSFNCGridCellRecRange.$clone(CellRange)) && (MarkerType === this.GetItem$1(i).FMarkType)) this.Delete(i);
      };
    };
  });
  rtl.createClass(this,"TTMSFNCGridCellList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      Result.$assign(rtl.getObject(this.Get(Index)));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      var v = $mod.TTMSFNCGridCellRec.$new();
      v.$assign(Value);
      this.Put(Index,v);
    };
    this.Create$2 = function () {
      pas.Classes.TList.Create$1.call(this);
      return this;
    };
    this.Destroy = function () {
      this.Clear$1();
      pas.Classes.TList.Destroy.call(this);
    };
    this.AddCell = function (Cell) {
      this.Add($mod.TTMSFNCGridCellRec.$clone(Cell));
    };
    this.DeleteCell = function (Cell) {
      var i = 0;
      var p = $mod.TTMSFNCGridCellRec.$new();
      for (var $l = this.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        p.$assign(this.GetItem(i));
        if ((p.Col === Cell.Col) && (p.Row === Cell.Row)) this.Delete(i);
      };
    };
    this.DeleteCell$1 = function (index) {
      if ((index >= 0) && (index < this.GetCount())) this.Delete(index);
    };
    this.Clear$1 = function () {
      while (this.GetCount() > 0) {
        this.Delete(this.GetCount() - 1);
      };
    };
    this.Find = function (Cell) {
      var Result = 0;
      var i = 0;
      var p = $mod.TTMSFNCGridCellRec.$new();
      Result = -1;
      for (var $l = this.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        p.$assign(this.GetItem(i));
        if ((p.Col === Cell.Col) && (p.Row === Cell.Row)) {
          Result = i;
          break;
        };
      };
      return Result;
    };
    this.FindFixed = function (Cell) {
      var Result = 0;
      var i = 0;
      var p = $mod.TTMSFNCGridCellRec.$new();
      Result = -1;
      for (var $l = this.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        p.$assign(this.GetItem(i));
        if ((p.Row === Cell.Row) || (p.Col === Cell.Col)) {
          Result = i;
          break;
        };
      };
      return Result;
    };
  });
  this.TTMSFNCGridExportState = {"0": "esExportStart", esExportStart: 0, "1": "esExportNewRow", esExportNewRow: 1, "2": "esExportDone", esExportDone: 2, "3": "esExportSelRow", esExportSelRow: 3, "4": "esExportFail", esExportFail: 4, "5": "esExportNextRow", esExportNextRow: 5, "6": "esExportFindRow", esExportFindRow: 6};
  this.$rtti.$Enum("TTMSFNCGridExportState",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TTMSFNCGridExportState});
  this.TTMSFNCGridImportState = {"0": "isImportStart", isImportStart: 0, "1": "isImportNewRow", isImportNewRow: 1, "2": "isImportDone", isImportDone: 2, "3": "isImportSelRow", isImportSelRow: 3};
  this.$rtti.$Enum("TTMSFNCGridImportState",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGridImportState});
  this.TTMSFNCGridEditorType = {"0": "etEdit", etEdit: 0, "1": "etNumericEdit", etNumericEdit: 1, "2": "etSignedNumericEdit", etSignedNumericEdit: 2, "3": "etFloatEdit", etFloatEdit: 3, "4": "etSignedFloatEdit", etSignedFloatEdit: 4, "5": "etUppercaseEdit", etUppercaseEdit: 5, "6": "etMixedCaseEdit", etMixedCaseEdit: 6, "7": "etLowerCaseEdit", etLowerCaseEdit: 7, "8": "etMoneyEdit", etMoneyEdit: 8, "9": "etHexEdit", etHexEdit: 9, "10": "etAlphaNumericEdit", etAlphaNumericEdit: 10, "11": "etValidCharsEdit", etValidCharsEdit: 11, "12": "etComboBox", etComboBox: 12, "13": "etSpinBox", etSpinBox: 13, "14": "etDatePicker", etDatePicker: 14, "15": "etColorPicker", etColorPicker: 15, "16": "etTrackBar", etTrackBar: 16, "17": "etMemo", etMemo: 17, "18": "etCustom", etCustom: 18};
  this.$rtti.$Enum("TTMSFNCGridEditorType",{minvalue: 0, maxvalue: 18, ordtype: 1, enumtype: this.TTMSFNCGridEditorType});
  this.$rtti.$MethodVar("TTMSFNCGridIOProgressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["CurrentRow",rtl.longint],["TotalRows",rtl.longint],["Progres",rtl.smallint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridIOEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Col",rtl.longint],["Row",rtl.longint],["Value",rtl.string,1]]), methodkind: 0});
  this.TTMSFNCGridColumnType = {"0": "ctDefault", ctDefault: 0, "1": "ctButton", ctButton: 1, "2": "ctCheckBox", ctCheckBox: 2, "3": "ctProgressBar", ctProgressBar: 3, "4": "ctRadioButton", ctRadioButton: 4};
  this.$rtti.$Enum("TTMSFNCGridColumnType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCGridColumnType});
  rtl.createClass(this,"TTMSFNCGridColumn",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FGrid = null;
      this.FColor = 0;
      this.FVertAlignment = 0;
      this.FHorzAlignment = 0;
      this.FSortFormat = 0;
      this.FFont = null;
      this.FEditor = 0;
      this.FReadOnly = false;
      this.FBorderColor = 0;
      this.FID$1 = "";
      this.FBorderWidth = 0;
      this.FWordWrap = false;
      this.FFixed = false;
      this.FSortPrefix = "";
      this.FSortSuffix = "";
      this.FTag = 0;
      this.FComboItems = null;
      this.FColumnType = 0;
      this.FName = "";
      this.FFixedFont = null;
    };
    this.$final = function () {
      this.FGrid = undefined;
      this.FFont = undefined;
      this.FComboItems = undefined;
      this.FFixedFont = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetColor = function (Value) {
      if (this.FColor !== Value) {
        this.FColor = Value;
        this.Changed$1();
      };
    };
    this.SetHorzAlignment = function (Value) {
      if (this.FHorzAlignment !== Value) {
        this.FHorzAlignment = Value;
        this.Changed$1();
      };
    };
    this.SetVertAlignment = function (Value) {
      if (this.FVertAlignment !== Value) {
        this.FVertAlignment = Value;
        this.Changed$1();
      };
    };
    this.SetFont = function (Value) {
      this.FFont.Assign(Value);
      this.Changed$1();
    };
    this.SetBorderColor = function (Value) {
      if (this.FBorderColor !== Value) {
        this.FBorderColor = Value;
        this.Changed$1();
      };
    };
    this.SetBorderWidth = function (Value) {
      if (this.FBorderWidth !== Value) {
        this.FBorderWidth = Value;
        this.Changed$1();
      };
    };
    this.SetWordWrap = function (Value) {
      if (this.FWordWrap !== Value) {
        this.FWordWrap = Value;
        this.Changed$1();
      };
    };
    this.SetFixed = function (Value) {
      if (this.FFixed !== Value) {
        this.FFixed = Value;
        this.Changed$1();
      };
    };
    this.SetComboItems = function (Value) {
      this.FComboItems.Assign(Value);
    };
    this.SetColumnType = function (Value) {
      if (this.FColumnType !== Value) {
        this.FColumnType = Value;
        this.Changed$1();
      };
    };
    this.GetWidth = function () {
      var Result = 0.0;
      Result = rtl.as(this.FCollection.Owner(),$mod.TTMSFNCGridData).GetColWidths(this.GetIndex());
      return Result;
    };
    this.SetWidth = function (Value) {
      if (this.FCollection !== null) {
        rtl.as(this.FCollection.Owner(),$mod.TTMSFNCGridData).BeginUpdate();
        rtl.as(this.FCollection.Owner(),$mod.TTMSFNCGridData).SetColWidths(this.GetIndex(),Value);
        rtl.as(this.FCollection.Owner(),$mod.TTMSFNCGridData).EndUpdate();
      };
    };
    this.SetFixedFont = function (Value) {
      this.FFixedFont.Assign(Value);
      this.Changed$1();
    };
    this.IsWidthStored = function () {
      var Result = false;
      Result = this.GetWidth() !== 64;
      return Result;
    };
    this.Changed$1 = function () {
      if (this.FGrid != null) this.FGrid.UpdateGridCells(false);
    };
    this.GetDisplayName = function () {
      var Result = "";
      Result = "";
      if (this.FGrid != null) Result = this.FGrid.GetColumnDisplayName(this.GetIndex());
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FGrid = rtl.as(this.FCollection,$mod.TTMSFNCGridColumns).FGrid;
      this.FColor = -1;
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFixedFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFixedFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      this.FEditor = $mod.TTMSFNCGridEditorType.etEdit;
      this.FBorderColor = 12632256;
      this.FBorderWidth = 1;
      this.FComboItems = pas.Classes.TStringList.$create("Create$1");
      this.FColumnType = $mod.TTMSFNCGridColumnType.ctDefault;
      this.FHorzAlignment = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FComboItems");
      rtl.free(this,"FFont");
      rtl.free(this,"FFixedFont");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridColumn.isPrototypeOf(Source)) {
        this.FBorderColor = rtl.as(Source,$mod.TTMSFNCGridColumn).FBorderColor;
        this.FBorderWidth = rtl.as(Source,$mod.TTMSFNCGridColumn).FBorderWidth;
        this.FColor = rtl.as(Source,$mod.TTMSFNCGridColumn).FColor;
        this.FFixed = rtl.as(Source,$mod.TTMSFNCGridColumn).FFixed;
        this.FFont.Assign(rtl.as(Source,$mod.TTMSFNCGridColumn).FFont);
        this.FHorzAlignment = rtl.as(Source,$mod.TTMSFNCGridColumn).FHorzAlignment;
        this.FID$1 = rtl.as(Source,$mod.TTMSFNCGridColumn).FID$1;
        this.FVertAlignment = rtl.as(Source,$mod.TTMSFNCGridColumn).FVertAlignment;
        this.FEditor = rtl.as(Source,$mod.TTMSFNCGridColumn).FEditor;
        this.FReadOnly = rtl.as(Source,$mod.TTMSFNCGridColumn).FReadOnly;
        this.FSortFormat = rtl.as(Source,$mod.TTMSFNCGridColumn).FSortFormat;
        this.FSortSuffix = rtl.as(Source,$mod.TTMSFNCGridColumn).FSortSuffix;
        this.FSortPrefix = rtl.as(Source,$mod.TTMSFNCGridColumn).FSortPrefix;
        this.FWordWrap = rtl.as(Source,$mod.TTMSFNCGridColumn).FWordWrap;
        this.FColumnType = rtl.as(Source,$mod.TTMSFNCGridColumn).FColumnType;
        this.FComboItems.Assign(rtl.as(Source,$mod.TTMSFNCGridColumn).FComboItems);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",4,{Default: 12632256});
    $r.addProperty("BorderWidth",2,rtl.longint,"FBorderWidth","SetBorderWidth");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: -1});
    $r.addProperty("ColumnType",2,$mod.$rtti["TTMSFNCGridColumnType"],"FColumnType","SetColumnType",4,{Default: $mod.TTMSFNCGridColumnType.ctDefault});
    $r.addProperty("ComboItems",2,pas.Classes.$rtti["TStringList"],"FComboItems","SetComboItems");
    $r.addProperty("Editor",0,$mod.$rtti["TTMSFNCGridEditorType"],"FEditor","FEditor",4,{Default: $mod.TTMSFNCGridEditorType.etEdit});
    $r.addProperty("Fixed",2,rtl.boolean,"FFixed","SetFixed",4,{Default: false});
    $r.addProperty("FixedFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFixedFont","SetFixedFont");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
    $r.addProperty("HorzAlignment",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorzAlignment","SetHorzAlignment",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("ID",0,rtl.string,"FID$1","FID$1");
    $r.addProperty("Name",0,rtl.string,"FName","FName");
    $r.addProperty("ReadOnly",0,rtl.boolean,"FReadOnly","FReadOnly",4,{Default: false});
    $r.addProperty("SortFormat",0,$mod.$rtti["TTMSFNCGridSortFormat"],"FSortFormat","FSortFormat",4,{Default: $mod.TTMSFNCGridSortFormat.ssAutomatic});
    $r.addProperty("SortSuffix",0,rtl.string,"FSortSuffix","FSortSuffix");
    $r.addProperty("SortPrefix",0,rtl.string,"FSortPrefix","FSortPrefix");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",4,{Default: 0});
    $r.addProperty("VertAlignment",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVertAlignment","SetVertAlignment",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("Width",15,rtl.double,"GetWidth","SetWidth",4,{stored: "IsWidthStored"});
    $r.addProperty("WordWrap",2,rtl.boolean,"FWordWrap","SetWordWrap",4,{Default: false});
  });
  rtl.createClass(this,"TTMSFNCGridColumns",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FGrid = null;
    };
    this.$final = function () {
      this.FGrid = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$3 = function (AGrid) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AGrid,$mod.TTMSFNCGridColumn);
      this.FGrid = AGrid;
      return this;
    };
    this.ColumnByName = function (AName) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FName === AName) {
          Result = this.GetItem$1(i);
          break;
        };
      };
      return Result;
    };
    this.ColumnByID = function (AID) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FID$1 === AID) {
          Result = this.GetItem$1(i);
          break;
        };
      };
      return Result;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.ByID = function (Id) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FID$1 === Id) {
          Result = this.GetItem$1(i);
          break;
        };
      };
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCGridRowInfoList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCGridIntegerList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = 0;
      Result = rtl.trunc(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCGridSList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = 0.0;
      Result = rtl.getNumber(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCGridData",pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.$init.call(this);
      this.FDefaultLayout = null;
      this.FOldSize = 0.0;
      this.FInternalColumnUpdate = false;
      this.FInternalRowUpdate = false;
      this.FColumnProp = null;
      this.FColumns = null;
      this.FUseColumns = false;
      this.FFirstCellApply = false;
      this.FBlockUpdate = false;
      this.FFocusedCell = $mod.TTMSFNCGridCellRec.$new();
      this.FStartCell = $mod.TTMSFNCGridCellRec.$new();
      this.FStopCell = $mod.TTMSFNCGridCellRec.$new();
      this.FRowList = null;
      this.FRowDisplayList = null;
      this.FColumnDisplayList = null;
      this.FSuppressedColumnList = null;
      this.FHiddenColumnList = null;
      this.FHiddenRowList = null;
      this.FColSelect = null;
      this.FSelectedCells = null;
      this.FRowCount = 0;
      this.FFilterApplied = false;
      this.FSortDirection = 0;
      this.FSortColumn = 0;
      this.FSortDir = 0;
      this.FIOOffset = pas.Types.TPoint.$new();
      this.FFilter = null;
      this.FSortIndexes = null;
      this.FCellCalcList = null;
      this.FSaveHiddenCells = false;
      this.FFindCol = 0;
      this.FFindRow = 0;
      this.FSearchCell = pas.Types.TPoint.$new();
      this.FSearchCache = "";
      this.FFindParams = {};
      this.FFindBusy = false;
      this.FColumnCount = 0;
      this.FFixedRows = 0;
      this.FFixedColumns = 0;
      this.FRowH = null;
      this.FFixedRightColumns = 0;
      this.FColumnW = null;
      this.FOrigColumnW = null;
      this.FFixedFooterRows = 0;
      this.FDefaultRowHeight = 0.0;
      this.FDefaultColumnWidth = 0.0;
      this.FCheckFalse = "";
      this.FCheckTrue = "";
      this.FPrevProgress = 0;
      this.FGroupColumn = 0;
      this.FGroupWidth = 0.0;
      this.FGroupCaption = "";
      this.FGroupFooter = "";
      this.FIsGrouping = false;
      this.FFloatFormat = "";
      this.FClipTopLeft = pas.Types.TPoint.$new();
      this.FClipOperation = 0;
      this.FColumnOrder = null;
      this.FBitmapContainer = null;
      this.FOnIOProgress = null;
      this.FOnSortFormat = null;
      this.FOnCustomCompare = null;
      this.FOnRawCompare = null;
      this.FOptions = null;
      this.FMarkList = null;
      this.FDefaultFont = null;
      this.FOnClipboardAfterPasteCell = null;
      this.FOnClipboardBeforePasteCell = null;
      this.FOnCellsChanged = null;
      this.FOnClipboardPaste = null;
      this.FOnLoadCell = null;
      this.FOnSaveCell = null;
      this.FOnNeedFilterDropDown = null;
      this.FOnNeedFilterDropDownData = null;
      this.FOnFilterSelect = null;
      this.FOnGroupCalc = null;
      this.FOnColumnCalc = null;
      this.FOnAfterApplyFilter = null;
      this.FBlockSelectEventHandler = false;
      this.FOnSelectedCell = null;
      this.FOnSelectCell = null;
      this.FGlobalFont = null;
    };
    this.$final = function () {
      this.FDefaultLayout = undefined;
      this.FColumnProp = undefined;
      this.FColumns = undefined;
      this.FFocusedCell = undefined;
      this.FStartCell = undefined;
      this.FStopCell = undefined;
      this.FRowList = undefined;
      this.FRowDisplayList = undefined;
      this.FColumnDisplayList = undefined;
      this.FSuppressedColumnList = undefined;
      this.FHiddenColumnList = undefined;
      this.FHiddenRowList = undefined;
      this.FColSelect = undefined;
      this.FSelectedCells = undefined;
      this.FIOOffset = undefined;
      this.FFilter = undefined;
      this.FSortIndexes = undefined;
      this.FCellCalcList = undefined;
      this.FSearchCell = undefined;
      this.FFindParams = undefined;
      this.FRowH = undefined;
      this.FColumnW = undefined;
      this.FOrigColumnW = undefined;
      this.FClipTopLeft = undefined;
      this.FColumnOrder = undefined;
      this.FBitmapContainer = undefined;
      this.FOnIOProgress = undefined;
      this.FOnSortFormat = undefined;
      this.FOnCustomCompare = undefined;
      this.FOnRawCompare = undefined;
      this.FOptions = undefined;
      this.FMarkList = undefined;
      this.FDefaultFont = undefined;
      this.FOnClipboardAfterPasteCell = undefined;
      this.FOnClipboardBeforePasteCell = undefined;
      this.FOnCellsChanged = undefined;
      this.FOnClipboardPaste = undefined;
      this.FOnLoadCell = undefined;
      this.FOnSaveCell = undefined;
      this.FOnNeedFilterDropDown = undefined;
      this.FOnNeedFilterDropDownData = undefined;
      this.FOnFilterSelect = undefined;
      this.FOnGroupCalc = undefined;
      this.FOnColumnCalc = undefined;
      this.FOnAfterApplyFilter = undefined;
      this.FOnSelectedCell = undefined;
      this.FOnSelectCell = undefined;
      this.FGlobalFont = undefined;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.$final.call(this);
    };
    this.SetDefaultColumnWidth = function (Value) {
      if (this.FDefaultColumnWidth !== Value) {
        this.BeginUpdate();
        this.FDefaultColumnWidth = Value;
        this.EndUpdate();
      };
    };
    this.SetDefaultRowHeight = function (Value) {
      if (this.FDefaultRowHeight !== Value) {
        this.BeginUpdate();
        this.FDefaultRowHeight = Value;
        this.EndUpdate();
      };
    };
    this.EnsureRow = function (Row) {
      while (this.FRowList.GetCount() <= Row) {
        this.FRowList.Add(null);
      };
      while (this.FRowDisplayList.GetCount() <= Row) {
        this.FRowDisplayList.Add(this.FRowDisplayList.GetCount());
      };
    };
    this.EnsureCol = function (Col) {
      while (this.FColumnDisplayList.GetCount() <= Col) {
        this.FColumnDisplayList.Add(this.FColumnDisplayList.GetCount());
        this.SetColumnCount(Col + 1);
      };
    };
    this.GetCells = function (Col, Row) {
      var Result = "";
      var sl = null;
      var RDisp = 0;
      var CDisp = 0;
      Result = "";
      if (Row >= this.FRowDisplayList.GetCount()) return Result;
      if (Col >= this.FColumnDisplayList.GetCount()) return Result;
      RDisp = -1;
      if ((Row >= 0) && (Row <= (this.FRowDisplayList.GetCount() - 1))) RDisp = this.FRowDisplayList.GetItem(Row);
      CDisp = -1;
      if ((Col >= 0) && (Col <= (this.FColumnDisplayList.GetCount() - 1))) CDisp = this.FColumnDisplayList.GetItem(Col);
      if ((RDisp >= 0) && (RDisp < this.FRowList.GetCount())) {
        if (this.FRowList.GetItem(RDisp) != null) {
          sl = this.FRowList.GetItem(RDisp).FData;
          if ((CDisp >= 0) && (CDisp < sl.GetCount())) {
            Result = sl.Get(CDisp);
          };
        };
      };
      return Result;
    };
    this.SetCells = function (Col, Row, Value) {
      var sl = null;
      var RDisp = 0;
      var CDisp = 0;
      this.EnsureRow(Row);
      this.EnsureCol(Col);
      RDisp = this.FRowDisplayList.GetItem(Row);
      CDisp = this.FColumnDisplayList.GetItem(Col);
      if (this.FRowList.GetItem(RDisp) != null) {
        sl = this.FRowList.GetItem(RDisp);
      } else {
        sl = $mod.TTMSFNCGridRowInfo.$create("Create$1");
        this.FRowList.SetItem(RDisp,sl);
      };
      while (sl.FData.GetCount() <= CDisp) sl.FData.AddObject("",null);
      sl.FData.Put(CDisp,Value);
      this.UpdateGridCells(false);
    };
    this.GetIntObjects = function (Col, Row) {
      var Result = null;
      var sl = null;
      Result = null;
      if ((Row >= 0) && (Row <= (this.FRowList.GetCount() - 1))) {
        if (this.FRowList.GetItem(Row) != null) {
          sl = this.FRowList.GetItem(Row).FData;
          if ((Col >= 0) && (Col <= (sl.GetCount() - 1))) Result = sl.GetObject(Col);
        };
      };
      return Result;
    };
    this.SetIntObjects = function (Col, Row, Value) {
      var sl = null;
      while (this.FRowList.GetCount() <= Row) {
        this.FRowList.Add(null);
        this.FRowDisplayList.Add(this.FRowDisplayList.GetCount());
      };
      if (this.FRowList.GetItem(Row) != null) {
        sl = this.FRowList.GetItem(Row);
      } else {
        sl = $mod.TTMSFNCGridRowInfo.$create("Create$1");
        this.FRowList.SetItem(Row,sl);
      };
      while (sl.FData.GetCount() <= Col) sl.FData.AddObject("",null);
      sl.FData.PutObject(Col,Value);
      this.UpdateGridCells(false);
    };
    this.GetRowCount = function () {
      var Result = 0;
      Result = this.FRowCount;
      return Result;
    };
    this.GetHiddenColCount = function () {
      var Result = 0;
      Result = this.FHiddenColumnList.GetCount();
      return Result;
    };
    this.GetHiddenRowCount = function () {
      var Result = 0;
      Result = this.FRowList.GetCount() - this.FRowDisplayList.GetCount();
      return Result;
    };
    this.GetTotalColCount = function () {
      var Result = 0;
      Result = this.GetColumnCount() + this.FHiddenColumnList.GetCount();
      return Result;
    };
    this.GetTotalRowCount = function () {
      var Result = 0;
      Result = this.FRowList.GetCount();
      return Result;
    };
    this.GetAllCells = function (Col, Row) {
      var Result = "";
      var sl = null;
      Result = "";
      if (Row < this.FRowList.GetCount()) {
        if (this.FRowList.GetItem(Row) != null) {
          sl = this.FRowList.GetItem(Row).FData;
          if (Col < sl.GetCount()) Result = sl.Get(Col);
        };
      };
      return Result;
    };
    this.SetAllCells = function (Col, Row, Value) {
      var sl = null;
      while (this.FRowList.GetCount() <= Row) {
        this.FRowList.Add(null);
      };
      while ((this.FRowDisplayList.GetCount() + this.FHiddenRowList.GetCount()) <= Row) {
        this.FRowDisplayList.Add(this.FRowDisplayList.GetCount());
      };
      while ((this.FColumnDisplayList.GetCount() + this.FHiddenColumnList.GetCount()) <= Col) {
        this.FColumnDisplayList.Add(this.FColumnDisplayList.GetCount());
        this.SetColumnCount(Col + 1);
      };
      if (this.FRowList.GetItem(Row) != null) {
        sl = this.FRowList.GetItem(Row);
      } else {
        sl = $mod.TTMSFNCGridRowInfo.$create("Create$1");
        this.FRowList.SetItem(Row,sl);
      };
      while (sl.FData.GetCount() <= Col) sl.FData.AddObject("",null);
      sl.FData.Put(Col,Value);
    };
    this.GetColors = function (Col, Row) {
      var Result = 0;
      var CellProp = null;
      Result = -1;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FColor;
      return Result;
    };
    this.SetColors = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FColor = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FColor = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.SetColumnCount = function (Value) {
      var i = 0;
      while (Value > this.FColumns.GetCount()) this.FColumns.Add$1();
      this.BeginUpdate();
      if (Value < this.FColumnCount) this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(Value,0,this.FColumnCount - 1,this.GetRowCount() - 1)));
      this.FColumnCount = Value;
      if (Value < this.FColumnDisplayList.GetCount()) {
        while (this.FColumnDisplayList.GetCount() > Value) {
          this.FColumnDisplayList.Delete(this.FColumnDisplayList.GetCount() - 1);
        };
      } else {
        i = 0;
        if (this.FColumnDisplayList.GetCount() > 0) i = this.FColumnDisplayList.GetItem(this.FColumnDisplayList.GetCount() - 1) + 1;
        while (this.FColumnDisplayList.GetCount() < Value) {
          this.FColumnDisplayList.Add(i);
          i += 1;
        };
      };
      this.DoColumnCountChanged();
      this.EndUpdate();
    };
    this.SetRowCount = function (Value) {
      var ri = null;
      this.BeginUpdate();
      if (Value < this.FRowCount) this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,Value,this.GetColumnCount() - 1,this.FRowCount - 1)));
      this.FRowCount = Value;
      if (Value < this.FRowList.GetCount()) {
        while (this.FRowList.GetCount() > Value) {
          if (this.FRowList.GetItem(this.FRowList.GetCount() - 1) != null) {
            ri = this.FRowList.GetItem(this.FRowList.GetCount() - 1);
            ri = rtl.freeLoc(ri);
          };
          this.FRowList.Delete(this.FRowList.GetCount() - 1);
        };
      } else while (this.FRowList.GetCount() < Value) this.FRowList.Add(null);
      while (this.FRowDisplayList.GetCount() > this.FRowCount) this.FRowDisplayList.Delete(this.FRowDisplayList.GetCount() - 1);
      this.DoRowCountChanged();
      this.EndUpdate();
    };
    this.SetColumnW = function (Value) {
      if (this.FColumnW !== Value) {
        this.BeginUpdate();
        this.FColumnW.Assign(Value);
        this.EndUpdate();
      };
    };
    this.SetFixedColumns = function (Value) {
      if ((this.FFixedColumns !== Value) && (Value >= 0)) {
        this.BeginUpdate();
        this.FFirstCellApply = false;
        this.FFixedColumns = Value;
        this.EndUpdate();
      };
    };
    this.SetFixedFooterRows = function (Value) {
      if ((this.FFixedFooterRows !== Value) && (Value >= 0)) {
        this.BeginUpdate();
        this.FFirstCellApply = false;
        this.FFixedFooterRows = Value;
        this.EndUpdate();
      };
    };
    this.SetFixedRightColumns = function (Value) {
      if ((this.FFixedRightColumns !== Value) && (Value >= 0)) {
        this.BeginUpdate();
        this.FFirstCellApply = false;
        this.FFixedRightColumns = Value;
        this.EndUpdate();
      };
    };
    this.SetFixedRows = function (Value) {
      if ((this.FFixedRows !== Value) && (Value >= 0)) {
        this.BeginUpdate();
        this.FFirstCellApply = false;
        this.FFixedRows = Value;
        this.EndUpdate();
      };
    };
    this.SetRowH = function (Value) {
      if (this.FRowH !== Value) {
        this.BeginUpdate();
        this.FRowH.Assign(Value);
        this.EndUpdate();
      };
    };
    this.GetColumnCount = function () {
      var Result = 0;
      Result = this.FColumnCount;
      return Result;
    };
    this.SetColWidths = function (Col, Value) {
      var idx = 0;
      var c = null;
      idx = this.FColumnW.IndexOf(Col);
      if ((idx >= 0) && (idx <= (this.FColumnW.GetCount() - 1))) {
        if (Value === this.FDefaultColumnWidth) {
          this.FColumnW.Delete(idx)}
         else {
          this.FColumnW.GetItem$1(idx).SetValue(Math.max(0,Value));
          this.FColumnW.GetItem$1(idx).FCellVal = Col;
        };
      } else if (Value !== this.FDefaultColumnWidth) {
        c = this.FColumnW.Add$1();
        c.SetValue(Math.max(0,Value));
        c.FCellVal = Col;
      };
    };
    this.SetRowHeights = function (Row, Value) {
      var idx = 0;
      var r = null;
      idx = this.FRowH.IndexOf(Row);
      if ((idx >= 0) && (idx <= (this.FRowH.GetCount() - 1))) {
        if (Value === this.FDefaultRowHeight) {
          this.FRowH.Delete(idx)}
         else {
          this.FRowH.GetItem$1(idx).SetValue(Math.max(0,Value));
          this.FRowH.GetItem$1(idx).FCellVal = Row;
        };
      } else if (Value !== this.FDefaultRowHeight) {
        r = this.FRowH.Add$1();
        r.SetValue(Math.max(0,Value));
        r.FCellVal = Row;
      };
    };
    this.GetSelection = function () {
      var Result = $mod.TTMSFNCGridCellRecRange.$new();
      Result.StartCol = this.FStartCell.Col;
      Result.StartRow = this.FStartCell.Row;
      Result.EndCol = this.FStopCell.Col;
      Result.EndRow = this.FStopCell.Row;
      return Result;
    };
    this.SetSelection = function (Value) {
      var start = $mod.TTMSFNCGridCellRec.$new();
      var stop = $mod.TTMSFNCGridCellRec.$new();
      var val = $mod.TTMSFNCGridCellRecRange.$new();
      var vl = $mod.TTMSFNCGridCellRec.$new();
      var a = false;
      val.$assign(Value);
      if (this.IsNormalFixed(val.StartCol,val.StartRow)) {
        vl.$assign(this.NextSelectableColumn(val.StartCol,val.StartRow));
        val.StartCol = vl.Col;
        val.StartRow = vl.Row;
      };
      this.FStartCell.Col = val.StartCol;
      this.FStartCell.Row = val.StartRow;
      this.FStopCell.Col = val.EndCol;
      this.FStopCell.Row = val.EndRow;
      start.$assign(this.FStartCell);
      stop.$assign(this.FStopCell);
      a = true;
      if (this.FOnSelectCell != null) this.FOnSelectCell(this,start.Col,start.Row,{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) {
        this.FBlockSelectEventHandler = true;
        this.SelectCell($mod.TTMSFNCGridCellRec.$clone(start),{},true);
        this.SelectCell($mod.TTMSFNCGridCellRec.$clone(stop),{},true);
        this.FBlockSelectEventHandler = false;
        if (this.FOnSelectedCell != null) this.FOnSelectedCell(this,start.Col,start.Row);
      };
      this.FFocusedCell.$assign(this.FStartCell);
      this.UpdateGridCells(false);
    };
    this.GetFocusedCell = function () {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      Result.$assign(this.FFocusedCell);
      return Result;
    };
    this.SetFocusedCell = function (Value) {
      var val = $mod.TTMSFNCGridCellRec.$new();
      this.SetFocusCell(Value.Col,Value.Row);
      if (this.IsNormalFixed(this.GetFocusedCell().Col,this.GetFocusedCell().Row)) {
        val.$assign(this.NextSelectableColumn(this.GetFocusedCell().Col,this.GetFocusedCell().Row));
        this.SetFocusCell(val.Col,val.Row);
      };
      this.SelectCell($mod.TTMSFNCGridCellRec.$clone(this.FFocusedCell),{},false);
    };
    this.GetCellProps = function (Col, Row) {
      var Result = null;
      Result = this.GetIntObjects(Col,Row);
      return Result;
    };
    this.GetRowSelect = function (Row) {
      var Result = false;
      Result = false;
      if (Row < this.FRowList.GetCount()) {
        if (this.FRowList.GetItem(Row) != null) Result = this.FRowList.GetItem(Row).FState === $mod.TTMSFNCGridRowState.rsSelected;
      };
      return Result;
    };
    this.SetSortColumn = function (Value) {
      if (Value !== this.FSortColumn) this.SortData(Value,this.FSortDirection);
    };
    this.SetSortDirection = function (Value) {
      if (Value !== this.FSortDirection) this.SortData(this.FSortColumn,Value);
    };
    this.SetOptions = function (Value) {
      if (this.FOptions !== Value) this.FOptions.Assign(Value);
    };
    this.GetObjects = function (Col, Row) {
      var Result = null;
      var cp = null;
      Result = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) Result = cp.FObject;
      return Result;
    };
    this.SetObjects = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      cp.FObject = Value;
      this.SetIntObjects(Col,Row,cp);
    };
    this.GetAllFloats = function (Col, Row) {
      var Result = 0.0;
      var s = "";
      var Res = 0.0;
      var Err = 0;
      s = this.GetAllCells(Col,Row);
      if ((s === "") || (s === "-")) s = "0";
      s = $impl.CleanupSep(s);
      pas.System.val$8(s,{get: function () {
          return Res;
        }, set: function (v) {
          Res = v;
        }},{get: function () {
          return Err;
        }, set: function (v) {
          Err = v;
        }});
      if (Err !== 0) {
        Result = 0}
       else Result = Res;
      return Result;
    };
    this.SetAllFloats = function (Col, Row, Value) {
      this.SetAllCells(Col,Row,pas.SysUtils.Format(this.FFloatFormat,pas.System.VarRecs(3,Value)));
    };
    this.GetAllInts = function (Col, Row) {
      var Result = 0;
      var s = "";
      var Res = 0;
      var Err = 0;
      s = this.GetAllCells(Col,Row);
      if ((s === "") || (s === "-")) s = "0";
      s = $impl.CleanupSep(s);
      pas.System.val$6(s,{get: function () {
          return Res;
        }, set: function (v) {
          Res = v;
        }},{get: function () {
          return Err;
        }, set: function (v) {
          Err = v;
        }});
      if (Err !== 0) {
        Result = 0}
       else Result = Res;
      return Result;
    };
    this.SetAllInts = function (Col, Row, Value) {
      this.SetAllCells(Col,Row,pas.SysUtils.IntToStr(Value));
    };
    this.GetMergeCellPrintPageNr = function (Col, Row) {
      var Result = 0;
      var cp = null;
      Result = -1;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FBaseCol !== -1)) {
        Result = cp.FPrintPageNr;
      };
      return Result;
    };
    this.SetMergeCellPrintPageNr = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FBaseCol !== -1)) {
        cp.FPrintPageNr = Value;
      };
    };
    this.GetHorzAlignments = function (Col, Row) {
      var Result = 0;
      var CellProp = null;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FAlignHorz;
      return Result;
    };
    this.SetHorzAlignments = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FAlignHorz = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FAlignHorz = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetVertAlignments = function (Col, Row) {
      var Result = 0;
      var CellProp = null;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FAlignVert;
      return Result;
    };
    this.SetVertAlignments = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FAlignVert = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FAlignVert = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetFontStyles = function (Col, Row) {
      var Result = {};
      var CellProp = null;
      Result = {};
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = rtl.refSet(CellProp.FFontStyle);
      return Result;
    };
    this.SetFontStyles = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FFontStyle = rtl.refSet(Value)}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FFontStyle = rtl.refSet(Value);
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetFontSizes = function (Col, Row) {
      var Result = 0.0;
      var CellProp = null;
      Result = 12;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FFontSize;
      return Result;
    };
    this.SetFontSizes = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FFontSize = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FFontSize = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetFontNames = function (Col, Row) {
      var Result = "";
      var CellProp = null;
      Result = this.FDefaultFont.FName;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FFontName;
      return Result;
    };
    this.SetFontNames = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FFontName = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FFontName = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetFontColors = function (Col, Row) {
      var Result = 0;
      var CellProp = null;
      Result = -1;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FFontColor;
      return Result;
    };
    this.SetFontColors = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FFontColor = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FFontColor = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetRowSelectionCount = function () {
      var Result = 0;
      var i = 0;
      var r = 0;
      r = 0;
      for (var $l = 0, $end = this.FRowList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetRowSelect(i)) r += 1;
      };
      Result = r;
      return Result;
    };
    this.GetReadOnlys = function (Col, Row) {
      var Result = false;
      var cp = null;
      Result = false;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) Result = cp.FReadOnly;
      return Result;
    };
    this.SetReadOnlys = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      cp.FReadOnly = Value;
      this.SetIntObjects(Col,Row,cp);
    };
    this.SaveToHTMLString = function (dir) {
      var $Self = this;
      var Result = "";
      var i = 0;
      var j = 0;
      var mc = 0;
      var mr = 0;
      var s = "";
      var tablestyle = "";
      var slist = null;
      var FirstRow = 0;
      var strtCol = 0;
      var strtRow = 0;
      var wraptxt = "";
      var colwtxt = "";
      var CellText = "";
      var SpanTxt = "";
      var DoneColW = false;
      var Span = pas.Types.TPoint.$new();
      var cssval = "";
      var cssidx = 0;
      var CSSList = null;
      var r = "";
      var Pic = null;
      var images_counter = 0;
      var htmlhdr = "";
      var summ = "";
      var l = null;
      var cellclasstype = null;
      var prevclasstype = null;
      var cellstr = "";
      var cell = null;
      var a = 0;
      function HTMLAddImage(Pic, counter, dir) {
        var Result = "";
        var fname = "";
        fname = dir + "images/img" + pas.SysUtils.IntToStr(counter) + ".png";
        Result = fname;
        return Result;
      };
      function MakeHREF(s) {
        var Result = "";
        Result = s;
        if (!$Self.FOptions.FURL.FShow) return Result;
        if ((pas.System.Pos("://",s) > 0) && (pas.System.Pos("</",s) === 0)) {
          if (!$Self.FOptions.FURL.FFull) {
            Result = "<a href=" + s + ">" + pas.System.Copy(s,pas.System.Pos("://",s) + 3,255) + "</a>"}
           else Result = "<a href=" + s + ">" + s + "</a>";
        };
        if ((pas.System.Pos("mailto:",s) > 0) && (pas.System.Pos("</",s) === 0)) {
          if (!$Self.FOptions.FURL.FFull) {
            Result = "<a href=" + s + ">" + pas.System.Copy(s,pas.System.Pos("mailto:",s) + 7,255) + "</a>"}
           else Result = "<a href=" + s + ">" + s + "</a>";
        };
        return Result;
      };
      function AppendStrEx(s, newstr) {
        if (s.get() === "") {
          s.set(newstr)}
         else s.set(s.get() + ";" + newstr);
      };
      function CSS(AFont, AColor, AFontColor, AHAlign, AVAlign, AAngle) {
        var Result = "";
        var r = "";
        r = "";
        if ((AColor !== -1) && $Self.FOptions.FHTMLExport.FSaveColors) AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"background-color: " + pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.ColorToHTML(AColor) + "");
        if ((AFontColor !== -1) && $Self.FOptions.FHTMLExport.FSaveColors) AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"color: " + pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.ColorToHTML(AFontColor) + "");
        AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"font-size:" + pas.SysUtils.IntToStr(Math.round(AFont.FSize)) + "pt");
        if (pas["WEBLib.Graphics"].TFontStyle.fsItalic in AFont.FStyle) AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"font-style: italic");
        if (pas["WEBLib.Graphics"].TFontStyle.fsBold in AFont.FStyle) AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"font-weight: bold");
        AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"font-family: " + AFont.FName + "");
        var $tmp = AHAlign;
        if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          AppendStrEx({get: function () {
              return r;
            }, set: function (v) {
              r = v;
            }},"text-align: center")}
         else if ($tmp === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"text-align: right");
        var $tmp1 = AVAlign;
        if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
          AppendStrEx({get: function () {
              return r;
            }, set: function (v) {
              r = v;
            }},"vertical-align: top")}
         else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
          AppendStrEx({get: function () {
              return r;
            }, set: function (v) {
              r = v;
            }},"vertical-align: middle")}
         else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) AppendStrEx({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},"vertical-align: bottom");
        Result = r;
        return Result;
      };
      function ExportImg(ACol, ARow, lst, Pic) {
        var Result = "";
        var image = "";
        Result = "";
        if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(Pic)) {
          image = '<img src= "file://' + HTMLAddImage(Pic,images_counter,dir) + '">';
          lst.Add('<TD class="c' + pas.SysUtils.IntToStr(cssidx) + '"' + SpanTxt + wraptxt + colwtxt + ">" + image + s + "</td>");
          images_counter += 1;
        } else lst.Add('<TD class="c' + pas.SysUtils.IntToStr(cssidx) + '"' + SpanTxt + wraptxt + colwtxt + ">" + s + "</td>");
        return Result;
      };
      strtCol = this.FIOOffset.x;
      strtRow = this.FIOOffset.y;
      slist = pas.Classes.TStringList.$create("Create$1");
      slist.SetSorted(false);
      CSSList = pas.Classes.TStringList.$create("Create$1");
      DoneColW = false;
      htmlhdr = "";
      cell = null;
      cellclasstype = null;
      prevclasstype = null;
      l = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      try {
        if (this.FOptions.FHTMLExport.FXHTML) {
          htmlhdr = htmlhdr + '<?xml version="1.0" encoding="utf-8"?>\r\n' + '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\r\n' + '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r\n' + '<HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r\n';
        };
        if (this.FOptions.FHTMLExport.FPrefixTag !== "") htmlhdr = htmlhdr + this.FOptions.FHTMLExport.FPrefixTag;
        if (this.FOptions.FHTMLExport.FTableStyle !== "") {
          tablestyle = " " + this.FOptions.FHTMLExport.FTableStyle + " "}
         else tablestyle = "";
        if (this.FOptions.FHTMLExport.FSummary !== "") {
          summ = 'SUMMARY="' + this.FOptions.FHTMLExport.FSummary + '" '}
         else summ = "";
        slist.Add('<TABLE BORDER="' + pas.SysUtils.IntToStr(this.FOptions.FHTMLExport.FBorderSize) + '" ' + 'CELLSPACING="' + pas.SysUtils.IntToStr(this.FOptions.FHTMLExport.FCellSpacing) + '" ' + 'CELLPADDING="' + pas.SysUtils.IntToStr(this.FOptions.FHTMLExport.FCellPadding) + '" ' + summ + tablestyle + ' WIDTH="' + pas.SysUtils.IntToStr(this.FOptions.FHTMLExport.FWidth) + '%">');
        FirstRow = strtRow;
        if ((this.FFixedRows > 0) && (this.FIOOffset.y < this.FFixedRows)) {
          slist.Add("<TR>");
          DoneColW = true;
          for (var $l = strtCol, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
            i = $l;
            mc = 0;
            mr = 0;
            if (this.IsBaseCellEx(i,0,{get: function () {
                return mc;
              }, set: function (v) {
                mc = v;
              }},{get: function () {
                return mr;
              }, set: function (v) {
                mr = v;
              }})) {
              Span.$assign(this.CellSpan(i,0));
              SpanTxt = "";
              if (Span.x > 0) SpanTxt = ' COLSPAN="' + pas.SysUtils.IntToStr(Span.x) + '"';
              if (Span.y > 0) SpanTxt = SpanTxt + ' ROWSPAN="' + pas.SysUtils.IntToStr(Span.y) + '"';
              CellText = this.DoSaveCell(i,0);
              s = pas["WEBLib.TMSFNCGridDataUtil"].HTMLLineBreaks(CellText);
              s = MakeHREF(s);
              if (s === "") s = "&nbsp;";
              if (this.FOptions.FHTMLExport.FColumnWidths.GetCount() > i) {
                colwtxt = " WIDTH=" + pas.SysUtils.IntToStr(this.FOptions.FHTMLExport.FColumnWidths.GetInteger(i))}
               else colwtxt = "";
              cellclasstype = null;
              this.DoGetCellClass(i,0,{get: function () {
                  return cellclasstype;
                }, set: function (v) {
                  cellclasstype = v;
                }});
              cellstr = "";
              this.DoGetCellData(i,0,{get: function () {
                  return cellstr;
                }, set: function (v) {
                  cellstr = v;
                }});
              if ((prevclasstype !== cellclasstype) && (prevclasstype !== null) && (cell != null)) cell = rtl.freeLoc(cell);
              if (prevclasstype !== cellclasstype) {
                cell = cellclasstype.$create("Create$1",[$Self]);
                if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FBitmapContainer = this.GetBitmapContainer();
                prevclasstype = cellclasstype;
              };
              if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
                l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
                l.Assign(this.GetDefaultNormalLayout());
                this.DoGetCellLayout(i,0,l,$mod.TTMSFNCGridCellState.csNormal);
                rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
              };
              this.DoGetCellProperties(i,0,cell);
              a = 0;
              this.DoGetCellRotation(i,0,{get: function () {
                  return a;
                }, set: function (v) {
                  a = v;
                }});
              wraptxt = "";
              cssval = CSS(l.FFont,l.FFill.FColor,l.FFont.FColor,l.FTextAlign,l.FVerticalTextAlign,a);
              cssidx = CSSList.IndexOf(cssval);
              if (cssidx === -1) cssidx = CSSList.Add(cssval);
              if (this.FOptions.FHTMLExport.FExportImages) {
                Pic = this.GetBitmap(i,0)}
               else Pic = null;
              ExportImg(i,0,slist,Pic);
            };
          };
          slist.Add("</TR>");
          FirstRow = 1;
        };
        this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,FirstRow);
        images_counter = 1;
        for (var $l1 = FirstRow, $end1 = this.GetRowCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.ExportNotification($mod.TTMSFNCGridExportState.esExportNextRow,i);
          slist.Add("<TR>");
          for (var $l2 = strtCol, $end2 = this.GetColumnCount() - 1; $l2 <= $end2; $l2++) {
            j = $l2;
            if (this.IsBaseCellEx(j,i,{get: function () {
                return mc;
              }, set: function (v) {
                mc = v;
              }},{get: function () {
                return mr;
              }, set: function (v) {
                mr = v;
              }})) {
              Span.$assign(this.CellSpan(j,i));
              SpanTxt = "";
              if (Span.x > 0) SpanTxt = ' COLSPAN="' + pas.SysUtils.IntToStr(Span.x) + '"';
              if (Span.y > 0) SpanTxt = SpanTxt + ' ROWSPAN="' + pas.SysUtils.IntToStr(Span.y) + '"';
              CellText = this.DoSaveCell(j,i);
              s = CellText;
              if (this.FOptions.FHTMLExport.FConvertSpecialChars) s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.FixMarkup(s,true);
              if (this.FOptions.FHTMLExport.FNonBreakingText) s = pas["WEBLib.TMSFNCGridDataUtil"].FixNonBreaking(s);
              s = pas["WEBLib.TMSFNCGridDataUtil"].HTMLLineBreaks(s);
              s = MakeHREF(s);
              cellclasstype = null;
              this.DoGetCellClass(j,i,{get: function () {
                  return cellclasstype;
                }, set: function (v) {
                  cellclasstype = v;
                }});
              cellstr = "";
              this.DoGetCellData(j,i,{get: function () {
                  return cellstr;
                }, set: function (v) {
                  cellstr = v;
                }});
              if ((prevclasstype !== cellclasstype) && (prevclasstype !== null) && (cell != null)) cell = rtl.freeLoc(cell);
              if (prevclasstype !== cellclasstype) {
                cell = cellclasstype.$create("Create$1",[$Self]);
                if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FBitmapContainer = this.GetBitmapContainer();
                prevclasstype = cellclasstype;
              };
              if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
                l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
                l.Assign(this.GetDefaultNormalLayout());
                this.DoGetCellLayout(j,i,l,$mod.TTMSFNCGridCellState.csNormal);
                rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
              };
              this.DoGetCellProperties(j,i,cell);
              a = 0;
              this.DoGetCellRotation(j,i,{get: function () {
                  return a;
                }, set: function (v) {
                  a = v;
                }});
              cssval = CSS(l.FFont,l.FFill.FColor,l.FFont.FColor,l.FTextAlign,l.FVerticalTextAlign,a);
              cssidx = CSSList.IndexOf(cssval);
              if (cssidx === -1) cssidx = CSSList.Add(cssval);
              if ((this.FOptions.FHTMLExport.FColumnWidths.GetCount() > (j - strtCol)) && !DoneColW) {
                colwtxt = " width=" + pas.SysUtils.IntToStr(this.FOptions.FHTMLExport.FColumnWidths.GetInteger(j - strtCol))}
               else colwtxt = "";
              if (pas.SysUtils.Trim(s) === "") s = "&nbsp;";
              wraptxt = "";
              if (this.FOptions.FHTMLExport.FExportImages) {
                Pic = this.GetBitmap(j,i)}
               else Pic = null;
              ExportImg(j,i,slist,Pic);
            };
          };
          slist.Add("</TR>");
        };
        this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
        slist.Add("</TABLE>");
        if (this.FOptions.FHTMLExport.FSuffixTag !== "") slist.Add(this.FOptions.FHTMLExport.FSuffixTag);
        if (this.FOptions.FHTMLExport.FXHTML) slist.Add("</HTML>");
        r = "<style>\r\n";
        for (var $l3 = 0, $end3 = CSSList.GetCount() - 1; $l3 <= $end3; $l3++) {
          cssidx = $l3;
          r = r + ".c" + pas.SysUtils.IntToStr(cssidx) + " {" + CSSList.Get(cssidx) + "}\r\n";
        };
        r = r + "</style>\r\n";
        Result = htmlhdr + r + slist.GetTextStr();
      } finally {
        if (cell != null) cell = rtl.freeLoc(cell);
        l = rtl.freeLoc(l);
        slist = rtl.freeLoc(slist);
        CSSList = rtl.freeLoc(CSSList);
      };
      return Result;
    };
    this.GetColumnSelect = function (Col) {
      var Result = false;
      Result = this.FColSelect.HasValue(Col);
      return Result;
    };
    this.GetColumnSelectionCount = function () {
      var Result = 0;
      Result = this.FColSelect.GetCount();
      return Result;
    };
    this.SetColumnSelect = function (Col, Value) {
      var idx = 0;
      idx = this.FColSelect.IndexOfValue(Col);
      if ((idx === -1) && Value) this.FColSelect.Add$1(Col);
      if ((idx !== -1) && !Value) this.FColSelect.Delete$1(idx);
      this.UpdateGridCells(false);
    };
    this.GetCellSelect = function (Col, Row) {
      var Result = false;
      Result = this.FSelectedCells.Find($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(Col,Row))) !== -1;
      return Result;
    };
    this.GetCellSelectionCount = function () {
      var Result = 0;
      Result = this.FSelectedCells.GetCount();
      return Result;
    };
    this.SetCellSelect = function (Col, Row, Value) {
      var idx = 0;
      var c = $mod.TTMSFNCGridCellRec.$new();
      c.$assign($mod.MakeCell(Col,Row));
      idx = this.FSelectedCells.Find($mod.TTMSFNCGridCellRec.$clone(c));
      if ((idx === -1) && Value) this.FSelectedCells.AddCell($mod.TTMSFNCGridCellRec.$clone(c));
      if ((idx !== -1) && !Value) this.FSelectedCells.DeleteCell$1(idx);
      this.UpdateGridCells(false);
    };
    this.GetSelectedColumn = function (index) {
      var Result = 0;
      Result = this.FColSelect.GetInteger(index);
      return Result;
    };
    this.GetSelectedRow = function (index) {
      var Result = 0;
      var i = 0;
      var cnt = 0;
      Result = -1;
      cnt = 0;
      for (var $l = 0, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FRowList.GetItem(i) != null) {
          if (this.FRowList.GetItem(i).FState === $mod.TTMSFNCGridRowState.rsSelected) {
            if (cnt === index) {
              Result = i;
              break;
            };
            cnt += 1;
          };
        };
      };
      return Result;
    };
    this.GetSelectedCell = function (index) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      Result.$assign(this.FSelectedCells.GetItem(index));
      return Result;
    };
    this.GetCheckBoxState = function (Col, Row) {
      var Result = false;
      var cp = null;
      var c = 0;
      Result = false;
      cp = this.GetIntObjects(Col,Row);
      if (this.FUseColumns && !(cp != null)) {
        c = this.DisplToRealColumn(Col);
        if (c < this.FColumns.GetCount()) {
          if (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctCheckBox) {
            Result = this.GetCells(Col,Row) === this.FCheckTrue;
          };
        };
      } else {
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellCheckBox.isPrototypeOf(cp.FControl)) {
          Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked;
        };
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl)) {
          Result = this.GetCells(Col,Row) === this.FCheckTrue;
        };
      };
      return Result;
    };
    this.SetCheckBoxState = function (Col, Row, Value) {
      var cp = null;
      var c = 0;
      cp = this.GetIntObjects(Col,Row);
      if (this.FUseColumns && !(cp != null)) {
        c = this.DisplToRealColumn(Col);
        if (c < this.FColumns.GetCount()) {
          if (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctCheckBox) {
            if (Value) {
              this.SetCells(Col,Row,this.FCheckTrue)}
             else this.SetCells(Col,Row,this.FCheckFalse);
          };
        };
      } else {
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellCheckBox.isPrototypeOf(cp.FControl)) {
          rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked = Value;
        };
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl)) {
          if (Value) {
            this.SetCells(Col,Row,this.FCheckTrue)}
           else this.SetCells(Col,Row,this.FCheckFalse);
        };
      };
      this.UpdateGridCells(false);
    };
    this.GetFixedCellSelect = function (Col, Row) {
      var Result = false;
      Result = this.FSelectedCells.FindFixed($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(Col,Row))) !== -1;
      return Result;
    };
    this.GetComments = function (Col, Row) {
      var Result = "";
      var CellProp = null;
      Result = "";
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FComment;
      return Result;
    };
    this.SetComments = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FComment = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FComment = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetCommentColors = function (Col, Row) {
      var Result = 0;
      var CellProp = null;
      Result = -1;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FCommentColor;
      return Result;
    };
    this.SetCommentColors = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FCommentColor = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FCommentColor = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetColumnCalculation = function (Col) {
      var Result = 0;
      if (Col >= this.FCellCalcList.GetCount()) {
        Result = $mod.TTMSFNCGridColumnCalculation.ccNone;
      } else {
        Result = this.FCellCalcList.GetInteger(Col);
      };
      return Result;
    };
    this.SetColumnCalculation = function (Col, Value) {
      while (this.FCellCalcList.GetCount() <= Col) this.FCellCalcList.Add$1($mod.TTMSFNCGridColumnCalculation.ccNone);
      this.FCellCalcList.SetInteger(Col,Value);
      this.UpdateColumnCalc(Col,Value);
    };
    this.UpdateColumnCalc = function (Col, Value) {
      var str = "";
      var r = 0.0;
      if (this.FFixedFooterRows === 0) return;
      var $tmp = Value;
      if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccNone) {
        str = ""}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccSum) {
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnSum(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)))}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccAvg) {
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnAvg(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)))}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccCount) {
        r = this.GetRowCount() - this.FFixedFooterRows - this.FFixedRows;
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,r));
      } else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccMin) {
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnMin(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)))}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccMax) {
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnMax(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)))}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccCUSTOM) {
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnCustomCalc(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)))}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccDistinct) {
        str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnDistinct(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)))}
       else if ($tmp === $mod.TTMSFNCGridColumnCalculation.ccStdDev) str = pas.SysUtils.Format(this.FOptions.FEditing.FCalcFormat,pas.System.VarRecs(3,this.ColumnStdDev(Col,this.FFixedRows,this.GetRowCount() - this.FFixedFooterRows - 1)));
      this.SetCells(Col,this.GetRowCount() - this.FFixedFooterRows,str);
    };
    this.GetFloats = function (Col, Row) {
      var Result = 0.0;
      var s = "";
      var Res = 0.0;
      var Err = 0;
      s = this.GetCells(Col,Row);
      this.DoGetCellData(Col,Row,{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }});
      if ((s === "") || (s === "-")) s = "0";
      s = $impl.CleanupSep(s);
      pas.System.val$8(s,{get: function () {
          return Res;
        }, set: function (v) {
          Res = v;
        }},{get: function () {
          return Err;
        }, set: function (v) {
          Err = v;
        }});
      if (Err !== 0) {
        Result = 0}
       else Result = Res;
      return Result;
    };
    this.SetFloats = function (Col, Row, Value) {
      this.SetAllCells(Col,Row,pas.SysUtils.Format(this.FFloatFormat,pas.System.VarRecs(3,Value)));
    };
    this.GetInts = function (Col, Row) {
      var Result = 0;
      var s = "";
      var Res = 0;
      var Err = 0;
      s = this.GetCells(Col,Row);
      this.DoGetCellData(Col,Row,{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }});
      if ((s === "") || (s === "-")) s = "0";
      s = $impl.CleanupSep(s);
      pas.System.val$6(s,{get: function () {
          return Res;
        }, set: function (v) {
          Res = v;
        }},{get: function () {
          return Err;
        }, set: function (v) {
          Err = v;
        }});
      if (Err !== 0) {
        Result = 0}
       else Result = Res;
      return Result;
    };
    this.SetInts = function (Col, Row, Value) {
      this.SetAllCells(Col,Row,pas.SysUtils.IntToStr(Value));
    };
    this.GetStrippedCells = function (Col, Row) {
      var Result = "";
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(this.GetCells(Col,Row));
      return Result;
    };
    this.GetRowText = function (Row) {
      var Result = "";
      var sl = null;
      var RDisp = 0;
      Result = "";
      if (Row >= this.FRowDisplayList.GetCount()) return Result;
      RDisp = this.FRowDisplayList.GetItem(Row);
      if (RDisp < this.FRowList.GetCount()) {
        if (this.FRowList.GetItem(RDisp) != null) {
          sl = this.FRowList.GetItem(RDisp).FData;
          sl.SetDelimiter(this.FOptions.FIO.FDelimiter);
          Result = sl.GetDelimitedText();
        };
      };
      return Result;
    };
    this.GetBitmaps = function (Col, Row) {
      var Result = null;
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellBitmap.isPrototypeOf(cp.FControl)) {
        Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmap).FBitmap}
       else Result = this.CreateBitmap(Col,Row);
      return Result;
    };
    this.GetBooleans = function (Col, Row) {
      var Result = false;
      Result = this.GetCheckBoxState(Col,Row);
      return Result;
    };
    this.SetBitmaps = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellBitmap.$create("Create$1",[this]);
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmap).FBitmap.Assign(Value);
      this.SetIntObjects(Col,Row,cp);
    };
    this.SetBooleans = function (Col, Row, Value) {
      this.AddDataCheckBox(Col,Row,Value);
    };
    this.SetColumns = function (Value) {
      this.FColumns.Assign(Value);
    };
    this.SetOrigColumnW = function (Value) {
      this.FOrigColumnW.Assign(Value);
    };
    this.IsDefaultColumnWidthStored = function () {
      var Result = false;
      Result = this.FDefaultColumnWidth !== 68;
      return Result;
    };
    this.IsDefaultRowHeightStored = function () {
      var Result = false;
      Result = this.FDefaultRowHeight !== 24;
      return Result;
    };
    this.SetRowText = function (Row, Value) {
      var $Self = this;
      var str = null;
      var I = 0;
      function Split(ADelimiter, AInput, AStrings) {
        AStrings.Clear();
        AStrings.SetDelimiter(ADelimiter);
        AStrings.FStrictDelimiter = true;
        AStrings.SetDelimitedText(AInput);
      };
      str = pas.Classes.TStringList.$create("Create$1");
      Split(this.FOptions.FIO.FDelimiter,Value,str);
      for (var $l = this.FIOOffset.x, $end = (this.FIOOffset.x + str.GetCount()) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetCells(I,Row,str.Get(I - this.FIOOffset.x));
      };
      str = rtl.freeLoc(str);
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
    };
    this.GetCellCalcStates = function (Col, Row) {
      var Result = 0;
      var CellProp = null;
      Result = $mod.TTMSFNCGridCellCalcState.csNoCalc;
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FCalcState;
      return Result;
    };
    this.SetCellCalcStates = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FCalcState = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FCalcState = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.GetCalcValues = function (Col, Row) {
      var Result = undefined;
      var CellProp = null;
      Result = "";
      CellProp = this.GetIntObjects(Col,Row);
      if (CellProp != null) Result = CellProp.FCalcValue;
      return Result;
    };
    this.SetCalcValues = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FCalcValue = Value}
       else {
        cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
        cp.FCalcValue = Value;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.SetDefaultFont = function (Value) {
      this.FDefaultFont.Assign(Value);
    };
    this.SetGlobalFont = function (Value) {
      this.FGlobalFont.Assign(Value);
    };
    this.GetDataRowCount = function () {
      var Result = 0;
      Result = this.GetRowCount() - this.FFixedRows - this.FFixedFooterRows;
      return Result;
    };
    this.DataGetItemIndex = function () {
      var Result = 0;
      Result = this.FFocusedCell.Row - this.FFixedRows;
      return Result;
    };
    this.ClearData = function () {
      this.Clear();
      this.SetRowCount(this.FFixedRows + this.FFixedFooterRows);
      this.SetColumnCount(this.FFixedColumns + this.FFixedRightColumns);
    };
    this.SetDataColumnCount = function (AValue) {
      this.SetColumnCount(AValue + this.FFixedRows + this.FFixedRightColumns);
    };
    this.SetDataRowCount = function (AValue) {
      this.SetRowCount(this.FFixedRows + this.FFixedFooterRows + AValue);
    };
    this.SetDataValue = function (AColumn, ARow, AValue) {
      this.SetCells(AColumn + this.FFixedColumns,ARow + this.FFixedRows,AValue);
    };
    this.SetDataHeader = function (AColumn, AValue) {
      this.SetCells(AColumn + this.FFixedColumns,0,AValue);
    };
    this.DataBeginUpdate = function () {
      this.BeginUpdate();
    };
    this.DataEndUpdate = function () {
      this.EndUpdate();
    };
    this.DataInsertRow = function (AInsertPosition) {
      this.InsertRow(AInsertPosition);
    };
    this.DataSetItemIndex = function (AValue) {
      this.SelectCell($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(this.FFocusedCell.Col,AValue + this.FFixedRows)),{},false);
    };
    this.SetRowSelect = function (Row, Value) {
      var sl = null;
      this.EnsureRow(Row);
      if (!(this.FRowList.GetItem(Row) != null)) {
        sl = $mod.TTMSFNCGridRowInfo.$create("Create$1");
        this.FRowList.SetItem(Row,sl);
      };
      if (Value) {
        this.FRowList.GetItem(Row).SetState($mod.TTMSFNCGridRowState.rsSelected)}
       else this.FRowList.GetItem(Row).SetState($mod.TTMSFNCGridRowState.rsDefault);
      this.UpdateGridCells(false);
    };
    this.GetColumnDisplayName = function (ACol) {
      var Result = "";
      var c = null;
      Result = "Column " + pas.SysUtils.IntToStr(ACol);
      if ((ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) {
        c = this.FColumns.GetItem$1(ACol);
        if (c.FName !== "") Result = c.FName;
      };
      return Result;
    };
    this.SelectCell = function (Cell, Shift, MouseDragging) {
    };
    this.SetStartCell = function (ACol, ARow) {
      this.FStartCell.Col = ACol;
      this.FStartCell.Row = ARow;
      this.FStartCell.Col = Math.max(this.FFixedColumns,Math.min(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FStartCell.Col));
      this.FStartCell.Row = Math.max(this.FFixedRows,Math.min(this.GetRowCount() - 1 - this.FFixedFooterRows,this.FStartCell.Row));
    };
    this.SetStopCell = function (ACol, ARow) {
      this.FStopCell.Col = ACol;
      this.FStopCell.Row = ARow;
      this.FStopCell.Col = Math.max(this.FFixedColumns,Math.min(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FStopCell.Col));
      this.FStopCell.Row = Math.max(this.FFixedRows,Math.min(this.GetRowCount() - 1 - this.FFixedFooterRows,this.FStopCell.Row));
    };
    this.SetFocusCell = function (ACol, ARow) {
      this.FFocusedCell.Col = ACol;
      this.FFocusedCell.Row = ARow;
      this.FFocusedCell.Col = Math.max(this.FFixedColumns,Math.min(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FFocusedCell.Col));
      this.FFocusedCell.Row = Math.max(this.FFixedRows,Math.min(this.GetRowCount() - 1 - this.FFixedFooterRows,this.FFocusedCell.Row));
    };
    this.GetColWidths = function (AIndex) {
      var Result = 0.0;
      var idx = 0;
      Result = 0;
      if (this.FSuppressedColumnList.IndexOf(AIndex) !== -1) return Result;
      idx = this.FColumnW.IndexOf(AIndex);
      if (idx !== -1) {
        Result = this.FColumnW.GetItem$1(idx).FValue}
       else Result = this.FDefaultColumnWidth;
      return Result;
    };
    this.GetRowHeights = function (AIndex) {
      var Result = 0.0;
      var idx = 0;
      idx = this.FRowH.IndexOf(AIndex);
      if (idx !== -1) {
        Result = this.FRowH.GetItem$1(idx).FValue}
       else Result = this.FDefaultRowHeight;
      return Result;
    };
    this.CompareLine = function (Col, Row1, Row2) {
      var Result = 0;
      var r = 0;
      if (this.IsIgnoredColumn(Col)) {
        r = 0}
       else r = this.CompareRows(Col,Row1,Row2);
      if ((r === 0) && this.FOptions.FSorting.FMultiColumn) {
        if (Col <= (this.GetColumnCount() - 2)) {
          Col += 1;
          r = this.CompareLine(Col,Row1,Row2);
        };
      };
      Result = r;
      return Result;
    };
    this.CompareRows = function (Col, Row1, Row2) {
      var Result = 0;
      var s1 = "";
      var s2 = "";
      var SortFormat = 0;
      var Prefix = "";
      var Suffix = "";
      var dt1 = 0.0;
      var dt2 = 0.0;
      var db1 = 0.0;
      var db2 = 0.0;
      var st1 = "";
      var st2 = "";
      var b1 = false;
      var b2 = false;
      var r = 0;
      var err = 0;
      var t1 = 0;
      var t2 = 0;
      var v = 0.0;
      s1 = this.GetCells(Col,Row1);
      s2 = this.GetCells(Col,Row2);
      if (this.FOptions.FSorting.FIgnoreCase) {
        s1 = pas.SysUtils.UpperCase(s1);
        s2 = pas.SysUtils.UpperCase(s2);
      };
      Suffix = "";
      Prefix = "";
      SortFormat = $mod.TTMSFNCGridSortFormat.ssAutomatic;
      this.DoSortFormat(Col,{get: function () {
          return SortFormat;
        }, set: function (v) {
          SortFormat = v;
        }},{get: function () {
          return Prefix;
        }, set: function (v) {
          Prefix = v;
        }},{get: function () {
          return Suffix;
        }, set: function (v) {
          Suffix = v;
        }});
      var $tmp = SortFormat;
      if ($tmp === $mod.TTMSFNCGridSortFormat.ssAutomatic) {
        t1 = pas["WEBLib.TMSFNCGridDataUtil"].IsType(s1);
        t2 = pas["WEBLib.TMSFNCGridDataUtil"].IsType(s2);
        if ((t1 in rtl.createSet(pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridAutoType.atNumeric,pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridAutoType.atFloat)) && (t2 in rtl.createSet(pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridAutoType.atNumeric,pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridAutoType.atFloat))) {
          pas.System.val$8(s1,{get: function () {
              return db1;
            }, set: function (v) {
              db1 = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          pas.System.val$8(s2,{get: function () {
              return db2;
            }, set: function (v) {
              db2 = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (db1 === db2) {
            r = 0}
           else if (db1 > db2) {
            r = 1}
           else r = -1;
        } else {
          if (s1 === s2) {
            r = 0}
           else if (s1 > s2) {
            r = 1}
           else r = -1;
        };
      } else if (($tmp === $mod.TTMSFNCGridSortFormat.ssAlphabetic) || ($tmp === $mod.TTMSFNCGridSortFormat.ssHTML)) {
        st1 = s1;
        st2 = s2;
        if (SortFormat === $mod.TTMSFNCGridSortFormat.ssHTML) {
          st1 = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(st1);
          st2 = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(st2);
        };
        if (st1 === st2) {
          r = 0}
         else if (st1 > st2) {
          r = 1}
         else r = -1;
      } else if ($tmp === $mod.TTMSFNCGridSortFormat.ssAlphabeticNoCase) {
        st1 = pas.SysUtils.UpperCase(pas["WEBLib.TMSFNCTypes"].VarToStr(s1));
        st2 = pas.SysUtils.UpperCase(pas["WEBLib.TMSFNCTypes"].VarToStr(s2));
        if (st1 === st2) {
          r = 0}
         else if (st1 > st2) {
          r = 1}
         else r = -1;
      } else if ($tmp === $mod.TTMSFNCGridSortFormat.ssNumeric) {
        if (s1 !== "") {
          v = Infinity;
          pas.SysUtils.TryStrToFloat$2(s1,{get: function () {
              return v;
            }, set: function (w) {
              v = w;
            }});
        } else v = Infinity - 1;
        db1 = v;
        if (s2 !== "") {
          v = Infinity;
          pas.SysUtils.TryStrToFloat$2(s2,{get: function () {
              return v;
            }, set: function (w) {
              v = w;
            }});
        } else v = Infinity - 1;
        db2 = v;
        if (db1 === db2) {
          r = 0}
         else if (db1 > db2) {
          r = 1}
         else r = -1;
      } else if ($tmp === $mod.TTMSFNCGridSortFormat.ssDate) {
        dt1 = 0;
        if (s1 !== "") try {
          dt1 = pas["WEBLib.TMSFNCTypes"].VarToDateTime(s1);
        } catch ($e) {
        };
        dt2 = 0;
        if (s2 !== "") try {
          dt2 = pas["WEBLib.TMSFNCTypes"].VarToDateTime(s2);
        } catch ($e) {
        };
        if (dt1 === dt2) {
          r = 0}
         else if (dt1 > dt2) {
          r = 1}
         else r = -1;
      } else if ($tmp === $mod.TTMSFNCGridSortFormat.ssCheckBox) {
        b1 = this.GetCheckBoxState(Col,Row1);
        b2 = this.GetCheckBoxState(Col,Row2);
        if (b1 && !b2) {
          r = 1}
         else if (b1 === b2) {
          r = 0}
         else r = -1;
      } else if ($tmp === $mod.TTMSFNCGridSortFormat.ssCustom) {
        this.DoCustomCompare(s1,s2,{get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }});
      } else if ($tmp === $mod.TTMSFNCGridSortFormat.ssRaw) {
        this.DoRawCompare(Col,Row1,Row2,{get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }});
      };
      if (this.FOptions.FSorting.FIgnoreBlanks) {
        var $tmp1 = this.FSortDirection;
        if ($tmp1 === $mod.TTMSFNCGridSortDirection.sdAscending) {
          if ((s1 === "") && (s2 !== "")) if (this.FOptions.FSorting.FBlankPosition === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortBlankPosition.blFirst) {
            r = -1}
           else r = +1;
          if ((s2 === "") && (s1 !== "")) if (this.FOptions.FSorting.FBlankPosition === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortBlankPosition.blFirst) {
            r = +1}
           else r = -1;
        } else if ($tmp1 === $mod.TTMSFNCGridSortDirection.sdDescending) {
          if ((s1 === "") && (s2 !== "")) if (this.FOptions.FSorting.FBlankPosition === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortBlankPosition.blFirst) {
            r = +1}
           else r = -1;
          if ((s2 === "") && (s1 !== "")) if (this.FOptions.FSorting.FBlankPosition === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortBlankPosition.blFirst) {
            r = -1}
           else r = +1;
        };
      };
      Result = r;
      return Result;
    };
    this.CompareRowsIndexed = function (Col, Row1, Row2) {
      var Result = 0;
      var r = 0;
      var idx = 0;
      var sd = 0;
      idx = this.FSortIndexes.GetInteger(Col) & 0x7FFFFFFF;
      if ((this.FSortIndexes.GetInteger(Col) & 0x80000000) === 0x80000000) {
        sd = $mod.TTMSFNCGridSortDirection.sdDescending}
       else sd = $mod.TTMSFNCGridSortDirection.sdAscending;
      if (this.IsIgnoredColumn(idx)) {
        r = 0}
       else r = this.CompareRows(idx,Row1,Row2);
      if ((r === 0) && this.FOptions.FSorting.FMultiColumn) {
        if (Col < (this.FSortIndexes.GetCount() - 1)) {
          Col += 1;
          r = this.CompareRowsIndexed(Col,Row1,Row2);
        };
      } else {
        if (sd === $mod.TTMSFNCGridSortDirection.sdDescending) {
          r = -r;
        };
      };
      Result = r;
      return Result;
    };
    this.QuickSortRows = function (Col, L, R) {
      var i = 0;
      var j = 0;
      var k = 0;
      var m = 0;
      if (this.FSortDirection === $mod.TTMSFNCGridSortDirection.sdAscending) {
        this.FSortDir = 1}
       else this.FSortDir = -1;
      i = L;
      j = R;
      m = (L + R) >>> 1;
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        k = $l;
        this.SetCells(k,this.GetRowCount() - 1,this.GetCells(k,m));
        this.SetObjects(k,this.GetRowCount() - 1,this.GetObjects(k,m));
      };
      do {
        while ((this.CompareRows(Col,this.GetRowCount() - 1,i) === this.FSortDir) && (i < R)) i += 1;
        while ((this.CompareRows(Col,j,this.GetRowCount() - 1) === this.FSortDir) && (j > L)) j -= 1;
        if (i <= j) {
          if (i !== j) {
            if (this.CompareRows(Col,i,j) !== 0) {
              var $tmp = this.FOptions.FSorting.FColumns;
              if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortColumns.scAll) {
                this.SwapRows(i,j)}
               else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortColumns.scSingle) {
                this.SwapCells(Col,i,j)}
               else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortColumns.scNormal) this.SwapNormalCells(i,j);
            };
          };
          i += 1;
          j -= 1;
        };
      } while (!(i > j));
      if (L < j) this.QuickSortRows(Col,L,j);
      if (i < R) this.QuickSortRows(Col,i,R);
    };
    this.QuickSortRowsIndexed = function (Col, L, R) {
      var i = 0;
      var j = 0;
      var k = 0;
      var m = 0;
      if (this.FSortDirection === $mod.TTMSFNCGridSortDirection.sdAscending) {
        this.FSortDir = 1}
       else this.FSortDir = -1;
      i = L;
      j = R;
      m = (L + R) >>> 1;
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        k = $l;
        this.SetCells(k,this.GetRowCount() - 1,this.GetCells(k,m));
        this.SetObjects(k,this.GetRowCount() - 1,this.GetObjects(k,m));
      };
      do {
        while ((this.CompareRowsIndexed(Col,this.GetRowCount() - 1,i) === this.FSortDir) && (i < R)) i += 1;
        while ((this.CompareRowsIndexed(Col,j,this.GetRowCount() - 1) === this.FSortDir) && (j > L)) j -= 1;
        if (i <= j) {
          if (i !== j) {
            if (this.CompareRowsIndexed(Col,i,j) !== 0) {
              var $tmp = this.FOptions.FSorting.FColumns;
              if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortColumns.scAll) {
                this.SwapRows(i,j)}
               else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortColumns.scNormal) {
                this.SwapNormalCells(i,j)}
               else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortColumns.scSingle) this.SwapCells(Col,i,j);
            };
          };
          i += 1;
          j -= 1;
        };
      } while (!(i > j));
      if (L < j) this.QuickSortRowsIndexed(Col,L,j);
      if (i < R) this.QuickSortRowsIndexed(Col,i,R);
    };
    this.SortGroupedInt = function (Indexed) {
      var i = 0;
      var rr = 0;
      var r1 = 0;
      var r2 = 0;
      var span = 0;
      var idx = 0;
      var nodeClosed = [];
      var fltr = false;
      nodeClosed = rtl.arraySetLength(nodeClosed,false,0);
      fltr = false;
      i = this.FFixedRows;
      while (i <= (this.FRowCount - this.FFixedFooterRows)) {
        rr = this.DisplToRealRow(i);
        if (this.IsNode(rr)) {
          idx = rtl.length(nodeClosed);
          nodeClosed = rtl.arraySetLength(nodeClosed,false,idx + 1);
          if (this.GetNodeState(rr) === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsClosed) {
            nodeClosed[idx] = true}
           else nodeClosed[idx] = false;
        };
        i += 1;
      };
      this.OpenAllNodes();
      if (this.FFilterApplied) {
        this.RemoveFilter();
        fltr = true;
      };
      this.BeginUpdate();
      try {
        this.SetRowCount(this.GetRowCount() + 1);
        i = this.FFixedRows;
        while (i <= (this.FRowCount - this.FFixedFooterRows - 3)) {
          rr = this.DisplToRealRow(i);
          if (this.IsNode(rr)) {
            span = this.GetNodeSpan(rr);
            r1 = rr + 1;
            r2 = rr + span;
            if ((r2 - r1) >= 1) {
              if (Indexed) {
                this.QuickSortRowsIndexed(0,r1,r2)}
               else this.QuickSortRows(this.FSortColumn,r1,r2);
            };
            i = i + span;
          } else i += 1;
        };
        this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,this.GetRowCount() - 1,this.GetColumnCount() - 1,this.GetRowCount() - 1)));
        this.SetRowCount(this.GetRowCount() - 1);
        i = this.FFixedRows;
        idx = 0;
        while (i <= (this.FRowCount - this.FFixedFooterRows)) {
          rr = this.DisplToRealRow(i);
          if (this.IsNode(rr)) {
            if (nodeClosed[idx]) this.CloseNode(rr);
            idx += 1;
          };
          i += 1;
        };
      } finally {
        if (fltr) this.ApplyFilter();
        this.EndUpdate();
      };
      this.UpdateGridCells(false);
    };
    this.MatchFilter = function (ARow) {
      var Result = false;
      var i = 0;
      var s = "";
      var temp = false;
      Result = true;
      for (var $l = 1, $end = this.FFilter.GetCount(); $l <= $end; $l++) {
        i = $l;
        var $with = this.FFilter.GetItem$1(i - 1);
        var $tmp = this.FFilter.GetItem$1(i - 1).FData;
        if ($tmp === $mod.TTMSFNCGridFilterCells.fcVirtual) {
          s = this.GetCells($with.FColumn,ARow)}
         else if ($tmp === $mod.TTMSFNCGridFilterCells.fcNormal) {
          s = this.GetCells($with.FColumn,ARow);
          this.DoGetCellData($with.FColumn,ARow,{get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }});
        } else if ($tmp === $mod.TTMSFNCGridFilterCells.fcStripHTML) {
          s = this.GetStrippedCells($with.FColumn,ARow)}
         else if ($tmp === $mod.TTMSFNCGridFilterCells.fcRow) s = this.GetRowText(ARow);
        s = pas.SysUtils.Trim(s);
        if (this.FFilter.GetItem$1(i - 1).FData === $mod.TTMSFNCGridFilterCells.fcRow) {
          temp = pas.System.Pos(pas.SysUtils.UpperCase($with.FCondition),pas.SysUtils.UpperCase(s)) > 0;
        } else {
          if ($with.FPrefix !== "") if (pas.System.Pos($with.FPrefix,s) === 1) pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,this.FFilter.GetItem$1(i - 1).FPrefix.length);
          if ($with.FSuffix !== "") if (pas.System.Pos($with.FSuffix,s) === ((1 + s.length) - $with.FSuffix.length)) pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},(1 + s.length) - $with.FSuffix.length,s.length);
          try {
            temp = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx($with.FCondition,s,$with.FCaseSensitive);
          } catch ($e) {
            temp = false;
          };
        };
        var $tmp1 = this.FFilter.GetItem$1(i - 1).FOperation;
        if ($tmp1 === $mod.TTMSFNCGridFilterOperation.foSHORT) {
          Result = temp;
          if (!Result) break;
        } else if ($tmp1 === $mod.TTMSFNCGridFilterOperation.foNONE) {
          Result = temp}
         else if ($tmp1 === $mod.TTMSFNCGridFilterOperation.foAND) {
          Result = Result && temp}
         else if ($tmp1 === $mod.TTMSFNCGridFilterOperation.foOR) {
          Result = Result || temp}
         else if ($tmp1 === $mod.TTMSFNCGridFilterOperation.foXOR) Result = Result ^ temp;
      };
      return Result;
    };
    this.MatchCell = function (Col, Row) {
      var Result = false;
      var res1 = false;
      var res2 = false;
      var ct = "";
      var cs = "";
      var ic = 0;
      res2 = true;
      if ($mod.TTMSFNCGridFindParameters.fnIncludeHiddenRows in this.FFindParams) {
        cs = this.GetAllCells(Col,Row)}
       else cs = this.GetCells(Col,Row);
      if (!($mod.TTMSFNCGridFindParameters.fnMatchCase in this.FFindParams)) {
        ct = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(cs)}
       else ct = cs;
      if ($mod.TTMSFNCGridFindParameters.fnIgnoreHTMLTags in this.FFindParams) ct = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(ct);
      if (this.FSearchCache === '""') {
        Result = ct === "";
        return Result;
      };
      ic = pas.System.Pos(this.FSearchCache,ct);
      if ($mod.TTMSFNCGridFindParameters.fnMatchStart in this.FFindParams) {
        res1 = ic === 1}
       else res1 = ic > 0;
      if ($mod.TTMSFNCGridFindParameters.fnMatchFull in this.FFindParams) res2 = this.FSearchCache === ct;
      if ($mod.TTMSFNCGridFindParameters.fnMatchRegular in this.FFindParams) {
        Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx(this.FSearchCache,ct,$mod.TTMSFNCGridFindParameters.fnMatchCase in this.FFindParams);
      } else Result = res1 && res2;
      return Result;
    };
    this.MaxCharsInCol = function (ACol) {
      var Result = 0;
      var i = 0;
      var k = 0;
      var rc = 0;
      var s = "";
      var substr = "";
      Result = 0;
      rc = ACol;
      for (var $l = 0, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
        i = $l;
        s = this.DoSaveCell(rc,i);
        do {
          substr = pas["WEBLib.TMSFNCGridDataUtil"].GetNextLine({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},true);
          k = substr.length;
          if (k > Result) Result = k;
        } while (!(s === ""));
      };
      return Result;
    };
    this.InputFromCSVStream = function (AStream, Encoding, insertmode, MaxRows) {
      var buffer = "";
      var celltext = "";
      var s = 0;
      var z = 0;
      var strtCol = 0;
      var strtRow = 0;
      var c1 = 0;
      var c2 = 0;
      var cm = 0;
      var OldDelimiter = "\x00";
      var delimiterpos = 0;
      var quotepos = 0;
      var lr = null;
      var NewRows = 0;
      var sl = null;
      var sh = 0;
      var hasquote = false;
      strtCol = this.FIOOffset.x;
      strtRow = this.FIOOffset.y;
      sl = $mod.TTMSFNCGridFileStringList.$create("Create$1");
      pas.Classes.TStringsHelper.LoadFromStream$1.call(sl,AStream,Encoding);
      if (sl.GetEOF()) {
        throw pas.SysUtils.Exception.$create("Create$1",["File is empty"]);
        sl = rtl.freeLoc(sl);
        return;
      };
      z = strtRow;
      lr = pas.Classes.TStringList.$create("Create$1");
      if (insertmode) z = this.GetRowCount();
      OldDelimiter = this.FOptions.FIO.FDelimiter;
      this.BeginUpdate();
      if (this.FOptions.FIO.FDelimiter === "\x00") {
        celltext = "";
        buffer = "";
        sl.ReadLn({get: function () {
            return buffer;
          }, set: function (v) {
            buffer = v;
          }});
        if (!sl.GetEOF()) sl.ReadLn({get: function () {
            return celltext;
          }, set: function (v) {
            celltext = v;
          }});
        sl.Reset();
        cm = 0;
        for (s = 1; s <= 10; s++) {
          c1 = pas["WEBLib.TMSFNCGridDataUtil"].NumSingleChar($mod.CSVSeparators[s - 1],buffer);
          c2 = pas["WEBLib.TMSFNCGridDataUtil"].NumSingleChar($mod.CSVSeparators[s - 1],celltext);
          if ((c1 === c2) && (c1 > cm)) {
            this.FOptions.FIO.FDelimiter = $mod.CSVSeparators[s - 1];
            cm = c1;
          };
        };
        if (cm === 0) for (s = 1; s <= 10; s++) {
          c1 = pas["WEBLib.TMSFNCGridDataUtil"].NumChar($mod.CSVSeparators[s - 1],buffer);
          c2 = pas["WEBLib.TMSFNCGridDataUtil"].NumChar($mod.CSVSeparators[s - 1],celltext);
          if ((c1 === c2) && (c1 > cm)) {
            this.FOptions.FIO.FDelimiter = $mod.CSVSeparators[s - 1];
            cm = c1;
          };
        };
        if (cm === 0) for (s = 1; s <= 10; s++) {
          c1 = pas["WEBLib.TMSFNCGridDataUtil"].NumChar($mod.CSVSeparators[s - 1],buffer);
          c2 = pas["WEBLib.TMSFNCGridDataUtil"].NumChar($mod.CSVSeparators[s - 1],celltext);
          if ((c1 > cm) || (c2 > cm)) {
            this.FOptions.FIO.FDelimiter = $mod.CSVSeparators[s - 1];
            cm = Math.max(c1,c2);
          };
        };
      };
      sl.Reset();
      NewRows = 0;
      sh = 0;
      while (!sl.GetEOF() && ((MaxRows <= 0) || (NewRows < MaxRows))) {
        sl.ReadLn({get: function () {
            return buffer;
          }, set: function (v) {
            buffer = v;
          }});
        NewRows += 1;
        s = strtCol;
        if (z >= (this.GetRowCount() - this.FFixedFooterRows)) {
          this.SetRowCount(z + 1000);
        };
        delimiterpos = -1;
        while (pas["WEBLib.TMSFNCGridDataUtil"].VarCharPos(this.FOptions.FIO.FDelimiter,buffer,{get: function () {
            return delimiterpos;
          }, set: function (v) {
            delimiterpos = v;
          }}) > 0) {
          hasquote = buffer.charAt(0) === '"';
          if (hasquote) {
            pas.System.Delete({get: function () {
                return buffer;
              }, set: function (v) {
                buffer = v;
              }},1,1);
            quotepos = -1;
            if (pas["WEBLib.TMSFNCGridDataUtil"].SinglePos('"',buffer,{get: function () {
                return quotepos;
              }, set: function (v) {
                quotepos = v;
              }}) > 0) {
              celltext = pas.System.Copy(buffer,1,quotepos - 1);
              celltext = pas["WEBLib.TMSFNCGridDataUtil"].DoubleToSingleChar('"',celltext);
              pas.System.Delete({get: function () {
                  return buffer;
                }, set: function (v) {
                  buffer = v;
                }},1,quotepos);
            } else celltext = "";
            pas["WEBLib.TMSFNCGridDataUtil"].VarCharPos(this.FOptions.FIO.FDelimiter,buffer,{get: function () {
                return delimiterpos;
              }, set: function (v) {
                delimiterpos = v;
              }});
          } else {
            celltext = pas.System.Copy(buffer,1,delimiterpos - 1);
          };
          pas["WEBLib.TMSFNCGridDataUtil"].CSVToLineFeeds({get: function () {
              return celltext;
            }, set: function (v) {
              celltext = v;
            }});
          this.SetCells(s,z,celltext);
          pas.System.Delete({get: function () {
              return buffer;
            }, set: function (v) {
              buffer = v;
            }},1,delimiterpos);
          s += 1;
          if (s >= (this.GetColumnCount() + sh)) {
            this.SetColumnCount(s - sh);
          };
        };
        if (buffer.length > 0) {
          hasquote = buffer.charAt(0) === '"';
          if (hasquote) pas.System.Delete({get: function () {
              return buffer;
            }, set: function (v) {
              buffer = v;
            }},1,1);
          if (buffer.length > 0) {
            if (hasquote && (buffer.charAt(buffer.length - 1) === '"')) pas.System.Delete({get: function () {
                return buffer;
              }, set: function (v) {
                buffer = v;
              }},buffer.length,1);
          };
          if (hasquote) {
            celltext = pas["WEBLib.TMSFNCGridDataUtil"].DoubleToSingleChar('"',buffer)}
           else celltext = buffer;
          pas["WEBLib.TMSFNCGridDataUtil"].CSVToLineFeeds({get: function () {
              return celltext;
            }, set: function (v) {
              celltext = v;
            }});
          this.SetCells(s,z,celltext);
          s += 1;
          if (s > (this.GetColumnCount() + sh)) {
            this.SetColumnCount(s - sh);
          };
        };
        z += 1;
        this.DoIOProgress(z,sl.GetCount());
      };
      sl = rtl.freeLoc(sl);
      this.SetRowCount(z + this.FFixedFooterRows);
      lr = rtl.freeLoc(lr);
      this.FOptions.FIO.FDelimiter = OldDelimiter;
      this.DoCellsChanged($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,0,this.GetColumnCount() - 1,this.GetRowCount() - 1)));
      this.EndUpdate();
    };
    this.InputFromCSV = function (FileName, Encoding, insertmode, MaxRows) {
      var $Self = this;
      var ms = null;
      function InternalInputFromCSV() {
        ms.SetPosition(0);
        $Self.InputFromCSVStream(ms,Encoding,insertmode,MaxRows);
      };
      ms = pas.Classes.TMemoryStream.$create("Create");
      try {
        ms.LoadFromFile(FileName,function () {
          InternalInputFromCSV();
          ms = rtl.freeLoc(ms);
        },null);
      } finally {
      };
    };
    this.OutputToCSVStream = function (AStream, Encoding) {
      var z = 0;
      var s = 0;
      var n = 0;
      var rs = 0;
      var CellText = "";
      var LineText = "";
      var Delim = "\x00";
      var dblquotes = false;
      var sl = null;
      if (this.FSaveHiddenCells) {
        n = this.GetHiddenColCount()}
       else n = 0;
      if (this.FOptions.FIO.FDelimiter === "\x00") {
        Delim = ","}
       else Delim = this.FOptions.FIO.FDelimiter;
      sl = pas.Classes.TStringList.$create("Create$1");
      sl.SetLineBreak("\r\n");
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,this.FIOOffset.y);
      for (var $l = this.FIOOffset.y, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
        z = $l;
        this.ExportNotification($mod.TTMSFNCGridExportState.esExportNextRow,z);
        LineText = "";
        for (var $l1 = this.FIOOffset.x, $end1 = (this.GetColumnCount() - 1) + n; $l1 <= $end1; $l1++) {
          s = $l1;
          if (s > this.FIOOffset.x) LineText = LineText + Delim;
          rs = s;
          CellText = this.DoSaveCell(rs,z);
          CellText = pas["WEBLib.TMSFNCGridDataUtil"].CSVQuotes(CellText);
          dblquotes = false;
          if (this.FOptions.FIO.FAlwaysQuotes || ((pas.System.Pos(Delim,CellText) === 0) && (pas.System.Pos('"',CellText) > 0))) {
            CellText = '"' + CellText + '"';
            dblquotes = true;
          };
          if (CellText === "") {
            if (this.FOptions.FIO.FQuoteEmptyCells) CellText = '""';
          };
          if ((pas.System.Pos(Delim,CellText) > 0) || (pas["WEBLib.TMSFNCGridDataUtil"].LinesInText(CellText,true) > 1)) {
            if (!dblquotes) {
              pas["WEBLib.TMSFNCGridDataUtil"].LineFeedsToCSV({get: function () {
                  return CellText;
                }, set: function (v) {
                  CellText = v;
                }})}
             else pas["WEBLib.TMSFNCGridDataUtil"].LineFeedsToCSVNQ({get: function () {
                return CellText;
              }, set: function (v) {
                CellText = v;
              }});
          };
          LineText = LineText + CellText;
        };
        sl.Add(LineText);
        this.DoIOProgress(z,this.GetRowCount() - 1);
      };
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
      pas.Classes.TStringsHelper.SaveToStream.call(sl,AStream);
      AStream.SetPosition(0);
      sl = rtl.freeLoc(sl);
    };
    this.FindInternal = function (StartC, s, FindParams) {
      var Result = pas.Types.TPoint.$new();
      var MaxCol = 0;
      var MinCol = 0;
      var MaxRow = 0;
      var MinRow = 0;
      var i = 0;
      var j = 0;
      Result.x = -1;
      Result.y = -1;
      this.FFindParams = rtl.refSet(FindParams);
      this.FFindBusy = true;
      if (!($mod.TTMSFNCGridFindParameters.fnMatchCase in FindParams)) {
        this.FSearchCache = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(s)}
       else this.FSearchCache = s;
      if ($mod.TTMSFNCGridFindParameters.fnIncludeFixed in FindParams) {
        MaxCol = this.GetColumnCount() - 1;
        MaxRow = this.GetRowCount() - 1;
        MinCol = 0;
        MinRow = 0;
      } else {
        MaxCol = this.GetColumnCount() - 1;
        MaxRow = this.GetRowCount() - 1;
        MinCol = this.FIOOffset.x;
        MinRow = this.FIOOffset.y;
      };
      if ($mod.TTMSFNCGridFindParameters.fnSelectedCells in FindParams) {
        MaxCol = this.GetSelection().EndCol;
        MaxRow = this.GetSelection().EndRow;
        MinCol = this.GetSelection().StartCol;
        MinRow = this.GetSelection().StartRow;
      };
      if ($mod.TTMSFNCGridFindParameters.fnIncludeHiddenColumns in FindParams) MaxCol = MaxCol + this.GetHiddenColCount();
      if ($mod.TTMSFNCGridFindParameters.fnIncludeHiddenRows in FindParams) MaxRow = MaxRow + this.GetHiddenRowCount();
      if ((StartC.x === -1) && (StartC.y === -1)) {
        if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
          StartC.x = MaxCol;
          StartC.y = MaxRow;
        } else {
          StartC.x = MinCol;
          StartC.y = MinRow;
        };
      } else {
        if ($mod.TTMSFNCGridFindParameters.fnDirectionLeftRight in FindParams) {
          if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
            if (StartC.x >= MinCol) {
              StartC.x -= 1}
             else if (StartC.y >= MinRow) {
              StartC.y -= 1}
             else {
              StartC.x = MaxCol;
              StartC.y = MaxRow;
            };
          } else {
            if (StartC.x <= MaxCol) {
              StartC.x += 1}
             else if (StartC.y <= MaxRow) {
              StartC.y += 1}
             else {
              StartC.x = MinCol;
              StartC.y = MinRow;
            };
          };
        } else {
          if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
            if (StartC.y >= MinRow) {
              StartC.y -= 1}
             else if (StartC.x >= MinCol) {
              StartC.x -= 1}
             else {
              StartC.x = MaxCol;
              StartC.y = MaxRow;
            };
          } else {
            if (StartC.y <= MaxRow) {
              StartC.y += 1}
             else if (StartC.x <= MaxCol) {
              StartC.x += 1}
             else {
              StartC.x = MinCol;
              StartC.y = MinRow;
            };
          };
        };
      };
      i = StartC.x;
      j = StartC.y;
      if ($mod.TTMSFNCGridFindParameters.fnFindInCurrentRow in FindParams) {
        j = this.GetSelection().StartRow;
        MaxRow = this.GetSelection().StartRow;
        MinRow = this.GetSelection().StartRow;
      };
      if ($mod.TTMSFNCGridFindParameters.fnFindInPresetRow in FindParams) {
        j = this.FFindRow;
        MaxRow = this.FFindRow;
        MinRow = this.FFindRow;
      };
      if ($mod.TTMSFNCGridFindParameters.fnFindInCurrentCol in FindParams) {
        i = this.GetSelection().StartCol;
        MaxCol = this.GetSelection().StartCol;
        MinCol = this.GetSelection().StartCol;
      };
      if ($mod.TTMSFNCGridFindParameters.fnFindInPresetCol in FindParams) {
        i = this.FFindCol;
        MaxCol = this.FFindCol;
        MinCol = this.FFindCol;
      };
      StartC.x = i;
      StartC.y = j;
      if ($mod.TTMSFNCGridFindParameters.fnDirectionLeftRight in FindParams) {
        while ((j <= MaxRow) && (j >= MinRow)) {
          while ((i <= MaxCol) && (i >= MinCol)) {
            if (this.MatchCell(i,j)) {
              this.FSearchCell.x = i;
              this.FSearchCell.y = j;
              Result.$assign(this.FSearchCell);
              return Result;
            };
            if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
              i -= 1}
             else i += 1;
          };
          if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
            i = MaxCol}
           else i = MinCol;
          if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
            j -= 1}
           else j += 1;
        };
      } else {
        while ((i <= MaxCol) && (i >= MinCol)) {
          while ((j <= MaxRow) && (j >= MinRow)) {
            if (this.MatchCell(i,j)) {
              this.FSearchCell.x = i;
              this.FSearchCell.y = j;
              Result.$assign(this.FSearchCell);
              return Result;
            };
            if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
              j -= 1}
             else j += 1;
          };
          if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
            j = MaxRow}
           else j = MinRow;
          if ($mod.TTMSFNCGridFindParameters.fnBackward in FindParams) {
            i -= 1}
           else i += 1;
        };
      };
      this.FFindBusy = false;
      return Result;
    };
    this.CellNameIndex = function (AName) {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.UpdateGridCells = function (AScrollOnly) {
    };
    this.ExportNotification = function (AState, ARow) {
      if (AState === $mod.TTMSFNCGridExportState.esExportStart) this.FPrevProgress = -1;
    };
    this.ImportNotification = function (AState, ARow) {
      if (AState === $mod.TTMSFNCGridImportState.isImportStart) this.FPrevProgress = -1;
    };
    this.DoRowCountChanged = function () {
    };
    this.DoColumnCountChanged = function () {
    };
    this.DoIOProgress = function (CurrentRow, TotalRows) {
      var np = 0;
      if ((this.FOnIOProgress != null) && (TotalRows > 0)) {
        np = Math.round((CurrentRow / TotalRows) * 100);
        if (np !== this.FPrevProgress) {
          this.FOnIOProgress(this,CurrentRow,TotalRows,np);
          this.FPrevProgress = np;
        };
      };
    };
    this.DoSortFormat = function (Col, SortFormat, Prefix, Suffix) {
      var c = 0;
      SortFormat.set($mod.TTMSFNCGridSortFormat.ssAutomatic);
      Prefix.set("");
      Suffix.set("");
      c = this.DisplToRealColumn(Col);
      if (this.FUseColumns && (c < this.FColumns.GetCount())) {
        SortFormat.set(this.FColumns.GetItem$1(c).FSortFormat);
        Suffix.set(this.FColumns.GetItem$1(c).FSortSuffix);
        Prefix.set(this.FColumns.GetItem$1(c).FSortPrefix);
      };
      if (this.FOnSortFormat != null) this.FOnSortFormat(this,Col,SortFormat,Prefix,Suffix);
    };
    this.DoCustomCompare = function (Value1, Value2, res) {
      if (this.FOnCustomCompare != null) this.FOnCustomCompare(this,Value1,Value2,res);
    };
    this.DoRawCompare = function (Col, Row1, Row2, res) {
      if (this.FOnRawCompare != null) this.FOnRawCompare(this,Col,Row1,Row2,res);
    };
    this.DoClipboardBeforePasteCell = function (Col, Row, AValue, Allow) {
      if (this.FOnClipboardBeforePasteCell != null) this.FOnClipboardBeforePasteCell(this,Col,Row,AValue,Allow);
    };
    this.DoClipboardAfterPasteCell = function (Col, Row, AValue) {
      if (this.FOnClipboardAfterPasteCell != null) this.FOnClipboardAfterPasteCell(this,Col,Row,AValue);
    };
    this.DoNeedFilterDropDown = function (Col, Row, Allow) {
      if (this.FOnNeedFilterDropDown != null) this.FOnNeedFilterDropDown(this,Col,Row,Allow);
    };
    this.DoNeedFilterDropDownData = function (Col, Row, Values) {
      if (this.FOnNeedFilterDropDownData != null) this.FOnNeedFilterDropDownData(this,Col,Row,Values);
    };
    this.DoCellsChanged = function (Cells) {
      if (this.FOnCellsChanged != null) this.FOnCellsChanged(this,$mod.TTMSFNCGridCellRecRange.$clone(Cells));
    };
    this.DoClipboardPaste = function (Cells) {
      if (this.FOnClipboardPaste != null) this.FOnClipboardPaste(this,$mod.TTMSFNCGridCellRecRange.$clone(Cells));
    };
    this.DoSaveCell = function (Col, Row) {
      var Result = "";
      Result = this.GetCells(Col,Row);
      if (this.FOptions.FIO.FSaveVirtualCellData) this.DoGetCellData(Col,Row,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      if (this.FOnSaveCell != null) this.FOnSaveCell(this,Col,Row,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DoLoadCell = function (Col, Row, Value) {
      if (this.FOnLoadCell != null) this.FOnLoadCell(this,Col,Row,Value);
      this.SetCells(Col,Row,Value.get());
    };
    this.DoFilterSelect = function (Col, Condition) {
      if (this.FOnFilterSelect != null) this.FOnFilterSelect(this,Col,Condition);
    };
    this.DoAfterApplyFilter = function (Col, Condition, UpdateCalculations) {
      if (this.FOnAfterApplyFilter != null) this.FOnAfterApplyFilter(this,Col,Condition,UpdateCalculations);
    };
    this.SetHorizontalScrollBarVisible = function (Value) {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.SetHorizontalScrollBarVisible.apply(this,arguments);
      if (this.FUpdateCount$1 === 0) this.FOptions.FScrollBar.SetHorizontalScrollBarVisible(this.FHorizontalScrollBarVisible);
    };
    this.SetVerticalScrollBarVisible = function (Value) {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.SetVerticalScrollBarVisible.apply(this,arguments);
      if (this.FUpdateCount$1 === 0) this.FOptions.FScrollBar.SetVerticalScrollBarVisible(this.FVerticalScrollBarVisible);
    };
    this.RemoveCellControl = function (Col, Row, AClass) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FControl != null) && AClass.isPrototypeOf(cp.FControl)) {
        cp.FreeControl();
        this.UpdateGridCells(false);
      };
    };
    this.IsCellControl = function (Col, Row, AClass) {
      var Result = false;
      var cp = null;
      var c = 0;
      var r = 0;
      c = this.DisplToRealColumn(Col);
      r = this.DisplToRealRow(Row);
      cp = this.GetIntObjects(c,r);
      Result = (cp != null) && (cp.FControl != null) && AClass.isPrototypeOf(cp.FControl);
      return Result;
    };
    this.IsIgnoredColumn = function (Col) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
    };
    this.Loaded = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Loaded.call(this);
      this.InitOriginalColumnSizes();
      this.FIOOffset.$assign(pas.Types.Point(this.FFixedColumns,this.FFixedRows));
      this.SetColumnOrder();
    };
    this.GetDefaultFont = function (Col, Row) {
      var Result = null;
      var gc = null;
      if (this.IsFixed(Col,Row)) {
        gc = this.GetDefaultFixedLayout()}
       else gc = this.GetDefaultNormalLayout();
      if (gc != null) {
        Result = gc.FFont}
       else Result = this.FDefaultFont;
      return Result;
    };
    this.GetDefaultFixedLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultNormalLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultGroupLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultSummaryLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultSelectedLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultFocusedLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultFixedSelectedLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultBandLayout = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultSortFill = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultIndexedSortFill = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultSortStroke = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultIndexedSortStroke = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultSortFont = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetDefaultIndexedSortFont = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.SetFonts = function (ASetType) {
      var I = 0;
      var J = 0;
      this.BeginUpdate();
      this.FGlobalFont.ApplyChange(this.FDefaultFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FDefaultLayout.FFont,ASetType);
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FGlobalFont.ApplyChange(this.FColumns.GetItem$1(I).FFont,ASetType);
        this.FGlobalFont.ApplyChange(this.FColumns.GetItem$1(I).FFixedFont,ASetType);
        for (var $l1 = 0, $end1 = this.GetRowCount() - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          this.FGlobalFont.ApplyChange(this.GetDefaultBandLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultNormalLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultFixedLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultSelectedLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultFixedSelectedLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultFocusedLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultGroupLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultSummaryLayout().FFont,ASetType);
          this.FGlobalFont.ApplyChange(this.GetDefaultBandLayout().FFont,ASetType);
        };
      };
      this.EndUpdate();
    };
    this.DoOptionsChange = function (Sender) {
      if ((this.FUpdateCount$1 > 0) || this.FBlockUpdate || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.SaveScrollPosition();
      this.BeginUpdate();
      this.SetHorizontalScrollBarVisible(this.FOptions.FScrollBar.FHorizontalScrollBarVisible);
      this.SetVerticalScrollBarVisible(this.FOptions.FScrollBar.FVerticalScrollBarVisible);
      this.EndUpdate();
      this.RestoreScrollPosition();
    };
    this.DoGetCellReadOnly = function (ACol, ARow, AReadOnly) {
      var cp = null;
      cp = this.GetCellProps(ACol,ARow);
      if (cp != null) {
        AReadOnly.set(cp.FReadOnly)}
       else {
        if (this.FUseColumns && (ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) {
          ACol = this.DisplToRealColumn(ACol);
          AReadOnly.set(this.FColumns.GetItem$1(ACol).FReadOnly);
        };
      };
    };
    this.DoGetCellIsDataCheckBox = function (ACol, ARow) {
      var Result = false;
      var cp = null;
      var c = 0;
      var r = 0;
      c = this.DisplToRealColumn(ACol);
      r = this.DisplToRealRow(ARow);
      Result = false;
      cp = this.GetCellProps(c,r);
      if (this.FUseColumns && !(this.GetIntObjects(c,r) != null)) {
        if (c < this.FColumns.GetCount()) Result = (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctCheckBox) || (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctRadioButton);
      } else {
        if (cp != null) Result = $mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl);
      };
      return Result;
    };
    this.DoFixedCellCheckBoxClick = function (ACol, ARow, ACell) {
    };
    this.DoFixedCellSpinBoxChange = function (ACol, ARow, ACell) {
    };
    this.DoFixedCellButtonClick = function (ACol, ARow, ACell) {
    };
    this.DoFixedCellDropDownButtonClick = function (ACol, ARow, ACell) {
    };
    this.DoFixedCellBitmapClick = function (ACol, ARow, ACell) {
    };
    this.DoCellRightClick = function (ACol, ARow) {
    };
    this.DoFixedCellRightClick = function (ACol, ARow) {
    };
    this.DoCellClick = function (ACol, ARow) {
      var rr = 0;
      var i = 0;
      var ns = 0;
      if ((this.FGroupColumn !== -1) && this.FOptions.FGrouping.FAutoSelectGroup) {
        rr = this.DisplToRealRow(ARow);
        if (this.IsNode(rr)) {
          ns = this.GetNodeSpan(rr);
          if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
            for (var $l = rr, $end = rr + ns; $l <= $end; $l++) {
              i = $l;
              this.SetRowSelect(i,true);
            };
          } else if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smCellRange) this.SetSelection(this.CellRange(this.FFixedColumns,ARow,this.GetColumnCount() - 1 - this.FFixedRightColumns,ARow + ns));
        };
      };
    };
    this.DoFixedCellClick = function (Shift, ACol, ARow) {
    };
    this.DoCellDblClick = function (ACol, ARow) {
    };
    this.DoFixedCellDblClick = function (ACol, ARow) {
    };
    this.DoCellCheckBoxClick = function (ACol, ARow, ACell) {
      var cp = null;
      var i = 0;
      var rr = 0;
      var ns = 0;
      var c = 0;
      var r = 0;
      c = this.DisplToRealColumn(ACol);
      r = this.DisplToRealRow(ARow);
      cp = this.GetIntObjects(c,r);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellCheckBox.isPrototypeOf(cp.FControl)) {
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked = rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked;
        if (rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FHeader) {
          for (var $l = ARow + 1, $end = this.GetRowCount() - 1 - this.FFixedFooterRows; $l <= $end; $l++) {
            i = $l;
            if (this.IsCheckBox(ACol,i)) {
              this.SetCheckBoxState(ACol,i,rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked)}
             else break;
          };
        };
        this.UpdateGridCells(false);
      };
      if (this.FOptions.FGrouping.FAutoCheckGroup) {
        rr = this.DisplToRealRow(ARow);
        if (this.IsNode(rr)) {
          ns = this.GetNodeSpan(rr);
          for (var $l1 = rr, $end1 = rr + ns; $l1 <= $end1; $l1++) {
            i = $l1;
            this.SetCheckBoxState(ACol,i,rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked);
          };
          this.UpdateGridCells(false);
        };
      };
      if (this.FUseColumns && !(cp != null)) {
        c = this.DisplToRealColumn(ACol);
        if (c < this.FColumns.GetCount()) {
          if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(ACell) && (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctCheckBox)) {
            if (rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked) {
              this.SetCells(ACol,ARow,this.FCheckTrue)}
             else this.SetCells(ACol,ARow,this.FCheckFalse);
          };
        };
      } else {
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl)) {
          if (rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked) {
            this.SetCells(ACol,ARow,this.FCheckTrue)}
           else this.SetCells(ACol,ARow,this.FCheckFalse);
        };
      };
    };
    this.DoCellRadioButtonClick = function (ACol, ARow, ACell) {
      var cp = null;
      var cpt = null;
      var r = 0;
      var c = 0;
      var rr = 0;
      c = this.DisplToRealColumn(ACol);
      r = this.DisplToRealRow(ARow);
      cp = this.GetIntObjects(c,r);
      if (this.FUseColumns && !(cp != null)) {
        for (var $l = this.FFixedRows, $end = this.GetRowCount() - 1 - this.FFixedFooterRows; $l <= $end; $l++) {
          rr = $l;
          this.SetCells(ACol,rr,this.FCheckFalse);
        };
        this.SetCells(ACol,ARow,this.FCheckTrue);
      } else {
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellRadioButton.isPrototypeOf(cp.FControl)) {
          for (var $l1 = 0, $end1 = this.GetRowCount() - 1; $l1 <= $end1; $l1++) {
            rr = $l1;
            cpt = this.GetIntObjects(ACol,rr);
            if ((cpt != null) && (cpt.FControl != null) && $mod.TTMSFNCGridCellRadioButton.isPrototypeOf(cpt.FControl) && (cpt !== cp)) {
              if (rtl.as(cpt.FControl,$mod.TTMSFNCGridCellRadioButton).FIndex === rtl.as(cp.FControl,$mod.TTMSFNCGridCellRadioButton).FIndex) rtl.as(cpt.FControl,$mod.TTMSFNCGridCellRadioButton).FChecked = false;
            };
          };
          rtl.as(cp.FControl,$mod.TTMSFNCGridCellRadioButton).FChecked = rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FChecked;
          this.UpdateGridCells(false);
        };
      };
    };
    this.DoCellButtonClick = function (ACol, ARow, ACell) {
    };
    this.DoCellBitmapClick = function (ACol, ARow, ACell) {
    };
    this.DoCellCommentClick = function (ACol, ARow, ACell) {
    };
    this.DoCellSortClick = function (Shift, ACol, ARow, Direction, ACell) {
      if (this.FGroupColumn !== -1) {
        var $tmp = this.FOptions.FSorting.FMode;
        if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmNormal) {
          this.SortGrouped(ACol,Direction)}
         else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmIndexed) this.SortGroupedIndexed();
      } else {
        var $tmp1 = this.FOptions.FSorting.FMode;
        if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmNormal) {
          this.SortData(ACol,Direction)}
         else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmIndexed) this.SortIndexed();
      };
    };
    this.DoCellNodeClick = function (ACol, ARow, ACell) {
      var cn = null;
      var rr = 0;
      rr = this.DisplToRealRow(ARow);
      cn = this.GetNode(rr);
      if (!(cn != null)) return;
      if (cn.FSpan !== -1) {
        if (cn.FState === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsOpen) {
          this.CloseNode(rr)}
         else this.OpenNode(rr);
      };
    };
    this.DoGetCellIsFixed = function (ACol, ARow, ACellFixed) {
      var cp = null;
      cp = this.GetCellProps(ACol,ARow);
      if (cp != null) {
        ACellFixed.set(cp.FFixed)}
       else {
        if (this.FUseColumns && (ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) {
          ACol = this.DisplToRealColumn(ACol);
          ACellFixed.set(this.FColumns.GetItem$1(ACol).FFixed);
        };
      };
    };
    this.DoGetRowIsBand = function (ARow, ARowBand) {
      if (this.FOptions.FBands.FTotalRowCount > 0) {
        ARowBand.set(((ARow - this.FFixedRows) % this.FOptions.FBands.FTotalRowCount) < this.FOptions.FBands.FBandRowCount);
      } else ARowBand.set(pas.System.Odd(ARow));
    };
    this.DoCanInsertRow = function (ARow, Allow) {
    };
    this.DoCanDeleteRow = function (ARow, Allow) {
    };
    this.DoCanAppendRow = function (ARow, Allow) {
    };
    this.DoCanAppendColumn = function (ACol, Allow) {
    };
    this.DoInsertRow = function (ARow) {
    };
    this.DoDeleteRow = function (ARow) {
    };
    this.DoAppendRow = function (ARow) {
    };
    this.DoAppendColumn = function (ACol) {
    };
    this.DoGetCellClass = function (ACol, ARow, CellClassType) {
      var cp = null;
      var c = 0;
      var r = 0;
      if (((ACol >= this.FFixedColumns) || (ACol <= (this.GetColumnCount() - 1 - this.FFixedRightColumns))) && ((ARow < this.FFixedRows) || (ARow > (this.GetRowCount() - this.FFixedFooterRows - 1)))) {
        CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell)}
       else CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
      c = this.DisplToRealColumn(ACol);
      r = this.DisplToRealRow(ARow);
      cp = this.GetCellProps(c,r);
      if (!(this.GetIntObjects(c,r) != null) && this.FUseColumns && (c < this.FColumns.GetCount()) && !this.IsFixed(c,r)) {
        var $tmp = this.FColumns.GetItem$1(c).FColumnType;
        if ($tmp === $mod.TTMSFNCGridColumnType.ctButton) {
          CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell)}
         else if ($tmp === $mod.TTMSFNCGridColumnType.ctCheckBox) {
          CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell)}
         else if ($tmp === $mod.TTMSFNCGridColumnType.ctProgressBar) {
          CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell)}
         else if ($tmp === $mod.TTMSFNCGridColumnType.ctRadioButton) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell);
      };
      if ((cp != null) && (cp.FControl != null)) {
        if ($mod.TTMSFNCGridCellCheckBox.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell);
        if ($mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell);
        if ($mod.TTMSFNCGridCellRadioButton.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell);
        if ($mod.TTMSFNCGridCellBitmapName.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell);
        if ($mod.TTMSFNCGridCellButton.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell);
        if ($mod.TTMSFNCGridCellProgressBar.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell);
        if ($mod.TTMSFNCGridCellBitmap.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell);
        if ($mod.TTMSFNCGridCellNode.isPrototypeOf(cp.FControl)) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell);
      };
      if (cp != null) {
        if ((CellClassType.get() === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell) && (cp.FComment !== "")) CellClassType.set(pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell);
      };
    };
    this.DoGetCellData = function (ACol, ARow, CellString) {
      var cp = null;
      var emptydata = false;
      var i = 0;
      var vp = 0;
      var rowc = 0;
      var rr = 0;
      var c = 0;
      rr = this.DisplToRealRow(ARow);
      c = this.DisplToRealColumn(ACol);
      cp = this.GetCellProps(c,rr);
      emptydata = false;
      if ((cp != null) && (cp.FControl != null)) {
        if ($mod.TTMSFNCGridCellBitmapName.isPrototypeOf(cp.FControl)) {
          emptydata = rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FData;
        };
        if ($mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl)) emptydata = true;
      };
      if (this.FUseColumns && !(this.GetIntObjects(c,rr) != null)) {
        if ((c >= 0) && (c < this.FColumns.GetCount()) && !this.IsFixed(c,rr)) emptydata = (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctCheckBox) || (this.FColumns.GetItem$1(c).FColumnType === $mod.TTMSFNCGridColumnType.ctRadioButton);
      };
      if (!emptydata) {
        CellString.set(this.GetCells(ACol,ARow));
        for (var $l = 0, $end = this.FMarkList.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ($mod.InCellRange(ACol,ARow,$mod.TTMSFNCGridCellRecRange.$clone(this.FMarkList.GetItem$1(i).FCellRange))) {
            var $tmp = this.FMarkList.GetItem$1(i).FMarkType;
            if ($tmp === $mod.TTMSFNCGridMarkType.mtHighlight) {
              CellString.set(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.ApplyHilight(CellString.get(),this.FMarkList.GetItem$1(i).FValue,"hi",this.FMarkList.GetItem$1(i).FCaseSensitive))}
             else if ($tmp === $mod.TTMSFNCGridMarkType.mtError) CellString.set(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.ApplyHilight(CellString.get(),this.FMarkList.GetItem$1(i).FValue,"e",this.FMarkList.GetItem$1(i).FCaseSensitive));
          };
        };
        if (this.FOptions.FURL.FShow && !this.FOptions.FURL.FFull) {
          vp = 0;
          if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("://",CellString.get(),{get: function () {
              return vp;
            }, set: function (v) {
              vp = v;
            }}) > 0) {
            CellString.set(pas.System.Copy(CellString.get(),vp + 3,255))}
           else if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos("mailto:",CellString.get(),{get: function () {
              return vp;
            }, set: function (v) {
              vp = v;
            }}) === 1) CellString.set(pas.System.Copy(CellString.get(),vp + 7,255));
        };
        if (this.FOptions.FGrouping.FShowGroupCount && (this.FGroupColumn !== -1) && (ACol === 1) && this.IsNode(rr)) {
          rowc = this.GetNodeSpan(rr);
          if (this.FOptions.FGrouping.FGroupCountFormat !== "") {
            CellString.set(CellString.get() + " " + pas.SysUtils.Format(this.FOptions.FGrouping.FGroupCountFormat,pas.System.VarRecs(0,rowc)))}
           else CellString.set(CellString.get() + " (" + pas.SysUtils.IntToStr(rowc) + ")");
        };
      } else CellString.set("");
    };
    this.DoGetCellRotation = function (ACol, ARow, Angle) {
      var cp = null;
      var c = 0;
      var r = 0;
      c = this.DisplToRealColumn(ACol);
      r = this.DisplToRealRow(ARow);
      cp = this.GetCellProps(c,r);
      if (cp != null) Angle.set(cp.FAngle);
    };
    this.DoGetCellLayout = function (ACol, ARow, ALayout, ACellState) {
      var cp = null;
      var c = 0;
      var r = 0;
      c = this.DisplToRealColumn(ACol);
      r = this.DisplToRealRow(ARow);
      cp = this.GetCellProps(c,r);
      if (this.FUseColumns && (c >= 0) && (c <= (this.FColumns.GetCount() - 1)) && !(cp != null)) {
        if (this.FColumnProp.FDefaultFont != null) {
          this.FColumnProp.FFontSize = this.FColumnProp.FDefaultFont.FSize;
          this.FColumnProp.FFontStyle = rtl.refSet(this.FColumnProp.FDefaultFont.FStyle);
        };
        if (ACellState === $mod.TTMSFNCGridCellState.csNormal) {
          this.FColumnProp.FColor = this.FColumns.GetItem$1(c).FColor;
          this.FColumnProp.FFontColor = this.FColumns.GetItem$1(c).FFont.FColor;
          this.FColumnProp.FFontName = this.FColumns.GetItem$1(c).FFont.FName;
          this.FColumnProp.FFontStyle = rtl.refSet(this.FColumns.GetItem$1(c).FFont.FStyle);
          this.FColumnProp.FFontSize = this.FColumns.GetItem$1(c).FFont.FSize;
          this.FColumnProp.FBorderColor = this.FColumns.GetItem$1(c).FBorderColor;
          this.FColumnProp.FBorderWidth = this.FColumns.GetItem$1(c).FBorderWidth;
        };
        if ((ACellState === $mod.TTMSFNCGridCellState.csFixed) || (ACellState === $mod.TTMSFNCGridCellState.csFixedSelected)) {
          this.FColumnProp.FFontColor = this.FColumns.GetItem$1(c).FFixedFont.FColor;
          this.FColumnProp.FFontName = this.FColumns.GetItem$1(c).FFixedFont.FName;
          this.FColumnProp.FFontStyle = rtl.refSet(this.FColumns.GetItem$1(c).FFixedFont.FStyle);
          this.FColumnProp.FFontSize = this.FColumns.GetItem$1(c).FFixedFont.FSize;
        };
        this.FColumnProp.FAlignHorz = this.FColumns.GetItem$1(c).FHorzAlignment;
        this.FColumnProp.FAlignVert = this.FColumns.GetItem$1(c).FVertAlignment;
        this.FColumnProp.FReadOnly = this.FColumns.GetItem$1(c).FReadOnly;
        this.FColumnProp.FFixed = this.FColumns.GetItem$1(c).FFixed;
        this.FColumnProp.FWordWrap = this.FColumns.GetItem$1(c).FWordWrap;
        cp = this.FColumnProp;
      };
      if (this.FUseColumns && (c >= 0) && (c <= (this.FColumns.GetCount() - 1))) ALayout.SetWordWrapping(this.FColumns.GetItem$1(c).FWordWrap);
      if (cp != null) {
        if ((cp.FColor !== -1) && (ACellState === $mod.TTMSFNCGridCellState.csNormal)) ALayout.FFill.SetColor(cp.FColor);
        if ((cp.FFontColor !== -1) && (ACellState === $mod.TTMSFNCGridCellState.csNormal)) ALayout.FFont.SetColor(cp.FFontColor);
        if ((cp.FBorderColor !== -1) && (ACellState === $mod.TTMSFNCGridCellState.csNormal)) ALayout.FStroke.SetColor(cp.FBorderColor);
        ALayout.SetTextAlign(cp.FAlignHorz);
        ALayout.SetVerticalTextAlign(cp.FAlignVert);
        ALayout.FFont.SetStyle(rtl.refSet(cp.FFontStyle));
        ALayout.FFont.SetSize(Math.round(cp.FFontSize));
        if (cp.FFontName !== "") ALayout.FFont.SetName(cp.FFontName);
        ALayout.FStroke.SetWidth(cp.FBorderWidth);
        if (!this.FUseColumns) ALayout.SetWordWrapping(cp.FWordWrap);
      };
      if (this.FOptions.FURL.FShow) {
        if (pas["WEBLib.TMSFNCGridDataUtil"].IsURL(this.GetCells(c,r))) {
          ALayout.FFont.SetColor(this.FOptions.FURL.FColor);
          if (this.FOptions.FURL.FUnderline) ALayout.FFont.SetStyle(rtl.unionSet(ALayout.FFont.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
        };
      };
    };
    this.DoGetCellProperties = function (ACol, ARow, Cell) {
      var cp = null;
      var realc = 0;
      var realr = 0;
      var allow = false;
      var evnt = null;
      var v = 0;
      realc = this.DisplToRealColumn(ACol);
      realr = this.DisplToRealRow(ARow);
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        if ((cp != null) && $mod.TTMSFNCGridCellButton.isPrototypeOf(cp.FControl)) {
          rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetControlEnabled(!this.IsReadOnly(realc,realr));
          rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetButtonText(rtl.as(cp.FControl,$mod.TTMSFNCGridCellButton).FText);
          rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetButtonWidth(rtl.as(cp.FControl,$mod.TTMSFNCGridCellButton).FWidth);
          rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetButtonHeight(rtl.as(cp.FControl,$mod.TTMSFNCGridCellButton).FHeight);
        };
      };
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        if (this.FUseColumns && !(this.GetIntObjects(realc,realr) != null)) {
          if (realc < this.FColumns.GetCount()) {
            if (this.FColumns.GetItem$1(realc).FColumnType === $mod.TTMSFNCGridColumnType.ctRadioButton) {
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetControlEnabled(!this.IsReadOnly(realc,realr));
              evnt = rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged;
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged = null;
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetChecked(this.GetCells(ACol,ARow) === this.FCheckTrue);
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged = evnt;
            };
          };
        } else {
          if ((cp != null) && $mod.TTMSFNCGridCellRadioButton.isPrototypeOf(cp.FControl)) {
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetControlEnabled(!this.IsReadOnly(realc,realr));
            evnt = rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged;
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged = null;
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetChecked(rtl.as(cp.FControl,$mod.TTMSFNCGridCellRadioButton).FChecked);
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged = evnt;
          };
        };
      };
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        if (cp != null) {
          rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell).FCommentText = cp.FComment;
          if (cp.FCommentColor !== -1) rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell).FCommentColor = cp.FCommentColor;
        };
      };
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        if (this.FUseColumns && !(this.GetIntObjects(realc,realr) != null)) {
          if (realc < this.FColumns.GetCount()) {
            if (this.FColumns.GetItem$1(realc).FColumnType === $mod.TTMSFNCGridColumnType.ctCheckBox) {
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetControlEnabled(!this.IsReadOnly(realc,realr));
              evnt = rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged;
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = null;
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetChecked(this.GetCells(ACol,ARow) === this.FCheckTrue);
              rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = evnt;
            };
          };
        } else {
          if ((cp != null) && $mod.TTMSFNCGridCellCheckBox.isPrototypeOf(cp.FControl)) {
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetControlEnabled(!this.IsReadOnly(realc,realr));
            evnt = rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged;
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = null;
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetChecked(rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked);
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = evnt;
          };
          if ((cp != null) && $mod.TTMSFNCGridCellDataCheckBox.isPrototypeOf(cp.FControl)) {
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetControlEnabled(!this.IsReadOnly(realc,realr));
            evnt = rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged;
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = null;
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetChecked(this.GetCells(ACol,ARow) === this.FCheckTrue);
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = evnt;
          };
        };
      };
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell).FBitmapContainer = this.GetBitmapContainer();
        if ((cp != null) && $mod.TTMSFNCGridCellBitmapName.isPrototypeOf(cp.FControl)) {
          if (rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FData) {
            rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell).SetBitmapName(this.GetCells(ACol,ARow))}
           else rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell).SetBitmapName(rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FBitmapName);
        };
        if ((cp != null) && $mod.TTMSFNCGridCellBitmap.isPrototypeOf(cp.FControl)) rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell).FBitmap.Assign(rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmap).FBitmap);
      };
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        if ((cp != null) && $mod.TTMSFNCGridCellNode.isPrototypeOf(cp.FControl)) {
          rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).FState = rtl.as(cp.FControl,$mod.TTMSFNCGridCellNode).FState;
        };
      };
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell.isPrototypeOf(Cell)) {
        cp = this.GetCellProps(realc,realr);
        if (this.FUseColumns && !(this.GetIntObjects(realc,realr) != null)) {
          if (realc < this.FColumns.GetCount()) {
            if (this.FColumns.GetItem$1(realc).FColumnType === $mod.TTMSFNCGridColumnType.ctProgressBar) {
              v = 0;
              if (pas.SysUtils.TryStrToInt(this.GetCells(ACol,ARow),{get: function () {
                  return v;
                }, set: function (w) {
                  v = w;
                }})) {
                rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetValue(v)}
               else rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetValue(0);
            };
          };
        } else {
          if ((cp != null) && $mod.TTMSFNCGridCellProgressBar.isPrototypeOf(cp.FControl)) {
            if (rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FData) {
              v = 0;
              if (pas.SysUtils.TryStrToInt(this.GetCells(ACol,ARow),{get: function () {
                  return v;
                }, set: function (w) {
                  v = w;
                }})) {
                rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetValue(v)}
               else rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetValue(0);
            } else rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetValue(rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FValue);
          };
        };
      };
      if (this.FOptions.FFiltering.FDropDown && pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(Cell)) {
        allow = false;
        if ((this.FOptions.FFiltering.FDropDownFixedRow === realr) && (realc >= this.FFixedColumns) && (realc < (this.GetColumnCount() - this.FFixedRightColumns))) {
          allow = true;
          this.DoNeedFilterDropDown(realc,realr,{get: function () {
              return allow;
            }, set: function (v) {
              allow = v;
            }});
        };
        rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FShowDropDownButton = allow;
        rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FSizeMargin = this.FOptions.FMouse.FColumnSizeMargin - 2;
      };
    };
    this.DoGetCellMergeInfo = function (ACol, ARow, ABaseCol, ABaseRow, AColSpan, ARowSpan) {
      var cp = null;
      cp = this.GetIntObjects(this.DisplToRealColumn(ACol),this.DisplToRealRow(ARow));
      if ((cp != null) && (cp.FBaseCol !== -1)) {
        ABaseCol.set(this.RealToDisplColumn(cp.FBaseCol));
        ABaseRow.set(this.RealToDisplRow(cp.FBaseRow));
        AColSpan.set(cp.FColSpan);
        ARowSpan.set(cp.FRowSpan);
      };
    };
    this.DoGetCellEditorType = function (ACol, ARow, CellEditorType) {
      var c = 0;
      c = this.DisplToRealColumn(ACol);
      if (c < this.FColumns.GetCount()) CellEditorType.set(this.FColumns.GetItem$1(c).FEditor);
      if (this.IsCellControl(ACol,ARow,$mod.TTMSFNCGridCellCombo)) CellEditorType.set($mod.TTMSFNCGridEditorType.etComboBox);
    };
    this.DoGetCellEditorCustomClassType = function (ACol, ARow, CellEditorCustomClassType) {
      var cp = null;
      cp = this.GetIntObjects(ACol,ARow);
      if ((cp != null) && cp.FReadOnly) CellEditorCustomClassType.set(null);
    };
    this.DoCellEditGetData = function (ACol, ARow, CellEditor, CellString) {
    };
    this.DoCellEditValidateData = function (ACol, ARow, CellEditor, CellString, Allow) {
    };
    this.DoCellEditSetData = function (ACol, ARow, CellEditor, CellString) {
      this.SetCells(ACol,ARow,CellString.get());
    };
    this.DoCellEditGetColor = function (ACol, ARow, CellEditor, CellColor) {
    };
    this.DoCellEditValidateColor = function (ACol, ARow, CellEditor, CellColor, Allow) {
    };
    this.DoCellEditSetColor = function (ACol, ARow, CellEditor, CellColor) {
      this.SetColors(ACol,ARow,CellColor.get());
    };
    this.DoCellEditDone = function (ACol, ARow, CellEditor) {
      var cc = 0;
      var I = 0;
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        I = $l;
        cc = this.GetColumnCalculation(I);
        if (cc !== $mod.TTMSFNCGridColumnCalculation.ccNone) this.UpdateColumnCalc(I,cc);
      };
    };
    this.DoGetCellEditorProperties = function (ACol, ARow, CellEditor) {
      var cp = null;
      var c = 0;
      if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(CellEditor)) {
        rtl.as(CellEditor,pas["WEBLib.StdCtrls"].TComboBox).SetParent(this);
        c = this.DisplToRealColumn(ACol);
        if (this.FUseColumns && (c < this.FColumns.GetCount())) {
          if (this.FColumns.GetItem$1(c).FEditor in rtl.createSet($mod.TTMSFNCGridEditorType.etComboBox)) {
            if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(CellEditor)) rtl.as(CellEditor,pas["WEBLib.StdCtrls"].TComboBox).FItems.Assign(this.FColumns.GetItem$1(c).FComboItems);
          };
        };
        if (this.IsCellControl(ACol,ARow,$mod.TTMSFNCGridCellCombo)) {
          cp = this.GetIntObjects(ACol,ARow);
          if (cp != null) {
            if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(CellEditor)) rtl.as(CellEditor,pas["WEBLib.StdCtrls"].TComboBox).FItems.Assign(rtl.as(cp.FControl,$mod.TTMSFNCGridCellCombo).FItems);
          };
        };
        rtl.as(CellEditor,pas["WEBLib.StdCtrls"].TComboBox).SetParent(null);
      };
    };
    this.DoColumnCalc = function (Acol, FromRow, ToRow) {
      var Result = 0.0;
      var r = 0.0;
      r = 0;
      if (this.FOnColumnCalc != null) this.FOnColumnCalc(this,Acol,FromRow,ToRow,{get: function () {
          return r;
        }, set: function (v) {
          r = v;
        }});
      Result = r;
      return Result;
    };
    this.DoColumnCalcGroup = function (Acol, FromRow, ToRow) {
      var Result = 0.0;
      var r = 0.0;
      r = 0;
      if (this.FOnGroupCalc != null) this.FOnGroupCalc(this,Acol,FromRow,ToRow,{get: function () {
          return r;
        }, set: function (v) {
          r = v;
        }});
      Result = r;
      return Result;
    };
    this.DoCellAnchorClick = function (ACol, ARow, AAnchor) {
    };
    this.DoCanEditCell = function (ACol, ARow, Allow) {
      Allow.set(this.FOptions.FEditing.FEnabled);
      Allow.set(Allow.get() && !this.IsReadOnly(ACol,ARow));
    };
    this.DoCanSizeColumn = function (ACol, Allow) {
    };
    this.DoCanSizeRow = function (ARow, Allow) {
    };
    this.DoColumnSize = function (ACol, NewWidth) {
    };
    this.DoRowSize = function (ARow, NewHeight) {
    };
    this.DoColumnSized = function (ACol, NewWidth) {
    };
    this.DoRowSized = function (ARow, NewHeight) {
    };
    this.DoCanSortColumn = function (ACol, Allow) {
    };
    this.DoColumnSorted = function (ACol, Direction) {
    };
    this.DoIsCellSelected = function (ACol, ARow) {
      var Result = false;
      Result = false;
      var $tmp = this.FOptions.FSelection.FMode;
      if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) {
        Result = this.GetColumnSelect(ACol)}
       else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
        Result = this.GetRowSelect(ARow)}
       else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) Result = this.GetCellSelect(ACol,ARow);
      return Result;
    };
    this.CreateColumnProp = function () {
      if (this.FColumnProp != null) rtl.free(this,"FColumnProp");
      this.FColumnProp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.FDefaultFont]);
    };
    this.DoPasteNotify = function (Origin, ARange, AOperation) {
    };
    this.Create$1 = function (AOwner) {
      var i = 0;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Create$1.apply(this,arguments);
      this.FDefaultLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FUseColumns = true;
      this.FColumns = $mod.TTMSFNCGridColumns.$create("Create$3",[this]);
      for (i = 0; i <= 4; i++) this.FColumns.Add$1();
      this.FGroupColumn = -1;
      this.FSortColumn = -1;
      this.FRowCount = 10;
      this.FColumnCount = 5;
      this.FDefaultRowHeight = 24;
      this.FDefaultColumnWidth = 68;
      this.FFixedRows = 1;
      this.FFixedColumns = 1;
      this.FFixedRightColumns = 0;
      this.FFixedFooterRows = 0;
      this.FFilterApplied = false;
      this.FCheckTrue = "TRUE";
      this.FCheckFalse = "FALSE";
      this.FFloatFormat = "%g";
      this.FColumnOrder = pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridIntList.$create("Create$1");
      this.FDefaultFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FOptions = pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridOptions.$create("Create$1");
      this.FOptions.FOnChange = rtl.createCallback(this,"DoOptionsChange");
      this.FGlobalFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCAppearanceGlobalFont.$create("Create$1",[this]);
      this.FColumnW = $mod.TTMSFNCGridSingleList.$create("Create$3",[this]);
      this.FOrigColumnW = $mod.TTMSFNCGridSingleList.$create("Create$3",[this]);
      this.FRowH = $mod.TTMSFNCGridSingleList.$create("Create$3",[this]);
      this.FRowList = $mod.TTMSFNCGridRowInfoList.$create("Create$1");
      this.FRowDisplayList = $mod.TTMSFNCGridIntegerList.$create("Create$1");
      this.FColumnDisplayList = $mod.TTMSFNCGridIntegerList.$create("Create$1");
      this.FHiddenColumnList = $mod.TTMSFNCGridIntegerList.$create("Create$1");
      this.FSuppressedColumnList = $mod.TTMSFNCGridIntegerList.$create("Create$1");
      this.FHiddenRowList = $mod.TTMSFNCGridIntegerList.$create("Create$1");
      this.FColSelect = pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridIntList.$create("Create$1");
      this.FSelectedCells = $mod.TTMSFNCGridCellList.$create("Create$2");
      this.FMarkList = $mod.TTMSFNCGridCellMarkList.$create("Create$3",[this]);
      this.FCellCalcList = pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridIntList.$create("Create$1");
      this.FIOOffset.$assign(pas.Types.Point(this.FFixedColumns,this.FFixedRows));
      this.FFilter = $mod.TTMSFNCGridFilter.$create("Create$3",[this]);
      this.FSortIndexes = $mod.TTMSFNCGridSortIndexList.$create("Create$1");
      this.CreateColumnProp();
      this.FUpdateCount$1 = this.FUpdateCount$1 + 1;
      this.SetColumnCount(this.FColumnCount);
      this.FUpdateCount$1 = this.FUpdateCount$1 - 1;
      return this;
    };
    this.Destroy = function () {
      this.Clear();
      rtl.free(this,"FGlobalFont");
      rtl.free(this,"FDefaultLayout");
      rtl.free(this,"FColumns");
      rtl.free(this,"FColumnProp");
      rtl.free(this,"FDefaultFont");
      rtl.free(this,"FOptions");
      rtl.free(this,"FColumnW");
      rtl.free(this,"FOrigColumnW");
      rtl.free(this,"FRowH");
      rtl.free(this,"FRowDisplayList");
      rtl.free(this,"FColumnDisplayList");
      rtl.free(this,"FHiddenColumnList");
      rtl.free(this,"FSuppressedColumnList");
      rtl.free(this,"FHiddenRowList");
      rtl.free(this,"FRowList");
      rtl.free(this,"FFilter");
      rtl.free(this,"FSortIndexes");
      rtl.free(this,"FMarkList");
      rtl.free(this,"FColSelect");
      rtl.free(this,"FSelectedCells");
      rtl.free(this,"FCellCalcList");
      this.FColumnOrder.Clear();
      rtl.free(this,"FColumnOrder");
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Destroy.call(this);
    };
    this.Clear = function () {
      var i = 0;
      var j = 0;
      var cp = null;
      var ri = null;
      this.BeginUpdate();
      this.UnHideRowsAll();
      this.UnHideColumnsAll();
      for (var $l = this.FRowList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.FRowList.GetItem(i) != null) {
          for (var $l1 = 0, $end = this.FRowList.GetItem(i).FData.GetCount() - 1; $l1 <= $end; $l1++) {
            j = $l1;
            cp = this.FRowList.GetItem(i).FData.GetObject(j);
            if ((cp != null) && cp.IsBaseCell(j,i)) {
              cp.FreeControl();
              cp = rtl.freeLoc(cp);
            };
          };
          ri = this.FRowList.GetItem(i);
          ri = rtl.freeLoc(ri);
        };
      };
      this.FRowList.Clear();
      this.FRowDisplayList.Clear();
      this.FColumnDisplayList.Clear();
      this.FHiddenColumnList.Clear();
      this.FSuppressedColumnList.Clear();
      this.FHiddenRowList.Clear();
      this.EndUpdate();
    };
    this.ClearSortColumn = function () {
      this.FSortColumn = -1;
    };
    this.ClearCells = function (CellRange) {
      var i = 0;
      var j = 0;
      var cp = null;
      var sl = null;
      this.BeginUpdate();
      for (var $l = CellRange.StartRow, $end = CellRange.EndRow; $l <= $end; $l++) {
        i = $l;
        if ((i < this.FRowList.GetCount()) && (this.FRowList.GetItem(i) != null)) {
          for (var $l1 = CellRange.StartCol, $end1 = Math.min(CellRange.EndCol,this.FRowList.GetItem(i).FData.GetCount() - 1); $l1 <= $end1; $l1++) {
            j = $l1;
            this.SplitCell(j,i);
            sl = this.FRowList.GetItem(i).FData;
            sl.Put(j,"");
            cp = sl.GetObject(j);
            if (cp != null) {
              if (cp.FControl != null) cp.FreeControl();
              cp = rtl.freeLoc(cp);
              sl.PutObject(j,null);
            };
          };
        };
      };
      this.EndUpdate();
    };
    this.ClearNormalCells = function () {
      this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(this.FFixedColumns,this.FFixedRows,this.GetColumnCount() - 1,this.GetRowCount() - 1)));
    };
    this.Debug = function () {
    };
    this.GetCellMergeInfo = function (ACol, ARow, ABaseCol, ABaseRow, AColSpan, ARowSpan) {
      this.DoGetCellMergeInfo(ACol,ARow,ABaseCol,ABaseRow,AColSpan,ARowSpan);
    };
    this.GetCellState = function (ACol, ARow) {
      var Result = 0;
      Result = $mod.TTMSFNCGridCellState.csNormal;
      return Result;
    };
    this.GetCellLayout = function (ACol, ARow, ACellState) {
      var Result = null;
      this.FDefaultLayout.Assign(this.GetDefaultNormalLayout());
      this.DoGetCellLayout(ACol,ARow,this.FDefaultLayout,ACellState);
      Result = this.FDefaultLayout;
      return Result;
    };
    this.DisplToRealRow = function (Row) {
      var Result = 0;
      if ((Row >= 0) && (Row < this.FRowDisplayList.GetCount())) {
        Result = this.FRowDisplayList.GetItem(Row)}
       else Result = Row;
      return Result;
    };
    this.RealToDisplRow = function (Row) {
      var Result = 0;
      var i = 0;
      Result = Row;
      i = 0;
      while (i < this.FRowDisplayList.GetCount()) {
        if (this.FRowDisplayList.GetItem(i) === Row) {
          Result = i;
          break;
        };
        i += 1;
      };
      return Result;
    };
    this.DisplToRealColumn = function (Col) {
      var Result = 0;
      if ((Col >= 0) && (Col < this.FColumnDisplayList.GetCount())) {
        Result = this.FColumnDisplayList.GetItem(Col)}
       else Result = Col;
      return Result;
    };
    this.RealToDisplColumn = function (Col) {
      var Result = 0;
      var i = 0;
      Result = -1;
      i = 0;
      while (i < this.FColumnDisplayList.GetCount()) {
        if (this.FColumnDisplayList.GetItem(i) === Col) {
          Result = i;
          break;
        };
        i += 1;
      };
      return Result;
    };
    this.GetColumnRange = function (Col, DoFixed) {
      var Result = $mod.TTMSFNCGridCellRecRange.$new();
      if (DoFixed) {
        Result.$assign(this.CellRange(Col,0,Col,this.GetRowCount() - 1))}
       else Result.$assign(this.CellRange(Col,this.FFixedRows,Col,this.GetRowCount() - 1 - this.FFixedFooterRows));
      return Result;
    };
    this.GetRowRange = function (Row, DoFixed) {
      var Result = $mod.TTMSFNCGridCellRecRange.$new();
      if (DoFixed) {
        Result.$assign(this.CellRange(0,Row,this.GetColumnCount() - 1,Row))}
       else Result.$assign(this.CellRange(this.FFixedColumns,Row,this.GetColumnCount() - 1 - this.FFixedRightColumns,Row));
      return Result;
    };
    this.GetGridRange = function (DoFixed) {
      var Result = $mod.TTMSFNCGridCellRecRange.$new();
      if (DoFixed) {
        Result.$assign(this.CellRange(0,0,this.GetColumnCount() - 1,this.GetRowCount() - 1))}
       else Result.$assign(this.CellRange(this.FFixedColumns,this.FFixedRows,this.GetColumnCount() - 1 - this.FFixedRightColumns,this.GetRowCount() - 1 - this.FFixedFooterRows));
      return Result;
    };
    this.GetCellRecRange = function (Col, Row) {
      var Result = $mod.TTMSFNCGridCellRecRange.$new();
      Result.$assign(this.CellRange(Col,Row,Col,Row));
      return Result;
    };
    this.InitOriginalColumnSizes = function () {
      var i = 0;
      this.FOrigColumnW.Clear();
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        i = $l;
        var $with = this.FOrigColumnW.Add$1();
        $with.SetValue(this.GetColWidths(i));
      };
      this.FOldSize = this.GetWidth();
    };
    this.RandomFill = function (DoFixed, rnd) {
      var i = 0;
      var j = 0;
      var ro = 0;
      var co = 0;
      var re = 0;
      var ce = 0;
      this.BeginUpdate();
      if (DoFixed) {
        ro = 0;
        co = 0;
        re = this.GetRowCount() - 1;
        ce = this.GetColumnCount() - 1;
      } else {
        ro = this.FFixedRows;
        co = this.FFixedColumns;
        re = this.GetRowCount() - 1 - this.FFixedFooterRows;
        ce = this.GetColumnCount() - 1 - this.FFixedRightColumns;
      };
      for (var $l = ro, $end = re; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = co, $end1 = ce; $l1 <= $end1; $l1++) {
          j = $l1;
          this.SetCells(j,i,pas.SysUtils.IntToStr(pas.System.Random(rnd)));
        };
      };
      this.EndUpdate();
    };
    this.LinearFill = function (DoFixed) {
      var i = 0;
      var j = 0;
      var ro = 0;
      var co = 0;
      var re = 0;
      var ce = 0;
      this.BeginUpdate();
      if (DoFixed) {
        ro = 0;
        co = 0;
        re = this.GetRowCount() - 1;
        ce = this.GetColumnCount() - 1;
      } else {
        ro = this.FFixedRows;
        co = this.FFixedColumns;
        re = this.GetRowCount() - 1 - this.FFixedFooterRows;
        ce = this.GetColumnCount() - 1 - this.FFixedRightColumns;
      };
      for (var $l = ro, $end = re; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = co, $end1 = ce; $l1 <= $end1; $l1++) {
          j = $l1;
          this.SetCells(j,i,pas.SysUtils.IntToStr(j) + ":" + pas.SysUtils.IntToStr(i));
        };
      };
      this.EndUpdate();
    };
    this.CellRange = function (AStartCol, AStartRow, AEndCol, AEndRow) {
      var Result = $mod.TTMSFNCGridCellRecRange.$new();
      Result.StartCol = AStartCol;
      Result.StartRow = AStartRow;
      Result.EndCol = AEndCol;
      Result.EndRow = AEndRow;
      return Result;
    };
    this.SingleCell = function (ACol, ARow) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      Result.Col = ACol;
      Result.Row = ARow;
      return Result;
    };
    this.IsReadOnly = function (Col, Row) {
      var Result = false;
      Result = false;
      this.DoGetCellReadOnly(Col,Row,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ClearRowSelect = function () {
      var i = 0;
      for (var $l = this.FFixedRows, $end = this.GetRowCount() - this.FFixedFooterRows - 1; $l <= $end; $l++) {
        i = $l;
        if (i >= this.FRowList.GetCount()) break;
        if (this.FRowList.GetItem(i) != null) this.FRowList.GetItem(i).SetState($mod.TTMSFNCGridRowState.rsDefault);
      };
    };
    this.GetSelectedRowCount = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      for (var $l = this.FFixedRows, $end = this.GetRowCount() - this.FFixedFooterRows - 1; $l <= $end; $l++) {
        i = $l;
        if (i >= this.FRowList.GetCount()) break;
        if ((this.FRowList.GetItem(i) != null) && (this.FRowList.GetItem(i).FState === $mod.TTMSFNCGridRowState.rsSelected)) Result += 1;
      };
      return Result;
    };
    this.SelectRows = function (FromRow, ToRow) {
      var i = 0;
      if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) {
        this.SetSelection(this.CellRange(0,FromRow,0,ToRow))}
       else if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) {
        this.SetSelection(this.CellRange(0,FromRow,0,FromRow))}
       else if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
        i = $l;
        this.SetRowSelect(i,true);
      };
    };
    this.UnSelectRows = function (FromRow, ToRow) {
      var i = 0;
      for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
        i = $l;
        this.SetRowSelect(i,false);
      };
    };
    this.ClearColumnSelect = function () {
      this.FColSelect.Clear();
    };
    this.GetSelectedColumnCount = function () {
      var Result = 0;
      Result = this.FColSelect.GetCount();
      return Result;
    };
    this.SelectColumns = function (FromColumn, ToColumn) {
      this.SelectCell($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(FromColumn,0)),{},false);
      this.SelectCell($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(ToColumn,0)),rtl.createSet(pas.Classes.TShiftState$a.ssCtrl,pas.Classes.TShiftState$a.ssShift),false);
    };
    this.UnSelectColumns = function (FromColumn, ToColumn) {
      var i = 0;
      var idx = 0;
      for (var $l = FromColumn, $end = ToColumn; $l <= $end; $l++) {
        i = $l;
        idx = this.FColSelect.IndexOfValue(i);
        if (idx !== -1) this.FColSelect.Delete$1(idx);
      };
      this.UpdateGridCells(false);
    };
    this.ClearCellSelect = function () {
      this.FSelectedCells.Clear$1();
    };
    this.GetSelectedCellCount = function () {
      var Result = 0;
      Result = this.FSelectedCells.GetCount();
      return Result;
    };
    this.SelectCells = function (ARange) {
      this.SelectCell($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(ARange.StartCol,ARange.StartRow)),{},false);
      this.SelectCell($mod.TTMSFNCGridCellRec.$clone($mod.MakeCell(ARange.EndCol,ARange.EndRow)),rtl.createSet(pas.Classes.TShiftState$a.ssShift,pas.Classes.TShiftState$a.ssCtrl),false);
    };
    this.UnSelectCells = function (ARange) {
      var i = 0;
      var j = 0;
      for (var $l = ARange.StartCol, $end = ARange.EndCol; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = ARange.StartRow, $end1 = ARange.EndRow; $l1 <= $end1; $l1++) {
          j = $l1;
          this.SetCellSelect(i,j,false);
        };
      };
    };
    this.SetColumnOrder = function () {
      var i = 0;
      this.FColumnOrder.Clear();
      for (var $l = 1, $end = this.GetColumnCount(); $l <= $end; $l++) {
        i = $l;
        this.FColumnOrder.Add$1(i - 1);
      };
    };
    this.ResetColumnOrder = function () {
      var i = 0;
      var rst = false;
      this.UnHideColumnsAll();
      if (this.FColumnOrder.GetCount() === 0) {
        this.SetColumnOrder();
        return;
      };
      rst = false;
      while (!rst) {
        rst = true;
        for (var $l = 1, $end = this.GetColumnCount(); $l <= $end; $l++) {
          i = $l;
          if ((i - 1) > this.FColumnOrder.GetInteger(i - 1)) {
            rst = false;
            this.MoveColumn(i - 1,this.FColumnOrder.GetInteger(i - 1));
          };
        };
      };
    };
    this.ColumnStatesToString = function () {
      var Result = "";
      var i = 0;
      var ci = 0;
      var r = "";
      r = pas.SysUtils.IntToStr(this.GetColumnCount() + this.GetHiddenColCount()) + "#";
      for (var $l = 0, $end = (this.GetColumnCount() - 1) + this.GetHiddenColCount(); $l <= $end; $l++) {
        i = $l;
        ci = pas.System.Trunc(this.GetColWidths(i));
        if (i === 0) {
          r = r + pas.SysUtils.IntToStr(ci)}
         else r = r + "," + pas.SysUtils.IntToStr(ci);
      };
      r = r + "#";
      if (this.FColumnOrder.GetCount() === 0) {
        for (var $l1 = 0, $end1 = (this.GetColumnCount() - 1) + this.GetHiddenColCount(); $l1 <= $end1; $l1++) {
          i = $l1;
          if (i === 0) {
            r = r + pas.SysUtils.IntToStr(i)}
           else r = r + "," + pas.SysUtils.IntToStr(i);
        };
      } else for (var $l2 = 0, $end2 = this.FColumnOrder.GetCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if (i === 0) {
          r = r + pas.SysUtils.IntToStr(this.FColumnOrder.GetInteger(i))}
         else r = r + "," + pas.SysUtils.IntToStr(this.FColumnOrder.GetInteger(i));
      };
      r = r + "#";
      for (var $l3 = 0, $end3 = (this.GetColumnCount() - 1) + this.GetHiddenColCount(); $l3 <= $end3; $l3++) {
        i = $l3;
        if (i === 0) {
          if (this.IsHiddenColumn(i)) {
            r = r + "0"}
           else r = r + "1";
        } else {
          if (this.IsHiddenColumn(i)) {
            r = r + ",0"}
           else r = r + ",1";
        };
      };
      Result = r;
      return Result;
    };
    this.StringToColumnStates = function (Value) {
      var i = 0;
      var j = 0;
      var il = null;
      var sl = null;
      var s = "";
      var NewPos = 0;
      var cw = 0;
      var stretch = false;
      if (pas.System.Pos("#",Value) === 0) return;
      this.BeginUpdate();
      try {
        this.FColumnOrder.Clear();
        this.UnHideColumnsAll();
        s = pas.System.Copy(Value,1,pas.System.Pos("#",Value) - 1);
        this.SetColumnCount(pas.SysUtils.StrToInt(s));
        pas.System.Delete({get: function () {
            return Value;
          }, set: function (v) {
            Value = v;
          }},1,pas.System.Pos("#",Value));
        s = pas.System.Copy(Value,pas.System.Pos("#",Value) + 1,Value.length);
        s = pas.System.Copy(s,1,pas.System.Pos("#",s) - 1);
        sl = pas.Classes.TStringList.$create("Create$1");
        sl.SetCommaText(s);
        if (s !== "") {
          for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (i < sl.GetCount()) {
              NewPos = pas.SysUtils.StrToInt(sl.Get(i));
              if (NewPos !== -1) this.FColumnOrder.Add$1(NewPos);
            };
          };
          il = pas["WEBLib.TMSFNCGridDataUtil"].TTMSFNCGridIntList.$create("Create$1");
          for (var $l1 = 0, $end1 = this.GetColumnCount() - 1; $l1 <= $end1; $l1++) {
            i = $l1;
            for (var $l2 = 0, $end2 = this.FColumnOrder.GetCount() - 1; $l2 <= $end2; $l2++) {
              j = $l2;
              if (this.FColumnOrder.GetInteger(j) === i) il.Add$1(j);
            };
          };
          this.FColumnOrder.Clear();
          for (var $l3 = 0, $end3 = this.GetColumnCount() - 1; $l3 <= $end3; $l3++) {
            i = $l3;
            this.FColumnOrder.Add$1(il.GetInteger(i));
          };
          il = rtl.freeLoc(il);
          if (this.FColumnOrder.GetCount() > 0) this.ResetColumnOrder();
          this.FColumnOrder.Clear();
          for (var $l4 = 0, $end4 = this.GetColumnCount() - 1; $l4 <= $end4; $l4++) {
            i = $l4;
            NewPos = pas.SysUtils.StrToInt(sl.Get(i));
            if (NewPos !== -1) this.FColumnOrder.Add$1(NewPos);
          };
        };
        s = pas.System.Copy(Value,pas.System.Pos("#",Value) + 1,Value.length);
        s = pas.System.Copy(s,pas.System.Pos("#",s) + 1,s.length);
        sl.SetCommaText(s);
        for (var $l5 = this.GetColumnCount() - 1; $l5 >= 0; $l5--) {
          i = $l5;
          if (sl.Get(i) === "0") this.HideColumn(i);
        };
        s = pas.System.Copy(Value,1,pas.System.Pos("#",Value) - 1);
        sl.SetCommaText(s);
        stretch = this.FOptions.FColumnSize.FStretch;
        this.FOptions.FColumnSize.SetStretch(false);
        if (stretch) {
          if (this.FOptions.FColumnSize.FStretchColumn === -1) {
            this.SetDefaultColumnWidth(this.GetColWidths(this.GetColumnCount() - 1))}
           else this.SetDefaultColumnWidth(this.GetColWidths(this.FOptions.FColumnSize.FStretchColumn));
        };
        for (var $l6 = 0, $end5 = this.GetColumnCount() - 1; $l6 <= $end5; $l6++) {
          i = $l6;
          cw = pas.SysUtils.StrToInt(sl.Get(i));
          if (cw === 0) {
            this.SuppressColumn(i)}
           else this.SetColWidths(this.RealToDisplColumn(i),cw);
        };
        this.FOptions.FColumnSize.SetStretch(stretch);
        sl = rtl.freeLoc(sl);
      } finally {
        this.EndUpdate();
      };
    };
    this.ColumnPosition = function (ACol) {
      var Result = 0;
      var i = 0;
      Result = ACol;
      if (this.FColumnOrder.GetCount() === 0) return Result;
      for (var $l = 1, $end = this.GetColumnCount() + this.GetHiddenColCount(); $l <= $end; $l++) {
        i = $l;
        if (ACol === this.FColumnOrder.GetInteger(i - 1)) {
          Result = i - 1;
          break;
        };
      };
      if (this.FGroupColumn !== -1) {
        if (ACol >= this.FGroupColumn) {
          Result = Result - 1;
        };
      };
      return Result;
    };
    this.ColumnAtPosition = function (ACol) {
      var Result = 0;
      Result = ACol;
      if (this.FColumnOrder.GetCount() === 0) {
        this.SetColumnOrder();
        if (this.FColumnOrder.GetCount() === 0) return Result;
      };
      Result = this.FColumnOrder.GetInteger(ACol);
      if (this.FGroupColumn !== -1) {
        if (Result >= this.FGroupColumn) Result = Result + 1;
      };
      return Result;
    };
    this.Find = function (StartC, s, FindParams) {
      var Result = pas.Types.TPoint.$new();
      Result.$assign(this.FindInternal(pas.Types.TPoint.$clone(StartC),s,rtl.refSet(FindParams)));
      if (($mod.TTMSFNCGridFindParameters.fnAutoGoto in FindParams) && (Result.x !== -1)) {
        this.SetSelection(this.CellRange(Result.x,Result.y,Result.x,Result.y));
      };
      return Result;
    };
    this.FindFirst = function (s, FindParams) {
      var Result = pas.Types.TPoint.$new();
      this.FSearchCell.$assign(this.Find(pas.Types.TPoint.$clone(pas.Types.Point(-1,-1)),s,rtl.refSet(FindParams)));
      Result.$assign(this.FSearchCell);
      return Result;
    };
    this.FindNext = function () {
      var Result = pas.Types.TPoint.$new();
      this.FSearchCell.$assign(this.Find(pas.Types.TPoint.$clone(this.FSearchCell),this.FSearchCache,rtl.refSet(this.FFindParams)));
      Result.$assign(this.FSearchCell);
      return Result;
    };
    this.Replace = function (OrigStr, NewStr, FindParams) {
      var Result = 0;
      var cp = pas.Types.TPoint.$new();
      var i = 0;
      i = 0;
      cp.$assign(this.FindFirst(OrigStr,rtl.refSet(FindParams)));
      while (cp.x !== -1) {
        this.SetCells(cp.x,cp.y,NewStr);
        i += 1;
        cp.$assign(this.FindNext());
      };
      Result = i;
      return Result;
    };
    this.IsFixed = function (Col, Row) {
      var Result = false;
      Result = (Row < this.FFixedRows) || (Row > (this.GetRowCount() - 1 - this.FFixedFooterRows)) || (Col < this.FFixedColumns) || (Col > (this.GetColumnCount() - 1 - this.FFixedRightColumns));
      Result = Result || this.IsNormalFixed(Col,Row);
      return Result;
    };
    this.IsBand = function (Row) {
      var Result = false;
      Result = pas.System.Odd(Row);
      this.DoGetRowIsBand(Row,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.IsNormalFixed = function (Col, Row) {
      var Result = false;
      var ACellFixed = false;
      ACellFixed = false;
      this.DoGetCellIsFixed(Col,Row,{get: function () {
          return ACellFixed;
        }, set: function (v) {
          ACellFixed = v;
        }});
      Result = ACellFixed;
      return Result;
    };
    this.NextSelectableRow = function (Col, Row) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      var c = 0;
      var r = 0;
      var corig = 0;
      var rorig = 0;
      var rs = 0;
      var chk = false;
      c = Col;
      r = Row;
      corig = c;
      rorig = r;
      Result.Col = Col;
      Result.Row = Row;
      rs = this.RowSpan(c,r);
      if (rs > 0) {
        chk = (Result.Row + rs) <= (this.GetRowCount() - 1 - this.FFixedFooterRows);
        if (chk) Result.Row = Result.Row + rs;
      } else {
        chk = (Result.Row + 1) <= (this.GetRowCount() - 1 - this.FFixedFooterRows);
        if (chk) Result.Row = Result.Row + 1;
      };
      if (chk) {
        while (this.IsNormalFixed(Result.Col,Result.Row) && (Result.Row < (this.GetRowCount() - 1 - this.FFixedFooterRows))) {
          rs = this.RowSpan(c,r);
          if (rs > 0) {
            Result.Row = Result.Row + rs}
           else Result.Row = Result.Row + 1;
        };
      };
      if (this.IsNormalFixed(Result.Col,Result.Row)) {
        Result.Col = corig;
        Result.Row = rorig;
      };
      return Result;
    };
    this.NextSelectableColumn = function (Col, Row) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      var c = 0;
      var corig = 0;
      var r = 0;
      var rorig = 0;
      var cs = 0;
      var chk = false;
      c = Col;
      r = Row;
      corig = c;
      rorig = r;
      Result.Col = Col;
      Result.Row = Row;
      cs = this.ColSpan(c,r);
      if (cs > 0) {
        chk = (Result.Col + cs) <= (this.GetColumnCount() - 1 - this.FFixedRightColumns);
        if (chk) Result.Col = Result.Col + cs;
      } else {
        chk = (Result.Col + 1) <= (this.GetColumnCount() - 1 - this.FFixedRightColumns);
        if (chk) Result.Col = Result.Col + 1;
      };
      if (chk) {
        while ((this.IsNormalFixed(Result.Col,Result.Row) || this.IsSuppressedColumn(Result.Col)) && (Result.Col < (this.GetColumnCount() - 1 - this.FFixedRightColumns))) {
          cs = this.ColSpan(c,r);
          if (cs > 0) {
            Result.Col = Result.Col + cs}
           else Result.Col = Result.Col + 1;
        };
      };
      if (this.IsNormalFixed(Result.Col,Result.Row) || this.IsSuppressedColumn(Result.Col)) {
        Result.Col = corig;
        Result.Row = rorig;
      };
      return Result;
    };
    this.PreviousSelectableColumn = function (Col, Row) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      var c = 0;
      var r = 0;
      var rorig = 0;
      var corig = 0;
      c = Col;
      r = Row;
      corig = c;
      rorig = r;
      Result.Col = Col;
      Result.Row = Row;
      if ((Result.Col - 1) >= this.FFixedColumns) {
        Result.Col = Result.Col - 1;
        while ((this.IsNormalFixed(Result.Col,Result.Row) || this.IsSuppressedColumn(Result.Col)) && (Result.Col > this.FFixedColumns)) Result.Col = Result.Col - 1;
      };
      if (this.IsNormalFixed(Result.Col,Result.Row) || this.IsSuppressedColumn(Result.Col)) {
        Result.Col = corig;
        Result.Row = rorig;
      };
      return Result;
    };
    this.PreviousSelectableRow = function (Col, Row) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      var c = 0;
      var r = 0;
      var corig = 0;
      var rorig = 0;
      c = Col;
      r = Row;
      corig = c;
      rorig = r;
      Result.Col = Col;
      Result.Row = Row;
      if ((Result.Row - 1) >= this.FFixedRows) {
        Result.Row = Result.Row - 1;
        while (this.IsNormalFixed(Result.Col,Result.Row) && (Result.Row > this.FFixedRows)) Result.Row = Result.Row - 1;
      };
      if (this.IsNormalFixed(Result.Col,Result.Row)) {
        Result.Col = corig;
        Result.Row = rorig;
      };
      return Result;
    };
    this.ApplyFilter = function () {
      var i = 0;
      var h = 0;
      var HideList = null;
      var cnd = false;
      HideList = $mod.TTMSFNCGridIntegerList.$create("Create$1");
      try {
        for (var $l = this.FFixedRows, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
          i = $l;
          cnd = (this.FOptions.FFiltering.FRows === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFilterRows.frAll) || ((this.FOptions.FFiltering.FRows === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFilterRows.frNormal) && !this.IsNode(i) && !this.IsSummary(i) && !this.IsFixed(this.FFixedColumns,i));
          if (!this.MatchFilter(i) && cnd) {
            HideList.Add(i);
          };
        };
        h = 0;
        for (var $l1 = 0, $end1 = HideList.GetCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          while (this.FRowDisplayList.GetItem(h) !== HideList.GetItem(i)) h += 1;
          if (this.FRowDisplayList.GetItem(h) === HideList.GetItem(i)) this.FRowDisplayList.Delete(h);
        };
        this.FRowCount = this.FRowCount - HideList.GetCount();
      } finally {
        HideList = rtl.freeLoc(HideList);
        this.FFilterApplied = true;
        this.UpdateControl(true,true);
      };
    };
    this.RemoveFilter = function () {
      this.UnHideRowsAll();
      this.FFilterApplied = false;
    };
    this.RemoveFilters = function () {
      this.FFilter.Clear();
      this.UnHideRowsAll();
      this.FFilterApplied = false;
    };
    this.LookupInColumn = function (Col, AValue, AllRows, AutoGoto) {
      var Result = 0;
      var sr = 0;
      if (AllRows) {
        sr = 0}
       else sr = this.FFixedRows;
      Result = this.LookupInColumnFromRow(Col,sr,AValue,AllRows,AutoGoto);
      return Result;
    };
    this.LookupInColumnFromRow = function (Col, Row, AValue, AllRows, AutoGoto) {
      var Result = 0;
      var i = 0;
      var sr = 0;
      var er = 0;
      var m = 0;
      var s = "";
      var v = "";
      Result = -1;
      v = AValue;
      if (!this.FOptions.FLookup.FCaseSensitive) v = pas.SysUtils.UpperCase(v);
      if (AllRows) {
        sr = this.FFixedRows;
        er = this.GetRowCount() - 1;
      } else {
        sr = Row;
        er = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      if (Col === this.FSortColumn) {
        do {
          m = sr + Math.round((er - sr) / 2);
          s = this.GetCells(Col,this.DisplToRealRow(m));
          if (!this.FOptions.FLookup.FCaseSensitive) s = pas.SysUtils.UpperCase(s);
          if (pas.System.Pos(v,s) === 1) {
            Result = m;
            break;
          };
          if (v > s) {
            sr = m}
           else er = m;
        } while (!((er - sr) <= 1));
        if ((m > sr) && (Result !== -1)) {
          do {
            s = this.GetCells(Col,this.DisplToRealRow(m - 1));
            if (!this.FOptions.FLookup.FCaseSensitive) s = pas.SysUtils.UpperCase(s);
            if (pas.System.Pos(v,s) === 1) {
              m -= 1}
             else break;
          } while (!(m <= sr));
          Result = m;
        };
      } else {
        for (var $l = sr, $end = er; $l <= $end; $l++) {
          i = $l;
          s = this.GetCells(Col,this.DisplToRealRow(i));
          if (!this.FOptions.FLookup.FCaseSensitive) s = pas.SysUtils.UpperCase(s);
          if (pas.System.Pos(v,s) === 1) {
            Result = i;
            break;
          };
        };
      };
      if (AutoGoto && (Result !== -1)) this.SetFocusedCell($mod.MakeCell(Col,Result));
      return Result;
    };
    this.AutoNumberCol = function (Col, StartRow, StartValue) {
      var i = 0;
      for (var $l = StartRow, $end = this.FRowCount - 1; $l <= $end; $l++) {
        i = $l;
        this.SetCells(Col,i,pas.SysUtils.IntToStr(StartValue));
        StartValue += 1;
      };
    };
    this.AutoNumberRow = function (Row, StartColumn, StartValue) {
      var i = 0;
      for (var $l = StartColumn, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.SetCells(i,Row,pas.SysUtils.IntToStr(StartValue));
        StartValue += 1;
      };
    };
    this.AddHeaderCheckBox = function (Col, Row, State) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellCheckBox.$create("Create");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked = State;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FHeader = true;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.AddCheckBox = function (Col, Row, State) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellCheckBox.$create("Create");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked = State;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FHeader = false;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.AddCheckBoxColumn = function (Col) {
      var i = 0;
      for (var $l = this.FFixedRows, $end = this.GetRowCount() - this.FFixedFooterRows - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FGroupColumn !== -1) {
          if (this.IsNode(i)) {
            if (this.FOptions.FGrouping.FAutoCheckGroup) this.AddCheckBox(Col,i,false);
          } else if (!this.IsSummary(i)) this.AddCheckBox(Col,i,false);
        } else this.AddCheckBox(Col,i,false);
      };
    };
    this.RemoveCheckBox = function (Col, Row) {
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellCheckBox);
    };
    this.IsCheckBox = function (Col, Row) {
      var Result = false;
      Result = this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellCheckBox) || this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellDataCheckBox);
      return Result;
    };
    this.AddDataCheckBox = function (Col, Row, State) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellDataCheckBox.$create("Create");
      this.SetIntObjects(Col,Row,cp);
      if (State) {
        this.SetCells(Col,Row,this.FCheckTrue)}
       else this.SetCells(Col,Row,this.FCheckFalse);
      this.UpdateGridCells(false);
    };
    this.AddDataCheckBoxColumn = function (Col) {
      var i = 0;
      for (var $l = this.FFixedRows, $end = this.GetRowCount() - this.FFixedFooterRows - 1; $l <= $end; $l++) {
        i = $l;
        this.AddDataCheckBox(Col,i,false);
      };
    };
    this.AddRadioButton = function (Col, Row, Index, State) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellRadioButton.$create("Create");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellRadioButton).FChecked = State;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellRadioButton).FIndex = Index;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.AddRadioButtonColumn = function (Col, Index) {
      var i = 0;
      for (var $l = this.FFixedRows, $end = this.GetRowCount() - this.FFixedFooterRows - 1; $l <= $end; $l++) {
        i = $l;
        this.AddRadioButton(Col,i,Index,false);
      };
    };
    this.RemoveRadioButton = function (Col, Row) {
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellRadioButton);
    };
    this.IsRadioButton = function (Col, Row) {
      var Result = false;
      Result = this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellRadioButton);
      return Result;
    };
    this.RadioButtonState = function (Col, Row) {
      var Result = false;
      var cp = null;
      Result = false;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellRadioButton.isPrototypeOf(cp.FControl)) {
        Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellRadioButton).FChecked;
      };
      return Result;
    };
    this.AddRotated = function (Col, Row, AAngle, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      cp.FAngle = AAngle;
      this.SetIntObjects(Col,Row,cp);
      this.SetCells(Col,Row,Value);
    };
    this.SetRotated = function (Col, Row, AAngle) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp != null) {
        cp.FAngle = AAngle;
        this.SetIntObjects(Col,Row,cp);
      };
    };
    this.RemoveRotated = function (Col, Row) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) {
        cp.FAngle = 0;
        this.UpdateGridCells(false);
      };
    };
    this.IsRotated = function (Col, Row, AAngle) {
      var Result = false;
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (cp != null) AAngle.set(cp.FAngle);
      Result = AAngle.get() !== 0;
      return Result;
    };
    this.AddButton = function (Col, Row, AText, AWidth, AHeight) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellButton.$create("Create");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellButton).FWidth = AWidth;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellButton).FHeight = AHeight;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellButton).FText = AText;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.IsButton = function (Col, Row) {
      var Result = false;
      Result = this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellButton);
      return Result;
    };
    this.RemoveButton = function (Col, Row) {
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellButton);
    };
    this.AddBitmap = function (Col, Row, AName) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellBitmapName.$create("Create$1");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FBitmapName = AName;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.AddBitmap$1 = function (Col, Row, ABitmap) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellBitmap.$create("Create$1",[this]);
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmap).FBitmap.Assign(ABitmap);
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.CreateBitmap = function (Col, Row) {
      var Result = null;
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellBitmap.$create("Create$1",[this]);
      Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmap).FBitmap;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
      return Result;
    };
    this.CreateCheck = function (Col, Row) {
      var Result = false;
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellCheckBox.$create("Create");
      Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellCheckBox).FChecked;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
      return Result;
    };
    this.AddDataBitmap = function (Col, Row) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellBitmapName.$create("Create$1");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FData = true;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.RemoveBitmap = function (Col, Row) {
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellBitmapName);
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellBitmap);
    };
    this.IsBitmap = function (Col, Row) {
      var Result = false;
      Result = this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellBitmapName) || this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellBitmap);
      return Result;
    };
    this.GetBitmap = function (Col, Row) {
      var Result = null;
      var cp = null;
      Result = null;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellBitmapName.isPrototypeOf(cp.FControl)) ;
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellBitmap.isPrototypeOf(cp.FControl)) {
        Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmap).FBitmap;
      };
      return Result;
    };
    this.SetBitmapName = function (Col, Row, AName) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellBitmapName.isPrototypeOf(cp.FControl)) {
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FBitmapName = AName;
        this.UpdateGridCells(false);
      };
    };
    this.GetBitmapName = function (Col, Row) {
      var Result = "";
      var cp = null;
      Result = "";
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellBitmapName.isPrototypeOf(cp.FControl)) {
        Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellBitmapName).FBitmapName;
      };
      return Result;
    };
    this.AddProgressBar = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellProgressBar.$create("Create");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FValue = Value;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FData = false;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.AddDataProgressBar = function (Col, Row) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellProgressBar.$create("Create");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FValue = 0;
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FData = true;
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.SetProgressBarValue = function (Col, Row, Value) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) return;
      if ($mod.TTMSFNCGridCellProgressBar.isPrototypeOf(cp.FControl)) {
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FValue = Value;
        this.UpdateGridCells(false);
      };
    };
    this.GetProgressBarValue = function (Col, Row) {
      var Result = 0.0;
      var cp = null;
      Result = 0;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) return Result;
      if ($mod.TTMSFNCGridCellProgressBar.isPrototypeOf(cp.FControl)) Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellProgressBar).FValue;
      return Result;
    };
    this.IsProgressBar = function (Col, Row) {
      var Result = false;
      Result = this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellProgressBar);
      return Result;
    };
    this.RemoveProgressBar = function (Col, Row) {
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellProgressBar);
    };
    this.AddSummary = function (Row) {
      var cp = null;
      cp = this.GetIntObjects(this.FFixedColumns - 1,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(this.FFixedColumns - 1,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellSummary.$create("Create");
      this.SetIntObjects(this.FFixedColumns - 1,Row,cp);
    };
    this.RemoveSummary = function (Row) {
      this.RemoveCellControl(this.FFixedColumns - 1,Row,$mod.TTMSFNCGridCellSummary);
    };
    this.IsSummary = function (Row) {
      var Result = false;
      Result = this.IsCellControl(0,Row,$mod.TTMSFNCGridCellSummary);
      return Result;
    };
    this.AddNode = function (Row, Span) {
      var cp = null;
      if ((this.FFixedColumns - 1) >= 0) {
        cp = this.GetIntObjects(this.FFixedColumns - 1,Row);
        if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(this.FFixedColumns - 1,Row)]);
        if (cp.FControl != null) cp.FreeControl();
        cp.FControl = $mod.TTMSFNCGridCellNode.$create("Create");
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellNode).FSpan = Span;
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellNode).FState = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsOpen;
        this.SetIntObjects(this.FFixedColumns - 1,Row,cp);
        this.UpdateGridCells(false);
      };
    };
    this.RemoveNode = function (Row) {
      this.RemoveCellControl(this.FFixedColumns - 1,Row,$mod.TTMSFNCGridCellNode);
    };
    this.IsNode = function (Row) {
      var Result = false;
      Result = this.IsCellControl(this.FFixedColumns - 1,Row,$mod.TTMSFNCGridCellNode);
      return Result;
    };
    this.SetNodeState = function (Row, State) {
      var cp = null;
      cp = this.GetIntObjects(this.FFixedColumns - 1,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellNode.isPrototypeOf(cp.FControl)) {
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellNode).FState = State;
      };
    };
    this.GetNodeState = function (Row) {
      var Result = 0;
      var cn = null;
      Result = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsOpen;
      cn = this.GetNode(Row);
      if (cn != null) Result = cn.FState;
      return Result;
    };
    this.SetNodeSpan = function (Row, Span) {
      var cp = null;
      cp = this.GetIntObjects(this.FFixedColumns - 1,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellNode.isPrototypeOf(cp.FControl)) {
        rtl.as(cp.FControl,$mod.TTMSFNCGridCellNode).FSpan = Span;
      };
    };
    this.GetNodeSpan = function (Row) {
      var Result = 0;
      var cn = null;
      Result = -1;
      cn = this.GetNode(Row);
      if (cn != null) Result = cn.FSpan;
      return Result;
    };
    this.GetNode = function (Row) {
      var Result = null;
      var cp = null;
      Result = null;
      cp = this.GetIntObjects(this.FFixedColumns - 1,Row);
      if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellNode.isPrototypeOf(cp.FControl)) {
        Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellNode);
      };
      return Result;
    };
    this.OpenNode = function (Row) {
      var cn = null;
      cn = this.GetNode(Row);
      if (!(cn != null)) return;
      if (cn.FSpan !== -1) {
        if (cn.FState === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsClosed) {
          cn.FState = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsOpen;
          this.UnHideRows(Row + 1,cn.FSpan);
        };
      };
    };
    this.CloseNode = function (Row) {
      var cn = null;
      cn = this.GetNode(Row);
      if (!(cn != null)) return;
      if (cn.FSpan !== -1) {
        if (cn.FState === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsOpen) {
          cn.FState = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsClosed;
          this.HideRows(Row + 1,cn.FSpan);
        };
      };
    };
    this.OpenAllNodes = function () {
      var i = 0;
      var rr = 0;
      i = this.FFixedRows;
      while (i < (this.GetRowCount() - this.FFixedFooterRows)) {
        rr = this.DisplToRealRow(i);
        if (this.IsNode(rr)) this.OpenNode(rr);
        i += 1;
      };
      this.UpdateGridCells(false);
    };
    this.CloseAllNodes = function () {
      var i = 0;
      var rr = 0;
      i = this.FFixedRows;
      while (i < (this.GetRowCount() - this.FFixedFooterRows)) {
        rr = this.DisplToRealRow(i);
        if (this.IsNode(i)) this.CloseNode(rr);
        i += 1;
      };
      this.UpdateGridCells(false);
    };
    this.AddComboBox = function (Col, Row, Items) {
      var cp = null;
      cp = this.GetIntObjects(Col,Row);
      if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(Col,Row)]);
      if (cp.FControl != null) cp.FreeControl();
      cp.FControl = $mod.TTMSFNCGridCellCombo.$create("Create$1");
      rtl.as(cp.FControl,$mod.TTMSFNCGridCellCombo).FItems.Assign(Items);
      this.SetIntObjects(Col,Row,cp);
      this.UpdateGridCells(false);
    };
    this.RemoveComboBox = function (Col, Row) {
      this.RemoveCellControl(Col,Row,$mod.TTMSFNCGridCellCombo);
    };
    this.IsComboBox = function (Col, Row) {
      var Result = false;
      Result = this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellCombo);
      return Result;
    };
    this.GetComboIndex = function (Col, Row) {
      var Result = 0;
      var cp = null;
      Result = -1;
      if (this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellCombo)) {
        cp = this.GetIntObjects(Col,Row);
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellCombo.isPrototypeOf(cp.FControl)) Result = rtl.as(cp.FControl,$mod.TTMSFNCGridCellCombo).FItems.IndexOf(this.GetCells(Col,Row));
      };
      return Result;
    };
    this.SetComboIndex = function (Col, Row, Value) {
      var cp = null;
      if (Value === -1) {
        this.SetCells(Col,Row,"")}
       else if (this.IsCellControl(Col,Row,$mod.TTMSFNCGridCellCombo)) {
        cp = this.GetIntObjects(Col,Row);
        if ((cp != null) && (cp.FControl != null) && $mod.TTMSFNCGridCellCombo.isPrototypeOf(cp.FControl)) {
          if (Value < rtl.as(cp.FControl,$mod.TTMSFNCGridCellCombo).FItems.GetCount()) this.SetCells(Col,Row,rtl.as(cp.FControl,$mod.TTMSFNCGridCellCombo).FItems.Get(Value));
        };
      };
    };
    this.MergeSelection = function (ASelection) {
      this.MergeCells(ASelection.StartCol,ASelection.StartRow,(ASelection.EndCol - ASelection.StartCol) + 1,(ASelection.EndRow - ASelection.StartRow) + 1);
    };
    this.MergeCells = function (Col, Row, ColCount, RowCount) {
      var cp = null;
      var oldcp = null;
      var i = 0;
      var j = 0;
      var cl = $mod.TTMSFNCGridCellRec.$new();
      var usecp = false;
      this.FBlockUpdate = true;
      usecp = false;
      cp = null;
      for (var $l = Col, $end = (Col + ColCount) - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = Row, $end1 = (Row + RowCount) - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          if (!usecp) {
            cp = this.GetIntObjects(i,j);
            if (!(cp != null)) cp = $mod.TTMSFNCGridCellProperty.$create("Create$1",[this.GetDefaultFont(this.RealToDisplColumn(Col),this.RealToDisplRow(Row))]);
            cp.FBaseCol = Col;
            cp.FBaseRow = Row;
            cp.FColSpan = ColCount;
            cp.FRowSpan = RowCount;
            usecp = true;
          } else {
            oldcp = this.GetIntObjects(i,j);
            if (oldcp != null) {
              if (oldcp.FControl != null) oldcp.FreeControl();
              oldcp = rtl.freeLoc(oldcp);
            };
          };
          this.SetIntObjects(i,j,cp);
        };
      };
      cl.$assign(this.BaseCell(Col,Row));
      cl.Col = Col;
      cl.Row = Row;
      this.SetFocusedCell(cl);
      this.FBlockUpdate = false;
      this.UpdateGridCells(false);
    };
    this.IsMerged = function (Col, Row) {
      var Result = false;
      var cp = null;
      Result = false;
      cp = this.GetIntObjects(Col,this.DisplToRealRow(Row));
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) {
        Result = (cp.FColSpan > 1) || (cp.FRowSpan > 1);
      };
      return Result;
    };
    this.IsYMergedCell = function (Col, Row) {
      var Result = false;
      var cp = null;
      Result = false;
      cp = this.GetIntObjects(Col,this.DisplToRealRow(Row));
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) {
        Result = cp.FRowSpan > 1;
      };
      return Result;
    };
    this.IsXMergedCell = function (Col, Row) {
      var Result = false;
      var cp = null;
      Result = false;
      cp = this.GetIntObjects(Col,this.DisplToRealRow(Row));
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) {
        Result = cp.FColSpan > 1;
      };
      return Result;
    };
    this.IsBaseCell = function (Col, Row) {
      var Result = false;
      var c = $mod.TTMSFNCGridCellRec.$new();
      c.$assign(this.BaseCell(Col,Row));
      Result = (c.Col === Col) && (c.Row === Row);
      return Result;
    };
    this.ColSpan = function (Col, Row) {
      var Result = 0;
      var cp = null;
      Result = 0;
      cp = this.GetIntObjects(this.DisplToRealColumn(Col),this.DisplToRealRow(Row));
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) Result = cp.FColSpan;
      return Result;
    };
    this.RowSpan = function (Col, Row) {
      var Result = 0;
      var cp = null;
      Result = 0;
      cp = this.GetIntObjects(this.DisplToRealColumn(Col),this.DisplToRealRow(Row));
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) Result = cp.FRowSpan;
      return Result;
    };
    this.CellSpan = function (Col, Row) {
      var Result = pas.Types.TPoint.$new();
      var cp = null;
      Result.$assign(pas.Types.Point(0,0));
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) {
        Result.$assign(pas.Types.Point(cp.FColSpan,cp.FRowSpan));
      };
      return Result;
    };
    this.GetCellSize = function (Col, Row) {
      var Result = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      Result.cx = this.GetColWidths(Col);
      Result.cy = this.GetRowHeights(Row);
      return Result;
    };
    this.BaseCell = function (Col, Row) {
      var Result = $mod.TTMSFNCGridCellRec.$new();
      var cp = null;
      cp = this.GetIntObjects(this.DisplToRealColumn(Col),this.DisplToRealRow(Row));
      Result.Col = Col;
      Result.Row = Row;
      if ((cp != null) && (cp.FBaseCol !== -1) && (cp.FBaseRow !== -1)) {
        Result.Col = cp.FBaseCol;
        Result.Row = this.RealToDisplRow(cp.FBaseRow);
      };
      return Result;
    };
    this.IsBaseCellEx = function (Col, Row, BaseCol, BaseRow) {
      var Result = false;
      var c = $mod.TTMSFNCGridCellRec.$new();
      c.$assign(this.BaseCell(Col,Row));
      BaseCol.set(c.Col);
      BaseRow.set(c.Row);
      Result = (c.Col === Col) && (c.Row === Row);
      return Result;
    };
    this.SplitCell = function (Col, Row) {
      var cp = null;
      var i = 0;
      var j = 0;
      var fromc = 0;
      var toc = 0;
      var fromr = 0;
      var tor = 0;
      cp = this.GetIntObjects(Col,Row);
      if ((cp != null) && cp.IsBaseCell(Col,Row)) {
        fromc = cp.FBaseCol;
        fromr = cp.FBaseRow;
        toc = cp.FBaseCol + cp.FColSpan;
        tor = cp.FBaseRow + cp.FRowSpan;
        for (var $l = fromc, $end = toc - 1; $l <= $end; $l++) {
          i = $l;
          for (var $l1 = fromr, $end1 = tor - 1; $l1 <= $end1; $l1++) {
            j = $l1;
            cp = this.GetIntObjects(i,j);
            if (cp != null) {
              cp.FBaseCol = -1;
              cp.FBaseRow = -1;
              cp.FColSpan = 0;
              cp.FRowSpan = 0;
            };
            if (!((j === fromr) && (i === fromc))) this.SetIntObjects(i,j,null);
          };
        };
        this.UpdateGridCells(false);
      };
    };
    this.DeleteRow = function (Row) {
      this.DeleteRows(Row,1);
    };
    this.DeleteRows = function (Row, Count) {
      var i = 0;
      var j = 0;
      var ri = null;
      var cp = null;
      this.BeginUpdate();
      this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,Row,(this.GetColumnCount() - 1) + this.GetHiddenColCount(),(Row + Count) - 1)));
      for (var $l = Row, $end = this.FRowDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.GetColumnCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          if (this.IsBaseCell(j,i)) {
            cp = this.GetIntObjects(j,i);
            if (cp != null) if (cp.FBaseRow >= Row) {
              cp.FBaseRow = cp.FBaseRow - Count;
            };
          };
        };
      };
      while (this.FRowList.GetCount() < this.GetRowCount()) this.FRowList.Add(null);
      for (var $l2 = 1, $end2 = Count; $l2 <= $end2; $l2++) {
        i = $l2;
        if (this.FRowList.GetItem(Row) != null) {
          ri = this.FRowList.GetItem(Row);
          ri = rtl.freeLoc(ri);
        };
        if (Row < this.FRowList.GetCount()) this.FRowList.Delete(Row);
        if (Row < this.FRowDisplayList.GetCount()) this.FRowDisplayList.Delete(Row);
        this.FRowCount = this.FRowCount - 1;
      };
      for (var $l3 = Row, $end3 = this.FRowDisplayList.GetCount() - 1; $l3 <= $end3; $l3++) {
        i = $l3;
        this.FRowDisplayList.SetItem(i,this.FRowDisplayList.GetItem(i) - Count);
      };
      this.EndUpdate();
    };
    this.InsertRow = function (Row) {
      this.InsertRows(Row,1);
    };
    this.InsertRows = function (Row, Count) {
      var i = 0;
      var j = 0;
      var ridx = 0;
      var cp = null;
      if (Row > this.GetRowCount()) return;
      this.BeginUpdate();
      this.EnsureRow(Row);
      for (var $l = Row, $end = this.FRowDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        for (var $l1 = 0, $end1 = this.GetColumnCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          if (this.IsBaseCell(j,i)) {
            cp = this.GetIntObjects(j,i);
            if (cp != null) if (cp.FBaseRow >= Row) {
              cp.FBaseRow = cp.FBaseRow + Count;
            };
          };
        };
      };
      for (var $l2 = 1, $end2 = Count; $l2 <= $end2; $l2++) {
        i = $l2;
        this.FRowList.Insert(Row,$mod.TTMSFNCGridRowInfo.$create("Create$1"));
      };
      for (var $l3 = 1, $end3 = Count; $l3 <= $end3; $l3++) {
        i = $l3;
        this.FRowDisplayList.Insert(Row,(Row + i) - 1);
      };
      for (var $l4 = 1, $end4 = Count; $l4 <= $end4; $l4++) {
        i = $l4;
        this.FRowDisplayList.SetItem((Row + i) - 1,(Row + i) - 1);
      };
      for (var $l5 = Row + Count, $end5 = this.FRowDisplayList.GetCount() - 1; $l5 <= $end5; $l5++) {
        i = $l5;
        this.FRowDisplayList.SetItem(i,this.FRowDisplayList.GetItem(i) + Count);
      };
      if (!this.FInternalRowUpdate) {
        if (Row <= (this.FRowH.GetCount() - 1)) {
          ridx = this.FRowH.Insert$1(Row).GetIndex()}
         else ridx = this.FRowH.Add$1().GetIndex();
        if ((ridx >= 0) && (ridx <= (this.FRowH.GetCount() - 1))) {
          this.FRowH.GetItem$1(ridx).SetValue(this.FDefaultRowHeight);
          this.FRowH.GetItem$1(ridx).FCellVal = Row;
          for (var $l6 = ridx + 1, $end6 = this.FRowH.GetCount() - 1; $l6 <= $end6; $l6++) {
            i = $l6;
            this.FRowH.GetItem$1(i).FCellVal = this.FRowH.GetItem$1(i).FCellVal + 1;
          };
        };
      };
      this.FRowCount = this.FRowCount + Count;
      this.EndUpdate();
    };
    this.SwapCells = function (Col, Row1, Row2) {
      var v = "";
      var o = null;
      v = this.GetCells(Col,Row1);
      o = this.GetIntObjects(Col,Row1);
      this.SetCells(Col,Row1,this.GetCells(Col,Row2));
      this.SetIntObjects(Col,Row1,this.GetIntObjects(Col,Row2));
      this.SetCells(Col,Row2,v);
      this.SetIntObjects(Col,Row2,o);
    };
    this.SwapNormalCells = function (Row1, Row2) {
      var i = 0;
      var v = "";
      var o = null;
      for (var $l = this.FFixedColumns, $end = this.GetColumnCount() - this.FFixedRightColumns - 1; $l <= $end; $l++) {
        i = $l;
        v = this.GetCells(i,Row1);
        o = this.GetIntObjects(i,Row1);
        this.SetCells(i,Row1,this.GetCells(i,Row2));
        this.SetIntObjects(i,Row1,this.GetIntObjects(i,Row2));
        this.SetCells(i,Row2,v);
        this.SetIntObjects(i,Row2,o);
      };
    };
    this.SwapRows = function (Row1, Row2) {
      var item = null;
      var val1 = 0.0;
      var val2 = 0.0;
      var rr1 = 0;
      var rr2 = 0;
      var sel1 = false;
      var sel2 = false;
      rr1 = this.DisplToRealRow(Row1);
      rr2 = this.DisplToRealRow(Row2);
      item = this.FRowList.GetItem(rr1);
      this.FRowList.SetItem(rr1,this.FRowList.GetItem(rr2));
      this.FRowList.SetItem(rr2,item);
      val1 = this.GetRowHeights(Row1);
      val2 = this.GetRowHeights(Row2);
      this.SetRowHeights(Row1,val2);
      this.SetRowHeights(Row2,val1);
      sel1 = this.GetRowSelect(Row1);
      sel2 = this.GetRowSelect(Row2);
      this.SetRowSelect(Row1,sel2);
      this.SetRowSelect(Row2,sel1);
      this.UpdateGridCells(false);
    };
    this.MoveRow = function (FromRow, ToRow) {
      var rh = null;
      var si = null;
      var ii = 0;
      this.FRowList.Move(FromRow,ToRow);
      rh = $mod.TTMSFNCGridSList.$create("Create$1");
      try {
        for (var $l = 0, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
          ii = $l;
          rh.Add(this.GetRowHeights(ii));
        };
        rh.Move(FromRow,ToRow);
        this.FRowH.Clear();
        for (var $l1 = 0, $end1 = this.GetRowCount() - 1; $l1 <= $end1; $l1++) {
          ii = $l1;
          si = this.FRowH.Add$1();
          si.FCellVal = ii;
          si.SetValue(rh.GetItem(ii));
        };
      } finally {
        rh = rtl.freeLoc(rh);
      };
      this.UpdateControl(true,true);
    };
    this.HighlightInCell = function (DoCase, Col, Row, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetCellRecRange(Col,Row));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtHighlight;
      this.UpdateGridCells(false);
    };
    this.HighlightInCol = function (DoFixed, DoCase, Col, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetColumnRange(Col,DoFixed));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtHighlight;
      this.UpdateGridCells(false);
    };
    this.HighlightInRow = function (DoFixed, DoCase, Row, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetRowRange(Row,DoFixed));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtHighlight;
      this.UpdateGridCells(false);
    };
    this.HighlightInGrid = function (DoFixed, DoCase, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetGridRange(DoFixed));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtHighlight;
      this.UpdateGridCells(false);
    };
    this.UnHighlightInCell = function (Col, Row) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetCellRecRange(Col,Row)),$mod.TTMSFNCGridMarkType.mtHighlight);
      this.UpdateGridCells(false);
    };
    this.UnHighlightInCol = function (DoFixed, Col) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetColumnRange(Col,DoFixed)),$mod.TTMSFNCGridMarkType.mtHighlight);
      this.UpdateGridCells(false);
    };
    this.UnHighlightInRow = function (DoFixed, Row) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetRowRange(Row,DoFixed)),$mod.TTMSFNCGridMarkType.mtHighlight);
      this.UpdateGridCells(false);
    };
    this.UnHighlightInGrid = function (DoFixed) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetGridRange(DoFixed)),$mod.TTMSFNCGridMarkType.mtHighlight);
      this.UpdateGridCells(false);
    };
    this.UnHighlightAll = function () {
      var i = 0;
      for (var $l = this.FMarkList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.FMarkList.GetItem$1(i).FMarkType === $mod.TTMSFNCGridMarkType.mtHighlight) this.FMarkList.Delete(i);
      };
      this.UpdateGridCells(false);
    };
    this.MarkInCell = function (DoCase, Col, Row, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetCellRecRange(Col,Row));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtError;
      this.UpdateGridCells(false);
    };
    this.MarkInCol = function (DoFixed, DoCase, Col, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetColumnRange(Col,DoFixed));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtError;
      this.UpdateGridCells(false);
    };
    this.MarkInRow = function (DoFixed, DoCase, Row, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetRowRange(Row,DoFixed));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtError;
      this.UpdateGridCells(false);
    };
    this.MarkInGrid = function (DoFixed, DoCase, HiText) {
      var mi = null;
      mi = this.FMarkList.Add$1();
      mi.FCellRange.$assign(this.GetGridRange(DoFixed));
      mi.FValue = HiText;
      mi.FCaseSensitive = DoCase;
      mi.FMarkType = $mod.TTMSFNCGridMarkType.mtError;
      this.UpdateGridCells(false);
    };
    this.UnMarkInCell = function (Col, Row) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetCellRecRange(Col,Row)),$mod.TTMSFNCGridMarkType.mtError);
      this.UpdateGridCells(false);
    };
    this.UnMarkInCol = function (DoFixed, Col) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetColumnRange(Col,DoFixed)),$mod.TTMSFNCGridMarkType.mtError);
      this.UpdateGridCells(false);
    };
    this.UnMarkInRow = function (DoFixed, Row) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetRowRange(Row,DoFixed)),$mod.TTMSFNCGridMarkType.mtError);
      this.UpdateGridCells(false);
    };
    this.UnMarkInGrid = function (DoFixed) {
      this.FMarkList.RemoveMarker($mod.TTMSFNCGridCellRecRange.$clone(this.GetGridRange(DoFixed)),$mod.TTMSFNCGridMarkType.mtError);
      this.UpdateGridCells(false);
    };
    this.UnMarkAll = function () {
      var i = 0;
      for (var $l = this.FMarkList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.FMarkList.GetItem$1(i).FMarkType === $mod.TTMSFNCGridMarkType.mtError) this.FMarkList.Delete(i);
      };
      this.UpdateGridCells(false);
    };
    this.UnGroup = function () {
      var i = 0;
      var j = 0;
      var nc = "";
      var grpc = 0;
      if (this.FGroupColumn <= 0) return;
      this.BeginUpdate();
      this.OpenAllNodes();
      if (this.FGroupColumn === 1) {
        grpc = 2}
       else grpc = 1;
      i = this.FFixedRows;
      this.FIsGrouping = true;
      while (i <= (this.GetRowCount() - 1 - this.FFixedFooterRows)) {
        if (this.IsNode(i)) {
          if (this.FOptions.FGrouping.FMergeHeader) this.SplitCell(this.FFixedColumns,i);
          if (this.FOptions.FGrouping.FMergeSummary) {
            j = this.GetNodeSpan(i);
            this.SplitCell(this.FFixedColumns,i + j + 1);
          };
        };
        if (this.IsSummary(i)) this.RemoveSummary(i);
        i += 1;
      };
      this.FInternalColumnUpdate = true;
      this.InsertColumn(this.FGroupColumn);
      this.FInternalColumnUpdate = false;
      this.SetColWidths(this.FGroupColumn,this.FGroupWidth);
      if (this.FFixedRows > 0) this.SetCells(this.FGroupColumn,0,this.FGroupCaption);
      if (this.FFixedFooterRows > 0) this.SetCells(this.FGroupColumn,this.GetRowCount() - 1,this.FGroupFooter);
      i = this.FFixedRows;
      this.FIsGrouping = true;
      while (i <= (this.GetRowCount() - 1 - this.FFixedFooterRows)) {
        if (this.IsNode(i)) {
          if (this.FOptions.FGrouping.FSummary) {
            j = this.GetNodeSpan(i);
            this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,i + j + 1,this.GetColumnCount() - 1,i + j + 1)));
            this.DeleteRows(i + j + 1,1);
          };
          nc = this.GetCells(grpc,i);
          this.RemoveNode(i);
          this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,i,this.GetColumnCount() - 1,i)));
          this.DeleteRows(i,1);
        } else {
          this.SetCells(this.FGroupColumn,i,nc);
          i += 1;
        };
      };
      this.FIsGrouping = false;
      this.FGroupColumn = -1;
      this.EndUpdate();
    };
    this.Group = function (Column) {
      var i = 0;
      var np = 0;
      var lc = "";
      var nc = "";
      var grp = 0;
      var grpc = 0;
      if (Column < this.FFixedColumns) return;
      if (this.FGroupColumn !== -1) this.UnGroup();
      if ((this.GetRowCount() - this.FFixedRows) < 1) return;
      this.BeginUpdate();
      this.FIsGrouping = true;
      try {
        this.FGroupColumn = Column;
        this.FGroupWidth = this.GetColWidths(Column);
        if (this.FFixedRows > 0) this.FGroupCaption = this.GetCells(Column,0);
        if (this.FFixedFooterRows > 0) this.FGroupFooter = this.GetCells(Column,this.GetRowCount() - 1);
        grp = Column;
        grpc = 1;
        if (grpc === Column) grpc += 1;
        np = -1;
        lc = String.fromCharCode(255) + String.fromCharCode(254);
        i = this.FFixedRows;
        while (i <= (this.GetRowCount() - 1 - this.FFixedFooterRows)) {
          nc = this.GetCells(Column,i);
          if (lc !== nc) {
            if (np !== -1) {
              if ((np > this.FFixedRows) && this.FOptions.FGrouping.FSummary) {
                this.FInternalRowUpdate = true;
                this.InsertRows(np,1);
                this.FInternalRowUpdate = false;
                this.AddSummary(np);
                np += 1;
                this.AddNode(np,i - np);
                i += 1;
              } else {
                this.AddNode(np,i - np - 1);
              };
            };
            this.FInternalRowUpdate = true;
            this.InsertRows(i,1);
            this.FInternalRowUpdate = false;
            this.SetCells(grpc,i,nc);
            np = i;
            i += 1;
          };
          if (i < (this.GetRowCount() - 1)) lc = this.GetCells(grp,i);
          i += 1;
        };
        if (np !== -1) {
          if ((np > this.FFixedRows) && this.FOptions.FGrouping.FSummary) {
            this.FInternalRowUpdate = true;
            this.InsertRows(np,1);
            this.FInternalRowUpdate = false;
            this.AddSummary(np);
            np += 1;
            i += 1;
          };
          this.AddNode(np,i - np - 1);
        } else this.AddNode(this.FFixedRows,i - 1 - 1);
        if (this.FOptions.FGrouping.FSummary) {
          this.FInternalRowUpdate = true;
          this.InsertRows(i,1);
          this.FInternalRowUpdate = false;
          this.AddSummary(i);
        };
        this.DeleteColumn(grp);
        if (this.FOptions.FGrouping.FMergeHeader || (this.FOptions.FGrouping.FMergeSummary && this.FOptions.FGrouping.FSummary)) {
          for (var $l = this.FFixedRows, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
            i = $l;
            grpc = 1;
            if (this.IsNode(i) && this.FOptions.FGrouping.FMergeHeader) {
              this.MergeCells(grpc,i,this.GetColumnCount() - grpc - this.FFixedRightColumns,1);
            };
            if ((this.IsNode(i + 1) || (i === (this.GetRowCount() - 1))) && this.FOptions.FGrouping.FMergeSummary && this.FOptions.FGrouping.FSummary) {
              this.MergeCells(grpc,i,this.GetColumnCount() - grpc - this.FFixedRightColumns,1);
            };
          };
        };
      } finally {
        this.FIsGrouping = false;
        this.EndUpdate();
      };
    };
    this.GroupCalc = function (Col, method) {
      var i = 0;
      var j = 0;
      var k = 0;
      var r = 0.0;
      i = this.FFixedRows;
      while (i < this.GetRowCount()) {
        if (this.IsNode(i)) {
          j = i + this.GetNodeSpan(i);
          if (this.FOptions.FGrouping.FSummary) {
            k = i + this.GetNodeSpan(i) + 1}
           else k = i + 1;
          r = 0;
          var $tmp = method;
          if ($tmp === 1) {
            r = this.ColumnSum(Col,i + 1,j)}
           else if ($tmp === 2) {
            r = this.ColumnAvg(Col,i + 1,j)}
           else if ($tmp === 3) {
            r = this.ColumnMin(Col,i + 1,j)}
           else if ($tmp === 4) {
            r = this.ColumnMax(Col,i + 1,j)}
           else if ($tmp === 5) {
            r = j - i}
           else if ($tmp === 6) {
            r = this.ColumnCustomCalcGroup(Col,i + 1,j)}
           else if ($tmp === 7) {
            r = this.ColumnDistinct(Col,i + 1,j)}
           else if ($tmp === 8) r = this.ColumnStdDev(Col,i + 1,j);
          this.SetCells(Col,k,pas.SysUtils.Format(this.FOptions.FGrouping.FCalcFormat,pas.System.VarRecs(3,r)));
          i = j;
        } else i += 1;
      };
      this.UpdateGridCells(false);
    };
    this.GroupSum = function (Col) {
      this.GroupCalc(Col,1);
    };
    this.GroupAvg = function (Col) {
      this.GroupCalc(Col,2);
    };
    this.GroupMin = function (Col) {
      this.GroupCalc(Col,3);
    };
    this.GroupMax = function (Col) {
      this.GroupCalc(Col,4);
    };
    this.ColumnSum = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      var i = 0;
      var sum = 0.0;
      if ((FromRow === -1) || (ToRow === -1)) {
        FromRow = this.FFixedRows;
        ToRow = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      sum = 0;
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,FromRow);
      for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
        i = $l;
        if (this.IsBaseCell(ACol,i)) {
          this.ExportNotification($mod.TTMSFNCGridExportState.esExportNextRow,i);
          try {
            sum = sum + this.GetFloats(ACol,i);
          } catch ($e) {
          };
        };
      };
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
      Result = sum;
      return Result;
    };
    this.ColumnAvg = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      if ((FromRow === -1) || (ToRow === -1)) {
        FromRow = this.FFixedRows;
        ToRow = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      if (((ToRow - FromRow) + 1) > 0) {
        Result = this.ColumnSum(ACol,FromRow,ToRow) / ((ToRow - FromRow) + 1)}
       else Result = 0;
      return Result;
    };
    this.ColumnMin = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      var m = 0.0;
      var i = 0;
      if ((FromRow === -1) || (ToRow === -1)) {
        FromRow = this.FFixedRows;
        ToRow = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      m = this.GetFloats(ACol,FromRow);
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,FromRow);
      for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
        i = $l;
        if (this.IsBaseCell(ACol,i)) {
          this.ExportNotification($mod.TTMSFNCGridExportState.esExportNextRow,i);
          try {
            if (m > this.GetFloats(ACol,i)) m = this.GetFloats(ACol,i);
          } catch ($e) {
          };
        };
      };
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
      Result = m;
      return Result;
    };
    this.ColumnMax = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      var m = 0.0;
      var i = 0;
      if ((FromRow === -1) || (ToRow === -1)) {
        FromRow = this.FFixedRows;
        ToRow = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      m = this.GetFloats(ACol,FromRow);
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,FromRow);
      for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
        i = $l;
        if (this.IsBaseCell(ACol,i)) {
          this.ExportNotification($mod.TTMSFNCGridExportState.esExportNextRow,i);
          try {
            if (m < this.GetFloats(ACol,i)) m = this.GetFloats(ACol,i);
          } catch ($e) {
          };
        };
      };
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
      Result = m;
      return Result;
    };
    this.ColumnDistinct = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      var sl = null;
      var i = 0;
      if ((FromRow === -1) || (ToRow === -1)) {
        FromRow = this.FFixedRows;
        ToRow = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,FromRow);
      sl = pas.Classes.TStringList.$create("Create$1");
      try {
        sl.FDuplicates = pas.Types.TDuplicates.dupIgnore;
        sl.SetSorted(true);
        sl.SetCaseSensitive(false);
        for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
          i = $l;
          this.ExportNotification($mod.TTMSFNCGridExportState.esExportNextRow,i);
          sl.Add(this.GetCells(ACol,i));
        };
        Result = sl.GetCount();
      } finally {
        this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
        sl = rtl.freeLoc(sl);
      };
      return Result;
    };
    this.ColumnStdDev = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      var m = 0.0;
      var d = 0.0;
      var i = 0;
      if ((FromRow === -1) || (ToRow === -1)) {
        FromRow = this.FFixedRows;
        ToRow = this.GetRowCount() - 1 - this.FFixedFooterRows;
      };
      m = this.ColumnAvg(ACol,FromRow,ToRow);
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportStart,FromRow);
      d = 0;
      for (var $l = FromRow, $end = ToRow; $l <= $end; $l++) {
        i = $l;
        d = d + pas.System.Sqr$1(this.GetFloats(ACol,i) - m);
      };
      Result = Math.sqrt(d / ((ToRow - FromRow) + 1));
      this.ExportNotification($mod.TTMSFNCGridExportState.esExportDone,-1);
      return Result;
    };
    this.ColumnCustomCalc = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      Result = this.DoColumnCalc(ACol,FromRow,ToRow);
      return Result;
    };
    this.ColumnCustomCalcGroup = function (ACol, FromRow, ToRow) {
      var Result = 0.0;
      Result = this.DoColumnCalcGroup(ACol,FromRow,ToRow);
      return Result;
    };
    this.UpdateCalculations = function () {
      var i = 0;
      var cc = 0;
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        i = $l;
        cc = this.GetColumnCalculation(i);
        if (cc !== $mod.TTMSFNCGridColumnCalculation.ccNone) this.UpdateColumnCalc(i,cc);
      };
    };
    this.UpdateCalculation = function (ACol) {
      var cc = 0;
      cc = this.GetColumnCalculation(ACol);
      if (cc !== $mod.TTMSFNCGridColumnCalculation.ccNone) this.UpdateColumnCalc(ACol,cc);
    };
    this.GroupCustomCalc = function (Col) {
      this.GroupCalc(Col,6);
    };
    this.GroupCount = function (Col) {
      this.GroupCalc(Col,5);
    };
    this.GroupDistinct = function (Col) {
      this.GroupCalc(Col,7);
    };
    this.GroupStdDev = function (Col) {
      this.GroupCalc(Col,8);
    };
    this.HideRow = function (Row) {
      var i = 0;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FRowDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FRowDisplayList.GetItem(i) === Row) {
          this.FHiddenRowList.Add(Row);
          this.FRowDisplayList.Delete(i);
          this.FRowCount = this.FRowCount - 1;
          break;
        };
      };
      this.EndUpdate();
    };
    this.HideRows = function (Row, Count) {
      var i = 0;
      var c = 0;
      var flg = false;
      c = 0;
      i = 0;
      flg = false;
      while (i < this.FRowDisplayList.GetCount()) {
        if (this.FRowDisplayList.GetItem(i) === (Row + c)) {
          this.FHiddenRowList.Add(Row + c);
          this.FRowDisplayList.Delete(i);
          this.FRowCount = this.FRowCount - 1;
          flg = true;
          if (c < (Count - 1)) {
            c += 1}
           else break;
        } else i += 1;
      };
      if (flg) this.UpdateControl(true,true);
    };
    this.UnHideRow = function (Row) {
      var i = 0;
      var fnd = false;
      if (!this.IsHiddenRow(Row)) return;
      i = 0;
      fnd = this.FHiddenRowList.GetCount() > 0;
      while (i < this.FRowDisplayList.GetCount()) {
        if (this.FRowDisplayList.GetItem(i) >= Row) {
          fnd = true;
          break;
        } else i += 1;
      };
      if (fnd) {
        this.FRowDisplayList.Insert(i,Row);
        this.FHiddenRowList.Delete(this.FHiddenRowList.IndexOf(Row));
        this.FRowCount = this.FRowCount + 1;
        this.UpdateGridCells(false);
      };
    };
    this.UnHideRows = function (Row, Count) {
      var i = 0;
      var j = 0;
      var nr = 0;
      var ri = 0;
      var fnd = false;
      if (this.FHiddenRowList.GetCount() === 0) return;
      i = 0;
      nr = 0;
      if ((this.FRowDisplayList.GetCount() === 0) || (Row > this.FRowDisplayList.GetItem(this.FRowDisplayList.GetCount() - 1))) {
        for (var $l = 0, $end = Math.max(0,Count - 1); $l <= $end; $l++) {
          i = $l;
          if (this.FHiddenRowList.IndexOf(i + Row) !== -1) {
            nr += 1;
            this.FRowDisplayList.Add(i + Row);
            this.FHiddenRowList.Delete(this.FHiddenRowList.IndexOf(i + Row));
          };
        };
        this.FRowCount = this.FRowCount + nr;
        this.UpdateControl(true,true);
        return;
      };
      fnd = false;
      while (i < this.FRowDisplayList.GetCount()) {
        if (this.FRowDisplayList.GetItem(i) >= Row) {
          fnd = true;
          break;
        } else i += 1;
      };
      if (fnd) {
        ri = this.FHiddenRowList.IndexOf(Row);
        if (ri >= 0) {
          this.FRowDisplayList.Insert(i,Row);
          this.FHiddenRowList.Delete(ri);
          this.FRowCount = this.FRowCount + 1;
          j = 1;
          i += 1;
          while (j <= Count) {
            if (this.FRowDisplayList.GetItem(i) !== (Row + j)) {
              ri = this.FHiddenRowList.IndexOf(Row + j);
              if (ri >= 0) {
                this.FRowDisplayList.Insert(i,Row + j);
                this.FHiddenRowList.Delete(ri);
                this.FRowCount = this.FRowCount + 1;
              };
            };
            i += 1;
            j += 1;
          };
        };
      };
      if (fnd) this.UpdateControl(true,true);
    };
    this.UnHideRowsAll = function () {
      var i = 0;
      while (this.FRowDisplayList.GetCount() < this.FRowList.GetCount()) {
        this.FRowDisplayList.Add(0);
      };
      for (var $l = 0, $end = this.FRowList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FRowDisplayList.SetItem(i,i);
      };
      this.FRowCount = this.FRowList.GetCount();
      this.UpdateControl(true,true);
    };
    this.IsHiddenRow = function (Row) {
      var Result = false;
      var i = 0;
      Result = false;
      for (var $l = 0, $end = this.FHiddenRowList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FHiddenRowList.GetItem(i) === Row) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.UpdateColumnWidth = function (ACol, AWidth) {
      this.BeginUpdate();
      this.SetColWidths(ACol,AWidth);
      this.EndUpdate();
    };
    this.UpdateRowHeight = function (ARow, AHeight) {
      this.BeginUpdate();
      this.SetRowHeights(ARow,AHeight);
      this.EndUpdate();
    };
    this.HideColumn = function (Col) {
      var i = 0;
      var fnd = false;
      if (this.IsHiddenColumn(Col)) return;
      fnd = false;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FColumnDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FColumnDisplayList.GetItem(i) === Col) {
          this.FHiddenColumnList.Add(Col);
          this.FColumnDisplayList.Delete(i);
          fnd = true;
          break;
        };
      };
      if (fnd) this.FColumnCount = this.FColumnCount - 1;
      this.EndUpdate();
    };
    this.HideColumns = function (Col, Count) {
      var i = 0;
      var c = 0;
      this.BeginUpdate();
      c = 0;
      i = 0;
      while (i < this.FColumnDisplayList.GetCount()) {
        if ((this.FColumnDisplayList.GetItem(i) === (Col + c)) && (c < Count)) {
          this.FHiddenColumnList.Add(Col + c);
          this.FColumnDisplayList.Delete(i);
          c += 1;
        } else i += 1;
      };
      this.FColumnCount = this.FColumnCount - c;
      this.EndUpdate();
    };
    this.UnHideColumn = function (Col) {
      var i = 0;
      var fnd = false;
      if (!this.IsHiddenColumn(Col) || (this.FHiddenColumnList.GetCount() === 0)) return;
      i = 0;
      fnd = this.FHiddenColumnList.IndexOf(Col) !== -1;
      while (i < this.FColumnDisplayList.GetCount()) {
        if (this.FColumnDisplayList.GetItem(i) >= Col) {
          fnd = true;
          break;
        } else i += 1;
      };
      if (fnd) {
        this.FColumnDisplayList.Insert(i,Col);
        this.FHiddenColumnList.Delete(this.FHiddenColumnList.IndexOf(Col));
        this.SetColumnCount(this.GetColumnCount() + 1);
        this.UpdateGridCells(false);
      };
    };
    this.UnHideColumns = function (Col, Count) {
      var i = 0;
      for (var $l = Col, $end = (Col + Count) - 1; $l <= $end; $l++) {
        i = $l;
        this.UnHideColumn(i);
      };
    };
    this.UnHideColumnsAll = function () {
      var i = 0;
      this.BeginUpdate();
      while (this.FColumnDisplayList.GetCount() < this.GetTotalColCount()) {
        this.FColumnDisplayList.Add(0);
      };
      for (var $l = 0, $end = this.GetTotalColCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FColumnDisplayList.SetItem(i,i);
      };
      this.FColumnCount = this.GetTotalColCount();
      this.FHiddenColumnList.Clear();
      this.EndUpdate();
    };
    this.IsHiddenColumn = function (Col) {
      var Result = false;
      var i = 0;
      Result = true;
      for (var $l = 0, $end = this.FColumnDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FColumnDisplayList.GetItem(i) === Col) {
          Result = false;
          break;
        };
      };
      return Result;
    };
    this.SuppressColumn = function (Col) {
      var i = 0;
      if (this.IsSuppressedColumn(Col)) return;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FColumnDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FColumnDisplayList.GetItem(i) === Col) {
          this.FSuppressedColumnList.Add(Col);
          break;
        };
      };
      this.EndUpdate();
    };
    this.SuppressColumns = function (Col, Count) {
      var i = 0;
      var c = 0;
      this.BeginUpdate();
      c = 0;
      i = 0;
      while (i < this.FColumnDisplayList.GetCount()) {
        if ((this.FColumnDisplayList.GetItem(i) === (Col + c)) && (c < Count)) {
          this.FSuppressedColumnList.Add(Col + c);
          c += 1;
        } else i += 1;
      };
      this.EndUpdate();
    };
    this.UnSuppressColumn = function (Col) {
      var i = 0;
      var fnd = false;
      if (!this.IsSuppressedColumn(Col) || (this.FSuppressedColumnList.GetCount() === 0)) return;
      i = 0;
      fnd = this.FSuppressedColumnList.IndexOf(Col) !== -1;
      while (i < this.FColumnDisplayList.GetCount()) {
        if (this.FColumnDisplayList.GetItem(i) >= Col) {
          fnd = true;
          break;
        } else i += 1;
      };
      if (fnd) {
        this.FSuppressedColumnList.Delete(this.FSuppressedColumnList.IndexOf(Col));
        this.UpdateGridCells(false);
      };
    };
    this.UnSuppressColumns = function (Col, Count) {
      var i = 0;
      for (var $l = Col, $end = (Col + Count) - 1; $l <= $end; $l++) {
        i = $l;
        this.UnSuppressColumn(i);
      };
    };
    this.UnSuppressColumnsAll = function () {
      this.BeginUpdate();
      this.FSuppressedColumnList.Clear();
      this.EndUpdate();
    };
    this.IsSuppressedColumn = function (Col) {
      var Result = false;
      var i = 0;
      Result = false;
      for (var $l = 0, $end = this.FSuppressedColumnList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FSuppressedColumnList.GetItem(i) === Col) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.DeleteColumn = function (Col) {
      var i = 0;
      var rc = 0;
      this.BeginUpdate();
      rc = this.DisplToRealColumn(Col);
      for (var $l = Col, $end = this.FColumnDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FColumnDisplayList.GetItem(i) > Col) this.FColumnDisplayList.SetItem(i,this.FColumnDisplayList.GetItem(i) - 1);
      };
      this.FColumnDisplayList.Delete(Col);
      this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(rc,0,rc,this.GetRowCount() - 1)));
      for (var $l1 = 0, $end1 = this.FRowList.GetCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        if ((this.FRowList.GetItem(i) != null) && (this.FRowList.GetItem(i).FData.GetCount() > rc)) this.FRowList.GetItem(i).FData.Delete(rc);
      };
      this.SetColumnCount(this.GetColumnCount() - 1);
      this.EndUpdate();
    };
    this.InsertColumn = function (Col) {
      var i = 0;
      var sl = null;
      var cidx = 0;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FRowList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        sl = this.FRowList.GetItem(i);
        if (sl != null) {
          if (Col < sl.FData.GetCount()) sl.FData.InsertObject(Col,"",null);
        };
      };
      if (!this.FInternalColumnUpdate) {
        if (Col <= (this.FColumnW.GetCount() - 1)) {
          cidx = this.FColumnW.Insert$1(Col).GetIndex()}
         else cidx = this.FColumnW.Add$1().GetIndex();
        if ((cidx >= 0) && (cidx <= (this.FColumnW.GetCount() - 1))) {
          this.FColumnW.GetItem$1(cidx).SetValue(this.FDefaultColumnWidth);
          this.FColumnW.GetItem$1(cidx).FCellVal = Col;
          for (var $l1 = cidx + 1, $end1 = this.FColumnW.GetCount() - 1; $l1 <= $end1; $l1++) {
            i = $l1;
            this.FColumnW.GetItem$1(i).FCellVal = this.FColumnW.GetItem$1(i).FCellVal + 1;
          };
        };
      };
      this.EndUpdate();
      this.FColumnDisplayList.Insert(Col,Col);
      for (var $l2 = Col + 1, $end2 = this.FColumnDisplayList.GetCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        this.FColumnDisplayList.SetItem(i,this.FColumnDisplayList.GetItem(i) + 1);
      };
      this.SetColumnCount(this.GetColumnCount() + 1);
    };
    this.MoveColumn = function (FromCol, ToCol) {
      var rfi = 0;
      var rti = 0;
      var ii = 0;
      var si = null;
      var cw = null;
      if (this.FColumnOrder.GetCount() === 0) this.SetColumnOrder();
      this.FColumnDisplayList.Move(FromCol,ToCol);
      cw = $mod.TTMSFNCGridSList.$create("Create$1");
      try {
        for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
          ii = $l;
          cw.Add(this.GetColWidths(ii));
        };
        cw.Move(FromCol,ToCol);
        this.FColumnW.Clear();
        for (var $l1 = 0, $end1 = this.GetColumnCount() - 1; $l1 <= $end1; $l1++) {
          ii = $l1;
          si = this.FColumnW.Add$1();
          si.FCellVal = ii;
          si.SetValue(cw.GetItem(ii));
        };
      } finally {
        cw = rtl.freeLoc(cw);
      };
      rfi = FromCol;
      rti = ToCol;
      if ((this.FColumnOrder.GetCount() > rfi) && (this.FColumnOrder.GetCount() > rti)) {
        ii = this.FColumnOrder.GetInteger(rfi);
        this.FColumnOrder.Delete$1(rfi);
        this.FColumnOrder.Insert$1(rti,ii);
      };
      this.UpdateControl(true,true);
    };
    this.SwapColumns = function (Col1, Col2) {
      var i = 0;
      var k = 0;
      var v = "";
      var o = null;
      var val1 = 0.0;
      var val2 = 0.0;
      var cc = 0;
      for (var $l = 0, $end = this.FRowList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FRowList.GetItem(i) != null) {
          for (var $l1 = this.FRowList.GetItem(i).FData.GetCount(), $end1 = Col1; $l1 <= $end1; $l1++) {
            k = $l1;
            this.FRowList.GetItem(i).FData.Add("");
          };
          for (var $l2 = this.FRowList.GetItem(i).FData.GetCount(), $end2 = Col2; $l2 <= $end2; $l2++) {
            k = $l2;
            this.FRowList.GetItem(i).FData.Add("");
          };
          v = this.FRowList.GetItem(i).FData.Get(Col1);
          o = this.FRowList.GetItem(i).FData.GetObject(Col1);
          this.FRowList.GetItem(i).FData.Put(Col1,this.FRowList.GetItem(i).FData.Get(Col2));
          this.FRowList.GetItem(i).FData.PutObject(Col1,this.FRowList.GetItem(i).FData.GetObject(Col2));
          this.FRowList.GetItem(i).FData.Put(Col2,v);
          this.FRowList.GetItem(i).FData.PutObject(Col2,o);
        };
      };
      val1 = this.GetColWidths(Col1);
      val2 = this.GetColWidths(Col2);
      this.SetColWidths(Col1,val2);
      this.SetColWidths(Col2,val1);
      cc = this.GetColumnCalculation(Col1);
      this.SetColumnCalculation(Col1,this.GetColumnCalculation(Col2));
      this.SetColumnCalculation(Col2,cc);
      this.UpdateGridCells(false);
    };
    this.SortData = function (Column, Direction) {
      var fltr = false;
      this.FBlockUpdate = true;
      fltr = false;
      if (this.FFilterApplied) {
        this.RemoveFilter();
        fltr = true;
      };
      this.FSortColumn = Column;
      this.FSortDirection = Direction;
      this.FRowCount = this.FRowCount + 1;
      this.QuickSortRows(this.FSortColumn,this.FFixedRows,this.FRowCount - 2 - this.FFixedFooterRows);
      this.DeleteRow(this.GetRowCount() - 1);
      if (fltr) this.ApplyFilter();
      this.FBlockUpdate = false;
      this.UpdateGridCells(false);
    };
    this.SortIndexed = function () {
      var rdl = 0;
      var rl = 0;
      var ri = null;
      var fltr = false;
      if (this.FSortIndexes.GetCount() === 0) throw pas.SysUtils.Exception.$create("Create$1",["No indexes specified for indexed sort"]);
      fltr = false;
      if (this.FFilterApplied) {
        this.RemoveFilter();
        fltr = true;
      };
      this.BeginUpdate();
      try {
        rdl = this.FRowDisplayList.GetCount();
        rl = this.FRowList.GetCount();
        this.FRowCount = this.FRowCount + 1;
        this.QuickSortRowsIndexed(0,this.FFixedRows,this.FRowCount - 2 - this.FFixedFooterRows);
        this.ClearCells($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,this.GetRowCount() - 1,this.GetColumnCount() - 1,this.GetRowCount() - 1)));
        this.FRowCount = this.FRowCount - 1;
        while (rdl < this.FRowDisplayList.GetCount()) {
          this.FRowDisplayList.Delete(this.FRowDisplayList.GetCount() - 1);
        };
        while (rl < this.FRowList.GetCount()) {
          ri = this.FRowList.GetItem(this.FRowList.GetCount() - 1);
          ri = rtl.freeLoc(ri);
          this.FRowList.Delete(this.FRowList.GetCount() - 1);
        };
      } finally {
        if (fltr) this.ApplyFilter();
        this.EndUpdate();
      };
      this.UpdateGridCells(false);
    };
    this.SortGrouped = function (Column, Direction) {
      this.FSortColumn = Column;
      this.FSortDirection = Direction;
      this.SortGroupedInt(false);
    };
    this.SortGroupedIndexed = function () {
      this.SortGroupedInt(true);
    };
    this.CopyToClipboard = function (SelectedCells) {
    };
    this.CutToClipboard = function (SelectedCells) {
    };
    this.PasteFromClipboard = function () {
    };
    this.LoadFromCSV = function (FileName, MaxRows) {
      this.InputFromCSV(FileName,null,false,MaxRows);
    };
    this.InsertFromCSV = function (FileName, MaxRows) {
      this.InputFromCSV(FileName,null,true,MaxRows);
    };
    this.LoadFromCSV$1 = function (FileName, Encoding, MaxRows) {
      this.InputFromCSV(FileName,Encoding,false,MaxRows);
    };
    this.InsertFromCSV$1 = function (FileName, Encoding, MaxRows) {
      this.InputFromCSV(FileName,Encoding,true,MaxRows);
    };
    this.LoadFromCSVStream = function (AStream, MaxRows) {
      this.InputFromCSVStream(AStream,null,false,MaxRows);
    };
    this.InsertFromCSVStream = function (AStream, MaxRows) {
      this.InputFromCSVStream(AStream,null,true,MaxRows);
    };
    this.LoadFromCSVStream$1 = function (AStream, Encoding, MaxRows) {
      this.InputFromCSVStream(AStream,Encoding,false,MaxRows);
    };
    this.InsertFromCSVStream$1 = function (AStream, Encoding, MaxRows) {
      this.InputFromCSVStream(AStream,Encoding,true,MaxRows);
    };
    this.LoadFromFile = function (FileName) {
      var $Self = this;
      var X = 0;
      var Y = 0;
      var CW = 0;
      var ss = "";
      var ss1 = "";
      var strtCol = 0;
      var strtRow = 0;
      var oprogr = 0;
      var seppos = 0;
      var sl = null;
      function MStrToInt(s) {
        var Result = 0;
        var code = 0;
        var i = 0;
        pas.System.val$6(s,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }},{get: function () {
            return code;
          }, set: function (v) {
            code = v;
          }});
        Result = i;
        return Result;
      };
      sl = $mod.TTMSFNCGridFileStringList.$create("Create$1");
      sl.LoadFromFile(FileName);
      strtCol = 0;
      strtRow = 0;
      ss = "";
      sl.ReadLn({get: function () {
          return ss;
        }, set: function (v) {
          ss = v;
        }});
      if (ss !== "") {
        ss1 = pas.System.Copy(ss,1,pas["WEBLib.TMSFNCGridDataUtil"].CharPos(",",ss) - 1);
        this.SetColumnCount(MStrToInt(ss1) + strtCol);
        ss1 = pas.System.Copy(ss,pas["WEBLib.TMSFNCGridDataUtil"].CharPos(",",ss) + 1,ss.length);
        this.FRowCount = MStrToInt(ss1) + strtRow;
      };
      if ((this.GetColumnCount() === 0) || (this.FRowCount === 0)) {
        sl = rtl.freeLoc(sl);
        throw pas.SysUtils.Exception.$create("Create$1",["File contains no data or corrupt file " + FileName]);
      };
      this.BeginUpdate();
      try {
        this.SetCells(this.GetColumnCount() - 1,this.FRowCount - 1,"");
        oprogr = 1;
        while (!sl.GetEOF()) {
          sl.ReadLn({get: function () {
              return ss;
            }, set: function (v) {
              ss = v;
            }});
          if (pas.System.Pos("cw",ss) === 1) {
            seppos = pas["WEBLib.TMSFNCGridDataUtil"].CharPos(",",ss);
            ss1 = pas.System.Copy(ss,4,seppos - 4);
            ss = pas.System.Copy(ss,seppos + 1,255);
            CW = MStrToInt(ss1);
            if ((CW >= 0) && (CW < this.GetColumnCount())) this.SetColWidths(CW,MStrToInt(ss));
          } else {
            ss1 = pas["WEBLib.TMSFNCGridDataUtil"].GetToken({get: function () {
                return ss;
              }, set: function (v) {
                ss = v;
              }},",");
            X = MStrToInt(ss1);
            ss1 = pas["WEBLib.TMSFNCGridDataUtil"].GetToken({get: function () {
                return ss;
              }, set: function (v) {
                ss = v;
              }},",");
            Y = MStrToInt(ss1);
            if ((X < this.GetColumnCount()) && (Y < this.FRowCount)) {
              ss = pas["WEBLib.TMSFNCGridDataUtil"].FileToLf(ss,true);
              this.DoLoadCell(X,Y,{get: function () {
                  return ss;
                }, set: function (v) {
                  ss = v;
                }});
            };
          };
          oprogr += 1;
          this.DoIOProgress(oprogr,sl.GetCount());
        };
      } finally {
        sl = rtl.freeLoc(sl);
        this.DoCellsChanged($mod.TTMSFNCGridCellRecRange.$clone(this.CellRange(0,0,this.GetColumnCount() - 1,this.GetRowCount() - 1)));
        this.EndUpdate();
      };
    };
    this.LoadXMLFromStream = function (AStream, LoadFieldDescr, IgnoreFixedColumns) {
      var s = null;
      s = pas.Classes.TStringStream.$create("Create$2",[""]);
      try {
        AStream.SetPosition(0);
        s.CopyFrom(AStream,AStream.GetSize());
        this.LoadXMLFromText(s.GetDataString(),LoadFieldDescr,IgnoreFixedColumns);
      } finally {
        s = rtl.freeLoc(s);
      };
    };
    this.LoadXMLFromText = function (AText, LoadFieldDescr, IgnoreFixedColumns) {
      var $Self = this;
      var xmldoc = null;
      var r = 0;
      var c = 0;
      var fc = 0;
      var fr = 0;
      var parentNode = null;
      var eNode = null;
      var I = 0;
      var sl = null;
      var txt = "";
      function LoadChildNodes(ANode) {
        var J = 0;
        var idx = 0;
        for (var $l = 0, $end = $mod.TJSNodeListHelper.GetCount.call(ANode.childNodes) - 1; $l <= $end; $l++) {
          J = $l;
          if ($mod.TJSNodeListHelper.GetCount.call(ANode.childNodes.item(J).childNodes) > 1) {
            LoadChildNodes(ANode.childNodes.item(J));
          } else if ($mod.TJSNodeListHelper.GetCount.call(ANode.childNodes.item(J).childNodes) === 1) {
            eNode = ANode.childNodes.item(J);
            idx = sl.IndexOf(eNode.nodeName);
            if (idx === -1) {
              sl.Add(eNode.nodeName);
              idx = sl.GetCount() - 1;
              if (LoadFieldDescr) {
                txt = eNode.nodeName;
                $Self.DoLoadCell(idx + fc,fr - 1,{get: function () {
                    return txt;
                  }, set: function (v) {
                    txt = v;
                  }});
              };
            };
            txt = eNode.childNodes.item(0).nodeValue;
            $Self.DoLoadCell(idx + fc,r,{get: function () {
                return txt;
              }, set: function (v) {
                txt = v;
              }});
          };
        };
        if ($mod.TJSNodeListHelper.GetCount.call(ANode.childNodes) > 0) r = r + 1;
      };
      var parser = new DOMParser();
      xmldoc = parser.parseFromString(AText, 'text/xml');
      parentNode = xmldoc.documentElement;
      if (IgnoreFixedColumns) {
        fc = 0}
       else fc = this.FFixedColumns;
      if (LoadFieldDescr && (this.FFixedRows < 1)) {
        fr = 1}
       else fr = this.FFixedRows;
      r = fr;
      sl = pas.Classes.TStringList.$create("Create$1");
      try {
        for (var $l = 0, $end = $mod.TJSNodeListHelper.GetCount.call(parentNode.childNodes) - 1; $l <= $end; $l++) {
          I = $l;
          LoadChildNodes(parentNode.childNodes.item(I));
        };
      } finally {
        c = sl.GetCount() + fc;
        sl = rtl.freeLoc(sl);
      };
      this.SetColumnCount(c);
      this.SetRowCount(r);
    };
    this.SaveToCSVStream = function (AStream, Encoding) {
      this.OutputToCSVStream(AStream,Encoding);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("DefaultRowHeight",14,rtl.double,"FDefaultRowHeight","SetDefaultRowHeight",4,{stored: "IsDefaultRowHeightStored"});
    $r.addProperty("DefaultColumnWidth",14,rtl.double,"FDefaultColumnWidth","SetDefaultColumnWidth",4,{stored: "IsDefaultColumnWidthStored"});
    $r.addProperty("FixedColumns",2,rtl.longint,"FFixedColumns","SetFixedColumns",4,{Default: 1});
    $r.addProperty("FixedRows",2,rtl.longint,"FFixedRows","SetFixedRows",4,{Default: 1});
    $r.addProperty("FixedRightColumns",2,rtl.longint,"FFixedRightColumns","SetFixedRightColumns",4,{Default: 0});
    $r.addProperty("FixedFooterRows",2,rtl.longint,"FFixedFooterRows","SetFixedFooterRows",4,{Default: 0});
    $r.addProperty("ColumnCount",3,rtl.longint,"GetColumnCount","SetColumnCount",4,{Default: 5});
    $r.addProperty("RowCount",3,rtl.longint,"GetRowCount","SetRowCount",4,{Default: 10});
    $r.addProperty("OnColumnCalc",0,$mod.$rtti["TTMSFNCGridColumnCalcEvent"],"FOnColumnCalc","FOnColumnCalc");
    $r.addProperty("OnGroupCalc",0,$mod.$rtti["TTMSFNCGridColumnCalcEvent"],"FOnGroupCalc","FOnGroupCalc");
    $r.addProperty("OnCustomCompare",0,$mod.$rtti["TTMSFNCGridCustomCompareEvent"],"FOnCustomCompare","FOnCustomCompare");
    $r.addProperty("OnIOProgress",0,$mod.$rtti["TTMSFNCGridIOProgressEvent"],"FOnIOProgress","FOnIOProgress");
    $r.addProperty("OnRawCompare",0,$mod.$rtti["TTMSFNCGridRawCompareEvent"],"FOnRawCompare","FOnRawCompare");
    $r.addProperty("OnSortFormat",0,$mod.$rtti["TTMSFNCGridSortFormatEvent"],"FOnSortFormat","FOnSortFormat");
    $r.addProperty("OnCellsChanged",0,$mod.$rtti["TTMSFNCGridCellsChangedEvent"],"FOnCellsChanged","FOnCellsChanged");
    $r.addProperty("OnClipboardBeforePasteCell",0,$mod.$rtti["TTMSFNCGridClipboardBeforePasteEvent"],"FOnClipboardBeforePasteCell","FOnClipboardBeforePasteCell");
    $r.addProperty("OnClipboardAfterPasteCell",0,$mod.$rtti["TTMSFNCGridClipboardAfterPasteEvent"],"FOnClipboardAfterPasteCell","FOnClipboardAfterPasteCell");
    $r.addProperty("OnClipboardPaste",0,$mod.$rtti["TTMSFNCGridCellsChangedEvent"],"FOnClipboardPaste","FOnClipboardPaste");
    $r.addProperty("OnNeedFilterDropDown",0,$mod.$rtti["TTMSFNCGridNeedFilterDropDownEvent"],"FOnNeedFilterDropDown","FOnNeedFilterDropDown");
    $r.addProperty("OnNeedFilterDropDownData",0,$mod.$rtti["TTMSFNCGridNeedFilterDropDownDataEvent"],"FOnNeedFilterDropDownData","FOnNeedFilterDropDownData");
    $r.addProperty("OnFilterSelect",0,$mod.$rtti["TTMSFNCGridFilterSelectEvent"],"FOnFilterSelect","FOnFilterSelect");
    $r.addProperty("OnAfterApplyFilter",0,$mod.$rtti["TTMSFNCGridAfterApplyFilterEvent"],"FOnAfterApplyFilter","FOnAfterApplyFilter");
    $r.addProperty("OnLoadCell",0,$mod.$rtti["TTMSFNCGridIOEvent"],"FOnLoadCell","FOnLoadCell");
    $r.addProperty("OnSaveCell",0,$mod.$rtti["TTMSFNCGridIOEvent"],"FOnSaveCell","FOnSaveCell");
    $r.addProperty("Options",2,pas["WEBLib.TMSFNCGridOptions"].$rtti["TTMSFNCGridOptions"],"FOptions","SetOptions");
    $r.addProperty("OnSelectCell",0,$mod.$rtti["TTMSFNCGridOnSelectCell"],"FOnSelectCell","FOnSelectCell");
    $r.addProperty("OnSelectedCell",0,$mod.$rtti["TTMSFNCGridOnSelectedCell"],"FOnSelectedCell","FOnSelectedCell");
  });
  this.MakeCellRange = function (AStartCol, AStartRow, AEndCol, AEndRow) {
    var Result = $mod.TTMSFNCGridCellRecRange.$new();
    Result.StartCol = AStartCol;
    Result.StartRow = AStartRow;
    Result.EndCol = AEndCol;
    Result.EndRow = AEndRow;
    return Result;
  };
  this.EqualsCellRange = function (Range1, Range2) {
    var Result = false;
    Result = (Range1.StartCol === Range2.StartCol) && (Range1.StartRow === Range2.StartRow) && (Range1.EndCol === Range2.EndCol) && (Range1.EndRow === Range2.EndRow);
    return Result;
  };
  this.InCellRange = function (Col, Row, Range) {
    var Result = false;
    Result = (Col >= Range.StartCol) && (Col <= Range.EndCol) && (Row >= Range.StartRow) && (Row <= Range.EndRow);
    return Result;
  };
  this.MakeCell = function (ACol, ARow) {
    var Result = $mod.TTMSFNCGridCellRec.$new();
    Result.Col = ACol;
    Result.Row = ARow;
    return Result;
  };
  $mod.$implcode = function () {
    $impl.CleanupSep = function (value) {
      var Result = "";
      var i = 0;
      var s = "";
      s = "";
      for (var $l = 1, $end = value.length; $l <= $end; $l++) {
        i = $l;
        if (value.charAt(i - 1) === pas.SysUtils.FormatSettings.ThousandSeparator) continue;
        if (value.charAt(i - 1) === pas.SysUtils.FormatSettings.DecimalSeparator) {
          s = s + "."}
         else s = s + value.charAt(i - 1);
      };
      Result = s;
      return Result;
    };
  };
},["RTLConsts","Math","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCTreeViewBase",["System","Classes","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCScrollBar","WEBLib.StdCtrls","WEBLib.Controls","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  this.SWIPECOUNT = 300;
  this.DOWNCOUNT = 100;
  this.$rtti.$Class("TTMSFNCTreeViewBase");
  rtl.createClass(this,"TTMSFNCTreeViewDoubleListItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FOwner = null;
      this.FValue = 0.0;
      this.FCellVal = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetCellData = function (Value) {
      this.FValue = Value;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner = rtl.as(this.FCollection,$mod.TTMSFNCTreeViewDoubleList).FOwner$1;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Value",2,rtl.double,"FValue","SetCellData");
    $r.addProperty("CellVal",0,rtl.longint,"FCellVal","FCellVal");
  });
  rtl.createClass(this,"TTMSFNCTreeViewDoubleList",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.IndexOf = function (ACellVal) {
      var Result = 0;
      var r = 0;
      Result = -1;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        r = $l;
        if (this.GetItem$1(r).FCellVal === ACellVal) {
          Result = r;
          return Result;
        };
      };
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCTreeViewDoubleListItem);
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.TTMSFNCTreeViewScrollMode = {"0": "smPixelScrolling", smPixelScrolling: 0, "1": "smNodeScrolling", smNodeScrolling: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewScrollMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewScrollMode});
  this.TTMSFNCTreeViewScrollUpdate = {"0": "suContinuous", suContinuous: 0, "1": "suOnce", suOnce: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewScrollUpdate",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewScrollUpdate});
  this.TTMSFNCTreeViewStretchingMode = {"0": "stmIndex", stmIndex: 0, "1": "stmAll", stmAll: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewStretchingMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewStretchingMode});
  rtl.createClass(this,"TTMSFNCTreeViewBase",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FSaveHScrollPos = 0.0;
      this.FSaveVScrollPos = 0.0;
      this.FTotalRowHeight = 0.0;
      this.FNodeListBuild = false;
      this.FTotalColumnWidth = 0.0;
      this.FStartOffset = 0.0;
      this.FStartCol = 0;
      this.FStopCol = 0;
      this.FStartRow = 0;
      this.FStopRow = 0;
      this.FStartX = 0.0;
      this.FStopX = 0.0;
      this.FStartY = 0.0;
      this.FStopY = 0.0;
      this.FBlockScrollingUpdate = false;
      this.FUpdateCount$1 = 0;
      this.FVerticalScrollBar = null;
      this.FHorizontalScrollBar = null;
      this.FCustomVerticalScrollBar = null;
      this.FCustomHorizontalScrollBar = null;
      this.FRowCount = 0;
      this.FColumnCount = 0;
      this.FColumnW = null;
      this.FColumnP = null;
      this.FDefaultRowHeight = 0.0;
      this.FDefaultColumnWidth = 0.0;
      this.FVerticalScrollBarVisible = false;
      this.FHorizontalScrollBarVisible = false;
      this.FScrollMode = 0;
      this.FIsMouseDown = false;
      this.FDelayedLoading = false;
      this.FStretchScrollBars = false;
      this.FBlockUpdateNodeList = false;
      this.FBlockUpdateNode = false;
      this.FBlockRemoveNode = 0;
      this.FBlockUserInput = false;
      this.FBlockMouseClick = false;
      this.FCustomScrollBars = false;
      this.FScrollUpdate = 0;
      this.FDefaultColumnMinWidth = 0.0;
      this.FColumnMinW = null;
    };
    this.$final = function () {
      this.FVerticalScrollBar = undefined;
      this.FHorizontalScrollBar = undefined;
      this.FCustomVerticalScrollBar = undefined;
      this.FCustomHorizontalScrollBar = undefined;
      this.FColumnW = undefined;
      this.FColumnP = undefined;
      this.FColumnMinW = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetColumnCount = function (Value) {
      if (this.FColumnCount !== Value) this.FColumnCount = Value;
    };
    this.SetRowCount = function (Value) {
      if (this.FRowCount !== Value) this.FRowCount = Value;
    };
    this.SetDefaultColumnWidth = function (Value) {
      if (this.FDefaultColumnWidth !== Value) this.FDefaultColumnWidth = Value;
    };
    this.SetDefaultRowHeight = function (Value) {
      if (this.FDefaultRowHeight !== Value) this.FDefaultRowHeight = Value;
    };
    this.SetHorizontalScrollBarVisible = function (Value) {
      if (this.FHorizontalScrollBarVisible !== Value) {
        this.FHorizontalScrollBarVisible = Value;
        this.UpdateTreeViewCache();
      };
    };
    this.SetVerticalScrollBarVisible = function (Value) {
      if (this.FVerticalScrollBarVisible !== Value) {
        this.FVerticalScrollBarVisible = Value;
        this.UpdateTreeViewCache();
      };
    };
    this.SetScrollMode = function (Value) {
      if (this.FScrollMode !== Value) {
        this.FScrollMode = Value;
        this.UpdateTreeViewDisplay();
      };
    };
    this.SetColWidths = function (Col, Value) {
      var idx = 0;
      var c = null;
      idx = this.FColumnW.IndexOf(Col);
      if ((idx >= 0) && (idx <= (this.FColumnW.GetCount() - 1))) {
        if (Value === this.FDefaultColumnWidth) {
          this.FColumnW.Delete(idx)}
         else {
          this.FColumnW.GetItem$1(idx).SetCellData(Math.max(0,Value));
          this.FColumnW.GetItem$1(idx).FCellVal = Col;
        };
      } else if (Value !== this.FDefaultColumnWidth) {
        c = this.FColumnW.Add$1();
        c.SetCellData(Math.max(0,Value));
        c.FCellVal = Col;
      };
    };
    this.SetColumnP = function (Value) {
      this.FColumnP.Assign(Value);
    };
    this.SetColumnW = function (Value) {
      this.FColumnW.Assign(Value);
    };
    this.GetColWidths = function (Col) {
      var Result = 0.0;
      var idx = 0;
      idx = this.FColumnW.IndexOf(Col);
      if (idx !== -1) {
        Result = this.FColumnW.GetItem$1(idx).FValue}
       else Result = this.FDefaultColumnWidth;
      return Result;
    };
    this.GetColPos = function (Col) {
      var Result = 0.0;
      var idx = 0;
      idx = this.FColumnP.IndexOf(Col);
      if (idx !== -1) {
        Result = this.FColumnP.GetItem$1(idx).FValue}
       else Result = -1;
      return Result;
    };
    this.SetColPos = function (Col, Value) {
      var idx = 0;
      var c = null;
      idx = this.FColumnP.IndexOf(Col);
      if ((idx >= 0) && (idx <= (this.FColumnP.GetCount() - 1))) {
        if (Value === -1) {
          this.FColumnP.Delete(idx)}
         else {
          this.FColumnP.GetItem$1(idx).SetCellData(Math.max(0,Value));
          this.FColumnP.GetItem$1(idx).FCellVal = Col;
        };
      } else if (Value !== -1) {
        c = this.FColumnP.Add$1();
        c.SetCellData(Math.max(0,Value));
        c.FCellVal = Col;
      };
    };
    this.SetStretchScrollBars = function (Value) {
      if (this.FStretchScrollBars !== Value) {
        this.FStretchScrollBars = Value;
        this.UpdateTreeViewDisplay();
      };
    };
    this.SetCustomScrollBars = function (Value) {
      if (this.FCustomScrollBars !== Value) {
        this.FCustomScrollBars = Value;
        this.UpdateTreeViewCache();
      };
    };
    this.SetScrollUpdate = function (Value) {
      if (this.FScrollUpdate !== Value) {
        this.FScrollUpdate = Value;
        if (this.FCustomVerticalScrollBar != null) this.FCustomVerticalScrollBar.SetTracking(this.FScrollUpdate === $mod.TTMSFNCTreeViewScrollUpdate.suContinuous);
        if (this.FCustomHorizontalScrollBar != null) this.FCustomHorizontalScrollBar.SetTracking(this.FScrollUpdate === $mod.TTMSFNCTreeViewScrollUpdate.suContinuous);
        this.UpdateTreeViewCache();
      };
    };
    this.GetColMinWidths = function (Col) {
      var Result = 0.0;
      var idx = 0;
      idx = this.FColumnMinW.IndexOf(Col);
      if (idx !== -1) {
        Result = this.FColumnMinW.GetItem$1(idx).FValue}
       else Result = this.FDefaultColumnMinWidth;
      return Result;
    };
    this.SetColMinWidths = function (Col, Value) {
      var idx = 0;
      var c = null;
      idx = this.FColumnMinW.IndexOf(Col);
      if ((idx >= 0) && (idx <= (this.FColumnMinW.GetCount() - 1))) {
        if (Value === this.FDefaultColumnMinWidth) {
          this.FColumnMinW.Delete(idx)}
         else {
          this.FColumnMinW.GetItem$1(idx).SetCellData(Math.max(0,Value));
          this.FColumnMinW.GetItem$1(idx).FCellVal = Col;
        };
      } else if (Value !== this.FDefaultColumnMinWidth) {
        c = this.FColumnMinW.Add$1();
        c.SetCellData(Math.max(0,Value));
        c.FCellVal = Col;
      };
    };
    this.SetDefaultColumnMinWidth = function (Value) {
      if (this.FDefaultColumnMinWidth !== Value) this.FDefaultColumnMinWidth = Value;
    };
    this.SetColumnMinW = function (Value) {
      this.FColumnMinW.Assign(Value);
    };
    this.UpdateTreeView = function () {
      this.SaveScrollPosition();
      this.UpdateNodesCache(true,true);
      this.RestoreScrollPosition();
      this.UpdateGroupsCache();
      this.UpdateColumnsCache();
    };
    this.IncUpdateCount$1 = function () {
      this.FUpdateCount$1 += 1;
    };
    this.DecUpdateCount$1 = function () {
      this.FUpdateCount$1 -= 1;
    };
    this.UpdateVisualRange = function () {
      var c = 0;
      var r = 0;
      var xval = 0.0;
      var yval = 0.0;
      var yoffs = 0.0;
      var cw = 0.0;
      var ch = 0.0;
      var vpos = 0.0;
      var hpos = 0.0;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rh = 0.0;
      hpos = this.GetHorizontalScrollPosition();
      vpos = this.GetVerticalScrollPosition();
      yoffs = this.GetVScrollOffset();
      cr.$assign(this.GetContentRect());
      xval = -hpos;
      yval = -vpos;
      cw = cr.Right - cr.Left;
      ch = cr.Bottom - cr.Top;
      this.FStartCol = -1;
      this.FStartRow = -1;
      this.FStopCol = -1;
      this.FStopRow = -1;
      this.FStartX = cr.Left;
      this.FStopX = cr.Left;
      this.FStartY = cr.Top;
      this.FStopY = cr.Top;
      this.FStartOffset = 0;
      for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
        c = $l;
        xval = xval + this.GetColWidths(c);
        if ((xval > 0) && (this.FStartCol === -1)) {
          this.FStartCol = c;
          this.FStartX = this.FStartX + pas.System.Int(xval - this.GetColWidths(c));
        };
        if ((xval >= cw) && (this.FStopCol === -1)) {
          this.FStopCol = c;
          this.FStopX = this.FStopX + pas.System.Int(xval);
        };
        if ((this.FStartCol > -1) && (this.FStopCol > -1)) break;
      };
      for (var $l1 = 0, $end1 = this.FRowCount - 1; $l1 <= $end1; $l1++) {
        r = $l1;
        rh = this.GetRowHeight(r);
        yval = yval + rh;
        if ((yval > -yoffs) && (this.FStartRow === -1)) {
          this.FStartRow = r;
          this.FStartOffset = yval - rh;
          this.FStartY = this.FStartY + pas.System.Int(this.FStartOffset);
        };
        if ((yval >= ch) && (this.FStopRow === -1)) {
          this.FStopRow = r;
          this.FStopY = this.FStopY + pas.System.Int(yval);
        };
        if ((this.FStartRow > -1) && (this.FStopRow > -1)) break;
      };
      if ((this.FStartRow > -1) && (this.FStopRow === -1)) this.FStopRow = this.FRowCount - 1;
      if ((this.FStartCol > -1) && (this.FStopCol === -1)) this.FStopCol = this.FColumnCount - 1;
    };
    this.StretchColumns = function (AMode, AIndex, ANewWidth) {
      var Result = false;
      var tw = 0.0;
      var i = 0;
      var cw = 0.0;
      var t = 0.0;
      var vc = 0;
      var stc = 0;
      var sec = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var horz = null;
      var vert = null;
      Result = false;
      horz = this.HorizontalScrollBar();
      vert = this.VerticalScrollBar();
      if (!(vert != null) || !(horz != null)) return Result;
      this.IncUpdateCount$1();
      try {
        if (ANewWidth > -1) {
          tw = ANewWidth}
         else {
          r.$assign(this.GetContentRect());
          tw = r.Right - r.Left;
          if (tw < 0) return Result;
        };
        stc = 0;
        sec = this.FColumnCount - 1;
        if ((AMode === $mod.TTMSFNCTreeViewStretchingMode.stmIndex) && (AIndex === -1)) {
          AIndex = sec;
          while (!this.IsColumnVisible(AIndex) && (AIndex > stc)) AIndex -= 1;
        };
        vc = 0;
        for (var $l = 0, $end = stc - 1; $l <= $end; $l++) {
          i = $l;
          if (this.IsColumnVisible(i)) tw = tw - this.GetColWidths(i);
        };
        for (var $l1 = this.FColumnCount - 1, $end1 = sec + 1; $l1 >= $end1; $l1--) {
          i = $l1;
          if (this.IsColumnVisible(i)) tw = tw - this.GetColWidths(i);
        };
        for (var $l2 = stc, $end2 = sec; $l2 <= $end2; $l2++) {
          i = $l2;
          if (this.IsColumnVisible(i)) {
            vc += 1;
            if ((i !== AIndex) && (AIndex !== -1) && (AMode === $mod.TTMSFNCTreeViewStretchingMode.stmIndex)) tw = tw - this.GetColWidths(i);
          };
        };
        if (AMode === $mod.TTMSFNCTreeViewStretchingMode.stmAll) {
          if (vc > 0) {
            cw = tw / vc;
            t = 0;
            for (var $l3 = stc, $end3 = sec; $l3 <= $end3; $l3++) {
              i = $l3;
              if (this.IsColumnVisible(i)) {
                if (i === sec) {
                  this.SetColWidths(i,Math.max(this.GetColMinWidths(i),pas.System.Int(tw - t)))}
                 else {
                  this.SetColWidths(i,Math.max(this.GetColMinWidths(i),pas.System.Int(cw)));
                  t = t + pas.System.Int(cw);
                };
              };
            };
            Result = true;
          };
        } else {
          if ((AIndex >= 0) && (AIndex < this.FColumnCount) && this.IsColumnVisible(AIndex)) {
            cw = tw;
            if (cw > 0) {
              this.SetColWidths(AIndex,Math.max(this.GetColMinWidths(AIndex),cw))}
             else this.SetColWidths(AIndex,this.FDefaultColumnWidth);
            Result = cw > 0;
          };
        };
      } finally {
        this.DecUpdateCount$1();
      };
      return Result;
    };
    this.StretchColumn = function (AStretchAll, ACol, ANewWidth) {
      if (AStretchAll) {
        this.StretchColumns($mod.TTMSFNCTreeViewStretchingMode.stmAll,-1,ANewWidth)}
       else this.StretchColumns($mod.TTMSFNCTreeViewStretchingMode.stmIndex,ACol,ANewWidth);
    };
    this.Scroll = function (AHorizontalPos, AVerticalPos) {
      this.FBlockScrollingUpdate = true;
      this.SetHScrollValue(AHorizontalPos);
      this.SetVScrollValue(AVerticalPos);
      this.FBlockScrollingUpdate = false;
      this.UpdateDisplay();
    };
    this.UpdateDisplay = function () {
    };
    this.VScrollChanged = function (Sender) {
      if (this.FBlockScrollingUpdate) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.VerticalScrollPositionChanged();
    };
    this.HScrollChanged = function (Sender) {
      if (this.FBlockScrollingUpdate) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.HorizontalScrollPositionChanged();
    };
    this.HCustomScrollChanged = function (Sender, AValue) {
      if (this.FBlockScrollingUpdate || !this.FCustomScrollBars) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.HorizontalScrollPositionChanged();
      this.SetHScrollValue(this.GetHScrollValue());
    };
    this.VCustomScrollChanged = function (Sender, AValue) {
      if (this.FBlockScrollingUpdate || !this.FCustomScrollBars) return;
      if (!this.FIsMouseDown) this.StopAnimationTimer();
      this.VerticalScrollPositionChanged();
      this.SetVScrollValue(this.GetVScrollValue());
    };
    this.UpdateScrollBars = function (AUpdate, ACalculate) {
      var vs = null;
      var hs = null;
      var vsc = null;
      var hsc = null;
      var w = 0.0;
      var h = 0.0;
      var cw = 0.0;
      var ch = 0.0;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var vmgr = null;
      var hmgr = null;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.FBlockScrollingUpdate = true;
      if (ACalculate) {
        this.UpdateAutoSizing();
        this.UpdateColumnRowCalculations(true);
      };
      vs = this.VerticalScrollBar();
      hs = this.HorizontalScrollBar();
      vsc = this.CustomVerticalScrollBar();
      hsc = this.CustomHorizontalScrollBar();
      if ((vs != null) && (hs != null) && (vsc != null) && (hsc != null)) {
        if (AUpdate) {
          cr.$assign(this.GetCalculationRect())}
         else cr.$assign(this.GetContentRect());
        cw = cr.Right - cr.Left;
        ch = cr.Bottom - cr.Top;
        w = this.GetTotalColumnWidth();
        h = this.GetTotalRowHeight();
        hs.SetVisible((w > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(w,cw,0) === 1) && this.FHorizontalScrollBarVisible && !this.ColumnStretchingActive() && !this.FCustomScrollBars);
        vs.SetVisible((h > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(h,ch,0) === 1) && this.FVerticalScrollBarVisible && !this.FCustomScrollBars);
        hsc.SetVisible((w > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(w,cw,0) === 1) && this.FHorizontalScrollBarVisible && !this.ColumnStretchingActive() && this.FCustomScrollBars);
        vsc.SetVisible((h > 0) && (pas["WEBLib.TMSFNCTypes"].CompareValueEx(h,ch,0) === 1) && this.FVerticalScrollBarVisible && this.FCustomScrollBars);
        if (vsc.FVisible && this.FCustomScrollBars) {
          vsc.SetParent(this)}
         else vsc.SetParent(null);
        if (hsc.FVisible && this.FCustomScrollBars) {
          hsc.SetParent(this)}
         else hsc.SetParent(null);
        if (vs.FVisible && !this.FCustomScrollBars) {
          vs.SetParent(this)}
         else vs.SetParent(null);
        if (hs.FVisible && !this.FCustomScrollBars) {
          hs.SetParent(this)}
         else hs.SetParent(null);
        vmgr = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
        hmgr = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
        if (this.FCustomScrollBars) {
          if (vsc.FVisible && this.FStretchScrollBars) {
            hmgr.SetRight(vsc.GetWidth() + 1)}
           else hmgr.SetRight(1);
        } else {
          if (vs.FVisible && this.FStretchScrollBars) {
            hmgr.SetRight(vs.GetWidth() + 1)}
           else hmgr.SetRight(1);
        };
        vmgr.SetTop(1);
        vmgr.SetRight(1);
        hmgr.SetBottom(1);
        hmgr.SetLeft(1);
        if (this.FCustomScrollBars) {
          if (hsc.FVisible) {
            vmgr.SetBottom(hsc.GetHeight() + 1)}
           else vmgr.SetBottom(1);
        } else {
          if (hs.FVisible) {
            vmgr.SetBottom(hs.GetHeight() + 1)}
           else vmgr.SetBottom(1);
        };
        if (!this.FStretchScrollBars) {
          cr.$assign(this.GetCalculationRect());
          hmgr.SetLeft(hmgr.FLeft + cr.Left);
          hmgr.SetRight(hmgr.FRight + (this.GetWidth() - cr.Right));
          vmgr.SetTop(vmgr.FTop + cr.Top);
          vmgr.SetBottom(vmgr.FBottom + (this.GetHeight() - cr.Bottom));
        };
        hs.SetLeft(Math.round(hmgr.FLeft));
        hs.SetTop(Math.round(this.GetHeight() - hmgr.FBottom - hs.GetHeight()));
        vs.SetLeft(Math.round(this.GetWidth() - vmgr.FRight - vs.GetWidth()));
        vs.SetTop(Math.round(vmgr.FTop));
        hs.SetWidth(Math.round(Math.max(0,this.GetWidth() - hmgr.FRight - hmgr.FLeft)));
        vs.SetHeight(Math.round(Math.max(0,this.GetHeight() - vmgr.FBottom - vmgr.FTop)));
        vs.SetHeight(Math.round(Math.max(0,this.GetHeight() - vmgr.FBottom - vmgr.FTop)));
        hsc.SetLeft(Math.round(hmgr.FLeft));
        hsc.SetTop(Math.round(this.GetHeight() - hmgr.FBottom - hsc.GetHeight()));
        vsc.SetLeft(Math.round(this.GetWidth() - vmgr.FRight - vsc.GetWidth()));
        vsc.SetTop(Math.round(vmgr.FTop));
        hsc.SetWidth(Math.round(Math.max(0,this.GetWidth() - hmgr.FRight - hmgr.FLeft)));
        vsc.SetHeight(Math.round(Math.max(0,this.GetHeight() - vmgr.FBottom - vmgr.FTop)));
        hmgr = rtl.freeLoc(hmgr);
        vmgr = rtl.freeLoc(vmgr);
        cr.$assign(this.GetContentRect());
        cw = cr.Right - cr.Left;
        ch = cr.Bottom - cr.Top;
        if (this.FScrollMode === $mod.TTMSFNCTreeViewScrollMode.smNodeScrolling) {
          vs.SetPageSize(Math.round(Math.max(0,this.GetRowViewPortSize())));
          vs.SetMax(Math.max(vs.GetPageSize(),this.FRowCount));
        } else {
          vs.SetPageSize(Math.round(Math.max(0,Math.min(h,ch))));
          vs.SetMax(Math.round(Math.max(vs.GetPageSize(),h)));
          vs.FSmallChange = Math.round(this.FDefaultRowHeight);
          vs.FLargeChange = Math.max(1,vs.GetPageSize());
          vs.SetPosition(Math.min(vs.GetPosition(),vs.FMax));
        };
        if (this.FScrollMode === $mod.TTMSFNCTreeViewScrollMode.smNodeScrolling) {
          hs.SetPageSize(Math.round(Math.max(0,this.GetColumnViewPortSize())));
          hs.SetMax(Math.max(hs.GetPageSize(),this.FColumnCount));
        } else {
          hs.SetPageSize(Math.round(Math.max(0,Math.min(w,cw))));
          hs.SetMax(Math.round(Math.max(hs.GetPageSize(),w)));
          hs.SetPosition(Math.min(hs.GetPosition(),hs.FMax));
        };
        if (this.FScrollMode === $mod.TTMSFNCTreeViewScrollMode.smNodeScrolling) {
          vsc.SetPageSize(this.GetRowViewPortSize());
          vsc.SetMax(this.FRowCount);
        } else {
          vsc.SetPageSize(Math.min(h,ch));
          vsc.SetMax(h);
          vsc.FSmallChange = Math.round(this.FDefaultRowHeight);
          vsc.SetValue(Math.min(vsc.FValue,vsc.FMax - vsc.FPageSize));
        };
        if (this.FScrollMode === $mod.TTMSFNCTreeViewScrollMode.smNodeScrolling) {
          hsc.SetPageSize(this.GetColumnViewPortSize());
          hsc.SetMax(this.FColumnCount);
        } else {
          hsc.SetPageSize(Math.min(w,cw));
          hsc.SetMax(w);
          hsc.SetValue(Math.min(hsc.FValue,hsc.FMax - hsc.FPageSize));
        };
      };
      this.FBlockScrollingUpdate = false;
      if (AUpdate) this.UpdateScrollBars(false,false);
    };
    this.UpdateTreeViewCache = function () {
      if ((this.FUpdateCount$1 > 0) || this.FBlockUpdateNode || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.ResetNodes(true);
      this.UpdateCalculations();
      this.UpdateColumns();
      this.UpdateScrollBars(true,true);
      this.UpdateNodesCache(true,true);
      this.UpdateGroupsCache();
      this.UpdateColumnsCache();
    };
    this.UpdateTreeViewDisplay = function () {
      this.UpdateScrollBars(true,true);
      this.UpdateDisplay();
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateTreeViewCache();
    };
    this.SetHScrollValue = function (AValue) {
      if (this.FCustomScrollBars) {
        if (this.CustomHorizontalScrollBar().FPageSize > 0) this.CustomHorizontalScrollBar().SetValue(Math.min(this.CustomHorizontalScrollBar().FMax - this.CustomHorizontalScrollBar().FPageSize,Math.max(0,AValue)));
      } else {
        this.HorizontalScrollBar().SetPosition(Math.round(Math.min(this.HorizontalScrollBar().FMax - this.HorizontalScrollBar().GetPageSize(),Math.max(0,AValue))));
      };
    };
    this.SetVScrollValue = function (AValue) {
      if (this.FCustomScrollBars) {
        if (this.CustomVerticalScrollBar().FPageSize > 0) this.CustomVerticalScrollBar().SetValue(Math.min(this.CustomVerticalScrollBar().FMax - this.CustomVerticalScrollBar().FPageSize,Math.max(0,AValue)));
      } else {
        this.VerticalScrollBar().SetPosition(Math.round(Math.min(this.VerticalScrollBar().FMax - this.VerticalScrollBar().GetPageSize(),Math.max(0,AValue))));
      };
    };
    this.UpdateControlAfterResize = function () {
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.ResetNodes(true);
      this.SaveScrollPosition();
      this.UpdateNodesCache(true,true);
      this.UpdateGroupsCache();
      this.UpdateColumnsCache();
      this.RestoreScrollPosition();
    };
    this.CanScrollDown = function () {
      var Result = false;
      Result = this.GetVerticalScrollPosition() < (this.GetTotalRowHeight() - this.GetVViewPortSize());
      return Result;
    };
    this.CanScrollUp = function () {
      var Result = false;
      Result = this.GetVerticalScrollPosition() > 0;
      return Result;
    };
    this.ScrollLimitation = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.IsColumnVisible = function (ACol) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetRowHeight = function (ARow) {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetCalculationRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetLocalRect());
      return Result;
    };
    this.GetContentRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.GetContentRect.call(this));
      if (this.FCustomScrollBars) {
        if (this.CustomHorizontalScrollBar().FVisible) Result.Bottom = Result.Bottom - this.CustomHorizontalScrollBar().GetHeight() - 1;
        if (this.CustomVerticalScrollBar().FVisible) Result.Right = Result.Right - this.CustomVerticalScrollBar().GetWidth() - 1;
      } else {
        if (this.HorizontalScrollBar().FVisible) Result.Bottom = Result.Bottom - this.HorizontalScrollBar().GetHeight() - 1;
        if (this.VerticalScrollBar().FVisible) Result.Right = Result.Right - this.VerticalScrollBar().GetWidth() - 1;
      };
      return Result;
    };
    this.GetContentClipRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetContentRect());
      return Result;
    };
    this.GetHScrollValue = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = Math.min(this.CustomHorizontalScrollBar().FMax - this.CustomHorizontalScrollBar().FPageSize,Math.max(0,this.CustomHorizontalScrollBar().FValue))}
       else {
        Result = Math.round(Math.min(this.HorizontalScrollBar().FMax - this.HorizontalScrollBar().GetPageSize(),Math.max(0,this.HorizontalScrollBar().GetPosition())));
      };
      return Result;
    };
    this.GetVScrollValue = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = Math.min(this.CustomVerticalScrollBar().FMax - this.CustomVerticalScrollBar().FPageSize,Math.max(0,this.CustomVerticalScrollBar().FValue))}
       else {
        Result = Math.round(Math.min(this.VerticalScrollBar().FMax - this.VerticalScrollBar().GetPageSize(),Math.max(0,this.VerticalScrollBar().GetPosition())));
      };
      return Result;
    };
    this.GetVViewPortSize = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = this.CustomVerticalScrollBar().FPageSize}
       else {
        Result = this.VerticalScrollBar().GetPageSize();
      };
      return Result;
    };
    this.GetHViewPortSize = function () {
      var Result = 0.0;
      if (this.FCustomScrollBars) {
        Result = this.CustomHorizontalScrollBar().FPageSize}
       else {
        Result = this.HorizontalScrollBar().GetPageSize();
      };
      return Result;
    };
    this.GetVScrollOffset = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetColumnViewPortSize = function () {
      var Result = 0.0;
      var I = 0;
      var cnt = 0;
      var w = 0.0;
      var cw = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetContentRect());
      cw = r.Right - r.Left;
      Result = 0;
      w = 0;
      cnt = 0;
      for (var $l = this.FColumnCount - 1; $l >= 0; $l--) {
        I = $l;
        w = w + this.GetColWidths(I);
        if (w > cw) {
          Result = Math.max(1,cnt);
          break;
        };
        cnt += 1;
      };
      return Result;
    };
    this.GetRowViewPortSize = function () {
      var Result = 0.0;
      var I = 0;
      var cnt = 0;
      var h = 0.0;
      var ch = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetContentRect());
      ch = r.Bottom - r.Top;
      Result = 0;
      h = 0;
      cnt = 0;
      for (var $l = this.FRowCount - 1; $l >= 0; $l--) {
        I = $l;
        h = h + this.GetRowHeight(I);
        if (h > ch) {
          Result = Math.max(1,cnt);
          break;
        };
        cnt += 1;
      };
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FDelayedLoading = false;
      this.FStretchScrollBars = true;
      this.FScrollUpdate = $mod.TTMSFNCTreeViewScrollUpdate.suContinuous;
      this.FCustomVerticalScrollBar = pas["WEBLib.TMSFNCScrollBar"].TTMSFNCScrollBar.$create("Create$1",[this]);
      this.FCustomVerticalScrollBar.SetParent(this);
      this.FCustomHorizontalScrollBar = pas["WEBLib.TMSFNCScrollBar"].TTMSFNCScrollBar.$create("Create$1",[this]);
      this.FCustomHorizontalScrollBar.SetParent(this);
      this.FVerticalScrollBar = pas["WEBLib.StdCtrls"].TScrollBar.$create("Create$1",[this]);
      this.FVerticalScrollBar.SetParent(this);
      this.FHorizontalScrollBar = pas["WEBLib.StdCtrls"].TScrollBar.$create("Create$1",[this]);
      this.FHorizontalScrollBar.SetParent(this);
      this.FCustomVerticalScrollBar.FAppearance.SetThumbButtonSize(0);
      this.FCustomHorizontalScrollBar.FAppearance.SetThumbButtonSize(0);
      this.FCustomHorizontalScrollBar.SetKind(pas["WEBLib.TMSFNCScrollBar"].TTMSFNCScrollBarKind.sbkHorizontal);
      this.FVerticalScrollBar.FDoubleBuffered = false;
      this.FHorizontalScrollBar.FDoubleBuffered = false;
      this.FVerticalScrollBar.SetKind(pas["WEBLib.Controls"].TScrollBarKind.sbVertical);
      this.FVerticalScrollBar.SetVisible(true);
      this.FHorizontalScrollBar.SetVisible(true);
      this.FCustomVerticalScrollBar.SetVisible(false);
      this.FCustomHorizontalScrollBar.SetVisible(false);
      this.FVerticalScrollBar.FOnChange = rtl.createCallback(this,"VScrollChanged");
      this.FHorizontalScrollBar.FOnChange = rtl.createCallback(this,"HScrollChanged");
      this.FCustomHorizontalScrollBar.FOnValueChange = rtl.createCallback(this,"HCustomScrollChanged");
      this.FCustomVerticalScrollBar.FOnValueChange = rtl.createCallback(this,"VCustomScrollChanged");
      this.FVerticalScrollBarVisible = true;
      this.FHorizontalScrollBarVisible = true;
      this.FScrollMode = $mod.TTMSFNCTreeViewScrollMode.smPixelScrolling;
      this.FColumnW = $mod.TTMSFNCTreeViewDoubleList.$create("Create$3",[this]);
      this.FColumnMinW = $mod.TTMSFNCTreeViewDoubleList.$create("Create$3",[this]);
      this.FColumnP = $mod.TTMSFNCTreeViewDoubleList.$create("Create$3",[this]);
      this.FDefaultRowHeight = 25;
      this.FDefaultColumnWidth = 75;
      this.FDefaultColumnMinWidth = 0;
      this.FColumnCount = 0;
      this.FRowCount = 0;
      this.FVerticalScrollBarVisible = true;
      this.FHorizontalScrollBarVisible = true;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FColumnP");
      rtl.free(this,"FColumnMinW");
      rtl.free(this,"FColumnW");
      rtl.free(this,"FCustomVerticalScrollBar");
      rtl.free(this,"FCustomHorizontalScrollBar");
      rtl.free(this,"FVerticalScrollBar");
      rtl.free(this,"FHorizontalScrollBar");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCTreeViewBase.isPrototypeOf(Source)) {
        this.FScrollMode = rtl.as(Source,$mod.TTMSFNCTreeViewBase).FScrollMode;
        this.FStretchScrollBars = rtl.as(Source,$mod.TTMSFNCTreeViewBase).FStretchScrollBars;
      };
    };
    this.Resize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Resize.call(this);
      this.UpdateControlAfterResize();
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
      this.FUpdateCount$1 += 1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.FUpdateCount$1 -= 1;
      if (this.FUpdateCount$1 === 0) this.UpdateTreeViewCache();
    };
    this.SaveScrollPosition = function () {
      this.FSaveHScrollPos = this.GetHScrollValue();
      this.FSaveVScrollPos = this.GetVScrollValue();
    };
    this.RestoreScrollPosition = function () {
      this.Scroll(this.FSaveHScrollPos,this.FSaveVScrollPos);
    };
    this.AutoSizeColumn = function (ACol) {
      this.AutoSizeColumnInternal(ACol,true,true);
    };
    this.GetVerticalScrollPosition = function () {
      var Result = 0.0;
      var vVal = 0.0;
      vVal = this.GetVScrollValue();
      if (this.FScrollMode === $mod.TTMSFNCTreeViewScrollMode.smNodeScrolling) ;
      Result = vVal;
      return Result;
    };
    this.GetHorizontalScrollPosition = function () {
      var Result = 0.0;
      var hVal = 0.0;
      var scrollh = 0.0;
      hVal = this.GetHScrollValue();
      if (this.FScrollMode === $mod.TTMSFNCTreeViewScrollMode.smNodeScrolling) {
        scrollh = this.GetColPos(Math.round(hVal));
        hVal = scrollh;
      };
      Result = hVal;
      return Result;
    };
    this.HorizontalScrollBar = function () {
      var Result = null;
      Result = this.FHorizontalScrollBar;
      return Result;
    };
    this.VerticalScrollBar = function () {
      var Result = null;
      Result = this.FVerticalScrollBar;
      return Result;
    };
    this.CustomHorizontalScrollBar = function () {
      var Result = null;
      Result = this.FCustomHorizontalScrollBar;
      return Result;
    };
    this.CustomVerticalScrollBar = function () {
      var Result = null;
      Result = this.FCustomVerticalScrollBar;
      return Result;
    };
    this.StartCol = function () {
      var Result = 0;
      Result = this.FStartCol;
      return Result;
    };
    this.StopCol = function () {
      var Result = 0;
      Result = this.FStopCol;
      return Result;
    };
    this.StartX = function () {
      var Result = 0.0;
      Result = this.FStartX;
      return Result;
    };
    this.StopX = function () {
      var Result = 0.0;
      Result = this.FStopX;
      return Result;
    };
    this.StartRow = function () {
      var Result = 0;
      Result = this.FStartRow;
      return Result;
    };
    this.StartOffset = function () {
      var Result = 0.0;
      Result = this.FStartOffset;
      return Result;
    };
    this.StopRow = function () {
      var Result = 0;
      Result = this.FStopRow;
      return Result;
    };
    this.StartY = function () {
      var Result = 0.0;
      Result = this.FStartY;
      return Result;
    };
    this.StopY = function () {
      var Result = 0.0;
      Result = this.FStopY;
      return Result;
    };
    this.GetColumnWidth = function (AColumn) {
      var Result = 0.0;
      Result = this.GetColWidths(AColumn);
      return Result;
    };
    this.GetColumnPosition = function (AColumn) {
      var Result = 0.0;
      Result = this.GetColPos(AColumn);
      return Result;
    };
    this.GetTotalColumnNodeWidth = function () {
      var Result = 0.0;
      Result = this.FTotalColumnWidth;
      return Result;
    };
    this.GetTotalColumnWidth = function () {
      var Result = 0.0;
      Result = this.FTotalColumnWidth;
      return Result;
    };
    this.GetTotalRowHeight = function () {
      var Result = 0.0;
      Result = this.FTotalRowHeight;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
},["Math","WEBLib.TMSFNCUtils","SysUtils","WEBLib.Forms"]);
rtl.module("WEBLib.TMSFNCTreeViewData",["System","Classes","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCTreeViewBase","contnrs"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAXLEVELDEPTH = 100;
  this.MAXNODECOUNT = 2000000;
  this.$rtti.$Class("TTMSFNCTreeViewCacheItem");
  this.$rtti.$Class("TTMSFNCTreeViewData");
  this.$rtti.$Class("TTMSFNCTreeViewGroup");
  this.$rtti.$Class("TTMSFNCTreeViewColumn");
  this.$rtti.$Class("TTMSFNCTreeViewNode");
  this.TTMSFNCTreeViewNodeScrollPosition = {"0": "tvnspTop", tvnspTop: 0, "1": "tvnspBottom", tvnspBottom: 1, "2": "tvnspMiddle", tvnspMiddle: 2};
  this.$rtti.$Enum("TTMSFNCTreeViewNodeScrollPosition",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCTreeViewNodeScrollPosition});
  rtl.recNewT(this,"TTMSFNCTreeViewVirtualNodeRemoveData",function () {
    this.RowIndex = 0;
    this.Count = 0;
    this.ParentNode = 0;
    this.$eq = function (b) {
      return (this.RowIndex === b.RowIndex) && (this.Count === b.Count) && (this.ParentNode === b.ParentNode);
    };
    this.$assign = function (s) {
      this.RowIndex = s.RowIndex;
      this.Count = s.Count;
      this.ParentNode = s.ParentNode;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTreeViewVirtualNodeRemoveData",{},this);
    $r.addField("RowIndex",rtl.longint);
    $r.addField("Count",rtl.longint);
    $r.addField("ParentNode",rtl.longint);
  });
  this.$rtti.$DynArray("TTMSFNCArrayTRectF",{eltype: pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]});
  this.$rtti.$DynArray("TTMSFNCArrayBoolean",{eltype: rtl.boolean});
  rtl.createClass(this,"TTMSFNCTreeViewVirtualNode",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FTreeView = null;
      this.FLevel = 0;
      this.FAddedToVisibleList = false;
      this.FFilterExpanded = false;
      this.FChildren = 0;
      this.FParentNode = 0;
      this.FExpanded = false;
      this.FTotalChildren = 0;
      this.FIndex = 0;
      this.FRow = 0;
      this.FHeight = 0.0;
      this.FCalculated = false;
      this.FCache = null;
      this.FTextRects = [];
      this.FBitmapRects = [];
      this.FExpandRects = [];
      this.FCheckRects = [];
      this.FCheckStates = [];
      this.FNode = null;
      this.FExtended = false;
      this.FExtraRects = [];
      this.FTitleRects = [];
      this.FTitleHeight = 0.0;
      this.FTitleExtraRects = [];
      this.FDataPointer = null;
      this.FDataBoolean = false;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FCache = undefined;
      this.FTextRects = undefined;
      this.FBitmapRects = undefined;
      this.FExpandRects = undefined;
      this.FCheckRects = undefined;
      this.FCheckStates = undefined;
      this.FNode = undefined;
      this.FExtraRects = undefined;
      this.FTitleRects = undefined;
      this.FTitleExtraRects = undefined;
      this.FDataObject = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetExpanded = function () {
      var Result = false;
      Result = this.FExpanded;
      if ((this.FTreeView != null) && this.FTreeView.FFilterApplied) Result = this.FFilterExpanded;
      return Result;
    };
    this.GetText = function (AColumn) {
      var Result = "";
      Result = "";
      if (this.FTreeView != null) Result = this.FTreeView.GetVirtualNodeText(this,AColumn);
      return Result;
    };
    this.GetTitle = function (AColumn) {
      var Result = "";
      Result = "";
      if (this.FTreeView != null) Result = this.FTreeView.GetVirtualNodeTitle(this,AColumn);
      return Result;
    };
    this.GetTitleExpanded = function (AColumn) {
      var Result = false;
      Result = true;
      if (this.FTreeView != null) Result = this.FTreeView.GetVirtualNodeTitleExpanded(this,AColumn);
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetParentVirtualNode(this);
      return Result;
    };
    this.GetChildCount = function () {
      var Result = 0;
      Result = 0;
      if (this.FTreeView != null) Result = this.FTreeView.GetVirtualNodeChildCount(this);
      return Result;
    };
    this.GetPrevious = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetPreviousVirtualNode(this);
      return Result;
    };
    this.GetNext = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNextVirtualNode(this);
      return Result;
    };
    this.GetPreviousChild = function (ANode) {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetPreviousChildVirtualNode(this,ANode);
      return Result;
    };
    this.GetNextChild = function (ANode) {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNextChildVirtualNode(this,ANode);
      return Result;
    };
    this.GetNextSibling = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNextSiblingVirtualNode(this);
      return Result;
    };
    this.GetPreviousSibling = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetPreviousSiblingVirtualNode(this);
      return Result;
    };
    this.GetFirstChild = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetFirstChildVirtualNode(this);
      return Result;
    };
    this.GetLastChild = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetLastChildVirtualNode(this);
      return Result;
    };
    this.RemoveChildren = function () {
      if (this.FTreeView != null) this.FTreeView.RemoveVirtualNodeChildren(this);
    };
    this.Expand = function (ARecurse) {
      if (this.FTreeView != null) this.FTreeView.ExpandVirtualNode(this,ARecurse);
    };
    this.Collapse = function (ARecurse) {
      if (this.FTreeView != null) this.FTreeView.CollapseVirtualNode(this,ARecurse);
    };
    this.CopyFrom = function (Source) {
      if (Source != null) {
        this.FChildren = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FChildren;
        this.FTotalChildren = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FTotalChildren;
        this.FExpanded = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FExpanded;
        this.FFilterExpanded = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FFilterExpanded;
        this.FExtended = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FExtended;
        this.FLevel = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FLevel;
        this.FRow = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FRow;
        this.FCalculated = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FCalculated;
        this.FHeight = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FHeight;
        this.FParentNode = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FParentNode;
        this.FIndex = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FIndex;
        this.FTextRects = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FTextRects;
        this.FExtraRects = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FExtraRects;
        this.FBitmapRects = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FBitmapRects;
        this.FCheckRects = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FCheckRects;
        this.FExpandRects = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FExpandRects;
        this.FCheckStates = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FCheckStates;
        this.FNode = rtl.as(Source,$mod.TTMSFNCTreeViewVirtualNode).FNode;
      };
    };
    this.Create$1 = function (ATreeView) {
      this.FTreeView = ATreeView;
      this.FFilterExpanded = false;
      return this;
    };
    this.Destroy = function () {
      this.FCache = null;
      this.FNode = null;
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.TTMSFNCTreeViewCacheItemKind = {"0": "ikNode", ikNode: 0, "1": "ikColumnTop", ikColumnTop: 1, "2": "ikColumnBottom", ikColumnBottom: 2, "3": "ikGroupTop", ikGroupTop: 3, "4": "ikGroupBottom", ikGroupBottom: 4};
  this.$rtti.$Enum("TTMSFNCTreeViewCacheItemKind",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCTreeViewCacheItemKind});
  rtl.createClass(this,"TTMSFNCTreeViewCacheItem",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FDrawRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FKind = 0;
      this.FGroup = 0;
      this.FColumn = 0;
      this.FNode = null;
      this.FRow = 0;
      this.FCol = 0;
      this.FStartColumn = 0;
      this.FEndColumn = 0;
    };
    this.$final = function () {
      this.FRect = undefined;
      this.FDrawRect = undefined;
      this.FNode = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.CreateNode = function (ARect, ANode) {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewCacheItem.$create("Create");
      Result.FKind = $mod.TTMSFNCTreeViewCacheItemKind.ikNode;
      Result.FRect.$assign(ARect);
      Result.FNode = ANode;
      return Result;
    };
    this.CreateColumnTop = function (ARect, AColumn) {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewCacheItem.$create("Create");
      Result.FKind = $mod.TTMSFNCTreeViewCacheItemKind.ikColumnTop;
      Result.FColumn = AColumn;
      Result.FRect.$assign(ARect);
      return Result;
    };
    this.CreateGroupTop = function (ARect, AGroup, AStartColumn, AEndColumn) {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewCacheItem.$create("Create");
      Result.FKind = $mod.TTMSFNCTreeViewCacheItemKind.ikGroupTop;
      Result.FGroup = AGroup;
      Result.FStartColumn = AStartColumn;
      Result.FEndColumn = AEndColumn;
      Result.FRect.$assign(ARect);
      return Result;
    };
    this.CreateColumnBottom = function (ARect, AColumn) {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewCacheItem.$create("Create");
      Result.FKind = $mod.TTMSFNCTreeViewCacheItemKind.ikColumnBottom;
      Result.FColumn = AColumn;
      Result.FRect.$assign(ARect);
      return Result;
    };
    this.CreateGroupBottom = function (ARect, AGroup, AStartColumn, AEndColumn) {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewCacheItem.$create("Create");
      Result.FKind = $mod.TTMSFNCTreeViewCacheItemKind.ikGroupBottom;
      Result.FGroup = AGroup;
      Result.FStartColumn = AStartColumn;
      Result.FEndColumn = AEndColumn;
      Result.FRect.$assign(ARect);
      return Result;
    };
    this.Destroy = function () {
      this.FNode = null;
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewCacheItemList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewIntegerList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = 0;
      Result = rtl.trunc(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  this.$rtti.$DynArray("TTMSFNCTreeViewVirtualNodeArray",{eltype: this.$rtti["TTMSFNCTreeViewVirtualNode"]});
  this.TTMSFNCTreeViewColumnEditorType = {"0": "tcetEdit", tcetEdit: 0, "1": "tcetComboBox", tcetComboBox: 1, "2": "tcetMemo", tcetMemo: 2, "3": "tcetNone", tcetNone: 3};
  this.$rtti.$Enum("TTMSFNCTreeViewColumnEditorType",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCTreeViewColumnEditorType});
  this.TTMSFNCTreeViewNodesSortMode = {"0": "nsmAscending", nsmAscending: 0, "1": "nsmDescending", nsmDescending: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewNodesSortMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewNodesSortMode});
  this.TTMSFNCTreeViewNodesSortKind = {"0": "nskNone", nskNone: 0, "1": "nskAscending", nskAscending: 1, "2": "nskDescending", nskDescending: 2};
  this.$rtti.$Enum("TTMSFNCTreeViewNodesSortKind",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCTreeViewNodesSortKind});
  this.TTMSFNCTreeViewColumnSorting = {"0": "tcsNone", tcsNone: 0, "1": "tcsNormal", tcsNormal: 1, "2": "tcsRecursive", tcsRecursive: 2, "3": "tcsNormalCaseSensitive", tcsNormalCaseSensitive: 3, "4": "tcsRecursiveCaseSensitive", tcsRecursiveCaseSensitive: 4};
  this.$rtti.$Enum("TTMSFNCTreeViewColumnSorting",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCTreeViewColumnSorting});
  rtl.createClass(this,"TTMSFNCTreeViewColumnFiltering",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FColumn = null;
      this.FEnabled = false;
      this.FMultiColumn = false;
      this.FDropDownHeight = 0;
      this.FDropDownWidth = 0;
      this.FButtonSize = 0.0;
    };
    this.$final = function () {
      this.FColumn = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        if (this.FColumn != null) this.FColumn.UpdateColumn();
      };
    };
    this.IsButtonSizeStored = function () {
      var Result = false;
      Result = this.FButtonSize !== 15;
      return Result;
    };
    this.SetButtonSize = function (Value) {
      if (this.FButtonSize !== Value) {
        this.FButtonSize = Value;
        if (this.FColumn != null) this.FColumn.UpdateColumn();
      };
    };
    this.Create$1 = function (AColumn) {
      this.FColumn = AColumn;
      this.FEnabled = false;
      this.FDropDownWidth = 100;
      this.FDropDownHeight = 120;
      this.FMultiColumn = false;
      this.FButtonSize = 15;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewColumnFiltering.isPrototypeOf(Source)) {
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCTreeViewColumnFiltering).FEnabled;
        this.FDropDownWidth = rtl.as(Source,$mod.TTMSFNCTreeViewColumnFiltering).FDropDownWidth;
        this.FDropDownHeight = rtl.as(Source,$mod.TTMSFNCTreeViewColumnFiltering).FDropDownHeight;
        this.FMultiColumn = rtl.as(Source,$mod.TTMSFNCTreeViewColumnFiltering).FMultiColumn;
        this.FButtonSize = rtl.as(Source,$mod.TTMSFNCTreeViewColumnFiltering).FButtonSize;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: false});
    $r.addProperty("DropDownWidth",0,rtl.longint,"FDropDownWidth","FDropDownWidth",4,{Default: 100});
    $r.addProperty("DropDownHeight",0,rtl.longint,"FDropDownHeight","FDropDownHeight",4,{Default: 120});
    $r.addProperty("MultiColumn",0,rtl.boolean,"FMultiColumn","FMultiColumn",4,{Default: false});
    $r.addProperty("ButtonSize",14,rtl.double,"FButtonSize","SetButtonSize",4,{stored: "IsButtonSizeStored"});
  });
  this.TTMSFNCTreeViewFilterOperation = {"0": "tfoSHORT", tfoSHORT: 0, "1": "tfoNONE", tfoNONE: 1, "2": "tfoAND", tfoAND: 2, "3": "tfoXOR", tfoXOR: 3, "4": "tfoOR", tfoOR: 4};
  this.$rtti.$Enum("TTMSFNCTreeViewFilterOperation",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCTreeViewFilterOperation});
  rtl.createClass(this,"TTMSFNCTreeViewFilterData",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FColumn = 0;
      this.FCondition = "";
      this.FCaseSensitive = false;
      this.FSuffix = "";
      this.FPrefix = "";
      this.FOperation = 0;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FCaseSensitive = true;
      return this;
    };
    this.Assign = function (Source) {
      var ASrcFilterData = null;
      ASrcFilterData = rtl.as(Source,$mod.TTMSFNCTreeViewFilterData);
      if (ASrcFilterData != null) {
        this.FColumn = ASrcFilterData.FColumn;
        this.FCondition = ASrcFilterData.FCondition;
        this.FCaseSensitive = ASrcFilterData.FCaseSensitive;
        this.FPrefix = ASrcFilterData.FPrefix;
        this.FSuffix = ASrcFilterData.FSuffix;
        this.FOperation = ASrcFilterData.FOperation;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Column",0,rtl.smallint,"FColumn","FColumn");
    $r.addProperty("Condition",0,rtl.string,"FCondition","FCondition");
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive",4,{Default: true});
    $r.addProperty("Prefix",0,rtl.string,"FPrefix","FPrefix");
    $r.addProperty("Suffix",0,rtl.string,"FSuffix","FSuffix");
    $r.addProperty("Operation",0,$mod.$rtti["TTMSFNCTreeViewFilterOperation"],"FOperation","FOperation");
  });
  rtl.createClass(this,"TTMSFNCTreeViewFilter",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.GetItem.call(this,Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.GetColFilter = function (Col) {
      var Result = null;
      var i = 0;
      for (var $l = 1, $end = this.GetCount(); $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i - 1).FColumn === Col) {
          Result = this.GetItem$1(i - 1);
          return Result;
        };
      };
      Result = this.Add$1();
      Result.FColumn = Col;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCTreeViewFilterData);
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      if (this.GetCount() === 1) {
        Result.FOperation = $mod.TTMSFNCTreeViewFilterOperation.tfoNONE}
       else Result.FOperation = $mod.TTMSFNCTreeViewFilterOperation.tfoAND;
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
    this.HasFilter = function (Col) {
      var Result = false;
      var i = 0;
      Result = false;
      for (var $l = 1, $end = this.GetCount(); $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i - 1).FColumn === Col) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.RemoveColumnFilter = function (Col) {
      var i = 0;
      i = this.GetCount();
      while (i > 0) {
        i -= 1;
        if (this.GetItem$1(i).FColumn === Col) this.Delete(i);
      };
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumn",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FSortKind = 0;
      this.FTag = 0;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FTreeView = null;
      this.FText = "";
      this.FName = "";
      this.FDBKey = "";
      this.FDataBoolean = false;
      this.FWordWrapping = false;
      this.FVerticalTextAlign = 0;
      this.FTrimming = 0;
      this.FHorizontalTextAlign = 0;
      this.FWidth = 0.0;
      this.FVisible = false;
      this.FUseDefaultAppearance = false;
      this.FBottomFill = null;
      this.FBottomStroke = null;
      this.FTopFill = null;
      this.FTopStroke = null;
      this.FTopFont = null;
      this.FBottomFont = null;
      this.FFont = null;
      this.FFill = null;
      this.FStroke = null;
      this.FEditorType = 0;
      this.FDisabledFontColor = 0;
      this.FSelectedFontColor = 0;
      this.FEditorItems = null;
      this.FCustomEditor = false;
      this.FSorting = 0;
      this.FSortIndex = 0;
      this.FFiltering = null;
      this.FDataPointer = null;
      this.FTitleTrimming = 0;
      this.FTitleHorizontalTextAlign = 0;
      this.FTitleWordWrapping = false;
      this.FTitleVerticalTextAlign = 0;
      this.FDisabledTitleFontColor = 0;
      this.FSelectedTitleFontColor = 0;
      this.FTitleFont = null;
      this.FExpanded = false;
      this.FExpandable = false;
      this.FExpandingButtonSize = 0.0;
      this.FHTMLTemplate = "";
      this.FMinimumWidth = 0.0;
    };
    this.$final = function () {
      this.FDataObject = undefined;
      this.FTreeView = undefined;
      this.FBottomFill = undefined;
      this.FBottomStroke = undefined;
      this.FTopFill = undefined;
      this.FTopStroke = undefined;
      this.FTopFont = undefined;
      this.FBottomFont = undefined;
      this.FFont = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FEditorItems = undefined;
      this.FFiltering = undefined;
      this.FTitleFont = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.UpdateColumn();
      };
    };
    this.SetName = function (Value) {
      if (this.FName !== Value) {
        this.FName = Value;
      };
    };
    this.SetHorizontalTextAlign = function (Value) {
      if (this.FHorizontalTextAlign !== Value) {
        this.FHorizontalTextAlign = Value;
        this.UpdateColumn();
      };
    };
    this.SetTrimming = function (Value) {
      if (this.FTrimming !== Value) {
        this.FTrimming = Value;
        this.UpdateColumn();
      };
    };
    this.SetVerticalTextAlign = function (Value) {
      if (this.FVerticalTextAlign !== Value) {
        this.FVerticalTextAlign = Value;
        this.UpdateColumn();
      };
    };
    this.SetWordWrapping = function (Value) {
      if (this.FWordWrapping !== Value) {
        this.FWordWrapping = Value;
        this.UpdateColumn();
      };
    };
    this.SetWidth = function (Value) {
      if (this.FWidth !== Value) {
        this.FWidth = Value;
        this.UpdateColumn();
      };
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.UpdateColumn();
      };
    };
    this.SetUseDefaultAppearance = function (Value) {
      if (this.FUseDefaultAppearance !== Value) {
        this.FUseDefaultAppearance = Value;
        this.UpdateColumn();
      };
    };
    this.SetBottomFill = function (Value) {
      if (this.FBottomFill !== Value) this.FBottomFill.Assign(Value);
    };
    this.SetBottomStroke = function (Value) {
      if (this.FBottomStroke !== Value) this.FBottomStroke.Assign(Value);
    };
    this.SetTopFill = function (Value) {
      if (this.FTopFill !== Value) this.FTopFill.Assign(Value);
    };
    this.SetTopStroke = function (Value) {
      if (this.FTopStroke !== Value) this.FTopStroke.Assign(Value);
    };
    this.SetBottomFont = function (Value) {
      if (this.FBottomFont !== Value) this.FBottomFont.Assign(Value);
    };
    this.SetTopFont = function (Value) {
      if (this.FTopFont !== Value) this.FTopFont.Assign(Value);
    };
    this.SetFill = function (Value) {
      if (this.FFill !== Value) this.FFill.Assign(Value);
    };
    this.SetFont = function (Value) {
      if (this.FFont !== Value) this.FFont.Assign(Value);
    };
    this.SetStroke = function (Value) {
      if (this.FStroke !== Value) this.FStroke.Assign(Value);
    };
    this.SetEditorType = function (Value) {
      if (this.FEditorType !== Value) this.FEditorType = Value;
    };
    this.SetDisabledFontColor = function (Value) {
      if (this.FDisabledFontColor !== Value) {
        this.FDisabledFontColor = Value;
        this.Changed$1(this);
      };
    };
    this.SetSelectedFontColor = function (Value) {
      if (this.FSelectedFontColor !== Value) {
        this.FSelectedFontColor = Value;
        this.Changed$1(this);
      };
    };
    this.SetEditorItems = function (Value) {
      this.FEditorItems.Assign(Value);
    };
    this.SetSorting = function (Value) {
      if (this.FSorting !== Value) {
        this.FSorting = Value;
        this.Changed$1(this);
      };
    };
    this.SetSortKind = function (Value) {
      if (this.FSortKind !== Value) {
        this.FSortKind = Value;
        this.Changed$1(this);
      };
    };
    this.SetSortIndex = function (Value) {
      if (this.FSortIndex !== Value) {
        this.FSortIndex = Value;
        this.Changed$1(this);
      };
    };
    this.SetFiltering = function (Value) {
      if (this.FFiltering !== Value) this.FFiltering.Assign(Value);
    };
    this.SetTitleHorizontalTextAlign = function (Value) {
      if (this.FTitleHorizontalTextAlign !== Value) {
        this.FTitleHorizontalTextAlign = Value;
        this.UpdateColumn();
      };
    };
    this.SetTitleTrimming = function (Value) {
      if (this.FTitleTrimming !== Value) {
        this.FTitleTrimming = Value;
        this.UpdateColumn();
      };
    };
    this.SetTitleVerticalTextAlign = function (Value) {
      if (this.FTitleVerticalTextAlign !== Value) {
        this.FTitleVerticalTextAlign = Value;
        this.UpdateColumn();
      };
    };
    this.SetTitleWordWrapping = function (Value) {
      if (this.FTitleWordWrapping !== Value) {
        this.FTitleWordWrapping = Value;
        this.UpdateColumn();
      };
    };
    this.SetDisabledTitleFontColor = function (Value) {
      if (this.FDisabledTitleFontColor !== Value) {
        this.FDisabledTitleFontColor = Value;
        this.UpdateColumn();
      };
    };
    this.SetSelectedTitleFontColor = function (Value) {
      if (this.FSelectedTitleFontColor !== Value) {
        this.FSelectedTitleFontColor = Value;
        this.Changed$1(this);
      };
    };
    this.SetTitleFont = function (Value) {
      if (this.FTitleFont !== Value) this.FTitleFont.Assign(Value);
    };
    this.SetExpanded = function (Value) {
      if (this.FExpanded !== Value) {
        this.FExpanded = Value;
        this.UpdateColumn();
      };
    };
    this.SetExpandable = function (Value) {
      if (this.FExpandable !== Value) {
        this.FExpandable = Value;
        this.UpdateColumn();
      };
    };
    this.IsExpandingButtonSizeStored = function () {
      var Result = false;
      Result = this.FExpandingButtonSize !== 15;
      return Result;
    };
    this.SetExpandingButtonSize = function (Value) {
      this.FExpandingButtonSize = Value;
    };
    this.SetHTMLTemplate = function (Value) {
      if (this.FHTMLTemplate !== Value) {
        this.FHTMLTemplate = Value;
        if (this.FTreeView != null) this.FTreeView.UpdateTreeView();
      };
    };
    this.SetMinimumWidth = function (Value) {
      if (this.FMinimumWidth !== Value) {
        this.FMinimumWidth = Value;
        this.UpdateColumn();
      };
    };
    this.UpdateColumn = function () {
      var t = null;
      t = this.TreeView();
      if (t != null) {
        t.UpdateColumns();
        t.UpdateTreeViewCache();
      };
    };
    this.Changed$1 = function (Sender) {
      this.UpdateColumn();
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FText;
      if (Result === "") {
        Result = this.FName;
        if (Result === "") Result = $mod.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCTreeViewColumn")) + " " + pas.SysUtils.IntToStr(this.GetIndex());
      };
      return Result;
    };
    this.GetColumnText = function () {
      var Result = "";
      Result = this.FText;
      if ((Result === "") || (pas.System.Pos("</",Result) > 0) || (pas.System.Pos("/>",Result) > 0) || (pas.System.Pos("<BR>",pas.SysUtils.UpperCase(Result)) > 0)) {
        Result = this.FName;
        if (Result === "") Result = $mod.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCTreeViewColumn")) + " " + pas.SysUtils.IntToStr(this.GetIndex());
      };
      return Result;
    };
    this.GetDisplayName = function () {
      var Result = "";
      if (this.FName !== "") {
        Result = this.FName}
       else Result = "";
      return Result;
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FTreeView = rtl.as(this.FCollection,$mod.TTMSFNCTreeViewColumns).TreeView();
      this.FSorting = $mod.TTMSFNCTreeViewColumnSorting.tcsNone;
      this.FExpandingButtonSize = 15;
      this.FExpanded = true;
      this.FSortIndex = -1;
      this.FSortKind = $mod.TTMSFNCTreeViewNodesSortKind.nskNone;
      this.FFiltering = $mod.TTMSFNCTreeViewColumnFiltering.$create("Create$1",[this]);
      this.FEditorType = $mod.TTMSFNCTreeViewColumnEditorType.tcetNone;
      this.FWordWrapping = false;
      this.FTrimming = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
      this.FCustomEditor = false;
      this.FHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FTitleWordWrapping = false;
      this.FTitleTrimming = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
      this.FTitleHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FTitleVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FEditorItems = pas.Classes.TStringList.$create("Create$1");
      if (this.FCollection != null) this.FText = $mod.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCTreeViewColumn")) + " " + pas.SysUtils.IntToStr(this.FCollection.GetCount() - 1);
      this.FName = pas.SysUtils.StringReplace(this.FText," ","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      this.FWidth = 100;
      this.FVisible = true;
      this.FUseDefaultAppearance = true;
      this.FBottomFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone,16777215,8421504,-1,-1]);
      this.FBottomStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FTopFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone,16777215,8421504,-1,-1]);
      this.FTopStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,-1,8421504,-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FSelectedFontColor = 16777215;
      this.FDisabledFontColor = 12632256;
      this.FSelectedTitleFontColor = 16777215;
      this.FDisabledTitleFontColor = 12632256;
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FTitleFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FTopFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBottomFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBottomFill.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTopFill.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FBottomStroke.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTopStroke.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FStroke.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FFill.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FFont.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTitleFont.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTopFont.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FBottomFont.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.UpdateColumn();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFiltering");
      rtl.free(this,"FEditorItems");
      rtl.free(this,"FTopFill");
      rtl.free(this,"FTopStroke");
      rtl.free(this,"FTopFont");
      rtl.free(this,"FBottomFill");
      rtl.free(this,"FBottomStroke");
      rtl.free(this,"FBottomFont");
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FFont");
      rtl.free(this,"FTitleFont");
      pas.Classes.TCollectionItem.Destroy.call(this);
      this.UpdateColumn();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewColumn.isPrototypeOf(Source)) {
        this.FTag = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTag;
        this.FText = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FText;
        this.FName = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FName;
        this.FTrimming = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTrimming;
        this.FWordWrapping = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FWordWrapping;
        this.FHorizontalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FHorizontalTextAlign;
        this.FVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FVerticalTextAlign;
        this.FTitleTrimming = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTitleTrimming;
        this.FTitleWordWrapping = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTitleWordWrapping;
        this.FTitleHorizontalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTitleHorizontalTextAlign;
        this.FTitleVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTitleVerticalTextAlign;
        this.FWidth = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FWidth;
        this.FVisible = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FVisible;
        this.FUseDefaultAppearance = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FUseDefaultAppearance;
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FFill);
        this.FDisabledFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FDisabledFontColor;
        this.FSelectedFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FSelectedFontColor;
        this.FDisabledTitleFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FDisabledTitleFontColor;
        this.FSelectedTitleFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FSelectedTitleFontColor;
        this.FTitleFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTitleFont);
        this.FFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FFont);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FStroke);
        this.FBottomFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FBottomFill);
        this.FBottomFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FBottomFont);
        this.FBottomStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FBottomStroke);
        this.FTopFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTopFill);
        this.FTopStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTopStroke);
        this.FTopFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FTopFont);
        this.FEditorType = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FEditorType;
        this.FEditorItems.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FEditorItems);
        this.FCustomEditor = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FCustomEditor;
        this.FSorting = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FSorting;
        this.FFiltering.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FFiltering);
        this.FExpandingButtonSize = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FExpandingButtonSize;
        this.FHTMLTemplate = rtl.as(Source,$mod.TTMSFNCTreeViewColumn).FHTMLTemplate;
      };
    };
    this.UpdateWidth = function (AWidth) {
      this.FWidth = AWidth;
    };
    this.Sort = function (ARecurse, ACaseSensitive, ASortingMode) {
      var t = null;
      t = this.TreeView();
      if (t != null) t.FNodes.Sort$1(this.GetIndex(),ARecurse,ACaseSensitive,ASortingMode,true);
    };
    var $r = this.$rtti;
    $r.addProperty("EditorType",2,$mod.$rtti["TTMSFNCTreeViewColumnEditorType"],"FEditorType","SetEditorType",4,{Default: $mod.TTMSFNCTreeViewColumnEditorType.tcetNone});
    $r.addProperty("EditorItems",2,pas.Classes.$rtti["TStringList"],"FEditorItems","SetEditorItems");
    $r.addProperty("CustomEditor",0,rtl.boolean,"FCustomEditor","FCustomEditor",4,{Default: false});
    $r.addProperty("Name",2,rtl.string,"FName","SetName");
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",4,{Default: 0});
    $r.addProperty("HorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalTextAlign","SetHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("VerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("WordWrapping",2,rtl.boolean,"FWordWrapping","SetWordWrapping",4,{Default: false});
    $r.addProperty("Trimming",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],"FTrimming","SetTrimming",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone});
    $r.addProperty("MinimumWidth",2,rtl.double,"FMinimumWidth","SetMinimumWidth");
    $r.addProperty("Width",2,rtl.double,"FWidth","SetWidth");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("UseDefaultAppearance",2,rtl.boolean,"FUseDefaultAppearance","SetUseDefaultAppearance",4,{Default: true});
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
    $r.addProperty("SelectedFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedFontColor","SetSelectedFontColor",4,{Default: 16777215});
    $r.addProperty("DisabledFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledFontColor","SetDisabledFontColor",4,{Default: 12632256});
    $r.addProperty("TopFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FTopFill","SetTopFill");
    $r.addProperty("TopStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FTopStroke","SetTopStroke");
    $r.addProperty("TopFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FTopFont","SetTopFont");
    $r.addProperty("BottomFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FBottomFill","SetBottomFill");
    $r.addProperty("BottomStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FBottomStroke","SetBottomStroke");
    $r.addProperty("BottomFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FBottomFont","SetBottomFont");
    $r.addProperty("Sorting",2,$mod.$rtti["TTMSFNCTreeViewColumnSorting"],"FSorting","SetSorting",4,{Default: $mod.TTMSFNCTreeViewColumnSorting.tcsNone});
    $r.addProperty("Filtering",2,$mod.$rtti["TTMSFNCTreeViewColumnFiltering"],"FFiltering","SetFiltering");
    $r.addProperty("HTMLTemplate",2,rtl.string,"FHTMLTemplate","SetHTMLTemplate");
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumns",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FTreeView = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.GetItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewColumn;
      return Result;
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Create$3 = function (ATreeView) {
      pas.Classes.TOwnedCollection.Create$2.call(this,ATreeView,this.GetItemClass());
      this.FTreeView = ATreeView;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$Class("TTMSFNCTreeViewNodes");
  this.TTMSFNCTreeViewNodeCheckType = {"0": "tvntNone", tvntNone: 0, "1": "tvntCheckBox", tvntCheckBox: 1, "2": "tvntRadioButton", tvntRadioButton: 2};
  this.$rtti.$Enum("TTMSFNCTreeViewNodeCheckType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCTreeViewNodeCheckType});
  rtl.createClass(this,"TTMSFNCTreeViewNodeValue",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FTag = 0;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FTreeView = null;
      this.FNode = null;
      this.FText = "";
      this.FDBKey = "";
      this.FDataBoolean = false;
      this.FCheckType = 0;
      this.FChecked = false;
      this.FCollapsedIcon = null;
      this.FCollapsedIconLarge = null;
      this.FExpandedIcon = null;
      this.FExpandedIconLarge = null;
      this.FCollapsedIconName = "";
      this.FCollapsedIconLargeName = "";
      this.FExpandedIconName = "";
      this.FExpandedIconLargeName = "";
      this.FDataPointer = null;
      this.FTitle = "";
      this.FTitleExpanded = false;
      this.FHTMLTemplateItems = null;
    };
    this.$final = function () {
      this.FDataObject = undefined;
      this.FTreeView = undefined;
      this.FNode = undefined;
      this.FCollapsedIcon = undefined;
      this.FCollapsedIconLarge = undefined;
      this.FExpandedIcon = undefined;
      this.FExpandedIconLarge = undefined;
      this.FHTMLTemplateItems = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.UpdateNodeValue();
      };
    };
    this.UpdateNodeValue = function () {
      var c = null;
      var n = null;
      c = this.TreeView();
      n = this.Node();
      if ((c != null) && (n != null)) c.UpdateNode(n.FVirtualNode);
    };
    this.SetChecked = function (Value) {
      var chkst = [];
      var I = 0;
      var chk = false;
      var t = null;
      var n = null;
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        t = this.TreeView();
        n = this.Node();
        if ((t != null) && (n != null) && (n.FVirtualNode != null)) {
          chkst = rtl.arraySetLength(chkst,false,0);
          for (var $l = 0, $end = t.FColumnCount - 1; $l <= $end; $l++) {
            I = $l;
            chk = false;
            this.TreeView().DoIsNodeChecked(this.Node().FVirtualNode,I,{get: function () {
                return chk;
              }, set: function (v) {
                chk = v;
              }});
            chkst = rtl.arraySetLength(chkst,false,rtl.length(chkst) + 1);
            chkst[rtl.length(chkst) - 1] = chk;
          };
          this.TreeView().UpdateNodeCheckStates(this.Node().FVirtualNode,rtl.arrayRef(chkst));
        };
        this.UpdateNodeValue();
      };
    };
    this.SetCheckType = function (Value) {
      if (this.FCheckType !== Value) {
        this.FCheckType = Value;
        this.UpdateNodeValue();
      };
    };
    this.SetCollapsedIconLarge = function (Value) {
      if (this.FCollapsedIconLarge !== Value) {
        this.FCollapsedIconLarge.Assign(Value);
        this.UpdateNodeValue();
      };
    };
    this.SetCollapsedIcon = function (Value) {
      if (this.FCollapsedIcon !== Value) {
        this.FCollapsedIcon.Assign(Value);
        this.UpdateNodeValue();
      };
    };
    this.SetExpandedIconLarge = function (Value) {
      if (this.FExpandedIconLarge !== Value) {
        this.FExpandedIconLarge.Assign(Value);
        this.UpdateNodeValue();
      };
    };
    this.SetExpandedIcon = function (Value) {
      if (this.FExpandedIcon !== Value) {
        this.FExpandedIcon.Assign(Value);
        this.UpdateNodeValue();
      };
    };
    this.SetCollapsedIconLargeName = function (Value) {
      if (this.FCollapsedIconLargeName !== Value) {
        this.FCollapsedIconLargeName = Value;
        this.UpdateNodeValue();
      };
    };
    this.SetCollapsedIconName = function (Value) {
      if (this.FCollapsedIconName !== Value) {
        this.FCollapsedIconName = Value;
        this.UpdateNodeValue();
      };
    };
    this.SetExpandedIconLargeName = function (Value) {
      if (this.FExpandedIconLargeName !== Value) {
        this.FExpandedIconLargeName = Value;
        this.UpdateNodeValue();
      };
    };
    this.SetExpandedIconName = function (Value) {
      if (this.FExpandedIconName !== Value) {
        this.FExpandedIconName = Value;
        this.UpdateNodeValue();
      };
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetBitmapContainer();
      return Result;
    };
    this.SetTitle = function (Value) {
      if (this.FTitle !== Value) {
        this.FTitle = Value;
        this.UpdateNodeValue();
      };
    };
    this.SetTitleExpanded = function (Value) {
      if (this.FTitleExpanded !== Value) {
        this.FTitleExpanded = Value;
        this.UpdateNodeValue();
      };
    };
    this.SetHTMLTemplateItems = function (Value) {
      if (this.FHTMLTemplateItems !== Value) {
        this.FHTMLTemplateItems.Assign(Value);
        this.UpdateNodeValue();
      };
    };
    this.BitmapChanged = function (Sender) {
      this.UpdateNodeValue();
    };
    this.TemplateItemsChanged = function (Sender) {
      this.UpdateNodeValue();
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Node = function () {
      var Result = null;
      Result = this.FNode;
      return Result;
    };
    this.GetText = function () {
      var Result = "";
      var ht = "";
      var s = "";
      s = this.FText;
      if (this.FTreeView != null) {
        ht = this.FTreeView.GetHTMLTemplate(this.GetIndex());
        this.FTreeView.DoGetHTMLTemplate(this,this.GetIndex(),{get: function () {
            return ht;
          }, set: function (v) {
            ht = v;
          }});
        if (ht !== "") s = this.FTreeView.HTMLReplace(ht,this);
      };
      Result = s;
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) {
        this.FTreeView = rtl.as(this.FCollection,$mod.TTMSFNCTreeViewNodeValues).TreeView();
        this.FNode = rtl.as(this.FCollection,$mod.TTMSFNCTreeViewNodeValues).Node();
      };
      this.FChecked = false;
      this.FTitleExpanded = true;
      this.FCheckType = $mod.TTMSFNCTreeViewNodeCheckType.tvntNone;
      this.FCollapsedIcon = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FCollapsedIcon.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FExpandedIcon = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FExpandedIcon.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FCollapsedIconLarge = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FCollapsedIconLarge.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FExpandedIconLarge = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FExpandedIconLarge.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FHTMLTemplateItems = pas.Classes.TStringList.$create("Create$1");
      this.FHTMLTemplateItems.FOnChange = rtl.createCallback(this,"TemplateItemsChanged");
      this.UpdateNodeValue();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHTMLTemplateItems");
      rtl.free(this,"FCollapsedIcon");
      rtl.free(this,"FCollapsedIconLarge");
      rtl.free(this,"FExpandedIcon");
      rtl.free(this,"FExpandedIconLarge");
      pas.Classes.TCollectionItem.Destroy.call(this);
      this.UpdateNodeValue();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewNodeValue.isPrototypeOf(Source)) {
        this.FTag = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FTag;
        this.FText = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FText;
        this.FTitleExpanded = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FTitleExpanded;
        this.FTitle = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FTitle;
        this.FCheckType = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FCheckType;
        this.FChecked = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FChecked;
        this.FCollapsedIcon.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FCollapsedIcon);
        this.FCollapsedIconLarge.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FCollapsedIconLarge);
        this.FExpandedIcon.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FExpandedIcon);
        this.FExpandedIconLarge.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FExpandedIconLarge);
        this.FCollapsedIconName = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FCollapsedIconName;
        this.FCollapsedIconLargeName = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FCollapsedIconLargeName;
        this.FExpandedIconName = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FExpandedIconName;
        this.FExpandedIconLargeName = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FExpandedIconLargeName;
        this.FHTMLTemplateItems.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FHTMLTemplateItems);
        this.AssignData(Source);
      };
    };
    this.AssignData = function (Source) {
      if ($mod.TTMSFNCTreeViewNodeValue.isPrototypeOf(Source)) {
        this.FDataString = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FDataString;
        this.FDataPointer = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FDataPointer;
        this.FDataBoolean = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FDataBoolean;
        this.FDataObject = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FDataObject;
        this.FDataInteger = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FDataInteger;
        this.FDBKey = rtl.as(Source,$mod.TTMSFNCTreeViewNodeValue).FDBKey;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",4,{Default: 0});
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("CollapsedIconName",2,rtl.string,"FCollapsedIconName","SetCollapsedIconName");
    $r.addProperty("CollapsedIconLargeName",2,rtl.string,"FCollapsedIconLargeName","SetCollapsedIconLargeName");
    $r.addProperty("ExpandedIconName",2,rtl.string,"FExpandedIconName","SetExpandedIconName");
    $r.addProperty("ExpandedIconLargeName",2,rtl.string,"FExpandedIconLargeName","SetExpandedIconLargeName");
    $r.addProperty("CollapsedIcon",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FCollapsedIcon","SetCollapsedIcon");
    $r.addProperty("CollapsedIconLarge",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FCollapsedIconLarge","SetCollapsedIconLarge");
    $r.addProperty("ExpandedIcon",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FExpandedIcon","SetExpandedIcon");
    $r.addProperty("ExpandedIconLarge",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FExpandedIconLarge","SetExpandedIconLarge");
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",4,{Default: false});
    $r.addProperty("CheckType",2,$mod.$rtti["TTMSFNCTreeViewNodeCheckType"],"FCheckType","SetCheckType",4,{Default: $mod.TTMSFNCTreeViewNodeCheckType.tvntNone});
    $r.addProperty("HTMLTemplateItems",2,pas.Classes.$rtti["TStringList"],"FHTMLTemplateItems","SetHTMLTemplateItems");
  });
  rtl.createClass(this,"TTMSFNCTreeViewNodeValues",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FTreeView = null;
      this.FNode = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FNode = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.GetItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewNodeValue;
      return Result;
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Node = function () {
      var Result = null;
      Result = this.FNode;
      return Result;
    };
    this.UpdateChecked = function (AIndex, AValue) {
      if (this.FTreeView != null) this.FTreeView.FUpdateCount$1 = this.FTreeView.FUpdateCount$1 + 1;
      this.GetItem$1(AIndex).SetChecked(AValue);
      if (this.FTreeView != null) this.FTreeView.FUpdateCount$1 = this.FTreeView.FUpdateCount$1 - 1;
    };
    this.Create$3 = function (ATreeView, ANode) {
      pas.Classes.TOwnedCollection.Create$2.call(this,ATreeView,this.GetItemClass());
      this.FTreeView = ATreeView;
      this.FNode = ANode;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$DynArray("TTMSFNCTreeViewNodeTextValues",{eltype: rtl.string});
  this.$rtti.$DynArray("TTMSFNCTreeViewNodeCheckStates",{eltype: rtl.boolean});
  this.$rtti.$DynArray("TTMSFNCTreeViewNodeCheckTypes",{eltype: this.$rtti["TTMSFNCTreeViewNodeCheckType"]});
  this.$rtti.$DynArray("TTMSFNCTreeViewNodeIcons",{eltype: pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]});
  this.$rtti.$DynArray("TTMSFNCTreeViewNodeIconNames",{eltype: rtl.string});
  rtl.createClass(this,"TTMSFNCTreeViewNode",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FTag = 0;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FTreeView = null;
      this.FValues = null;
      this.FDBKey = "";
      this.FDataBoolean = false;
      this.FNodes = null;
      this.FVirtualNode = null;
      this.FExpanded = false;
      this.FEnabled = false;
      this.FExtended = false;
      this.FDataPointer = null;
    };
    this.$final = function () {
      this.FDataObject = undefined;
      this.FTreeView = undefined;
      this.FValues = undefined;
      this.FNodes = undefined;
      this.FVirtualNode = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetValues = function (Value) {
      if (this.FValues !== Value) {
        this.FValues.Assign(Value);
        this.UpdateNode();
      };
    };
    this.SetNodes = function (Value) {
      if (this.FNodes !== Value) {
        this.FNodes.Assign(Value);
        this.UpdateNode();
      };
    };
    this.SetExpanded = function (Value) {
      if (this.FExpanded !== Value) {
        this.FExpanded = Value;
        if (this.FTreeView != null) this.FTreeView.ToggleNode(this);
      };
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.UpdateNode();
      };
    };
    this.SetExtended = function (Value) {
      if (this.FExtended !== Value) {
        this.FExtended = Value;
        this.UpdateNode();
      };
    };
    this.GetChecked = function (AColumn) {
      var Result = false;
      var v = null;
      Result = false;
      v = this.GetValueForColumn(AColumn);
      if (v != null) Result = v.FChecked;
      return Result;
    };
    this.SetChecked = function (AColumn, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) v.SetChecked(Value);
    };
    this.GetCheckType = function (AColumn) {
      var Result = 0;
      var v = null;
      Result = $mod.TTMSFNCTreeViewNodeCheckType.tvntNone;
      v = this.GetValueForColumn(AColumn);
      if (v != null) Result = v.FCheckType;
      return Result;
    };
    this.GetCollapsedIcon = function (AColumn, ALarge) {
      var Result = null;
      var v = null;
      Result = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          Result = v.FCollapsedIconLarge}
         else Result = v.FCollapsedIcon;
      };
      return Result;
    };
    this.GetCollapsedIconName = function (AColumn, ALarge) {
      var Result = "";
      var v = null;
      Result = "";
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          Result = v.FCollapsedIconLargeName}
         else Result = v.FCollapsedIconName;
      };
      return Result;
    };
    this.GetExpandedIcon = function (AColumn, ALarge) {
      var Result = null;
      var v = null;
      Result = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          Result = v.FExpandedIconLarge}
         else Result = v.FExpandedIcon;
      };
      return Result;
    };
    this.GetExpandedIconName = function (AColumn, ALarge) {
      var Result = "";
      var v = null;
      Result = "";
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          Result = v.FExpandedIconLargeName}
         else Result = v.FExpandedIconName;
      };
      return Result;
    };
    this.GetText = function (AColumn) {
      var Result = "";
      var v = null;
      Result = "";
      v = this.GetValueForColumn(AColumn);
      if (v != null) Result = v.FText;
      return Result;
    };
    this.SetCheckType = function (AColumn, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) v.SetCheckType(Value);
    };
    this.SetCollapsedIcon = function (AColumn, ALarge, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          v.FCollapsedIconLarge.Assign(Value)}
         else v.FCollapsedIcon.Assign(Value);
      };
    };
    this.SetCollapsedIconName = function (AColumn, ALarge, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          v.SetCollapsedIconLargeName(Value)}
         else v.SetCollapsedIconName(Value);
      };
    };
    this.SetExpandedIcon = function (AColumn, ALarge, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          v.FExpandedIconLarge.Assign(Value)}
         else v.FExpandedIcon.Assign(Value);
      };
    };
    this.SetExpandedIconName = function (AColumn, ALarge, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) {
        if (ALarge) {
          v.SetExpandedIconLargeName(Value)}
         else v.SetExpandedIconName(Value);
      };
    };
    this.SetText = function (AColumn, Value) {
      var v = null;
      v = this.GetValueForColumn(AColumn);
      if (v != null) v.SetText(Value);
    };
    this.GetStrippedHTMLText = function (AColumn) {
      var Result = "";
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(this.GetText(AColumn));
      return Result;
    };
    this.UpdateNode = function () {
      var c = null;
      c = this.TreeView();
      if (c != null) {
        if (this.FTreeView.FNodeListBuild) {
          c.UpdateNode(this.FVirtualNode)}
         else c.UpdateTreeViewCache();
      };
    };
    this.GetValueForColumn = function (AColumn) {
      var Result = null;
      var I = 0;
      Result = null;
      if ((AColumn >= 0) && (AColumn <= (this.FValues.GetCount() - 1))) {
        Result = this.FValues.GetItem$1(AColumn);
        return Result;
      };
      this.FTreeView.FBlockUpdateNode = true;
      for (var $l = 0, $end = AColumn; $l <= $end; $l++) {
        I = $l;
        if (I > (this.FValues.GetCount() - 1)) Result = this.FValues.Add$1();
      };
      this.FTreeView.FBlockUpdateNode = false;
      return Result;
    };
    this.CreateNodes = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewNodes.$create("Create$3",[this.FTreeView,this]);
      return Result;
    };
    this.CreateNodeValues = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewNodeValues.$create("Create$3",[this.FTreeView,this]);
      return Result;
    };
    this.SetIndex = function (Value) {
      var $Self = this;
      function InsertSubNodes(ANodes) {
        var I = 0;
        for (var $l = 0, $end = ANodes.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          $Self.FTreeView.InsertItemInternal(ANodes.GetItem$1(I));
          InsertSubNodes(ANodes.GetItem$1(I).FNodes);
        };
      };
      pas.Classes.TCollectionItem.SetIndex.apply(this,arguments);
      if (this.FTreeView != null) {
        if (this.FTreeView.FNodeListBuild) {
          this.FTreeView.RemoveItemInternal($Self,true);
          this.FTreeView.InsertItemInternal($Self);
          InsertSubNodes(this.FNodes);
        } else this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.ValuesChanged = function (Sender) {
      this.UpdateNode();
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetParentNode(this);
      return Result;
    };
    this.GetChildCount = function () {
      var Result = 0;
      Result = 0;
      if (this.FTreeView != null) Result = this.FTreeView.GetNodeChildCount(this);
      return Result;
    };
    this.GetPrevious = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetPreviousNode(this);
      return Result;
    };
    this.GetNext = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNextNode(this);
      return Result;
    };
    this.GetPreviousChild = function (ANode) {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetPreviousChildNode(this,ANode);
      return Result;
    };
    this.GetNextChild = function (ANode) {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNextChildNode(this,ANode);
      return Result;
    };
    this.GetNextSibling = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNextSiblingNode(this);
      return Result;
    };
    this.GetPreviousSibling = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetPreviousSiblingNode(this);
      return Result;
    };
    this.GetFirstChild = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetFirstChildNode(this);
      return Result;
    };
    this.GetLastChild = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetLastChildNode(this);
      return Result;
    };
    var TabChar = "\t";
    this.SaveToString = function (ATextOnly) {
      var Result = "";
      var vn = null;
      var I = 0;
      if (!(this.FTreeView != null)) return Result;
      vn = this.FVirtualNode;
      Result = "";
      for (var $l = 0, $end = vn.FLevel - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + TabChar;
      };
      for (var $l1 = 0, $end1 = this.FTreeView.FColumnCount - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        if (ATextOnly) {
          if (I === (this.FTreeView.FColumnCount - 1)) {
            Result = Result + this.GetStrippedHTMLText(I)}
           else Result = Result + this.GetStrippedHTMLText(I) + "{1}";
        } else {
          if (I === (this.FTreeView.FColumnCount - 1)) {
            Result = Result + this.GetText(I)}
           else Result = Result + this.GetText(I) + "{1}";
        };
      };
      if (!ATextOnly) Result = Result + "{0}";
      for (var $l2 = 0, $end2 = this.FTreeView.FColumnCount - 1; $l2 <= $end2; $l2++) {
        I = $l2;
        if (!ATextOnly) {
          Result = Result + pas.SysUtils.IntToStr(this.GetCheckType(I)) + ";";
          Result = Result + pas.SysUtils.BoolToStr(this.GetChecked(I),false) + ";";
          Result = Result + this.GetExpandedIconName(I,false) + ";";
          Result = Result + this.GetExpandedIconName(I,true) + ";";
          Result = Result + this.GetCollapsedIconName(I,false) + ";";
          Result = Result + this.GetCollapsedIconName(I,true) + ";";
          Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SaveBitmapToHexStr(this.GetExpandedIcon(I,false)) + ";";
          Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SaveBitmapToHexStr(this.GetExpandedIcon(I,true)) + ";";
          Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SaveBitmapToHexStr(this.GetCollapsedIcon(I,false)) + ";";
          if (I === (this.FValues.GetCount() - 1)) {
            Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SaveBitmapToHexStr(this.GetCollapsedIcon(I,true))}
           else Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SaveBitmapToHexStr(this.GetCollapsedIcon(I,true)) + "|";
        };
      };
      if (!ATextOnly) {
        Result = Result + "{0}";
        Result = Result + pas.SysUtils.BoolToStr(this.FExtended,false) + "{0}";
        Result = Result + pas.SysUtils.BoolToStr(this.FEnabled,false);
      };
      return Result;
    };
    this.LoadFromString = function (AString) {
      var k = 0;
      var l = 0;
      var a = null;
      var c = null;
      var s = null;
      var y = 0;
      var st = "";
      var ps = 0;
      var subst = "";
      a = pas.Classes.TStringList.$create("Create$1");
      try {
        st = AString;
        while (st !== "") {
          ps = pas.System.Pos("{0}",st);
          if (ps === 0) {
            a.Add(st);
            break;
          };
          subst = pas.System.Copy(st,1,ps - 1);
          a.Add(subst);
          pas.System.Delete({get: function () {
              return st;
            }, set: function (v) {
              st = v;
            }},1,(ps - 1) + "{0}".length);
        };
        for (var $l = 0, $end = a.GetCount() - 1; $l <= $end; $l++) {
          k = $l;
          if (a.Get(k) !== "") {
            if (k === 0) {
              c = pas.Classes.TStringList.$create("Create$1");
              try {
                st = a.Get(k);
                while (st !== "") {
                  ps = pas.System.Pos("{1}",st);
                  if (ps === 0) {
                    c.Add(st);
                    break;
                  };
                  subst = pas.System.Copy(st,1,ps - 1);
                  c.Add(subst);
                  pas.System.Delete({get: function () {
                      return st;
                    }, set: function (v) {
                      st = v;
                    }},1,(ps - 1) + "{0}".length);
                };
                for (var $l1 = 0, $end1 = c.GetCount() - 1; $l1 <= $end1; $l1++) {
                  l = $l1;
                  if (c.Get(l) !== "") this.SetText(l,c.Get(l));
                };
              } finally {
                c = rtl.freeLoc(c);
              };
            } else if (k === 1) {
              c = pas.Classes.TStringList.$create("Create$1");
              try {
                pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Split("|",a.Get(k),c,false);
                for (var $l2 = 0, $end2 = c.GetCount() - 1; $l2 <= $end2; $l2++) {
                  l = $l2;
                  s = pas.Classes.TStringList.$create("Create$1");
                  try {
                    pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Split(";",c.Get(l),s,false);
                    for (var $l3 = 0, $end3 = s.GetCount() - 1; $l3 <= $end3; $l3++) {
                      y = $l3;
                      if (s.Get(y) !== "") {
                        if (y === 0) {
                          this.SetCheckType(l,pas.SysUtils.StrToInt(s.Get(y)))}
                         else if (y === 1) {
                          this.SetChecked(l,pas.SysUtils.StrToBool(s.Get(y)))}
                         else if (y === 2) {
                          this.SetExpandedIconName(l,false,s.Get(y))}
                         else if (y === 3) {
                          this.SetExpandedIconName(l,true,s.Get(y))}
                         else if (y === 4) {
                          this.SetCollapsedIconName(l,false,s.Get(y))}
                         else if (y === 5) {
                          this.SetCollapsedIconName(l,true,s.Get(y))}
                         else if ((y === 6) || (y === 7) || (y === 8) || (y === 9)) {
                          if (y === 6) {
                            pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.LoadBitmapFromHexStr(s.Get(y),this.GetExpandedIcon(l,false))}
                           else if (y === 7) {
                            pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.LoadBitmapFromHexStr(s.Get(y),this.GetExpandedIcon(l,true))}
                           else if (y === 8) {
                            pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.LoadBitmapFromHexStr(s.Get(y),this.GetCollapsedIcon(l,false))}
                           else pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.LoadBitmapFromHexStr(s.Get(y),this.GetCollapsedIcon(l,true));
                        };
                      };
                    };
                  } finally {
                    s = rtl.freeLoc(s);
                  };
                };
              } finally {
                c = rtl.freeLoc(c);
              };
            } else if (k === 2) {
              this.SetExtended(pas.SysUtils.StrToBool(a.Get(k)))}
             else if (k === 3) this.SetEnabled(pas.SysUtils.StrToBool(a.Get(k)));
          };
        };
      } finally {
        a = rtl.freeLoc(a);
      };
    };
    this.RemoveChildren = function () {
      this.FNodes.Clear();
    };
    this.Expand = function (ARecurse) {
      if (this.FTreeView != null) this.FTreeView.ExpandNode(this,ARecurse);
    };
    this.Collapse = function (ARecurse) {
      if (this.FTreeView != null) this.FTreeView.CollapseNode(this,ARecurse);
    };
    this.MoveTo = function (ADestination, AIndex) {
      if (this.FTreeView != null) this.FTreeView.MoveNode(this,ADestination,AIndex);
    };
    this.CopyTo = function (ADestination, AIndex) {
      if (this.FTreeView != null) this.FTreeView.CopyNode(this,ADestination,AIndex);
    };
    this.SetTextValues = function (ATextValues) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(ATextValues) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetText(I,ATextValues[I]);
      };
    };
    this.SetCheckStates = function (ACheckStates) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(ACheckStates) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetChecked(I,ACheckStates[I]);
      };
    };
    this.SetCheckTypes = function (ACheckTypes) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(ACheckTypes) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetCheckType(I,ACheckTypes[I]);
      };
    };
    this.SetCollapsedIcons = function (AIcons, ALarge) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(AIcons) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetCollapsedIcon(I,ALarge,AIcons[I]);
      };
    };
    this.SetExpandedIcons = function (AIcons, ALarge) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(AIcons) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetExpandedIcon(I,ALarge,AIcons[I]);
      };
    };
    this.SetCollapsedIconNames = function (AIconNames, ALarge) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(AIconNames) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetCollapsedIconName(I,ALarge,AIconNames[I]);
      };
    };
    this.SetExpandedIconNames = function (AIconNames, ALarge) {
      var I = 0;
      for (var $l = 0, $end = rtl.length(AIconNames) - 1; $l <= $end; $l++) {
        I = $l;
        this.SetExpandedIconName(I,ALarge,AIconNames[I]);
      };
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FTreeView = rtl.as(this.FCollection,$mod.TTMSFNCTreeViewNodes).TreeView();
      this.FValues = this.CreateNodeValues();
      this.FExpanded = false;
      this.FExtended = false;
      this.FEnabled = true;
      this.FNodes = this.CreateNodes();
      if (this.FTreeView != null) {
        if (this.FTreeView.FNodeListBuild) {
          this.FTreeView.InsertItemInternal(this)}
         else this.FTreeView.UpdateTreeViewCache();
      };
      return this;
    };
    this.Destroy = function () {
      var ru = $mod.TTMSFNCTreeViewVirtualNodeRemoveData.$new();
      ru.RowIndex = -1;
      ru.Count = 0;
      ru.ParentNode = -1;
      if (this.FTreeView != null) {
        if (this.FTreeView.FNodeListBuild && !(this.FTreeView.FBlockRemoveNode > 0)) ru.$assign(this.FTreeView.RemoveItemInternal(this,false));
      };
      this.FVirtualNode = null;
      if (this.FTreeView != null) this.FTreeView.FBlockRemoveNode = this.FTreeView.FBlockRemoveNode + 1;
      rtl.free(this,"FNodes");
      if (this.FTreeView != null) this.FTreeView.FBlockRemoveNode = this.FTreeView.FBlockRemoveNode - 1;
      rtl.free(this,"FValues");
      pas.Classes.TCollectionItem.Destroy.call(this);
      if (ru.RowIndex !== -1) this.FTreeView.UpdateNodesInternal($mod.TTMSFNCTreeViewVirtualNodeRemoveData.$clone(ru));
      if (this.FTreeView != null) this.FTreeView.UpdateTreeViewCache();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewNode.isPrototypeOf(Source)) {
        this.FTag = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FTag;
        this.FValues.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNode).FValues);
        this.FExpanded = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FExpanded;
        this.FExtended = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FExtended;
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FEnabled;
        this.FNodes.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNode).FNodes);
        this.AssignData(Source);
        if (this.FTreeView != null) {
          if (this.FExpanded) {
            this.FTreeView.ExpandNode(this,false)}
           else this.FTreeView.CollapseNode(this,false);
        };
      };
    };
    this.AssignData = function (Source) {
      if ($mod.TTMSFNCTreeViewNode.isPrototypeOf(Source)) {
        this.FDataString = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FDataString;
        this.FDataBoolean = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FDataBoolean;
        this.FDataObject = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FDataObject;
        this.FDataInteger = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FDataInteger;
        this.FDataPointer = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FDataPointer;
        this.FDBKey = rtl.as(Source,$mod.TTMSFNCTreeViewNode).FDBKey;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Values",2,$mod.$rtti["TTMSFNCTreeViewNodeValues"],"FValues","SetValues");
    $r.addProperty("Expanded",2,rtl.boolean,"FExpanded","SetExpanded",4,{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Extended",2,rtl.boolean,"FExtended","SetExtended",4,{Default: false});
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag");
    $r.addProperty("Nodes",2,$mod.$rtti["TTMSFNCTreeViewNodes"],"FNodes","SetNodes");
  });
  rtl.createClass(this,"TTMSFNCTreeViewNodes",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FTreeView = null;
      this.FNode = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FNode = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.GetItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewNode;
      return Result;
    };
    this.Compare = function (ANode1, ANode2, AColumn, ACaseSensitive, ASortingMode) {
      var Result = 0;
      var td = null;
      Result = 0;
      td = this.TreeView();
      if (!(td != null)) return Result;
      if (!ACaseSensitive) {
        Result = pas.SysUtils.AnsiCompareStr(pas.SysUtils.UpperCase(ANode1.GetStrippedHTMLText(AColumn)),pas.SysUtils.UpperCase(ANode2.GetStrippedHTMLText(AColumn)))}
       else Result = pas.SysUtils.AnsiCompareStr(ANode1.GetStrippedHTMLText(AColumn),ANode2.GetStrippedHTMLText(AColumn));
      var $tmp = ASortingMode;
      if ($tmp === $mod.TTMSFNCTreeViewNodesSortMode.nsmDescending) Result = Result * -1;
      td.DoNodeCompare(ANode1,ANode2,AColumn,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.QuickSort = function (L, R, AColumn, ACaseSensitive, ASortingMode) {
      var $Self = this;
      var I = 0;
      var J = 0;
      var p = 0;
      var SortList = null;
      function ExchangeItems(Index1, Index2) {
        var Save = undefined;
        Save = SortList.Get(Index1);
        SortList.Put(Index1,SortList.Get(Index2));
        SortList.Put(Index2,Save);
      };
      SortList = $Self.FItems;
      do {
        I = L;
        J = R;
        p = (L + R) >>> 1;
        do {
          while (this.Compare(this.GetItem$1(I),this.GetItem$1(p),AColumn,ACaseSensitive,ASortingMode) < 0) I += 1;
          while (this.Compare(this.GetItem$1(J),this.GetItem$1(p),AColumn,ACaseSensitive,ASortingMode) > 0) J -= 1;
          if (I <= J) {
            ExchangeItems(I,J);
            if (p === I) {
              p = J}
             else if (p === J) p = I;
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if (L < J) this.QuickSort(L,J,AColumn,ACaseSensitive,ASortingMode);
        L = I;
      } while (!(I >= R));
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Node = function () {
      var Result = null;
      Result = this.FNode;
      return Result;
    };
    this.Create$3 = function (ATreeView, ANode) {
      pas.Classes.TOwnedCollection.Create$2.call(this,ATreeView,this.GetItemClass());
      this.FTreeView = ATreeView;
      this.FNode = ANode;
      return this;
    };
    this.Destroy = function () {
      this.FNode = null;
      pas.Classes.TCollection.Destroy.call(this);
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.Sort$1 = function (AColumn, ARecurse, ACaseSensitive, ASortingMode, AClearNodeList) {
      var td = null;
      var I = 0;
      td = this.TreeView();
      if (td != null) {
        td.FSortMode = ASortingMode;
        td.BeginUpdate();
        if (AClearNodeList) td.ClearNodeList();
        this.BeginUpdate();
        if (this.GetCount() > 0) {
          this.QuickSort(0,this.GetCount() - 1,AColumn,ACaseSensitive,ASortingMode);
          if (ARecurse) {
            for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
              I = $l;
              this.GetItem$1(I).FNodes.Sort$1(AColumn,ARecurse,ACaseSensitive,ASortingMode,AClearNodeList);
            };
          };
        };
        this.EndUpdate();
        td.EndUpdate();
      };
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroup",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FTag = 0;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FTreeView = null;
      this.FText = "";
      this.FStartColumn = 0;
      this.FEndColumn = 0;
      this.FName = "";
      this.FDBKey = "";
      this.FDataBoolean = false;
      this.FBottomFill = null;
      this.FBottomStroke = null;
      this.FTopFill = null;
      this.FTopStroke = null;
      this.FTopFont = null;
      this.FBottomFont = null;
      this.FUseDefaultAppearance = false;
      this.FDataPointer = null;
    };
    this.$final = function () {
      this.FDataObject = undefined;
      this.FTreeView = undefined;
      this.FBottomFill = undefined;
      this.FBottomStroke = undefined;
      this.FTopFill = undefined;
      this.FTopStroke = undefined;
      this.FTopFont = undefined;
      this.FBottomFont = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.UpdateGroup();
      };
    };
    this.SetStartColumn = function (Value) {
      if (this.FStartColumn !== Value) {
        this.FStartColumn = Value;
        this.UpdateGroup();
      };
    };
    this.SetEndColumn = function (Value) {
      if (this.FEndColumn !== Value) {
        this.FEndColumn = Value;
        this.UpdateGroup();
      };
    };
    this.SetName = function (Value) {
      if (this.FName !== Value) {
        this.FName = Value;
      };
    };
    this.SetBottomFill = function (Value) {
      if (this.FBottomFill !== Value) this.FBottomFill.Assign(Value);
    };
    this.SetBottomStroke = function (Value) {
      if (this.FBottomStroke !== Value) this.FBottomStroke.Assign(Value);
    };
    this.SetTopFill = function (Value) {
      if (this.FTopFill !== Value) this.FTopFill.Assign(Value);
    };
    this.SetTopStroke = function (Value) {
      if (this.FTopStroke !== Value) this.FTopStroke.Assign(Value);
    };
    this.SetBottomFont = function (Value) {
      if (this.FBottomFont !== Value) this.FBottomFont.Assign(Value);
    };
    this.SetTopFont = function (Value) {
      if (this.FTopFont !== Value) this.FTopFont.Assign(Value);
    };
    this.SetUseDefaultAppearance = function (Value) {
      if (this.FUseDefaultAppearance !== Value) {
        this.FUseDefaultAppearance = Value;
        this.Changed$1(this);
      };
    };
    this.UpdateGroup = function () {
      var c = null;
      c = this.TreeView();
      if (c != null) {
        c.UpdateColumns();
        c.UpdateTreeViewCache();
      };
    };
    this.Changed$1 = function (Sender) {
      this.UpdateGroup();
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Create$1 = function (ACollection) {
      var grp = null;
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) {
        this.FTreeView = rtl.as(this.FCollection,$mod.TTMSFNCTreeViewGroups).TreeView();
        this.FText = $mod.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCTreeViewGroup")) + " " + pas.SysUtils.IntToStr(this.FTreeView.FGroups.GetCount() - 1);
        if (this.FTreeView.FGroups.GetCount() < 2) {
          this.FStartColumn = 0;
          this.FEndColumn = 0;
        } else {
          grp = this.FTreeView.FGroups.GetItem$1(this.FTreeView.FGroups.GetCount() - 2);
          this.FStartColumn = grp.FStartColumn + 1;
          this.FEndColumn = this.FStartColumn;
        };
      };
      this.FUseDefaultAppearance = true;
      this.FBottomFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone,16777215,8421504,-1,-1]);
      this.FBottomStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FTopFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone,16777215,8421504,-1,-1]);
      this.FTopStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FTopFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBottomFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBottomFill.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTopFill.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FBottomStroke.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTopStroke.FOnChanged = rtl.createCallback(this,"Changed$1");
      this.FTopFont.FOnChange = rtl.createCallback(this,"Changed$1");
      this.FBottomFont.FOnChange = rtl.createCallback(this,"Changed$1");
      this.UpdateGroup();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FTopFill");
      rtl.free(this,"FTopStroke");
      rtl.free(this,"FTopFont");
      rtl.free(this,"FBottomFill");
      rtl.free(this,"FBottomStroke");
      rtl.free(this,"FBottomFont");
      pas.Classes.TCollectionItem.Destroy.call(this);
      this.UpdateGroup();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewGroup.isPrototypeOf(Source)) {
        this.FTag = rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FTag;
        this.FText = rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FText;
        this.FStartColumn = rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FStartColumn;
        this.FEndColumn = rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FEndColumn;
        this.FUseDefaultAppearance = rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FUseDefaultAppearance;
        this.FBottomFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FBottomFill);
        this.FBottomFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FBottomFont);
        this.FBottomStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FBottomStroke);
        this.FTopFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FTopFill);
        this.FTopStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FTopStroke);
        this.FTopFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroup).FTopFont);
      };
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FText;
      if (Result === "") {
        Result = this.FName;
        if (Result === "") Result = $mod.TranslateTextEx(rtl.getResStr($mod,"sTMSFNCTreeViewGroup")) + " " + pas.SysUtils.IntToStr(this.GetIndex());
      };
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Name",2,rtl.string,"FName","SetName");
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("StartColumn",2,rtl.longint,"FStartColumn","SetStartColumn",4,{Default: 0});
    $r.addProperty("EndColumn",2,rtl.longint,"FEndColumn","SetEndColumn",4,{Default: 0});
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",4,{Default: 0});
    $r.addProperty("UseDefaultAppearance",2,rtl.boolean,"FUseDefaultAppearance","SetUseDefaultAppearance",4,{Default: true});
    $r.addProperty("TopFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FTopFill","SetTopFill");
    $r.addProperty("TopStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FTopStroke","SetTopStroke");
    $r.addProperty("TopFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FTopFont","SetTopFont");
    $r.addProperty("BottomFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FBottomFill","SetBottomFill");
    $r.addProperty("BottomStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FBottomStroke","SetBottomStroke");
    $r.addProperty("BottomFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FBottomFont","SetBottomFont");
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroups",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FTreeView = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.GetItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewGroup;
      return Result;
    };
    this.TreeView = function () {
      var Result = null;
      Result = this.FTreeView;
      return Result;
    };
    this.Create$3 = function (ATreeView) {
      pas.Classes.TOwnedCollection.Create$2.call(this,ATreeView,this.GetItemClass());
      this.FTreeView = ATreeView;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.TTMSFNCTreeViewNodeTextMode = {"0": "tntmDrawing", tntmDrawing: 0, "1": "tntmEditing", tntmEditing: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewNodeTextMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewNodeTextMode});
  rtl.createClass(this,"TTMSFNCTreeViewNodeStructure",pas.contnrs.TObjectList,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewVisibleNodes",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.recNewT(this,"TTMSFNCTreeViewDisplayGroup",function () {
    this.StartColumn = 0;
    this.EndColumn = 0;
    this.$eq = function (b) {
      return (this.StartColumn === b.StartColumn) && (this.EndColumn === b.EndColumn);
    };
    this.$assign = function (s) {
      this.StartColumn = s.StartColumn;
      this.EndColumn = s.EndColumn;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTreeViewDisplayGroup",{},this);
    $r.addField("StartColumn",rtl.longint);
    $r.addField("EndColumn",rtl.longint);
  });
  rtl.createClass(this,"TTMSFNCTreeViewDisplayGroups",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = $mod.TTMSFNCTreeViewDisplayGroup.$new();
      Result.$assign(rtl.getObject(this.Get(Index)));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewData",pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.$init.call(this);
      this.FFilterApplied = false;
      this.FBlockUpdate = false;
      this.FNodeStructure = null;
      this.FVisibleNodes = null;
      this.FColumns = null;
      this.FGroups = null;
      this.FNodes = null;
      this.FBitmapContainer = null;
      this.FDisplayGroups = null;
      this.FFilter = null;
      this.FSortMode = 0;
    };
    this.$final = function () {
      this.FNodeStructure = undefined;
      this.FVisibleNodes = undefined;
      this.FColumns = undefined;
      this.FGroups = undefined;
      this.FNodes = undefined;
      this.FBitmapContainer = undefined;
      this.FDisplayGroups = undefined;
      this.FFilter = undefined;
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.$final.call(this);
    };
    this.SetColumns = function (Value) {
      this.FColumns.Assign(Value);
    };
    this.SetGroups = function (Value) {
      this.FGroups.Assign(Value);
    };
    this.SetNodes = function (Value) {
      this.FNodes.Assign(Value);
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
      this.Invalidate();
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((AComponent === this.FBitmapContainer) && (Operation === pas.Classes.TOperation.opRemove)) this.FBitmapContainer = null;
    };
    this.CreateColumns = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewColumns.$create("Create$3",[this]);
      return Result;
    };
    this.CreateGroups = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewGroups.$create("Create$3",[this]);
      return Result;
    };
    this.CreateNodes = function () {
      var Result = null;
      Result = $mod.TTMSFNCTreeViewNodes.$create("Create$3",[this,null]);
      return Result;
    };
    this.GetInsertPosition = function (ANode, ARoot, AInsert) {
      var Result = 0;
      var prev = null;
      var I = 0;
      var r = 0;
      var n = null;
      Result = -1;
      if (!(ANode != null)) return Result;
      if (ANode.FRow === 0) {
        Result = 0;
        return Result;
      };
      if (AInsert) {
        prev = this.GetNodeFromNodeStructure(ANode.FRow - 1)}
       else prev = this.GetNodeFromNodeStructure(ANode.FRow);
      if (ARoot) {
        while ((prev != null) && (prev.FParentNode >= 0) && (prev.FParentNode <= (this.FNodeStructure.GetCount() - 1))) {
          n = this.GetNodeFromNodeStructure(prev.FParentNode);
          if (n !== prev) {
            prev = n}
           else break;
        };
      };
      if (prev != null) {
        for (var $l = 0, $end = this.FVisibleNodes.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if (AInsert) {
            r = ANode.FRow + 1}
           else r = ANode.FRow;
          if (this.FVisibleNodes.GetItem(I).FRow === r) {
            Result = I;
            break;
          };
        };
      };
      return Result;
    };
    this.GetNodeFromNodeStructure = function (AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.FNodeStructure.GetCount() - 1))) Result = this.FNodeStructure.GetItem$1(AIndex);
      return Result;
    };
    this.MatchFilter = function (ANode) {
      var Result = false;
      var i = 0;
      var s = "";
      var temp = false;
      Result = true;
      for (var $l = 1, $end = this.FFilter.GetCount(); $l <= $end; $l++) {
        i = $l;
        var $with = this.FFilter.GetItem$1(i - 1);
        s = "";
        this.DoGetNodeText(ANode,$with.FColumn,$mod.TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }});
        s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(s);
        s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.UnFixMarkup(s,true,false);
        s = pas.SysUtils.Trim(s);
        if ($with.FPrefix !== "") if (pas.System.Pos($with.FPrefix,s) === 1) pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},1,this.FFilter.GetItem$1(i - 1).FPrefix.length);
        if ($with.FSuffix !== "") if (pas.System.Pos($with.FSuffix,s) === ((1 + s.length) - $with.FSuffix.length)) pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},(1 + s.length) - $with.FSuffix.length,s.length);
        try {
          temp = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx($with.FCondition,s,$with.FCaseSensitive);
        } catch ($e) {
          temp = false;
        };
        var $tmp = this.FFilter.GetItem$1(i - 1).FOperation;
        if ($tmp === $mod.TTMSFNCTreeViewFilterOperation.tfoSHORT) {
          Result = temp;
          if (!Result) break;
        } else if ($tmp === $mod.TTMSFNCTreeViewFilterOperation.tfoNONE) {
          Result = temp}
         else if ($tmp === $mod.TTMSFNCTreeViewFilterOperation.tfoAND) {
          Result = Result && temp}
         else if ($tmp === $mod.TTMSFNCTreeViewFilterOperation.tfoOR) {
          Result = Result || temp}
         else if ($tmp === $mod.TTMSFNCTreeViewFilterOperation.tfoXOR) Result = Result ^ temp;
      };
      return Result;
    };
    this.BuildNodeList = function () {
      var $Self = this;
      var v = null;
      var c = 0;
      function BuildFilteredVisibleNodes(ANode, APathVisible) {
        var Result = 0;
        var child = null;
        var nodeVisible = false;
        Result = 0;
        if (!(ANode != null)) return Result;
        ANode.FFilterExpanded = false;
        ANode.FAddedToVisibleList = $Self.MatchFilter(ANode);
        child = ANode.GetFirstChild();
        while (child != null) {
          Result += BuildFilteredVisibleNodes(child,APathVisible);
          ANode.FAddedToVisibleList = ANode.FAddedToVisibleList || child.FAddedToVisibleList;
          child = child.GetNextSibling();
        };
        ANode.FFilterExpanded = Result > 0;
        nodeVisible = true;
        $Self.DoIsNodeVisible(ANode,{get: function () {
            return nodeVisible;
          }, set: function (v) {
            nodeVisible = v;
          }});
        if (ANode.FAddedToVisibleList && nodeVisible && APathVisible) {
          if (Result > 0) {
            $Self.FVisibleNodes.Insert($Self.FVisibleNodes.GetCount() - Result,ANode)}
           else $Self.FVisibleNodes.Add(ANode);
          $Self.FTotalRowHeight = $Self.FTotalRowHeight + ANode.FHeight;
          Result += 1;
        };
        return Result;
      };
      if (this.FNodeListBuild) return;
      this.FNodeStructure.Clear();
      this.FVisibleNodes.Clear();
      v = $mod.TTMSFNCTreeViewVirtualNode.$create("Create$1",[$Self]);
      this.FTotalRowHeight = 1;
      this.SetRowCount(0);
      c = 0;
      this.BuildInternalNodeList(v,"ROOT",-1,-1,-1,true,{get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }});
      if (this.FFilterApplied) {
        this.FVisibleNodes.Clear();
        v = this.GetFirstRootVirtualNode();
        while (v != null) {
          BuildFilteredVisibleNodes(v,true);
          v = v.GetNextSibling();
        };
      };
      this.SetRowCount(this.FVisibleNodes.GetCount());
      this.FNodeListBuild = this.FNodeStructure.GetCount() > 0;
    };
    this.UpdateColumns = function () {
      var I = 0;
      var c = null;
      var g = null;
      var grp = $mod.TTMSFNCTreeViewDisplayGroup.$new();
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.FDisplayGroups.Clear();
      for (var $l = 0, $end = this.FGroups.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        g = this.FGroups.GetItem$1(I);
        grp.StartColumn = Math.max(0,Math.min(g.FStartColumn,this.FColumns.GetCount() - 1));
        grp.EndColumn = Math.max(0,Math.min(g.FEndColumn,this.FColumns.GetCount() - 1));
        this.FDisplayGroups.Add($mod.TTMSFNCTreeViewDisplayGroup.$clone(grp));
      };
      for (var $l1 = 0, $end1 = this.FColumns.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        c = this.FColumns.GetItem$1(I);
        if (c.FVisible) {
          this.SetColWidths(I,c.FWidth);
          this.SetColMinWidths(I,c.FMinimumWidth);
        } else {
          this.SetColWidths(I,0);
          this.SetColMinWidths(I,0);
        };
      };
    };
    this.BuildInternalNodeList = function (ANode, AID, AParentNode, ANodeIndex, ALevel, AParentExpanded, ATotalChildren) {
      var I = 0;
      var nd = 0;
      var vi = false;
      var v = null;
      var exp = false;
      var tot = 0;
      var chk = false;
      var ext = false;
      var chkst = [];
      var pathVisible = false;
      ANode.FRow = this.FNodeStructure.GetCount();
      ANode.FParentNode = AParentNode;
      ANode.FIndex = ANodeIndex;
      ANode.FLevel = ALevel;
      if (AID !== "ROOT") this.GetNodeForNodeData(ANode);
      nd = 0;
      if (ALevel < 100) this.DoGetNumberOfNodes(ANode,{get: function () {
          return nd;
        }, set: function (v) {
          nd = v;
        }});
      ANode.FChildren = nd;
      ANode.FCalculated = false;
      ANode.FHeight = this.GetDefaultRowHeight(ANode);
      exp = false;
      if (AID !== "ROOT") this.DoIsNodeExpanded(ANode,{get: function () {
          return exp;
        }, set: function (v) {
          exp = v;
        }});
      ANode.FExpanded = exp;
      ext = false;
      this.DoIsNodeExtended(ANode,{get: function () {
          return ext;
        }, set: function (v) {
          ext = v;
        }});
      this.UpdateNodeExtended(ANode,ext);
      chkst = rtl.arraySetLength(chkst,false,0);
      if (AID !== "ROOT") {
        for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
          I = $l;
          chk = false;
          this.DoIsNodeChecked(ANode,I,{get: function () {
              return chk;
            }, set: function (v) {
              chk = v;
            }});
          chkst = rtl.arraySetLength(chkst,false,rtl.length(chkst) + 1);
          chkst[rtl.length(chkst) - 1] = chk;
        };
        ANode.FCheckStates = rtl.arrayRef(chkst);
      };
      vi = true;
      if ((AID !== "ROOT") && !this.FFilterApplied) this.DoIsNodeVisible(ANode,{get: function () {
          return vi;
        }, set: function (v) {
          vi = v;
        }});
      tot = nd;
      pathVisible = AParentExpanded || (ANode.FLevel === 0);
      if (AID !== "ROOT") {
        this.FNodeStructure.Add$1(ANode);
        if (!this.FFilterApplied && vi && pathVisible) {
          this.FVisibleNodes.Add(ANode);
          ANode.FAddedToVisibleList = true;
        };
      };
      for (var $l1 = 0, $end1 = nd - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        if (this.FNodeStructure.GetCount() === 2000000) break;
        v = $mod.TTMSFNCTreeViewVirtualNode.$create("Create$1",[this]);
        if (AID === "ROOT") {
          this.BuildInternalNodeList(v,"",AParentNode,I,0,pathVisible && exp,{get: function () {
              return tot;
            }, set: function (v) {
              tot = v;
            }})}
         else this.BuildInternalNodeList(v,"",ANode.FRow,I,ANode.FLevel + 1,pathVisible && exp,{get: function () {
            return tot;
          }, set: function (v) {
            tot = v;
          }});
      };
      ATotalChildren.set(ATotalChildren.get() + tot);
      if (AID !== "ROOT") {
        ANode.FTotalChildren = tot}
       else ANode = rtl.freeLoc(ANode);
    };
    this.GetNodeForNodeData = function (ANode) {
      var col = null;
      var p = null;
      var it = null;
      if (ANode != null) {
        p = this.GetNodeFromNodeStructure(ANode.FParentNode);
        if ((p != null) && (p.FNode != null)) {
          col = p.FNode.FNodes}
         else col = this.FNodes;
      } else return;
      if (col != null) {
        if ((ANode.FIndex >= 0) && (ANode.FIndex <= (col.GetCount() - 1))) {
          it = col.GetItem$1(ANode.FIndex);
          ANode.FNode = it;
          it.FVirtualNode = ANode;
        };
      };
    };
    this.DoGetNumberOfNodes = function (ANode, ANumberOfNodes) {
      if (ANode.FNode != null) {
        ANumberOfNodes.set(ANode.FNode.FNodes.GetCount())}
       else ANumberOfNodes.set(this.FNodes.GetCount());
    };
    this.DoGetColumnTrimming = function (AColumn, AKind, ATrimming) {
    };
    this.DoGetColumnHorizontalTextAlign = function (AColumn, AKind, AHorizontalTextAlign) {
    };
    this.DoGetColumnVerticalTextAlign = function (AColumn, AKind, AVerticalTextAlign) {
    };
    this.DoGetColumnWordWrapping = function (AColumn, AKind, AWordWrapping) {
    };
    this.DoGetNodeSides = function (ANode, ASides) {
    };
    this.DoGetNodeText = function (ANode, AColumn, AMode, AText) {
      var it = null;
      it = ANode.FNode;
      if ((it != null) && (it.FValues != null)) {
        if ((AColumn >= 0) && (AColumn <= (it.FValues.GetCount() - 1))) AText.set(it.FValues.GetItem$1(AColumn).GetText());
      };
    };
    this.DoGetNodeData = function (ANode) {
    };
    this.DoGetNodeTitle = function (ANode, AColumn, AMode, ATitle) {
      var it = null;
      it = ANode.FNode;
      if ((it != null) && (it.FValues != null)) {
        if ((AColumn >= 0) && (AColumn <= (it.FValues.GetCount() - 1))) ATitle.set(it.FValues.GetItem$1(AColumn).FTitle);
      };
    };
    this.DoGetNodeTitleExpanded = function (ANode, AColumn, AExpanded) {
      var it = null;
      it = ANode.FNode;
      if ((it != null) && (it.FValues != null)) {
        if ((AColumn >= 0) && (AColumn <= (it.FValues.GetCount() - 1))) AExpanded.set(it.FValues.GetItem$1(AColumn).FTitleExpanded);
      };
    };
    this.DoGetNodeTrimming = function (ANode, AColumn, ATrimming) {
    };
    this.DoGetNodeHorizontalTextAlign = function (ANode, AColumn, AHorizontalTextAlign) {
    };
    this.DoGetNodeVerticalTextAlign = function (ANode, AColumn, AVerticalTextAlign) {
    };
    this.DoGetNodeWordWrapping = function (ANode, AColumn, AWordWrapping) {
    };
    this.DoGetNodeTitleTrimming = function (ANode, AColumn, ATrimming) {
    };
    this.DoGetNodeTitleHorizontalTextAlign = function (ANode, AColumn, AHorizontalTextAlign) {
    };
    this.DoGetNodeTitleVerticalTextAlign = function (ANode, AColumn, AVerticalTextAlign) {
    };
    this.DoGetNodeTitleWordWrapping = function (ANode, AColumn, AWordWrapping) {
    };
    this.DoGetNodeExtraSize = function (ANode, AColumn, AExtraSize) {
    };
    this.DoGetNodeTitleExtraSize = function (ANode, AColumn, ATitleExtraSize) {
    };
    this.DoGetNodeCheckType = function (ANode, AColumn, ACheckType) {
      var it = null;
      it = ANode.FNode;
      if (it != null) {
        if ((AColumn >= 0) && (AColumn <= (it.FValues.GetCount() - 1))) ACheckType.set(it.FValues.GetItem$1(AColumn).FCheckType);
      };
    };
    this.DoGetNodeIcon = function (ANode, AColumn, ALarge, AIcon) {
      var it = null;
      var v = null;
      it = ANode.FNode;
      if (it != null) {
        if ((AColumn >= 0) && (AColumn <= (it.FValues.GetCount() - 1))) {
          v = it.FValues.GetItem$1(AColumn);
          if (ANode.GetExpanded()) {
            if (ALarge) {
              if ((this.GetBitmapContainer() != null) && (v.FExpandedIconLargeName !== "")) AIcon.set(this.GetBitmapContainer().FindBitmap$1(v.FExpandedIconLargeName));
              if (!(AIcon.get() != null)) AIcon.set(v.FExpandedIconLarge);
            } else {
              if ((this.GetBitmapContainer() != null) && (v.FExpandedIconName !== "")) AIcon.set(this.GetBitmapContainer().FindBitmap$1(v.FExpandedIconName));
              if (!(AIcon.get() != null)) AIcon.set(v.FExpandedIcon);
            };
          } else {
            if (ALarge) {
              if ((this.GetBitmapContainer() != null) && (v.FCollapsedIconLargeName !== "")) AIcon.set(this.GetBitmapContainer().FindBitmap$1(v.FCollapsedIconLargeName));
              if (!(AIcon.get() != null)) AIcon.set(v.FCollapsedIconLarge);
            } else {
              if ((this.GetBitmapContainer() != null) && (v.FCollapsedIconName !== "")) AIcon.set(this.GetBitmapContainer().FindBitmap$1(v.FCollapsedIconName));
              if (!(AIcon.get() != null)) AIcon.set(v.FCollapsedIcon);
            };
          };
        };
      };
    };
    this.DoGetNodeIconSize = function (ANode, AColumn, ALarge, AIcon, AIconWidth, AIconHeight) {
    };
    this.DoGetNodeSelectedColor = function (ANode, AColor) {
    };
    this.DoGetNodeDisabledColor = function (ANode, AColor) {
    };
    this.DoGetNodeColor = function (ANode, AColor) {
    };
    this.DoGetNodeSelectedTextColor = function (ANode, AColumn, ATextColor) {
    };
    this.DoGetNodeDisabledTextColor = function (ANode, AColumn, ATextColor) {
    };
    this.DoGetNodeSelectedTitleColor = function (ANode, AColumn, ATitleColor) {
    };
    this.DoGetNodeDisabledTitleColor = function (ANode, AColumn, ATitleColor) {
    };
    this.DoGetNodeTextColor = function (ANode, AColumn, ATextColor) {
    };
    this.DoGetNodeTitleColor = function (ANode, AColumn, ATitleColor) {
    };
    this.DoIsNodeExpanded = function (ANode, AExpanded) {
      var it = null;
      it = ANode.FNode;
      if (it != null) AExpanded.set(it.FExpanded);
    };
    this.DoIsNodeExtended = function (ANode, AExtended) {
      var it = null;
      it = ANode.FNode;
      if (it != null) AExtended.set(it.FExtended);
    };
    this.DoIsNodeChecked = function (ANode, AColumn, AChecked) {
      var it = null;
      it = ANode.FNode;
      if (it != null) {
        if ((AColumn >= 0) && (AColumn <= (it.FValues.GetCount() - 1))) AChecked.set(it.FValues.GetItem$1(AColumn).FChecked);
      };
    };
    this.DoIsNodeVisible = function (ANode, AVisible) {
    };
    this.DoIsNodeEnabled = function (ANode, AEnabled) {
      var it = null;
      it = ANode.FNode;
      if (it != null) AEnabled.set(it.FEnabled);
    };
    this.DoNodeCompare = function (ANode1, ANode2, AColumn, ACompareResult) {
    };
    this.DoGetHTMLTemplateValue = function (ANodeValue, AName, AValue) {
    };
    this.DoGetHTMLTemplate = function (ANodeValue, AColumnIndex, AHTMLTemplate) {
    };
    this.ToggleCheckNodeInternal = function (ANode, AColumn, ARecurse) {
      var chk = false;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(ANode != null) || !this.FNodeListBuild) return;
      if ((AColumn >= 0) && (AColumn <= (rtl.length(ANode.FCheckStates) - 1))) {
        chk = ANode.FCheckStates[AColumn];
        if (chk) {
          this.UnCheckNodeInternal(ANode,AColumn,ARecurse)}
         else this.CheckNodeInternal(ANode,AColumn,ARecurse);
      };
    };
    this.CheckNodeInternal = function (ANode, AColumn, ARecurse) {
      var chkt = 0;
      var pn = null;
      var n = null;
      var st = 0;
      var stp = 0;
      var I = 0;
      var v = null;
      if (!(ANode != null)) return;
      if ((AColumn >= 0) && (AColumn <= (rtl.length(ANode.FCheckStates) - 1))) {
        ANode.FCheckStates[AColumn] = true;
        this.UpdateCheckState(ANode,AColumn,ANode.FCheckStates[AColumn]);
      };
      if (ANode.FNode != null) {
        if ((AColumn >= 0) && (AColumn <= (ANode.FNode.FValues.GetCount() - 1))) ANode.FNode.FValues.UpdateChecked(AColumn,true);
      };
      chkt = $mod.TTMSFNCTreeViewNodeCheckType.tvntNone;
      this.DoGetNodeCheckType(ANode,AColumn,{get: function () {
          return chkt;
        }, set: function (v) {
          chkt = v;
        }});
      if (chkt === $mod.TTMSFNCTreeViewNodeCheckType.tvntRadioButton) {
        pn = this.GetNodeFromNodeStructure(ANode.FParentNode);
        if (pn != null) {
          st = pn.FRow + 1;
          stp = st + pn.FTotalChildren;
        } else {
          st = 0;
          stp = this.FNodeStructure.GetCount();
        };
        while (st < stp) {
          n = this.GetNodeFromNodeStructure(st);
          if (n != null) {
            if (n !== ANode) {
              chkt = $mod.TTMSFNCTreeViewNodeCheckType.tvntNone;
              this.DoGetNodeCheckType(n,AColumn,{get: function () {
                  return chkt;
                }, set: function (v) {
                  chkt = v;
                }});
              if (chkt === $mod.TTMSFNCTreeViewNodeCheckType.tvntRadioButton) {
                if ((AColumn >= 0) && (AColumn <= (rtl.length(n.FCheckStates) - 1))) {
                  n.FCheckStates[AColumn] = false;
                  this.UpdateCheckState(n,AColumn,n.FCheckStates[AColumn]);
                };
                if (n.FNode != null) {
                  if ((AColumn >= 0) && (AColumn <= (n.FNode.FValues.GetCount() - 1))) n.FNode.FValues.UpdateChecked(AColumn,false);
                };
              };
            };
            st = st + n.FTotalChildren + 1;
          } else break;
        };
      };
      if (ARecurse) {
        for (var $l = ANode.FRow + 1, $end = ANode.FRow + ANode.FTotalChildren; $l <= $end; $l++) {
          I = $l;
          v = this.GetNodeFromNodeStructure(I);
          if (v != null) this.CheckNodeInternal(v,AColumn,ARecurse);
        };
      };
      this.Invalidate();
    };
    this.UpdateCheckState = function (ANode, AColumn, AChecked) {
    };
    this.UnCheckNodeInternal = function (ANode, AColumn, ARecurse) {
      var chkt = 0;
      var I = 0;
      var v = null;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(ANode != null) || !this.FNodeListBuild) return;
      chkt = $mod.TTMSFNCTreeViewNodeCheckType.tvntNone;
      this.DoGetNodeCheckType(ANode,AColumn,{get: function () {
          return chkt;
        }, set: function (v) {
          chkt = v;
        }});
      if (chkt === $mod.TTMSFNCTreeViewNodeCheckType.tvntCheckBox) {
        if ((AColumn >= 0) && (AColumn <= (rtl.length(ANode.FCheckStates) - 1))) {
          ANode.FCheckStates[AColumn] = false;
          this.UpdateCheckState(ANode,AColumn,ANode.FCheckStates[AColumn]);
        };
        if (ANode.FNode != null) {
          if ((AColumn >= 0) && (AColumn <= (ANode.FNode.FValues.GetCount() - 1))) ANode.FNode.FValues.UpdateChecked(AColumn,false);
        };
      };
      if (ARecurse) {
        for (var $l = ANode.FRow + 1, $end = ANode.FRow + ANode.FTotalChildren; $l <= $end; $l++) {
          I = $l;
          v = this.GetNodeFromNodeStructure(I);
          if (v != null) this.UnCheckNodeInternal(v,AColumn,ARecurse);
        };
      };
      this.Invalidate();
    };
    this.ExpandNodeInternal = function (ANode, ARecurse) {
      var I = 0;
      var v = null;
      var n = null;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(ANode != null)) return;
      if (ANode.FExpanded) {
        if (ARecurse) {
          n = ANode.GetFirstChild();
          while (n != null) {
            this.ExpandNodeInternal(n,ARecurse);
            n = n.GetNextSibling();
          };
        };
        return;
      };
      ANode.FExpanded = true;
      this.UpdateNodeExpanded(ANode,true);
      if (ARecurse) {
        for (var $l = ANode.FRow + 1, $end = ANode.FRow + ANode.FTotalChildren; $l <= $end; $l++) {
          I = $l;
          v = this.GetNodeFromNodeStructure(I);
          if (v != null) this.UpdateNodeExpanded(v,true);
        };
      };
      if (this.FFilterApplied) {
        this.FNodeListBuild = false;
        this.BuildNodeList();
      } else this.UpdateVisibleNodes(ANode);
      if (!this.FBlockUpdate) {
        this.ResetNodes(this.FFilterApplied);
        this.UpdateTreeView();
        this.Invalidate();
      };
    };
    this.CollapseNodeInternal = function (ANode, ARecurse) {
      var I = 0;
      var v = null;
      var n = null;
      if (!(ANode != null) || !this.FNodeListBuild || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if (!ANode.FExpanded) {
        if (ARecurse) {
          n = ANode.GetFirstChild();
          while (n != null) {
            this.CollapseNodeInternal(n,ARecurse);
            n = n.GetNextSibling();
          };
        };
        return;
      };
      ANode.FExpanded = false;
      this.UpdateNodeExpanded(ANode,false);
      if (ARecurse) {
        for (var $l = ANode.FRow + 1, $end = ANode.FRow + ANode.FTotalChildren; $l <= $end; $l++) {
          I = $l;
          v = this.GetNodeFromNodeStructure(I);
          if (v != null) this.UpdateNodeExpanded(v,false);
        };
      };
      if (this.FFilterApplied) {
        this.FNodeListBuild = false;
        this.BuildNodeList();
      } else this.UpdateVisibleNodes(ANode);
      if (!this.FBlockUpdate) {
        this.ResetNodes(this.FFilterApplied);
        this.UpdateTreeView();
        this.Invalidate();
      };
    };
    this.RemoveNodeInternal = function (ANode, AUpdateNodes) {
      var Result = $mod.TTMSFNCTreeViewVirtualNodeRemoveData.$new();
      var I = 0;
      var R = 0;
      var pi = 0;
      var subv = null;
      var pv = null;
      var rs = null;
      var cnt = 0;
      var exp = false;
      var ext = false;
      var chkst = [];
      var K = 0;
      var chk = false;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !this.FNodeListBuild || !(ANode != null)) return Result;
      cnt = this.FNodeStructure.GetCount();
      pv = this.GetNodeFromNodeStructure(ANode.FParentNode);
      while (pv != null) {
        this.UpdateNodeTotalChildren(pv,pv.FTotalChildren - 1 - ANode.FTotalChildren);
        if (pv.FRow === ANode.FParentNode) this.UpdateNodeChildren(pv,pv.FChildren - 1);
        pi = pv.FParentNode;
        pv = this.GetNodeFromNodeStructure(pi);
      };
      for (var $l = ANode.FTotalChildren - 1; $l >= 0; $l--) {
        I = $l;
        R = I + ANode.FRow + 1;
        subv = this.GetNodeFromNodeStructure(R);
        if (subv != null) {
          if (this.FVisibleNodes.IndexOf(subv) > -1) {
            this.FVisibleNodes.Remove(subv);
            this.FTotalRowHeight = this.FTotalRowHeight - subv.FHeight;
            this.SetRowCount(this.FRowCount - 1);
          };
          this.FNodeStructure.Remove$1(subv);
          this.RemoveNodeFromSelection(subv);
        };
      };
      R = ANode.FRow;
      pi = ANode.FParentNode;
      if (this.FVisibleNodes.IndexOf(ANode) > -1) {
        this.FVisibleNodes.Remove(ANode);
        this.FTotalRowHeight = this.FTotalRowHeight - ANode.FHeight;
        this.SetRowCount(this.FRowCount - 1);
      };
      this.UpdateNodeChildren(ANode,ANode.FChildren - 1);
      this.UpdateNodeTotalChildren(ANode,ANode.FTotalChildren - 1);
      this.ClearFocusedNode(ANode);
      this.FNodeStructure.Remove$1(ANode);
      this.RemoveNodeFromSelection(ANode);
      cnt = cnt - this.FNodeStructure.GetCount();
      Result.Count = cnt;
      Result.RowIndex = R;
      Result.ParentNode = pi;
      if (AUpdateNodes) {
        for (var $l1 = R, $end = this.FNodeStructure.GetCount() - 1; $l1 <= $end; $l1++) {
          I = $l1;
          rs = this.GetNodeFromNodeStructure(I);
          if (rs != null) {
            this.UpdateNodeRow(rs,rs.FRow - cnt);
            if (rs.FParentNode > pi) this.UpdateNodeParentNode(rs,rs.FParentNode - cnt);
            if (rs.FParentNode === pi) this.UpdateNodeIndex(rs,rs.FIndex - 1);
            this.GetNodeForNodeData(rs);
            exp = false;
            this.DoIsNodeExpanded(rs,{get: function () {
                return exp;
              }, set: function (v) {
                exp = v;
              }});
            this.UpdateNodeExpanded(rs,exp);
            ext = false;
            this.DoIsNodeExtended(rs,{get: function () {
                return ext;
              }, set: function (v) {
                ext = v;
              }});
            this.UpdateNodeExtended(rs,ext);
            chkst = rtl.arraySetLength(chkst,false,0);
            for (var $l2 = 0, $end1 = this.FColumnCount - 1; $l2 <= $end1; $l2++) {
              K = $l2;
              chk = false;
              this.DoIsNodeChecked(rs,K,{get: function () {
                  return chk;
                }, set: function (v) {
                  chk = v;
                }});
              chkst = rtl.arraySetLength(chkst,false,rtl.length(chkst) + 1);
              chkst[rtl.length(chkst) - 1] = chk;
            };
            this.UpdateNodeCheckStates(rs,rtl.arrayRef(chkst));
          };
        };
        if (!this.FBlockUpdate) {
          this.ResetNodes(false);
          this.UpdateTreeView();
          this.Invalidate();
        };
      };
      return Result;
    };
    this.UpdateNodesInternal = function (ANodeRemoveData) {
      var cnt = 0;
      var I = 0;
      var pi = 0;
      var R = 0;
      var rs = null;
      var ext = false;
      var exp = false;
      var chkst = [];
      var K = 0;
      var chk = false;
      cnt = ANodeRemoveData.Count;
      pi = ANodeRemoveData.ParentNode;
      R = ANodeRemoveData.RowIndex;
      for (var $l = R, $end = this.FNodeStructure.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        rs = this.GetNodeFromNodeStructure(I);
        if (rs != null) {
          this.UpdateNodeRow(rs,rs.FRow - cnt);
          if (rs.FParentNode > pi) this.UpdateNodeParentNode(rs,rs.FParentNode - cnt);
          if (rs.FParentNode === pi) this.UpdateNodeIndex(rs,rs.FIndex - 1);
          this.GetNodeForNodeData(rs);
          exp = false;
          this.DoIsNodeExpanded(rs,{get: function () {
              return exp;
            }, set: function (v) {
              exp = v;
            }});
          this.UpdateNodeExpanded(rs,exp);
          ext = false;
          this.DoIsNodeExtended(rs,{get: function () {
              return ext;
            }, set: function (v) {
              ext = v;
            }});
          this.UpdateNodeExtended(rs,ext);
          chkst = rtl.arraySetLength(chkst,false,0);
          for (var $l1 = 0, $end1 = this.FColumnCount - 1; $l1 <= $end1; $l1++) {
            K = $l1;
            chk = false;
            this.DoIsNodeChecked(rs,K,{get: function () {
                return chk;
              }, set: function (v) {
                chk = v;
              }});
            chkst = rtl.arraySetLength(chkst,false,rtl.length(chkst) + 1);
            chkst[rtl.length(chkst) - 1] = chk;
          };
          this.UpdateNodeCheckStates(rs,rtl.arrayRef(chkst));
        };
      };
      if (!this.FBlockUpdate) {
        this.ResetNodes(false);
        this.UpdateTreeView();
        this.Invalidate();
      };
    };
    this.InsertNodeInternal = function (AParentNode, AIndex, AInsertIndex, ANode) {
      var I = 0;
      var pi = 0;
      var pv = null;
      var rs = null;
      var cnt = 0;
      var vi = false;
      var chk = false;
      var chkst = [];
      var ins = 0;
      var exp = false;
      var ext = false;
      var K = 0;
      if (!this.FNodeListBuild || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if (!(ANode != null)) {
        ANode = rtl.freeLoc(ANode);
        return;
      };
      cnt = this.FNodeStructure.GetCount();
      if (AParentNode != null) {
        pi = AParentNode.FRow;
        if ((pi >= 0) && (pi <= (this.FNodeStructure.GetCount() - 1))) {
          pv = this.GetNodeFromNodeStructure(pi);
          while (pv != null) {
            this.UpdateNodeTotalChildren(pv,pv.FTotalChildren + 1);
            if (pv.FRow === AParentNode.FRow) this.UpdateNodeChildren(pv,pv.FChildren + 1);
            pi = pv.FParentNode;
            pv = this.GetNodeFromNodeStructure(pi);
          };
        };
      };
      this.UpdateNodeIndex(ANode,AIndex);
      this.UpdateNodeRow(ANode,AInsertIndex);
      if (AParentNode != null) {
        this.UpdateNodeParentNode(ANode,AParentNode.FRow);
        this.UpdateNodeLevel(ANode,AParentNode.FLevel + 1);
      } else {
        this.UpdateNodeParentNode(ANode,-1);
        this.UpdateNodeLevel(ANode,0);
      };
      this.UpdateNodeHeight(ANode,this.GetDefaultRowHeight(ANode));
      this.GetNodeForNodeData(ANode);
      exp = false;
      this.DoIsNodeExpanded(ANode,{get: function () {
          return exp;
        }, set: function (v) {
          exp = v;
        }});
      this.UpdateNodeExpanded(ANode,exp);
      ext = false;
      this.DoIsNodeExtended(ANode,{get: function () {
          return ext;
        }, set: function (v) {
          ext = v;
        }});
      this.UpdateNodeExtended(ANode,ext);
      chkst = rtl.arraySetLength(chkst,false,0);
      for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
        I = $l;
        chk = false;
        this.DoIsNodeChecked(ANode,I,{get: function () {
            return chk;
          }, set: function (v) {
            chk = v;
          }});
        chkst = rtl.arraySetLength(chkst,false,rtl.length(chkst) + 1);
        chkst[rtl.length(chkst) - 1] = chk;
      };
      this.UpdateNodeCheckStates(ANode,rtl.arrayRef(chkst));
      if ((ANode.FRow >= 0) && (ANode.FRow < this.FNodeStructure.GetCount())) {
        this.FNodeStructure.Insert$1(ANode.FRow,ANode)}
       else this.FNodeStructure.Add$1(ANode);
      vi = true;
      if (AParentNode != null) this.DoIsNodeVisible(AParentNode,{get: function () {
          return vi;
        }, set: function (v) {
          vi = v;
        }});
      cnt = cnt - this.FNodeStructure.GetCount();
      for (var $l1 = ANode.FRow + 1, $end1 = this.FNodeStructure.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        rs = this.GetNodeFromNodeStructure(I);
        if (rs != null) {
          this.UpdateNodeRow(rs,rs.FRow - cnt);
          if (rs.FParentNode > ANode.FParentNode) this.UpdateNodeParentNode(rs,rs.FParentNode - cnt);
          if (rs.FParentNode === ANode.FParentNode) this.UpdateNodeIndex(rs,rs.FIndex + 1);
          this.GetNodeForNodeData(rs);
          exp = false;
          this.DoIsNodeExpanded(rs,{get: function () {
              return exp;
            }, set: function (v) {
              exp = v;
            }});
          this.UpdateNodeExpanded(rs,exp);
          ext = false;
          this.DoIsNodeExtended(rs,{get: function () {
              return ext;
            }, set: function (v) {
              ext = v;
            }});
          this.UpdateNodeExtended(rs,ext);
          chkst = rtl.arraySetLength(chkst,false,0);
          for (var $l2 = 0, $end2 = this.FColumnCount - 1; $l2 <= $end2; $l2++) {
            K = $l2;
            chk = false;
            this.DoIsNodeChecked(rs,K,{get: function () {
                return chk;
              }, set: function (v) {
                chk = v;
              }});
            chkst = rtl.arraySetLength(chkst,false,rtl.length(chkst) + 1);
            chkst[rtl.length(chkst) - 1] = chk;
          };
          this.UpdateNodeCheckStates(rs,rtl.arrayRef(chkst));
        };
      };
      if (!(AParentNode != null) || ((AParentNode != null) && AParentNode.GetExpanded() && vi)) {
        if (!(AParentNode != null)) {
          this.SetRowCount(this.FRowCount + 1);
          this.FTotalRowHeight = this.FTotalRowHeight + this.GetDefaultRowHeight(ANode);
          ins = this.GetInsertPosition(ANode,true,true);
          if ((ins >= 0) && (ins < this.FVisibleNodes.GetCount())) {
            this.FVisibleNodes.Insert(ins,ANode)}
           else this.FVisibleNodes.Add(ANode);
        } else {
          this.UpdateNodeExpanded(AParentNode,false);
          this.UpdateVisibleNodes(AParentNode);
          this.UpdateNodeExpanded(AParentNode,true);
          this.UpdateVisibleNodes(AParentNode);
        };
      };
      this.ResetNodes(false);
      this.UpdateTreeView();
      this.Invalidate();
    };
    this.UpdateVisibleNodes = function (ANode) {
      var add = false;
      var R = 0;
      var I = 0;
      var C = 0;
      var idx = 0;
      var subv = null;
      var en = false;
      var vi = false;
      var visub = false;
      add = ANode.GetExpanded();
      if (add) {
        idx = this.GetInsertPosition(ANode,ANode.FParentNode === -1,false);
        en = true;
        this.DoIsNodeEnabled(ANode,{get: function () {
            return en;
          }, set: function (v) {
            en = v;
          }});
        vi = true;
        this.DoIsNodeVisible(ANode,{get: function () {
            return vi;
          }, set: function (v) {
            vi = v;
          }});
        if ((idx !== -1) && vi && en) {
          I = 0;
          C = idx + 1;
          while (I < ANode.FTotalChildren) {
            R = I + ANode.FRow + 1;
            subv = this.GetNodeFromNodeStructure(R);
            if ((subv != null) && (((this.MatchFilter(subv) || subv.FAddedToVisibleList) && this.FFilterApplied) || !this.FFilterApplied)) {
              visub = true;
              this.DoIsNodeVisible(subv,{get: function () {
                  return visub;
                }, set: function (v) {
                  visub = v;
                }});
              if (visub) {
                if ((C >= 0) && (C < this.FVisibleNodes.GetCount())) {
                  this.FVisibleNodes.Insert(C,subv)}
                 else this.FVisibleNodes.Add(subv);
                if (subv.FChildren === 0) subv.FExpanded = true;
                this.FTotalRowHeight = this.FTotalRowHeight + subv.FHeight;
                this.SetRowCount(this.FRowCount + 1);
                C += 1;
              };
              if (!subv.GetExpanded() || !visub) I = I + subv.FTotalChildren;
            };
            I += 1;
          };
        };
      } else {
        for (var $l = 0, $end = ANode.FTotalChildren - 1; $l <= $end; $l++) {
          I = $l;
          R = I + ANode.FRow + 1;
          subv = this.GetNodeFromNodeStructure(R);
          if (subv != null) {
            this.UpdateNodeCalculated(subv,false);
            if (this.FVisibleNodes.IndexOf(subv) > -1) {
              this.FVisibleNodes.Remove(subv);
              if (subv.FChildren === 0) subv.FExpanded = false;
              this.FTotalRowHeight = this.FTotalRowHeight - subv.FHeight;
              this.SetRowCount(this.FRowCount - 1);
            };
          };
        };
      };
    };
    this.ToggleNodeInternal = function (ANode, ARecurse) {
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(ANode != null) || !this.FNodeListBuild) return;
      if (ANode.FExpanded) {
        this.CollapseNodeInternal(ANode,ARecurse)}
       else this.ExpandNodeInternal(ANode,ARecurse);
    };
    this.InsertItemInternal = function (AItem) {
      var pn = null;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(AItem != null) || !this.FNodeListBuild) return;
      pn = AItem.FCollection.Node();
      if (pn != null) {
        this.InsertVirtualNode(AItem.GetIndex(),pn.FVirtualNode)}
       else this.InsertVirtualNode(AItem.GetIndex(),null);
    };
    this.RemoveItemInternal = function (AItem, AUpdate) {
      var Result = $mod.TTMSFNCTreeViewVirtualNodeRemoveData.$new();
      Result.RowIndex = -1;
      Result.Count = 0;
      Result.ParentNode = -1;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(AItem != null) || !this.FNodeListBuild) return Result;
      Result.$assign(this.RemoveNodeInternal(AItem.FVirtualNode,AUpdate));
      return Result;
    };
    this.GetNodesSpacing = function (ANode) {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetDefaultRowHeight = function (ANode) {
      var Result = 0.0;
      Result = this.FDefaultRowHeight + this.GetNodesSpacing(ANode);
      return Result;
    };
    this.GetVisibleNodeForIndex = function (AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.FVisibleNodes.GetCount() - 1))) Result = this.FVisibleNodes.GetItem(AIndex);
      return Result;
    };
    this.ToggleNode = function (ANode) {
      if (ANode != null) this.ToggleVirtualNode(ANode.FVirtualNode,false);
    };
    this.UpdateNodeCalculated = function (ANode, ACalculated) {
      ANode.FCalculated = ACalculated;
    };
    this.UpdateNodeHeight = function (ANode, AHeight) {
      ANode.FHeight = AHeight;
    };
    this.UpdateNodeTitleHeight = function (ANode, AHeight) {
      ANode.FTitleHeight = AHeight;
    };
    this.UpdateNodeCheckStates = function (ANode, ACheckStates) {
      ANode.FCheckStates = rtl.arrayRef(ACheckStates);
    };
    this.UpdateNodeBitmapRects = function (ANode, ABitmapRects) {
      ANode.FBitmapRects = rtl.arrayRef(ABitmapRects);
    };
    this.UpdateNodeCheckRects = function (ANode, ACheckRects) {
      ANode.FCheckRects = rtl.arrayRef(ACheckRects);
    };
    this.UpdateNodeExpandRects = function (ANode, AExpandRects) {
      ANode.FExpandRects = rtl.arrayRef(AExpandRects);
    };
    this.UpdateNodeTextRects = function (ANode, ATextRects) {
      ANode.FTextRects = rtl.arrayRef(ATextRects);
    };
    this.UpdateNodeTitleRects = function (ANode, ATitleRects) {
      ANode.FTitleRects = rtl.arrayRef(ATitleRects);
    };
    this.UpdateNodeExtraRects = function (ANode, AExtraRects) {
      ANode.FExtraRects = rtl.arrayRef(AExtraRects);
    };
    this.UpdateNodeTitleExtraRects = function (ANode, ATitleExtraRects) {
      ANode.FTitleExtraRects = rtl.arrayRef(ATitleExtraRects);
    };
    this.UpdateNodeCacheReference = function (ANode, ACache) {
      ANode.FCache = ACache;
    };
    this.UpdateNodeExpanded = function (ANode, AExpanded) {
      ANode.FExpanded = AExpanded;
      if (ANode.FNode != null) ANode.FNode.FExpanded = AExpanded;
    };
    this.UpdateNodeExtended = function (ANode, AExtended) {
      ANode.FExtended = AExtended;
    };
    this.UpdateNodeTotalChildren = function (ANode, ATotalChildren) {
      ANode.FTotalChildren = ATotalChildren;
    };
    this.UpdateNodeChildren = function (ANode, AChildren) {
      ANode.FChildren = AChildren;
    };
    this.UpdateNodeIndex = function (ANode, AIndex) {
      ANode.FIndex = AIndex;
    };
    this.UpdateNodeRow = function (ANode, ARow) {
      ANode.FRow = ARow;
    };
    this.UpdateNodeLevel = function (ANode, ALevel) {
      ANode.FLevel = ALevel;
    };
    this.UpdateNodeParentNode = function (ANode, AParentNode) {
      ANode.FParentNode = AParentNode;
    };
    this.UpdateNode = function (ANode) {
      if (!(ANode != null) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !this.FNodeListBuild) return;
      if (this.FBlockUpdateNode) return;
      ANode.FCalculated = false;
      if (this.FUpdateCount$1 > 0) return;
      this.UpdateNodesCache(true,false);
      this.Invalidate();
    };
    this.CustomizeScrollPosition = function (ANode, APosition, ATopPosition) {
    };
    this.HTMLReplace = function (AValue, ANodeValue) {
      var Result = "";
      var beforetag = "";
      var aftertag = "";
      var nm = "";
      var vl = "";
      var i = 0;
      var j = 0;
      Result = "";
      if (!(ANodeValue != null)) return Result;
      beforetag = "";
      while ((pas.System.Pos("<#",AValue) > 0) && (pas.System.Pos(">",AValue) > 0)) {
        i = pas.System.Pos("<#",AValue);
        beforetag = beforetag + pas.System.Copy(AValue,1,i - 1);
        aftertag = pas.System.Copy(AValue,i,AValue.length);
        j = pas.System.Pos(">",aftertag);
        nm = pas.System.Copy(aftertag,1,j - 1);
        pas.System.Delete({get: function () {
            return nm;
          }, set: function (v) {
            nm = v;
          }},1,2);
        pas.System.Delete({get: function () {
            return AValue;
          }, set: function (v) {
            AValue = v;
          }},1,(i + j) - 1);
        vl = ANodeValue.FHTMLTemplateItems.GetValue(nm);
        this.DoGetHTMLTemplateValue(ANodeValue,nm,{get: function () {
            return vl;
          }, set: function (v) {
            vl = v;
          }});
        beforetag = beforetag + vl;
      };
      Result = beforetag + AValue;
      return Result;
    };
    this.GetHTMLTemplate = function (AColumnIndex) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.Assign.apply(this,arguments);
      if ($mod.TTMSFNCTreeViewData.isPrototypeOf(Source)) {
        this.FColumns.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewData).FColumns);
        this.FGroups.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewData).FGroups);
        this.FNodes.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewData).FNodes);
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.Create$1.apply(this,arguments);
      this.FFilter = $mod.TTMSFNCTreeViewFilter.$create("Create$3",[this]);
      this.FNodeStructure = $mod.TTMSFNCTreeViewNodeStructure.$create("Create$2");
      this.FVisibleNodes = $mod.TTMSFNCTreeViewVisibleNodes.$create("Create$1");
      this.FDisplayGroups = $mod.TTMSFNCTreeViewDisplayGroups.$create("Create$1");
      this.FNodes = this.CreateNodes();
      this.FColumns = this.CreateColumns();
      this.FGroups = this.CreateGroups();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFilter");
      rtl.free(this,"FDisplayGroups");
      rtl.free(this,"FNodeStructure");
      rtl.free(this,"FVisibleNodes");
      rtl.free(this,"FNodes");
      rtl.free(this,"FGroups");
      rtl.free(this,"FColumns");
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.Destroy.call(this);
    };
    this.IsColumnVisible = function (ACol) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.IsColumnVisible.call(this,ACol);
      if ((ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) Result = this.FColumns.GetItem$1(ACol).FVisible;
      return Result;
    };
    this.FindColumnByName = function (AName) {
      var Result = null;
      var I = 0;
      var res = null;
      Result = null;
      for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
        I = $l;
        if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1))) {
          res = this.FColumns.GetItem$1(I);
          if (res.FName === AName) {
            Result = res;
            break;
          };
        };
      };
      return Result;
    };
    this.FindGroupByName = function (AName) {
      var Result = null;
      var I = 0;
      var grp = null;
      Result = null;
      for (var $l = 0, $end = this.FGroups.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        grp = this.FGroups.GetItem$1(I);
        if (grp.FName === AName) {
          Result = grp;
          break;
        };
      };
      return Result;
    };
    this.FindColumnIndexByName = function (AName) {
      var Result = 0;
      var res = null;
      Result = -1;
      res = this.FindColumnByName(AName);
      if (res != null) Result = res.GetIndex();
      return Result;
    };
    this.FindGroupIndexByName = function (AName) {
      var Result = 0;
      var grp = null;
      Result = -1;
      grp = this.FindGroupByName(AName);
      if (grp != null) Result = grp.GetIndex();
      return Result;
    };
    this.BeforeExport = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.BeforeExport.call(this);
      this.ClearNodeList();
    };
    this.AfterExport = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.AfterExport.call(this);
      this.ClearNodeList();
    };
    this.ClearColumns = function () {
      this.BeginUpdate();
      this.FColumns.Clear();
      this.EndUpdate();
    };
    this.ClearNodes = function () {
      this.BeginUpdate();
      this.FNodeListBuild = false;
      this.FNodes.Clear();
      this.ClearFocusedNode(null);
      this.EndUpdate();
    };
    this.ClearNodeList = function () {
      this.BeginUpdate();
      this.FNodeListBuild = false;
      this.ClearFocusedNode(null);
      this.EndUpdate();
    };
    this.RemoveVirtualNode = function (ANode) {
      this.RemoveNodeInternal(ANode,true);
    };
    this.RemoveNode = function (ANode) {
      if (ANode != null) {
        ANode = rtl.freeLoc(ANode);
      };
    };
    this.ExpandNode = function (ANode, ARecurse) {
      if (ANode != null) this.ExpandVirtualNode(ANode.FVirtualNode,ARecurse);
    };
    this.MoveNode = function (ANode, ADestinationNode, AIndex) {
      var n = null;
      var np = null;
      if (!(ANode != null)) return;
      if (ADestinationNode !== ANode) {
        if (ADestinationNode != null) {
          np = ADestinationNode.GetParent();
          while (np != null) {
            if (np === ANode) return;
            np = np.GetParent();
          };
        };
        this.BeginUpdate();
        n = $mod.TTMSFNCTreeViewNode.$create("Create$1",[null]);
        if (ADestinationNode != null) {
          ANode.SetCollection(ADestinationNode.FNodes)}
         else ANode.SetCollection(this.FNodes);
        if (ADestinationNode != null) {
          if ((AIndex >= 0) && (AIndex <= (ADestinationNode.FNodes.GetCount() - 1))) {
            ANode.SetIndex(AIndex)}
           else ANode.SetIndex(ADestinationNode.FNodes.GetCount() - 1);
        } else {
          if ((AIndex >= 0) && (AIndex <= (this.FNodes.GetCount() - 1))) {
            ANode.SetIndex(AIndex)}
           else ANode.SetIndex(this.FNodes.GetCount() - 1);
        };
        n = rtl.freeLoc(n);
        this.EndUpdate();
      };
    };
    this.CopyNode = function (ANode, ADestinationNode, AIndex) {
      var n = null;
      var nw = null;
      if (ADestinationNode !== ANode) {
        this.BeginUpdate();
        n = $mod.TTMSFNCTreeViewNode.$create("Create$1",[null]);
        n.Assign(ANode);
        if (ADestinationNode != null) {
          nw = ADestinationNode.FNodes.Add$1()}
         else nw = this.FNodes.Add$1();
        nw.Assign(n);
        n = rtl.freeLoc(n);
        if (ADestinationNode != null) {
          if ((AIndex >= 0) && (AIndex <= (ADestinationNode.FNodes.GetCount() - 1))) nw.SetIndex(AIndex);
        } else {
          if ((AIndex >= 0) && (AIndex <= (this.FNodes.GetCount() - 1))) nw.SetIndex(AIndex);
        };
        this.EndUpdate();
      };
    };
    this.ExpandAll = function () {
      var $Self = this;
      function ExpandNodes(n) {
        var I = 0;
        for (var $l = 0, $end = n.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          n.GetItem$1(I).FExpanded = true;
          ExpandNodes(n.GetItem$1(I).FNodes);
        };
      };
      ExpandNodes(this.FNodes);
      this.ExpandAllVirtual();
    };
    this.CollapseAll = function () {
      var $Self = this;
      function CollapseNodes(n) {
        var I = 0;
        for (var $l = 0, $end = n.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          n.GetItem$1(I).FExpanded = false;
          CollapseNodes(n.GetItem$1(I).FNodes);
        };
      };
      CollapseNodes(this.FNodes);
      this.CollapseAllVirtual();
    };
    this.ExpandAllVirtual = function () {
      var I = 0;
      var v = null;
      if (this.FFilterApplied) {
        for (var $l = 0, $end = this.FNodeStructure.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          v = this.GetNodeFromNodeStructure(I);
          if (v != null) this.UpdateNodeExpanded(v,true);
        };
        this.FNodeListBuild = false;
        this.BuildNodeList();
        this.ResetNodes(true);
        this.UpdateTreeView();
        this.Invalidate();
        return;
      };
      this.FVisibleNodes.Clear();
      this.FTotalRowHeight = 1;
      this.SetRowCount(0);
      for (var $l1 = 0, $end1 = this.FNodeStructure.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        v = this.GetNodeFromNodeStructure(I);
        if ((v != null) && (((this.MatchFilter(v) || v.FAddedToVisibleList) && this.FFilterApplied) || !this.FFilterApplied)) {
          this.UpdateNodeExpanded(v,true);
          this.FVisibleNodes.Add(v);
          this.FTotalRowHeight = this.FTotalRowHeight + v.FHeight;
          this.SetRowCount(this.FRowCount + 1);
        };
      };
      this.ResetNodes(true);
      this.UpdateTreeView();
      this.Invalidate();
    };
    this.CollapseAllVirtual = function () {
      var I = 0;
      var v = null;
      if (this.FFilterApplied) {
        for (var $l = 0, $end = this.FNodeStructure.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          v = this.GetNodeFromNodeStructure(I);
          if (v != null) this.UpdateNodeExpanded(v,false);
        };
        this.FNodeListBuild = false;
        this.BuildNodeList();
        this.ResetNodes(true);
        this.UpdateTreeView();
        this.Invalidate();
        return;
      };
      this.FVisibleNodes.Clear();
      this.FTotalRowHeight = 1;
      this.SetRowCount(0);
      for (var $l1 = 0, $end1 = this.FNodeStructure.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        v = this.GetNodeFromNodeStructure(I);
        if (v != null) {
          this.UpdateNodeExpanded(v,false);
          if (v.FParentNode === -1) {
            this.FVisibleNodes.Add(v);
            this.FTotalRowHeight = this.FTotalRowHeight + v.FHeight;
            this.SetRowCount(this.FRowCount + 1);
          };
        };
      };
      this.ResetNodes(true);
      this.UpdateTreeView();
      this.Invalidate();
    };
    this.ApplyFilter = function () {
      this.FFilterApplied = true;
      this.ClearNodeList();
    };
    this.RemoveFilter = function () {
      this.FFilterApplied = false;
      this.ClearNodeList();
    };
    this.RemoveFilters = function () {
      this.FFilter.Clear();
      this.RemoveFilter();
    };
    this.CollapseNode = function (ANode, ARecurse) {
      if (ANode != null) this.CollapseVirtualNode(ANode.FVirtualNode,ARecurse);
    };
    this.ToggleVirtualNode = function (ANode, ARecurse) {
      this.ToggleNodeInternal(ANode,ARecurse);
    };
    this.ExpandVirtualNode = function (ANode, ARecurse) {
      this.ExpandNodeInternal(ANode,ARecurse);
    };
    this.CollapseVirtualNode = function (ANode, ARecurse) {
      this.CollapseNodeInternal(ANode,ARecurse);
    };
    this.CheckNode = function (ANode, AColumn, ARecurse) {
      if (ANode != null) this.CheckNodeInternal(ANode.FVirtualNode,AColumn,ARecurse);
    };
    this.UnCheckNode = function (ANode, AColumn, ARecurse) {
      if (ANode != null) this.UnCheckNodeInternal(ANode.FVirtualNode,AColumn,ARecurse);
    };
    this.ToggleCheckNode = function (ANode, AColumn, ARecurse) {
      if (ANode != null) this.ToggleCheckNodeInternal(ANode.FVirtualNode,AColumn,ARecurse);
    };
    this.CheckVirtualNode = function (ANode, AColumn, ARecurse) {
      this.CheckNodeInternal(ANode,AColumn,ARecurse);
    };
    this.UnCheckVirtualNode = function (ANode, AColumn, ARecurse) {
      this.UnCheckNodeInternal(ANode,AColumn,ARecurse);
    };
    this.ToggleCheckVirtualNode = function (ANode, AColumn, ARecurse) {
      this.ToggleCheckNodeInternal(ANode,AColumn,ARecurse);
    };
    this.SetNodeTextValues = function (ANode, ATextValues) {
      if (ANode != null) ANode.SetTextValues(rtl.arrayRef(ATextValues));
    };
    this.SetNodeCheckStates = function (ANode, ACheckStates) {
      if (ANode != null) ANode.SetCheckStates(rtl.arrayRef(ACheckStates));
    };
    this.SetNodeCheckTypes = function (ANode, ACheckTypes) {
      if (ANode != null) ANode.SetCheckTypes(rtl.arrayRef(ACheckTypes));
    };
    this.SetNodeCollapsedIcons = function (ANode, AIcons, ALarge) {
      if (ANode != null) ANode.SetCollapsedIcons(rtl.arrayRef(AIcons),ALarge);
    };
    this.SetNodeExpandedIcons = function (ANode, AIcons, ALarge) {
      if (ANode != null) ANode.SetExpandedIcons(rtl.arrayRef(AIcons),ALarge);
    };
    this.SetNodeCollapsedIconNames = function (ANode, AIconNames, ALarge) {
      if (ANode != null) ANode.SetCollapsedIconNames(rtl.arrayRef(AIconNames),ALarge);
    };
    this.SetNodeExpandedIconNames = function (ANode, AIconNames, ALarge) {
      if (ANode != null) ANode.SetExpandedIconNames(rtl.arrayRef(AIconNames),ALarge);
    };
    this.RemoveVirtualNodeChildren = function (ANode) {
      var I = 0;
      var s = null;
      if (ANode != null) {
        for (var $l = ANode.FTotalChildren - 1; $l >= 0; $l--) {
          I = $l;
          s = this.GetNodeFromNodeStructure(ANode.FRow + I);
          if (s != null) this.RemoveVirtualNode(s);
        };
      };
    };
    this.RemoveNodeChildren = function (ANode) {
      if (ANode != null) ANode.FNodes.Clear();
    };
    this.ScrollToNode = function (ANode, AScrollIfNotVisible, AScrollPosition, AForceScroll) {
      if (ANode != null) this.ScrollToVirtualNode(ANode.FVirtualNode,AScrollIfNotVisible,AScrollPosition,AForceScroll);
    };
    this.ScrollToVirtualNode = function (ANode, AScrollIfNotVisible, AScrollPosition, AForceScroll) {
      var v = 0.0;
      if (!(ANode != null)) return;
      if (this.IsVariableNodeHeight()) {
        while (!ANode.FCalculated && (ANode.GetExpanded() || (ANode.FChildren === 0))) {
          v = this.GetVerticalScrollPosition();
          this.ScrollToVirtualNodeInternal(ANode,AScrollIfNotVisible,AScrollPosition,AForceScroll);
          if (v === this.GetVerticalScrollPosition()) break;
        };
      };
      this.ScrollToVirtualNodeInternal(ANode,AScrollIfNotVisible,AScrollPosition,AForceScroll);
    };
    this.ScrollToVirtualNodeInternal = function (ANode, AScrollIfNotVisible, AScrollPosition, AForceScroll) {
      var I = 0;
      var yp = 0.0;
      var ps = 0.0;
      var v = null;
      yp = 0;
      if (ANode != null) {
        for (var $l = 0, $end = this.FVisibleNodes.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          v = this.FVisibleNodes.GetItem(I);
          if (v != null) {
            if (v.FRow === ANode.FRow) break;
            if (v.FCalculated) {
              yp = yp + v.FHeight}
             else yp = yp + this.GetDefaultRowHeight(v);
          };
        };
        ps = yp;
        var $tmp = AScrollPosition;
        if ($tmp === $mod.TTMSFNCTreeViewNodeScrollPosition.tvnspBottom) {
          yp = (yp - this.GetVViewPortSize()) + ANode.FHeight}
         else if ($tmp === $mod.TTMSFNCTreeViewNodeScrollPosition.tvnspMiddle) yp = (yp - (this.GetVViewPortSize() / 2)) + (ANode.FHeight / 2);
        this.CustomizeScrollPosition(ANode,{get: function () {
            return yp;
          }, set: function (v) {
            yp = v;
          }},{get: function () {
            return ps;
          }, set: function (v) {
            ps = v;
          }});
        if (AScrollIfNotVisible) {
          if ((ps < Math.abs(this.GetVScrollValue())) || ((ps + ANode.FHeight) > (Math.abs(this.GetVScrollValue()) + this.GetVViewPortSize())) || AForceScroll) this.Scroll(this.GetHScrollValue(),yp);
        } else {
          this.Scroll(this.GetHScrollValue(),yp);
        };
      };
    };
    this.ScrollToVirtualNodeRow = function (ARow, AScrollIfNotVisible, AScrollPosition, AForceScroll) {
      var n = null;
      n = this.GetNodeForRow(ARow);
      if (n != null) this.ScrollToVirtualNode(n,AScrollIfNotVisible,AScrollPosition,AForceScroll);
    };
    this.ScrollToTop = function () {
      this.VerticalScrollBar().SetPosition(0);
    };
    this.ScrollToBottom = function () {
      this.VerticalScrollBar().SetPosition(this.VerticalScrollBar().FMax);
    };
    this.GetNodeForRow = function (ARow) {
      var Result = null;
      Result = null;
      if ((ARow >= 0) && (ARow <= (this.FNodeStructure.GetCount() - 1))) Result = this.FNodeStructure.GetItem$1(ARow);
      return Result;
    };
    this.AddNode = function (AParentNode) {
      var Result = null;
      if (AParentNode != null) {
        Result = AParentNode.FNodes.Add$1()}
       else Result = this.FNodes.Add$1();
      return Result;
    };
    this.AddVirtualNode = function (AParentNode) {
      var Result = null;
      var p = null;
      var idx = 0;
      Result = null;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !this.FNodeListBuild) return Result;
      if (AParentNode != null) {
        idx = AParentNode.FChildren;
      } else {
        p = null;
        if (this.FNodeStructure.GetCount() > 0) {
          p = this.GetNodeFromNodeStructure(this.FNodeStructure.GetCount() - 1);
          while ((p != null) && (p.FParentNode >= 0) && (p.FParentNode <= (this.FNodeStructure.GetCount() - 1))) p = this.GetNodeFromNodeStructure(p.FParentNode);
        };
        idx = p.FIndex + 1;
      };
      Result = this.InsertVirtualNode(idx,AParentNode);
      return Result;
    };
    this.GetParentVirtualNode = function (ANode) {
      var Result = null;
      Result = null;
      if (ANode != null) Result = this.GetNodeFromNodeStructure(ANode.FParentNode);
      return Result;
    };
    this.GetParentNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetParentVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetVirtualNodeChildCount = function (ANode) {
      var Result = 0;
      Result = 0;
      if (ANode != null) Result = ANode.FChildren;
      return Result;
    };
    this.GetTotalVirtualNodeCount = function () {
      var Result = 0;
      var n = null;
      Result = 0;
      n = this.GetFirstRootVirtualNode();
      while (n != null) {
        Result = Result + n.FTotalChildren + 1;
        n = n.GetNextSibling();
      };
      return Result;
    };
    this.GetTotalNodeCount = function () {
      var Result = 0;
      Result = this.GetTotalVirtualNodeCount();
      return Result;
    };
    this.GetNodeText = function (ANode, AColumn) {
      var Result = "";
      Result = this.GetVirtualNodeText(ANode.FVirtualNode,AColumn);
      return Result;
    };
    this.GetVirtualNodeText = function (ANode, AColumn) {
      var Result = "";
      Result = "";
      if (ANode != null) {
        Result = "";
        this.DoGetNodeText(ANode,AColumn,$mod.TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
      };
      return Result;
    };
    this.GetNodeTitle = function (ANode, AColumn) {
      var Result = "";
      Result = this.GetVirtualNodeTitle(ANode.FVirtualNode,AColumn);
      return Result;
    };
    this.GetVirtualNodeTitle = function (ANode, AColumn) {
      var Result = "";
      Result = "";
      if (ANode != null) {
        Result = "";
        this.DoGetNodeTitle(ANode,AColumn,$mod.TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
      };
      return Result;
    };
    this.GetVirtualNodeTitleExpanded = function (ANode, AColumn) {
      var Result = false;
      Result = true;
      if (ANode != null) {
        Result = true;
        this.DoGetNodeTitleExpanded(ANode,AColumn,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
      };
      return Result;
    };
    this.FindVirtualNodeByRow = function (ARow) {
      var Result = null;
      var n = null;
      Result = null;
      n = this.GetFirstRootVirtualNode();
      while (n != null) {
        if (n.FRow === ARow) {
          Result = n;
          break;
        };
        n = n.GetNext();
      };
      return Result;
    };
    this.FindNodeByRow = function (ARow) {
      var Result = null;
      var v = null;
      Result = null;
      v = this.FindVirtualNodeByRow(ARow);
      if (v != null) Result = v.FNode;
      return Result;
    };
    this.FindVirtualNodeByDBKey = function (ADBKey) {
      var Result = null;
      var n = null;
      Result = null;
      n = this.GetFirstRootVirtualNode();
      while (n != null) {
        if ((n.FNode != null) && (n.FNode.FDBKey === ADBKey)) {
          Result = n;
          break;
        };
        n = n.GetNext();
      };
      return Result;
    };
    this.FindNodeByDBKey = function (ADBKey) {
      var Result = null;
      var v = null;
      Result = null;
      v = this.FindVirtualNodeByDBKey(ADBKey);
      if (v != null) Result = v.FNode;
      return Result;
    };
    this.FindVirtualNodeByTextAndColumn = function (AText, AColumn, ARecurse, ACaseSensitive) {
      var Result = null;
      var n = null;
      var t = "";
      Result = null;
      n = this.GetFirstRootVirtualNode();
      while (n != null) {
        t = "";
        this.DoGetNodeText(n,AColumn,$mod.TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx(AText,t,ACaseSensitive)) {
          Result = n;
          break;
        };
        if (ARecurse) {
          n = n.GetNext()}
         else n = n.GetNextSibling();
      };
      return Result;
    };
    this.FindNodeByTextAndColumn = function (AText, AColumn, ARecurse, ACaseSensitive) {
      var Result = null;
      var v = null;
      Result = null;
      v = this.FindVirtualNodeByTextAndColumn(AText,AColumn,ARecurse,ACaseSensitive);
      if (v != null) Result = v.FNode;
      return Result;
    };
    this.GetNodeChildCount = function (ANode) {
      var Result = 0;
      Result = 0;
      if (ANode != null) Result = this.GetVirtualNodeChildCount(ANode.FVirtualNode);
      return Result;
    };
    this.GetPreviousNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetPreviousVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetNextNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetNextVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetPreviousChildNode = function (ANode, AStartNode) {
      var Result = null;
      var v = null;
      Result = null;
      if ((ANode != null) && (AStartNode != null)) {
        v = this.GetPreviousChildVirtualNode(ANode.FVirtualNode,AStartNode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetNextChildNode = function (ANode, AStartNode) {
      var Result = null;
      var v = null;
      Result = null;
      if ((ANode != null) && (AStartNode != null)) {
        v = this.GetNextChildVirtualNode(ANode.FVirtualNode,AStartNode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetNextSiblingNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetNextSiblingVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetPreviousSiblingNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetPreviousSiblingVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetFirstChildNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetFirstChildVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetLastChildNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = null;
      if (ANode != null) {
        v = this.GetLastChildVirtualNode(ANode.FVirtualNode);
        if (v != null) Result = v.FNode;
      };
      return Result;
    };
    this.GetPreviousVirtualNode = function (ANode) {
      var Result = null;
      Result = null;
      if (ANode != null) Result = this.GetNodeFromNodeStructure(ANode.FRow - 1);
      return Result;
    };
    this.GetNextVirtualNode = function (ANode) {
      var Result = null;
      Result = null;
      if (ANode != null) Result = this.GetNodeFromNodeStructure(ANode.FRow + 1);
      return Result;
    };
    this.GetPreviousChildVirtualNode = function (ANode, AStartNode) {
      var Result = null;
      Result = this.GetPreviousSiblingVirtualNode(AStartNode);
      return Result;
    };
    this.GetNextChildVirtualNode = function (ANode, AStartNode) {
      var Result = null;
      Result = this.GetNextSiblingVirtualNode(AStartNode);
      return Result;
    };
    this.GetNextSiblingVirtualNode = function (ANode) {
      var Result = null;
      var res = null;
      res = ANode;
      do {
        res = this.GetNextVirtualNode(res);
        Result = res;
      } while (!((Result === null) || ((Result != null) && (Result.FParentNode === ANode.FParentNode))));
      return Result;
    };
    this.GetPreviousSiblingVirtualNode = function (ANode) {
      var Result = null;
      var res = null;
      res = ANode;
      do {
        res = this.GetPreviousVirtualNode(res);
        Result = res;
      } while (!((Result === null) || ((Result != null) && (Result.FParentNode === ANode.FParentNode))));
      return Result;
    };
    this.GetFirstChildVirtualNode = function (ANode) {
      var Result = null;
      Result = null;
      if ((ANode != null) && (ANode.FChildren > 0)) Result = this.GetNodeFromNodeStructure(ANode.FRow + 1);
      return Result;
    };
    this.GetLastChildVirtualNode = function (ANode) {
      var Result = null;
      var v = null;
      Result = this.GetFirstChildVirtualNode(ANode);
      if (Result != null) {
        v = Result;
        do {
          Result = v;
          v = this.GetNextSiblingVirtualNode(v);
        } while (!(v === null));
      };
      return Result;
    };
    this.GetFirstRootNode = function () {
      var Result = null;
      var n = null;
      Result = null;
      n = this.GetFirstRootVirtualNode();
      if (n != null) Result = n.FNode;
      return Result;
    };
    this.GetLastRootNode = function () {
      var Result = null;
      var n = null;
      Result = null;
      n = this.GetLastRootVirtualNode();
      if (n != null) Result = n.FNode;
      return Result;
    };
    this.GetLastNode = function () {
      var Result = null;
      var n = null;
      Result = null;
      n = this.GetLastVirtualNode();
      if (n != null) Result = n.FNode;
      return Result;
    };
    this.GetFirstRootVirtualNode = function () {
      var Result = null;
      Result = null;
      if (this.FNodeStructure.GetCount() > 0) Result = this.FNodeStructure.GetItem$1(0);
      return Result;
    };
    this.GetLastRootVirtualNode = function () {
      var Result = null;
      Result = null;
      if (this.FNodeStructure.GetCount() > 0) {
        Result = this.FNodeStructure.GetItem$1(this.FNodeStructure.GetCount() - 1);
        while ((Result != null) && (Result.FParentNode > -1)) Result = this.FNodeStructure.GetItem$1(Result.FRow - 1);
      };
      return Result;
    };
    this.GetLastVirtualNode = function () {
      var Result = null;
      Result = null;
      if (this.FNodeStructure.GetCount() > 0) Result = this.FNodeStructure.GetItem$1(this.FNodeStructure.GetCount() - 1);
      return Result;
    };
    this.GetRootNodeByIndex = function (AIndex) {
      var Result = null;
      var n = null;
      Result = null;
      n = this.GetRootVirtualNodeByIndex(AIndex);
      if (n != null) Result = n.FNode;
      return Result;
    };
    this.GetRootVirtualNodeByIndex = function (AIndex) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.FNodeStructure.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FNodeStructure.GetItem$1(I).FIndex === AIndex) {
          Result = this.FNodeStructure.GetItem$1(I);
          break;
        };
      };
      return Result;
    };
    this.InsertNode = function (AIndex, AParentNode) {
      var Result = null;
      if (AParentNode != null) {
        Result = AParentNode.FNodes.Insert$1(AIndex)}
       else Result = this.FNodes.Insert$1(AIndex);
      return Result;
    };
    this.InsertVirtualNode = function (AIndex, AParentNode) {
      var Result = null;
      var v = null;
      var p = null;
      var n = null;
      var c = null;
      var I = 0;
      var idx = 0;
      Result = null;
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !this.FNodeListBuild) return Result;
      v = $mod.TTMSFNCTreeViewVirtualNode.$create("Create$1",[this]);
      if (AParentNode != null) {
        idx = -1;
        I = AParentNode.FRow + 1;
        while (I <= (AParentNode.FRow + AParentNode.FTotalChildren)) {
          n = this.GetNodeFromNodeStructure(I);
          if (n != null) {
            if ((n.FIndex === AIndex) && (n.FParentNode === AParentNode.FRow)) {
              idx = n.FRow;
              break;
            };
            I = I + n.FChildren + 1;
          } else break;
        };
        if (idx === -1) {
          this.InsertNodeInternal(AParentNode,AIndex,AParentNode.FRow + AParentNode.FTotalChildren + 1,v)}
         else this.InsertNodeInternal(AParentNode,AIndex,idx,v);
      } else {
        p = null;
        if (this.FNodeStructure.GetCount() > 0) {
          p = this.GetNodeFromNodeStructure(this.FNodeStructure.GetCount() - 1);
          while ((p != null) && (p.FParentNode >= 0) && (p.FParentNode <= (this.FNodeStructure.GetCount() - 1))) p = this.GetNodeFromNodeStructure(p.FParentNode);
        };
        if (p != null) {
          if (AIndex > p.FIndex) {
            this.InsertNodeInternal(null,AIndex,p.FRow + p.FTotalChildren + 1,v)}
           else {
            n = null;
            I = 0;
            while (!(n != null)) {
              c = this.GetNodeFromNodeStructure(I);
              if (c != null) {
                if (c.FIndex === AIndex) {
                  n = c;
                  break;
                } else I = I + c.FTotalChildren + 1;
              } else break;
            };
            if (n != null) this.InsertNodeInternal(null,AIndex,n.FRow,v);
          };
        } else this.InsertNodeInternal(null,0,0,v);
      };
      Result = v;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TranslateTextEx = function (AText) {
    var Result = "";
    Result = AText;
    return Result;
  };
  $mod.$resourcestrings = {sTMSFNCTreeViewGroup: {org: "Group"}, sTMSFNCTreeViewColumn: {org: "Column"}};
  $mod.$implcode = function () {
    rtl.createClass($impl,"TShadowedCollection",pas.Classes.TPersistent,function () {
      this.$init = function () {
        pas.Classes.TPersistent.$init.call(this);
        this.FItemClass = null;
        this.FItems = null;
      };
      this.$final = function () {
        this.FItemClass = undefined;
        this.FItems = undefined;
        pas.Classes.TPersistent.$final.call(this);
      };
    });
  };
},["SysUtils","Math","WEBLib.TMSFNCUtils","WEBLib.Graphics"]);
rtl.module("WEBLib.TMSFNCPopup",["System","Classes","WEBLib.Controls","WEBLib.TMSFNCCustomComponent","WEBLib.TMSFNCGraphics","WEBLib.Graphics","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphicsTypes","WEBLib.Forms","WEBLib.ExtCtrls","Types","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 9;
  this.TTMSFNCPopupPlacement = {"0": "ppBottom", ppBottom: 0, "1": "ppTop", ppTop: 1, "2": "ppLeft", ppLeft: 2, "3": "ppRight", ppRight: 3, "4": "ppCenter", ppCenter: 4, "5": "ppBottomCenter", ppBottomCenter: 5, "6": "ppTopCenter", ppTopCenter: 6, "7": "ppLeftCenter", ppLeftCenter: 7, "8": "ppRightCenter", ppRightCenter: 8, "9": "ppAbsolute", ppAbsolute: 9, "10": "ppMouse", ppMouse: 10, "11": "ppMouseCenter", ppMouseCenter: 11, "12": "ppAboveMouse", ppAboveMouse: 12, "13": "ppAboveMouseCenter", ppAboveMouseCenter: 13};
  this.$rtti.$Enum("TTMSFNCPopupPlacement",{minvalue: 0, maxvalue: 13, ordtype: 1, enumtype: this.TTMSFNCPopupPlacement});
  this.$rtti.$MethodVar("TTMSFNCPopupPaint",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  this.$rtti.$Class("TTMSFNCCustomPopupForm");
  this.$rtti.$ClassRef("TTMSFNCCustomPopupFormClass",{instancetype: this.$rtti["TTMSFNCCustomPopupForm"]});
  this.$rtti.$Class("TTMSFNCCustomPopup");
  rtl.createClass(this,"TCustomPaintedForm",pas["WEBLib.Forms"].TCustomForm,function () {
    this.$init = function () {
      pas["WEBLib.Forms"].TCustomForm.$init.call(this);
      this.FPaintBox = null;
    };
    this.$final = function () {
      this.FPaintBox = undefined;
      pas["WEBLib.Forms"].TCustomForm.$final.call(this);
    };
    this.GetCanvas$1 = function () {
      var Result = null;
      this.CreateCanvas();
      Result = this.FPaintBox.GetCanvas();
      return Result;
    };
    this.DoPaint = function (Sender) {
      this.Paint();
    };
    this.Paint = function () {
      pas["WEBLib.Forms"].TCustomForm.Paint.call(this);
      if (this.FOnPaint != null) this.FOnPaint(this);
    };
    this.CreateCanvas = function () {
      if (!(this.FPaintBox != null)) {
        this.FPaintBox = pas["WEBLib.ExtCtrls"].TPaintBox.$create("Create$1",[this]);
        this.FPaintBox.SetParent(this);
        this.FPaintBox.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
        this.FPaintBox.FOnPaint = rtl.createCallback(this,"DoPaint");
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomPopupForm",this.TCustomPaintedForm,function () {
    this.$init = function () {
      $mod.TCustomPaintedForm.$init.call(this);
      this.FPreferedDisplayIndex = 0;
      this.FHintWindow = false;
      this.FTimer = null;
      this.FFirstShow = false;
      this.FOwner$1 = null;
      this.FShowModal = false;
      this.FPlacement = 0;
      this.FRealPlacement = 0;
      this.FPlacementControl = null;
      this.FOffset = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      this.FSize = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      this.FPlacementRectangle = null;
      this.FScreenPlacementRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FPlacementChanged = false;
      this.FDragWithParent = false;
      this.FOnBeforeClose = null;
      this.FOnBeforeShow = null;
      this.FScreenContentRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FContentPadding = null;
      this.FContentControl = null;
      this.FOnRealPlacementChanged = null;
      this.FOnPopupPaint = null;
    };
    this.$final = function () {
      this.FTimer = undefined;
      this.FOwner$1 = undefined;
      this.FPlacementControl = undefined;
      this.FOffset = undefined;
      this.FSize = undefined;
      this.FPlacementRectangle = undefined;
      this.FScreenPlacementRect = undefined;
      this.FOnBeforeClose = undefined;
      this.FOnBeforeShow = undefined;
      this.FScreenContentRect = undefined;
      this.FContentPadding = undefined;
      this.FContentControl = undefined;
      this.FOnRealPlacementChanged = undefined;
      this.FOnPopupPaint = undefined;
      $mod.TCustomPaintedForm.$final.call(this);
    };
    this.SetOffset = function (Value) {
      if ((this.FOffset.X !== Value.X) || (this.FOffset.Y !== Value.Y)) {
        this.FOffset.$assign(Value);
        this.ApplyPlacement();
      };
    };
    this.SetSize = function (Value) {
      if ((this.FSize.cx !== Value.cx) || (this.FSize.cy !== Value.cy)) {
        this.FSize.$assign(Value);
        this.ApplyPlacement();
      };
    };
    this.TimerProc = function (Sender) {
      if ((this.FVisible || this.FHintWindow) && (this.FFirstShow || this.FDragWithParent)) this.ApplyPlacement();
      if ((this.FVisible || this.FHintWindow) && this.FFirstShow) {
        this.FFirstShow = false;
      };
    };
    this.SetPlacementRectangle = function (Value) {
      this.FPlacementRectangle.Assign(Value);
    };
    this.SetPlacement = function (Value) {
      if (this.FPlacement !== Value) {
        this.FPlacement = Value;
        this.ApplyPlacement();
      };
    };
    this.SetPlacementControl = function (Value) {
      if (this.FPlacementControl !== Value) {
        if (this.FPlacementControl !== null) this.FPlacementControl.RemoveFreeNotification(this);
        this.FPlacementControl = Value;
        if (this.FPlacementControl !== null) this.FPlacementControl.FreeNotification(this);
      };
    };
    this.SetDragWithParent = function (Value) {
      this.FDragWithParent = Value;
    };
    this.SetContentPadding = function (Value) {
      this.FContentPadding.Assign(Value);
    };
    this.SetContentControl = function (Value) {
      if (this.FContentControl !== Value) {
        if (this.FContentControl !== null) this.FContentControl.RemoveFreeNotification(this);
        this.FContentControl = Value;
        if (this.FContentControl !== null) {
          this.FContentControl.FreeNotification(this);
          try {
            this.FContentControl.SetParent(this);
            this.FContentControl.SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
            this.FContentControl.SetVisible(true);
          } finally {
          };
        };
      };
    };
    this.GetPopup = function () {
      var Result = null;
      Result = null;
      if ($mod.TTMSFNCCustomPopup.isPrototypeOf(this.FOwner$1)) Result = rtl.as(this.FOwner$1,$mod.TTMSFNCCustomPopup);
      return Result;
    };
    this.DoBeforeShow = function () {
      this.FHintWindow = false;
      if (this.FOnBeforeShow != null) this.FOnBeforeShow(this);
      this.FFirstShow = true;
      if (!(this.FTimer != null)) this.FTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FTimer.SetInterval(20);
      this.FTimer.FOnTimer = rtl.createCallback(this,"TimerProc");
      this.FTimer.SetEnabled(true);
    };
    this.DoBeforeClose = function () {
      if (this.FOnBeforeClose != null) this.FOnBeforeClose(this);
    };
    this.UpdateBounds = function (LRect) {
      this.SetBounds(Math.round(LRect.Left),Math.round(LRect.Top),Math.round(LRect.Right - LRect.Left),Math.round(LRect.Bottom - LRect.Top));
    };
    this.DoClose = function (CloseAction) {
      CloseAction.set(pas["WEBLib.Forms"].TCloseAction.caFree);
      pas["WEBLib.Forms"].TCustomForm.DoClose.apply(this,arguments);
      if (CloseAction.get() !== pas["WEBLib.Forms"].TCloseAction.caNone) {
        if (this.FTimer != null) this.FTimer.SetEnabled(false);
      };
    };
    this.DoApplyPlacement = function () {
      var $Self = this;
      var Pos = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var pt = pas.Types.TPoint.$new();
      var AbsolutePos = pas.Types.TPoint.$new();
      var LRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var LPlacement = 0;
      var LOffset = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var LStep = 0;
      var LSoGood = false;
      var SourceSize = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var PlacementByTarget = false;
      function UpdateRectByScreen(R, cs) {
        var Result = false;
        var WorkareaRect = pas.Types.TRect.$new();
        var WorkareaRectF = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var W = 0.0;
        var H = 0.0;
        var P = pas.Types.TPoint.$new();
        Result = true;
        R.Left = Math.round(R.Left);
        R.Top = Math.round(R.Top);
        R.Right = Math.round(R.Right);
        R.Bottom = Math.round(R.Bottom);
        WorkareaRect.Left = 0;
        WorkareaRect.Top = 0;
        WorkareaRect.Right = pas["WEBLib.Forms"].WinWidth();
        WorkareaRect.Bottom = pas["WEBLib.Forms"].WinHeight();
        WorkareaRectF.$assign(pas["WEBLib.TMSFNCTypes"].RectF(WorkareaRect.Left - $Self.FContentPadding.FLeft,WorkareaRect.Top - $Self.FContentPadding.FTop,WorkareaRect.Right + $Self.FContentPadding.FRight,WorkareaRect.Bottom + $Self.FContentPadding.FBottom));
        if (!(pas.Classes.TComponentStateItem.csDesigning in cs)) {
          W = R.Right - R.Left;
          H = R.Bottom - R.Top;
          if (R.Left > WorkareaRectF.Left) {
            if (R.Left > (WorkareaRectF.Right - W)) {
              R.Left = WorkareaRectF.Right - W;
              if (LPlacement === $mod.TTMSFNCPopupPlacement.ppRight) {
                LPlacement = $mod.TTMSFNCPopupPlacement.ppLeft;
                Result = false;
              };
              if (LPlacement === $mod.TTMSFNCPopupPlacement.ppRightCenter) {
                LPlacement = $mod.TTMSFNCPopupPlacement.ppLeftCenter;
                Result = false;
              };
            };
          } else {
            R.Left = WorkareaRectF.Left;
            if (LPlacement === $mod.TTMSFNCPopupPlacement.ppLeft) {
              LPlacement = $mod.TTMSFNCPopupPlacement.ppRight;
              Result = false;
            };
            if (LPlacement === $mod.TTMSFNCPopupPlacement.ppLeftCenter) {
              LPlacement = $mod.TTMSFNCPopupPlacement.ppRightCenter;
              Result = false;
            };
          };
          if (R.Top > WorkareaRectF.Top) {
            if (R.Top > (WorkareaRectF.Bottom - H)) {
              R.Top = WorkareaRectF.Bottom - H;
              if (LPlacement === $mod.TTMSFNCPopupPlacement.ppBottom) {
                LPlacement = $mod.TTMSFNCPopupPlacement.ppTop;
                Result = false;
              };
              if (LPlacement === $mod.TTMSFNCPopupPlacement.ppBottomCenter) {
                LPlacement = $mod.TTMSFNCPopupPlacement.ppTopCenter;
                Result = false;
              };
            };
          } else {
            R.Top = WorkareaRectF.Top;
            if (LPlacement === $mod.TTMSFNCPopupPlacement.ppTop) {
              LPlacement = $mod.TTMSFNCPopupPlacement.ppBottom;
              Result = false;
            };
            if (LPlacement === $mod.TTMSFNCPopupPlacement.ppTopCenter) {
              LPlacement = $mod.TTMSFNCPopupPlacement.ppBottomCenter;
              Result = false;
            };
          };
          R.Right = R.Left + W;
          R.Bottom = R.Top + H;
        };
        return Result;
      };
      this.FPlacementChanged = false;
      LOffset.$assign(this.FOffset);
      LPlacement = this.FPlacement;
      LStep = 0;
      do {
        LRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FPlacementRectangle.FLeft,this.FPlacementRectangle.FTop,this.FPlacementRectangle.FRight,this.FPlacementRectangle.FBottom));
        if ((this.FPlacementControl !== null) && this.FPlacementRectangle.Empty()) LRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FPlacementControl.GetWidth(),this.FPlacementControl.GetHeight()));
        if ((this.FPlacementControl === null) && this.FPlacementRectangle.Empty() && !(LPlacement in rtl.createSet($mod.TTMSFNCPopupPlacement.ppAbsolute,$mod.TTMSFNCPopupPlacement.ppMouse,$mod.TTMSFNCPopupPlacement.ppMouseCenter,$mod.TTMSFNCPopupPlacement.ppAboveMouse,$mod.TTMSFNCPopupPlacement.ppAboveMouseCenter))) ;
        this.FScreenPlacementRect.$assign(LRect);
        if (LPlacement in rtl.createSet($mod.TTMSFNCPopupPlacement.ppTop,$mod.TTMSFNCPopupPlacement.ppTopCenter)) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,0,this.FContentPadding.FBottom - LOffset.Y)}
         else pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,0,LOffset.Y - this.FContentPadding.FTop);
        if (LPlacement in rtl.createSet($mod.TTMSFNCPopupPlacement.ppLeft,$mod.TTMSFNCPopupPlacement.ppLeftCenter)) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,this.FContentPadding.FRight - LOffset.X,0)}
         else pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,LOffset.X - this.FContentPadding.FLeft,0);
        PlacementByTarget = !(LPlacement in rtl.createSet($mod.TTMSFNCPopupPlacement.ppAbsolute,$mod.TTMSFNCPopupPlacement.ppMouse,$mod.TTMSFNCPopupPlacement.ppMouseCenter,$mod.TTMSFNCPopupPlacement.ppAboveMouse,$mod.TTMSFNCPopupPlacement.ppAboveMouseCenter));
        SourceSize.$assign(this.FSize);
        var $tmp = LPlacement;
        if ($tmp === $mod.TTMSFNCPopupPlacement.ppBottom) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,0,LRect.Bottom - LRect.Top)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppTop) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,0,-SourceSize.cy)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppLeft) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,-SourceSize.cx,0)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppRight) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,LRect.Right - LRect.Left,0)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppCenter) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,(LRect.Right - LRect.Left - SourceSize.cx) / 2,(LRect.Bottom - LRect.Top - SourceSize.cy) / 2)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppBottomCenter) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,(LRect.Right - LRect.Left - SourceSize.cx) / 2,LRect.Bottom - LRect.Top)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppTopCenter) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,(LRect.Right - LRect.Left - SourceSize.cx) / 2,-SourceSize.cy)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppLeftCenter) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,-SourceSize.cx,(LRect.Bottom - LRect.Top - SourceSize.cy) / 2)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppRightCenter) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,LRect.Right - LRect.Left,(LRect.Bottom - LRect.Top - SourceSize.cy) / 2)}
         else if ($tmp === $mod.TTMSFNCPopupPlacement.ppAbsolute) {
          if (this.FPlacementRectangle.Empty()) {
            LRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FPlacementRectangle.GetRect().Left,this.FPlacementRectangle.GetRect().Top,this.FPlacementRectangle.GetRect().Left + SourceSize.cx,this.FPlacementRectangle.GetRect().Top + SourceSize.cy))}
           else LRect.$assign(this.FPlacementRectangle.GetRect());
        } else if (($tmp === $mod.TTMSFNCPopupPlacement.ppMouse) || ($tmp === $mod.TTMSFNCPopupPlacement.ppMouseCenter) || ($tmp === $mod.TTMSFNCPopupPlacement.ppAboveMouse) || ($tmp === $mod.TTMSFNCPopupPlacement.ppAboveMouseCenter)) {
          Pos.$assign(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetMousePos());
          LRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Pos.X,Pos.Y,Pos.X + SourceSize.cx,Pos.Y + SourceSize.cy));
          if (LPlacement === $mod.TTMSFNCPopupPlacement.ppMouseCenter) pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,-SourceSize.cx / 2,-SourceSize.cy / 2);
          if (LPlacement === $mod.TTMSFNCPopupPlacement.ppAboveMouseCenter) pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,-SourceSize.cx / 2,-SourceSize.cy - 5);
          if (LPlacement === $mod.TTMSFNCPopupPlacement.ppAboveMouse) pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(LRect,0,-SourceSize.cy - 5);
        };
        if (PlacementByTarget) {
          AbsolutePos.$assign(pas.Types.Point(Math.round(LRect.Left),Math.round(LRect.Top)));
          if (this.FPlacementControl !== null) {
            AbsolutePos.$assign(this.FPlacementControl.ClientToScreen(AbsolutePos));
            pt.$assign(pas.Types.Point(Math.round(this.FScreenPlacementRect.Left),Math.round(this.FScreenPlacementRect.Top)));
            pt.$assign(this.FPlacementControl.ClientToScreen(pt));
            this.FScreenPlacementRect.Left = pt.x;
            this.FScreenPlacementRect.Top = pt.y;
            pt.$assign(pas.Types.Point(Math.round(this.FScreenPlacementRect.Right),Math.round(this.FScreenPlacementRect.Bottom)));
            pt.$assign(this.FPlacementControl.ClientToScreen(pt));
            this.FScreenPlacementRect.Right = pt.x;
            this.FScreenPlacementRect.Bottom = pt.y;
          };
          LRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(AbsolutePos.x,AbsolutePos.y,AbsolutePos.x + this.FSize.cx,AbsolutePos.y + this.FSize.cy));
        };
        LSoGood = UpdateRectByScreen(LRect,rtl.refSet(this.FComponentState));
        LStep += 1;
      } while (!(LSoGood || (LStep > 1)));
      this.FScreenContentRect.$assign(LRect);
      this.FScreenContentRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FScreenContentRect.Left + this.FContentPadding.FLeft,this.FScreenContentRect.Top + this.FContentPadding.FTop,this.FScreenContentRect.Right - this.FContentPadding.FRight,this.FScreenContentRect.Bottom - this.FContentPadding.FBottom));
      this.FRealPlacement = LPlacement;
      this.UpdateBounds(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(LRect));
    };
    this.Loaded = function () {
      pas["WEBLib.Forms"].TCustomForm.Loaded.call(this);
      if (this.FPlacementChanged) this.ApplyPlacement();
    };
    this.Updated = function () {
      pas.Classes.TComponent.Updated.call(this);
      if (this.FPlacementChanged) this.ApplyPlacement();
    };
    this.HandleFocusedControl = function () {
      if (this.GetPopup() != null) this.GetPopup().HandleFocusedControl();
    };
    this.GetPopupParent = function () {
      var Result = null;
      Result = null;
      if ((this.FOwner$1 != null) && $mod.TTMSFNCCustomPopup.isPrototypeOf(this.FOwner$1)) Result = rtl.as(this.FOwner$1,$mod.TTMSFNCCustomPopup).GetParent();
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if (Operation === pas.Classes.TOperation.opRemove) {
        if (AComponent === this.FPlacementControl) {
          this.FPlacementControl = null;
          this.ApplyPlacement();
        };
        if (AComponent === this.FContentControl) this.FContentControl = null;
      };
    };
    this.DoRealPlacementChanged = function () {
      if (this.FOnRealPlacementChanged != null) this.FOnRealPlacementChanged(this);
    };
    this.CreateNew = function (AOwner, Dummy) {
      var $Self = this;
      function FindUniqueFormName(Name) {
        var Result = "";
        var I = 0;
        I = 0;
        Result = Name;
        while ((pas["WEBLib.Controls"].FindGlobalComponent(Result) !== null) || ((AOwner !== null) && (AOwner.FindComponent(Result) !== null))) {
          I += 1;
          Result = pas.SysUtils.Format("%s_%d",pas.System.VarRecs(18,Name,0,I));
        };
        return Result;
      };
      this.SetName(FindUniqueFormName("CustomPopupForm"));
      pas["WEBLib.Forms"].TCustomForm.CreateNew.apply(this,arguments);
      this.FPreferedDisplayIndex = -1;
      this.FOwner$1 = AOwner;
      this.FDragWithParent = true;
      this.FPlacementRectangle = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FContentPadding = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FSize.cx = 320;
      this.FSize.cy = 200;
      this.FPlacement = $mod.TTMSFNCPopupPlacement.ppBottom;
      this.FRealPlacement = this.FPlacement;
      this.SetVisible(false);
      try {
        this.SetBorder(pas["WEBLib.Forms"].TFormBorderStyle.fbNone);
        this.SetPosition(pas["WEBLib.Forms"].TPosition.poDesigned);
      } finally {
      };
      return this;
    };
    this.Create$8 = function (AOwner, APlacementControl) {
      this.CreateNew(AOwner,0);
      try {
        if (APlacementControl !== null) this.FPlacementControl = APlacementControl;
        if (this.FPlacementControl !== null) this.FPlacementControl.FreeNotification(this);
      } finally {
      };
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FTimer;
        }, set: function (v) {
          this.p.FTimer = v;
        }});
      if (this.FPlacementControl !== null) {
        this.FPlacementControl.RemoveFreeNotification(this);
        this.FPlacementControl = null;
      };
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FContentPadding;
        }, set: function (v) {
          this.p.FContentPadding = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FPlacementRectangle;
        }, set: function (v) {
          this.p.FPlacementRectangle = v;
        }});
      pas["WEBLib.Forms"].TCustomForm.Destroy.call(this);
    };
    this.ApplyPlacement = function () {
      var OldRect = pas.Types.TRect.$new();
      var NewRect = pas.Types.TRect.$new();
      var OldRealPlacement = 0;
      OldRect.$assign(pas.Types.Rect(this.GetLeft(),this.GetTop(),this.GetLeft() + this.GetWidth(),this.GetTop() + this.GetHeight()));
      OldRealPlacement = this.FRealPlacement;
      this.DoApplyPlacement();
      NewRect.$assign(pas.Types.Rect(this.GetLeft(),this.GetTop(),this.GetLeft() + this.GetWidth(),this.GetTop() + this.GetHeight()));
      if ((NewRect.Left !== OldRect.Left) || (NewRect.Top !== OldRect.Top) || (NewRect.Bottom !== OldRect.Bottom) || (NewRect.Right !== OldRect.Right) || (OldRealPlacement !== this.FRealPlacement)) this.DoRealPlacementChanged();
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      if (rtl.neSet(Shift,{})) return;
      var $tmp = Key.get();
      if (($tmp === 27) || ($tmp === 115)) this.Close();
    };
    this.CloseQuery = function () {
      var Result = false;
      Result = pas["WEBLib.Forms"].TCustomForm.CloseQuery.call(this);
      if (Result && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.DoBeforeClose();
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomPopup",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FCloseTime = 0;
      this.FCheckTime = false;
      this.FDestroyingPopup = false;
      this.FOwner$1 = null;
      this.FCustomOwner = null;
      this.FPlacementControl = null;
      this.FPopupForm = null;
      this.FStaysOpen = false;
      this.FPlacement = 0;
      this.FPlacementRectangle = null;
      this.FHorizontalOffset = 0.0;
      this.FVerticalOffset = 0.0;
      this.FDragWithParent = false;
      this.FModalResult = 0;
      this.FModal = false;
      this.FOnClosePopup = null;
      this.FOnPopup = null;
      this.FPopupFormSize = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      this.FContentControl = null;
      this.FDropDownHeight = 0.0;
      this.FDropDownWidth = 0.0;
      this.FFocusable = false;
      this.FFocusedControl = null;
      this.FOnPopupPaint = null;
      this.FOnPopupShown = null;
      this.FIsOpen = false;
      this.FFillColor = 0;
      this.FStrokeColor = 0;
      this.FTransparent = false;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FCustomOwner = undefined;
      this.FPlacementControl = undefined;
      this.FPopupForm = undefined;
      this.FPlacementRectangle = undefined;
      this.FOnClosePopup = undefined;
      this.FOnPopup = undefined;
      this.FPopupFormSize = undefined;
      this.FContentControl = undefined;
      this.FFocusedControl = undefined;
      this.FOnPopupPaint = undefined;
      this.FOnPopupShown = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetIsOpen = function (Value) {
      var b = false;
      if (this.FIsOpen !== Value) {
        b = false;
        b = (pas["WEBLib.Forms"].VSIDE != null);
        if (!b && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.FIsOpen = false;
          return;
        };
        if (Value) {
          this.DoCreatePopup(false)}
         else {
          if (this.HasPopupForm()) {
            this.FPopupForm.Close()}
           else this.FIsOpen = Value;
        };
      };
    };
    this.SetPlacementRectangle = function (Value) {
      this.FPlacementRectangle.Assign(Value);
    };
    this.SetModalResult = function (Value) {
      this.FModalResult = Value;
      if (this.FPopupForm != null) this.FPopupForm.SetModalResult(this.FModalResult);
    };
    this.SetPlacementControl = function (Value) {
      if (this.FPlacementControl !== Value) {
        if (this.FPlacementControl !== null) this.FPlacementControl.RemoveFreeNotification(this);
        this.FPlacementControl = Value;
        if (this.HasPopupForm()) this.FPopupForm.SetPlacementControl(this.FPlacementControl);
        if (this.FPlacementControl !== null) this.FPlacementControl.FreeNotification(this);
      };
    };
    this.SetPlacement = function (Value) {
      if (this.FPlacement !== Value) {
        this.FPlacement = Value;
        if (this.HasPopupForm()) this.FPopupForm.SetPlacement(this.FPlacement);
      };
    };
    this.SetDragWithParent = function (Value) {
      if (this.FDragWithParent !== Value) {
        this.FDragWithParent = Value;
        if (this.HasPopupForm()) this.FPopupForm.SetDragWithParent(this.FDragWithParent);
      };
    };
    this.BeforeShowProc = function (Sender) {
      this.FIsOpen = true;
      this.DoPopup();
    };
    this.BeforeCloseProc = function (Sender) {
      this.FIsOpen = false;
    };
    this.CloseProc = function (Sender, CloseAction) {
      this.ClosePopup();
    };
    this.ShowProc = function (Sender) {
      if ((this.FPopupForm != null) && this.FPopupForm.FShowModal) this.HandleFocusedControl();
      this.DoPopupShown();
    };
    this.DeactivateProc = function (Sender) {
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if ((this.FPopupForm != null) && !this.FPopupForm.FShowModal && !this.FStaysOpen) {
        this.FPopupForm.SetVisible(false);
        this.FPopupForm.Close();
        this.FCloseTime = $impl.GetTickCountX();
        this.FCheckTime = true;
      };
    };
    this.SetPopupFormSize = function (Value) {
      if ((this.FPopupFormSize.cx !== Value.cx) || (this.FPopupFormSize.cy !== Value.cy)) {
        this.FPopupFormSize.$assign(Value);
        this.UpdatePopupSize();
      };
    };
    this.UpdatePopupSize = function () {
      var LSize = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      if (this.FPopupForm !== null) {
        if (this.FPopupFormSize.cx > 0) {
          LSize.cx = this.FPopupFormSize.cx}
         else LSize.cx = this.FDropDownWidth;
        if (this.FPopupFormSize.cy > 0) {
          LSize.cy = this.FPopupFormSize.cy}
         else LSize.cy = this.FDropDownHeight;
        this.FPopupForm.SetSize(LSize);
      };
    };
    this.SetContentControl = function (Value) {
      if (Value === null) {
        if (this.FContentControl != null) this.FContentControl.SetVisible(true);
      };
      this.FContentControl = Value;
      if (this.FContentControl != null) {
        this.FContentControl.SetVisible(false);
        this.SetDropDownWidth(this.FContentControl.GetWidth());
        this.SetDropDownHeight(this.FContentControl.GetHeight());
      };
    };
    this.SetDropDownHeight = function (Value) {
      if (this.FDropDownHeight !== Value) {
        this.FDropDownHeight = Value;
        if (this.FPopupForm != null) this.FPopupForm.SetHeight(Math.round(Value));
      };
    };
    this.SetDropDownWidth = function (Value) {
      if (this.FDropDownWidth !== Value) {
        this.FDropDownWidth = Value;
        if (this.FPopupForm != null) this.FPopupForm.SetWidth(Math.round(Value));
      };
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = "https://download.tmssoftware.com/doc/tmsfncuipack/components/ttmsfncpopup";
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,9);
      return Result;
    };
    this.SetAdaptToStyle = function (Value) {
      var ia = null;
      var $ir = rtl.createIntfRefs();
      try {
        pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.SetAdaptToStyle.apply(this,arguments);
        if (this.FContentControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FContentControl,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle),{get: function () {
              return ia;
            }, set: function (v) {
              ia = v;
            }})) ia.SetAdaptToStyle(this.FAdaptToStyle);
        };
      } finally {
        $ir.free();
        rtl._Release(ia);
      };
    };
    this.ShowPopup = function (AModal) {
      if (AModal) {
        this.FModalResult = this.FPopupForm.ShowModal()}
       else {
        this.FPopupForm.Show$1();
        this.HandleFocusedControl();
      };
    };
    this.HandleFocusedControl = function () {
      var frm = null;
      if ((this.FPopupForm != null) && (this.FFocusedControl != null)) {
        if (!this.FPopupForm.FShowModal) {
          frm = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetParentForm(this.FFocusedControl);
          if ((frm != null) && (frm !== this.FPopupForm)) {
            frm.SetFocus();
          };
        };
        if (pas["WEBLib.Controls"].TControl.isPrototypeOf(this.FFocusedControl)) {
          if (rtl.as(this.FFocusedControl,pas["WEBLib.Controls"].TControl).CanFocus()) rtl.as(this.FFocusedControl,pas["WEBLib.Controls"].TControl).SetFocus();
        };
      };
    };
    this.FormPaint = function (Sender) {
      var g = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var fc = 0;
      var sc = 0;
      if (this.FPopupForm != null) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[this.FPopupForm.GetCanvas$1(),false]);
        try {
          if (g.BeginScene()) {
            if (this.FTransparent) {
              fc = 0xFFFFFE;
              sc = 0xFFFFFE;
            } else {
              fc = this.FFillColor;
              sc = this.FStrokeColor;
            };
            g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
            g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
            if (fc !== -1) {
              g.FFill.SetColor(fc)}
             else g.FFill.SetColor(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupFillColor);
            if (sc !== -1) {
              g.FStroke.SetColor(sc)}
             else g.FStroke.SetColor(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupStrokeColor);
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FPopupForm.GetWidth(),this.FPopupForm.GetHeight()));
            g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
            if (this.FOnPopupPaint != null) this.FOnPopupPaint(this,g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
            g.EndScene();
          };
        } finally {
          g = rtl.freeLoc(g);
        };
      };
    };
    this.DoPopupPaint = function (Sender, AGraphics, ARect) {
      if (this.FOnPopupPaint != null) this.FOnPopupPaint(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if (Operation === pas.Classes.TOperation.opRemove) {
        if (AComponent === this.FContentControl) this.FContentControl = null;
        if (AComponent === this.FFocusedControl) this.FFocusedControl = null;
        if (AComponent === this.FPopupForm) this.FPopupForm = null;
        if (AComponent === this.FPlacementControl) {
          this.FPlacementControl = null;
          if (this.HasPopupForm()) this.FPopupForm.SetPlacementControl(null);
        };
      };
    };
    this.MChanged = function (Sender) {
      if (this.FPopupForm !== null) this.FPopupForm.SetPlacementRectangle(this.FPlacementRectangle);
    };
    this.DoClosePopup = function () {
      if (this.FOnClosePopup != null) this.FOnClosePopup(this);
    };
    this.DoPopup = function () {
      if (this.FOnPopup != null) this.FOnPopup(this);
    };
    this.DoPopupShown = function () {
      if (this.FOnPopupShown != null) this.FOnPopupShown(this);
    };
    this.ClosePopup = function () {
      var p = null;
      if (!this.HasPopupForm() || this.FDestroyingPopup) return;
      this.FDestroyingPopup = true;
      if (this.FModal && (this.FModalResult === 0)) {
        this.SetModalResult(2);
        return;
      };
      this.FIsOpen = false;
      if (this.FContentControl != null) {
        p = this.GetParent();
        this.FContentControl.SetVisible(false);
        if ((p != null) && pas["WEBLib.Controls"].TWinControl.isPrototypeOf(p)) {
          this.FContentControl.SetParent(rtl.as(p,pas["WEBLib.Controls"].TWinControl))}
         else this.FContentControl.SetParent(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetParentForm(this));
      };
      if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (this.HasPopupForm()) {
          if ($mod.TTMSFNCNonFocusablePopup.isPrototypeOf(this)) rtl.free(this,"FPopupForm");
          this.DoClosePopup();
          this.FPopupForm = null;
        };
      };
      this.FDestroyingPopup = false;
    };
    this.DoCreatePopup = function (AShowModal) {
      var ia = null;
      var $ir = rtl.createIntfRefs();
      try {
        if ((($impl.GetTickCountX() - this.FCloseTime) < 200) && this.FCheckTime) {
          this.FCheckTime = false;
          return;
        };
        if (this.FIsOpen) return;
        if (this.HasPopupForm()) this.FPopupForm.Close();
        this.FPopupForm = this.CreatePopupForm();
        try {
          try {
            this.FPopupForm.SetFormStyle(pas["WEBLib.Forms"].TFormStyle.fsStayOnTop);
            this.FPopupForm.FOnPaint = rtl.createCallback(this,"FormPaint");
            this.FPopupForm.FOnPopupPaint = rtl.createCallback(this,"DoPopupPaint");
            this.FPopupForm.FreeNotification(this);
            this.FPopupForm.SetPlacement(this.FPlacement);
            this.FPopupForm.SetOffset(pas["WEBLib.TMSFNCTypes"].PointF(this.FHorizontalOffset,this.FVerticalOffset));
            this.FPopupForm.SetPlacementRectangle(this.FPlacementRectangle);
            this.FPopupForm.SetDragWithParent(this.FDragWithParent);
            this.UpdatePopupSize();
            this.FPopupForm.FOnDeactivate = rtl.createCallback(this,"DeactivateProc");
            this.FPopupForm.FOnBeforeShow = rtl.createCallback(this,"BeforeShowProc");
            this.FPopupForm.FOnBeforeClose = rtl.createCallback(this,"BeforeCloseProc");
            this.FPopupForm.FOnClose = rtl.createCallback(this,"CloseProc");
            this.FPopupForm.FOnShow = rtl.createCallback(this,"ShowProc");
            this.FPopupForm.FShowModal = AShowModal;
            this.FPopupForm.SetContentControl(this.FContentControl);
            if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FContentControl,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle),{get: function () {
                return ia;
              }, set: function (v) {
                ia = v;
              }})) ia.SetAdaptToStyle(this.FAdaptToStyle);
            if (this.FContentControl != null) this.FContentControl.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
          } finally {
          };
        } catch ($e) {
          pas.SysUtils.FreeAndNil({p: this, get: function () {
              return this.p.FPopupForm;
            }, set: function (v) {
              this.p.FPopupForm = v;
            }});
          throw $e;
        };
        if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.FPopupForm.DoBeforeShow();
        this.ShowPopup(AShowModal);
        if (this.FOnPopupPaint != null) this.FPopupForm.Paint();
      } finally {
        $ir.free();
        rtl._Release(ia);
      };
    };
    this.DestroyPopupForm = function () {
      if (this.FPopupForm != null) rtl.free(this,"FPopupForm");
    };
    this.GetPopupFormClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCCustomPopupForm;
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = this.FPlacementControl;
      if (!(Result != null) && pas["WEBLib.Controls"].TControl.isPrototypeOf(this.FOwner$1)) Result = rtl.as(this.FOwner$1,pas["WEBLib.Controls"].TControl);
      return Result;
    };
    this.CreatePopupForm = function () {
      var Result = null;
      var NewForm = null;
      var cls = null;
      NewForm = null;
      try {
        cls = this.GetPopupFormClass();
        NewForm = cls.$create("Create$8",[this,this.FPlacementControl]);
      } catch ($e) {
        pas.SysUtils.FreeAndNil({get: function () {
            return NewForm;
          }, set: function (v) {
            NewForm = v;
          }});
        throw $e;
      };
      Result = NewForm;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.call(this,AOwner);
      this.FOwner$1 = AOwner;
      this.FPlacement = $mod.TTMSFNCPopupPlacement.ppBottom;
      this.FFocusable = true;
      this.FStaysOpen = false;
      this.FPlacementRectangle = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FPlacementRectangle.FOnChange = rtl.createCallback(this,"MChanged");
      this.FFillColor = -1;
      this.FStrokeColor = -1;
      this.FTransparent = false;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomPopup.isPrototypeOf(Source)) {
        this.FModalResult = rtl.as(Source,$mod.TTMSFNCCustomPopup).FModalResult;
        this.FPopupFormSize.$assign(rtl.as(Source,$mod.TTMSFNCCustomPopup).FPopupFormSize);
        this.FDragWithParent = rtl.as(Source,$mod.TTMSFNCCustomPopup).FDragWithParent;
        this.FStaysOpen = rtl.as(Source,$mod.TTMSFNCCustomPopup).FStaysOpen;
        this.FDropDownHeight = rtl.as(Source,$mod.TTMSFNCCustomPopup).FDropDownHeight;
        this.FDropDownWidth = rtl.as(Source,$mod.TTMSFNCCustomPopup).FDropDownWidth;
        this.FHorizontalOffset = rtl.as(Source,$mod.TTMSFNCCustomPopup).FHorizontalOffset;
        this.FPlacementControl = rtl.as(Source,$mod.TTMSFNCCustomPopup).FPlacementControl;
        this.FPlacement = rtl.as(Source,$mod.TTMSFNCCustomPopup).FPlacement;
        this.FPlacementRectangle.Assign(rtl.as(Source,$mod.TTMSFNCCustomPopup).FPlacementRectangle);
        this.FVerticalOffset = rtl.as(Source,$mod.TTMSFNCCustomPopup).FVerticalOffset;
        this.FFocusedControl = rtl.as(Source,$mod.TTMSFNCCustomPopup).FFocusedControl;
        this.FContentControl = rtl.as(Source,$mod.TTMSFNCCustomPopup).FContentControl;
      };
    };
    this.Destroy = function () {
      this.FContentControl = null;
      this.ClosePopup();
      if (this.HasPopupForm()) {
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.FPopupForm;
          }, set: function (v) {
            this.p.FPopupForm = v;
          }});
      };
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FPlacementRectangle;
        }, set: function (v) {
          this.p.FPlacementRectangle = v;
        }});
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.HasPopupForm = function () {
      var Result = false;
      Result = this.FPopupForm !== null;
      return Result;
    };
    this.PointInPopup = function (APoint) {
      var Result = false;
      Result = false;
      if (this.FPopupForm != null) Result = pas["WEBLib.TMSFNCTypes"].PtInRectEx(pas["WEBLib.TMSFNCTypes"].RectF(this.FPopupForm.GetLeft(),this.FPopupForm.GetTop(),this.FPopupForm.GetLeft() + this.FPopupForm.GetWidth(),this.FPopupForm.GetTop() + this.FPopupForm.GetHeight()),APoint);
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCPopup",this.TTMSFNCCustomPopup,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCPopup);
    };
    this.PopupModal = function () {
      var Result = 0;
      var LStaysOpen = false;
      Result = 0;
      if (this.FIsOpen) return Result;
      if (this.HasPopupForm()) this.FPopupForm.Close();
      LStaysOpen = this.FStaysOpen;
      try {
        this.FStaysOpen = true;
        this.Popup(true);
        Result = this.FModalResult;
        this.SetIsOpen(false);
      } finally {
        this.FStaysOpen = LStaysOpen;
      };
      return Result;
    };
    this.Popup = function (AShowModal) {
      this.DoCreatePopup(AShowModal);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("StaysOpen",0,rtl.boolean,"FStaysOpen","FStaysOpen",4,{Default: false});
    $r.addProperty("DropDownHeight",2,rtl.double,"FDropDownHeight","SetDropDownHeight");
    $r.addProperty("DropDownWidth",2,rtl.double,"FDropDownWidth","SetDropDownWidth");
    $r.addProperty("HorizontalOffset",0,rtl.double,"FHorizontalOffset","FHorizontalOffset");
    $r.addProperty("Placement",2,$mod.$rtti["TTMSFNCPopupPlacement"],"FPlacement","SetPlacement",4,{Default: $mod.TTMSFNCPopupPlacement.ppBottom});
    $r.addProperty("PlacementRectangle",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FPlacementRectangle","SetPlacementRectangle");
    $r.addProperty("PlacementControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FPlacementControl","SetPlacementControl");
    $r.addProperty("VerticalOffset",0,rtl.double,"FVerticalOffset","FVerticalOffset");
    $r.addProperty("FocusedControl",0,pas["WEBLib.Controls"].$rtti["TControl"],"FFocusedControl","FFocusedControl");
    $r.addProperty("ContentControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FContentControl","SetContentControl");
    $r.addProperty("OnClosePopup",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClosePopup","FOnClosePopup");
    $r.addProperty("OnPopupPaint",0,$mod.$rtti["TTMSFNCPopupPaint"],"FOnPopupPaint","FOnPopupPaint");
    $r.addProperty("OnPopup",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPopup","FOnPopup");
    $r.addProperty("OnPopupShown",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPopupShown","FOnPopupShown");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCCustomNonFocusablePopupForm",this.TTMSFNCCustomPopupForm,function () {
    this.UpdateBounds = function (LRect) {
      $mod.TTMSFNCCustomPopupForm.UpdateBounds.apply(this,arguments);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomNonFocusablePopup",this.TTMSFNCCustomPopup,function () {
    this.ActivatePreviousWindow = function () {
    };
    this.ShowPopup = function (AModal) {
      $mod.TTMSFNCCustomPopup.ShowPopup.apply(this,arguments);
      this.FIsOpen = true;
    };
    this.GetPopupFormClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCCustomNonFocusablePopupForm;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomPopup.Create$1.apply(this,arguments);
      this.FStaysOpen = true;
      return this;
    };
    this.Destroy = function () {
      $mod.TTMSFNCCustomPopup.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCNonFocusablePopup",this.TTMSFNCCustomNonFocusablePopup,function () {
    this.Deactivate = function () {
      this.ClosePopup();
    };
    this.Activate = function () {
      this.DoCreatePopup(false);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("ContentControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FContentControl","SetContentControl");
    $r.addProperty("Placement",2,$mod.$rtti["TTMSFNCPopupPlacement"],"FPlacement","SetPlacement",4,{Default: $mod.TTMSFNCPopupPlacement.ppBottom});
    $r.addProperty("PlacementRectangle",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FPlacementRectangle","SetPlacementRectangle");
    $r.addProperty("PlacementControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FPlacementControl","SetPlacementControl");
  });
  $mod.$implcode = function () {
    $impl.GetTickCountX = function () {
      var Result = 0;
      var h = 0;
      var m = 0;
      var s = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(pas.SysUtils.Now(),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }},{get: function () {
          return m;
        }, set: function (v) {
          m = v;
        }},{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = ms + (s * 1000) + (m * 60 * 1000) + (h * 60 * 60 * 1000);
      return Result;
    };
    rtl.createClass($impl,"TDPIControlProtected",pas["WEBLib.Controls"].TControl,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
},["SysUtils","WEBLib.TMSFNCUtils","Math","WEBLib.TMSFNCStyles"]);
rtl.module("WEBLib.TMSFNCImage",["System","Classes","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 1;
  rtl.createClass(this,"TTMSFNCCustomImage",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FBitmap = null;
      this.FBitmapContainer = null;
      this.FStretch = false;
      this.FBitmaps = null;
      this.FCropping = false;
      this.FCenter$1 = false;
      this.FAutoSize = false;
      this.FAspectRatio = false;
      this.FOnBitmapChanged = null;
      this.FBitmapMargins = null;
      this.FDottedDesigntimeRectangle = false;
    };
    this.$final = function () {
      this.FBitmap = undefined;
      this.FBitmapContainer = undefined;
      this.FBitmaps = undefined;
      this.FOnBitmapChanged = undefined;
      this.FBitmapMargins = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
      this.ApplyAutoSize();
      this.Invalidate();
    };
    this.SetBitmaps = function (Value) {
      this.FBitmaps.Assign(Value);
      this.Invalidate();
    };
    this.SetBitmap = function (Value) {
      this.FBitmap.Assign(Value);
      this.Invalidate();
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetBitmapMargins = function (Value) {
      this.FBitmapMargins.Assign(Value);
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,1);
      return Result;
    };
    this.ApplyAutoSize = function () {
      var bmp = null;
      bmp = this.GetBitmap();
      if (bmp != null) {
        if (this.FAutoSize && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
          this.SetWidth(Math.round(bmp.GetWidth() + this.FBitmapMargins.FLeft + this.FBitmapMargins.FRight));
          this.SetHeight(Math.round(bmp.GetHeight() + this.FBitmapMargins.FTop + this.FBitmapMargins.FBottom));
        };
      };
    };
    this.BitmapMarginsChanged = function (Sender) {
      this.ApplyAutoSize();
      this.Invalidate();
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
    };
    this.BitmapChanged = function (Sender) {
      if (this.FOnBitmapChanged != null) this.FOnBitmapChanged(this);
      this.ApplyAutoSize();
      this.Invalidate();
    };
    this.SetStretch = function (Value) {
      this.FStretch = Value;
      this.Invalidate();
    };
    this.SetCropping = function (Value) {
      this.FCropping = Value;
      this.Invalidate();
    };
    this.SetCenter = function (Value) {
      this.FCenter$1 = Value;
      this.Invalidate();
    };
    this.SetAS = function (Value) {
      this.FAutoSize = Value;
      this.ApplyAutoSize();
      this.Invalidate();
    };
    this.SetAspectRatio = function (Value) {
      this.FAspectRatio = Value;
      this.Invalidate();
    };
    this.Clear = function () {
      this.FBitmaps.Clear();
    };
    this.GetPaintRectangle = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmp = null;
      var rdest = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var w = 0.0;
      var h = 0.0;
      var x = 0.0;
      var y = 0.0;
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      bmp = this.GetBitmap();
      if (bmp != null) {
        x = this.FBitmapMargins.FLeft;
        y = this.FBitmapMargins.FTop;
        w = 0;
        h = 0;
        pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetAspectSize({get: function () {
            return w;
          }, set: function (v) {
            w = v;
          }},{get: function () {
            return h;
          }, set: function (v) {
            h = v;
          }},bmp.GetWidth(),bmp.GetHeight(),this.GetWidth() - this.FBitmapMargins.FLeft - this.FBitmapMargins.FRight,this.GetHeight() - this.FBitmapMargins.FTop - this.FBitmapMargins.FBottom,this.FAspectRatio,this.FStretch,this.FCropping);
        if (this.FCenter$1 || this.FCropping) {
          x = (this.GetWidth() - w) / 2;
          y = (this.GetHeight() - h) / 2;
        };
        rdest.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,y,x + w,y + h));
        Result.$assign(rdest);
      };
      return Result;
    };
    this.GetBitmap = function () {
      var Result = null;
      if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FBitmap)) {
        Result = this.FBitmap}
       else Result = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FBitmaps,0,this.FBitmapContainer);
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FDottedDesigntimeRectangle = true;
      if (this.IsDesignTime()) this.DisableBackground();
      this.FBitmapMargins = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FBitmapMargins.FOnChange = rtl.createCallback(this,"BitmapMarginsChanged");
      this.FCenter$1 = true;
      this.FStretch = false;
      this.FAspectRatio = true;
      this.FCropping = false;
      this.FBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FBitmaps.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.SetWidth(100);
      this.SetHeight(100);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      rtl.free(this,"FBitmaps");
      rtl.free(this,"FBitmapMargins");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Draw = function (AGraphics, ARect) {
      var bmp = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && this.FDottedDesigntimeRectangle) {
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDot);
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      };
      bmp = this.GetBitmap();
      if (bmp != null) {
        ARect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left + this.FBitmapMargins.FLeft,ARect.Top + this.FBitmapMargins.FTop,ARect.Right - this.FBitmapMargins.FRight,ARect.Bottom - this.FBitmapMargins.FBottom));
        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),bmp,this.FAspectRatio,this.FStretch,this.FCenter$1,this.FCropping);
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCImage",this.TTMSFNCCustomImage,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCImage);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AspectRatio",2,rtl.boolean,"FAspectRatio","SetAspectRatio",4,{Default: true});
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapMargins",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FBitmapMargins","SetBitmapMargins");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("Bitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FBitmaps","SetBitmaps");
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("Stretch",2,rtl.boolean,"FStretch","SetStretch",4,{Default: false});
    $r.addProperty("Cropping",2,rtl.boolean,"FCropping","SetCropping",4,{Default: false});
    $r.addProperty("Center",2,rtl.boolean,"FCenter$1","SetCenter",4,{Default: true});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAS",4,{Default: false});
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["WEBLib.Controls","WEBLib.Graphics","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCCustomTreeView",["System","Classes","SysUtils","WEBLib.TMSFNCTreeViewData","WEBLib.TMSFNCCustomComponent","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCPopup","WEBLib.TMSFNCImage","Types","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.ExtCtrls","WEBLib.StdCtrls","WEBLib.TMSFNCGraphicsTypes","contnrs","Web","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TTMSFNCTreeViewDocURL = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/ttmsfnctreeview/";
  this.MAJ_VER = 1;
  this.MIN_VER = 2;
  this.REL_VER = 2;
  this.BLD_VER = 6;
  this.CLP_FMT = "#TREEVIEW#";
  this.ENDOFLINE = "\r\n";
  this.DRAGMARGIN = 10;
  this.CACHEWIDTH = 1000;
  this.CACHEHEIGHT = 1000;
  this.SCROLLINGDELAY = 0;
  this.TTMSFNCTreeViewColorExtended = 0xF4F4F4;
  this.TTMSFNCTreeViewColorSelection = 0xF8AD1B;
  this.$rtti.$Class("TTMSFNCCustomTreeView");
  rtl.createClass(this,"TTMSFNCTreeViewCache",pas.contnrs.TObjectList,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewNodeCache",this.TTMSFNCTreeViewCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsCache",this.TTMSFNCTreeViewCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsTopCache",this.TTMSFNCTreeViewColumnsCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsBottomCache",this.TTMSFNCTreeViewColumnsCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroupsCache",this.TTMSFNCTreeViewCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroupsTopCache",this.TTMSFNCTreeViewGroupsCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroupsBottomCache",this.TTMSFNCTreeViewGroupsCache,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewDisplayList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCTreeViewNodeDisplayList",this.TTMSFNCTreeViewDisplayList,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsDisplayList",this.TTMSFNCTreeViewDisplayList,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsTopDisplayList",this.TTMSFNCTreeViewColumnsDisplayList,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsBottomDisplayList",this.TTMSFNCTreeViewColumnsDisplayList,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroupsDisplayList",this.TTMSFNCTreeViewDisplayList,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroupsTopDisplayList",this.TTMSFNCTreeViewGroupsDisplayList,function () {
  });
  rtl.createClass(this,"TTMSFNCTreeViewGroupsBottomDisplayList",this.TTMSFNCTreeViewGroupsDisplayList,function () {
  });
  this.TTMSFNCTreeViewColumnsLayout = {"0": "tclTop", tclTop: 0, "1": "tclBottom", tclBottom: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewColumnsLayout",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewColumnsLayout});
  this.$rtti.$Set("TTMSFNCTreeViewColumnsLayouts",{comptype: this.$rtti["TTMSFNCTreeViewColumnsLayout"]});
  this.TTMSFNCTreeViewGroupLayout = {"0": "tglTop", tglTop: 0, "1": "tglBottom", tglBottom: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewGroupLayout",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewGroupLayout});
  this.$rtti.$Set("TTMSFNCTreeViewGroupsLayouts",{comptype: this.$rtti["TTMSFNCTreeViewGroupLayout"]});
  this.TTMSFNCTreeViewNodeHeightMode = {"0": "tnhmFixed", tnhmFixed: 0, "1": "tnhmVariable", tnhmVariable: 1};
  this.$rtti.$Enum("TTMSFNCTreeViewNodeHeightMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTreeViewNodeHeightMode});
  this.TTMSFNCTreeViewSelectionArea = {"0": "tsaDefault", tsaDefault: 0, "1": "tsaFull", tsaFull: 1, "2": "tsaFromLevel", tsaFromLevel: 2, "3": "tsaFromText", tsaFromText: 3};
  this.$rtti.$Enum("TTMSFNCTreeViewSelectionArea",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCTreeViewSelectionArea});
  rtl.createClass(this,"TTMSFNCTreeViewNodesAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FTreeView = null;
      this.FFill = null;
      this.FStroke = null;
      this.FFont = null;
      this.FDisabledFill = null;
      this.FSelectedFill = null;
      this.FDisabledStroke = null;
      this.FSelectedStroke = null;
      this.FSelectionArea = 0;
      this.FExpandColumn = 0;
      this.FExpandWidth = 0.0;
      this.FExpandHeight = 0.0;
      this.FLevelIndent = 0.0;
      this.FHeightMode = 0;
      this.FFixedHeight = 0.0;
      this.FVariableMinimumHeight = 0.0;
      this.FSelectedFontColor = 0;
      this.FDisabledFontColor = 0;
      this.FExtendedFontColor = 0;
      this.FExtendedSelectedFontColor = 0;
      this.FExtendedDisabledFontColor = 0;
      this.FExtendedDisabledFill = null;
      this.FExtendedFont = null;
      this.FExtendedSelectedFill = null;
      this.FExtendedDisabledStroke = null;
      this.FExtendedSelectedStroke = null;
      this.FExtendedFill = null;
      this.FExtendedStroke = null;
      this.FShowLines = false;
      this.FExpandNodeIcon = null;
      this.FCollapseNodeIcon = null;
      this.FExpandNodeIconLarge = null;
      this.FCollapseNodeIconLarge = null;
      this.FColumnStroke = null;
      this.FLineStroke = null;
      this.FShowFocus = false;
      this.FSpacing = 0.0;
      this.FDisabledTitleFontColor = 0;
      this.FSelectedTitleFontColor = 0;
      this.FTitleFont = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FFont = undefined;
      this.FDisabledFill = undefined;
      this.FSelectedFill = undefined;
      this.FDisabledStroke = undefined;
      this.FSelectedStroke = undefined;
      this.FExtendedDisabledFill = undefined;
      this.FExtendedFont = undefined;
      this.FExtendedSelectedFill = undefined;
      this.FExtendedDisabledStroke = undefined;
      this.FExtendedSelectedStroke = undefined;
      this.FExtendedFill = undefined;
      this.FExtendedStroke = undefined;
      this.FExpandNodeIcon = undefined;
      this.FCollapseNodeIcon = undefined;
      this.FExpandNodeIconLarge = undefined;
      this.FCollapseNodeIconLarge = undefined;
      this.FColumnStroke = undefined;
      this.FLineStroke = undefined;
      this.FTitleFont = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      if (this.FFill !== Value) this.FFill.Assign(Value);
    };
    this.SetStroke = function (Value) {
      if (this.FStroke !== Value) this.FStroke.Assign(Value);
    };
    this.SetFont = function (Value) {
      if (this.FFont !== Value) this.FFont.Assign(Value);
    };
    this.SetDisabledFill = function (Value) {
      if (this.FDisabledFill !== Value) this.FDisabledFill.Assign(Value);
    };
    this.SetDisabledStroke = function (Value) {
      if (this.FDisabledStroke !== Value) this.FDisabledStroke.Assign(Value);
    };
    this.SetSelectedFill = function (Value) {
      if (this.FSelectedFill !== Value) this.FSelectedFill.Assign(Value);
    };
    this.SetSelectedStroke = function (Value) {
      if (this.FSelectedStroke !== Value) this.FSelectedStroke.Assign(Value);
    };
    this.SetSelectionArea = function (Value) {
      if (this.FSelectionArea !== Value) {
        this.FSelectionArea = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.SetExtendedFill = function (Value) {
      if (this.FExtendedFill !== Value) this.FExtendedFill.Assign(Value);
    };
    this.SetExtendedStroke = function (Value) {
      if (this.FExtendedStroke !== Value) this.FExtendedStroke.Assign(Value);
    };
    this.SetExtendedFont = function (Value) {
      if (this.FExtendedFont !== Value) this.FExtendedFont.Assign(Value);
    };
    this.SetExtendedDisabledFill = function (Value) {
      if (this.FExtendedDisabledFill !== Value) this.FExtendedDisabledFill.Assign(Value);
    };
    this.SetExtendedDisabledStroke = function (Value) {
      if (this.FExtendedDisabledStroke !== Value) this.FExtendedDisabledStroke.Assign(Value);
    };
    this.SetExtendedSelectedFill = function (Value) {
      if (this.FExtendedSelectedFill !== Value) this.FExtendedSelectedFill.Assign(Value);
    };
    this.SetExtendedSelectedStroke = function (Value) {
      if (this.FExtendedSelectedStroke !== Value) this.FExtendedSelectedStroke.Assign(Value);
    };
    this.SetExpandColumn = function (Value) {
      if (this.FExpandColumn !== Value) {
        this.FExpandColumn = Value;
        this.Changed(this);
      };
    };
    this.SetExpandWidth = function (Value) {
      if (this.FExpandWidth !== Value) {
        this.FExpandWidth = Value;
        this.Changed(this);
      };
    };
    this.SetExpandHeight = function (Value) {
      if (this.FExpandHeight !== Value) {
        this.FExpandHeight = Value;
        this.Changed(this);
      };
    };
    this.SetLevelIndent = function (Value) {
      if (this.FLevelIndent !== Value) {
        this.FLevelIndent = Value;
        this.Changed(this);
      };
    };
    this.SetFixedHeight = function (Value) {
      if (this.FFixedHeight !== Value) {
        this.FFixedHeight = Value;
        this.Changed(this);
      };
    };
    this.SetVariableMinimumHeight = function (Value) {
      if (this.FVariableMinimumHeight !== Value) {
        this.FVariableMinimumHeight = Value;
        this.Changed(this);
      };
    };
    this.SetSelectedFontColor = function (Value) {
      if (this.FSelectedFontColor !== Value) {
        this.FSelectedFontColor = Value;
        this.Changed(this);
      };
    };
    this.SetDisabledFontColor = function (Value) {
      if (this.FDisabledFontColor !== Value) {
        this.FDisabledFontColor = Value;
        this.Changed(this);
      };
    };
    this.SetExtendedFontColor = function (Value) {
      if (this.FExtendedFontColor !== Value) {
        this.FExtendedFontColor = Value;
        this.Changed(this);
      };
    };
    this.SetExtendedSelectedFontColor = function (Value) {
      if (this.FExtendedSelectedFontColor !== Value) {
        this.FExtendedSelectedFontColor = Value;
        this.Changed(this);
      };
    };
    this.SetExtendedDisabledFontColor = function (Value) {
      if (this.FExtendedDisabledFontColor !== Value) {
        this.FExtendedDisabledFontColor = Value;
        this.Changed(this);
      };
    };
    this.SetHeightMode = function (Value) {
      if (this.FHeightMode !== Value) {
        this.FHeightMode = Value;
        this.Changed(this);
      };
    };
    this.SetShowLines = function (Value) {
      if (this.FShowLines !== Value) {
        this.FShowLines = Value;
        this.Changed(this);
      };
    };
    this.SetCollapseNodeIcon = function (Value) {
      if (this.FCollapseNodeIcon !== Value) {
        this.FCollapseNodeIcon.Assign(Value);
        this.Changed(this);
      };
    };
    this.SetExpandNodeIcon = function (Value) {
      if (this.FExpandNodeIcon !== Value) {
        this.FExpandNodeIcon.Assign(Value);
        this.Changed(this);
      };
    };
    this.SetCollapseNodeIconLarge = function (Value) {
      if (this.FCollapseNodeIconLarge !== Value) {
        this.FCollapseNodeIconLarge.Assign(Value);
        this.Changed(this);
      };
    };
    this.SetExpandNodeIconLarge = function (Value) {
      if (this.FExpandNodeIconLarge !== Value) {
        this.FExpandNodeIconLarge.Assign(Value);
        this.Changed(this);
      };
    };
    this.SetColumnStroke = function (Value) {
      if (this.FColumnStroke !== Value) this.FColumnStroke.Assign(Value);
    };
    this.SetLineStroke = function (Value) {
      if (this.FLineStroke !== Value) this.FLineStroke.Assign(Value);
    };
    this.SetShowFocus = function (Value) {
      if (this.FShowFocus !== Value) {
        this.FShowFocus = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.IsSpacingStored = function () {
      var Result = false;
      Result = this.FSpacing !== 0;
      return Result;
    };
    this.SetSpacing = function (Value) {
      if (this.FSpacing !== Value) {
        this.FSpacing = Value;
        this.Changed(this);
      };
    };
    this.SetDisabledTitleFontColor = function (Value) {
      if (this.FDisabledTitleFontColor !== Value) {
        this.FDisabledTitleFontColor = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.SetSelectedTitleFontColor = function (Value) {
      if (this.FSelectedTitleFontColor !== Value) {
        this.FSelectedTitleFontColor = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.SetTitleFont = function (Value) {
      if (this.FTitleFont !== Value) this.FTitleFont.Assign(Value);
    };
    this.Changed = function (Sender) {
      this.FTreeView.UpdateTreeViewCache();
    };
    this.BitmapChanged = function (Sender) {
      this.FTreeView.UpdateTreeViewCache();
    };
    this.Create$1 = function (ATreeView) {
      this.FTreeView = ATreeView;
      this.FShowFocus = true;
      this.FSelectionArea = $mod.TTMSFNCTreeViewSelectionArea.tsaFromText;
      this.FExpandColumn = 0;
      this.FExpandWidth = 15;
      this.FExpandHeight = 15;
      this.FFixedHeight = 25;
      this.FVariableMinimumHeight = 25;
      this.FShowLines = true;
      this.FHeightMode = $mod.TTMSFNCTreeViewNodeHeightMode.tnhmFixed;
      this.FLevelIndent = 20;
      this.FSpacing = 0;
      this.FSelectedFontColor = 16777215;
      this.FDisabledFontColor = 12632256;
      this.FSelectedTitleFontColor = 16777215;
      this.FDisabledTitleFontColor = 12632256;
      this.FExtendedFontColor = 0;
      this.FExtendedSelectedFontColor = 16777215;
      this.FExtendedDisabledFontColor = 12632256;
      this.FColumnStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,-1,1.0]);
      this.FLineStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDot,11119017,1.0]);
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,-1,8421504,-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone,11119017,1.0]);
      this.FSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16297243,8421504,-1,-1]);
      this.FSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,16297243,1.0]);
      this.FDisabledFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,11119017,8421504,-1,-1]);
      this.FDisabledStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone,11119017,1.0]);
      this.FExtendedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16053492,8421504,-1,-1]);
      this.FExtendedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FExtendedSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16297243,8421504,-1,-1]);
      this.FExtendedSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone,11119017,1.0]);
      this.FExtendedDisabledFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,11119017,8421504,-1,-1]);
      this.FExtendedDisabledStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone,11119017,1.0]);
      this.FExpandNodeIcon = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource$1($mod.TTMSFNCTREEVIEWEXPAND,pas["WEBLib.TMSFNCTypes"].HInstance());
      this.FExpandNodeIcon.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FCollapseNodeIcon = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource$1($mod.TTMSFNCTREEVIEWCOLLAPSE,pas["WEBLib.TMSFNCTypes"].HInstance());
      this.FCollapseNodeIcon.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FExpandNodeIconLarge = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource$1($mod.TTMSFNCTREEVIEWEXPANDLARGE,pas["WEBLib.TMSFNCTypes"].HInstance());
      this.FExpandNodeIconLarge.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FCollapseNodeIconLarge = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource$1($mod.TTMSFNCTREEVIEWCOLLAPSELARGE,pas["WEBLib.TMSFNCTypes"].HInstance());
      this.FCollapseNodeIconLarge.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      if ((this.FTreeView != null) && this.FTreeView.IsDesignTime()) this.FFont.SetColor(0);
      this.FTitleFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      if ((this.FTreeView != null) && this.FTreeView.IsDesignTime()) this.FTitleFont.SetColor(0);
      this.FFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FSelectedFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FSelectedStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FDisabledFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FDisabledStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FExtendedFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedSelectedFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedSelectedStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedDisabledFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedDisabledStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FFont.FOnChanged = rtl.createCallback(this,"Changed");
      this.FExtendedFont.FOnChanged = rtl.createCallback(this,"Changed");
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewNodesAppearance.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FStroke);
        this.FFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FFont);
        this.FTitleFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FTitleFont);
        this.FSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FSelectedFill);
        this.FSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FSelectedStroke);
        this.FDisabledFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FDisabledFill);
        this.FDisabledStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FDisabledStroke);
        this.FExtendedFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedFill);
        this.FExtendedStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedStroke);
        this.FExtendedFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedFont);
        this.FExtendedSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedSelectedFill);
        this.FExtendedSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedSelectedStroke);
        this.FExtendedDisabledFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedDisabledFill);
        this.FExtendedDisabledStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedDisabledStroke);
        this.FExpandColumn = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExpandColumn;
        this.FExpandWidth = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExpandWidth;
        this.FExpandHeight = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExpandHeight;
        this.FFixedHeight = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FFixedHeight;
        this.FVariableMinimumHeight = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FVariableMinimumHeight;
        this.FSelectedFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FSelectedFontColor;
        this.FDisabledFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FDisabledFontColor;
        this.FSelectedTitleFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FSelectedTitleFontColor;
        this.FDisabledTitleFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FDisabledTitleFontColor;
        this.FExtendedFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedFontColor;
        this.FExtendedSelectedFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedSelectedFontColor;
        this.FExtendedDisabledFontColor = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FExtendedDisabledFontColor;
        this.FLevelIndent = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FLevelIndent;
        this.FSpacing = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FSpacing;
        this.FHeightMode = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FHeightMode;
        this.FShowLines = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FShowLines;
        this.FShowFocus = rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FShowFocus;
        this.FColumnStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FColumnStroke);
        this.FLineStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewNodesAppearance).FLineStroke);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FLineStroke");
      rtl.free(this,"FColumnStroke");
      rtl.free(this,"FExpandNodeIconLarge");
      rtl.free(this,"FCollapseNodeIconLarge");
      rtl.free(this,"FExpandNodeIcon");
      rtl.free(this,"FCollapseNodeIcon");
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FFont");
      rtl.free(this,"FTitleFont");
      rtl.free(this,"FSelectedFill");
      rtl.free(this,"FSelectedStroke");
      rtl.free(this,"FDisabledFill");
      rtl.free(this,"FDisabledStroke");
      rtl.free(this,"FExtendedFill");
      rtl.free(this,"FExtendedStroke");
      rtl.free(this,"FExtendedFont");
      rtl.free(this,"FExtendedSelectedFill");
      rtl.free(this,"FExtendedSelectedStroke");
      rtl.free(this,"FExtendedDisabledFill");
      rtl.free(this,"FExtendedDisabledStroke");
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: true});
    $r.addProperty("ExpandColumn",2,rtl.longint,"FExpandColumn","SetExpandColumn",4,{Default: 0});
    $r.addProperty("ExpandWidth",2,rtl.double,"FExpandWidth","SetExpandWidth");
    $r.addProperty("ExpandHeight",2,rtl.double,"FExpandHeight","SetExpandHeight");
    $r.addProperty("LevelIndent",2,rtl.double,"FLevelIndent","SetLevelIndent");
    $r.addProperty("Spacing",14,rtl.double,"FSpacing","SetSpacing",4,{stored: "IsSpacingStored"});
    $r.addProperty("FixedHeight",2,rtl.double,"FFixedHeight","SetFixedHeight");
    $r.addProperty("VariableMinimumHeight",2,rtl.double,"FVariableMinimumHeight","SetVariableMinimumHeight");
    $r.addProperty("HeightMode",2,$mod.$rtti["TTMSFNCTreeViewNodeHeightMode"],"FHeightMode","SetHeightMode",4,{Default: $mod.TTMSFNCTreeViewNodeHeightMode.tnhmFixed});
    $r.addProperty("ShowLines",2,rtl.boolean,"FShowLines","SetShowLines",4,{Default: true});
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("ColumnStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FColumnStroke","SetColumnStroke");
    $r.addProperty("LineStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FLineStroke","SetLineStroke");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
    $r.addProperty("TitleFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FTitleFont","SetTitleFont");
    $r.addProperty("SelectedFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedFontColor","SetSelectedFontColor",4,{Default: 16777215});
    $r.addProperty("DisabledFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledFontColor","SetDisabledFontColor",4,{Default: 12632256});
    $r.addProperty("SelectedTitleFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTitleFontColor","SetSelectedTitleFontColor",4,{Default: 16777215});
    $r.addProperty("DisabledTitleFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledTitleFontColor","SetDisabledTitleFontColor",4,{Default: 12632256});
    $r.addProperty("ExtendedFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FExtendedFontColor","SetExtendedFontColor",4,{Default: 0});
    $r.addProperty("ExtendedSelectedFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FExtendedSelectedFontColor","SetExtendedSelectedFontColor",4,{Default: 16777215});
    $r.addProperty("ExtendedDisabledFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FExtendedDisabledFontColor","SetExtendedDisabledFontColor",4,{Default: 12632256});
    $r.addProperty("SelectedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FSelectedFill","SetSelectedFill");
    $r.addProperty("SelectedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FSelectedStroke","SetSelectedStroke");
    $r.addProperty("SelectionArea",2,$mod.$rtti["TTMSFNCTreeViewSelectionArea"],"FSelectionArea","SetSelectionArea",4,{Default: $mod.TTMSFNCTreeViewSelectionArea.tsaFromText});
    $r.addProperty("DisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDisabledFill","SetDisabledFill");
    $r.addProperty("DisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDisabledStroke","SetDisabledStroke");
    $r.addProperty("ExtendedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FExtendedFill","SetExtendedFill");
    $r.addProperty("ExtendedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FExtendedStroke","SetExtendedStroke");
    $r.addProperty("ExtendedFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FExtendedFont","SetExtendedFont");
    $r.addProperty("ExtendedSelectedFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FExtendedSelectedFill","SetExtendedSelectedFill");
    $r.addProperty("ExtendedSelectedStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FExtendedSelectedStroke","SetExtendedSelectedStroke");
    $r.addProperty("ExtendedDisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FExtendedDisabledFill","SetExtendedDisabledFill");
    $r.addProperty("ExtendedDisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FExtendedDisabledStroke","SetExtendedDisabledStroke");
    $r.addProperty("ExpandNodeIcon",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FExpandNodeIcon","SetExpandNodeIcon");
    $r.addProperty("CollapseNodeIcon",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FCollapseNodeIcon","SetCollapseNodeIcon");
    $r.addProperty("ExpandNodeIconLarge",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FExpandNodeIconLarge","SetExpandNodeIconLarge");
    $r.addProperty("CollapseNodeIconLarge",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FCollapseNodeIconLarge","SetCollapseNodeIconLarge");
  });
  rtl.createClass(this,"TTMSFNCTreeViewColumnsAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FTreeView = null;
      this.FLayouts = {};
      this.FStretch = false;
      this.FStretchColumn = 0;
      this.FStretchAll = false;
      this.FBottomSize = 0.0;
      this.FTopSize = 0.0;
      this.FBottomFill = null;
      this.FBottomStroke = null;
      this.FTopFill = null;
      this.FTopStroke = null;
      this.FTopFont = null;
      this.FBottomFont = null;
      this.FTopVerticalTextAlign = 0;
      this.FTopHorizontalTextAlign = 0;
      this.FBottomHorizontalTextAlign = 0;
      this.FBottomVerticalTextAlign = 0;
      this.FTopVerticalText = false;
      this.FBottomVerticalText = false;
      this.FFillEmptySpaces = false;
      this.FSortIndicatorColor = 0;
      this.FOptimizedColumnDisplay = false;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FLayouts = undefined;
      this.FBottomFill = undefined;
      this.FBottomStroke = undefined;
      this.FTopFill = undefined;
      this.FTopStroke = undefined;
      this.FTopFont = undefined;
      this.FBottomFont = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetLayouts = function (Value) {
      if (rtl.neSet(this.FLayouts,Value)) {
        this.FLayouts = rtl.refSet(Value);
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetStretch = function (Value) {
      if (this.FStretch !== Value) {
        this.FStretch = Value;
        this.FTreeView.UpdateColumns();
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetStretchAll = function (Value) {
      if (this.FStretchAll !== Value) {
        this.FStretchAll = Value;
        this.FTreeView.UpdateColumns();
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetStretchColumn = function (Value) {
      if (this.FStretchColumn !== Value) {
        this.FStretchColumn = Value;
        this.FTreeView.UpdateColumns();
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetBottomSize = function (Value) {
      if (this.FBottomSize !== Value) {
        this.FBottomSize = Value;
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetTopSize = function (Value) {
      if (this.FTopSize !== Value) {
        this.FTopSize = Value;
        this.Changed(this);
      };
    };
    this.SetBottomFill = function (Value) {
      if (this.FBottomFill !== Value) this.FBottomFill.Assign(Value);
    };
    this.SetBottomStroke = function (Value) {
      if (this.FBottomStroke !== Value) this.FBottomStroke.Assign(Value);
    };
    this.SetTopFill = function (Value) {
      if (this.FTopFill !== Value) this.FTopFill.Assign(Value);
    };
    this.SetTopStroke = function (Value) {
      if (this.FTopStroke !== Value) this.FTopStroke.Assign(Value);
    };
    this.SetBottomFont = function (Value) {
      if (this.FBottomFont !== Value) this.FBottomFont.Assign(Value);
    };
    this.SetTopFont = function (Value) {
      if (this.FTopFont !== Value) this.FTopFont.Assign(Value);
    };
    this.SetTopVerticalText = function (Value) {
      if (this.FTopVerticalText !== Value) {
        this.FTopVerticalText = Value;
        this.Changed(this);
      };
    };
    this.SetBottomVerticalText = function (Value) {
      if (this.FBottomVerticalText !== Value) {
        this.FBottomVerticalText = Value;
        this.Changed(this);
      };
    };
    this.SetFillEmptySpaces = function (Value) {
      if (this.FFillEmptySpaces !== Value) {
        this.FFillEmptySpaces = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.SetSortIndicatorColor = function (Value) {
      if (this.FSortIndicatorColor !== Value) {
        this.FSortIndicatorColor = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.SetOptimizedColumnDisplay = function (Value) {
      if (this.FOptimizedColumnDisplay !== Value) {
        this.FOptimizedColumnDisplay = Value;
        this.FTreeView.UpdateColumns();
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.Changed = function (Sender) {
      this.FTreeView.UpdateTreeViewCache();
    };
    this.Create$1 = function (ATreeView) {
      this.FTreeView = ATreeView;
      this.FSortIndicatorColor = 11829830;
      this.FLayouts = rtl.createSet($mod.TTMSFNCTreeViewColumnsLayout.tclTop);
      this.FFillEmptySpaces = true;
      this.FOptimizedColumnDisplay = true;
      this.FStretch = true;
      this.FStretchAll = true;
      this.FStretchColumn = -1;
      this.FBottomSize = 25;
      this.FTopVerticalText = false;
      this.FStretchAll = true;
      this.FBottomVerticalText = false;
      this.FTopSize = 25;
      this.FTopHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FTopVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FBottomHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FBottomVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FBottomFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FBottomStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FTopFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FTopStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FTopFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FTopFont.SetColor(0);
      this.FBottomFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBottomFont.SetColor(0);
      this.FBottomFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FTopFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FBottomStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FTopStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FTopFont.FOnChanged = rtl.createCallback(this,"Changed");
      this.FBottomFont.FOnChanged = rtl.createCallback(this,"Changed");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FTopFont");
      rtl.free(this,"FBottomFont");
      rtl.free(this,"FBottomFill");
      rtl.free(this,"FTopFill");
      rtl.free(this,"FBottomStroke");
      rtl.free(this,"FTopStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewColumnsAppearance.isPrototypeOf(Source)) {
        this.FSortIndicatorColor = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FSortIndicatorColor;
        this.FLayouts = rtl.refSet(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FLayouts);
        this.FTopSize = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FTopSize;
        this.FBottomSize = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FBottomSize;
        this.FBottomFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FBottomFill);
        this.FBottomFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FBottomFont);
        this.FBottomStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FBottomStroke);
        this.FTopFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FTopFill);
        this.FTopStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FTopStroke);
        this.FTopFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FTopFont);
        this.FStretch = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FStretch;
        this.FOptimizedColumnDisplay = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FOptimizedColumnDisplay;
        this.FStretchColumn = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FStretchColumn;
        this.FStretchAll = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FStretchAll;
        this.FTopVerticalText = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FTopVerticalText;
        this.FBottomVerticalText = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FBottomVerticalText;
        this.FFillEmptySpaces = rtl.as(Source,$mod.TTMSFNCTreeViewColumnsAppearance).FFillEmptySpaces;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Layouts",2,$mod.$rtti["TTMSFNCTreeViewColumnsLayouts"],"FLayouts","SetLayouts",4,{Default: rtl.createSet($mod.TTMSFNCTreeViewColumnsLayout.tclTop)});
    $r.addProperty("Stretch",2,rtl.boolean,"FStretch","SetStretch",4,{Default: true});
    $r.addProperty("StretchColumn",2,rtl.longint,"FStretchColumn","SetStretchColumn",4,{Default: -1});
    $r.addProperty("StretchAll",2,rtl.boolean,"FStretchAll","SetStretchAll",4,{Default: true});
    $r.addProperty("TopSize",2,rtl.double,"FTopSize","SetTopSize");
    $r.addProperty("BottomSize",2,rtl.double,"FBottomSize","SetBottomSize");
    $r.addProperty("TopFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FTopFont","SetTopFont");
    $r.addProperty("BottomFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FBottomFont","SetBottomFont");
    $r.addProperty("TopFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FTopFill","SetTopFill");
    $r.addProperty("BottomFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FBottomFill","SetBottomFill");
    $r.addProperty("TopStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FTopStroke","SetTopStroke");
    $r.addProperty("BottomStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FBottomStroke","SetBottomStroke");
    $r.addProperty("TopVerticalText",2,rtl.boolean,"FTopVerticalText","SetTopVerticalText",4,{Default: false});
    $r.addProperty("BottomVerticalText",2,rtl.boolean,"FBottomVerticalText","SetBottomVerticalText",4,{Default: false});
    $r.addProperty("FillEmptySpaces",2,rtl.boolean,"FFillEmptySpaces","SetFillEmptySpaces",4,{Default: true});
    $r.addProperty("SortIndicatorColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSortIndicatorColor","SetSortIndicatorColor",4,{Default: 11829830});
    $r.addProperty("OptimizedColumnDisplay",2,rtl.boolean,"FOptimizedColumnDisplay","SetOptimizedColumnDisplay",4,{Default: true});
  });
  this.TTMSFNCTreeViewColumnEmptySpace = {"0": "tcesTopLeft", tcesTopLeft: 0, "1": "tcesTopRight", tcesTopRight: 1, "2": "tcesBottomLeft", tcesBottomLeft: 2, "3": "tcesBottomRight", tcesBottomRight: 3};
  this.$rtti.$Enum("TTMSFNCTreeViewColumnEmptySpace",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCTreeViewColumnEmptySpace});
  this.TTMSFNCTreeViewGroupEmptySpace = {"0": "tgesTopLeft", tgesTopLeft: 0, "1": "tgesTopRight", tgesTopRight: 1, "2": "tgesBottomLeft", tgesBottomLeft: 2, "3": "tgesBottomRight", tgesBottomRight: 3};
  this.$rtti.$Enum("TTMSFNCTreeViewGroupEmptySpace",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCTreeViewGroupEmptySpace});
  rtl.createClass(this,"TTMSFNCTreeViewGroupsAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FTreeView = null;
      this.FLayouts = {};
      this.FBottomSize = 0.0;
      this.FTopSize = 0.0;
      this.FBottomFill = null;
      this.FBottomStroke = null;
      this.FTopFill = null;
      this.FTopStroke = null;
      this.FTopFont = null;
      this.FBottomFont = null;
      this.FBottomHorizontalTextAlign = 0;
      this.FTopVerticalTextAlign = 0;
      this.FTopHorizontalTextAlign = 0;
      this.FBottomVerticalTextAlign = 0;
      this.FTopVerticalText = false;
      this.FBottomVerticalText = false;
      this.FFillEmptySpaces = false;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FLayouts = undefined;
      this.FBottomFill = undefined;
      this.FBottomStroke = undefined;
      this.FTopFill = undefined;
      this.FTopStroke = undefined;
      this.FTopFont = undefined;
      this.FBottomFont = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetLayouts = function (Value) {
      if (rtl.neSet(this.FLayouts,Value)) {
        this.FLayouts = rtl.refSet(Value);
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetBottomSize = function (Value) {
      if (this.FBottomSize !== Value) {
        this.FBottomSize = Value;
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetTopSize = function (Value) {
      if (this.FTopSize !== Value) {
        this.FTopSize = Value;
        this.FTreeView.UpdateTreeViewCache();
      };
    };
    this.SetBottomFill = function (Value) {
      if (this.FBottomFill !== Value) this.FBottomFill.Assign(Value);
    };
    this.SetBottomStroke = function (Value) {
      if (this.FBottomStroke !== Value) this.FBottomStroke.Assign(Value);
    };
    this.SetTopFill = function (Value) {
      if (this.FTopFill !== Value) this.FTopFill.Assign(Value);
    };
    this.SetTopStroke = function (Value) {
      if (this.FTopStroke !== Value) this.FTopStroke.Assign(Value);
    };
    this.SetBottomFont = function (Value) {
      if (this.FBottomFont !== Value) this.FBottomFont.Assign(Value);
    };
    this.SetTopFont = function (Value) {
      if (this.FTopFont !== Value) this.FTopFont.Assign(Value);
    };
    this.SetBottomHorizontalTextAlign = function (Value) {
      if (this.FBottomHorizontalTextAlign !== Value) {
        this.FBottomHorizontalTextAlign = Value;
        this.Changed(this);
      };
    };
    this.SetBottomVerticalTextAlign = function (Value) {
      if (this.FBottomVerticalTextAlign !== Value) {
        this.FBottomVerticalTextAlign = Value;
        this.Changed(this);
      };
    };
    this.SetTopHorizontalTextAlign = function (Value) {
      if (this.FTopHorizontalTextAlign !== Value) {
        this.FTopHorizontalTextAlign = Value;
        this.Changed(this);
      };
    };
    this.SetTopVerticalTextAlign = function (Value) {
      if (this.FTopVerticalTextAlign !== Value) {
        this.FTopVerticalTextAlign = Value;
        this.Changed(this);
      };
    };
    this.SetTopVerticalText = function (Value) {
      if (this.FTopVerticalText !== Value) {
        this.FTopVerticalText = Value;
        this.Changed(this);
      };
    };
    this.SetBottomVerticalText = function (Value) {
      if (this.FBottomVerticalText !== Value) {
        this.FBottomVerticalText = Value;
        this.Changed(this);
      };
    };
    this.SetFillEmptySpaces = function (Value) {
      if (this.FFillEmptySpaces !== Value) {
        this.FFillEmptySpaces = Value;
        this.FTreeView.Invalidate();
      };
    };
    this.Changed = function (Sender) {
      this.FTreeView.UpdateTreeViewCache();
    };
    this.Create$1 = function (ATreeView) {
      this.FTreeView = ATreeView;
      this.FLayouts = rtl.createSet($mod.TTMSFNCTreeViewGroupLayout.tglTop);
      this.FFillEmptySpaces = true;
      this.FTopSize = 50;
      this.FBottomSize = 50;
      this.FTopVerticalText = false;
      this.FBottomVerticalText = false;
      this.FTopHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FTopVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FBottomHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FBottomVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FBottomFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FBottomStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FTopFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FTopStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,11119017,1.0]);
      this.FTopFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FTopFont.SetColor(0);
      this.FBottomFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBottomFont.SetColor(0);
      this.FBottomFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FTopFill.FOnChanged = rtl.createCallback(this,"Changed");
      this.FBottomStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FTopStroke.FOnChanged = rtl.createCallback(this,"Changed");
      this.FTopFont.FOnChanged = rtl.createCallback(this,"Changed");
      this.FBottomFont.FOnChanged = rtl.createCallback(this,"Changed");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBottomFont");
      rtl.free(this,"FTopFont");
      rtl.free(this,"FBottomFill");
      rtl.free(this,"FBottomStroke");
      rtl.free(this,"FTopFill");
      rtl.free(this,"FTopStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewGroupsAppearance.isPrototypeOf(Source)) {
        this.FLayouts = rtl.refSet(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FLayouts);
        this.FTopSize = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopSize;
        this.FBottomSize = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomSize;
        this.FBottomFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomFill);
        this.FBottomFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomFont);
        this.FBottomStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomStroke);
        this.FTopFill.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopFill);
        this.FTopStroke.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopStroke);
        this.FTopFont.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopFont);
        this.FTopHorizontalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopHorizontalTextAlign;
        this.FTopVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopVerticalTextAlign;
        this.FBottomHorizontalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomHorizontalTextAlign;
        this.FBottomVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomVerticalTextAlign;
        this.FTopVerticalText = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FTopVerticalText;
        this.FBottomVerticalText = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FBottomVerticalText;
        this.FFillEmptySpaces = rtl.as(Source,$mod.TTMSFNCTreeViewGroupsAppearance).FFillEmptySpaces;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Layouts",2,$mod.$rtti["TTMSFNCTreeViewGroupsLayouts"],"FLayouts","SetLayouts",4,{Default: rtl.createSet($mod.TTMSFNCTreeViewGroupLayout.tglTop)});
    $r.addProperty("TopSize",2,rtl.double,"FTopSize","SetTopSize");
    $r.addProperty("BottomSize",2,rtl.double,"FBottomSize","SetBottomSize");
    $r.addProperty("TopFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FTopFill","SetTopFill");
    $r.addProperty("BottomFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FBottomFill","SetBottomFill");
    $r.addProperty("TopFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FTopFont","SetTopFont");
    $r.addProperty("BottomFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FBottomFont","SetBottomFont");
    $r.addProperty("TopStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FTopStroke","SetTopStroke");
    $r.addProperty("BottomStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FBottomStroke","SetBottomStroke");
    $r.addProperty("TopHorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTopHorizontalTextAlign","SetTopHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("TopVerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTopVerticalTextAlign","SetTopVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("BottomHorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FBottomHorizontalTextAlign","SetBottomHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("BottomVerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FBottomVerticalTextAlign","SetBottomVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("TopVerticalText",2,rtl.boolean,"FTopVerticalText","SetTopVerticalText",4,{Default: false});
    $r.addProperty("BottomVerticalText",2,rtl.boolean,"FBottomVerticalText","SetBottomVerticalText",4,{Default: false});
    $r.addProperty("FillEmptySpaces",2,rtl.boolean,"FFillEmptySpaces","SetFillEmptySpaces",4,{Default: true});
  });
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawSortIndicatorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ASortIndex",rtl.longint],["ASortKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodesSortKind"]],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawSortIndicatorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ASortIndex",rtl.longint],["ASortKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodesSortKind"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeCompareEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node1",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNode"]],["Node2",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNode"]],["AColumn",rtl.longint],["ACompareResult",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeSizeColumnEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AColumnSize",rtl.double],["ANewColumnSize",rtl.double,1],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterSizeColumnEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AColumnSize",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawColumnEmptySpaceEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASpace",this.$rtti["TTMSFNCTreeViewColumnEmptySpace"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawColumnEmptySpaceEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASpace",this.$rtti["TTMSFNCTreeViewColumnEmptySpace"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawGroupEmptySpaceEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASpace",this.$rtti["TTMSFNCTreeViewGroupEmptySpace"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawGroupEmptySpaceEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASpace",this.$rtti["TTMSFNCTreeViewGroupEmptySpace"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNeedFilterDropDownDataEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AValues",pas.Classes.$rtti["TStrings"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawColumnEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawColumnEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawColumnHeaderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawColumnHeaderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawGroupEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AGroup",rtl.longint],["AStartColumn",rtl.longint],["AEndColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawGroupEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AGroup",rtl.longint],["AStartColumn",rtl.longint],["AEndColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNumberOfNodesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ANumberOfNodes",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetColumnTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AText",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawColumnTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AText",rtl.string],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawColumnTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetGroupTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGroup",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AText",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawGroupTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AGroup",rtl.longint],["AStartColumn",rtl.longint],["AEndColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AText",rtl.string],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawGroupTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AGroup",rtl.longint],["AStartColumn",rtl.longint],["AEndColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AAnchor",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeTitleAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AAnchor",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AMode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodeTextMode"]],["AText",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeDataEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTitleEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AMode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodeTextMode"]],["ATitle",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTitleExpandedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AExpanded",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeSidesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ASides",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsSides"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeRoundingEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ARounding",rtl.longint,1],["ACorners",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsCorners"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTrimmingEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ATrimming",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeHorizontalTextAlignEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AHorizontalTextAlign",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeVerticalTextAlignEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AVerticalTextAlign",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeWordWrappingEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AWordWrapping",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeExtraSizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AExtraSize",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTitleExtraSizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ATitleExtraSize",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetColumnTrimmingEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["ATrimming",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetColumnHorizontalTextAlignEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AHorizontalTextAlign",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetColumnVerticalTextAlignEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AVerticalTextAlign",pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetColumnWordWrappingEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AKind",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewCacheItemKind"]],["AWordWrapping",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeIconEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ALarge",rtl.boolean],["AIcon",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeIconSizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ALarge",rtl.boolean],["AIcon",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]],["AIconWidth",rtl.double,1],["AIconHeight",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewFocusedNodeChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeHeightEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AHeight",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AText",rtl.string],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeTitleEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ATitle",rtl.string],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeTitleEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ATitle",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeExpandEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AExpand",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeExpandEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AExpand",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeIconEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AIcon",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeIconEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AIcon",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeExtraEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeExtraEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewDrawNodeExtraEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeTitleExtraEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeTitleExtraEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewDrawNodeTitleExtraEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDrawNodeCheckEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACheck",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDrawNodeCheckEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AColumn",rtl.longint],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACheck",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeColorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeCheckTypeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ACheckType",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodeCheckType"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTextColorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ATextColor",pas["WEBLib.Graphics"].$rtti["TColor"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetNodeTitleColorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ATitleColor",pas["WEBLib.Graphics"].$rtti["TColor"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewIsNodeExtendedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AExtended",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewColumnAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AAnchor",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewCustomizeFilterListBoxEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["AListBox",pas["WEBLib.StdCtrls"].$rtti["TListBox"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewIsNodeDeletableEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ADeletable",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewIsNodeCheckedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AChecked",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewIsNodeExpandedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AExpanded",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewIsNodeVisibleEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AVisible",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewIsNodeEnabledEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AEnabled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeUpdateNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AText",rtl.string,1],["ACanUpdate",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterUpdateNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeCollapseNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACanCollapse",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterCollapseNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeExpandNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACanExpand",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterExpandNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeCheckNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ACanCheck",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterCheckNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeUnCheckNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ACanUnCheck",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterUnCheckNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeSelectAllNodesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanSelect",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterSelectAllNodesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeSelectNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACanSelect",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterSelectNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeUnSelectNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACanUnSelect",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterUnSelectNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeValueClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeMouseEnterEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewNodeMouseLeaveEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewScrollEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["APosition",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeAddJSONNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AJSONValue",pas["WEBLib.JSON"].$rtti["TJSONValue"]],["AAddNode",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterAddJSONNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNode"]],["AJSONValue",pas["WEBLib.JSON"].$rtti["TJSONValue"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetHTMLTemplateValueEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANodeValue",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodeValue"]],["AName",rtl.string],["AValue",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetHTMLTemplateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANodeValue",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodeValue"]],["AColumnIndex",rtl.longint],["AHTMLTemplate",rtl.string,1]]), methodkind: 0});
  this.$rtti.$ClassRef("TTMSFNCTreeViewInplaceEditorClass",{instancetype: pas["WEBLib.Controls"].$rtti["TWinControl"]});
  this.$rtti.$MethodVar("TTMSFNCTreeViewCustomizeInplaceEditorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AInplaceEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetInplaceEditorRectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AInplaceEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["AInplaceEditorRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewGetInplaceEditorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AInplaceEditorClass",this.$rtti["TTMSFNCTreeViewInplaceEditorClass"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeOpenInplaceEditorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["ACanOpen",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterOpenInplaceEditorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AInplaceEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["AInplaceEditorRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewCloseInplaceEditorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AColumn",rtl.longint],["AInplaceEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["ACancelled",rtl.boolean],["ACanClose",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeReorderNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AToNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACanReorder",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterReorderNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AToNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeSortNodesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASortColumn",rtl.longint],["ASortMode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodesSortMode"]],["ACanSort",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterSortNodesEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASortColumn",rtl.longint],["ASortMode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodesSortMode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeDropNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AToNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["ACanDrop",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterDropNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AToNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeCopyToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanCopy",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforeCutToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanCut",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewBeforePasteFromClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanPaste",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterCopyToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterCutToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewAfterPasteFromClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewFilterSelectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["ACondition",rtl.string,1]]), methodkind: 0});
  this.TTMSFNCTreeViewMouseEditMode = {"0": "tmemDoubleClick", tmemDoubleClick: 0, "1": "tmemSingleClick", tmemSingleClick: 1, "2": "tmemSingleClickOnSelectedNode", tmemSingleClickOnSelectedNode: 2};
  this.$rtti.$Enum("TTMSFNCTreeViewMouseEditMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCTreeViewMouseEditMode});
  this.TTMSFNCTreeViewClipboardMode = {"0": "tcmNone", tcmNone: 0, "1": "tcmTextOnly", tcmTextOnly: 1, "2": "tcmFull", tcmFull: 2};
  this.$rtti.$Enum("TTMSFNCTreeViewClipboardMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCTreeViewClipboardMode});
  this.TTMSFNCTreeViewDragDropMode = {"0": "tdmNone", tdmNone: 0, "1": "tdmMove", tdmMove: 1, "2": "tdmCopy", tdmCopy: 2};
  this.$rtti.$Enum("TTMSFNCTreeViewDragDropMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCTreeViewDragDropMode});
  this.TMultiSelectStyles = {"0": "msControlSelect", msControlSelect: 0, "1": "msShiftSelect", msShiftSelect: 1, "2": "msVisibleOnly", msVisibleOnly: 2, "3": "msSiblingOnly", msSiblingOnly: 3};
  this.$rtti.$Enum("TMultiSelectStyles",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TMultiSelectStyles});
  this.$rtti.$Set("TMultiSelectStyle",{comptype: this.$rtti["TMultiSelectStyles"]});
  this.$rtti.$Class("TTMSFNCTreeViewInteraction");
  rtl.createClass(this,"TTMSFNCTreeViewLookup",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FEnabled = false;
      this.FCaseSensitive = false;
      this.FIncremental = false;
      this.FColumn = 0;
      this.FAutoSelect = false;
      this.FRootNodesOnly = false;
      this.FAutoExpand = false;
      this.FVisibleNodesOnly = false;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FEnabled = true;
      this.FCaseSensitive = false;
      this.FIncremental = true;
      this.FColumn = -1;
      this.FAutoSelect = true;
      this.FAutoExpand = false;
      this.FRootNodesOnly = false;
      this.FVisibleNodesOnly = false;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewLookup.isPrototypeOf(Source)) {
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FEnabled;
        this.FCaseSensitive = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FCaseSensitive;
        this.FIncremental = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FIncremental;
        this.FColumn = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FColumn;
        this.FAutoSelect = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FAutoSelect;
        this.FAutoExpand = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FAutoExpand;
        this.FRootNodesOnly = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FRootNodesOnly;
        this.FVisibleNodesOnly = rtl.as(Source,$mod.TTMSFNCTreeViewLookup).FVisibleNodesOnly;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive",4,{Default: false});
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",4,{Default: true});
    $r.addProperty("Incremental",0,rtl.boolean,"FIncremental","FIncremental",4,{Default: true});
    $r.addProperty("Column",0,rtl.longint,"FColumn","FColumn",4,{Default: -1});
    $r.addProperty("RootNodesOnly",0,rtl.boolean,"FRootNodesOnly","FRootNodesOnly",4,{Default: false});
    $r.addProperty("VisibleNodesOnly",0,rtl.boolean,"FVisibleNodesOnly","FVisibleNodesOnly",4,{Default: false});
    $r.addProperty("AutoExpand",0,rtl.boolean,"FAutoExpand","FAutoExpand",4,{Default: false});
    $r.addProperty("AutoSelect",0,rtl.boolean,"FAutoSelect","FAutoSelect",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCTreeViewInteraction",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FTreeView = null;
      this.FMultiSelect = false;
      this.FTouchScrolling = false;
      this.FReadOnly = false;
      this.FColumnSizing = false;
      this.FColumnAutoSizeOnDblClick = false;
      this.FExtendedSelectable = false;
      this.FSelectionFollowsFocus = false;
      this.FKeyboardEdit = false;
      this.FMouseEditMode = 0;
      this.FExtendedEditable = false;
      this.FClipboardMode = 0;
      this.FReorder = false;
      this.FDragDropMode = 0;
      this.FLookup = null;
      this.FExpandCollapseOnDblClick = false;
      this.FAutoOpenURL = false;
      this.FURLDetectionOnMouseMove = false;
      this.FMouseWheelDelta = 0.0;
      this.FAnimationFactor = 0.0;
      this.FMultiSelectStyle = {};
    };
    this.$final = function () {
      this.FTreeView = undefined;
      this.FLookup = undefined;
      this.FMultiSelectStyle = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetMultiSelect = function (Value) {
      if (this.FMultiSelect !== Value) this.FMultiSelect = Value;
    };
    this.SetTouchScrolling = function (Value) {
      if (this.FTouchScrolling !== Value) this.FTouchScrolling = Value;
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) this.FReadOnly = Value;
    };
    this.SetColumnSizing = function (Value) {
      if (this.FColumnSizing !== Value) {
        this.FColumnSizing = Value;
        if ((this.FTreeView != null) && this.FColumnSizing) this.FTreeView.FColumnsAppearance.SetStretchAll(false);
      };
    };
    this.SetColumnAutoSizeOnDblClick = function (Value) {
      if (this.FColumnAutoSizeOnDblClick !== Value) this.FColumnAutoSizeOnDblClick = Value;
    };
    this.SetExtendedSelectable = function (Value) {
      if (this.FExtendedSelectable !== Value) this.FExtendedSelectable = Value;
    };
    this.SetSelectionFollowsFocus = function (Value) {
      if (this.FSelectionFollowsFocus !== Value) this.FSelectionFollowsFocus = Value;
    };
    this.SetMouseEditMode = function (Value) {
      if (this.FMouseEditMode !== Value) this.FMouseEditMode = Value;
    };
    this.SetExtendedEditable = function (Value) {
      if (this.FExtendedEditable !== Value) this.FExtendedEditable = Value;
    };
    this.SetDragDropMode = function (Value) {
      if (this.FDragDropMode !== Value) this.FDragDropMode = Value;
    };
    this.SetReorder = function (Value) {
      if (this.FReorder !== Value) this.FReorder = Value;
    };
    this.SetLookup = function (Value) {
      if (this.FLookup !== Value) this.FLookup.Assign(Value);
    };
    this.SetExpandCollapseOnDblClick = function (Value) {
      if (this.FExpandCollapseOnDblClick !== Value) this.FExpandCollapseOnDblClick = Value;
    };
    this.SetURLDetectionOnMouseMove = function (Value) {
      if (this.FURLDetectionOnMouseMove !== Value) {
        this.FURLDetectionOnMouseMove = Value;
      };
    };
    this.IsMouseWheelDeltaStored = function () {
      var Result = false;
      Result = this.FMouseWheelDelta !== 1;
      return Result;
    };
    this.SetMouseWheelDelta = function (Value) {
      this.FMouseWheelDelta = Value;
    };
    this.IsAnimationFactorStored = function () {
      var Result = false;
      Result = this.FAnimationFactor !== 2.5;
      return Result;
    };
    this.SetMultiSelectStyle = function (Value) {
      if (rtl.neSet(Value,this.FMultiSelectStyle)) {
        this.FMultiSelectStyle = rtl.refSet(Value);
      };
    };
    this.Create$1 = function (ATreeView) {
      this.FTreeView = ATreeView;
      this.FAutoOpenURL = true;
      this.FAnimationFactor = 2.5;
      this.FMouseWheelDelta = 1;
      this.FClipboardMode = $mod.TTMSFNCTreeViewClipboardMode.tcmNone;
      this.FExpandCollapseOnDblClick = true;
      this.FReorder = false;
      this.FDragDropMode = $mod.TTMSFNCTreeViewDragDropMode.tdmNone;
      this.FReadOnly = false;
      this.FURLDetectionOnMouseMove = true;
      this.FSelectionFollowsFocus = true;
      this.FTouchScrolling = true;
      this.FKeyboardEdit = true;
      this.FExtendedSelectable = false;
      this.FMultiSelect = false;
      this.FColumnSizing = false;
      this.FExtendedEditable = false;
      this.FColumnAutoSizeOnDblClick = false;
      this.FMouseEditMode = $mod.TTMSFNCTreeViewMouseEditMode.tmemSingleClickOnSelectedNode;
      this.FLookup = $mod.TTMSFNCTreeViewLookup.$create("Create$1",[this]);
      this.FMultiSelectStyle = rtl.createSet($mod.TMultiSelectStyles.msControlSelect,$mod.TMultiSelectStyles.msShiftSelect);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FLookup");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewInteraction.isPrototypeOf(Source)) {
        this.FMultiSelect = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FMultiSelect;
        this.FTouchScrolling = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FTouchScrolling;
        this.FReadOnly = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FReadOnly;
        this.FColumnSizing = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FColumnSizing;
        this.FColumnAutoSizeOnDblClick = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FColumnAutoSizeOnDblClick;
        this.FExtendedSelectable = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FExtendedSelectable;
        this.FSelectionFollowsFocus = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FSelectionFollowsFocus;
        this.FKeyboardEdit = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FKeyboardEdit;
        this.FMouseEditMode = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FMouseEditMode;
        this.FExtendedEditable = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FExtendedEditable;
        this.FClipboardMode = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FClipboardMode;
        this.FReorder = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FReorder;
        this.FDragDropMode = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FDragDropMode;
        this.FLookup.Assign(rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FLookup);
        this.FExpandCollapseOnDblClick = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FExpandCollapseOnDblClick;
        this.FAutoOpenURL = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FAutoOpenURL;
        this.FURLDetectionOnMouseMove = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FURLDetectionOnMouseMove;
        this.FMouseWheelDelta = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FMouseWheelDelta;
        this.FAnimationFactor = rtl.as(Source,$mod.TTMSFNCTreeViewInteraction).FAnimationFactor;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("AnimationFactor",12,rtl.double,"FAnimationFactor","FAnimationFactor",4,{stored: "IsAnimationFactorStored"});
    $r.addProperty("AutoOpenURL",0,rtl.boolean,"FAutoOpenURL","FAutoOpenURL",4,{Default: true});
    $r.addProperty("MultiSelect",2,rtl.boolean,"FMultiSelect","SetMultiSelect",4,{Default: false});
    $r.addProperty("MultiSelectStyle",2,$mod.$rtti["TMultiSelectStyle"],"FMultiSelectStyle","SetMultiSelectStyle",4,{Default: rtl.createSet($mod.TMultiSelectStyles.msControlSelect,$mod.TMultiSelectStyles.msShiftSelect)});
    $r.addProperty("ExtendedSelectable",2,rtl.boolean,"FExtendedSelectable","SetExtendedSelectable",4,{Default: false});
    $r.addProperty("ExtendedEditable",2,rtl.boolean,"FExtendedEditable","SetExtendedEditable",4,{Default: false});
    $r.addProperty("MouseEditMode",2,$mod.$rtti["TTMSFNCTreeViewMouseEditMode"],"FMouseEditMode","SetMouseEditMode",4,{Default: $mod.TTMSFNCTreeViewMouseEditMode.tmemSingleClickOnSelectedNode});
    $r.addProperty("MouseWheelDelta",14,rtl.double,"FMouseWheelDelta","SetMouseWheelDelta",4,{stored: "IsMouseWheelDeltaStored"});
    $r.addProperty("TouchScrolling",2,rtl.boolean,"FTouchScrolling","SetTouchScrolling",4,{Default: true});
    $r.addProperty("KeyboardEdit",0,rtl.boolean,"FKeyboardEdit","FKeyboardEdit",4,{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("ExpandCollapseOnDblClick",2,rtl.boolean,"FExpandCollapseOnDblClick","SetExpandCollapseOnDblClick",4,{Default: true});
    $r.addProperty("ColumnSizing",2,rtl.boolean,"FColumnSizing","SetColumnSizing",4,{Default: false});
    $r.addProperty("ColumnAutoSizeOnDblClick",2,rtl.boolean,"FColumnAutoSizeOnDblClick","SetColumnAutoSizeOnDblClick",4,{Default: false});
    $r.addProperty("ClipboardMode",0,$mod.$rtti["TTMSFNCTreeViewClipboardMode"],"FClipboardMode","FClipboardMode",4,{Default: $mod.TTMSFNCTreeViewClipboardMode.tcmNone});
    $r.addProperty("Reorder",2,rtl.boolean,"FReorder","SetReorder",4,{Default: false});
    $r.addProperty("DragDropMode",2,$mod.$rtti["TTMSFNCTreeViewDragDropMode"],"FDragDropMode","SetDragDropMode",4,{Default: $mod.TTMSFNCTreeViewDragDropMode.tdmNone});
    $r.addProperty("Lookup",2,$mod.$rtti["TTMSFNCTreeViewLookup"],"FLookup","SetLookup");
    $r.addProperty("URLDetectionOnMouseMove",2,rtl.boolean,"FURLDetectionOnMouseMove","SetURLDetectionOnMouseMove",4,{Default: true});
  });
  rtl.recNewT(this,"TTMSFNCTreeViewSceneDrawingScale",function () {
    this.SceneScale = 0.0;
    this.$new = function () {
      var r = Object.create(this);
      r.DrawingScale = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.SceneScale === b.SceneScale) && this.DrawingScale.$eq(b.DrawingScale);
    };
    this.$assign = function (s) {
      this.SceneScale = s.SceneScale;
      this.DrawingScale.$assign(s.DrawingScale);
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTreeViewSceneDrawingScale",{},this);
    $r.addField("SceneScale",rtl.double);
    $r.addField("DrawingScale",pas["WEBLib.TMSFNCTypes"].$rtti["TPointF"]);
  });
  rtl.createClass(this,"TTMSFNCTreeViewSelectedNodes",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  this.$rtti.$DynArray("TTMSFNCTreeViewNodeArray",{eltype: pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNode"]});
  rtl.recNewT(this,"TTMSFNCTreeViewNodeCheck",function () {
    this.AColumn = 0;
    this.ANode = null;
    this.$eq = function (b) {
      return (this.AColumn === b.AColumn) && (this.ANode === b.ANode);
    };
    this.$assign = function (s) {
      this.AColumn = s.AColumn;
      this.ANode = s.ANode;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTreeViewNodeCheck",{},this);
    $r.addField("AColumn",rtl.longint);
    $r.addField("ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]);
  });
  rtl.recNewT(this,"TTMSFNCTreeViewNodeIcon",function () {
    this.AColumn = 0;
    this.ANode = null;
    this.$eq = function (b) {
      return (this.AColumn === b.AColumn) && (this.ANode === b.ANode);
    };
    this.$assign = function (s) {
      this.AColumn = s.AColumn;
      this.ANode = s.ANode;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTreeViewNodeIcon",{},this);
    $r.addField("AColumn",rtl.longint);
    $r.addField("ANode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]);
  });
  rtl.recNewT(this,"TTMSFNCTreeViewNodeAnchor",function () {
    this.AAnchor = "";
    this.AColumn = 0;
    this.$eq = function (b) {
      return (this.AAnchor === b.AAnchor) && (this.AColumn === b.AColumn);
    };
    this.$assign = function (s) {
      this.AAnchor = s.AAnchor;
      this.AColumn = s.AColumn;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTreeViewNodeAnchor",{},this);
    $r.addField("AAnchor",rtl.string);
    $r.addField("AColumn",rtl.longint);
  });
  rtl.createClass(this,"TTMSFNCTreeViewComboBox",pas["WEBLib.StdCtrls"].TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCTreeViewMemo",pas["WEBLib.StdCtrls"].TMemo,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TMemo.$init.call(this);
      this.FTreeView = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      pas["WEBLib.StdCtrls"].TMemo.$final.call(this);
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      if ((this.FTreeView != null) && this.FTreeView.FInplaceEditorActive) {
        var $tmp = Key.get();
        if ($tmp === 27) {
          this.FTreeView.CloseInplaceEditor(true,true);
          Key.set(0);
        } else if ($tmp === 113) {
          this.FTreeView.CloseInplaceEditor(false,true);
          Key.set(0);
        };
      };
    };
    this.DoExit = function () {
      pas["WEBLib.Controls"].TControl.DoExit.call(this);
      if ((this.FTreeView != null) && this.FTreeView.FInplaceEditorActive) this.FTreeView.CloseInplaceEditor(false,false);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      if ($mod.TTMSFNCCustomTreeView.isPrototypeOf(AOwner)) this.FTreeView = rtl.as(AOwner,$mod.TTMSFNCCustomTreeView);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCTreeViewEdit",pas["WEBLib.StdCtrls"].TEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TEdit.$init.call(this);
      this.FTreeView = null;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      pas["WEBLib.StdCtrls"].TEdit.$final.call(this);
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      if ((this.FTreeView != null) && this.FTreeView.FInplaceEditorActive) {
        var $tmp = Key.get();
        if ($tmp === 27) {
          this.FTreeView.CloseInplaceEditor(true,true);
          Key.set(0);
        } else if (($tmp === 113) || ($tmp === 13)) {
          this.FTreeView.CloseInplaceEditor(false,true);
          Key.set(0);
        };
      };
    };
    this.DoExit = function () {
      pas["WEBLib.Controls"].TControl.DoExit.call(this);
      if ((this.FTreeView != null) && this.FTreeView.FInplaceEditorActive) this.FTreeView.CloseInplaceEditor(false,false);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      if ($mod.TTMSFNCCustomTreeView.isPrototypeOf(AOwner)) this.FTreeView = rtl.as(AOwner,$mod.TTMSFNCCustomTreeView);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCTreeViewCopyNodes",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodes,function () {
  });
  this.$rtti.$MethodVar("TTMSFNCTreeViewDragOverEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",pas.System.$rtti["TObject"]],["Point",pas["WEBLib.TMSFNCTypes"].$rtti["TPointF"]],["Accept",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewDragDropEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",pas.System.$rtti["TObject"]],["Point",pas["WEBLib.TMSFNCTypes"].$rtti["TPointF"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewColumnSortEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColumn",rtl.longint],["ASortMode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodesSortMode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewLookupEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ALookupString",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTreeViewReorderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]],["AToNode",pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewVirtualNode"]]]), methodkind: 0});
  this.TTMSFNCTreeViewExportState = {"0": "tvesExportStart", tvesExportStart: 0, "1": "tvesExportNewRow", tvesExportNewRow: 1, "2": "tvesExportDone", tvesExportDone: 2, "3": "tvesExportSelRow", tvesExportSelRow: 3, "4": "tvesExportFail", tvesExportFail: 4, "5": "tvesExportNextRow", tvesExportNextRow: 5, "6": "tvesExportFindRow", tvesExportFindRow: 6};
  this.$rtti.$Enum("TTMSFNCTreeViewExportState",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TTMSFNCTreeViewExportState});
  rtl.createClass(this,"TTMSFNCTreeViewAdapter",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FBlockAdd = false;
      this.FTreeView = null;
      this.FActive = false;
    };
    this.$final = function () {
      this.FTreeView = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetActive = function (Value) {
      this.FActive = Value;
      if (!(this.FTreeView != null)) return;
      this.Initialize();
    };
    this.SetTreeView = function (Value) {
      if (this.FTreeView !== Value) {
        this.FTreeView = Value;
        if (this.FBlockAdd) return;
        this.FBlockAdd = true;
        if (this.FTreeView != null) {
          this.FTreeView.SetAdapter(this);
          this.Initialize();
        };
        this.FBlockAdd = false;
      };
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.GetNumberOfNodes = function (ANode, ANumberOfNodes) {
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FTreeView)) this.FTreeView = null;
    };
    this.UpdateBounds = function () {
    };
    this.Initialize = function () {
    };
    this.ScrollTreeView = function (ADelta) {
    };
    this.SelectNode = function (ANode) {
    };
    this.GetNodeText = function (ACol, ANode, AText) {
    };
    this.ExportNotification = function (AState, ARow) {
    };
    this.GetColumnDisplayName = function (ACol) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.Create$1 = function (AOwner) {
      var I = 0;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      this.FActive = false;
      if (this.IsDesignTime() && (AOwner != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AOwner)) {
        for (var $l = 0, $end = AOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ($mod.TTMSFNCCustomTreeView.isPrototypeOf(AOwner.GetComponent(I))) {
            this.SetTreeView(rtl.as(AOwner.GetComponent(I),$mod.TTMSFNCCustomTreeView));
            break;
          };
        };
      };
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Active",2,rtl.boolean,"FActive","SetActive",4,{Default: false});
    $r.addProperty("TreeView",2,$mod.$rtti["TTMSFNCCustomTreeView"],"FTreeView","SetTreeView");
  });
  rtl.createClass(this,"TTMSFNCTreeViewViewJSONOptions",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FValueHTMLTemplate = "";
      this.FExpandNodes = false;
      this.FNameHTMLTemplate = "";
      this.FOnChange = null;
      this.FStretchColumn = 0;
      this.FArrayItemPrefix = "";
      this.FArrayItemSuffix = "";
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      this.FExpandNodes = true;
      this.FStretchColumn = 1;
      this.FNameHTMLTemplate = "<#NAME>";
      this.FValueHTMLTemplate = "<#VALUE>";
      this.FArrayItemPrefix = "";
      this.FArrayItemSuffix = "";
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTreeViewViewJSONOptions.isPrototypeOf(Source)) {
        this.FExpandNodes = rtl.as(Source,$mod.TTMSFNCTreeViewViewJSONOptions).FExpandNodes;
        this.FStretchColumn = rtl.as(Source,$mod.TTMSFNCTreeViewViewJSONOptions).FStretchColumn;
        this.FNameHTMLTemplate = rtl.as(Source,$mod.TTMSFNCTreeViewViewJSONOptions).FNameHTMLTemplate;
        this.FValueHTMLTemplate = rtl.as(Source,$mod.TTMSFNCTreeViewViewJSONOptions).FValueHTMLTemplate;
        this.FArrayItemPrefix = rtl.as(Source,$mod.TTMSFNCTreeViewViewJSONOptions).FArrayItemPrefix;
        this.FArrayItemSuffix = rtl.as(Source,$mod.TTMSFNCTreeViewViewJSONOptions).FArrayItemSuffix;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("ExpandNodes",0,rtl.boolean,"FExpandNodes","FExpandNodes",4,{Default: true});
    $r.addProperty("StretchColumn",0,rtl.longint,"FStretchColumn","FStretchColumn",4,{Default: 1});
    $r.addProperty("NameHTMLTemplate",0,rtl.string,"FNameHTMLTemplate","FNameHTMLTemplate");
    $r.addProperty("ValueHTMLTemplate",0,rtl.string,"FValueHTMLTemplate","FValueHTMLTemplate");
    $r.addProperty("ArrayItemPrefix",0,rtl.string,"FArrayItemPrefix","FArrayItemPrefix");
    $r.addProperty("ArrayItemSuffix",0,rtl.string,"FArrayItemSuffix","FArrayItemSuffix");
  });
  rtl.createClass(this,"TTMSFNCCustomTreeView",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.$init.call(this);
      this.FPrevDSP = null;
      this.FOldTopRow = 0;
      this.FCompactMode = false;
      this.FVerticalOffset = 0.0;
      this.FVerticalOffsetTo = 0.0;
      this.FAccepted = false;
      this.FLookupString = "";
      this.FY = 0.0;
      this.FDragY = 0.0;
      this.FSaveDragY = 0.0;
      this.FX = 0.0;
      this.FDragBitmap = null;
      this.FReorderMode = false;
      this.FDragMode$1 = false;
      this.FDragModeStarted = false;
      this.FSortColumn = 0;
      this.FClosing = false;
      this.FInplaceEditorClosed = false;
      this.FColumnSize = 0.0;
      this.FCloseWithDialogKey = false;
      this.FFilterPopup = null;
      this.FFilterListBox = null;
      this.FFilterTimer = null;
      this.FInplaceEditorClass = null;
      this.FInplaceEditor = null;
      this.FOldInplaceEditor = null;
      this.FInplaceEditorActive = false;
      this.FSizeColumn = 0;
      this.FDownColumnValue = 0;
      this.FDownColumn = 0;
      this.FDownColumnFilter = 0;
      this.FDownColumnExpand = 0;
      this.FUpdateNodeColumn = 0;
      this.FUpdateNode = null;
      this.FCopyNodes = null;
      this.FDoubleSelection = false;
      this.FDragTimer = null;
      this.FDragRow = 0;
      this.FDownNode = null;
      this.FFocusedNode = null;
      this.FDragNode = null;
      this.FDblClicked = false;
      this.FDoNodeAnchor = $mod.TTMSFNCTreeViewNodeAnchor.$new();
      this.FDoNodeTitleAnchor = $mod.TTMSFNCTreeViewNodeAnchor.$new();
      this.FDoNodeCheck = $mod.TTMSFNCTreeViewNodeCheck.$new();
      this.FDoNodeExpand = false;
      this.FDoNodeExtra = false;
      this.FDoNodeTitleExtra = false;
      this.FScrolling = false;
      this.FMouseUp = false;
      this.FAnimateVerticalPos = false;
      this.FAnimateHorizontalPos = false;
      this.FAnimateVerticalOffset = false;
      this.FAnimating = false;
      this.FSpX = 0.0;
      this.FSpY = 0.0;
      this.FScrollX = 0.0;
      this.FScrollY = 0.0;
      this.FDownX = 0.0;
      this.FDownY = 0.0;
      this.FMouseX = 0.0;
      this.FMouseY = 0.0;
      this.FSizeX = 0.0;
      this.FScrollVTo = 0.0;
      this.FScrollHTo = 0.0;
      this.FTimeStart = 0.0;
      this.FTimeStop = 0.0;
      this.FAnimateTimer = null;
      this.FNodeCache = null;
      this.FColumnsTopCache = null;
      this.FColumnsBottomCache = null;
      this.FGroupsTopCache = null;
      this.FGroupsBottomCache = null;
      this.FNodeDisplay = null;
      this.FColumnsTopDisplay = null;
      this.FColumnsBottomDisplay = null;
      this.FGroupsTopDisplay = null;
      this.FGroupsBottomDisplay = null;
      this.FNodesAppearance = null;
      this.FColumnsCaching = false;
      this.FGroupsCaching = false;
      this.FColumnStretchingActive = false;
      this.FColumnStretchingApplied = false;
      this.FGroupsAppearance = null;
      this.FColumnsAppearance = null;
      this.FOnAfterDrawGroup = null;
      this.FOnNodeCompare = null;
      this.FOnBeforeSizeColumn = null;
      this.FOnAfterSizeColumn = null;
      this.FOnBeforeDrawColumn = null;
      this.FOnBeforeDrawColumnHeader = null;
      this.FOnAfterDrawColumnHeader = null;
      this.FOnBeforeDrawNode = null;
      this.FOnAfterDrawColumn = null;
      this.FOnBeforeDrawGroup = null;
      this.FOnAfterDrawNode = null;
      this.FOnBeforeDrawNodeText = null;
      this.FOnBeforeDrawNodeTitle = null;
      this.FOnGetNodeHeight = null;
      this.FOnAfterDrawColumnText = null;
      this.FOnBeforeDrawGroupText = null;
      this.FOnAfterDrawNodeText = null;
      this.FOnAfterDrawNodeTitle = null;
      this.FOnAfterDrawGroupText = null;
      this.FOnBeforeDrawColumnText = null;
      this.FInteraction = null;
      this.FOnAfterUpdateNode = null;
      this.FOnBeforeUpdateNode = null;
      this.FOnAfterUnCheckNode = null;
      this.FOnBeforeUnCheckNode = null;
      this.FOnAfterCheckNode = null;
      this.FOnBeforeCheckNode = null;
      this.FOnAfterExpandNode = null;
      this.FOnBeforeExpandNode = null;
      this.FOnAfterCollapseNode = null;
      this.FOnBeforeCollapseNode = null;
      this.FOnBeforeSelectNode = null;
      this.FOnAfterSelectNode = null;
      this.FOnBeforeSelectAllNodes = null;
      this.FOnAfterSelectAllNodes = null;
      this.FOnNodeClick = null;
      this.FOnNodeValueClick = null;
      this.FOnNodeDblClick = null;
      this.FOnGetNodeText = null;
      this.FOnGetNodeTitle = null;
      this.FOnGetColumnText = null;
      this.FOnGetGroupText = null;
      this.FOnNodeAnchorClick = null;
      this.FOnVScroll = null;
      this.FOnHScroll = null;
      this.FOnBeforeDrawColumnEmptySpace = null;
      this.FOnAfterDrawColumnEmptySpace = null;
      this.FOnBeforeDrawGroupEmptySpace = null;
      this.FOnAfterDrawGroupEmptySpace = null;
      this.FOnGetNumberOfNodes = null;
      this.FOnIsNodeExpanded = null;
      this.FOnIsNodeEnabled = null;
      this.FOnIsNodeVisible = null;
      this.FSelectedNodes = null;
      this.FOnGetNodeDisabledColor = null;
      this.FOnGetNodeTextColor = null;
      this.FOnGetNodeTitleColor = null;
      this.FOnGetNodeSelectedColor = null;
      this.FOnGetNodeColor = null;
      this.FOnGetNodeDisabledTextColor = null;
      this.FOnGetNodeSelectedTextColor = null;
      this.FOnGetNodeDisabledTitleColor = null;
      this.FOnGetNodeSelectedTitleColor = null;
      this.FOnIsNodeExtended = null;
      this.FOnGetNodeIcon = null;
      this.FOnGetColumnWordWrapping = null;
      this.FOnGetColumnVerticalTextAlign = null;
      this.FOnGetColumnTrimming = null;
      this.FOnGetColumnHorizontalTextAlign = null;
      this.FOnGetNodeWordWrapping = null;
      this.FOnGetNodeVerticalTextAlign = null;
      this.FOnGetNodeTrimming = null;
      this.FOnGetNodeHorizontalTextAlign = null;
      this.FOnIsNodeChecked = null;
      this.FOnBeforeDrawNodeIcon = null;
      this.FOnBeforeDrawNodeExpand = null;
      this.FOnAfterDrawNodeIcon = null;
      this.FOnAfterDrawNodeExpand = null;
      this.FOnGetNodeCheckType = null;
      this.FOnAfterDrawNodeCheck = null;
      this.FOnBeforeDrawNodeCheck = null;
      this.FColumnStroke = null;
      this.FOnAfterDrawNodeColumn = null;
      this.FOnBeforeDrawNodeColumn = null;
      this.FOnBeforeUnSelectNode = null;
      this.FOnAfterUnSelectNode = null;
      this.FOnAfterOpenInplaceEditor = null;
      this.FOnGetInplaceEditor = null;
      this.FOnCloseInplaceEditor = null;
      this.FOnBeforeOpenInplaceEditor = null;
      this.FOnNodeChanged = null;
      this.FOnCustomizeInplaceEditor = null;
      this.FOnGetInplaceEditorRect = null;
      this.FOnBeforeReorderNode = null;
      this.FOnAfterReorderNode = null;
      this.FOnAfterDropNode = null;
      this.FOnBeforeDropNode = null;
      this.FOnAfterCutToClipboard = null;
      this.FOnBeforePasteFromClipboard = null;
      this.FOnBeforeCopyToClipboard = null;
      this.FOnAfterPasteFromClipboard = null;
      this.FOnBeforeCutToClipboard = null;
      this.FOnAfterCopyToClipboard = null;
      this.FOnNeedFilterDropDownData = null;
      this.FOnFilterSelect = null;
      this.FOnCustomReorder = null;
      this.FOnCustomDragDrop = null;
      this.FOnCustomDragOver = null;
      this.FOnCustomCopyToClipboard = null;
      this.FOnCustomCutToClipboard = null;
      this.FOnCustomPasteFromClipboard = null;
      this.FOnCustomColumnSort = null;
      this.FOnCustomLookup = null;
      this.FOnBeforeDrawSortIndicator = null;
      this.FOnAfterDrawSortIndicator = null;
      this.FAdapter = null;
      this.FOnGetNodeSides = null;
      this.FOnGetNodeExtraSize = null;
      this.FOnGetNodeTitleExtraSize = null;
      this.FOnAfterDrawNodeExtra = null;
      this.FOnBeforeDrawNodeExtra = null;
      this.FOnDrawNodeExtra = null;
      this.FOnGetNodeTitleTrimming = null;
      this.FOnGetNodeTitleHorizontalTextAlign = null;
      this.FOnGetNodeTitleWordWrapping = null;
      this.FOnGetNodeTitleVerticalTextAlign = null;
      this.FOnNodeTitleAnchorClick = null;
      this.FOnGetNodeExpanded = null;
      this.FOnBeforeDrawNodeTitleExtra = null;
      this.FOnAfterDrawNodeTitleExtra = null;
      this.FOnDrawNodeTitleExtra = null;
      this.FOnNodeMouseEnter = null;
      this.FOnNodeMouseLeave = null;
      this.FOnGetNodeIconSize = null;
      this.FOnColumnAnchorClick = null;
      this.FOnFocusedNodeChanged = null;
      this.FOnGetNodeData = null;
      this.FOnAfterSortNodes = null;
      this.FOnBeforeSortNodes = null;
      this.FGlobalFont = null;
      this.FOnGetNodeRounding = null;
      this.FOnGetNodeDisabledStrokeColor = null;
      this.FOnGetNodeSelectedStrokeColor = null;
      this.FOnGetNodeStrokeColor = null;
      this.FOnGetHTMLTemplateValue = null;
      this.FOnGetHTMLTemplate = null;
      this.FOnCustomizeFilterListBox = null;
      this.FPrecalculateItems = false;
      this.FDefaultViewJSONOptions = null;
      this.FOnAfterAddJSONNode = null;
      this.FOnBeforeAddJSONNode = null;
      this.FCheckStartSize = 0;
    };
    this.$final = function () {
      this.FPrevDSP = undefined;
      this.FDragBitmap = undefined;
      this.FFilterPopup = undefined;
      this.FFilterListBox = undefined;
      this.FFilterTimer = undefined;
      this.FInplaceEditorClass = undefined;
      this.FInplaceEditor = undefined;
      this.FOldInplaceEditor = undefined;
      this.FUpdateNode = undefined;
      this.FCopyNodes = undefined;
      this.FDragTimer = undefined;
      this.FDownNode = undefined;
      this.FFocusedNode = undefined;
      this.FDragNode = undefined;
      this.FDoNodeAnchor = undefined;
      this.FDoNodeTitleAnchor = undefined;
      this.FDoNodeCheck = undefined;
      this.FAnimateTimer = undefined;
      this.FNodeCache = undefined;
      this.FColumnsTopCache = undefined;
      this.FColumnsBottomCache = undefined;
      this.FGroupsTopCache = undefined;
      this.FGroupsBottomCache = undefined;
      this.FNodeDisplay = undefined;
      this.FColumnsTopDisplay = undefined;
      this.FColumnsBottomDisplay = undefined;
      this.FGroupsTopDisplay = undefined;
      this.FGroupsBottomDisplay = undefined;
      this.FNodesAppearance = undefined;
      this.FGroupsAppearance = undefined;
      this.FColumnsAppearance = undefined;
      this.FOnAfterDrawGroup = undefined;
      this.FOnNodeCompare = undefined;
      this.FOnBeforeSizeColumn = undefined;
      this.FOnAfterSizeColumn = undefined;
      this.FOnBeforeDrawColumn = undefined;
      this.FOnBeforeDrawColumnHeader = undefined;
      this.FOnAfterDrawColumnHeader = undefined;
      this.FOnBeforeDrawNode = undefined;
      this.FOnAfterDrawColumn = undefined;
      this.FOnBeforeDrawGroup = undefined;
      this.FOnAfterDrawNode = undefined;
      this.FOnBeforeDrawNodeText = undefined;
      this.FOnBeforeDrawNodeTitle = undefined;
      this.FOnGetNodeHeight = undefined;
      this.FOnAfterDrawColumnText = undefined;
      this.FOnBeforeDrawGroupText = undefined;
      this.FOnAfterDrawNodeText = undefined;
      this.FOnAfterDrawNodeTitle = undefined;
      this.FOnAfterDrawGroupText = undefined;
      this.FOnBeforeDrawColumnText = undefined;
      this.FInteraction = undefined;
      this.FOnAfterUpdateNode = undefined;
      this.FOnBeforeUpdateNode = undefined;
      this.FOnAfterUnCheckNode = undefined;
      this.FOnBeforeUnCheckNode = undefined;
      this.FOnAfterCheckNode = undefined;
      this.FOnBeforeCheckNode = undefined;
      this.FOnAfterExpandNode = undefined;
      this.FOnBeforeExpandNode = undefined;
      this.FOnAfterCollapseNode = undefined;
      this.FOnBeforeCollapseNode = undefined;
      this.FOnBeforeSelectNode = undefined;
      this.FOnAfterSelectNode = undefined;
      this.FOnBeforeSelectAllNodes = undefined;
      this.FOnAfterSelectAllNodes = undefined;
      this.FOnNodeClick = undefined;
      this.FOnNodeValueClick = undefined;
      this.FOnNodeDblClick = undefined;
      this.FOnGetNodeText = undefined;
      this.FOnGetNodeTitle = undefined;
      this.FOnGetColumnText = undefined;
      this.FOnGetGroupText = undefined;
      this.FOnNodeAnchorClick = undefined;
      this.FOnVScroll = undefined;
      this.FOnHScroll = undefined;
      this.FOnBeforeDrawColumnEmptySpace = undefined;
      this.FOnAfterDrawColumnEmptySpace = undefined;
      this.FOnBeforeDrawGroupEmptySpace = undefined;
      this.FOnAfterDrawGroupEmptySpace = undefined;
      this.FOnGetNumberOfNodes = undefined;
      this.FOnIsNodeExpanded = undefined;
      this.FOnIsNodeEnabled = undefined;
      this.FOnIsNodeVisible = undefined;
      this.FSelectedNodes = undefined;
      this.FOnGetNodeDisabledColor = undefined;
      this.FOnGetNodeTextColor = undefined;
      this.FOnGetNodeTitleColor = undefined;
      this.FOnGetNodeSelectedColor = undefined;
      this.FOnGetNodeColor = undefined;
      this.FOnGetNodeDisabledTextColor = undefined;
      this.FOnGetNodeSelectedTextColor = undefined;
      this.FOnGetNodeDisabledTitleColor = undefined;
      this.FOnGetNodeSelectedTitleColor = undefined;
      this.FOnIsNodeExtended = undefined;
      this.FOnGetNodeIcon = undefined;
      this.FOnGetColumnWordWrapping = undefined;
      this.FOnGetColumnVerticalTextAlign = undefined;
      this.FOnGetColumnTrimming = undefined;
      this.FOnGetColumnHorizontalTextAlign = undefined;
      this.FOnGetNodeWordWrapping = undefined;
      this.FOnGetNodeVerticalTextAlign = undefined;
      this.FOnGetNodeTrimming = undefined;
      this.FOnGetNodeHorizontalTextAlign = undefined;
      this.FOnIsNodeChecked = undefined;
      this.FOnBeforeDrawNodeIcon = undefined;
      this.FOnBeforeDrawNodeExpand = undefined;
      this.FOnAfterDrawNodeIcon = undefined;
      this.FOnAfterDrawNodeExpand = undefined;
      this.FOnGetNodeCheckType = undefined;
      this.FOnAfterDrawNodeCheck = undefined;
      this.FOnBeforeDrawNodeCheck = undefined;
      this.FColumnStroke = undefined;
      this.FOnAfterDrawNodeColumn = undefined;
      this.FOnBeforeDrawNodeColumn = undefined;
      this.FOnBeforeUnSelectNode = undefined;
      this.FOnAfterUnSelectNode = undefined;
      this.FOnAfterOpenInplaceEditor = undefined;
      this.FOnGetInplaceEditor = undefined;
      this.FOnCloseInplaceEditor = undefined;
      this.FOnBeforeOpenInplaceEditor = undefined;
      this.FOnNodeChanged = undefined;
      this.FOnCustomizeInplaceEditor = undefined;
      this.FOnGetInplaceEditorRect = undefined;
      this.FOnBeforeReorderNode = undefined;
      this.FOnAfterReorderNode = undefined;
      this.FOnAfterDropNode = undefined;
      this.FOnBeforeDropNode = undefined;
      this.FOnAfterCutToClipboard = undefined;
      this.FOnBeforePasteFromClipboard = undefined;
      this.FOnBeforeCopyToClipboard = undefined;
      this.FOnAfterPasteFromClipboard = undefined;
      this.FOnBeforeCutToClipboard = undefined;
      this.FOnAfterCopyToClipboard = undefined;
      this.FOnNeedFilterDropDownData = undefined;
      this.FOnFilterSelect = undefined;
      this.FOnCustomReorder = undefined;
      this.FOnCustomDragDrop = undefined;
      this.FOnCustomDragOver = undefined;
      this.FOnCustomCopyToClipboard = undefined;
      this.FOnCustomCutToClipboard = undefined;
      this.FOnCustomPasteFromClipboard = undefined;
      this.FOnCustomColumnSort = undefined;
      this.FOnCustomLookup = undefined;
      this.FOnBeforeDrawSortIndicator = undefined;
      this.FOnAfterDrawSortIndicator = undefined;
      this.FAdapter = undefined;
      this.FOnGetNodeSides = undefined;
      this.FOnGetNodeExtraSize = undefined;
      this.FOnGetNodeTitleExtraSize = undefined;
      this.FOnAfterDrawNodeExtra = undefined;
      this.FOnBeforeDrawNodeExtra = undefined;
      this.FOnDrawNodeExtra = undefined;
      this.FOnGetNodeTitleTrimming = undefined;
      this.FOnGetNodeTitleHorizontalTextAlign = undefined;
      this.FOnGetNodeTitleWordWrapping = undefined;
      this.FOnGetNodeTitleVerticalTextAlign = undefined;
      this.FOnNodeTitleAnchorClick = undefined;
      this.FOnGetNodeExpanded = undefined;
      this.FOnBeforeDrawNodeTitleExtra = undefined;
      this.FOnAfterDrawNodeTitleExtra = undefined;
      this.FOnDrawNodeTitleExtra = undefined;
      this.FOnNodeMouseEnter = undefined;
      this.FOnNodeMouseLeave = undefined;
      this.FOnGetNodeIconSize = undefined;
      this.FOnColumnAnchorClick = undefined;
      this.FOnFocusedNodeChanged = undefined;
      this.FOnGetNodeData = undefined;
      this.FOnAfterSortNodes = undefined;
      this.FOnBeforeSortNodes = undefined;
      this.FGlobalFont = undefined;
      this.FOnGetNodeRounding = undefined;
      this.FOnGetNodeDisabledStrokeColor = undefined;
      this.FOnGetNodeSelectedStrokeColor = undefined;
      this.FOnGetNodeStrokeColor = undefined;
      this.FOnGetHTMLTemplateValue = undefined;
      this.FOnGetHTMLTemplate = undefined;
      this.FOnCustomizeFilterListBox = undefined;
      this.FDefaultViewJSONOptions = undefined;
      this.FOnAfterAddJSONNode = undefined;
      this.FOnBeforeAddJSONNode = undefined;
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.$final.call(this);
    };
    this.SetNodesAppearance = function (Value) {
      if (this.FNodesAppearance !== Value) this.FNodesAppearance.Assign(Value);
    };
    this.SetGroupsAppearance = function (Value) {
      if (this.FGroupsAppearance !== Value) this.FGroupsAppearance.Assign(Value);
    };
    this.SetColumnsAppearance = function (Value) {
      if (this.FColumnsAppearance !== Value) this.FColumnsAppearance.Assign(Value);
    };
    this.SetInteraction = function (Value) {
      if (this.FInteraction !== Value) this.FInteraction.Assign(Value);
    };
    this.GetFocusedNode = function () {
      var Result = null;
      var n = null;
      Result = null;
      n = this.FFocusedNode;
      if (n != null) Result = n.FNode;
      return Result;
    };
    this.GetFocusedVirtualNode = function () {
      var Result = null;
      Result = this.FFocusedNode;
      return Result;
    };
    this.GetSelNode = function (AIndex) {
      var Result = null;
      var v = null;
      Result = null;
      v = this.GetSelVirtualNode(AIndex);
      if (v != null) Result = v.FNode;
      return Result;
    };
    this.GetSelVirtualNode = function (AIndex) {
      var Result = null;
      Result = null;
      if ((AIndex >= 0) && (AIndex <= (this.SelectedVirtualNodeCount() - 1))) Result = this.FSelectedNodes.GetItem(AIndex);
      return Result;
    };
    this.SetColumnStroke = function (Value) {
      if (this.FColumnStroke !== Value) this.FColumnStroke.Assign(Value);
    };
    this.SetFocusedNode = function (Value) {
      if (Value != null) {
        this.SetFocusedVirtualNode(Value.FVirtualNode)}
       else this.SetFocusedVirtualNode(null);
    };
    this.SetFocusedVirtualNode = function (Value) {
      this.FFocusedNode = Value;
      this.Invalidate();
    };
    this.SetSortColumn = function (Value) {
      if (this.FSortColumn !== Value) {
        this.FSortColumn = Value;
        this.Invalidate();
      };
    };
    this.HandleFilterTimer = function (Sender) {
      var fd = null;
      var cnd = "";
      var i = 0;
      var filtercol = 0;
      if (this.FFilterListBox != null) {
        filtercol = this.FFilterListBox.FTag$1;
        if ((filtercol >= 0) && (filtercol <= (this.FColumns.GetCount() - 1))) {
          if (this.FColumns.GetItem$1(filtercol).FFiltering.FMultiColumn) {
            for (var $l = this.FFilter.GetCount() - 1; $l >= 0; $l--) {
              i = $l;
              if (this.FFilter.GetItem$1(i).FColumn === filtercol) this.FFilter.Delete(i);
            };
          } else this.FFilter.Clear();
          fd = this.FFilter.Add$1();
          fd.FColumn = filtercol;
          cnd = "";
          if ((this.FFilterListBox.GetItemIndex() >= 0) && (this.FFilterListBox.GetItemIndex() <= (this.FFilterListBox.FItems.GetCount() - 1))) cnd = this.FFilterListBox.FItems.Get(this.FFilterListBox.GetItemIndex());
          if (pas.System.Pos(" ",cnd) > 0) cnd = '"' + cnd + '"';
          this.FFilterPopup.SetIsOpen(false);
          if (cnd === rtl.getResStr($mod,"sTMSFNCTreeViewFilterAll")) {
            this.RemoveFilters();
          } else {
            this.DoFilterSelect(fd.FColumn,{get: function () {
                return cnd;
              }, set: function (v) {
                cnd = v;
              }});
            fd.FCondition = cnd;
            this.ApplyFilter();
          };
        };
      };
      this.FFilterTimer.SetEnabled(false);
    };
    this.SetAdapter = function (Value) {
      if (Value != null) Value.SetTreeView(this);
      this.FAdapter = Value;
    };
    this.SetSelectedNode = function (Value) {
      if (Value != null) {
        this.SetSelectedVirtualNode(Value.FVirtualNode)}
       else this.SetSelectedVirtualNode(null);
    };
    this.SetSelectedVirtualNode = function (Value) {
      this.SetFocusedVirtualNode(Value);
      this.SelectVirtualNode(Value);
    };
    this.SetCompactMode = function (Value) {
      if (this.FCompactMode !== Value) {
        this.FCompactMode = Value;
        this.UpdateTreeView();
      };
    };
    this.GetSelectedVirtualNodeRow = function () {
      var Result = 0;
      var n = null;
      Result = -1;
      n = this.GetFocusedVirtualNode();
      if (n != null) Result = n.FRow;
      return Result;
    };
    this.GetTopRow = function () {
      var Result = 0;
      Result = this.GetFirstVisibleVirtualNodeRow();
      return Result;
    };
    this.SetTopRow = function (Value) {
      this.ScrollToVirtualNodeRow(Value,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,true);
    };
    this.GetBottomRow = function () {
      var Result = 0;
      Result = this.GetLastVisibleVirtualNodeRow();
      return Result;
    };
    this.SetGlobalFont = function (Value) {
      this.FGlobalFont.Assign(Value);
    };
    this.SetDefaultViewJSONOptions = function (Value) {
      this.FDefaultViewJSONOptions = Value;
    };
    this.DataGetItemIndex = function () {
      var Result = 0;
      Result = this.GetSelectedVirtualNodeRow();
      return Result;
    };
    this.DataSetItemIndex = function (AValue) {
      this.ScrollToVirtualNodeRow(AValue,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
      this.SelectVirtualNodeByRow(AValue);
    };
    this.ChangeDPIScale = function (M, D) {
      var I = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.CreateCheckBoxBitmaps();
      this.CreateRadioButtonBitmaps();
      this.FNodesAppearance.SetLevelIndent(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FNodesAppearance.FLevelIndent,M,D));
      this.FNodesAppearance.SetExpandWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FNodesAppearance.FExpandWidth,M,D));
      this.FNodesAppearance.SetExpandHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FNodesAppearance.FExpandHeight,M,D));
      this.FColumnsAppearance.SetTopSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FColumnsAppearance.FTopSize,M,D));
      this.FColumnsAppearance.SetBottomSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FColumnsAppearance.FBottomSize,M,D));
      this.FGroupsAppearance.SetTopSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FGroupsAppearance.FTopSize,M,D));
      this.FGroupsAppearance.SetBottomSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FGroupsAppearance.FBottomSize,M,D));
      this.FColumnsAppearance.FBottomFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumnsAppearance.FBottomFont.FHeight,M,D));
      this.FColumnsAppearance.FTopFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumnsAppearance.FTopFont.FHeight,M,D));
      this.FGroupsAppearance.FBottomFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FGroupsAppearance.FBottomFont.FHeight,M,D));
      this.FGroupsAppearance.FTopFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FGroupsAppearance.FTopFont.FHeight,M,D));
      this.FNodesAppearance.FExtendedFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FNodesAppearance.FExtendedFont.FHeight,M,D));
      this.FNodesAppearance.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FNodesAppearance.FFont.FHeight,M,D));
      this.FNodesAppearance.SetFixedHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FNodesAppearance.FFixedHeight,M,D));
      this.FNodesAppearance.SetVariableMinimumHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FNodesAppearance.FVariableMinimumHeight,M,D));
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FColumns.GetItem$1(I).SetWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FColumns.GetItem$1(I).FWidth,M,D));
        this.FColumns.GetItem$1(I).SetMinimumWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FColumns.GetItem$1(I).FMinimumWidth,M,D));
        this.FColumns.GetItem$1(I).FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FFont.FHeight,M,D));
        this.FColumns.GetItem$1(I).FTitleFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FTitleFont.FHeight,M,D));
        this.FColumns.GetItem$1(I).FTopFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FTopFont.FHeight,M,D));
        this.FColumns.GetItem$1(I).FBottomFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FBottomFont.FHeight,M,D));
        this.FColumns.GetItem$1(I).SetExpandingButtonSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FColumns.GetItem$1(I).FExpandingButtonSize,M,D));
        this.FColumns.GetItem$1(I).FFiltering.SetButtonSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FColumns.GetItem$1(I).FFiltering.FButtonSize,M,D));
        this.FColumns.GetItem$1(I).FFiltering.FDropDownWidth = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FFiltering.FDropDownWidth,M,D);
        this.FColumns.GetItem$1(I).FFiltering.FDropDownHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FFiltering.FDropDownHeight,M,D);
      };
      this.EndUpdate();
    };
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCCustomTreeView);
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFill.SetColor(c);
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FStroke.SetColor(c);
        this.FColumnsAppearance.FTopStroke.SetColor(c);
        this.FColumnsAppearance.FBottomStroke.SetColor(c);
        this.FGroupsAppearance.FTopStroke.SetColor(c);
        this.FGroupsAppearance.FBottomStroke.SetColor(c);
        this.FNodesAppearance.FExtendedFill.SetColor(c);
        this.FNodesAppearance.FExtendedStroke.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FColumnsAppearance.FTopFill.SetColor(c);
        this.FColumnsAppearance.FTopFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FColumnsAppearance.FBottomFill.SetColor(c);
        this.FColumnsAppearance.FBottomFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FGroupsAppearance.FTopFill.SetColor(c);
        this.FGroupsAppearance.FTopFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FGroupsAppearance.FBottomFill.SetColor(c);
        this.FGroupsAppearance.FBottomFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColorTo({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FColumnsAppearance.FTopFill.SetColorTo(c);
        this.FColumnsAppearance.FTopFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FColumnsAppearance.FBottomFill.SetColorTo(c);
        this.FColumnsAppearance.FBottomFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FGroupsAppearance.FTopFill.SetColorTo(c);
        this.FGroupsAppearance.FTopFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FGroupsAppearance.FBottomFill.SetColorTo(c);
        this.FGroupsAppearance.FBottomFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FNodesAppearance.FSelectedFill.SetColor(c);
        this.FNodesAppearance.FSelectedStroke.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FNodesAppearance.FFont.SetColor(c);
        this.FNodesAppearance.SetExtendedFontColor(c);
        this.FColumnsAppearance.FTopFont.SetColor(c);
        this.FColumnsAppearance.FBottomFont.SetColor(c);
        this.FGroupsAppearance.FTopFont.SetColor(c);
        this.FGroupsAppearance.FBottomFont.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleAlternativeTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FNodesAppearance.SetSelectedFontColor(c);
        this.FNodesAppearance.SetSelectedTitleFontColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFill.SetColor(c);
    };
    this.DoEnter = function () {
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      this.Invalidate();
    };
    this.DoExit = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.DoExit.call(this);
      this.Invalidate();
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.UpdateControlAfterResize.call(this);
      if (this.FAdapter != null) this.FAdapter.UpdateBounds();
    };
    this.ResetToDefaultStyle = function () {
      this.BeginUpdate();
      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(this.FColumnsAppearance.FTopFont,14,1);
      this.FColumnsAppearance.FTopFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      this.FColumnsAppearance.FTopFill.SetColor(0xF9F2EE);
      this.FColumnsAppearance.FTopFont.SetColor(0x454545);
      this.FNodesAppearance.FSelectedFill.SetColor(0xFCF8F6);
      this.FNodesAppearance.FSelectedStroke.SetColor(0xEF9B2D);
      this.FNodesAppearance.FFont.SetColor(0x7A7A7A);
      this.FNodesAppearance.SetSelectedFontColor(0x454545);
      this.FNodesAppearance.FSelectedStroke.SetColor(0xEF9B2D);
      this.FNodesAppearance.SetShowFocus(false);
      this.FNodesAppearance.SetExpandWidth(this.ScalePaintValue(18));
      this.FNodesAppearance.SetExpandHeight(this.ScalePaintValue(18));
      this.FNodesAppearance.SetShowFocus(false);
      this.FNodesAppearance.FSelectedStroke.SetWidth(pas.System.Trunc(this.ScalePaintValue$1(2.0)));
      this.FColumnsAppearance.SetTopSize(this.ScalePaintValue(36));
      this.FColumnsAppearance.FTopStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FFill.SetColor(16777215);
      this.FStroke.SetColor(11119017);
      this.FNodesAppearance.FExtendedFill.SetColor(16053492);
      this.FColumnsAppearance.FBottomFill.SetColor(this.FColumnsAppearance.FTopFill.FColor);
      this.FColumnsAppearance.FTopStroke.SetColor(11119017);
      this.FColumnsAppearance.FBottomStroke.SetColor(11119017);
      this.FColumnsAppearance.FBottomFont.SetColor(this.FColumnsAppearance.FTopFont.FColor);
      this.FGroupsAppearance.FTopFill.SetColor(16777215);
      this.FGroupsAppearance.FBottomFill.SetColor(16777215);
      this.FGroupsAppearance.FTopStroke.SetColor(11119017);
      this.FGroupsAppearance.FBottomStroke.SetColor(11119017);
      this.FGroupsAppearance.FTopFont.SetColor(0);
      this.FGroupsAppearance.FBottomFont.SetColor(0);
      this.FColumnsAppearance.FTopFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FColumnsAppearance.FBottomFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FColumnsAppearance.FBottomStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FGroupsAppearance.FTopFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FGroupsAppearance.FBottomFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      this.FGroupsAppearance.FTopStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FGroupsAppearance.FBottomStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FNodesAppearance.SetExtendedFontColor(this.FColumnsAppearance.FTopFont.FColor);
      this.FColumnsAppearance.FBottomFont.SetColor(this.FColumnsAppearance.FTopFont.FColor);
      this.FGroupsAppearance.FTopFont.SetColor(this.FColumnsAppearance.FTopFont.FColor);
      this.FGroupsAppearance.FBottomFont.SetColor(this.FColumnsAppearance.FTopFont.FColor);
      this.EndUpdate();
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.Notification.apply(this,arguments);
      if ((AComponent === this.FAdapter) && (Operation === pas.Classes.TOperation.opRemove)) this.FAdapter = null;
    };
    this.InitializeColumnSorting = function (AColumn, ASortMode) {
      var I = 0;
      this.FUpdateCount$1 = this.FUpdateCount$1 + 1;
      this.FSortColumn = AColumn;
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        var $tmp = ASortMode;
        if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmAscending) {
          this.FColumns.GetItem$1(I).SetSortKind(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskAscending)}
         else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmDescending) this.FColumns.GetItem$1(I).SetSortKind(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskDescending);
      };
      this.FUpdateCount$1 = this.FUpdateCount$1 - 1;
    };
    this.AutoSizeColumnInternal = function (ACol, AUpdate, ACallEventHandlers) {
      var I = 0;
      var rcalc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var v = null;
      var g = null;
      var strc = "";
      var strt = "";
      var ww = false;
      var wwt = false;
      var maxw = 0.0;
      var c = false;
      var colps = 0.0;
      var def = false;
      var col = null;
      var hs = 0.0;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if ((ACol >= 0) && (ACol <= (this.FColumnCount - 1)) && !this.FColumnsAppearance.FStretch && this.FNodeListBuild) {
        hs = this.GetHorizontalScrollPosition();
        maxw = 0;
        colps = this.GetColPos(ACol);
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.FBitmapContainer = this.GetBitmapContainer();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        try {
          try {
            if (!g.BeginScene()) return;
          } catch ($e) {
            return;
          };
          def = true;
          col = null;
          if ((ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) {
            col = this.FColumns.GetItem$1(ACol);
            if (!col.FUseDefaultAppearance) def = false;
          };
          if ($mod.TTMSFNCTreeViewColumnsLayout.tclTop in this.FColumnsAppearance.FLayouts) {
            strc = this.GetColumnText(ACol);
            this.DoGetColumnText(ACol,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop,{get: function () {
                return strc;
              }, set: function (v) {
                strc = v;
              }});
            if (def) {
              g.FFont.Assign(this.FColumnsAppearance.FTopFont)}
             else g.FFont.Assign(col.FTopFont);
            rcalc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000));
            rcalc.$assign(g.CalculateText(strc,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rcalc),false,true));
            rcalc.Right = rcalc.Right + this.ScalePaintValue(4);
            if ((rcalc.Right - rcalc.Left) > maxw) maxw = rcalc.Right - rcalc.Left;
          };
          if ($mod.TTMSFNCTreeViewColumnsLayout.tclBottom in this.FColumnsAppearance.FLayouts) {
            strc = this.GetColumnText(ACol);
            this.DoGetColumnText(ACol,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom,{get: function () {
                return strc;
              }, set: function (v) {
                strc = v;
              }});
            if (def) {
              g.FFont.Assign(this.FColumnsAppearance.FBottomFont)}
             else g.FFont.Assign(col.FBottomFont);
            rcalc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000));
            rcalc.$assign(g.CalculateText(strc,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rcalc),false,true));
            rcalc.Right = rcalc.Right + this.ScalePaintValue(4);
            if ((rcalc.Right - rcalc.Left) > maxw) maxw = rcalc.Right - rcalc.Left;
          };
          for (var $l = this.StartRow(), $end = this.StopRow(); $l <= $end; $l++) {
            I = $l;
            v = this.GetVisibleNodeForIndex(I);
            if (v != null) {
              strc = "";
              this.DoGetNodeText(v,ACol,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return strc;
                }, set: function (v) {
                  strc = v;
                }});
              ww = false;
              if ((ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) ww = this.FColumns.GetItem$1(ACol).FWordWrapping;
              this.DoGetNodeWordWrapping(v,ACol,{get: function () {
                  return ww;
                }, set: function (v) {
                  ww = v;
                }});
              rcalc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000));
              rcalc.$assign(g.CalculateText(strc,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rcalc),false,true));
              rcalc.Right = rcalc.Right + this.ScalePaintValue(4);
              if (ACol <= (rtl.length(v.FBitmapRects) - 1)) rcalc.Right = ((rcalc.Right + v.FBitmapRects[ACol].Right + hs) - colps) + this.ScalePaintValue(3);
              if ((rcalc.Right - rcalc.Left) > maxw) maxw = rcalc.Right - rcalc.Left;
              strt = "";
              this.DoGetNodeTitle(v,ACol,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return strt;
                }, set: function (v) {
                  strt = v;
                }});
              wwt = false;
              if ((ACol >= 0) && (ACol <= (this.FColumns.GetCount() - 1))) wwt = this.FColumns.GetItem$1(ACol).FTitleWordWrapping;
              this.DoGetNodeTitleWordWrapping(v,ACol,{get: function () {
                  return wwt;
                }, set: function (v) {
                  wwt = v;
                }});
              rcalc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000));
              rcalc.$assign(g.CalculateText(strt,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rcalc),false,true));
              rcalc.Right = rcalc.Right + this.ScalePaintValue(4);
              if (ACol <= (rtl.length(v.FBitmapRects) - 1)) rcalc.Right = ((rcalc.Right + v.FBitmapRects[ACol].Right + hs) - colps) + this.ScalePaintValue(3);
              if ((rcalc.Right - rcalc.Left) > maxw) maxw = rcalc.Right - rcalc.Left;
            };
          };
          g.EndScene();
        } finally {
          g = rtl.freeLoc(g);
        };
        maxw = pas.System.Int(maxw);
        c = true;
        if (ACallEventHandlers) this.DoBeforeSizeColumn(ACol,this.GetColWidths(ACol),{get: function () {
            return maxw;
          }, set: function (v) {
            maxw = v;
          }},{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        if (c) {
          this.SetColWidths(ACol,maxw);
          if (ACallEventHandlers) this.DoAfterSizeColumn(ACol,maxw);
          if (AUpdate) {
            this.UpdateTreeView();
            this.Invalidate();
          };
        };
      };
    };
    this.DoNodeCompare = function (ANode1, ANode2, AColumn, ACompareResult) {
      if (this.FOnNodeCompare != null) this.FOnNodeCompare(this,ANode1,ANode2,AColumn,ACompareResult);
    };
    this.SetFonts = function (ASetType) {
      this.BeginUpdate();
      this.FGlobalFont.ApplyChange(this.FNodesAppearance.FFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FNodesAppearance.FExtendedFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FNodesAppearance.FTitleFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FColumnsAppearance.FTopFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FColumnsAppearance.FBottomFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FGroupsAppearance.FTopFont,ASetType);
      this.FGlobalFont.ApplyChange(this.FGroupsAppearance.FBottomFont,ASetType);
      if (ASetType === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCAppearanceGlobalFontType.aftColor) {
        this.FNodesAppearance.SetSelectedFontColor(this.FGlobalFont.FColor);
        this.FNodesAppearance.SetExtendedFontColor(this.FGlobalFont.FColor);
        this.FNodesAppearance.SetSelectedTitleFontColor(this.FGlobalFont.FColor);
      };
      this.EndUpdate();
    };
    this.ExportNotification = function (AState, ARow) {
    };
    this.DoBeforeSortNodes = function (ASortColumn, ASortMode, ACanSort) {
      if (this.FOnBeforeSortNodes != null) this.FOnBeforeSortNodes(this,ASortColumn,ASortMode,ACanSort);
    };
    this.DoAfterSortNodes = function (ASortColumn, ASortMode) {
      if (this.FOnAfterSortNodes != null) this.FOnAfterSortNodes(this,ASortColumn,ASortMode);
    };
    this.DoBeforeDrawSortIndicator = function (AGraphics, ARect, AColumn, ASortIndex, ASortKind, ADefaultDraw) {
      if (this.FOnBeforeDrawSortIndicator != null) this.FOnBeforeDrawSortIndicator(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ASortIndex,ASortKind,ADefaultDraw);
    };
    this.DoAfterDrawSortIndicator = function (AGraphics, ARect, AColumn, ASortIndex, ASortKind) {
      if (this.FOnAfterDrawSortIndicator != null) this.FOnAfterDrawSortIndicator(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ASortIndex,ASortKind);
    };
    this.DoBeforeCutToClipboard = function (ACanCut) {
      if (this.FOnBeforeCutToClipboard != null) this.FOnBeforeCutToClipboard(this,ACanCut);
    };
    this.DoBeforeCopyToClipboard = function (ACanCopy) {
      if (this.FOnBeforeCopyToClipboard != null) this.FOnBeforeCopyToClipboard(this,ACanCopy);
    };
    this.DoBeforePasteFromClipboard = function (ACanPaste) {
      if (this.FOnBeforePasteFromClipboard != null) this.FOnBeforePasteFromClipboard(this,ACanPaste);
    };
    this.DoAfterCutToClipboard = function () {
      if (this.FOnAfterCutToClipboard != null) this.FOnAfterCutToClipboard(this);
    };
    this.DoAfterCopyToClipboard = function () {
      if (this.FOnAfterCopyToClipboard != null) this.FOnAfterCopyToClipboard(this);
    };
    this.DoAfterPasteFromClipboard = function () {
      if (this.FOnAfterPasteFromClipboard != null) this.FOnAfterPasteFromClipboard(this);
    };
    this.DoBeforeReorderNode = function (AFromNode, AToNode, ACanReorder) {
      if (this.FOnBeforeReorderNode != null) this.FOnBeforeReorderNode(this,AFromNode,AToNode,ACanReorder);
    };
    this.DoAfterReorderNode = function (AFromNode, AToNode) {
      if (this.FOnAfterReorderNode != null) this.FOnAfterReorderNode(this,AFromNode,AToNode);
    };
    this.DoBeforeDropNode = function (AFromNode, AToNode, ACanDrop) {
      if (this.FOnBeforeDropNode != null) this.FOnBeforeDropNode(this,AFromNode,AToNode,ACanDrop);
    };
    this.DoAfterDropNode = function (AFromNode, AToNode) {
      if (this.FOnAfterDropNode != null) this.FOnAfterDropNode(this,AFromNode,AToNode);
    };
    this.DoBeforeDrawColumnEmptySpace = function (AGraphics, ARect, ASpace, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawColumnEmptySpace != null) this.FOnBeforeDrawColumnEmptySpace(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ASpace,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawColumnEmptySpace = function (AGraphics, ARect, ASpace) {
      if (this.FOnAfterDrawColumnEmptySpace != null) this.FOnAfterDrawColumnEmptySpace(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ASpace);
    };
    this.DoBeforeDrawGroupEmptySpace = function (AGraphics, ARect, ASpace, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawGroupEmptySpace != null) this.FOnBeforeDrawGroupEmptySpace(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ASpace,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawGroupEmptySpace = function (AGraphics, ARect, ASpace) {
      if (this.FOnAfterDrawGroupEmptySpace != null) this.FOnAfterDrawGroupEmptySpace(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ASpace);
    };
    this.DoBeforeDrawColumnHeader = function (AGraphics, ARect, AColumn, AKind, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawColumnHeader != null) this.FOnBeforeDrawColumnHeader(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AKind,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawColumnHeader = function (AGraphics, ARect, AColumn, AKind) {
      if (this.FOnAfterDrawColumnHeader != null) this.FOnAfterDrawColumnHeader(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AKind);
    };
    this.DoBeforeDrawColumn = function (AGraphics, ARect, AColumn, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawColumn != null) this.FOnBeforeDrawColumn(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawColumn = function (AGraphics, ARect, AColumn) {
      if (this.FOnAfterDrawColumn != null) this.FOnAfterDrawColumn(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn);
    };
    this.DoBeforeDrawNodeColumn = function (AGraphics, ARect, AColumn, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawNodeColumn != null) this.FOnBeforeDrawNodeColumn(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawNodeColumn = function (AGraphics, ARect, AColumn) {
      if (this.FOnAfterDrawNodeColumn != null) this.FOnAfterDrawNodeColumn(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn);
    };
    this.DoBeforeDrawGroup = function (AGraphics, ARect, AGroup, AStartColumn, AEndColumn, AKind, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawGroup != null) this.FOnBeforeDrawGroup(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AGroup,AStartColumn,AEndColumn,AKind,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawGroup = function (AGraphics, ARect, AGroup, AStartColumn, AEndColumn, AKind) {
      if (this.FOnAfterDrawGroup != null) this.FOnAfterDrawGroup(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AGroup,AStartColumn,AEndColumn,AKind);
    };
    this.DoBeforeDrawNode = function (AGraphics, ARect, ANode, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawNode != null) this.FOnBeforeDrawNode(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ANode,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawNode = function (AGraphics, ARect, ANode) {
      if (this.FOnAfterDrawNode != null) this.FOnAfterDrawNode(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ANode);
    };
    this.DoCustomizeFilterListBox = function (AColumn, AListBox) {
      if (this.FOnCustomizeFilterListBox != null) this.FOnCustomizeFilterListBox(this,AColumn,AListBox);
    };
    this.DoGetColumnText = function (AColumn, AKind, AText) {
      if (this.FOnGetColumnText != null) this.FOnGetColumnText(this,AColumn,AKind,AText);
    };
    this.DoBeforeDrawColumnText = function (AGraphics, ARect, AColumn, AKind, AText, AAllow) {
      if (this.FOnBeforeDrawColumnText != null) this.FOnBeforeDrawColumnText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AKind,AText,AAllow);
    };
    this.DoAfterDrawColumnText = function (AGraphics, ARect, AColumn, AKind, AText) {
      if (this.FOnAfterDrawColumnText != null) this.FOnAfterDrawColumnText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AKind,AText);
    };
    this.DoGetGroupText = function (AGroup, AKind, AText) {
      if (this.FOnGetGroupText != null) this.FOnGetGroupText(this,AGroup,AKind,AText);
    };
    this.DoBeforeDrawGroupText = function (AGraphics, ARect, AGroup, AStartColumn, AEndColumn, AKind, AText, AAllow) {
      if (this.FOnBeforeDrawGroupText != null) this.FOnBeforeDrawGroupText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AGroup,AStartColumn,AEndColumn,AKind,AText,AAllow);
    };
    this.DoAfterDrawGroupText = function (AGraphics, ARect, AGroup, AStartColumn, AEndColumn, AKind, AText) {
      if (this.FOnAfterDrawGroupText != null) this.FOnAfterDrawGroupText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AGroup,AStartColumn,AEndColumn,AKind,AText);
    };
    this.DoNodeClick = function (ANode) {
      if (this.FOnNodeClick != null) this.FOnNodeClick(this,ANode);
    };
    this.DoNodeValueClick = function (ANode, AColumn) {
      if (this.FOnNodeValueClick != null) this.FOnNodeValueClick(this,ANode,AColumn);
    };
    this.DoNodeMouseLeave = function (ANode) {
      if (this.FOnNodeMouseLeave != null) this.FOnNodeMouseLeave(this,ANode);
    };
    this.DoNodeMouseEnter = function (ANode) {
      if (this.FOnNodeMouseEnter != null) this.FOnNodeMouseEnter(this,ANode);
    };
    this.DoNodeDblClick = function (ANode) {
      if (this.FOnNodeDblClick != null) this.FOnNodeDblClick(this,ANode);
    };
    this.DoGetNumberOfNodes = function (ANode, ANumberOfNodes) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNumberOfNodes.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetNumberOfNodes(ANode,ANumberOfNodes);
      if (this.FOnGetNumberOfNodes != null) {
        this.FUpdateCount$1 = this.FUpdateCount$1 + 1;
        this.FNodeListBuild = false;
        this.FNodes.Clear();
        this.FUpdateCount$1 = this.FUpdateCount$1 - 1;
        this.FOnGetNumberOfNodes(this,ANode,ANumberOfNodes);
      };
    };
    this.DoGetNodeText = function (ANode, AColumn, AMode, AText) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeText.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetNodeText(AColumn,ANode,AText);
      if (this.FOnGetNodeText != null) this.FOnGetNodeText(this,ANode,AColumn,AMode,AText);
    };
    this.DoGetNodeData = function (ANode) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeData.apply(this,arguments);
      if (this.FOnGetNodeData != null) this.FOnGetNodeData(this,ANode);
    };
    this.DoGetNodeTitle = function (ANode, AColumn, AMode, ATitle) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitle.apply(this,arguments);
      if (this.FOnGetNodeTitle != null) this.FOnGetNodeTitle(this,ANode,AColumn,AMode,ATitle);
    };
    this.DoGetNodeTitleExpanded = function (ANode, AColumn, AExpanded) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleExpanded.apply(this,arguments);
      if (this.FOnGetNodeExpanded != null) this.FOnGetNodeExpanded(this,ANode,AColumn,AExpanded);
    };
    this.DoGetNodeTrimming = function (ANode, AColumn, ATrimming) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTrimming.apply(this,arguments);
      if (this.FOnGetNodeTrimming != null) this.FOnGetNodeTrimming(this,ANode,AColumn,ATrimming);
    };
    this.DoGetNodeHorizontalTextAlign = function (ANode, AColumn, AHorizontalTextAlign) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeHorizontalTextAlign.apply(this,arguments);
      if (this.FOnGetNodeHorizontalTextAlign != null) this.FOnGetNodeHorizontalTextAlign(this,ANode,AColumn,AHorizontalTextAlign);
    };
    this.DoGetNodeVerticalTextAlign = function (ANode, AColumn, AVerticalTextAlign) {
      if (this.FOnGetNodeVerticalTextAlign != null) this.FOnGetNodeVerticalTextAlign(this,ANode,AColumn,AVerticalTextAlign);
    };
    this.DoGetNodeWordWrapping = function (ANode, AColumn, AWordWrapping) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeWordWrapping.apply(this,arguments);
      if (this.FOnGetNodeWordWrapping != null) this.FOnGetNodeWordWrapping(this,ANode,AColumn,AWordWrapping);
    };
    this.DoGetNodeTitleTrimming = function (ANode, AColumn, ATrimming) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleTrimming.apply(this,arguments);
      if (this.FOnGetNodeTitleTrimming != null) this.FOnGetNodeTitleTrimming(this,ANode,AColumn,ATrimming);
    };
    this.DoGetNodeTitleHorizontalTextAlign = function (ANode, AColumn, AHorizontalTextAlign) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleHorizontalTextAlign.apply(this,arguments);
      if (this.FOnGetNodeTitleHorizontalTextAlign != null) this.FOnGetNodeTitleHorizontalTextAlign(this,ANode,AColumn,AHorizontalTextAlign);
    };
    this.DoGetNodeTitleVerticalTextAlign = function (ANode, AColumn, AVerticalTextAlign) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleVerticalTextAlign.apply(this,arguments);
      if (this.FOnGetNodeTitleVerticalTextAlign != null) this.FOnGetNodeTitleVerticalTextAlign(this,ANode,AColumn,AVerticalTextAlign);
    };
    this.DoGetNodeTitleWordWrapping = function (ANode, AColumn, AWordWrapping) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleWordWrapping.apply(this,arguments);
      if (this.FOnGetNodeTitleWordWrapping != null) this.FOnGetNodeTitleWordWrapping(this,ANode,AColumn,AWordWrapping);
    };
    this.DoGetNodeExtraSize = function (ANode, AColumn, AExtraSize) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeExtraSize.apply(this,arguments);
      if (this.FOnGetNodeExtraSize != null) this.FOnGetNodeExtraSize(this,ANode,AColumn,AExtraSize);
    };
    this.DoGetNodeTitleExtraSize = function (ANode, AColumn, ATitleExtraSize) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleExtraSize.apply(this,arguments);
      if (this.FOnGetNodeTitleExtraSize != null) this.FOnGetNodeTitleExtraSize(this,ANode,AColumn,ATitleExtraSize);
    };
    this.DoGetColumnTrimming = function (AColumn, AKind, ATrimming) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetColumnTrimming.apply(this,arguments);
      if (this.FOnGetColumnTrimming != null) this.FOnGetColumnTrimming(this,AColumn,AKind,ATrimming);
    };
    this.DoGetColumnHorizontalTextAlign = function (AColumn, AKind, AHorizontalTextAlign) {
      if (this.FOnGetColumnHorizontalTextAlign != null) this.FOnGetColumnHorizontalTextAlign(this,AColumn,AKind,AHorizontalTextAlign);
    };
    this.DoGetColumnVerticalTextAlign = function (AColumn, AKind, AVerticalTextAlign) {
      if (this.FOnGetColumnVerticalTextAlign != null) this.FOnGetColumnVerticalTextAlign(this,AColumn,AKind,AVerticalTextAlign);
    };
    this.DoGetColumnWordWrapping = function (AColumn, AKind, AWordWrapping) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetColumnWordWrapping.apply(this,arguments);
      if (this.FOnGetColumnWordWrapping != null) this.FOnGetColumnWordWrapping(this,AColumn,AKind,AWordWrapping);
    };
    this.DoGetNodeCheckType = function (ANode, AColumn, ACheckType) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeCheckType.apply(this,arguments);
      if (this.FOnGetNodeCheckType != null) this.FOnGetNodeCheckType(this,ANode,AColumn,ACheckType);
    };
    this.DoGetNodeHeight = function (ANode, AColumn, AHeight) {
      if (this.FOnGetNodeHeight != null) this.FOnGetNodeHeight(this,ANode,AColumn,AHeight);
    };
    this.DoGetNodeIcon = function (ANode, AColumn, ALarge, AIcon) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeIcon.apply(this,arguments);
      if (this.FOnGetNodeIcon != null) this.FOnGetNodeIcon(this,ANode,AColumn,ALarge,AIcon);
    };
    this.DoGetNodeIconSize = function (ANode, AColumn, ALarge, AIcon, AIconWidth, AIconHeight) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeIconSize.apply(this,arguments);
      if (this.FOnGetNodeIconSize != null) this.FOnGetNodeIconSize(this,ANode,AColumn,ALarge,AIcon,AIconWidth,AIconHeight);
    };
    this.DoGetNodeSelectedColor = function (ANode, AColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeSelectedColor.apply(this,arguments);
      if (this.FOnGetNodeSelectedStrokeColor != null) this.FOnGetNodeSelectedStrokeColor(this,ANode,AColor);
    };
    this.DoGetNodeSelectedStrokeColor = function (ANode, AColor) {
      if (this.FOnGetNodeSelectedColor != null) this.FOnGetNodeSelectedStrokeColor(this,ANode,AColor);
    };
    this.DoGetNodeSides = function (ANode, ASides) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeSides.apply(this,arguments);
      if (this.FOnGetNodeSides != null) this.FOnGetNodeSides(this,ANode,ASides);
    };
    this.DoGetNodeRounding = function (ANode, ARounding, ACorners) {
      if (this.FOnGetNodeRounding != null) this.FOnGetNodeRounding(this,ANode,ARounding,ACorners);
    };
    this.DoGetNodeDisabledColor = function (ANode, AColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeDisabledColor.apply(this,arguments);
      if (this.FOnGetNodeDisabledColor != null) this.FOnGetNodeDisabledColor(this,ANode,AColor);
    };
    this.DoGetNodeDisabledStrokeColor = function (ANode, AColor) {
      if (this.FOnGetNodeDisabledStrokeColor != null) this.FOnGetNodeDisabledStrokeColor(this,ANode,AColor);
    };
    this.DoGetNodeColor = function (ANode, AColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeColor.apply(this,arguments);
      if (this.FOnGetNodeColor != null) this.FOnGetNodeColor(this,ANode,AColor);
    };
    this.DoGetNodeStrokeColor = function (ANode, AColor) {
      if (this.FOnGetNodeStrokeColor != null) this.FOnGetNodeStrokeColor(this,ANode,AColor);
    };
    this.DoGetNodeSelectedTextColor = function (ANode, AColumn, ATextColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeSelectedTextColor.apply(this,arguments);
      if (this.FOnGetNodeSelectedTextColor != null) this.FOnGetNodeSelectedTextColor(this,ANode,AColumn,ATextColor);
    };
    this.DoGetNodeDisabledTextColor = function (ANode, AColumn, ATextColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeDisabledTextColor.apply(this,arguments);
      if (this.FOnGetNodeDisabledTextColor != null) this.FOnGetNodeDisabledTextColor(this,ANode,AColumn,ATextColor);
    };
    this.DoGetNodeTextColor = function (ANode, AColumn, ATextColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTextColor.apply(this,arguments);
      if (this.FOnGetNodeTextColor != null) this.FOnGetNodeTextColor(this,ANode,AColumn,ATextColor);
    };
    this.DoGetNodeSelectedTitleColor = function (ANode, AColumn, ATitleColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeSelectedTitleColor.apply(this,arguments);
      if (this.FOnGetNodeSelectedTitleColor != null) this.FOnGetNodeSelectedTitleColor(this,ANode,AColumn,ATitleColor);
    };
    this.DoGetNodeDisabledTitleColor = function (ANode, AColumn, ATitleColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeDisabledTitleColor.apply(this,arguments);
      if (this.FOnGetNodeDisabledTitleColor != null) this.FOnGetNodeDisabledTitleColor(this,ANode,AColumn,ATitleColor);
    };
    this.DoGetNodeTitleColor = function (ANode, AColumn, ATitleColor) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoGetNodeTitleColor.apply(this,arguments);
      if (this.FOnGetNodeTitleColor != null) this.FOnGetNodeTitleColor(this,ANode,AColumn,ATitleColor);
    };
    this.DoIsNodeExpanded = function (ANode, AExpanded) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoIsNodeExpanded.apply(this,arguments);
      if (this.FOnIsNodeExpanded != null) this.FOnIsNodeExpanded(this,ANode,AExpanded);
    };
    this.DoIsNodeExtended = function (ANode, AExtended) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoIsNodeExtended.apply(this,arguments);
      if (this.FOnIsNodeExtended != null) this.FOnIsNodeExtended(this,ANode,AExtended);
    };
    this.DoIsNodeChecked = function (ANode, AColumn, AChecked) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoIsNodeChecked.apply(this,arguments);
      if (this.FOnIsNodeChecked != null) this.FOnIsNodeChecked(this,ANode,AColumn,AChecked);
    };
    this.DoIsNodeVisible = function (ANode, AVisible) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoIsNodeVisible.apply(this,arguments);
      if (this.FOnIsNodeVisible != null) this.FOnIsNodeVisible(ANode,ANode,AVisible);
    };
    this.DoIsNodeEnabled = function (ANode, AEnabled) {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.DoIsNodeEnabled.apply(this,arguments);
      if (this.FOnIsNodeEnabled != null) this.FOnIsNodeEnabled(this,ANode,AEnabled);
    };
    this.DoBeforeDrawNodeText = function (AGraphics, ARect, AColumn, ANode, AText, AAllow) {
      if (this.FOnBeforeDrawNodeText != null) this.FOnBeforeDrawNodeText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AText,AAllow);
    };
    this.DoAfterDrawNodeText = function (AGraphics, ARect, AColumn, ANode, AText) {
      if (this.FOnAfterDrawNodeText != null) this.FOnAfterDrawNodeText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AText);
    };
    this.DoBeforeDrawNodeTitle = function (AGraphics, ARect, AColumn, ANode, ATitle, AAllow) {
      if (this.FOnBeforeDrawNodeTitle != null) this.FOnBeforeDrawNodeTitle(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,ATitle,AAllow);
    };
    this.DoAfterDrawNodeTitle = function (AGraphics, ARect, AColumn, ANode, ATitle) {
      if (this.FOnAfterDrawNodeTitle != null) this.FOnAfterDrawNodeTitle(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,ATitle);
    };
    this.DoBeforeDrawNodeIcon = function (AGraphics, ARect, AColumn, ANode, AIcon, AAllow) {
      if (this.FOnBeforeDrawNodeIcon != null) this.FOnBeforeDrawNodeIcon(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AIcon,AAllow);
    };
    this.DoAfterDrawNodeIcon = function (AGraphics, ARect, AColumn, ANode, AIcon) {
      if (this.FOnAfterDrawNodeIcon != null) this.FOnAfterDrawNodeIcon(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AIcon);
    };
    this.DoBeforeDrawNodeExtra = function (AGraphics, ARect, AColumn, ANode, AAllow) {
      if (this.FOnBeforeDrawNodeExtra != null) this.FOnBeforeDrawNodeExtra(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AAllow);
    };
    this.DoDrawNodeExtra = function (AGraphics, ARect, AColumn, ANode) {
      if (this.FOnDrawNodeExtra != null) this.FOnDrawNodeExtra(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode);
    };
    this.DoAfterDrawNodeExtra = function (AGraphics, ARect, AColumn, ANode) {
      if (this.FOnAfterDrawNodeExtra != null) this.FOnAfterDrawNodeExtra(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode);
    };
    this.DoBeforeDrawNodeTitleExtra = function (AGraphics, ARect, AColumn, ANode, AAllow) {
      if (this.FOnBeforeDrawNodeTitleExtra != null) this.FOnBeforeDrawNodeTitleExtra(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AAllow);
    };
    this.DoDrawNodeTitleExtra = function (AGraphics, ARect, AColumn, ANode) {
      if (this.FOnDrawNodeTitleExtra != null) this.FOnDrawNodeTitleExtra(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode);
    };
    this.DoAfterDrawNodeTitleExtra = function (AGraphics, ARect, AColumn, ANode) {
      if (this.FOnAfterDrawNodeTitleExtra != null) this.FOnAfterDrawNodeTitleExtra(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode);
    };
    this.DoBeforeDrawNodeCheck = function (AGraphics, ARect, AColumn, ANode, ACheck, AAllow) {
      if (this.FOnBeforeDrawNodeCheck != null) this.FOnBeforeDrawNodeCheck(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,ACheck,AAllow);
    };
    this.DoAfterDrawNodeCheck = function (AGraphics, ARect, AColumn, ANode, ACheck) {
      if (this.FOnAfterDrawNodeCheck != null) this.FOnAfterDrawNodeCheck(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,ACheck);
    };
    this.DoBeforeDrawNodeExpand = function (AGraphics, ARect, AColumn, ANode, AExpand, AAllow) {
      if (this.FOnBeforeDrawNodeExpand != null) this.FOnBeforeDrawNodeExpand(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AExpand,AAllow);
    };
    this.DoAfterDrawNodeExpand = function (AGraphics, ARect, AColumn, ANode, AExpand) {
      if (this.FOnAfterDrawNodeExpand != null) this.FOnAfterDrawNodeExpand(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ANode,AExpand);
    };
    this.DoBeforeSelectNode = function (ANode, ACanSelect) {
      if (this.FOnBeforeSelectNode != null) this.FOnBeforeSelectNode(this,ANode,ACanSelect);
    };
    this.DoBeforeSelectAllNodes = function (ACanSelect) {
      if (this.FOnBeforeSelectAllNodes != null) this.FOnBeforeSelectAllNodes(this,ACanSelect);
    };
    this.DoBeforeUnSelectNode = function (ANode, ACanUnSelect) {
      if (this.FOnBeforeUnSelectNode != null) this.FOnBeforeUnSelectNode(this,ANode,ACanUnSelect);
    };
    this.DoCustomizeInplaceEditor = function (ANode, AColumn, AInplaceEditor) {
      if (this.FOnCustomizeInplaceEditor != null) this.FOnCustomizeInplaceEditor(this,ANode,AColumn,AInplaceEditor);
    };
    this.DoBeforeSizeColumn = function (AColumn, AColumnSize, ANewColumnSize, AAllow) {
      if (this.FOnBeforeSizeColumn != null) this.FOnBeforeSizeColumn(this,AColumn,AColumnSize,ANewColumnSize,AAllow);
    };
    this.DoAfterSizeColumn = function (AColumn, AColumnSize) {
      if (this.FOnAfterSizeColumn != null) this.FOnAfterSizeColumn(this,AColumn,AColumnSize);
    };
    this.DoBeforeUpdateNode = function (ANode, AColumn, AText, ACanUpdate) {
      if (this.FOnBeforeUpdateNode != null) this.FOnBeforeUpdateNode(this,ANode,AColumn,AText,ACanUpdate);
    };
    this.DoNodeChanged = function (ANode) {
      if (this.FOnNodeChanged != null) this.FOnNodeChanged(this,ANode);
    };
    this.DoAfterUpdateNode = function (ANode, AColumn) {
      if (this.FOnAfterUpdateNode != null) this.FOnAfterUpdateNode(this,ANode,AColumn);
    };
    this.DoUpdateNodeText = function (ANode, AColumn, AText) {
    };
    this.DoUpdateNodeTitle = function (ANode, AColumn, ATitle) {
    };
    this.DoBeforeExpandNode = function (ANode, ACanExpand) {
      if (this.FOnBeforeExpandNode != null) this.FOnBeforeExpandNode(this,ANode,ACanExpand);
    };
    this.DoAfterExpandNode = function (ANode) {
      if (this.FOnAfterExpandNode != null) this.FOnAfterExpandNode(this,ANode);
    };
    this.DoBeforeCollapseNode = function (ANode, ACanCollapse) {
      if (this.FOnBeforeCollapseNode != null) this.FOnBeforeCollapseNode(this,ANode,ACanCollapse);
    };
    this.DoAfterCollapseNode = function (ANode) {
      if (this.FOnAfterCollapseNode != null) this.FOnAfterCollapseNode(this,ANode);
    };
    this.DoBeforeCheckNode = function (ANode, AColumn, ACanCheck) {
      if (this.FOnBeforeCheckNode != null) this.FOnBeforeCheckNode(this,ANode,AColumn,ACanCheck);
    };
    this.DoAfterCheckNode = function (ANode, AColumn) {
      if (this.FOnAfterCheckNode != null) this.FOnAfterCheckNode(this,ANode,AColumn);
    };
    this.DoBeforeUnCheckNode = function (ANode, AColumn, ACanUnCheck) {
      if (this.FOnBeforeUnCheckNode != null) this.FOnBeforeUnCheckNode(this,ANode,AColumn,ACanUnCheck);
    };
    this.DoAfterUnCheckNode = function (ANode, AColumn) {
      if (this.FOnAfterUnCheckNode != null) this.FOnAfterUnCheckNode(this,ANode,AColumn);
    };
    this.DoNodeAnchorClick = function (ANode, AColumn, AAnchor) {
      if (this.FOnNodeAnchorClick != null) {
        this.FOnNodeAnchorClick(this,ANode,AColumn,AAnchor)}
       else if (this.FInteraction.FAutoOpenURL) pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
    };
    this.DoNodeTitleAnchorClick = function (ANode, AColumn, AAnchor) {
      if (this.FOnNodeTitleAnchorClick != null) {
        this.FOnNodeTitleAnchorClick(this,ANode,AColumn,AAnchor)}
       else if (this.FInteraction.FAutoOpenURL) pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
    };
    this.DoColumnAnchorClick = function (AColumn, AAnchor) {
      if (this.FOnColumnAnchorClick != null) {
        this.FOnColumnAnchorClick(this,AColumn,AAnchor)}
       else if (this.FInteraction.FAutoOpenURL) pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
    };
    this.DoGetHTMLTemplateValue = function (ANodeValue, AName, AValue) {
      if (this.FOnGetHTMLTemplateValue != null) this.FOnGetHTMLTemplateValue(this,ANodeValue,AName,AValue);
    };
    this.DoGetHTMLTemplate = function (ANodeValue, AColumnIndex, AHTMLTemplate) {
      if (this.FOnGetHTMLTemplate != null) this.FOnGetHTMLTemplate(this,ANodeValue,AColumnIndex,AHTMLTemplate);
    };
    this.DoBeforeAddJSONNode = function (AJSONValue, AAddNode) {
      if (this.FOnBeforeAddJSONNode != null) this.FOnBeforeAddJSONNode(this,AJSONValue,AAddNode);
    };
    this.DoAfterAddJSONNode = function (ANode, AJSONValue) {
      if (this.FOnAfterAddJSONNode != null) this.FOnAfterAddJSONNode(this,ANode,AJSONValue);
    };
    this.DoBeforeOpenInplaceEditor = function (ANode, AColumn, ACanOpen) {
      if (this.FOnBeforeOpenInplaceEditor != null) this.FOnBeforeOpenInplaceEditor(this,ANode,AColumn,ACanOpen);
    };
    this.DoAfterOpenInplaceEditor = function (ANode, AColumn, AInplaceEditor, AInplaceEditorRect) {
      if (this.FOnAfterOpenInplaceEditor != null) this.FOnAfterOpenInplaceEditor(this,ANode,AColumn,AInplaceEditor,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AInplaceEditorRect));
    };
    this.DoCloseInplaceEditor = function (ANode, AColumn, AInplaceEditor, ACancelled, ACanClose) {
      if (this.FOnCloseInplaceEditor != null) this.FOnCloseInplaceEditor(this,ANode,AColumn,AInplaceEditor,ACancelled,ACanClose);
    };
    this.UpdateInplaceEditorPosition = function () {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rt = pas.Types.TRect.$new();
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if ((this.FUpdateNode != null) && (this.FUpdateNodeColumn !== -1) && (this.FInplaceEditor != null) && this.FInplaceEditorActive) {
        if ((this.FUpdateNode.FRow >= this.StartRow()) && (this.FUpdateNode.FRow <= this.StopRow())) {
          r.$assign(this.GetInplaceEditorRect(this.FUpdateNode,this.FUpdateNodeColumn));
          this.FInplaceEditor.SetParent(this);
          this.FInplaceEditor.SetVisible(false);
          if (this.FInplaceEditor != null) {
            rt.$assign(pas.Types.Rect(Math.round(r.Left),Math.round(r.Top),Math.round(r.Right),Math.round(r.Bottom)));
            this.FInplaceEditor.SetBoundsRect(rt);
            this.FInplaceEditor.SetBoundsRect(pas.Types.Rect(rt.Left,rt.Top + rtl.trunc((rt.Bottom - rt.Top - this.FInplaceEditor.GetHeight()) / 2),rt.Right,rt.Top + rtl.trunc((rt.Bottom - rt.Top - this.FInplaceEditor.GetHeight()) / 2) + this.FInplaceEditor.GetHeight()));
            this.FInplaceEditor.SetVisible(true);
          };
        } else this.FInplaceEditor.SetParent(null);
      };
    };
    this.DoGetInplaceEditor = function (ANode, AColumn, AInplaceEditorClass) {
      if (this.FOnGetInplaceEditor != null) this.FOnGetInplaceEditor(this,ANode,AColumn,AInplaceEditorClass);
    };
    this.CloseInplaceEditor = function (ACancel, AFlagClose) {
      var str = "";
      var b = false;
      var c = false;
      var n = "";
      if (this.FClosing) {
        if (AFlagClose) this.FInplaceEditorClosed = true;
        return;
      };
      this.FClosing = true;
      if ((this.FUpdateNode != null) && (this.FUpdateNodeColumn !== -1) && (this.FInplaceEditor != null)) {
        if (!ACancel) {
          try {
            n = "";
            if (pas["WEBLib.StdCtrls"].TEdit.isPrototypeOf(this.FInplaceEditor)) {
              str = rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TEdit).GetText()}
             else if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(this.FInplaceEditor)) {
              str = rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TComboBox).GetText()}
             else if (pas["WEBLib.StdCtrls"].TMemo.isPrototypeOf(this.FInplaceEditor)) str = rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).GetText();
            n = str;
          } finally {
          };
        };
        c = true;
        this.DoCloseInplaceEditor(this.FUpdateNode,this.FUpdateNodeColumn,this.FInplaceEditor,ACancel,{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        if (c) {
          b = true;
          this.DoBeforeUpdateNode(this.FUpdateNode,this.FUpdateNodeColumn,{get: function () {
              return n;
            }, set: function (v) {
              n = v;
            }},{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }});
          if (b && !ACancel) {
            this.FUpdateCount$1 = this.FUpdateCount$1 + 1;
            if (this.FUpdateNode.FNode != null) this.FUpdateNode.FNode.SetText(this.FUpdateNodeColumn,n);
            this.DoUpdateNodeText(this.FUpdateNode,this.FUpdateNodeColumn,n);
            this.FUpdateCount$1 = this.FUpdateCount$1 - 1;
            this.DoAfterUpdateNode(this.FUpdateNode,this.FUpdateNodeColumn);
            this.DoNodeChanged(this.FUpdateNode);
          };
          this.FInplaceEditor.SetParent(null);
          if (this.FOldInplaceEditor != null) rtl.free(this,"FOldInplaceEditor");
          this.FOldInplaceEditor = this.FInplaceEditor;
          this.FInplaceEditor = null;
          this.FInplaceEditorActive = false;
        };
        this.ResetNodes(false);
        this.UpdateTreeView();
        this.Invalidate();
        if (this.CanFocus()) this.SetFocus();
      };
      this.FClosing = false;
      if (AFlagClose) this.FInplaceEditorClosed = true;
    };
    this.DoFocusedNodeChanged = function (ANode) {
      if (this.FOnFocusedNodeChanged != null) this.FOnFocusedNodeChanged(this,ANode);
    };
    this.DoAfterSelectNode = function (ANode) {
      if (this.FAdapter != null) this.FAdapter.SelectNode(ANode);
      if (this.FOnAfterSelectNode != null) this.FOnAfterSelectNode(this,ANode);
    };
    this.DoAfterSelectAllNodes = function () {
      if (this.FOnAfterSelectAllNodes != null) this.FOnAfterSelectAllNodes(this);
    };
    this.DoAfterUnSelectNode = function (ANode) {
      if (this.FOnAfterUnSelectNode != null) this.FOnAfterUnSelectNode(this,ANode);
    };
    this.DoHScroll = function (APosition) {
      if (this.FOnHScroll != null) this.FOnHScroll(this,APosition);
    };
    this.DoVScroll = function (APosition) {
      if (this.FAdapter != null) this.FAdapter.ScrollTreeView(this.GetFirstVisibleVirtualNodeRow() - this.FOldTopRow);
      if (this.FOnVScroll != null) this.FOnVScroll(this,APosition);
    };
    this.ResetNodes = function (AUpdateAll) {
      var I = 0;
      var v = null;
      var st = 0;
      var stp = 0;
      if (this.FVisibleNodes != null) {
        if (AUpdateAll) {
          st = 0;
          stp = this.FRowCount - 1;
        } else {
          st = this.StartRow();
          stp = this.StopRow();
        };
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          v = this.GetVisibleNodeForIndex(I);
          if (v != null) {
            this.FTotalRowHeight = (this.FTotalRowHeight - v.FHeight) + this.GetDefaultRowHeight(v);
            this.UpdateNodeHeight(v,this.GetDefaultRowHeight(v));
            this.UpdateNodeCalculated(v,false);
          };
        };
      };
    };
    this.CreateDragBitmap = function () {
      var g = null;
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = "";
      if (!(this.FDragNode != null)) return;
      this.DestroyDragBitmap();
      dr.$assign(this.FDragNode.FCache.FDrawRect);
      this.FDragBitmap = pas["WEBLib.TMSFNCImage"].TTMSFNCImage.$create("Create$1",[this]);
      this.FDragBitmap.SetWidth(Math.round((dr.Right - dr.Left) / this.FResourceScaleFactor));
      this.FDragBitmap.SetHeight(Math.round((dr.Bottom - dr.Top) / this.FResourceScaleFactor));
      this.FDragBitmap.SetLeft(Math.round(dr.Left / this.FResourceScaleFactor));
      this.FDragBitmap.SetTop(Math.round(dr.Top / this.FResourceScaleFactor));
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[Math.round(this.FDragBitmap.GetWidth() * this.FResourceScaleFactor),Math.round(this.FDragBitmap.GetHeight() * this.FResourceScaleFactor),false,true]);
      g.FBitmapContainer = this.GetBitmapContainer();
      g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
      try {
        if (g.BeginScene()) {
          this.DrawNode(g,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,dr.Right - dr.Left,dr.Bottom - dr.Top)),this.FDragNode,false,-dr.Left,-dr.Top);
          g.EndScene();
        };
        r = g.FBitmap.GetBase64Image();
        this.FDragBitmap.FBitmaps.AddBitmapFromResource(r,1.0);
      } finally {
        g = rtl.freeLoc(g);
      };
      this.FDragBitmap.SetParent(this);
    };
    this.DestroyDragBitmap = function () {
      if (this.FDragBitmap != null) {
        this.FDragBitmap.SetParent(null);
        rtl.free(this,"FDragBitmap");
        this.FDragBitmap = null;
      };
    };
    this.HandleSelectNode = function (ANode, ATriggerEvents, AKeyBoard, AMultiSelect, AColumn) {
      var I = 0;
      var it = null;
      var en = false;
      if (!AMultiSelect) {
        for (var $l = this.FSelectedNodes.GetCount() - 1; $l >= 0; $l--) {
          I = $l;
          it = this.FSelectedNodes.GetItem(I);
          if (it !== ANode) {
            en = true;
            if (ATriggerEvents) this.DoBeforeUnSelectNode(it,{get: function () {
                return en;
              }, set: function (v) {
                en = v;
              }});
            if (en) {
              if (this.FSelectedNodes.IndexOf(it) > -1) this.FSelectedNodes.Remove(it);
              if (ATriggerEvents) this.DoAfterUnSelectNode(it);
            };
          };
        };
      };
      if (ANode != null) {
        if ((this.FSelectedNodes.IndexOf(ANode) > -1) || ((this.FDownNode != null) && (this.FDownNode.FParentNode !== ANode.FParentNode) && ($mod.TMultiSelectStyles.msSiblingOnly in this.FInteraction.FMultiSelectStyle) && AMultiSelect)) {
          en = true;
          if (ATriggerEvents) this.DoBeforeUnSelectNode(ANode,{get: function () {
              return en;
            }, set: function (v) {
              en = v;
            }});
          if (en) {
            if (this.FSelectedNodes.IndexOf(ANode) > -1) this.FSelectedNodes.Remove(ANode);
            if (ATriggerEvents) this.DoAfterUnSelectNode(ANode);
          };
        } else {
          if (((this.FDownNode != null) && ((this.FDownNode.FParentNode === ANode.FParentNode) || !AMultiSelect)) || !($mod.TMultiSelectStyles.msSiblingOnly in this.FInteraction.FMultiSelectStyle)) {
            if ((this.FVisibleNodes.IndexOf(ANode) > -1) || !($mod.TMultiSelectStyles.msVisibleOnly in this.FInteraction.FMultiSelectStyle)) {
              en = true;
              if (ATriggerEvents) this.DoBeforeSelectNode(ANode,{get: function () {
                  return en;
                }, set: function (v) {
                  en = v;
                }});
              if (en) {
                this.FSelectedNodes.Add(ANode);
                if (ATriggerEvents) this.DoAfterSelectNode(ANode);
              };
            };
          };
        };
        if (!AKeyBoard && ATriggerEvents) {
          this.DoNodeClick(ANode);
          this.DoNodeValueClick(ANode,AColumn);
        };
      };
    };
    this.Animate = function (Sender) {
      var dx = 0.0;
      var dy = 0.0;
      var posx = 0.0;
      var posy = 0.0;
      var dvo = 0.0;
      var posvo = 0.0;
      var animh = false;
      var animv = false;
      var animvo = false;
      posy = this.GetVScrollValue();
      posx = this.GetHScrollValue();
      posvo = this.FVerticalOffset;
      animv = false;
      animh = false;
      animvo = false;
      if (this.FInteraction.FAnimationFactor > 0) {
        dx = Math.abs(this.FScrollHTo - posx) / Math.max(1,Math.abs(this.FSpX) * this.FInteraction.FAnimationFactor);
        dy = Math.abs(this.FScrollVTo - posy) / Math.max(1,Math.abs(this.FSpY) * this.FInteraction.FAnimationFactor);
        dvo = Math.abs(this.FVerticalOffsetTo - posvo) / this.FInteraction.FAnimationFactor;
        if (this.FAnimateVerticalPos) animv = $impl.AnimateDouble({get: function () {
            return posy;
          }, set: function (v) {
            posy = v;
          }},{p: this, get: function () {
            return this.p.FScrollVTo;
          }, set: function (v) {
            this.p.FScrollVTo = v;
          }},dy,0.01);
        if (this.FAnimateHorizontalPos) animh = $impl.AnimateDouble({get: function () {
            return posx;
          }, set: function (v) {
            posx = v;
          }},{p: this, get: function () {
            return this.p.FScrollHTo;
          }, set: function (v) {
            this.p.FScrollHTo = v;
          }},dx,0.01);
        if (this.FAnimateVerticalOffset) animvo = $impl.AnimateDouble({get: function () {
            return posvo;
          }, set: function (v) {
            posvo = v;
          }},{p: this, get: function () {
            return this.p.FVerticalOffsetTo;
          }, set: function (v) {
            this.p.FVerticalOffsetTo = v;
          }},dvo,0.01);
      };
      this.FAnimating = animv || animh;
      if (this.FAnimating) {
        this.Scroll(posx,posy)}
       else if (animvo) {
        this.FVerticalOffset = posvo;
        this.UpdateDisplay();
      } else {
        this.FVerticalOffset = this.FVerticalOffsetTo;
        this.UpdateDisplay();
        this.FAnimateVerticalPos = false;
        this.FAnimateTimer.SetEnabled(false);
        this.FAnimateHorizontalPos = false;
      };
    };
    this.ColumnStrokeChanged = function (Sender) {
      this.Invalidate();
    };
    this.DragTime = function (Sender) {
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FReorderMode || (this.FDragMode$1 && this.FDragModeStarted && this.AlternativeDragDrop())) {
        contentr.$assign(this.GetNodesRect());
        if (this.FY >= contentr.Bottom) {
          this.FDragRow = this.FDragRow + 1;
          this.ScrollToVirtualNode(this.GetNodeForRow(this.FDragRow),false,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
        } else if (this.FY <= contentr.Top) {
          this.FDragRow = this.FDragRow - 1;
          this.ScrollToVirtualNode(this.GetNodeForRow(this.FDragRow),false,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
        };
      };
    };
    this.StopAnimationTimer = function () {
      this.FAnimateTimer.SetEnabled(false);
      this.FAnimating = false;
    };
    this.HandleNodeToggle = function (ANode) {
      var e = false;
      if ((ANode != null) && (ANode.FChildren > 0)) {
        if (ANode.FFilterExpanded && !ANode.FExpanded) return;
        if (ANode.FExpanded) {
          e = true;
          this.FBlockUpdateNode = true;
          this.DoBeforeCollapseNode(ANode,{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          this.FBlockUpdateNode = false;
          if (e) {
            this.ToggleNodeInternal(ANode,false);
            this.DoAfterCollapseNode(ANode);
          };
        } else {
          e = true;
          this.FBlockUpdateNode = true;
          this.DoBeforeExpandNode(ANode,{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          this.FBlockUpdateNode = false;
          if (e) {
            this.ToggleNodeInternal(ANode,false);
            this.DoAfterExpandNode(ANode);
          };
        };
      };
    };
    this.HandleNodeExtra = function (ANode) {
    };
    this.HandleNodeTitleExtra = function (ANode) {
    };
    this.HandleNodeToggleCheck = function (ANode, AColumn) {
      var chk = false;
      var e = false;
      var chkt = 0;
      if (ANode != null) {
        if ((AColumn >= 0) && (AColumn <= (rtl.length(ANode.FCheckStates) - 1))) {
          chk = ANode.FCheckStates[AColumn];
          if (chk) {
            chkt = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone;
            this.DoGetNodeCheckType(ANode,AColumn,{get: function () {
                return chkt;
              }, set: function (v) {
                chkt = v;
              }});
            if (chkt === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntCheckBox) {
              e = true;
              this.DoBeforeUnCheckNode(ANode,AColumn,{get: function () {
                  return e;
                }, set: function (v) {
                  e = v;
                }});
              if (e) {
                this.ToggleCheckNodeInternal(ANode,AColumn,false);
                this.DoAfterUnCheckNode(ANode,AColumn);
              };
            };
          } else {
            e = true;
            this.DoBeforeCheckNode(ANode,AColumn,{get: function () {
                return e;
              }, set: function (v) {
                e = v;
              }});
            if (e) {
              this.ToggleCheckNodeInternal(ANode,AColumn,false);
              this.DoAfterCheckNode(ANode,AColumn);
            };
          };
        };
      };
    };
    this.HandleNodeExpand = function (ANode, ARecurse) {
      var e = false;
      if (ANode != null) {
        if (!ANode.FExpanded && (ANode.FChildren > 0)) {
          e = true;
          this.FBlockUpdateNode = true;
          this.DoBeforeExpandNode(ANode,{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          this.FBlockUpdateNode = false;
          if (e) {
            this.ToggleNodeInternal(ANode,ARecurse);
            this.DoAfterExpandNode(ANode);
          };
        };
      };
    };
    this.HandleNodeCollapse = function (ANode, ARecurse) {
      var e = false;
      if (ANode != null) {
        if (ANode.FExpanded && (ANode.FChildren > 0)) {
          e = true;
          this.FBlockUpdateNode = true;
          this.DoBeforeCollapseNode(ANode,{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          this.FBlockUpdateNode = false;
          if (e) {
            this.ToggleNodeInternal(ANode,ARecurse);
            this.DoAfterCollapseNode(ANode);
          };
        };
      };
    };
    this.HandleCustomKeys = function (AKey) {
    };
    this.OffsetNodeRects = function (ANode, AX, AY, ARect) {
      var C = 0;
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetNodesRect());
      pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(ARect,AX + r.Left,AY + r.Top);
      for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
        C = $l;
        if ((C >= 0) && (C <= (rtl.length(ANode.FTitleRects) - 1))) {
          nr.$assign(ANode.FTitleRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FTitleRects[C].$assign(nr);
        };
        if ((C >= 0) && (C <= (rtl.length(ANode.FTextRects) - 1))) {
          nr.$assign(ANode.FTextRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FTextRects[C].$assign(nr);
        };
        if ((C >= 0) && (C <= (rtl.length(ANode.FExtraRects) - 1))) {
          nr.$assign(ANode.FExtraRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FExtraRects[C].$assign(nr);
        };
        if ((C >= 0) && (C <= (rtl.length(ANode.FTitleExtraRects) - 1))) {
          nr.$assign(ANode.FTitleExtraRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FTitleExtraRects[C].$assign(nr);
        };
        if ((C >= 0) && (C <= (rtl.length(ANode.FBitmapRects) - 1))) {
          nr.$assign(ANode.FBitmapRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FBitmapRects[C].$assign(nr);
        };
        if ((C >= 0) && (C <= (rtl.length(ANode.FExpandRects) - 1))) {
          nr.$assign(ANode.FExpandRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FExpandRects[C].$assign(nr);
        };
        if ((C >= 0) && (C <= (rtl.length(ANode.FCheckRects) - 1))) {
          nr.$assign(ANode.FCheckRects[C]);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(nr,AX + r.Left,AY + r.Top);
          ANode.FCheckRects[C].$assign(nr);
        };
      };
    };
    this.BuildDisplay = function (ACache, ADisplay) {
      var x = 0.0;
      var y = 0.0;
      var I = 0;
      var cache = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rrb = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rg = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var grt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var grb = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var n = null;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(ACache != null) || !(ADisplay != null)) return;
      ADisplay.Clear();
      x = -this.GetHorizontalScrollPosition();
      y = -this.GetVerticalScrollPosition();
      if (this.CanApplyVerticalOffset()) y = y + this.FVerticalOffset;
      r.$assign(this.GetNodesRect());
      grt.$assign(this.GetGroupsTopRect());
      grb.$assign(this.GetGroupsBottomRect());
      rrt.$assign(this.GetColumnsTopRect());
      rrb.$assign(this.GetColumnsBottomRect());
      for (var $l = 0, $end = ACache.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        cache = ACache.GetItem$1(I);
        rg.$assign(cache.FRect);
        var $tmp = cache.FKind;
        if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikNode) {
          n = cache.FNode;
          if (n != null) this.OffsetNodeRects(n,pas.System.Int(x),pas.System.Int(y),rg);
        } else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(rg,pas.System.Int(x) + grt.Left,grt.Top)}
         else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(rg,pas.System.Int(x) + grb.Left,grb.Top - 1)}
         else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(rg,pas.System.Int(x) + rrt.Left,rrt.Top)}
         else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(rg,pas.System.Int(x) + rrb.Left,rrb.Top - 1);
        cache.FDrawRect.$assign(rg);
        var $tmp1 = cache.FKind;
        if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikNode) {
          if (pas["WEBLib.TMSFNCTypes"].RectIntersectsWithEx(rg,r)) ADisplay.Add(cache);
        } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
          if (pas["WEBLib.TMSFNCTypes"].RectIntersectsWithEx(rg,rrt)) ADisplay.Add(cache);
        } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) {
          if (pas["WEBLib.TMSFNCTypes"].RectIntersectsWithEx(rg,rrb)) ADisplay.Add(cache);
        } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
          if (pas["WEBLib.TMSFNCTypes"].RectIntersectsWithEx(rg,grt)) ADisplay.Add(cache);
        } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) {
          if (pas["WEBLib.TMSFNCTypes"].RectIntersectsWithEx(rg,grb)) ADisplay.Add(cache);
        };
      };
    };
    this.UpdateCalculations = function () {
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.FOldTopRow = this.GetFirstVisibleVirtualNodeRow();
      this.SetColumnCount(this.FColumns.GetCount());
      if (this.FNodesAppearance.FHeightMode === $mod.TTMSFNCTreeViewNodeHeightMode.tnhmFixed) {
        this.SetDefaultRowHeight(this.FNodesAppearance.FFixedHeight)}
       else this.SetDefaultRowHeight(this.FNodesAppearance.FVariableMinimumHeight);
      if ((this.FUpdateCount$1 === 0) && !this.FBlockUpdateNodeList && !((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (pas.Classes.TComponentStateItem.csReading in this.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState))) this.BuildNodeList();
    };
    this.ResetColumnWidths = function () {
      var I = 0;
      var cl = null;
      this.BeginUpdate();
      try {
        for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
          I = $l;
          cl = this.FColumns.GetItem$1(I);
          if (cl != null) {
            this.SetColWidths(I,Math.max(cl.FMinimumWidth,cl.FWidth))}
           else this.SetColWidths(I,this.FDefaultColumnWidth);
        };
      } finally {
        this.EndUpdate();
      };
    };
    this.UpdateAutoSizing = function () {
      if (pas.Classes.TComponentStateItem.csReading in this.FComponentState) return;
      this.IncUpdateCount$1();
      try {
        if (this.FColumnsAppearance.FStretch) {
          if (this.FColumnsAppearance.FStretchAll) {
            this.FColumnStretchingActive = this.StretchColumns(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewStretchingMode.stmAll,-1,-1)}
           else this.FColumnStretchingActive = this.StretchColumns(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewStretchingMode.stmIndex,this.FColumnsAppearance.FStretchColumn,-1);
          this.FColumnStretchingApplied = true;
        } else if (this.FColumnStretchingApplied) {
          this.FColumnStretchingActive = false;
          this.FColumnStretchingApplied = false;
          this.ResetColumnWidths();
        };
      } finally {
        this.DecUpdateCount$1();
      };
    };
    this.UpdateColumnRowCalculations = function (AUpdateTotalRowHeight) {
      var I = 0;
      var r = 0.0;
      var c = 0.0;
      var lm = 0.0;
      var tm = 0.0;
      var rm = 0.0;
      var bm = 0.0;
      this.FColumnP.Clear();
      c = 0;
      this.SetColPos(0,c);
      for (var $l = 0, $end = this.FColumnCount - 1; $l <= $end; $l++) {
        I = $l;
        c = c + this.GetColWidths(I);
        this.SetColPos(I + 1,c);
      };
      this.FTotalColumnWidth = c;
      if (AUpdateTotalRowHeight) {
        lm = 0;
        tm = 0;
        rm = 0;
        bm = 0;
        this.GetNodeMargins({get: function () {
            return lm;
          }, set: function (v) {
            lm = v;
          }},{get: function () {
            return tm;
          }, set: function (v) {
            tm = v;
          }},{get: function () {
            return rm;
          }, set: function (v) {
            rm = v;
          }},{get: function () {
            return bm;
          }, set: function (v) {
            bm = v;
          }});
        r = 0;
        for (var $l1 = 0, $end1 = this.FRowCount - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          r = r + this.GetRowHeight(I);
        };
        this.FTotalRowHeight = r + 1 + tm + bm;
      };
    };
    this.UpdateColumnsCache = function () {
      this.UpdateColumnCache(this.FColumnsTopCache);
      this.UpdateColumnCache(this.FColumnsBottomCache);
      this.UpdateColumnsDisplay();
    };
    this.UpdateColumnCache = function (ACache) {
      var w = 0.0;
      var h = 0.0;
      var bmpw = 0.0;
      var bmph = 0.0;
      var bw = 0.0;
      var bh = 0.0;
      var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = 0;
      var dx = 0.0;
      var offsetx = 0.0;
      var extrax = 0.0;
      var ac = 0;
      var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cnt = 0;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(ACache != null)) return;
      ACache.Clear();
      if ($mod.TTMSFNCTreeViewColumnsTopCache.isPrototypeOf(ACache) && (!($mod.TTMSFNCTreeViewColumnsLayout.tclTop in this.FColumnsAppearance.FLayouts) || (this.FColumnsAppearance.FTopSize <= 0))) return;
      if ($mod.TTMSFNCTreeViewColumnsBottomCache.isPrototypeOf(ACache) && (!($mod.TTMSFNCTreeViewColumnsLayout.tclBottom in this.FColumnsAppearance.FLayouts) || (this.FColumnsAppearance.FBottomSize <= 0))) return;
      w = this.GetTotalColumnWidth();
      if ($mod.TTMSFNCTreeViewColumnsTopCache.isPrototypeOf(ACache)) {
        h = this.GetColumnsTopSize() + 1}
       else h = this.GetColumnsBottomSize() + 1;
      extrax = this.GetColumnsExtraSize();
      offsetx = 0;
      bmpw = 0;
      bmph = 0;
      ac = 0;
      c = 0;
      dx = 0;
      cnt = this.FColumnCount - 1;
      while (bmpw < w) {
        bw = w;
        while (bmph < h) {
          bh = h;
          rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bw,bh));
          dx = rt.Left + offsetx;
          for (var $l = ac, $end = cnt; $l <= $end; $l++) {
            c = $l;
            rc.Top = pas.System.Int(rt.Top) + 0.5;
            rc.Bottom = pas.System.Int(rt.Bottom) - 0.5;
            rc.Left = pas.System.Int(dx) + 0.5;
            dx = dx + this.GetColWidths(c) + extrax;
            if (c === cnt) {
              rc.Right = pas.System.Int(dx) - 0.5}
             else rc.Right = pas.System.Int(dx) + 0.5;
            pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(rc,bmpw,bmph);
            if ($mod.TTMSFNCTreeViewColumnsTopCache.isPrototypeOf(ACache)) {
              ACache.Add$1(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItem.CreateColumnTop(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),c))}
             else ACache.Add$1(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItem.CreateColumnBottom(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),c));
            if (dx > (rt.Right - rt.Left)) break;
          };
          bmph = bmph + bh;
        };
        bmpw = bmpw + bw;
        bmph = 0;
        ac = c;
        offsetx = -this.GetColWidths(c) - (bw - dx);
      };
    };
    this.UpdateGroupsCache = function () {
      this.UpdateGroupCache(this.FGroupsTopCache);
      this.UpdateGroupCache(this.FGroupsBottomCache);
      this.UpdateGroupsDisplay();
    };
    this.UpdateGroupCache = function (ACache) {
      var h = 0.0;
      var I = 0;
      var grp = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewDisplayGroup.$new();
      var x = 0.0;
      var y = 0.0;
      var bw = 0.0;
      var bh = 0.0;
      var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cache = null;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (this.FColumnCount === 0) || (this.FDisplayGroups.GetCount() === 0) || !(ACache != null)) return;
      ACache.Clear();
      if ($mod.TTMSFNCTreeViewGroupsTopCache.isPrototypeOf(ACache) && (!($mod.TTMSFNCTreeViewGroupLayout.tglTop in this.FGroupsAppearance.FLayouts) || (this.FGroupsAppearance.FTopSize <= 0))) return;
      if ($mod.TTMSFNCTreeViewGroupsBottomCache.isPrototypeOf(ACache) && (!($mod.TTMSFNCTreeViewGroupLayout.tglBottom in this.FGroupsAppearance.FLayouts) || (this.FGroupsAppearance.FBottomSize <= 0))) return;
      if ($mod.TTMSFNCTreeViewGroupsTopCache.isPrototypeOf(ACache)) {
        h = this.GetGroupsTopSize() + 1}
       else h = this.GetGroupsBottomSize() + 1;
      for (var $l = 0, $end = this.FDisplayGroups.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        grp.$assign(this.FDisplayGroups.GetItem(I));
        y = 0;
        x = pas.System.Int(this.GetColPos(grp.StartColumn));
        bh = h;
        bw = pas.System.Int(this.GetColPos(grp.EndColumn + 1) - x);
        if ((bw <= 0) || (bh <= 0)) continue;
        rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bw,bh));
        rc.Top = pas.System.Int(rt.Top) + 0.5;
        rc.Bottom = pas.System.Int(rt.Bottom) - 0.5;
        rc.Left = pas.System.Int(rt.Left) + 0.5;
        rc.Right = pas.System.Int(rt.Right) + 0.5;
        pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(rc,x,y);
        if ($mod.TTMSFNCTreeViewGroupsTopCache.isPrototypeOf(ACache)) {
          cache = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItem.CreateGroupTop(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),I,grp.StartColumn,grp.EndColumn)}
         else cache = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItem.CreateGroupBottom(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),I,grp.StartColumn,grp.EndColumn);
        ACache.Add$1(cache);
      };
    };
    this.UpdateNodesCache = function (AUpdateNodes, AResetNodes) {
      if (this.FBlockUpdateNode) return;
      this.UpdateScrollBars(true,false);
      this.UpdateVisualRange();
      this.UpdateNodeCache();
      this.UpdateScrollBars(true,false);
      if (AUpdateNodes) {
        if (AResetNodes) this.ResetNodes(false);
        this.UpdateAutoSizing();
        this.UpdateColumnRowCalculations(false);
        this.UpdateNodesCache(false,false);
        this.UpdateVisualRange();
      } else {
        this.UpdateNodeDisplay();
        this.UpdateInplaceEditorPosition();
      };
    };
    this.UpdateNodeCache = function () {
      var g = null;
      var vs = 0.0;
      var stty = 0.0;
      var I = 0;
      var v = null;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !(this.FNodeCache != null)) return;
      this.FNodeCache.Clear();
      if (this.FColumnCount > 0) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.FBitmapContainer = this.GetBitmapContainer();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        try {
          try {
            if (!g.BeginScene()) return;
          } catch ($e) {
            return;
          };
          vs = this.GetVerticalScrollPosition();
          stty = vs + this.StartOffset();
          for (var $l = this.StartRow(), $end = this.StopRow(); $l <= $end; $l++) {
            I = $l;
            v = this.GetVisibleNodeForIndex(I);
            if (v != null) {
              if (this.ConfigureNode(g,I,v,{get: function () {
                  return stty;
                }, set: function (v) {
                  stty = v;
                }})) break;
            };
          };
          this.CustomizeNodeCache(g,stty);
          g.EndScene();
        } finally {
          g = rtl.freeLoc(g);
        };
      };
    };
    this.CustomizeNodeCache = function (AGraphics, AStartY) {
    };
    this.UpdateDisplay = function () {
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.UpdateDisplay.call(this);
      this.UpdateNodesCache(false,false);
      this.UpdateGroupsDisplay();
      this.UpdateColumnsDisplay();
      this.Invalidate();
    };
    this.UpdateTreeViewCache = function () {
      if ((this.FUpdateCount$1 > 0) || this.IsDestroying()) return;
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.UpdateTreeViewCache.call(this);
      this.Invalidate();
    };
    this.BuildNodeList = function () {
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.BuildNodeList.call(this);
      this.PrecalculateNodes();
    };
    this.UpdateColumnsDisplay = function () {
      this.BuildDisplay(this.FColumnsTopCache,this.FColumnsTopDisplay);
      this.BuildDisplay(this.FColumnsBottomCache,this.FColumnsBottomDisplay);
    };
    this.UpdateGroupsDisplay = function () {
      this.BuildDisplay(this.FGroupsTopCache,this.FGroupsTopDisplay);
      this.BuildDisplay(this.FGroupsBottomCache,this.FGroupsBottomDisplay);
    };
    this.UpdateNodeDisplay = function () {
      this.BuildDisplay(this.FNodeCache,this.FNodeDisplay);
    };
    this.PrecalculateNodes = function () {
      var g = null;
      var vs = 0.0;
      var stty = 0.0;
      var I = 0;
      var v = null;
      if ((this.FUpdateCount$1 > 0) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || !this.FPrecalculateItems) return;
      if (this.FColumnCount > 0) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.FBitmapContainer = this.GetBitmapContainer();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        try {
          try {
            if (!g.BeginScene()) return;
          } catch ($e) {
            return;
          };
          vs = this.GetVerticalScrollPosition();
          stty = vs + this.StartOffset();
          for (var $l = this.StartRow(), $end = this.FRowCount - 1; $l <= $end; $l++) {
            I = $l;
            v = this.GetVisibleNodeForIndex(I);
            if (v != null) this.ConfigureNode(g,I,v,{get: function () {
                return stty;
              }, set: function (v) {
                stty = v;
              }});
          };
          g.EndScene();
        } finally {
          g = rtl.freeLoc(g);
        };
      };
    };
    this.VerticalScrollPositionChanged = function () {
      this.FBlockScrollingUpdate = true;
      this.UpdateDisplay();
      this.FBlockScrollingUpdate = false;
      this.DoVScroll(this.GetVScrollValue());
    };
    this.Scroll = function (AHorizontalPos, AVerticalPos) {
      var h = 0.0;
      var v = 0.0;
      h = this.GetHorizontalScrollPosition();
      v = this.GetVerticalScrollPosition();
      pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.Scroll.apply(this,arguments);
      if (h !== AHorizontalPos) this.DoHScroll(AHorizontalPos);
      if (v !== AVerticalPos) this.DoVScroll(AVerticalPos);
    };
    this.HorizontalScrollPositionChanged = function () {
      this.FBlockScrollingUpdate = true;
      this.UpdateDisplay();
      this.FBlockScrollingUpdate = false;
      this.DoHScroll(this.GetHScrollValue());
    };
    this.DrawNode = function (AGraphics, ARect, ANode, ACaching, AOffsetX, AOffsetY) {
    };
    this.DrawGroup = function (AGraphics, ARect, AGroup, AStartColumn, AEndColumn, AKind) {
    };
    this.DrawColumn = function (AGraphics, ARect, AColumn, AKind) {
    };
    this.DrawNodes = function (AGraphics) {
      this.DrawDisplay(AGraphics,this.FNodeDisplay);
    };
    this.DrawColumns = function (AGraphics) {
      this.DrawDisplay(AGraphics,this.FColumnsTopDisplay);
      this.DrawDisplay(AGraphics,this.FColumnsBottomDisplay);
    };
    this.DrawNodeColumns = function (AGraphics) {
    };
    this.DrawGroups = function (AGraphics) {
      this.DrawDisplay(AGraphics,this.FGroupsTopDisplay);
      this.DrawDisplay(AGraphics,this.FGroupsBottomDisplay);
    };
    this.DrawBorders = function (AGraphics) {
    };
    this.DrawEmptySpaces = function (AGraphics) {
    };
    this.DrawDisplay = function (AGraphics, ADisplay) {
      var I = 0;
      var cache = null;
      var st = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (ADisplay.GetCount() === 0) return;
      st = AGraphics.SaveState(false);
      if ($mod.TTMSFNCTreeViewNodeDisplayList.isPrototypeOf(ADisplay)) {
        r.$assign(this.GetContentClipRect());
        r.Right = r.Right + 1;
      } else if ($mod.TTMSFNCTreeViewGroupsTopDisplayList.isPrototypeOf(ADisplay)) {
        r.$assign(this.GetGroupsTopRect());
        r.Bottom = r.Bottom + 1;
      } else if ($mod.TTMSFNCTreeViewGroupsBottomDisplayList.isPrototypeOf(ADisplay)) {
        r.$assign(this.GetGroupsBottomRect());
        r.Top = r.Top - 1;
      } else if ($mod.TTMSFNCTreeViewColumnsTopDisplayList.isPrototypeOf(ADisplay)) {
        r.$assign(this.GetColumnsTopRect());
        r.Bottom = r.Bottom + 1;
      } else if ($mod.TTMSFNCTreeViewColumnsBottomDisplayList.isPrototypeOf(ADisplay)) {
        r.$assign(this.GetColumnsBottomRect());
        r.Top = r.Top - 1;
      };
      AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
      for (var $l = 0, $end = ADisplay.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        cache = ADisplay.GetItem(I);
        if ($mod.TTMSFNCTreeViewNodeDisplayList.isPrototypeOf(ADisplay)) {
          if (cache.FNode != null) this.DrawNode(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cache.FDrawRect),cache.FNode,false,0,0);
        } else if ($mod.TTMSFNCTreeViewColumnsDisplayList.isPrototypeOf(ADisplay)) {
          this.DrawColumn(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cache.FDrawRect),cache.FColumn,cache.FKind)}
         else if ($mod.TTMSFNCTreeViewGroupsDisplayList.isPrototypeOf(ADisplay)) this.DrawGroup(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cache.FDrawRect),cache.FGroup,cache.FStartColumn,cache.FEndColumn,cache.FKind);
      };
      AGraphics.RestoreState(st,false);
    };
    this.HandleDragStart = function (X, Y) {
    };
    this.HandleDragOver = function (Source, Point, Accept) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDragOver.apply(this,arguments);
      if (this.FBlockUserInput || (this.FOnDragOver != null)) return;
      if (!this.AlternativeDragDrop()) {
        this.FDragMode$1 = false;
        this.FDragModeStarted = false;
        this.FIsMouseDown = false;
      };
      if (this.FOnCustomDragOver != null) {
        this.FOnCustomDragOver(this,Source,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(Point),Accept)}
       else {
        Accept.set((this.FInteraction.FDragDropMode !== $mod.TTMSFNCTreeViewDragDropMode.tdmNone) && $mod.TTMSFNCCustomTreeView.isPrototypeOf(Source) && (rtl.as(Source,$mod.TTMSFNCCustomTreeView).FDragNode != null));
        Accept.set(Accept.get() && pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetNodesRect(),Point));
      };
      this.FAccepted = Accept.get();
    };
    this.HandleDragDrop = function (Source, Point) {
      var dn = null;
      var dragn = null;
      var b = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDragDrop.apply(this,arguments);
      if (this.FBlockUserInput || (this.FOnDragDrop != null)) return;
      if (this.FOnCustomDragDrop != null) {
        this.FOnCustomDragDrop(this,Source,pas["WEBLib.TMSFNCTypes"].TPointF.$clone(Point))}
       else {
        if (this.FAccepted && (Source != null) && $mod.TTMSFNCCustomTreeView.isPrototypeOf(Source) && (rtl.as(Source,$mod.TTMSFNCCustomTreeView).FInteraction.FDragDropMode !== $mod.TTMSFNCTreeViewDragDropMode.tdmNone)) {
          dragn = rtl.as(Source,$mod.TTMSFNCCustomTreeView).FDragNode;
          if (dragn != null) {
            dn = this.XYToNode(Point.X,Point.Y,0);
            if ((dn !== dragn) && (dragn.FNode != null) && pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetNodesRect(),Point)) {
              b = true;
              this.DoBeforeDropNode(dragn,dn,{get: function () {
                  return b;
                }, set: function (v) {
                  b = v;
                }});
              if (b) {
                this.BeginUpdate();
                rtl.as(Source,$mod.TTMSFNCCustomTreeView).BeginUpdate();
                if ((dn != null) && (dn.FNode != null)) {
                  var $tmp = rtl.as(Source,$mod.TTMSFNCCustomTreeView).FInteraction.FDragDropMode;
                  if ($tmp === $mod.TTMSFNCTreeViewDragDropMode.tdmMove) {
                    dragn.FNode.MoveTo(dn.FNode,dn.FNode.GetIndex())}
                   else if ($tmp === $mod.TTMSFNCTreeViewDragDropMode.tdmCopy) dragn.FNode.CopyTo(dn.FNode,dn.FNode.GetIndex());
                } else {
                  this.FNodes.Add$1().Assign(dragn.FNode);
                  var $tmp1 = rtl.as(Source,$mod.TTMSFNCCustomTreeView).FInteraction.FDragDropMode;
                  if ($tmp1 === $mod.TTMSFNCTreeViewDragDropMode.tdmMove) dragn.FNode.TreeView().RemoveNode(dragn.FNode);
                  dragn = this.FNodes.GetItem$1(this.FNodes.GetCount() - 1).FVirtualNode;
                };
                rtl.as(Source,$mod.TTMSFNCCustomTreeView).FDragNode = null;
                rtl.as(Source,$mod.TTMSFNCCustomTreeView).EndUpdate();
                this.EndUpdate();
                this.DoAfterDropNode(dragn,dn);
              };
            };
          };
        };
      };
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      var dc = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if ((Button === pas["WEBLib.Controls"].TMouseButton.mbRight) || this.FBlockUserInput || this.FBlockMouseClick) return;
      if (!this.FDblClicked) this.CaptureEx();
      this.FDragMode$1 = false;
      this.FDragModeStarted = false;
      this.FReorderMode = false;
      this.FDragNode = null;
      if (!this.FDblClicked) {
        if (this.CanFocus()) this.SetFocus();
        if (this.FInplaceEditorActive) this.CloseInplaceEditor(false,false);
      };
      dc = this.XYToCacheItem(X,Y,0);
      this.FDownNode = null;
      if (dc != null) {
        this.FDownNode = dc.FNode;
        if (this.FSelectedNodes.IndexOf(this.FDownNode) > -1) {
          this.FDragNode = this.FDownNode;
          this.FDragMode$1 = (this.FDownNode != null) && (this.FInteraction.FDragDropMode !== $mod.TTMSFNCTreeViewDragDropMode.tdmNone) && !this.FDblClicked && !this.XYToNodeExpand(this.FDownNode,X,Y) && !this.XYToNodeExtra(this.FDownNode,X,Y) && !this.XYToNodeTitleExtra(this.FDownNode,X,Y) && !(this.XYToNodeCheck(this.FDownNode,X,Y).ANode != null);
          this.FReorderMode = (this.FDownNode != null) && this.FInteraction.FReorder && !this.FDragMode$1 && !this.FDblClicked && !this.XYToNodeExpand(this.FDownNode,X,Y) && !this.XYToNodeExtra(this.FDownNode,X,Y) && !this.XYToNodeTitleExtra(this.FDownNode,X,Y) && !(this.XYToNodeCheck(this.FDownNode,X,Y).ANode != null);
          this.FDragMode$1 = this.FDragMode$1 && !((pas.Classes.TShiftState$a.ssCtrl in Shift) || (pas.Classes.TShiftState$a.ssShift in Shift));
          this.FReorderMode = this.FReorderMode && !((pas.Classes.TShiftState$a.ssCtrl in Shift) || (pas.Classes.TShiftState$a.ssShift in Shift));
          if (this.FReorderMode) {
            this.CreateDragBitmap();
            this.FSaveDragY = this.FDragBitmap.GetTop();
          };
        };
      };
      if (this.FDragMode$1) {
        if (this.CanStartDragFromMouseDown()) {
          this.FDragModeStarted = true;
          this.HandleDragStart(X,Y);
          this.BeginDrag$1();
        };
        this.FIsMouseDown = !this.FDblClicked;
      } else {
        if (this.FDownNode != null) {
          this.FDoNodeExpand = this.XYToNodeExpand(this.FDownNode,X,Y);
          this.FDoNodeCheck.$assign(this.XYToNodeCheck(this.FDownNode,X,Y));
          this.FDoNodeAnchor.$assign(this.XYToNodeAnchor(this.FDownNode,X,Y));
          this.FDoNodeTitleAnchor.$assign(this.XYToNodeTitleAnchor(this.FDownNode,X,Y));
          this.FDoNodeExtra = this.XYToNodeExtra(this.FDownNode,X,Y);
          this.FDoNodeTitleExtra = this.XYToNodeTitleExtra(this.FDownNode,X,Y);
        };
        this.FSizeColumn = -1;
        if (this.FInteraction.FColumnSizing) {
          this.FSizeColumn = this.XYToColumnSize(X,Y);
          if ((this.FSizeColumn >= 0) && (this.FSizeColumn <= (this.FColumnCount - 1))) this.FColumnSize = this.GetColWidths(this.FSizeColumn);
        };
        this.FDownColumn = this.XYToColumn(X,Y,false);
        this.FDownColumnValue = this.XYToColumn(X,Y,true);
        this.FDownColumnFilter = this.XYToColumnFilter(X,Y);
        this.FDownColumnExpand = this.XYToColumnExpand(X,Y);
        this.FIsMouseDown = !this.FDblClicked;
        this.FTimeStart = $impl.GetTickCountX();
        this.FTimeStop = this.FTimeStart;
        this.FScrollVTo = this.GetVScrollValue();
        this.FScrollHTo = this.GetHScrollValue();
        this.FScrollX = X;
        this.FScrollY = Y;
        this.FDownX = X;
        this.FDownY = Y;
        this.FMouseX = X;
        this.FMouseY = Y;
        this.FSizeX = X;
        this.FDragY = Y;
        this.FVerticalOffset = 0;
        this.FVerticalOffsetTo = 0;
        this.FMouseUp = false;
        this.FDoubleSelection = !this.FAnimateTimer.FEnabled;
        this.FScrolling = false;
      };
      this.FDblClicked = false;
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var f = 0.0;
      var it = null;
      var doscroll = false;
      var dsp = null;
      var sc = 0;
      var c = false;
      var colsz = 0.0;
      var newcolsz = 0.0;
      var newposy = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var n = null;
      var su = false;
      var sd = false;
      var a = "";
      var crs = 0;
      var cl = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (this.FBlockUserInput || (this.FAnimating && !this.FIsMouseDown)) return;
      this.FY = Y;
      this.FX = X;
      if (this.FIsMouseDown && this.FDragMode$1 && this.CanStartDragFromMouseMove() && ((Math.abs(this.FY - this.FDownY) > 10) || (Math.abs(this.FX - this.FDownX) > 10))) {
        if (!this.FDragModeStarted) this.HandleDragStart(X,Y);
        this.FDragModeStarted = true;
        if (this.AlternativeDragDrop()) {
          this.HandleAlternativeDragOver(X,Y)}
         else this.BeginDrag$1();
        return;
      };
      if (this.FReorderMode && (this.FDragBitmap != null) && this.FInteraction.FReorder) {
        r.$assign(this.GetContentClipRect());
        newposy = this.FSaveDragY + (this.FY - this.FDragY);
        if ((newposy <= ((r.Top + (r.Bottom - r.Top)) - this.FDragBitmap.GetHeight())) && (newposy >= r.Top)) {
          this.FDragBitmap.SetTop(Math.round(Math.max(r.Top,Math.min((r.Top + (r.Bottom - r.Top)) - this.FDragBitmap.GetHeight(),newposy))));
          this.FSaveDragY = this.FDragBitmap.GetTop();
          this.FDragTimer.SetEnabled(false);
          if ((newposy > r.Top) && (newposy < (r.Top + (r.Right - r.Left)))) {
            n = this.XYToNode((r.Right - r.Left) / 2,newposy,0);
            if (n != null) this.FDragRow = n.FRow;
          };
        } else if (newposy > ((r.Top + (r.Bottom - r.Top)) - this.FDragBitmap.GetHeight())) {
          this.FDragBitmap.SetTop(Math.round((r.Top + (r.Bottom - r.Top)) - this.FDragBitmap.GetHeight()));
          this.FSaveDragY = newposy;
          this.FDragTimer.SetEnabled(true);
        } else if (newposy < r.Top) {
          this.FDragBitmap.SetTop(Math.round(r.Top));
          this.FSaveDragY = newposy;
          this.FDragTimer.SetEnabled(true);
        };
        this.FDragY = this.FY;
        return;
      };
      if ((this.FSizeColumn >= 0) && (this.FSizeColumn <= (this.FColumnCount - 1))) {
        c = true;
        colsz = this.FColumnSize;
        this.FColumnSize = colsz + (X - this.FSizeX);
        newcolsz = Math.max(0,this.FColumnSize);
        this.FSizeX = X;
        this.DoBeforeSizeColumn(this.FSizeColumn,colsz,{get: function () {
            return newcolsz;
          }, set: function (v) {
            newcolsz = v;
          }},{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        if (c) {
          this.SetColWidths(this.FSizeColumn,newcolsz);
          if ((this.FSizeColumn >= 0) && (this.FSizeColumn <= (this.FColumns.GetCount() - 1))) this.FColumns.GetItem$1(this.FSizeColumn).UpdateWidth(newcolsz);
          this.DoAfterSizeColumn(this.FSizeColumn,newcolsz);
          this.ResetNodes(true);
          this.UpdateTreeView();
          this.Invalidate();
        };
        return;
      };
      if (this.FIsMouseDown && !(this.FDoNodeAnchor.AAnchor !== "") && !(this.FDoNodeTitleAnchor.AAnchor !== "")) {
        doscroll = !this.FDoNodeExpand && !(this.FDoNodeCheck.ANode != null);
        if (doscroll) {
          f = 1;
          var $tmp = this.FScrollMode;
          if ($tmp === pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewScrollMode.smNodeScrolling) f = 0.1;
          c = true;
          if (this.ScrollLimitation() && (Math.abs(Y - this.FMouseY) < 15)) c = Math.abs(X - this.FMouseX) < 5;
          c = c && !(this.XYToColumn(X,Y,false) !== -1);
          if ((this.FScrolling || (Math.abs(this.FMouseX - X) > 3) || (Math.abs(this.FMouseY - Y) > 3)) && this.FInteraction.FTouchScrolling && c) {
            this.FDragTimer.SetEnabled(false);
            if ((Math.abs(X - this.FDownX) > 0) || (Math.abs(Y - this.FDownY) > 0)) {
              this.FScrolling = true;
              this.FDoubleSelection = false;
              if (this.FIsMouseDown && !this.FMouseUp) {
                su = this.CanScrollUp();
                sd = this.CanScrollDown();
                if ((su && ((Y - this.FDownY) > 0)) || (sd && ((Y - this.FDownY) < 0) && (this.FVerticalOffset === 0))) {
                  this.FVerticalOffset = 0;
                  this.Scroll(this.GetHScrollValue() - ((X - this.FDownX) * f),this.GetVScrollValue() - ((Y - this.FDownY) * f));
                } else if (this.CanApplyVerticalOffset()) {
                  this.FVerticalOffset = Math.min(75,Math.max(-75,this.FVerticalOffset + (Y - this.FDownY)));
                  this.UpdateDisplay();
                } else this.Scroll(this.GetHScrollValue() - ((X - this.FDownX) * f),this.GetVScrollValue());
                this.FDownY = Y;
                this.FDownX = X;
              };
            };
          };
        };
      } else {
        it = null;
        dsp = this.XYToCacheItem(X,Y,0);
        if (dsp != null) it = dsp.FNode;
        crs = 0;
        if ((it != null) && (dsp != null)) {
          if (this.FInteraction.FURLDetectionOnMouseMove && ((this.XYToNodeAnchor(it,X,Y).AAnchor !== "") || (this.XYToNodeTitleAnchor(it,X,Y).AAnchor !== ""))) crs = 21;
        } else {
          if (this.FInteraction.FColumnSizing) {
            sc = this.XYToColumnSize(X,Y);
            if ((sc >= 0) && (sc <= (this.FColumnCount - 1))) crs = 9;
          };
        };
        cl = -1;
        a = this.XYToColumnAnchor(X,Y,{get: function () {
            return cl;
          }, set: function (v) {
            cl = v;
          }});
        if (a !== "") crs = 21;
        if (crs !== this.FCursor) this.SetControlCursor(crs);
        if (this.FPrevDSP !== dsp) {
          if ((this.FPrevDSP != null) && (this.FPrevDSP.FNode != null)) this.DoNodeMouseLeave(this.FPrevDSP.FNode);
          if ((dsp != null) && (dsp.FNode != null)) this.DoNodeMouseEnter(dsp.FNode);
        };
        this.FPrevDSP = dsp;
      };
    };
    this.HandleDblClick = function (X, Y) {
      var pf = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var c = null;
      var col = 0;
      var dn = null;
      var en = false;
      var ext = false;
      var t = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDblClick.apply(this,arguments);
      if (this.FBlockUserInput) return;
      this.FDblClicked = true;
      pf.$assign(pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
      this.FDownNode = null;
      c = this.XYToNode(pf.X,pf.Y,0);
      if (c != null) {
        if (!this.XYToNodeExpand(c,pf.X,pf.Y) && !(this.XYToNodeCheck(c,pf.X,pf.Y).ANode != null)) {
          this.FDownNode = c;
          if (this.FDownNode != null) {
            en = true;
            this.DoIsNodeEnabled(this.FDownNode,{get: function () {
                return en;
              }, set: function (v) {
                en = v;
              }});
            if (en) {
              ext = false;
              this.DoIsNodeExtended(this.FDownNode,{get: function () {
                  return ext;
                }, set: function (v) {
                  ext = v;
                }});
              if (!this.FCompactMode && ((ext && this.FInteraction.FExtendedSelectable && this.FInteraction.FExtendedEditable) || !ext) && (this.FInteraction.FMouseEditMode === $mod.TTMSFNCTreeViewMouseEditMode.tmemDoubleClick) && !this.FInteraction.FReadOnly) {
                t = this.XYToNodeTextColumn(this.FDownNode,pf.X,pf.Y);
                if (t !== -1) this.HandleNodeEditing(this.FDownNode,t);
              } else if (this.FInteraction.FExpandCollapseOnDblClick) {
                dn = this.FDownNode.FNode;
                this.HandleNodeToggle(this.FDownNode);
                if ((dn != null) && (dn.FVirtualNode != null)) this.FDownNode = dn.FVirtualNode;
              };
            };
            this.DoNodeDblClick(this.FDownNode);
          };
        };
      } else {
        col = this.XYToColumnSize(pf.X,pf.Y);
        if (this.FInteraction.FColumnAutoSizeOnDblClick) this.AutoSizeColumn(col);
      };
      this.FIsMouseDown = false;
      this.FMouseUp = true;
      this.FScrolling = false;
      this.FDoNodeExpand = false;
      this.FDoNodeExtra = false;
      this.FDoNodeTitleExtra = false;
      this.FDoNodeAnchor.AAnchor = "";
      this.FDoNodeAnchor.AColumn = -1;
      this.FDoNodeTitleAnchor.AAnchor = "";
      this.FDoNodeTitleAnchor.AColumn = -1;
      this.FDownColumn = -1;
      this.FDownColumnValue = -1;
      this.FDownColumnFilter = -1;
      this.FDownColumnExpand = -1;
      this.FReorderMode = false;
      this.FDragMode$1 = false;
      this.FDragModeStarted = false;
    };
    this.DoNeedFilterDropDownData = function (AColumn, AValues) {
      if (this.FOnNeedFilterDropDownData != null) this.FOnNeedFilterDropDownData(this,AColumn,AValues);
    };
    this.DoFilterSelect = function (AColumn, ACondition) {
      if (this.FOnFilterSelect != null) this.FOnFilterSelect(this,AColumn,ACondition);
    };
    this.HandleFilter = function (AColumn) {
      var sl = null;
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var n = null;
      var s = "";
      var topr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var fr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var szd = 0.0;
      var colw = 0.0;
      var colp = 0.0;
      if ((AColumn >= 0) && (AColumn <= (this.FColumns.GetCount() - 1)) && this.FColumns.GetItem$1(AColumn).FFiltering.FEnabled) {
        colw = this.GetColWidths(AColumn);
        if (colw >= 0) {
          colp = this.GetColPos(AColumn);
          sl = pas.Classes.TStringList.$create("Create$1");
          try {
            sl.FDuplicates = pas.Types.TDuplicates.dupIgnore;
            sl.SetSorted(true);
            sl.Add(rtl.getResStr($mod,"sTMSFNCTreeViewFilterAll"));
            n = this.GetFirstRootVirtualNode();
            while (n != null) {
              s = "";
              this.DoGetNodeText(n,AColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }});
              s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(s);
              if (s !== "") sl.Add(s);
              n = n.GetNext();
            };
            this.DoNeedFilterDropDownData(AColumn,sl);
            this.FFilterListBox.SetParent(this);
            this.FFilterListBox.FItems.Assign(sl);
            this.FFilterListBox.SetItemIndex(-1);
            pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(this.FFilterListBox.FFont,16,1);
            this.FFilterListBox.FTag$1 = AColumn;
            this.DoCustomizeFilterListBox(AColumn,this.FFilterListBox);
            this.FFilterListBox.SetParent(null);
          } finally {
            sl = rtl.freeLoc(sl);
          };
          this.FFilterPopup.SetPlacementControl(this);
          topr.$assign(this.GetColumnsTopRect());
          topr.Left = topr.Left - this.GetHorizontalScrollPosition();
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(topr.Left + colp,topr.Top,topr.Left + colp + colw,topr.Bottom));
          szd = this.FColumns.GetItem$1(AColumn).FFiltering.FButtonSize;
          fr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(r.Right - szd - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - szd) / 2)),Math.round(r.Right - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - szd) / 2) + szd)));
          pt.$assign(this.LocalToScreenEx(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF((fr.Left + (fr.Right - fr.Left)) - szd - this.ScalePaintValue(2),fr.Top + (((fr.Bottom - fr.Top) + szd) / 2)))));
          this.FFilterPopup.FPlacementRectangle.SetLeft(pt.X);
          this.FFilterPopup.FPlacementRectangle.SetTop(pt.Y);
          this.FFilterListBox.SetWidth(this.FColumns.GetItem$1(AColumn).FFiltering.FDropDownWidth);
          this.FFilterListBox.SetHeight(this.FColumns.GetItem$1(AColumn).FFiltering.FDropDownHeight);
          this.FFilterPopup.SetDropDownHeight(this.FColumns.GetItem$1(AColumn).FFiltering.FDropDownHeight);
          this.FFilterPopup.SetDropDownWidth(this.FColumns.GetItem$1(AColumn).FFiltering.FDropDownWidth);
          this.FFilterPopup.FPlacementRectangle.SetRight(pt.X + this.FFilterPopup.FDropDownWidth);
          this.FFilterPopup.FPlacementRectangle.SetBottom(pt.Y + this.FFilterPopup.FDropDownHeight);
          this.FFilterPopup.SetContentControl(this.FFilterListBox);
          this.FFilterPopup.FFocusedControl = this.FFilterListBox;
          this.FFilterPopup.Popup(false);
        };
      };
    };
    this.HandleExpand = function (AColumn) {
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var f = 0.0;
      var a = $mod.TTMSFNCTreeViewNodeAnchor.$new();
      var cl = 0;
      var ha = "";
      var en = false;
      var d = false;
      var dosel = false;
      var ext = false;
      var I = 0;
      var t = 0;
      var dn = null;
      var prev = null;
      var b = false;
      var sz = 0;
      var cs = false;
      var add = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      if ((Button === pas["WEBLib.Controls"].TMouseButton.mbRight) || this.FBlockUserInput) return;
      this.ReleaseCaptureEx();
      if (this.FDragMode$1 && this.FDragModeStarted && this.AlternativeDragDrop()) {
        this.HandleAlternativeDragDrop(X,Y);
        this.DestroyDragBitmap();
        this.SetControlCursor(0);
      };
      sz = this.FSizeColumn;
      this.FSizeColumn = -1;
      this.FDragTimer.SetEnabled(false);
      if (!this.FIsMouseDown) return;
      if (this.FReorderMode && this.FInteraction.FReorder) {
        dn = this.XYToNode(X,Y,0);
        if (this.FOnCustomReorder != null) {
          this.FOnCustomReorder(this,this.FDragNode,dn)}
         else {
          if ((dn != null) && (dn !== this.FDragNode) && (dn.FNode != null) && (this.FDragNode.FNode != null)) {
            b = true;
            this.DoBeforeReorderNode(this.FDragNode,dn,{get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }});
            if (b) {
              if (this.FDragNode.FLevel === dn.FLevel) {
                if (dn.FNode.GetParent() === null) {
                  this.FDragNode.FNode.SetIndex(dn.FNode.GetIndex())}
                 else this.FDragNode.FNode.MoveTo(dn.FNode.GetParent(),dn.FNode.GetIndex());
              };
              this.DoAfterReorderNode(this.FDragNode,dn);
            };
          };
        };
        this.DestroyDragBitmap();
        this.FDragNode = null;
      };
      f = 1;
      var $tmp = this.FScrollMode;
      if ($tmp === pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewScrollMode.smNodeScrolling) f = 0.1;
      this.FIsMouseDown = false;
      this.FMouseUp = true;
      this.FScrolling = false;
      if (this.FDownColumnFilter !== -1) {
        this.HandleFilter(this.FDownColumnFilter)}
       else if (this.FDownColumnExpand !== -1) {
        this.HandleExpand(this.FDownColumnExpand)}
       else if ((this.FDownColumn !== -1) && (sz === -1)) {
        if ((this.FDownColumn >= 0) && (this.FDownColumn <= (this.FColumnCount - 1))) {
          if (this.FColumns.GetItem$1(this.FDownColumn).FSorting !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNone) {
            var $tmp1 = this.FColumns.GetItem$1(this.FDownColumn).FSortKind;
            if (($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskNone) || ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskAscending)) {
              this.InitializeColumnSorting(this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmDescending);
              if (this.FOnCustomColumnSort != null) {
                this.FOnCustomColumnSort(this,this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmDescending)}
               else {
                cs = true;
                this.DoBeforeSortNodes(this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmDescending,{get: function () {
                    return cs;
                  }, set: function (v) {
                    cs = v;
                  }});
                if (cs) {
                  this.FNodes.Sort$1(this.FDownColumn,this.FColumns.GetItem$1(this.FDownColumn).FSorting in rtl.createSet(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsRecursive,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsRecursiveCaseSensitive),this.FColumns.GetItem$1(this.FDownColumn).FSorting in rtl.createSet(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNormalCaseSensitive,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsRecursiveCaseSensitive),pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmDescending,true);
                  this.DoAfterSortNodes(this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmDescending);
                };
              };
            } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskDescending) {
              this.InitializeColumnSorting(this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmAscending);
              if (this.FOnCustomColumnSort != null) {
                this.FOnCustomColumnSort(this,this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmAscending)}
               else {
                cs = true;
                this.DoBeforeSortNodes(this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmAscending,{get: function () {
                    return cs;
                  }, set: function (v) {
                    cs = v;
                  }});
                if (cs) {
                  this.FNodes.Sort$1(this.FDownColumn,this.FColumns.GetItem$1(this.FDownColumn).FSorting in rtl.createSet(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsRecursive,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsRecursiveCaseSensitive),this.FColumns.GetItem$1(this.FDownColumn).FSorting in rtl.createSet(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNormalCaseSensitive,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsRecursiveCaseSensitive),pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmAscending,true);
                  this.DoAfterSortNodes(this.FDownColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortMode.nsmAscending);
                };
              };
            };
          };
          cl = -1;
          ha = this.XYToColumnAnchor(X,Y,{get: function () {
              return cl;
            }, set: function (v) {
              cl = v;
            }});
          if (ha !== "") this.DoColumnAnchorClick(this.FDownColumn,ha);
        };
      } else if (!this.FReorderMode && !this.FDragModeStarted) {
        if (!this.FDoNodeExpand && !this.FDoNodeExtra && !this.FDoNodeTitleExtra && !(this.FDoNodeCheck.ANode != null) && !(this.FDoNodeAnchor.AAnchor !== "") && !(this.FDoNodeTitleAnchor.AAnchor !== "")) {
          if (!this.FDoubleSelection && this.FInteraction.FTouchScrolling) {
            this.FTimeStop = $impl.GetTickCountX();
            if ((this.FVerticalOffset === 0) && ((this.FTimeStop - this.FTimeStart) < 300) && ((this.FTimeStop - this.FTimeStart) > 0)) {
              this.FSpY = Math.abs(Y - this.FScrollY) / (this.FTimeStop - this.FTimeStart);
              if (this.FSpY > 0) {
                if ((Y - this.FScrollY) > 0) {
                  this.FScrollVTo = Math.max(0,Math.min(this.VerticalScrollBar().FMax - this.GetVViewPortSize(),this.FScrollVTo - Math.round(Math.abs(Y - this.FScrollY) * this.FSpY * f * 3)))}
                 else this.FScrollVTo = Math.max(0,Math.min(this.VerticalScrollBar().FMax - this.GetVViewPortSize(),this.FScrollVTo + Math.round(Math.abs(Y - this.FScrollY) * this.FSpY * f * 3)));
                this.FAnimateVerticalPos = true;
                this.FAnimateTimer.SetEnabled(true);
              };
              this.FSpX = Math.abs(X - this.FScrollX) / (this.FTimeStop - this.FTimeStart);
              if (this.FSpX > 0) {
                if ((X - this.FScrollX) > 0) {
                  this.FScrollHTo = Math.max(0,Math.min(this.HorizontalScrollBar().FMax - this.GetHViewPortSize(),this.FScrollHTo - Math.round(Math.abs(X - this.FScrollX) * this.FSpX * f * 3)))}
                 else this.FScrollHTo = Math.max(0,Math.min(this.HorizontalScrollBar().FMax - this.GetHViewPortSize(),this.FScrollHTo + Math.round(Math.abs(X - this.FScrollX) * this.FSpX * f * 3)));
                this.FAnimateHorizontalPos = true;
                this.FAnimateTimer.SetEnabled(true);
              };
            } else if (this.CanApplyVerticalOffset()) {
              if (this.NeedsReload(this.FVerticalOffset)) this.StartReload();
              this.StartVerticalOffsetAnimation();
            };
          } else {
            if ((this.FDownNode != null) && !this.FBlockMouseClick) {
              en = this.IsVirtualNodeSelectable(this.FDownNode);
              prev = this.FFocusedNode;
              dosel = en;
              if (en) {
                if ((pas.Classes.TShiftState$a.ssShift in Shift) && ($mod.TMultiSelectStyles.msShiftSelect in this.FInteraction.FMultiSelectStyle)) {
                  if (this.FFocusedNode != null) {
                    if (($mod.TMultiSelectStyles.msSiblingOnly in this.FInteraction.FMultiSelectStyle) && (this.FFocusedNode.FParentNode !== this.FDownNode.FParentNode)) {
                      add = 0}
                     else add = 1;
                    if (this.FFocusedNode.FRow <= this.FDownNode.FRow) {
                      for (var $l = this.FFocusedNode.FRow + add, $end = this.FDownNode.FRow; $l <= $end; $l++) {
                        I = $l;
                        this.HandleSelectNode(this.GetNodeFromNodeStructure(I),true,false,(pas.Classes.TShiftState$a.ssShift in Shift) && this.FInteraction.FMultiSelect,this.FDownColumnValue);
                      };
                    } else {
                      for (var $l1 = this.FFocusedNode.FRow - add, $end1 = this.FDownNode.FRow; $l1 >= $end1; $l1--) {
                        I = $l1;
                        this.HandleSelectNode(this.GetNodeFromNodeStructure(I),true,false,(pas.Classes.TShiftState$a.ssShift in Shift) && this.FInteraction.FMultiSelect,this.FDownColumnValue);
                      };
                    };
                  };
                } else {
                  if (($mod.TMultiSelectStyles.msSiblingOnly in this.FInteraction.FMultiSelectStyle) && (this.FFocusedNode != null) && (this.FDownNode.FParentNode !== this.FFocusedNode.FParentNode) && (this.FSelectedNodes.GetCount() > 0)) {
                    this.FSelectedNodes.Clear();
                  } else if (((!(pas.Classes.TShiftState$a.ssCtrl in Shift) && !(pas.Classes.TShiftState$a.ssCtrl in Shift)) || !($mod.TMultiSelectStyles.msControlSelect in this.FInteraction.FMultiSelectStyle)) && (this.FSelectedNodes.GetCount() > 0)) this.UnSelectVirtualNode(this.FDownNode);
                  this.HandleSelectNode(this.FDownNode,true,false,((pas.Classes.TShiftState$a.ssCtrl in Shift) || (pas.Classes.TShiftState$a.ssCtrl in Shift)) && ($mod.TMultiSelectStyles.msControlSelect in this.FInteraction.FMultiSelectStyle) && this.FInteraction.FMultiSelect,this.FDownColumnValue);
                };
              };
              if (dosel) {
                if (this.FFocusedNode !== this.FDownNode) {
                  this.FFocusedNode = this.FDownNode;
                  this.DoFocusedNodeChanged(this.FFocusedNode);
                };
                this.NotifyDataBinderSetActiveRecord();
              };
              if (!this.FCompactMode && ((this.FInteraction.FMouseEditMode === $mod.TTMSFNCTreeViewMouseEditMode.tmemSingleClick) || ((this.FInteraction.FMouseEditMode === $mod.TTMSFNCTreeViewMouseEditMode.tmemSingleClickOnSelectedNode) && (this.FDownNode === prev))) && !this.FInteraction.FReadOnly) {
                if (this.FDownNode != null) {
                  ext = false;
                  this.DoIsNodeExtended(this.FDownNode,{get: function () {
                      return ext;
                    }, set: function (v) {
                      ext = v;
                    }});
                  d = true;
                  this.DoIsNodeEnabled(this.FDownNode,{get: function () {
                      return d;
                    }, set: function (v) {
                      d = v;
                    }});
                  a.$assign(this.XYToNodeTitleAnchor(this.FDownNode,X,Y));
                  if (a.AAnchor !== "") this.DoNodeTitleAnchorClick(this.FDownNode,a.AColumn,a.AAnchor);
                  a.$assign(this.XYToNodeAnchor(this.FDownNode,X,Y));
                  if (d && (a.AAnchor !== "")) {
                    this.DoNodeAnchorClick(this.FDownNode,a.AColumn,a.AAnchor);
                  } else if (((ext && this.FInteraction.FExtendedSelectable && this.FInteraction.FExtendedEditable) || !ext) && d) {
                    t = this.XYToNodeTextColumn(this.FDownNode,X,Y);
                    if ((t !== -1) && this.FDownNode.GetTitleExpanded(t)) {
                      this.HandleNodeEditing(this.FDownNode,t);
                    };
                  };
                };
              };
              this.Invalidate();
            };
          };
        } else if (!this.FCompactMode) {
          if (this.FDoNodeExpand) {
            this.HandleNodeToggle(this.FDownNode)}
           else if (this.FDoNodeExtra) {
            this.HandleNodeExtra(this.FDownNode)}
           else if (this.FDoNodeTitleExtra) {
            this.HandleNodeTitleExtra(this.FDownNode)}
           else if ((this.FDoNodeCheck.ANode != null) && !this.FInteraction.FReadOnly) {
            this.HandleNodeToggleCheck(this.FDownNode,this.FDoNodeCheck.AColumn)}
           else {
            a.$assign(this.XYToNodeAnchor(this.FDownNode,X,Y));
            if (a.AAnchor !== "") this.DoNodeAnchorClick(this.FDownNode,a.AColumn,a.AAnchor);
            a.$assign(this.XYToNodeTitleAnchor(this.FDownNode,X,Y));
            if (a.AAnchor !== "") this.DoNodeTitleAnchorClick(this.FDownNode,a.AColumn,a.AAnchor);
          };
        };
      };
      this.FDoNodeExpand = false;
      this.FDoNodeExtra = false;
      this.FDoNodeTitleExtra = false;
      this.FDoNodeAnchor.AAnchor = "";
      this.FDoNodeAnchor.AColumn = -1;
      this.FDoNodeTitleAnchor.AAnchor = "";
      this.FDoNodeTitleAnchor.AColumn = -1;
      this.FDownColumn = -1;
      this.FDownColumnValue = -1;
      this.FDownColumnFilter = -1;
      this.FDownColumnExpand = -1;
      this.FReorderMode = false;
      this.FDragMode$1 = false;
      this.FDragModeStarted = false;
    };
    this.StartVerticalOffsetAnimation = function () {
      this.FAnimateVerticalOffset = true;
      this.FAnimateTimer.SetEnabled(true);
    };
    this.ClearFocusedNode = function (ANode) {
      if ((ANode === this.FFocusedNode) || (ANode === null)) this.FFocusedNode = null;
    };
    this.SetVerticalOffset = function (AVerticalOffset) {
      this.FVerticalOffsetTo = AVerticalOffset;
    };
    this.HandleKeyPress = function (Key) {
      var k = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyPress.apply(this,arguments);
      if (this.FBlockUserInput) return;
      k = Key.get().charCodeAt();
      if (this.FInteraction.FLookup.FEnabled) {
        if (k in rtl.createSet(27,45,46,38,40,37,39,36,35,33,34,9,0)) {
          this.FLookupString = ""}
         else {
          if (this.FInteraction.FLookup.FIncremental) {
            this.FLookupString = this.FLookupString + Key.get()}
           else this.FLookupString = Key.get();
          if (this.FOnCustomLookup != null) {
            this.FOnCustomLookup(this,this.FLookupString)}
           else {
            this.LookupNode(this.FLookupString,this.FInteraction.FLookup.FRootNodesOnly,this.FInteraction.FLookup.FColumn,this.FInteraction.FLookup.FCaseSensitive,this.FInteraction.FLookup.FAutoSelect,this.FInteraction.FLookup.FAutoExpand);
          };
        };
      };
    };
    this.HandleKeyDown = function (Key, Shift) {
      var sel = null;
      var prevsel = null;
      var fsel = null;
      var sa = false;
      var spc = false;
      var donext = false;
      var doprev = false;
      var r = 0;
      var I = 0;
      var b = false;
      var a = false;
      var n = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      if (this.FInplaceEditorClosed || this.FBlockUserInput) return;
      if (Key.get() in rtl.createSet(27,45,46,38,40,37,39,36,35,33,34,9,106,109,107,111)) this.FLookupString = "";
      if ((pas.Classes.TShiftState$a.ssCtrl in Shift) || (pas.Classes.TShiftState$a.ssCtrl in Shift)) {
        var $tmp = Key.get();
        if ($tmp === 65) {
          if (this.FInteraction.FMultiSelect) {
            sa = true;
            this.DoBeforeSelectAllNodes({get: function () {
                return sa;
              }, set: function (v) {
                sa = v;
              }});
            if (sa) {
              this.SelectAllNodes();
              this.DoAfterSelectAllNodes();
            };
          };
          return;
        } else if ($tmp === 88) {
          if (this.FInteraction.FClipboardMode !== $mod.TTMSFNCTreeViewClipboardMode.tcmNone) {
            b = true;
            this.DoBeforeCutToClipboard({get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }});
            if (b) {
              this.CutToClipboard(this.FInteraction.FClipboardMode === $mod.TTMSFNCTreeViewClipboardMode.tcmTextOnly);
              this.DoAfterCutToClipboard();
            };
          };
          return;
        } else if ($tmp === 67) {
          if (this.FInteraction.FClipboardMode !== $mod.TTMSFNCTreeViewClipboardMode.tcmNone) {
            b = true;
            this.DoBeforeCopyToClipboard({get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }});
            if (b) {
              this.CopyToClipboard(this.FInteraction.FClipboardMode === $mod.TTMSFNCTreeViewClipboardMode.tcmTextOnly);
              this.DoAfterCopyToClipboard();
            };
          };
          return;
        } else if ($tmp === 86) {
          if (this.FInteraction.FClipboardMode !== $mod.TTMSFNCTreeViewClipboardMode.tcmNone) {
            b = true;
            this.DoBeforePasteFromClipboard({get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }});
            if (b) {
              this.PasteFromClipboard();
              this.DoAfterPasteFromClipboard();
            };
          };
          return;
        };
      };
      sel = this.GetFocusedVirtualNode();
      donext = false;
      doprev = false;
      var $tmp1 = Key.get();
      if (($tmp1 === 18) || ($tmp1 === 17) || ($tmp1 === 16)) {
        sel = null}
       else if ($tmp1 === 33) {
        doprev = true;
        if (sel != null) {
          r = sel.FRow - (this.StopRow() - this.StartRow());
          sel = this.GetNodeFromNodeStructure(r);
          if (sel != null) {
            if (!this.IsVirtualNodeSelectable(sel)) sel = this.GetPreviousFocusableNode(sel);
          };
          if (!(sel != null)) sel = this.GetNextFocusableNode(null);
        };
      } else if ($tmp1 === 34) {
        donext = true;
        if (sel != null) {
          r = sel.FRow + (this.StopRow() - this.StartRow());
          sel = this.GetNodeFromNodeStructure(r);
          if (sel != null) {
            if (!this.IsVirtualNodeSelectable(sel)) sel = this.GetNextFocusableNode(sel);
          };
          if (!(sel != null)) sel = this.GetPreviousFocusableNode(null);
        };
      } else if ($tmp1 === 36) {
        sel = this.GetNextFocusableNode(null);
        doprev = true;
      } else if ($tmp1 === 35) {
        sel = this.GetPreviousFocusableNode(null);
        doprev = true;
      } else if ($tmp1 === 40) {
        if (!this.FInteraction.FMultiSelect || (this.FInteraction.FMultiSelect && !(($mod.TMultiSelectStyles.msSiblingOnly in this.FInteraction.FMultiSelectStyle) && (pas.Classes.TShiftState$a.ssCtrl in Shift)))) {
          sel = this.GetNextFocusableNode(sel);
          donext = true;
        };
      } else if ($tmp1 === 38) {
        if (!($mod.TMultiSelectStyles.msSiblingOnly in this.FInteraction.FMultiSelectStyle) || !this.FInteraction.FMultiSelect || !(pas.Classes.TShiftState$a.ssCtrl in Shift)) {
          sel = this.GetPreviousFocusableNode(sel);
          doprev = true;
        };
      } else if (($tmp1 === 37) || ($tmp1 === 109) || ($tmp1 === 111)) {
        this.HandleNodeCollapse(sel,Key.get() === 111)}
       else if (($tmp1 === 39) || ($tmp1 === 107) || ($tmp1 === 106)) {
        this.HandleNodeExpand(sel,Key.get() === 106)}
       else if ($tmp1 === 32) this.DoNodeClick(sel);
      var $tmp2 = Key.get();
      if (($tmp2 === 37) || ($tmp2 === 39)) this.HandleCustomKeys(Key.get());
      spc = false;
      if (Key.get() === 32) spc = true;
      if (sel != null) {
        if ((this.FInteraction.FSelectionFollowsFocus && (donext || doprev)) || (spc && ((pas.Classes.TShiftState$a.ssCtrl in Shift) || (pas.Classes.TShiftState$a.ssCtrl in Shift)))) {
          if (pas.Classes.TShiftState$a.ssShift in Shift) {
            if (this.FSelectedNodes.GetCount() > 1) {
              prevsel = this.FSelectedNodes.GetItem(this.FSelectedNodes.GetCount() - 1);
              fsel = this.FSelectedNodes.GetItem(0);
              if ((doprev && (sel.FRow < prevsel.FRow) && (sel.FRow >= fsel.FRow)) || (donext && (sel.FRow > prevsel.FRow) && (sel.FRow <= fsel.FRow))) {
                if (prevsel.FRow <= sel.FRow) {
                  for (var $l = prevsel.FRow, $end = sel.FRow; $l <= $end; $l++) {
                    I = $l;
                    n = this.GetNodeFromNodeStructure(I);
                    if (n != null) {
                      if (n !== sel) {
                        a = true;
                        this.DoBeforeUnSelectNode(n,{get: function () {
                            return a;
                          }, set: function (v) {
                            a = v;
                          }});
                        if (a) {
                          this.UnSelectVirtualNode(n);
                          this.DoAfterUnSelectNode(n);
                        };
                      } else this.UnSelectVirtualNode(n);
                    };
                  };
                } else {
                  for (var $l1 = prevsel.FRow, $end1 = sel.FRow; $l1 >= $end1; $l1--) {
                    I = $l1;
                    n = this.GetNodeFromNodeStructure(I);
                    if (n != null) {
                      if (n !== sel) {
                        a = true;
                        this.DoBeforeUnSelectNode(n,{get: function () {
                            return a;
                          }, set: function (v) {
                            a = v;
                          }});
                        if (a) {
                          this.UnSelectVirtualNode(n);
                          this.DoAfterUnSelectNode(n);
                        };
                      } else this.UnSelectVirtualNode(n);
                    };
                  };
                };
              };
            };
          } else if (!(pas.Classes.TShiftState$a.ssCtrl in Shift) && !(pas.Classes.TShiftState$a.ssCtrl in Shift) && (donext || doprev) && (this.FSelectedNodes.GetCount() > 0)) {
            a = true;
            this.DoBeforeUnSelectNode(sel,{get: function () {
                return a;
              }, set: function (v) {
                a = v;
              }});
            if (a) {
              this.UnSelectVirtualNode(sel);
              this.DoAfterUnSelectNode(sel);
            };
          };
          if (pas.Classes.TShiftState$a.ssShift in Shift) {
            if (this.FFocusedNode != null) {
              if (this.FFocusedNode.FRow <= sel.FRow) {
                for (var $l2 = this.FFocusedNode.FRow + 1, $end2 = sel.FRow; $l2 <= $end2; $l2++) {
                  I = $l2;
                  this.HandleSelectNode(this.GetNodeFromNodeStructure(I),true,true,(pas.Classes.TShiftState$a.ssShift in Shift) && this.FInteraction.FMultiSelect,-1);
                };
              } else {
                for (var $l3 = this.FFocusedNode.FRow - 1, $end3 = sel.FRow; $l3 >= $end3; $l3--) {
                  I = $l3;
                  this.HandleSelectNode(this.GetNodeFromNodeStructure(I),true,true,(pas.Classes.TShiftState$a.ssShift in Shift) && this.FInteraction.FMultiSelect,-1);
                };
              };
            };
          } else this.HandleSelectNode(sel,true,true,((pas.Classes.TShiftState$a.ssCtrl in Shift) || (pas.Classes.TShiftState$a.ssCtrl in Shift)) && this.FInteraction.FMultiSelect,-1);
        } else if (spc) this.HandleNodeToggleCheck(sel,0);
        if (this.FFocusedNode !== sel) {
          this.FFocusedNode = sel;
          this.DoFocusedNodeChanged(this.FFocusedNode);
          this.NotifyDataBinderSetActiveRecord();
        };
        if (donext) {
          this.ScrollToVirtualNode(this.FFocusedNode,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspBottom,false)}
         else this.ScrollToVirtualNode(this.FFocusedNode,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
        this.Invalidate();
      };
    };
    this.HandleDialogKey = function (Key, Shift) {
      var n = null;
      var c = 0;
      var ext = false;
      if (this.FInplaceEditorClosed || this.FBlockUserInput) {
        pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDialogKey.apply(this,arguments);
        return;
      };
      if (((this.FInplaceEditor != null) && this.FInplaceEditorActive && ((Key.get() === 27) || (Key.get() === 9) || (Key.get() === 113) || (pas["WEBLib.StdCtrls"].TEdit.isPrototypeOf(this.FInplaceEditor) && (Key.get() === 13)))) || (pas["WEBLib.StdCtrls"].TMemo.isPrototypeOf(this.FInplaceEditor) && (Key.get() === 13) && !(pas.Classes.TShiftState$a.ssCtrl in Shift))) {
        this.FCloseWithDialogKey = true;
        this.CloseInplaceEditor(Key.get() === 27,false);
        if (Key.get() === 9) {
          if (this.FFocusedNode != null) {
            if (pas.Classes.TShiftState$a.ssShift in Shift) {
              ext = false;
              this.DoIsNodeExtended(this.FFocusedNode,{get: function () {
                  return ext;
                }, set: function (v) {
                  ext = v;
                }});
              if ((this.FUpdateNodeColumn > this.GetFirstEditableColumn()) && !ext) {
                this.HandleNodeEditing(this.FFocusedNode,this.GetPreviousEditableColumn(this.FUpdateNodeColumn));
                this.Invalidate();
                Key.set(0);
              } else {
                n = this.GetPreviousFocusableNode(this.FFocusedNode);
                if (n != null) {
                  ext = false;
                  this.DoIsNodeExtended(n,{get: function () {
                      return ext;
                    }, set: function (v) {
                      ext = v;
                    }});
                  if ((ext && this.FInteraction.FExtendedEditable) || !ext) {
                    if (!ext) {
                      c = this.GetLastEditableColumn()}
                     else c = 0;
                    if (this.FFocusedNode !== n) {
                      this.FFocusedNode = n;
                      this.DoFocusedNodeChanged(this.FFocusedNode);
                    };
                    this.SelectVirtualNode(n);
                    this.ScrollToVirtualNode(n,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
                    this.NotifyDataBinderSetActiveRecord();
                    this.HandleNodeEditing(n,c);
                    this.Invalidate();
                    Key.set(0);
                  };
                };
              };
            } else {
              ext = false;
              this.DoIsNodeExtended(this.FFocusedNode,{get: function () {
                  return ext;
                }, set: function (v) {
                  ext = v;
                }});
              if ((this.FUpdateNodeColumn < this.GetLastEditableColumn()) && !ext) {
                this.EditVirtualNode(this.FFocusedNode,this.GetNextEditableColumn(this.FUpdateNodeColumn));
                Key.set(0);
              } else {
                n = this.GetNextFocusableNode(this.FFocusedNode);
                if (n != null) {
                  ext = false;
                  this.DoIsNodeExtended(n,{get: function () {
                      return ext;
                    }, set: function (v) {
                      ext = v;
                    }});
                  if ((ext && this.FInteraction.FExtendedEditable) || !ext) {
                    c = this.GetFirstEditableColumn();
                    if (this.FFocusedNode !== n) {
                      this.FFocusedNode = n;
                      this.DoFocusedNodeChanged(this.FFocusedNode);
                    };
                    this.SelectVirtualNode(n);
                    this.ScrollToVirtualNode(n,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspBottom,false);
                    this.NotifyDataBinderSetActiveRecord();
                    this.HandleNodeEditing(n,c);
                    this.Invalidate();
                    Key.set(0);
                  };
                };
              };
            };
          };
        };
      };
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDialogKey.apply(this,arguments);
    };
    this.HandleFilterListClick = function (Sender) {
      this.FFilterTimer.SetEnabled(true);
    };
    this.HandleKeyUp = function (Key, Shift) {
      var en = false;
      var ext = false;
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyUp.apply(this,arguments);
      if (this.FBlockUserInput) return;
      if (this.FInplaceEditorClosed) {
        this.FInplaceEditorClosed = false;
        return;
      };
      if (this.FCloseWithDialogKey) {
        this.FCloseWithDialogKey = false;
        return;
      };
      if (this.FFocusedNode != null) {
        if (!this.FCompactMode && this.FInteraction.FKeyboardEdit && !this.FInteraction.FReadOnly && rtl.eqSet(Shift,{})) {
          var $tmp = Key.get();
          if (($tmp === 113) || ($tmp === 13)) {
            en = true;
            this.DoIsNodeEnabled(this.FFocusedNode,{get: function () {
                return en;
              }, set: function (v) {
                en = v;
              }});
            if (en) {
              ext = false;
              this.DoIsNodeExtended(this.FFocusedNode,{get: function () {
                  return ext;
                }, set: function (v) {
                  ext = v;
                }});
              if ((ext && this.FInteraction.FExtendedSelectable && this.FInteraction.FExtendedEditable) || !ext) {
                c = this.GetFirstEditableColumn();
                if ((c !== -1) && this.FFocusedNode.GetTitleExpanded(c)) this.HandleNodeEditing(this.FFocusedNode,c);
              };
            };
          };
        };
      };
    };
    this.HandleMouseWheel = function (Shift, WheelDelta, Handled) {
      var vpos = 0.0;
      var hpos = 0.0;
      var sz = 0.0;
      var R = 0;
      var nd = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseWheel.apply(this,arguments);
      if (Handled.get()) return;
      if (this.FBlockUserInput) return;
      vpos = this.GetVScrollValue();
      hpos = this.GetHScrollValue();
      if (WheelDelta > 0) {
        R = this.StartRow() - 1}
       else R = this.StartRow();
      nd = this.GetVisibleNodeForIndex(R);
      if (nd != null) {
        if (WheelDelta > 0) {
          sz = nd.FHeight * this.FInteraction.FMouseWheelDelta;
          this.Scroll(hpos,vpos - sz);
        } else {
          sz = nd.FHeight * this.FInteraction.FMouseWheelDelta;
          this.Scroll(hpos,vpos + sz);
        };
      } else this.Scroll(hpos,0);
      Handled.set(true);
    };
    this.HandleNodeEditing = function (ANode, AColumn) {
      var $Self = this;
      var c = null;
      var ins = false;
      var n = "";
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rtr = pas.Types.TRect.$new();
      function CreateCaretPos(ALine, APos) {
        var Result = pas.Types.TPoint.$new();
        Result.x = ALine;
        Result.y = APos;
        return Result;
      };
      if ((ANode != null) && (AColumn >= 0) && (AColumn <= (this.FColumns.GetCount() - 1))) {
        c = this.FColumns.GetItem$1(AColumn);
        this.FInplaceEditorClass = null;
        if (!c.FCustomEditor) {
          var $tmp = c.FEditorType;
          if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetEdit) {
            this.FInplaceEditorClass = $mod.TTMSFNCTreeViewEdit}
           else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetComboBox) {
            this.FInplaceEditorClass = $mod.TTMSFNCTreeViewComboBox}
           else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetMemo) {
            this.FInplaceEditorClass = $mod.TTMSFNCTreeViewMemo}
           else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetNone) return;
        };
        ins = true;
        this.DoBeforeOpenInplaceEditor(ANode,AColumn,{get: function () {
            return ins;
          }, set: function (v) {
            ins = v;
          }});
        if (ins) {
          this.DoGetInplaceEditor(ANode,AColumn,{p: this, get: function () {
              return this.p.FInplaceEditorClass;
            }, set: function (v) {
              this.p.FInplaceEditorClass = v;
            }});
          if (this.FInplaceEditor != null) {
            if (this.FOldInplaceEditor != null) rtl.free(this,"FOldInplaceEditor");
            this.FOldInplaceEditor = this.FInplaceEditor;
            this.FInplaceEditor = null;
          };
          if (this.FInplaceEditorClass != null) {
            this.FInplaceEditor = this.FInplaceEditorClass.$create("Create$1",[$Self])}
           else this.FInplaceEditor = pas["WEBLib.StdCtrls"].TEdit.$create("Create$1",[$Self]);
          r.$assign(this.GetInplaceEditorRect(ANode,AColumn));
          if (this.FInplaceEditor != null) {
            this.FUpdateNode = ANode;
            this.FUpdateNodeColumn = AColumn;
            this.FInplaceEditor.SetShowFocus(false);
            this.FInplaceEditor.SetParent($Self);
            this.FInplaceEditor.SetVisible(false);
            rtr.$assign(pas.Types.Rect(Math.round(r.Left),Math.round(r.Top),Math.round(r.Right),Math.round(r.Bottom)));
            this.FInplaceEditor.SetBoundsRect(rtr);
            this.FInplaceEditor.SetBoundsRect(pas.Types.Rect(rtr.Left,rtr.Top + rtl.trunc((rtr.Bottom - rtr.Top - this.FInplaceEditor.GetHeight()) / 2),rtr.Right,rtr.Top + rtl.trunc((rtr.Bottom - rtr.Top - this.FInplaceEditor.GetHeight()) / 2) + this.FInplaceEditor.GetHeight()));
            this.FInplaceEditor.SetVisible(true);
            if ((c.FEditorType === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetComboBox) && !c.FCustomEditor && pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(this.FInplaceEditor)) {
              rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TComboBox).FItems.Assign(c.FEditorItems);
              rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TComboBox).SetStyle(pas["WEBLib.StdCtrls"].TComboBoxStyle.csDropDownList);
            };
            this.CustomizeInplaceEditor(this.FInplaceEditor,ANode,c);
            try {
              n = "";
              this.DoGetNodeText(ANode,AColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmEditing,{get: function () {
                  return n;
                }, set: function (v) {
                  n = v;
                }});
              if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(this.FInplaceEditor)) rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TComboBox).SetItemIndex(rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TComboBox).FItems.IndexOf(n));
              if (pas["WEBLib.StdCtrls"].TEdit.isPrototypeOf(this.FInplaceEditor)) rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TEdit).SetText(n);
              if (pas["WEBLib.StdCtrls"].TMemo.isPrototypeOf(this.FInplaceEditor)) rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).SetText(n);
            } finally {
            };
            if (this.FInplaceEditor.CanFocus()) this.FInplaceEditor.SetFocus();
            if (pas["WEBLib.StdCtrls"].TEdit.isPrototypeOf(this.FInplaceEditor)) rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TEdit).SetSelStart(rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TEdit).GetText().length);
            if (pas["WEBLib.StdCtrls"].TMemo.isPrototypeOf(this.FInplaceEditor)) {
              rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).SetSelLength(0);
              if (rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).FLines.GetCount() > 0) {
                rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).FCaretPosition.$assign(CreateCaretPos(rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).FLines.GetCount() - 1,rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).FLines.Get(rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).FLines.GetCount() - 1).length))}
               else rtl.as(this.FInplaceEditor,pas["WEBLib.StdCtrls"].TMemo).FCaretPosition.$assign(CreateCaretPos(0,0));
            };
            this.FInplaceEditorActive = true;
            this.Invalidate();
          };
          this.DoAfterOpenInplaceEditor(ANode,AColumn,this.FInplaceEditor,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        };
      };
    };
    this.CustomizeInplaceEditor = function (AInplaceEditor, ANode, AColumn) {
      if (!(ANode != null) || !(AColumn != null) || !(AInplaceEditor != null)) return;
      this.DoCustomizeInplaceEditor(ANode,AColumn.GetIndex(),this.FInplaceEditor);
    };
    this.StartReload = function () {
      this.FVerticalOffsetTo = this.GetReloadOffset();
      this.StartVerticalOffsetAnimation();
    };
    this.ConfigureNodeRect = function (AIndex, ANode, ARect) {
    };
    this.GetDefaultRowHeight = function (ANode) {
      var Result = 0.0;
      var loff = 0.0;
      var toff = 0.0;
      var roff = 0.0;
      var boff = 0.0;
      Result = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.GetDefaultRowHeight.call(this,ANode);
      loff = 0;
      toff = 0;
      roff = 0;
      boff = 0;
      this.GetNodeOffset(ANode,{get: function () {
          return loff;
        }, set: function (v) {
          loff = v;
        }},{get: function () {
          return toff;
        }, set: function (v) {
          toff = v;
        }},{get: function () {
          return roff;
        }, set: function (v) {
          roff = v;
        }},{get: function () {
          return boff;
        }, set: function (v) {
          boff = v;
        }});
      Result = Result + toff + boff;
      return Result;
    };
    this.GetNodeOffset = function (ANode, ALeft, ATop, ARight, ABottom) {
    };
    this.GetNodeMargins = function (ALeft, ATop, ARight, ABottom) {
    };
    this.HandleAlternativeDragOver = function (X, Y) {
    };
    this.HandleAlternativeDragDrop = function (X, Y) {
    };
    this.InternalSelectVirtualNode = function (ANode) {
    };
    this.CanStartDragFromMouseDown = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CanStartDragFromMouseMove = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.AlternativeDragDrop = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetNodesSpacing = function (ANode) {
      var Result = 0.0;
      Result = this.FNodesAppearance.FSpacing;
      return Result;
    };
    this.IsAnimating = function () {
      var Result = false;
      Result = (this.FAnimateTimer.FEnabled === true) && this.FAnimating;
      return Result;
    };
    this.GetNodesRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetContentRect());
      return Result;
    };
    this.CanApplyVerticalOffset = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetReloadOffset = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.NeedsReload = function (AVerticalOffset) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.IsVariableNodeHeight = function () {
      var Result = false;
      Result = this.FNodesAppearance.FHeightMode === $mod.TTMSFNCTreeViewNodeHeightMode.tnhmVariable;
      return Result;
    };
    this.GetDragObjectScreenShot = function () {
      var Result = null;
      this.CreateDragBitmap();
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      if (this.FDragBitmap != null) {
        Result.Assign(this.FDragBitmap.GetBitmap());
        rtl.free(this,"FDragBitmap");
        this.FDragBitmap = null;
      };
      return Result;
    };
    this.ColumnStretchingActive = function () {
      var Result = false;
      Result = this.FColumnStretchingActive;
      return Result;
    };
    this.GetBufStart = function (ABuffer, ALevel) {
      var Result = "";
      var Pos = 0;
      Pos = 1;
      ALevel.set(0);
      while (pas["WEBLib.TMSFNCTypes"].CharInArray(ABuffer.charAt(Pos - 1),[" ","\t"])) {
        Pos += 1;
        ALevel.set(ALevel.get() + 1);
      };
      Result = pas.System.Copy(ABuffer,Pos,(ABuffer.length - Pos) + 1);
      return Result;
    };
    this.GetFirstEditableColumn = function () {
      var Result = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ((this.FColumns.GetItem$1(I).FEditorType !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetNone) || this.FColumns.GetItem$1(I).FCustomEditor) {
          Result = I;
          break;
        };
      };
      return Result;
    };
    this.GetLastEditableColumn = function () {
      var Result = 0;
      var I = 0;
      Result = -1;
      for (var $l = this.FColumns.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        if ((this.FColumns.GetItem$1(I).FEditorType !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetNone) || this.FColumns.GetItem$1(I).FCustomEditor) {
          Result = I;
          break;
        };
      };
      return Result;
    };
    this.GetPreviousEditableColumn = function (AColumn) {
      var Result = 0;
      var I = 0;
      Result = -1;
      if ((AColumn > 0) && (AColumn <= (this.FColumns.GetCount() - 1))) {
        for (var $l = AColumn - 1; $l >= 0; $l--) {
          I = $l;
          if ((this.FColumns.GetItem$1(I).FEditorType !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetNone) || this.FColumns.GetItem$1(I).FCustomEditor) {
            Result = I;
            break;
          };
        };
      };
      return Result;
    };
    this.GetNextEditableColumn = function (AColumn) {
      var Result = 0;
      var I = 0;
      Result = -1;
      if ((AColumn >= 0) && (AColumn < (this.FColumns.GetCount() - 1))) {
        for (var $l = AColumn + 1, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ((this.FColumns.GetItem$1(I).FEditorType !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnEditorType.tcetNone) || this.FColumns.GetItem$1(I).FCustomEditor) {
            Result = I;
            break;
          };
        };
      };
      return Result;
    };
    this.GetInplaceEditorRect = function (ANode, AColumn) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sts = 0;
      var c = 0;
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      if (!(ANode != null)) return Result;
      sts = this.GetFirstVisibleColumn();
      c = AColumn - sts;
      if ((c >= 0) && (c <= (rtl.length(ANode.FTextRects) - 1))) {
        r.$assign(ANode.FTextRects[c]);
        cr.$assign(this.GetContentClipRect());
        Result.$assign(r);
        Result.Top = Math.max(Result.Top,cr.Top);
        Result.Bottom = Math.min(Result.Bottom,cr.Bottom);
        Result.Left = Math.max(Result.Left,cr.Left);
        Result.Right = Math.min(Result.Right,cr.Right);
        Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.Math.Floor(Result.Left),pas.Math.Floor(Result.Top),pas.Math.Floor(Result.Right),pas.Math.Floor(Result.Bottom)));
        if (this.FOnGetInplaceEditorRect != null) this.FOnGetInplaceEditorRect(this,ANode,AColumn,this.FInplaceEditor,Result);
      };
      return Result;
    };
    this.GetNextFocusableNode = function (ANode) {
      var Result = null;
      var en = false;
      if (ANode != null) {
        Result = this.GetNextVirtualNode(ANode)}
       else Result = this.GetFirstRootVirtualNode();
      en = this.IsVirtualNodeSelectable(Result);
      while ((Result != null) && !en) {
        Result = this.GetNextVirtualNode(Result);
        en = this.IsVirtualNodeSelectable(Result);
      };
      return Result;
    };
    this.GetPreviousFocusableNode = function (ANode) {
      var Result = null;
      var en = false;
      if (ANode != null) {
        Result = this.GetPreviousVirtualNode(ANode)}
       else Result = this.GetLastVirtualNode();
      en = this.IsVirtualNodeSelectable(Result);
      while ((Result != null) && !en) {
        Result = this.GetPreviousVirtualNode(Result);
        en = this.IsVirtualNodeSelectable(Result);
      };
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,2,2,6);
      return Result;
    };
    this.GetFirstVisibleColumn = function () {
      var Result = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      Result = 0;
      if (!this.FColumnsAppearance.FOptimizedColumnDisplay) return Result;
      r.$assign(this.GetNodesRect());
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ((this.GetColPos(I) + this.GetColWidths(I)) >= (r.Left + this.GetHorizontalScrollPosition())) {
          Result = I;
          break;
        };
      };
      return Result;
    };
    this.GetLastVisibleColumn = function () {
      var Result = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      Result = this.FColumns.GetCount() - 1;
      if (!this.FColumnsAppearance.FOptimizedColumnDisplay) return Result;
      r.$assign(this.GetNodesRect());
      for (var $l = Result; $l >= 0; $l--) {
        I = $l;
        if (this.GetColPos(I) <= (r.Right + this.GetHorizontalScrollPosition())) {
          Result = I;
          break;
        };
      };
      return Result;
    };
    this.ConfigureNode = function (AGraphics, AIndex, ANode, AStartY) {
      var Result = false;
      var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bw = 0.0;
      var bh = 0.0;
      var x = 0.0;
      var y = 0.0;
      var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cache = null;
      var C = 0;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var urc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var vs = 0.0;
      var v = null;
      var lvlw = 0.0;
      var rcalc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rcalctw = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rcalct = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var strc = "";
      var strt = "";
      var texp = false;
      var cx = 0.0;
      var cw = 0.0;
      var maxh = 0.0;
      var st = 0;
      var stp = 0;
      var bmpn = null;
      var bmpw = 0.0;
      var bmph = 0.0;
      var expw = 0.0;
      var exph = 0.0;
      var ww = false;
      var wwt = false;
      var colw = 0.0;
      var chk = 0;
      var ext = false;
      var chksz = 0.0;
      var cl = null;
      var expr = [];
      var bmpr = [];
      var txtr = [];
      var titr = [];
      var chkr = [];
      var extr = [];
      var textr = [];
      var vl = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sz = 0.0;
      var szt = 0.0;
      var th = 0.0;
      var loff = 0.0;
      var toff = 0.0;
      var roff = 0.0;
      var boff = 0.0;
      var lm = 0.0;
      var tm = 0.0;
      var rm = 0.0;
      var bm = 0.0;
      this.DoGetNodeData(ANode);
      loff = 0;
      toff = 0;
      roff = 0;
      boff = 0;
      this.GetNodeOffset(ANode,{get: function () {
          return loff;
        }, set: function (v) {
          loff = v;
        }},{get: function () {
          return toff;
        }, set: function (v) {
          toff = v;
        }},{get: function () {
          return roff;
        }, set: function (v) {
          roff = v;
        }},{get: function () {
          return boff;
        }, set: function (v) {
          boff = v;
        }});
      lm = 0;
      tm = 0;
      rm = 0;
      bm = 0;
      this.GetNodeMargins({get: function () {
          return lm;
        }, set: function (v) {
          lm = v;
        }},{get: function () {
          return tm;
        }, set: function (v) {
          tm = v;
        }},{get: function () {
          return rm;
        }, set: function (v) {
          rm = v;
        }},{get: function () {
          return bm;
        }, set: function (v) {
          bm = v;
        }});
      vs = this.GetVerticalScrollPosition();
      cr.$assign(this.GetNodesRect());
      v = ANode;
      bw = this.GetTotalColumnNodeWidth() - rm - lm;
      lvlw = this.FNodesAppearance.FLevelIndent * v.FLevel;
      if (this.FNodesAppearance.FExpandColumn === this.GetFirstVisibleColumn()) {
        x = lvlw;
        bw = bw - lvlw;
      } else x = 0;
      maxh = 0;
      y = AStartY.get();
      bh = 0;
      x = x + lm;
      y = y + tm;
      rt.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(x),pas.System.Int(y),pas.System.Int(x + bw),pas.System.Int(y + bh)));
      if (this.HorizontalScrollBar().FVisible || this.FColumnsAppearance.FStretch) {
        if (AIndex === 0) {
          rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left + 1.5,rt.Top + 1.5,rt.Right - 1.5,rt.Bottom + 0.5))}
         else if (AIndex === (this.FRowCount - 1)) {
          rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left + 1.5,rt.Top + 0.5,rt.Right - 1.5,rt.Bottom + 0.5))}
         else rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left + 1.5,rt.Top + 0.5,rt.Right - 1.5,rt.Bottom + 0.5));
      } else {
        if (AIndex === 0) {
          rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left + 1.5,rt.Top + 1.5,rt.Right - 0.5,rt.Bottom + 0.5))}
         else if (AIndex === (this.FRowCount - 1)) {
          rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left + 1.5,rt.Top + 0.5,rt.Right - 0.5,rt.Bottom + 0.5))}
         else rc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rt.Left + 1.5,rt.Top + 0.5,rt.Right - 0.5,rt.Bottom + 0.5));
      };
      this.ConfigureNodeRect(AIndex,ANode,rc);
      if (v.FCalculated) {
        bh = v.FHeight}
       else {
        this.UpdateNodeCalculated(v,true);
        if (this.FNodesAppearance.FHeightMode === $mod.TTMSFNCTreeViewNodeHeightMode.tnhmVariable) {
          st = this.GetFirstVisibleColumn();
          stp = this.GetLastVisibleColumn();
          ext = false;
          this.DoIsNodeExtended(v,{get: function () {
              return ext;
            }, set: function (v) {
              ext = v;
            }});
          if (ext) stp = Math.min(st,stp);
          for (var $l = st, $end = stp; $l <= $end; $l++) {
            C = $l;
            colw = this.GetColWidths(C);
            if ((colw > 0) || ext) {
              strc = "";
              this.DoGetNodeText(v,C,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return strc;
                }, set: function (v) {
                  strc = v;
                }});
              strt = "";
              this.DoGetNodeTitle(v,C,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return strt;
                }, set: function (v) {
                  strt = v;
                }});
              texp = true;
              this.DoGetNodeTitleExpanded(v,C,{get: function () {
                  return texp;
                }, set: function (v) {
                  texp = v;
                }});
              if (this.FCompactMode) {
                strt = "";
                strc = "";
                texp = false;
              };
              cx = this.GetColPos(C);
              if (C === st) cx = cx + rc.Left;
              if (ext) {
                cw = cx + bw}
               else cw = cx + this.GetColWidths(C);
              if (C === st) cw = cw - rc.Left;
              if ((this.FNodesAppearance.FExpandColumn === C) && (C > st)) cx = cx + lvlw;
              cw = cw - loff - roff - rm - lm;
              if (C === this.FNodesAppearance.FExpandColumn) {
                expw = this.FNodesAppearance.FExpandWidth + this.ScalePaintValue(4);
                exph = this.FNodesAppearance.FExpandHeight + this.ScalePaintValue(4);
                cx = cx + expw;
                if (exph > maxh) maxh = exph;
              };
              chk = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone;
              this.DoGetNodeCheckType(v,C,{get: function () {
                  return chk;
                }, set: function (v) {
                  chk = v;
                }});
              if (chk !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone) {
                chksz = this.ScalePaintValue(this.FCheckStartSize);
                cx = cx + Math.max(0,chksz + 4);
                if (chksz > maxh) maxh = chksz;
              };
              bmpn = null;
              this.DoGetNodeIcon(v,C,false,{get: function () {
                  return bmpn;
                }, set: function (v) {
                  bmpn = v;
                }});
              if (!(bmpn != null) && pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHighDPIScale(null,-1)) this.DoGetNodeIcon(v,C,true,{get: function () {
                  return bmpn;
                }, set: function (v) {
                  bmpn = v;
                }});
              if ((bmpn != null) && (bmpn.GetWidth() > 0) && (bmpn.GetHeight() > 0)) {
                bmpw = bmpn.GetWidth() + this.ScalePaintValue(4);
                bmph = bmpn.GetHeight() + this.ScalePaintValue(4);
                this.DoGetNodeIconSize(v,C,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHighDPIScale(null,-1),bmpn,{get: function () {
                    return bmpw;
                  }, set: function (v) {
                    bmpw = v;
                  }},{get: function () {
                    return bmph;
                  }, set: function (v) {
                    bmph = v;
                  }});
                cx = cx + bmpw;
                if (bmph > maxh) maxh = bmph;
              };
              ww = false;
              wwt = false;
              if ((C >= 0) && (C <= (this.FColumns.GetCount() - 1))) {
                ww = this.FColumns.GetItem$1(C).FWordWrapping;
                wwt = this.FColumns.GetItem$1(C).FTitleWordWrapping;
              };
              this.DoGetNodeWordWrapping(v,C,{get: function () {
                  return ww;
                }, set: function (v) {
                  ww = v;
                }});
              this.DoGetNodeTitleWordWrapping(v,C,{get: function () {
                  return wwt;
                }, set: function (v) {
                  wwt = v;
                }});
              sz = 0;
              this.DoGetNodeExtraSize(v,C,{get: function () {
                  return sz;
                }, set: function (v) {
                  sz = v;
                }});
              szt = 0;
              this.DoGetNodeTitleExtraSize(v,C,{get: function () {
                  return szt;
                }, set: function (v) {
                  szt = v;
                }});
              rcalc.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cx,0,cw - sz,10000));
              pas["WEBLib.TMSFNCTypes"].InflateRectEx(rcalc,this.ScalePaintValue(-2),0);
              rcalctw.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cx,0,cw - szt,10000));
              pas["WEBLib.TMSFNCTypes"].InflateRectEx(rcalctw,this.ScalePaintValue(-2),0);
              cl = null;
              if ((C >= 0) && (C <= (this.FColumnCount - 1))) cl = this.FColumns.GetItem$1(C);
              if ((cl != null) && !cl.FUseDefaultAppearance && !ext) {
                AGraphics.FFont.Assign(cl.FFont)}
               else {
                if (ext) {
                  AGraphics.FFont.Assign(this.FNodesAppearance.FExtendedFont)}
                 else AGraphics.FFont.Assign(this.FNodesAppearance.FFont);
              };
              if (texp) {
                rcalc.$assign(AGraphics.CalculateText(strc,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rcalc),ww,true));
                rcalc.Bottom = rcalc.Bottom + this.ScalePaintValue(4);
                vl = rcalc.Bottom - rcalc.Top;
              } else vl = 0;
              if (strt !== "") {
                if ((cl != null) && !cl.FUseDefaultAppearance) {
                  AGraphics.FFont.Assign(cl.FTitleFont)}
                 else AGraphics.FFont.Assign(this.FNodesAppearance.FTitleFont);
                rcalct.$assign(AGraphics.CalculateText(strt,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rcalctw),wwt,true));
                rcalct.Bottom = rcalct.Bottom + this.ScalePaintValue(4);
                th = rcalct.Bottom - rcalct.Top;
              } else th = 0;
              this.UpdateNodeTitleHeight(v,Math.max(szt,th));
              vl = vl + v.FTitleHeight;
              this.DoGetNodeHeight(v,C,{get: function () {
                  return vl;
                }, set: function (v) {
                  vl = v;
                }});
              if (vl > maxh) maxh = vl;
            };
          };
          bh = Math.max(this.GetDefaultRowHeight(v),maxh + toff + boff + this.GetNodesSpacing(v));
          this.UpdateNodeHeight(v,pas.System.Int(bh));
          this.FTotalRowHeight = (this.FTotalRowHeight - this.GetDefaultRowHeight(v)) + v.FHeight;
        } else {
          bh = this.GetDefaultRowHeight(v);
          this.UpdateNodeHeight(v,bh);
        };
      };
      AStartY.set(AStartY.get() + pas.System.Int(bh));
      rc.Bottom = rc.Bottom + pas.System.Int(bh);
      rc.Bottom = rc.Bottom - this.GetNodesSpacing(ANode);
      urc.$assign(rc);
      urc.Left = urc.Left + loff;
      urc.Top = urc.Top + toff;
      urc.Right = urc.Right + roff;
      urc.Bottom = urc.Bottom + boff;
      extr = rtl.arraySetLength(extr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      textr = rtl.arraySetLength(textr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      txtr = rtl.arraySetLength(txtr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      titr = rtl.arraySetLength(titr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      bmpr = rtl.arraySetLength(bmpr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      expr = rtl.arraySetLength(expr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      chkr = rtl.arraySetLength(chkr,pas["WEBLib.TMSFNCTypes"].TRectF,0);
      st = this.GetFirstVisibleColumn();
      stp = this.GetLastVisibleColumn();
      ext = false;
      this.DoIsNodeExtended(v,{get: function () {
          return ext;
        }, set: function (v) {
          ext = v;
        }});
      if (ext) stp = Math.min(st,stp);
      for (var $l1 = st, $end1 = stp; $l1 <= $end1; $l1++) {
        C = $l1;
        colw = this.GetColumnWidth(C);
        cx = this.GetColumnPosition(C);
        if (C === st) cx = cx + urc.Left;
        if (ext) {
          cw = cx + bw}
         else cw = cx + colw;
        if (C === st) cw = cw - urc.Left;
        if ((this.FNodesAppearance.FExpandColumn === C) && (C > st)) cx = cx + lvlw;
        if (ext) cw = cw + lvlw;
        cw = cw - rm - roff;
        expw = 0;
        exph = 0;
        if (C === this.FNodesAppearance.FExpandColumn) {
          expw = this.FNodesAppearance.FExpandWidth + this.ScalePaintValue(4);
          exph = this.FNodesAppearance.FExpandHeight + this.ScalePaintValue(4);
        };
        expr = rtl.arraySetLength(expr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(expr) + 1);
        expr[rtl.length(expr) - 1].$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(cx + this.ScalePaintValue(2)),pas.System.Int(urc.Top + ((urc.Bottom - urc.Top - exph) / 2) + this.ScalePaintValue(2)),pas.System.Int((cx + expw) - this.ScalePaintValue(2)),pas.System.Int((urc.Top + ((urc.Bottom - urc.Top - exph) / 2) + exph) - this.ScalePaintValue(2))));
        cx = cx + expw;
        chk = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone;
        chksz = 0;
        this.DoGetNodeCheckType(v,C,{get: function () {
            return chk;
          }, set: function (v) {
            chk = v;
          }});
        if (chk !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone) {
          chksz = this.ScalePaintValue(this.FCheckStartSize);
        };
        chkr = rtl.arraySetLength(chkr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(chkr) + 1);
        chkr[rtl.length(chkr) - 1].$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(cx + this.ScalePaintValue(4)),pas.System.Int(urc.Top + ((urc.Bottom - urc.Top - chksz) / 2) + this.ScalePaintValue(2)),pas.System.Int(cx + chksz),pas.System.Int((urc.Top + ((urc.Bottom - urc.Top - chksz) / 2) + chksz) - this.ScalePaintValue(2))));
        cx = cx + Math.max(0,chksz + 4);
        bmpn = null;
        this.DoGetNodeIcon(v,C,false,{get: function () {
            return bmpn;
          }, set: function (v) {
            bmpn = v;
          }});
        if (!(bmpn != null) && pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHighDPIScale(null,-1)) this.DoGetNodeIcon(v,C,true,{get: function () {
            return bmpn;
          }, set: function (v) {
            bmpn = v;
          }});
        bmpw = 0;
        bmph = 0;
        if ((bmpn != null) && (bmpn.GetWidth() > 0) && (bmpn.GetHeight() > 0)) {
          bmpw = bmpn.GetWidth() + this.ScalePaintValue(4);
          bmph = bmpn.GetHeight() + this.ScalePaintValue(4);
          this.DoGetNodeIconSize(v,C,pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHighDPIScale(null,-1),bmpn,{get: function () {
              return bmpw;
            }, set: function (v) {
              bmpw = v;
            }},{get: function () {
              return bmph;
            }, set: function (v) {
              bmph = v;
            }});
        };
        bmpr = rtl.arraySetLength(bmpr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(bmpr) + 1);
        bmpr[rtl.length(bmpr) - 1].$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(cx + this.ScalePaintValue(2)),pas.System.Int(urc.Top + ((urc.Bottom - urc.Top - bmph) / 2) + this.ScalePaintValue(2)),pas.System.Int((cx + bmpw) - this.ScalePaintValue(2)),pas.System.Int((urc.Top + ((urc.Bottom - urc.Top - bmph) / 2) + bmph) - this.ScalePaintValue(2))));
        cx = cx + bmpw;
        sz = 0;
        this.DoGetNodeExtraSize(v,C,{get: function () {
            return sz;
          }, set: function (v) {
            sz = v;
          }});
        szt = 0;
        this.DoGetNodeTitleExtraSize(v,C,{get: function () {
            return szt;
          }, set: function (v) {
            szt = v;
          }});
        if (((v.GetTitle(C) !== "") || (v.FTitleHeight > 0)) && (v.GetText(C) !== "") && v.GetTitleExpanded(C)) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cx,urc.Top,cw - szt,urc.Top + v.FTitleHeight));
          titr = rtl.arraySetLength(titr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(titr) + 1);
          titr[rtl.length(titr) - 1].$assign(r);
          textr = rtl.arraySetLength(textr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(textr) + 1);
          textr[rtl.length(textr) - 1].$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right,urc.Top,r.Right + szt,urc.Top + szt));
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cx,r.Bottom,cw - sz,urc.Bottom));
          txtr = rtl.arraySetLength(txtr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(txtr) + 1);
          txtr[rtl.length(txtr) - 1].$assign(r);
        } else {
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cx,urc.Top + ((urc.Bottom - urc.Top - (rc.Bottom - rc.Top)) / 2),cw - szt,urc.Top + ((urc.Bottom - urc.Top - (rc.Bottom - rc.Top)) / 2) + (rc.Bottom - rc.Top)));
          titr = rtl.arraySetLength(titr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(titr) + 1);
          titr[rtl.length(titr) - 1].$assign(r);
          textr = rtl.arraySetLength(textr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(textr) + 1);
          textr[rtl.length(textr) - 1].$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right,urc.Top,r.Right + szt,urc.Top + szt));
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cx,urc.Top + ((urc.Bottom - urc.Top - (rc.Bottom - rc.Top)) / 2),cw - sz,urc.Top + ((urc.Bottom - urc.Top - (rc.Bottom - rc.Top)) / 2) + (rc.Bottom - rc.Top)));
          txtr = rtl.arraySetLength(txtr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(txtr) + 1);
          txtr[rtl.length(txtr) - 1].$assign(r);
        };
        extr = rtl.arraySetLength(extr,pas["WEBLib.TMSFNCTypes"].TRectF,rtl.length(extr) + 1);
        extr[rtl.length(extr) - 1].$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right,r.Top,r.Right + sz,r.Bottom));
      };
      this.UpdateNodeExtraRects(v,rtl.arrayRef(extr));
      this.UpdateNodeTitleExtraRects(v,rtl.arrayRef(textr));
      this.UpdateNodeTextRects(v,rtl.arrayRef(txtr));
      this.UpdateNodeTitleRects(v,rtl.arrayRef(titr));
      this.UpdateNodeBitmapRects(v,rtl.arrayRef(bmpr));
      this.UpdateNodeExpandRects(v,rtl.arrayRef(expr));
      this.UpdateNodeCheckRects(v,rtl.arrayRef(chkr));
      cache = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItem.CreateNode(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rc),v);
      this.FNodeCache.Add$1(cache);
      this.UpdateNodeCacheReference(v,cache);
      Result = (y - vs) > (cr.Bottom - cr.Top);
      return Result;
    };
    this.XYToColumnAnchorCache = function (AX, AY, ACache, AIndex) {
      var Result = "";
      var I = 0;
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var a = "";
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var str = "";
      var g = null;
      var c = null;
      var col = null;
      var def = false;
      var trim = 0;
      var ha = 0;
      var va = 0;
      var ww = false;
      var szt = 0.0;
      var szd = 0.0;
      var szr = 0.0;
      Result = "";
      AIndex.set(-1);
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
      try {
        try {
          if (!g.BeginScene()) return Result;
        } catch ($e) {
          return Result;
        };
        g.FBitmapContainer = this.GetBitmapContainer();
        for (var $l = 0, $end = ACache.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          c = ACache.GetItem$1(I);
          col = null;
          def = false;
          if ((c.FColumn >= 0) && (c.FColumn <= (this.FColumns.GetCount() - 1))) col = this.FColumns.GetItem$1(c.FColumn);
          r.$assign(c.FDrawRect);
          szt = 0;
          if (col != null) {
            if (col.FFiltering.FEnabled) {
              szd = col.FFiltering.FButtonSize;
              szt = szt + szd + this.ScalePaintValue(4);
            };
            if (col.FExpandable) {
              szr = col.FExpandingButtonSize;
              szt = szt + szr + this.ScalePaintValue(6);
            };
            if ((col.FSortKind !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskNone) && (this.FSortColumn === c.FColumn)) {
              szr = this.ScalePaintValue(8);
              szt = szt + szr + this.ScalePaintValue(6);
            };
          };
          if (def) {
            var $tmp = c.FKind;
            if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
              g.FFont.Assign(this.FColumnsAppearance.FTopFont)}
             else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) g.FFont.Assign(this.FColumnsAppearance.FBottomFont);
          } else if (col != null) {
            var $tmp1 = c.FKind;
            if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
              g.FFont.Assign(col.FTopFont)}
             else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) g.FFont.Assign(col.FBottomFont);
          };
          str = this.GetColumnText(c.FColumn);
          this.DoGetColumnText(c.FColumn,c.FKind,{get: function () {
              return str;
            }, set: function (v) {
              str = v;
            }});
          ha = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
          va = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
          ww = false;
          trim = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
          if (col != null) {
            ha = col.FHorizontalTextAlign;
            va = col.FVerticalTextAlign;
            ww = col.FWordWrapping;
            trim = col.FTrimming;
          };
          this.DoGetColumnTrimming(c.FColumn,c.FKind,{get: function () {
              return trim;
            }, set: function (v) {
              trim = v;
            }});
          this.DoGetColumnWordWrapping(c.FColumn,c.FKind,{get: function () {
              return ww;
            }, set: function (v) {
              ww = v;
            }});
          this.DoGetColumnHorizontalTextAlign(c.FColumn,c.FKind,{get: function () {
              return ha;
            }, set: function (v) {
              ha = v;
            }});
          this.DoGetColumnVerticalTextAlign(c.FColumn,c.FKind,{get: function () {
              return va;
            }, set: function (v) {
              va = v;
            }});
          txtr.$assign(r);
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(txtr,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
          txtr.Right = Math.max(txtr.Left,txtr.Right - szt);
          if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(txtr,pas["WEBLib.TMSFNCTypes"].PointF(AX,AY))) {
            var $tmp2 = c.FKind;
            if ($tmp2 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
              if (col != null) {
                g.FFont.Assign(col.FTopFont)}
               else g.FFont.Assign(this.FColumnsAppearance.FTopFont);
              if (this.FColumnsAppearance.FTopVerticalText) {
                a = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,-90,-1,-1,true,true,AX,AY)}
               else a = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,0,-1,-1,true,true,AX,AY);
            } else if ($tmp2 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) {
              if (col != null) {
                g.FFont.Assign(col.FBottomFont)}
               else g.FFont.Assign(this.FColumnsAppearance.FBottomFont);
              if (this.FColumnsAppearance.FBottomVerticalText) {
                a = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,90,-1,-1,true,true,AX,AY)}
               else a = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,0,-1,-1,true,true,AX,AY);
            };
            if (a !== "") {
              Result = a;
              AIndex.set(c.FColumn);
              break;
            };
          };
        };
        g.EndScene();
      } finally {
        g = rtl.freeLoc(g);
      };
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = $mod.TTMSFNCTreeViewDocURL;
      return Result;
    };
    this.GetRowHeight = function (ARow) {
      var Result = 0.0;
      var v = null;
      v = this.GetVisibleNodeForIndex(ARow);
      Result = this.GetDefaultRowHeight(v);
      if ((v != null) && v.FCalculated) Result = v.FHeight;
      return Result;
    };
    this.GetColumnText = function (AColumn) {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTreeViewData"].TranslateTextEx(rtl.getResStr(pas["WEBLib.TMSFNCTreeViewData"],"sTMSFNCTreeViewColumn")) + " " + pas.SysUtils.IntToStr(AColumn);
      if ((AColumn >= 0) && (AColumn <= (this.FColumnCount - 1))) {
        Result = this.FColumns.GetItem$1(AColumn).FText;
        if (Result === "") Result = this.FColumns.GetItem$1(AColumn).FName;
        if (Result === "") Result = pas["WEBLib.TMSFNCTreeViewData"].TranslateTextEx(rtl.getResStr(pas["WEBLib.TMSFNCTreeViewData"],"sTMSFNCTreeViewColumn")) + " " + pas.SysUtils.IntToStr(AColumn);
      };
      if (this.FAdapter != null) Result = this.FAdapter.GetColumnDisplayName(AColumn);
      return Result;
    };
    this.GetGroupText = function (AGroup) {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTreeViewData"].TranslateTextEx(rtl.getResStr(pas["WEBLib.TMSFNCTreeViewData"],"sTMSFNCTreeViewGroup")) + " " + pas.SysUtils.IntToStr(AGroup);
      if ((AGroup >= 0) && (AGroup <= (this.FGroups.GetCount() - 1))) Result = this.FGroups.GetItem$1(AGroup).GetText();
      return Result;
    };
    this.GetColumnsTopSize = function () {
      var Result = 0.0;
      Result = 0;
      if (($mod.TTMSFNCTreeViewColumnsLayout.tclTop in this.FColumnsAppearance.FLayouts) && (this.FColumnCount > 0)) Result = this.FColumnsAppearance.FTopSize;
      return Result;
    };
    this.GetColumnsExtraSize = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetColumnsBottomSize = function () {
      var Result = 0.0;
      Result = 0;
      if (($mod.TTMSFNCTreeViewColumnsLayout.tclBottom in this.FColumnsAppearance.FLayouts) && (this.FColumnCount > 0)) Result = this.FColumnsAppearance.FBottomSize;
      return Result;
    };
    this.GetGroupsTopSize = function () {
      var Result = 0.0;
      Result = 0;
      if (($mod.TTMSFNCTreeViewGroupLayout.tglTop in this.FGroupsAppearance.FLayouts) && (this.FDisplayGroups.GetCount() > 0) && (this.FColumnCount > 0)) Result = this.FGroupsAppearance.FTopSize;
      return Result;
    };
    this.GetGroupsBottomSize = function () {
      var Result = 0.0;
      Result = 0;
      if (($mod.TTMSFNCTreeViewGroupLayout.tglBottom in this.FGroupsAppearance.FLayouts) && (this.FDisplayGroups.GetCount() > 0) && (this.FColumnCount > 0)) Result = this.FGroupsAppearance.FBottomSize;
      return Result;
    };
    this.GetContentClipRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.GetContentClipRect.call(this));
      Result.Bottom = Result.Top + Math.min(this.GetTotalRowHeight(),Result.Bottom - Result.Top);
      Result.Right = Result.Left + Math.min(this.GetTotalColumnWidth(),Result.Right - Result.Left);
      Result.Left = Result.Left + 1;
      Result.Right = Result.Right - 1;
      return Result;
    };
    this.GetContentRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.GetContentRect.call(this));
      Result.Top = Result.Top + this.GetColumnsTopSize() + this.GetGroupsTopSize();
      Result.Bottom = Result.Bottom - this.GetColumnsBottomSize() - this.GetGroupsBottomSize();
      return Result;
    };
    this.GetCalculationRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.GetCalculationRect.call(this));
      Result.Top = Result.Top + this.GetColumnsTopSize() + this.GetGroupsTopSize();
      Result.Bottom = Result.Bottom - this.GetColumnsBottomSize() - this.GetGroupsBottomSize();
      Result.Right = Result.Left + Math.max(0,Result.Right - Result.Left);
      Result.Bottom = Result.Top + Math.max(0,Result.Bottom - Result.Top);
      return Result;
    };
    this.GetGroupsTopRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetColumnsTopRect());
      Result.Bottom = Result.Top;
      Result.Top = Result.Top - this.GetGroupsTopSize();
      return Result;
    };
    this.GetGroupsBottomRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetColumnsBottomRect());
      Result.Top = Result.Bottom;
      Result.Bottom = Result.Top + this.GetGroupsBottomSize();
      return Result;
    };
    this.GetColumnsTopRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      nr.$assign(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.GetContentRect.call(this));
      Result.Left = nr.Left;
      Result.Top = nr.Top + this.GetGroupsTopSize();
      Result.Right = nr.Right + this.GetColumnsExtraSize();
      Result.Bottom = nr.Top + this.GetGroupsTopSize() + this.GetColumnsTopSize();
      return Result;
    };
    this.GetColumnTopLeftEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetColumnsTopRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = nr.Left;
      Result.Right = ptr.Left;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetColumnBottomLeftEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetColumnsBottomRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = nr.Left;
      Result.Right = ptr.Left;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetColumnBottomRightEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetColumnsBottomRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = ptr.Right;
      Result.Right = nr.Right - 1;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetColumnTopRightEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetColumnsTopRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = ptr.Right;
      Result.Right = nr.Right - 1;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetGroupTopLeftEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetGroupsTopRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = nr.Left;
      Result.Right = ptr.Left;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetGroupBottomLeftEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetGroupsBottomRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = nr.Left;
      Result.Right = ptr.Left;
      Result.Bottom = nr.Bottom;
      return Result;
    };
    this.GetGroupBottomRightEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetGroupsBottomRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = ptr.Right;
      Result.Right = nr.Right;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetGroupTopRightEmptyRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ptr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      ptr.$assign(this.GetGroupsTopRect());
      nr.$assign(this.GetLocalRect());
      Result.Top = ptr.Top;
      Result.Left = ptr.Right;
      Result.Right = nr.Right;
      Result.Bottom = ptr.Bottom;
      return Result;
    };
    this.GetColumnsBottomRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      nr.$assign(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.GetContentRect.call(this));
      Result.Left = nr.Left;
      Result.Top = nr.Bottom - this.GetGroupsBottomSize() - this.GetColumnsBottomSize();
      Result.Right = nr.Right + this.GetColumnsExtraSize();
      Result.Bottom = nr.Bottom - this.GetGroupsBottomSize();
      return Result;
    };
    this.GetCacheWidth = function () {
      var Result = 0;
      Result = 1000;
      return Result;
    };
    this.GetCacheHeight = function () {
      var Result = 0;
      Result = 1000;
      return Result;
    };
    this.XYToCacheItem = function (X, Y, OffsetX) {
      var Result = null;
      var I = 0;
      var dsp = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result = null;
      if (!(this.FNodeDisplay != null)) return Result;
      if (!pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetContentClipRect(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) return Result;
      for (var $l = 0, $end = this.FNodeDisplay.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        dsp = this.FNodeDisplay.GetItem(I);
        r.$assign(dsp.FDrawRect);
        r.Left = r.Left + OffsetX;
        r.Right = r.Right + OffsetX;
        if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(r,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
          Result = dsp;
          break;
        };
      };
      return Result;
    };
    this.GetFirstVisibleCacheItem = function () {
      var Result = null;
      Result = null;
      if (this.FNodeDisplay.GetCount() > 0) Result = this.FNodeDisplay.GetItem(0);
      return Result;
    };
    this.IsReorderActive = function () {
      var Result = false;
      Result = this.FReorderMode && this.FInteraction.FReorder;
      return Result;
    };
    this.IsDragDropActive = function () {
      var Result = false;
      Result = this.FDragMode$1 && (this.FInteraction.FDragDropMode !== $mod.TTMSFNCTreeViewDragDropMode.tdmNone);
      return Result;
    };
    this.GetHTMLTemplate = function (AColumnIndex) {
      var Result = "";
      if ((AColumnIndex >= 0) && (AColumnIndex < this.FColumns.GetCount())) {
        Result = this.FColumns.GetItem$1(AColumnIndex).FHTMLTemplate}
       else Result = "";
      return Result;
    };
    this.Create$1 = function (AOwner) {
      var s = 0.0;
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.Create$1.apply(this,arguments);
      this.FColumnStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,-1,1.0]);
      this.FColumnStroke.FOnChanged = rtl.createCallback(this,"ColumnStrokeChanged");
      this.FSizeColumn = -1;
      this.FGroupsCaching = false;
      this.FColumnsCaching = false;
      this.FSelectedNodes = $mod.TTMSFNCTreeViewSelectedNodes.$create("Create$1");
      this.FNodeCache = $mod.TTMSFNCTreeViewNodeCache.$create("Create$2");
      this.FColumnsTopCache = $mod.TTMSFNCTreeViewColumnsTopCache.$create("Create$2");
      this.FGroupsTopCache = $mod.TTMSFNCTreeViewGroupsTopCache.$create("Create$2");
      this.FColumnsBottomCache = $mod.TTMSFNCTreeViewColumnsBottomCache.$create("Create$2");
      this.FGroupsBottomCache = $mod.TTMSFNCTreeViewGroupsBottomCache.$create("Create$2");
      this.FNodeDisplay = $mod.TTMSFNCTreeViewNodeDisplayList.$create("Create$1");
      this.FColumnsTopDisplay = $mod.TTMSFNCTreeViewColumnsTopDisplayList.$create("Create$1");
      this.FGroupsTopDisplay = $mod.TTMSFNCTreeViewGroupsTopDisplayList.$create("Create$1");
      this.FColumnsBottomDisplay = $mod.TTMSFNCTreeViewColumnsBottomDisplayList.$create("Create$1");
      this.FGroupsBottomDisplay = $mod.TTMSFNCTreeViewGroupsBottomDisplayList.$create("Create$1");
      this.FNodesAppearance = $mod.TTMSFNCTreeViewNodesAppearance.$create("Create$1",[this]);
      this.FColumnsAppearance = $mod.TTMSFNCTreeViewColumnsAppearance.$create("Create$1",[this]);
      this.FGroupsAppearance = $mod.TTMSFNCTreeViewGroupsAppearance.$create("Create$1",[this]);
      this.FInteraction = $mod.TTMSFNCTreeViewInteraction.$create("Create$1",[this]);
      this.FDragTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FDragTimer.SetInterval(10);
      this.FDragTimer.SetEnabled(false);
      this.FDragTimer.FOnTimer = rtl.createCallback(this,"DragTime");
      this.FAnimateTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FAnimateTimer.SetInterval(1);
      this.FAnimateTimer.SetEnabled(false);
      this.FAnimateTimer.FOnTimer = rtl.createCallback(this,"Animate");
      this.FCopyNodes = $mod.TTMSFNCTreeViewCopyNodes.$create("Create$3",[null,null]);
      this.FFilterListBox = pas["WEBLib.StdCtrls"].TListBox.$create("Create$1",[this]);
      this.FFilterListBox.FTag$1 = -1;
      this.FFilterListBox.FOnClick = rtl.createCallback(this,"HandleFilterListClick");
      this.FGlobalFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCAppearanceGlobalFont.$create("Create$1",[this]);
      this.FFilterTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FFilterTimer.FOnTimer = rtl.createCallback(this,"HandleFilterTimer");
      this.FFilterTimer.SetInterval(100);
      this.FFilterTimer.SetEnabled(false);
      this.FFilterPopup = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FFilterPopup.SetPlacement(pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppAbsolute);
      this.FPrecalculateItems = false;
      this.SetWidth(300);
      this.SetHeight(280);
      this.FDefaultViewJSONOptions = $mod.TTMSFNCTreeViewViewJSONOptions.$create("Create$1");
      s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(this,96);
      if (s === 1) {
        this.FCheckStartSize = 19}
       else if ((s === 1.25) || (s === 1.75)) {
        this.FCheckStartSize = 16}
       else this.FCheckStartSize = 17;
      if (this.IsDesignTime()) this.InitSample();
      return this;
    };
    this.Destroy = function () {
      if (this.FOldInplaceEditor != null) rtl.free(this,"FOldInplaceEditor");
      rtl.free(this,"FDefaultViewJSONOptions");
      rtl.free(this,"FGlobalFont");
      rtl.free(this,"FCopyNodes");
      rtl.free(this,"FFilterTimer");
      rtl.free(this,"FFilterListBox");
      rtl.free(this,"FFilterPopup");
      if (this.FDragBitmap != null) {
        rtl.free(this,"FDragBitmap");
        this.FDragBitmap = null;
      };
      rtl.free(this,"FColumnStroke");
      rtl.free(this,"FAnimateTimer");
      rtl.free(this,"FNodesAppearance");
      rtl.free(this,"FGroupsAppearance");
      rtl.free(this,"FInteraction");
      rtl.free(this,"FColumnsAppearance");
      rtl.free(this,"FGroupsTopDisplay");
      rtl.free(this,"FColumnsTopDisplay");
      rtl.free(this,"FGroupsBottomDisplay");
      rtl.free(this,"FColumnsBottomDisplay");
      rtl.free(this,"FSelectedNodes");
      rtl.free(this,"FNodeDisplay");
      rtl.free(this,"FNodeCache");
      rtl.free(this,"FGroupsTopCache");
      rtl.free(this,"FColumnsTopCache");
      rtl.free(this,"FGroupsBottomCache");
      rtl.free(this,"FColumnsBottomCache");
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.Destroy.call(this);
    };
    this.Assign = function (Source) {
      this.BeginUpdate();
      pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewData.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomTreeView.isPrototypeOf(Source)) {
        this.FNodesAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomTreeView).FNodesAppearance);
        this.FColumnsAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomTreeView).FColumnsAppearance);
        this.FGroupsAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomTreeView).FGroupsAppearance);
        this.FInteraction.Assign(rtl.as(Source,$mod.TTMSFNCCustomTreeView).FInteraction);
      };
      this.EndUpdate();
    };
    this.Draw = function (AGraphics, ARect) {
      var st = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      if (this.FUpdateCount$1 > 0) return;
      AGraphics.FBitmapContainer = this.GetBitmapContainer();
      this.DrawEmptySpaces(AGraphics);
      st = AGraphics.SaveState(false);
      AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetContentClipRect()));
      this.DrawNodeColumns(AGraphics);
      AGraphics.RestoreState(st,false);
      this.DrawNodes(AGraphics);
      this.DrawColumns(AGraphics);
      this.DrawGroups(AGraphics);
      this.DrawBorders(AGraphics);
    };
    this.InitSample = function () {
      var pManagers = null;
      var pSpecialists = null;
      var pAssistants = null;
      var pSub = null;
      var c = null;
      var I = 0;
      var n = "";
      this.BeginUpdate();
      this.SetWidth(this.ScalePaintValue(350));
      this.ClearNodeList();
      this.FColumns.Clear();
      this.FNodes.Clear();
      this.ResetToDefaultStyle();
      this.FNodesAppearance.SetExpandWidth(this.ScalePaintValue(18));
      this.FNodesAppearance.SetExpandHeight(this.ScalePaintValue(18));
      this.FColumnsAppearance.SetTopSize(this.ScalePaintValue(36));
      this.FColumnsAppearance.FTopStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.FNodesAppearance.FSelectedStroke.SetWidth(pas.System.Trunc(this.ScalePaintValue$1(2.0)));
      c = this.FColumns.Add$1();
      c.SetText("Name");
      c.SetHorizontalTextAlign(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading);
      c = this.FColumns.Add$1();
      c.SetText("Unit");
      c.SetHorizontalTextAlign(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing);
      c.SetWidth(this.ScalePaintValue(90));
      c = this.FColumns.Add$1();
      c.SetText("Status");
      c.SetHorizontalTextAlign(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter);
      c.SetWidth(this.ScalePaintValue(80));
      pManagers = this.AddNode(null);
      pManagers.SetText(0,"Managers");
      pSpecialists = this.AddNode(null);
      pSpecialists.SetText(0,"Specialists");
      pAssistants = this.AddNode(null);
      pAssistants.SetText(0,"Assistants");
      for (I = 0; I <= 7; I++) {
        if (I < 3) {
          pSub = this.AddNode(pManagers)}
         else if (I < 5) {
          pSub = this.AddNode(pSpecialists)}
         else pSub = this.AddNode(pAssistants);
        var $tmp = pas.System.Random(125) % 7;
        if ($tmp === 0) {
          n = "Liam"}
         else if ($tmp === 1) {
          n = "Fatma"}
         else if ($tmp === 2) {
          n = "Yusuf"}
         else if ($tmp === 3) {
          n = "Marie"}
         else if ($tmp === 4) {
          n = "Isabella"}
         else if ($tmp === 5) {
          n = "Omar"}
         else {
          n = "Arthur";
        };
        var $tmp1 = pas.System.Random(125) % 7;
        if ($tmp1 === 0) {
          n = n + " Andersson"}
         else if ($tmp1 === 1) {
          n = n + " Wang"}
         else if ($tmp1 === 2) {
          n = n + " Smith"}
         else if ($tmp1 === 3) {
          n = n + " Peeters"}
         else if ($tmp1 === 4) {
          n = n + " Gonzales"}
         else if ($tmp1 === 5) {
          n = n + " Moyo"}
         else {
          n = n + " Ali";
        };
        pSub.SetText(0,n);
        var $tmp2 = pas.System.Random(120) % 7;
        if ($tmp2 === 1) {
          pSub.SetText(1,"Research")}
         else if ($tmp2 === 2) {
          pSub.SetText(1,"Finance")}
         else if ($tmp2 === 3) {
          pSub.SetText(1,"Manufactering")}
         else if ($tmp2 === 4) {
          pSub.SetText(1,"Sales")}
         else if ($tmp2 === 5) {
          pSub.SetText(1,"HR")}
         else if ($tmp2 === 6) {
          pSub.SetText(1,"Marketing")}
         else {
          pSub.SetText(1,"Customers");
        };
        var $tmp3 = pas.System.Random(120) % 5;
        if ($tmp3 === 0) {
          pSub.SetText(2,"Flight")}
         else if ($tmp3 === 1) {
          pSub.SetText(2,"On Leave")}
         else if ($tmp3 === 2) {
          pSub.SetText(2,"Abroad")}
         else {
          pSub.SetText(2,"Office");
        };
      };
      pManagers.SetExpanded(true);
      pSpecialists.SetExpanded(true);
      this.FGlobalFont.SetName("Segoe UI");
      this.FColumnsAppearance.SetStretchAll(false);
      this.FColumnsAppearance.SetStretch(true);
      this.FColumnsAppearance.SetStretchColumn(0);
      this.EndUpdate();
    };
    this.CutToClipboard = function (ATextOnly) {
      var I = 0;
      var n = null;
      var nv = null;
      if (this.FOnCustomCutToClipboard != null) {
        this.FOnCustomCutToClipboard(this)}
       else {
        this.BeginUpdate();
        this.CopyToClipboard(ATextOnly);
        for (var $l = this.SelectedNodeCount() - 1; $l >= 0; $l--) {
          I = $l;
          n = this.GetSelNode(I);
          if (n != null) {
            this.RemoveNode(n)}
           else {
            nv = this.GetSelVirtualNode(I);
            this.RemoveVirtualNode(nv);
          };
        };
        this.EndUpdate();
      };
    };
    this.CopyToClipboard = function (ATextOnly) {
      var s = "";
      var I = 0;
      var K = 0;
      var n = null;
      var v = null;
      var cl = null;
      if (this.FOnCustomCopyToClipboard != null) {
        this.FOnCustomCopyToClipboard(this)}
       else {
        cl = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewIntegerList.$create("Create$1");
        try {
          s = "";
          for (var $l = 0, $end = this.SelectedVirtualNodeCount() - 1; $l <= $end; $l++) {
            I = $l;
            n = this.GetSelVirtualNode(I);
            if ((n != null) && (cl.IndexOf(n.FRow) === -1)) {
              if (n.FNode != null) s = s + n.FNode.SaveToString(ATextOnly) + $mod.ENDOFLINE;
              cl.Add(n.FRow);
            };
            if (n != null) {
              for (var $l1 = n.FRow + 1, $end1 = n.FRow + n.FTotalChildren; $l1 <= $end1; $l1++) {
                K = $l1;
                v = this.GetNodeFromNodeStructure(K);
                if ((v != null) && (v.FNode != null) && (cl.IndexOf(v.FRow) === -1)) {
                  s = s + v.FNode.SaveToString(ATextOnly) + $mod.ENDOFLINE;
                  cl.Add(v.FRow);
                };
              };
            };
          };
          if (s !== "") pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.SetText($mod.CLP_FMT + s);
        } finally {
          cl = rtl.freeLoc(cl);
        };
      };
    };
    this.PasteFromClipboard = function () {
      var s = "";
      var a = null;
      var ANode = null;
      var ANextNode = null;
      var ALevel = 0;
      var I = 0;
      var off = 0;
      var CurrStr = "";
      if (this.FOnCustomPasteFromClipboard != null) {
        this.FOnCustomPasteFromClipboard(this)}
       else {
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.HasFormat(pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoardFormat.cfText)) {
          s = pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.GetText();
          if (pas.System.Pos($mod.CLP_FMT,s) > 0) {
            a = pas.Classes.TStringList.$create("Create$1");
            try {
              s = pas.SysUtils.StringReplace(s,$mod.CLP_FMT,"",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
              a.SetTextStr(s);
              try {
                ANode = null;
                off = 0;
                for (var $l = 0, $end = a.GetCount() - 1; $l <= $end; $l++) {
                  I = $l;
                  ALevel = -1;
                  CurrStr = this.GetBufStart(a.Get(I),{get: function () {
                      return ALevel;
                    }, set: function (v) {
                      ALevel = v;
                    }});
                  if (ANode === null) {
                    ANode = this.AddNode(this.GetFocusedNode());
                    off = ALevel;
                    if (this.GetFocusedNode() != null) off = off - this.GetFocusedNode().FVirtualNode.FLevel;
                  } else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel === (ALevel - off))) {
                    ANode = this.AddNode(ANode.GetParent())}
                   else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel === (ALevel - 1 - off))) {
                    ANode = this.AddNode(ANode)}
                   else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel > (ALevel - off))) {
                    ANextNode = ANode.GetParent();
                    while ((ANextNode != null) && (ANextNode.FVirtualNode != null) && (ANextNode.FVirtualNode.FLevel > (ALevel - off))) ANextNode = ANextNode.GetParent();
                    ANode = this.AddNode(ANextNode.GetParent());
                  };
                  if (ANode != null) ANode.LoadFromString(CurrStr);
                };
              } finally {
              };
            } finally {
              a = rtl.freeLoc(a);
            };
          };
        };
      };
    };
    this.Sort = function (AColumn, ARecurse, ACaseSensitive, ASortingMode, AClearNodeList) {
      this.FNodes.Sort$1(AColumn,ARecurse,ACaseSensitive,ASortingMode,AClearNodeList);
    };
    this.ClearSorting = function () {
      var I = 0;
      this.BeginUpdate();
      this.FSortColumn = -1;
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FColumns.GetItem$1(I).SetSortKind(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskNone);
        this.FColumns.GetItem$1(I).SetSortIndex(-1);
      };
      this.EndUpdate();
    };
    this.LoadFromStream = function (AStream, AEncoding) {
      var List = null;
      var ANode = null;
      var NextNode = null;
      var ALevel = 0;
      var i = 0;
      var CurrStr = "";
      List = pas.Classes.TStringList.$create("Create$1");
      this.BeginUpdate();
      this.ClearNodeList();
      try {
        try {
          this.ClearNodes();
          pas.Classes.TStringsHelper.LoadFromStream$1.call(List,AStream,AEncoding);
          ANode = null;
          for (var $l = 0, $end = List.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            ALevel = -1;
            CurrStr = this.GetBufStart(List.Get(i),{get: function () {
                return ALevel;
              }, set: function (v) {
                ALevel = v;
              }});
            if (ANode === null) {
              ANode = this.AddNode(null)}
             else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel === ALevel)) {
              ANode = this.AddNode(ANode.GetParent())}
             else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel === (ALevel - 1))) {
              ANode = this.AddNode(ANode)}
             else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel > ALevel)) {
              NextNode = ANode.GetParent();
              while ((NextNode != null) && (NextNode.FVirtualNode != null) && (NextNode.FVirtualNode.FLevel > ALevel)) NextNode = NextNode.GetParent();
              ANode = this.AddNode(NextNode.GetParent());
            };
            if (ANode != null) ANode.LoadFromString(CurrStr);
            this.BuildNodeList();
          };
        } finally {
          this.EndUpdate();
          List = rtl.freeLoc(List);
        };
      } catch ($e) {
      };
    };
    this.ViewJSON = function (AFileName, AViewOptions) {
      var $Self = this;
      var ms = null;
      function InternalInputFromJSON() {
        ms.SetPosition(0);
        $Self.ViewJSONFromStream(ms,AViewOptions);
      };
      ms = pas.Classes.TMemoryStream.$create("Create");
      try {
        ms.LoadFromFile(AFileName,function () {
          InternalInputFromJSON();
          ms = rtl.freeLoc(ms);
        },null);
      } finally {
      };
    };
    this.ViewJSONFromStream = function (AStream, AViewOptions) {
      var SL = null;
      SL = pas.Classes.TStringList.$create("Create$1");
      try {
        AStream.SetPosition(0);
        pas.Classes.TStringsHelper.LoadFromStream.call(SL,AStream);
        this.ViewJSONFromText(SL.GetTextStr(),AViewOptions);
      } finally {
        SL = rtl.freeLoc(SL);
      };
    };
    this.ViewJSONFromText = function (AText, AViewOptions) {
      var $Self = this;
      var j = null;
      var col = null;
      var NameIndex = 0;
      var ValueIndex = 0;
      function SetJSONNodeText(ANode, AName, ATextType, AJSONValue, AValue) {
        if (ANode.FValues.GetCount() === 0) ANode.FValues.Add$1();
        var $tmp = ATextType;
        if ($tmp === $impl.TTMSFNCTreeViewJSONType.jtValue) {
          ANode.SetText(NameIndex,AName);
          ANode.FValues.GetItem$1(NameIndex).FHTMLTemplateItems.Add("NAME=" + AName);
          ANode.SetText(ValueIndex,AValue);
          ANode.FValues.GetItem$1(ValueIndex).FHTMLTemplateItems.Add("VALUE=" + AValue);
          ANode.FTag = 1;
        } else if ($tmp === $impl.TTMSFNCTreeViewJSONType.jtArraySize) {
          ANode.SetText(NameIndex,AName + " [" + AValue + "]");
          ANode.FValues.GetItem$1(NameIndex).FHTMLTemplateItems.Add("NAME=" + AName + " [" + AValue + "]");
          ANode.FTag = 2;
        } else if ($tmp === $impl.TTMSFNCTreeViewJSONType.jtObjectSize) {
          ANode.SetText(NameIndex,AName + " {" + AValue + "}");
          ANode.FValues.GetItem$1(NameIndex).FHTMLTemplateItems.Add("NAME=" + AName + " {" + AValue + "}");
          ANode.FTag = 3;
        } else if ($tmp === $impl.TTMSFNCTreeViewJSONType.jtArrayIndex) {
          ANode.SetText(NameIndex,AViewOptions.FArrayItemPrefix + AName + AViewOptions.FArrayItemSuffix);
          ANode.FValues.GetItem$1(NameIndex).FHTMLTemplateItems.Add("NAME=" + AViewOptions.FArrayItemPrefix + AName + AViewOptions.FArrayItemSuffix);
          ANode.FTag = 4;
        };
        $Self.DoAfterAddJSONNode(ANode,AJSONValue);
      };
      function ParseNode(nj, ANode) {
        var I = 0;
        var K = 0;
        var c = 0;
        var jv = null;
        var njav = null;
        var jav = null;
        var n = null;
        var sn = null;
        var nja = null;
        var ja = null;
        var name = "";
        var add = false;
        if (pas["WEBLib.JSON"].TJSONArray.isPrototypeOf(nj)) {
          add = true;
          $Self.DoBeforeAddJSONNode(nj,{get: function () {
              return add;
            }, set: function (v) {
              add = v;
            }});
          if (add) {
            if (ANode != null) {
              n = ANode.FNodes.Add$1()}
             else n = $Self.FNodes.Add$1();
            nja = rtl.as(nj,pas["WEBLib.JSON"].TJSONArray);
            c = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArraySize(nja);
            SetJSONNodeText(n,name,$impl.TTMSFNCTreeViewJSONType.jtArraySize,nj,pas.SysUtils.IntToStr(c));
            for (var $l = 0, $end = c - 1; $l <= $end; $l++) {
              K = $l;
              njav = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArrayItem(nja,K);
              if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(njav)) {
                sn = n.FNodes.Add$1();
                SetJSONNodeText(sn,pas.SysUtils.IntToStr(K),$impl.TTMSFNCTreeViewJSONType.jtArrayIndex,nj,"");
                sn.SetText(0,pas.SysUtils.IntToStr(K));
                ParseNode(njav,sn);
              } else {
                SetJSONNodeText(n.FNodes.Add$1(),pas.SysUtils.IntToStr(K),$impl.TTMSFNCTreeViewJSONType.jtValue,njav,njav.GetStrValue());
              };
            };
          };
        } else if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(nj)) {
          for (var $l1 = 0, $end1 = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONObjectSize(rtl.as(nj,pas["WEBLib.JSON"].TJSONObject)) - 1; $l1 <= $end1; $l1++) {
            I = $l1;
            name = "";
            name = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONObjectName(rtl.as(nj,pas["WEBLib.JSON"].TJSONObject),I);
            jv = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONObjectItem(rtl.as(nj,pas["WEBLib.JSON"].TJSONObject),I);
            add = true;
            $Self.DoBeforeAddJSONNode(jv,{get: function () {
                return add;
              }, set: function (v) {
                add = v;
              }});
            if (add) {
              if (ANode != null) {
                n = ANode.FNodes.Add$1()}
               else n = $Self.FNodes.Add$1();
              if (jv != null) {
                if (pas["WEBLib.JSON"].TJSONArray.isPrototypeOf(jv)) {
                  ja = rtl.as(jv,pas["WEBLib.JSON"].TJSONArray);
                  c = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArraySize(ja);
                  SetJSONNodeText(n,name,$impl.TTMSFNCTreeViewJSONType.jtArraySize,jv,pas.SysUtils.IntToStr(c));
                  for (var $l2 = 0, $end2 = c - 1; $l2 <= $end2; $l2++) {
                    K = $l2;
                    jav = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONArrayItem(ja,K);
                    if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(jav)) {
                      sn = n.FNodes.Add$1();
                      SetJSONNodeText(sn,pas.SysUtils.IntToStr(K),$impl.TTMSFNCTreeViewJSONType.jtArrayIndex,jv,"");
                      ParseNode(jav,sn);
                    } else {
                      SetJSONNodeText(n.FNodes.Add$1(),pas.SysUtils.IntToStr(K),$impl.TTMSFNCTreeViewJSONType.jtValue,jav,jav.GetStrValue());
                    };
                  };
                } else if (pas["WEBLib.JSON"].TJSONObject.isPrototypeOf(jv)) {
                  SetJSONNodeText(n,name,$impl.TTMSFNCTreeViewJSONType.jtObjectSize,jv,pas.SysUtils.IntToStr(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetJSONObjectSize(rtl.as(jv,pas["WEBLib.JSON"].TJSONObject))));
                  ParseNode(jv,n);
                } else SetJSONNodeText(n,name,$impl.TTMSFNCTreeViewJSONType.jtValue,jv,jv.GetStrValue());
              };
            };
          };
        } else {
          if (ANode != null) {
            SetJSONNodeText(ANode,name,$impl.TTMSFNCTreeViewJSONType.jtValue,nj,nj.GetStrValue())}
           else SetJSONNodeText($Self.FNodes.Add$1(),name,$impl.TTMSFNCTreeViewJSONType.jtValue,nj,nj.GetStrValue());
        };
      };
      NameIndex = 0;
      ValueIndex = 1;
      this.BeginUpdate();
      if (AViewOptions === null) AViewOptions = this.FDefaultViewJSONOptions;
      this.FNodes.Clear();
      this.FColumns.Clear();
      col = this.FColumns.Add$1();
      col.SetText("Object");
      col.SetTrimming(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter);
      col.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      col = this.FColumns.Add$1();
      col.SetText("Value");
      this.FColumns.GetItem$1(NameIndex).SetHTMLTemplate(AViewOptions.FNameHTMLTemplate);
      this.FColumns.GetItem$1(ValueIndex).SetHTMLTemplate(AViewOptions.FValueHTMLTemplate);
      j = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.ParseJSON(AText);
      if (j != null) try {
        ParseNode(j,null);
      } finally {
        j = rtl.freeLoc(j);
      };
      this.EndUpdate();
      if (AViewOptions.FExpandNodes) this.ExpandAll();
      if (AViewOptions.FStretchColumn > -1) {
        this.BeginUpdate();
        this.FColumnsAppearance.SetStretchAll(false);
        this.FColumnsAppearance.SetStretchColumn(AViewOptions.FStretchColumn);
        this.FColumnsAppearance.SetStretch(false);
        this.AutoSizeColumn(0);
        this.FColumns.GetItem$1(0).SetWidth(this.GetColWidths(0));
        this.FColumnsAppearance.SetStretch(true);
        this.EndUpdate();
      };
    };
    this.RemoveSelectedVirtualNodes = function () {
      var I = 0;
      var n = null;
      this.FBlockUpdate = true;
      for (var $l = this.SelectedVirtualNodeCount() - 1; $l >= 0; $l--) {
        I = $l;
        n = this.GetSelVirtualNode(I);
        this.FSelectedNodes.Remove(n);
        this.RemoveVirtualNode(n);
      };
      this.FBlockUpdate = false;
      this.ResetNodes(false);
      this.UpdateTreeView();
      this.Invalidate();
    };
    this.RemoveSelectedNodes = function () {
      var I = 0;
      var n = null;
      this.FBlockUpdate = true;
      for (var $l = this.SelectedNodeCount() - 1; $l >= 0; $l--) {
        I = $l;
        n = this.GetSelNode(I);
        this.FSelectedNodes.Remove(n.FVirtualNode);
        this.RemoveNode(n);
      };
      this.FBlockUpdate = false;
      this.ResetNodes(false);
      this.UpdateTreeView();
      this.Invalidate();
    };
    this.UnSelectAllNodes = function () {
      this.UnSelectAllVirtualNodes();
    };
    this.SelectAllNodes = function () {
      this.SelectAllVirtualNodes();
    };
    this.UnSelectAllVirtualNodes = function () {
      this.FSelectedNodes.Clear();
      this.Invalidate();
    };
    this.SelectAllVirtualNodes = function () {
      var I = 0;
      var n = null;
      var en = false;
      this.FSelectedNodes.Clear();
      for (var $l = 0, $end = this.FVisibleNodes.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        n = this.FVisibleNodes.GetItem(I);
        if (n != null) {
          en = this.IsVirtualNodeSelectable(n);
          if (en) this.FSelectedNodes.Add(n);
        };
      };
      this.Invalidate();
    };
    this.SelectNode = function (ANode) {
      if (ANode != null) {
        this.SelectVirtualNode(ANode.FVirtualNode)}
       else this.SelectVirtualNode(null);
    };
    this.SelectVirtualNodeByRow = function (ARow) {
      this.SelectVirtualNode(this.GetNodeForRow(ARow));
    };
    this.SelectVirtualNode = function (ANode) {
      var en = false;
      this.FSelectedNodes.Clear();
      if (ANode != null) {
        en = this.IsVirtualNodeSelectable(ANode);
        if (en) {
          this.FSelectedNodes.Add(ANode);
          this.FFocusedNode = ANode;
          this.InternalSelectVirtualNode(ANode);
        };
      };
      this.Invalidate();
    };
    this.SelectNodes = function (ANodes) {
      var I = 0;
      var v = null;
      var en = false;
      this.FSelectedNodes.Clear();
      for (var $l = 0, $end = rtl.length(ANodes) - 1; $l <= $end; $l++) {
        I = $l;
        v = ANodes[I];
        if (v != null) {
          en = this.IsVirtualNodeSelectable(v.FVirtualNode);
          if (en) this.FSelectedNodes.Add(v.FVirtualNode);
        };
      };
      this.Invalidate();
    };
    this.SelectVirtualNodes = function (ANodes) {
      var I = 0;
      var v = null;
      var en = false;
      this.FSelectedNodes.Clear();
      for (var $l = 0, $end = rtl.length(ANodes) - 1; $l <= $end; $l++) {
        I = $l;
        v = ANodes[I];
        if (v != null) {
          en = this.IsVirtualNodeSelectable(v);
          if (en) this.FSelectedNodes.Add(v);
        };
      };
      this.Invalidate();
    };
    this.UnSelectNode = function (ANode) {
      if (ANode != null) this.UnSelectVirtualNode(ANode.FVirtualNode);
    };
    this.UnSelectVirtualNode = function (ANode) {
      this.FSelectedNodes.Remove(ANode);
      this.Invalidate();
    };
    this.UnSelectNodes = function (ANodes) {
      var I = 0;
      var v = null;
      for (var $l = 0, $end = rtl.length(ANodes) - 1; $l <= $end; $l++) {
        I = $l;
        v = ANodes[I];
        if (v != null) this.FSelectedNodes.Remove(v.FVirtualNode);
      };
      this.Invalidate();
    };
    this.UnSelectVirtualNodes = function (ANodes) {
      var I = 0;
      var v = null;
      for (var $l = 0, $end = rtl.length(ANodes) - 1; $l <= $end; $l++) {
        I = $l;
        v = ANodes[I];
        this.FSelectedNodes.Remove(v);
      };
      this.Invalidate();
    };
    this.RemoveNodeFromSelection = function (ANode) {
      this.FSelectedNodes.Remove(ANode);
    };
    this.AddNodeToSelection = function (ANode) {
      this.FSelectedNodes.Add(ANode);
    };
    this.EditNode = function (ANode, AColumn) {
      if (ANode != null) this.EditVirtualNode(ANode.FVirtualNode,AColumn);
    };
    this.EditVirtualNode = function (ANode, AColumn) {
      this.HandleNodeEditing(ANode,AColumn);
      this.Invalidate();
    };
    this.StopEditing = function () {
      if (this.FInplaceEditorActive) this.CloseInplaceEditor(false,false);
    };
    this.CancelEditing = function () {
      if (this.FInplaceEditorActive) this.CloseInplaceEditor(true,false);
    };
    this.Clear = function () {
      this.BeginUpdate();
      this.ClearNodes();
      this.ClearColumns();
      this.ClearSorting();
      this.EndUpdate();
    };
    this.GetVisibleNodeCount = function () {
      var Result = 0;
      var f = null;
      var l = null;
      Result = 0;
      f = this.GetFirstVisibleVirtualNode();
      l = this.GetLastVisibleVirtualNode();
      if ((f != null) && (l != null)) Result = (l.FRow - f.FRow) + 1;
      return Result;
    };
    this.GetFirstVisibleVirtualNode = function () {
      var Result = null;
      Result = null;
      if (this.FNodeDisplay.GetCount() > 0) Result = this.FNodeDisplay.GetItem(0).FNode;
      return Result;
    };
    this.GetLastVisibleVirtualNode = function () {
      var Result = null;
      Result = null;
      if (this.FNodeDisplay.GetCount() > 0) Result = this.FNodeDisplay.GetItem(this.FNodeDisplay.GetCount() - 1).FNode;
      return Result;
    };
    this.GetFirstVisibleVirtualNodeRow = function () {
      var Result = 0;
      var n = null;
      n = this.GetFirstVisibleVirtualNode();
      Result = 0;
      if (n != null) Result = n.FRow;
      return Result;
    };
    this.GetLastVisibleVirtualNodeRow = function () {
      var Result = 0;
      var n = null;
      n = this.GetLastVisibleVirtualNode();
      Result = 0;
      if (n != null) Result = n.FRow;
      return Result;
    };
    this.GetNodesFromClipboard = function () {
      var Result = null;
      var s = "";
      var a = null;
      var ANode = null;
      var ANextNode = null;
      var ALevel = 0;
      var I = 0;
      var off = 0;
      var CurrStr = "";
      var tempt = null;
      if (pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.HasFormat(pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoardFormat.cfText)) {
        s = pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.GetText();
        if (pas.System.Pos($mod.CLP_FMT,s) > 0) {
          tempt = $mod.TTMSFNCCustomTreeView.$create("Create$1",[null]);
          a = pas.Classes.TStringList.$create("Create$1");
          try {
            s = pas.SysUtils.StringReplace(s,$mod.CLP_FMT,"",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
            a.SetTextStr(s);
            try {
              ANode = null;
              off = 0;
              for (var $l = 0, $end = a.GetCount() - 1; $l <= $end; $l++) {
                I = $l;
                ALevel = -1;
                CurrStr = this.GetBufStart(a.Get(I),{get: function () {
                    return ALevel;
                  }, set: function (v) {
                    ALevel = v;
                  }});
                if (ANode === null) {
                  ANode = tempt.AddNode(null);
                  off = ALevel;
                } else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel === (ALevel - off))) {
                  ANode = tempt.AddNode(ANode.GetParent())}
                 else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel === (ALevel - 1 - off))) {
                  ANode = tempt.AddNode(ANode)}
                 else if ((ANode.FVirtualNode != null) && (ANode.FVirtualNode.FLevel > (ALevel - off))) {
                  ANextNode = ANode.GetParent();
                  while ((ANextNode != null) && (ANextNode.FVirtualNode != null) && (ANextNode.FVirtualNode.FLevel > (ALevel - off))) ANextNode = ANextNode.GetParent();
                  ANode = tempt.AddNode(ANextNode.GetParent());
                };
                if (ANode != null) ANode.LoadFromString(CurrStr);
              };
            } finally {
            };
          } finally {
            this.FCopyNodes.Assign(tempt.FNodes);
            a = rtl.freeLoc(a);
            tempt = rtl.freeLoc(tempt);
          };
        };
      };
      Result = this.FCopyNodes;
      return Result;
    };
    this.IsEditing = function () {
      var Result = false;
      Result = this.FInplaceEditorActive;
      return Result;
    };
    this.LookupNode = function (ALookupString, ARootNodesOnly, AColumn, ACaseSensitive, AAutoSelect, AAutoExpand) {
      var Result = null;
      var v = "";
      var n = null;
      var fvn = null;
      var lvn = null;
      var s = "";
      var sr = 0;
      var er = 0;
      var m = 0;
      var C = 0;
      var fnd = false;
      Result = null;
      v = ALookupString;
      if (!ACaseSensitive) v = pas.SysUtils.UpperCase(v);
      if (ARootNodesOnly) {
        n = this.GetFirstRootVirtualNode();
        while (n != null) {
          fvn = this.GetFirstVisibleVirtualNode();
          lvn = this.GetLastVisibleVirtualNode();
          if (!this.FInteraction.FLookup.FVisibleNodesOnly || (this.FInteraction.FLookup.FVisibleNodesOnly && (fvn != null) && (lvn != null) && (n.FRow <= lvn.FRow) && (n.FRow >= fvn.FRow))) {
            if ((AColumn >= 0) && (AColumn <= (this.FColumns.GetCount() - 1))) {
              s = "";
              this.DoGetNodeText(n,AColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }});
              s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(s);
              if (!ACaseSensitive) s = pas.SysUtils.UpperCase(s);
              if (pas.System.Pos(v,s) === 1) {
                Result = n;
                break;
              };
            } else {
              fnd = false;
              for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
                C = $l;
                s = "";
                this.DoGetNodeText(n,C,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                    return s;
                  }, set: function (v) {
                    s = v;
                  }});
                s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(s);
                if (!ACaseSensitive) s = pas.SysUtils.UpperCase(s);
                if (pas.System.Pos(v,s) === 1) {
                  Result = n;
                  fnd = true;
                  break;
                };
              };
              if (fnd) break;
            };
          };
          n = n.GetNextSibling();
        };
      } else {
        sr = 0;
        er = this.FNodeStructure.GetCount() - 1;
        for (var $l1 = sr, $end1 = er; $l1 <= $end1; $l1++) {
          m = $l1;
          n = this.GetNodeFromNodeStructure(m);
          if (n != null) {
            fvn = this.GetFirstVisibleVirtualNode();
            lvn = this.GetLastVisibleVirtualNode();
            if (!this.FInteraction.FLookup.FVisibleNodesOnly || (this.FInteraction.FLookup.FVisibleNodesOnly && (fvn != null) && (lvn != null) && (n.FRow <= lvn.FRow) && (n.FRow >= fvn.FRow))) {
              if ((AColumn >= 0) && (AColumn <= (this.FColumns.GetCount() - 1))) {
                s = "";
                this.DoGetNodeText(n,AColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                    return s;
                  }, set: function (v) {
                    s = v;
                  }});
                s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(s);
                if (!ACaseSensitive) s = pas.SysUtils.UpperCase(s);
                if (pas.System.Pos(v,s) === 1) {
                  Result = n;
                  break;
                };
              } else {
                fnd = false;
                for (var $l2 = 0, $end2 = this.FColumns.GetCount() - 1; $l2 <= $end2; $l2++) {
                  C = $l2;
                  s = "";
                  this.DoGetNodeText(n,C,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                      return s;
                    }, set: function (v) {
                      s = v;
                    }});
                  s = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(s);
                  if (!ACaseSensitive) s = pas.SysUtils.UpperCase(s);
                  if (pas.System.Pos(v,s) === 1) {
                    Result = n;
                    fnd = true;
                    break;
                  };
                };
                if (fnd) break;
              };
            };
          };
        };
      };
      if (Result != null) {
        if (AAutoExpand) {
          n = Result.GetParent();
          while ((n != null) && (n.FLevel > 0)) {
            if (!n.GetExpanded()) n.Expand(false);
            n = n.GetParent();
          };
          if (n != null) n.Expand(false);
        };
        if (AAutoSelect) {
          if (this.IsVirtualNodeSelectable(Result)) {
            this.SelectVirtualNode(Result);
            this.NotifyDataBinderSetActiveRecord();
          };
          this.ScrollToVirtualNode(Result,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
        };
      };
      return Result;
    };
    this.GetInplaceEditor = function () {
      var Result = null;
      Result = this.FInplaceEditor;
      return Result;
    };
    this.IsNodeSelectable = function (ANode) {
      var Result = false;
      Result = true;
      if (ANode != null) Result = this.IsVirtualNodeSelectable(ANode.FVirtualNode);
      return Result;
    };
    this.IsVirtualNodeSelectable = function (ANode) {
      var Result = false;
      var ext = false;
      Result = true;
      if (ANode != null) {
        this.DoIsNodeEnabled(ANode,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
        ext = false;
        this.DoIsNodeExtended(ANode,{get: function () {
            return ext;
          }, set: function (v) {
            ext = v;
          }});
        if ((ext && !this.FInteraction.FExtendedSelectable) || !(this.FVisibleNodes.IndexOf(ANode) > -1)) Result = false;
      };
      return Result;
    };
    this.XYToColumnAnchor = function (AX, AY, AIndex) {
      var Result = "";
      Result = this.XYToColumnAnchorCache(AX,AY,this.FColumnsTopCache,AIndex);
      if ((Result === "") && (AIndex.get() === -1)) Result = this.XYToColumnAnchorCache(AX,AY,this.FColumnsBottomCache,AIndex);
      return Result;
    };
    this.XYToNode = function (X, Y, OffsetX) {
      var Result = null;
      var dsp = null;
      Result = null;
      dsp = this.XYToCacheItem(X,Y,OffsetX);
      if (dsp != null) Result = dsp.FNode;
      return Result;
    };
    this.XYToNodeAnchor = function (ANode, X, Y) {
      var Result = $mod.TTMSFNCTreeViewNodeAnchor.$new();
      var I = 0;
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var a = "";
      var str = "";
      var g = null;
      var c = null;
      var ha = 0;
      var va = 0;
      var ww = false;
      var trim = 0;
      var ext = false;
      var st = 0;
      var stp = 0;
      Result.AAnchor = "";
      Result.AColumn = -1;
      if (ANode != null) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FTextRects) - 1))) {
            txtr.$assign(ANode.FTextRects[I - st]);
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(txtr,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(txtr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              c = null;
              if (I <= (this.FColumns.GetCount() - 1)) c = this.FColumns.GetItem$1(I);
              ext = false;
              ha = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
              va = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
              ww = false;
              trim = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
              if (c != null) {
                ha = c.FHorizontalTextAlign;
                va = c.FVerticalTextAlign;
                ww = c.FWordWrapping;
                trim = c.FTrimming;
              };
              this.DoIsNodeExtended(ANode,{get: function () {
                  return ext;
                }, set: function (v) {
                  ext = v;
                }});
              this.DoGetNodeTrimming(ANode,I,{get: function () {
                  return trim;
                }, set: function (v) {
                  trim = v;
                }});
              this.DoGetNodeWordWrapping(ANode,I,{get: function () {
                  return ww;
                }, set: function (v) {
                  ww = v;
                }});
              this.DoGetNodeHorizontalTextAlign(ANode,I,{get: function () {
                  return ha;
                }, set: function (v) {
                  ha = v;
                }});
              this.DoGetNodeVerticalTextAlign(ANode,I,{get: function () {
                  return va;
                }, set: function (v) {
                  va = v;
                }});
              str = "";
              this.DoGetNodeText(ANode,I,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return str;
                }, set: function (v) {
                  str = v;
                }});
              g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
              try {
                try {
                  if (!g.BeginScene()) return Result;
                } catch ($e) {
                  return Result;
                };
                if ((c != null) && !c.FUseDefaultAppearance && !ext) {
                  g.FFont.Assign(c.FFont)}
                 else {
                  if (ext) {
                    g.FFont.Assign(this.FNodesAppearance.FExtendedFont)}
                   else g.FFont.Assign(this.FNodesAppearance.FFont);
                };
                g.FBitmapContainer = this.GetBitmapContainer();
                g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
                a = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,0,-1,-1,true,true,X,Y);
                g.EndScene();
              } finally {
                g = rtl.freeLoc(g);
              };
              if (a !== "") {
                Result.AAnchor = a;
                Result.AColumn = I;
                break;
              };
            };
          };
        };
      };
      return Result;
    };
    this.XYToNodeTitleAnchor = function (ANode, X, Y) {
      var Result = $mod.TTMSFNCTreeViewNodeAnchor.$new();
      var I = 0;
      var titr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var a = "";
      var str = "";
      var g = null;
      var c = null;
      var ha = 0;
      var va = 0;
      var ww = false;
      var trim = 0;
      var st = 0;
      var stp = 0;
      Result.AAnchor = "";
      Result.AColumn = -1;
      if (ANode != null) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FTitleRects) - 1))) {
            titr.$assign(ANode.FTitleRects[I - st]);
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(titr,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(titr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              c = null;
              if (I <= (this.FColumns.GetCount() - 1)) c = this.FColumns.GetItem$1(I);
              ha = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
              va = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
              ww = false;
              trim = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
              if (c != null) {
                ha = c.FTitleHorizontalTextAlign;
                va = c.FTitleVerticalTextAlign;
                ww = c.FTitleWordWrapping;
                trim = c.FTitleTrimming;
              };
              this.DoGetNodeTitleTrimming(ANode,I,{get: function () {
                  return trim;
                }, set: function (v) {
                  trim = v;
                }});
              this.DoGetNodeTitleWordWrapping(ANode,I,{get: function () {
                  return ww;
                }, set: function (v) {
                  ww = v;
                }});
              this.DoGetNodeTitleHorizontalTextAlign(ANode,I,{get: function () {
                  return ha;
                }, set: function (v) {
                  ha = v;
                }});
              this.DoGetNodeTitleVerticalTextAlign(ANode,I,{get: function () {
                  return va;
                }, set: function (v) {
                  va = v;
                }});
              str = "";
              this.DoGetNodeTitle(ANode,I,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                  return str;
                }, set: function (v) {
                  str = v;
                }});
              g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
              try {
                try {
                  if (!g.BeginScene()) return Result;
                } catch ($e) {
                  return Result;
                };
                if ((c != null) && !c.FUseDefaultAppearance) {
                  g.FFont.Assign(c.FTitleFont)}
                 else g.FFont.Assign(this.FNodesAppearance.FTitleFont);
                g.FBitmapContainer = this.GetBitmapContainer();
                g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
                a = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(titr),str,ww,ha,va,trim,0,-1,-1,true,true,X,Y);
                g.EndScene();
              } finally {
                g = rtl.freeLoc(g);
              };
              if (a !== "") {
                Result.AAnchor = a;
                Result.AColumn = I;
                break;
              };
            };
          };
        };
      };
      return Result;
    };
    this.XYToNodeExpand = function (ANode, X, Y) {
      var Result = false;
      var nrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var en = false;
      var c = 0;
      Result = false;
      if ((ANode != null) && (ANode.FChildren > 0)) {
        en = true;
        this.DoIsNodeEnabled(ANode,{get: function () {
            return en;
          }, set: function (v) {
            en = v;
          }});
        if (en) {
          c = this.GetFirstVisibleColumn();
          if (((this.FNodesAppearance.FExpandColumn - c) >= 0) && ((this.FNodesAppearance.FExpandColumn - c) <= (rtl.length(ANode.FExpandRects) - 1))) {
            nrt.$assign(ANode.FExpandRects[this.FNodesAppearance.FExpandColumn - c]);
            Result = pas["WEBLib.TMSFNCTypes"].PtInRectEx(nrt,pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
          };
        };
      };
      return Result;
    };
    this.XYToNodeExtra = function (ANode, X, Y) {
      var Result = false;
      var nrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var en = false;
      var I = 0;
      var st = 0;
      var stp = 0;
      Result = false;
      en = true;
      this.DoIsNodeEnabled(ANode,{get: function () {
          return en;
        }, set: function (v) {
          en = v;
        }});
      if ((ANode != null) && en) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FExtraRects) - 1))) {
            nrt.$assign(ANode.FExtraRects[I - st]);
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(nrt,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = true;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToNodeTitleExtra = function (ANode, X, Y) {
      var Result = false;
      var nrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var en = false;
      var I = 0;
      var st = 0;
      var stp = 0;
      Result = false;
      en = true;
      this.DoIsNodeEnabled(ANode,{get: function () {
          return en;
        }, set: function (v) {
          en = v;
        }});
      if ((ANode != null) && en) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FTitleExtraRects) - 1))) {
            nrt.$assign(ANode.FTitleExtraRects[I - st]);
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(nrt,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = true;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToNodeCheck = function (ANode, X, Y) {
      var Result = $mod.TTMSFNCTreeViewNodeCheck.$new();
      var nrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var en = false;
      var I = 0;
      var st = 0;
      var stp = 0;
      Result.AColumn = -1;
      Result.ANode = null;
      en = true;
      this.DoIsNodeEnabled(ANode,{get: function () {
          return en;
        }, set: function (v) {
          en = v;
        }});
      if ((ANode != null) && en) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FCheckRects) - 1))) {
            nrt.$assign(ANode.FCheckRects[I - st]);
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(nrt,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result.ANode = ANode;
              Result.AColumn = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToNodeIcon = function (ANode, X, Y) {
      var Result = $mod.TTMSFNCTreeViewNodeIcon.$new();
      var nrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var en = false;
      var I = 0;
      var st = 0;
      var stp = 0;
      Result.AColumn = -1;
      Result.ANode = null;
      en = true;
      this.DoIsNodeEnabled(ANode,{get: function () {
          return en;
        }, set: function (v) {
          en = v;
        }});
      if ((ANode != null) && en) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FBitmapRects) - 1))) {
            nrt.$assign(ANode.FBitmapRects[I - st]);
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(nrt,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result.ANode = ANode;
              Result.AColumn = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToNodeTextColumn = function (ANode, X, Y) {
      var Result = 0;
      var nrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var st = 0;
      var stp = 0;
      Result = -1;
      if (ANode != null) {
        st = this.GetFirstVisibleColumn();
        stp = this.GetLastVisibleColumn();
        for (var $l = st, $end = stp; $l <= $end; $l++) {
          I = $l;
          if (((I - st) >= 0) && ((I - st) <= (rtl.length(ANode.FTextRects) - 1))) {
            nrt.$assign(ANode.FTextRects[I - st]);
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(nrt,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToColumnSize = function (X, Y) {
      var Result = 0;
      var I = 0;
      var topr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var colw = 0.0;
      var colp = 0.0;
      Result = -1;
      topr.$assign(this.GetColumnsTopRect());
      topr.Left = topr.Left - this.GetHorizontalScrollPosition();
      for (var $l = this.FColumnCount - 1; $l >= 0; $l--) {
        I = $l;
        if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1)) && this.FColumns.GetItem$1(I).FVisible) {
          colw = this.GetColWidths(I);
          if ((colw >= 0) && (I >= 0) && (I <= (this.FColumns.GetCount() - 1)) && this.FColumns.GetItem$1(I).FVisible) {
            colp = this.GetColPos(I);
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF((topr.Left + colp + colw) - this.ScalePaintValue(4),topr.Top,topr.Left + colp + colw + this.ScalePaintValue(4),topr.Bottom));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(r,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToColumn = function (X, Y, AIncludeRows) {
      var Result = 0;
      var I = 0;
      var topr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var colw = 0.0;
      var colp = 0.0;
      Result = -1;
      if (AIncludeRows) {
        topr.$assign(pas["WEBLib.TMSFNCTreeViewBase"].TTMSFNCTreeViewBase.GetContentRect.call(this))}
       else topr.$assign(this.GetColumnsTopRect());
      topr.Left = topr.Left - this.GetHorizontalScrollPosition();
      for (var $l = this.FColumnCount - 1; $l >= 0; $l--) {
        I = $l;
        if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1)) && this.FColumns.GetItem$1(I).FVisible) {
          colw = this.GetColWidths(I) + this.GetColumnsExtraSize();
          if (colw >= 0) {
            colp = this.GetColPos(I);
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(topr.Left + colp,topr.Top,topr.Left + colp + colw,topr.Bottom));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(r,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToColumnFilter = function (X, Y) {
      var Result = 0;
      var I = 0;
      var topr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var szd = 0.0;
      var colw = 0.0;
      var colp = 0.0;
      Result = -1;
      topr.$assign(this.GetColumnsTopRect());
      topr.Left = topr.Left - this.GetHorizontalScrollPosition();
      for (var $l = this.FColumnCount - 1; $l >= 0; $l--) {
        I = $l;
        if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1)) && this.FColumns.GetItem$1(I).FFiltering.FEnabled && this.FColumns.GetItem$1(I).FVisible) {
          colw = this.GetColWidths(I) + this.GetColumnsExtraSize();
          if (colw >= 0) {
            colp = this.GetColPos(I);
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(topr.Left + colp,topr.Top,topr.Left + colp + colw,topr.Bottom));
            szd = this.FColumns.GetItem$1(I).FFiltering.FButtonSize;
            dr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(r.Right - szd - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - szd) / 2)),Math.round(r.Right - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - szd) / 2) + szd)));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(dr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.XYToColumnExpand = function (X, Y) {
      var Result = 0;
      var I = 0;
      var topr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var szd = 0.0;
      var colw = 0.0;
      var colp = 0.0;
      var f = 0.0;
      Result = -1;
      topr.$assign(this.GetColumnsTopRect());
      topr.Left = topr.Left - this.GetHorizontalScrollPosition();
      for (var $l = this.FColumnCount - 1; $l >= 0; $l--) {
        I = $l;
        if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1)) && this.FColumns.GetItem$1(I).FExpandable && this.FColumns.GetItem$1(I).FVisible) {
          colw = this.GetColWidths(I) + this.GetColumnsExtraSize();
          if (colw >= 0) {
            colp = this.GetColPos(I);
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(topr.Left + colp,topr.Top,topr.Left + colp + colw,topr.Bottom));
            szd = this.FColumns.GetItem$1(I).FExpandingButtonSize;
            if (this.FColumns.GetItem$1(I).FFiltering.FEnabled) {
              f = this.FColumns.GetItem$1(I).FFiltering.FButtonSize;
              dr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(r.Right - f - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - f) / 2)),Math.round(r.Right - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - f) / 2) + f)));
              sr.$assign(r);
              sr.Right = dr.Left;
            } else sr.$assign(r);
            dr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(sr.Right - szd - this.ScalePaintValue(6)),Math.round(sr.Top + ((sr.Bottom - sr.Top - szd) / 2)),Math.round(sr.Right - this.ScalePaintValue(6)),Math.round(sr.Top + ((sr.Bottom - sr.Top - szd) / 2) + szd)));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(dr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
              Result = I;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.SelectedNodeCount = function () {
      var Result = 0;
      Result = this.SelectedVirtualNodeCount();
      return Result;
    };
    this.SelectedVirtualNodeCount = function () {
      var Result = 0;
      Result = this.FSelectedNodes.GetCount();
      return Result;
    };
    this.IsNodeSelected = function (ANode) {
      var Result = false;
      Result = false;
      if (ANode != null) Result = this.IsVirtualNodeSelected(ANode.FVirtualNode);
      return Result;
    };
    this.IsVirtualNodeSelected = function (ANode) {
      var Result = false;
      Result = this.FSelectedNodes.IndexOf(ANode) > -1;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCTreeViewPublished",this.TTMSFNCCustomTreeView,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("HorizontalScrollBarVisible",2,rtl.boolean,"FHorizontalScrollBarVisible","SetHorizontalScrollBarVisible",4,{Default: true});
    $r.addProperty("VerticalScrollBarVisible",2,rtl.boolean,"FVerticalScrollBarVisible","SetVerticalScrollBarVisible",4,{Default: true});
    $r.addProperty("Groups",2,pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewGroups"],"FGroups","SetGroups");
    $r.addProperty("GroupsAppearance",2,$mod.$rtti["TTMSFNCTreeViewGroupsAppearance"],"FGroupsAppearance","SetGroupsAppearance");
    $r.addProperty("ColumnStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FColumnStroke","SetColumnStroke");
    $r.addProperty("Columns",2,pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewColumns"],"FColumns","SetColumns");
    $r.addProperty("Nodes",2,pas["WEBLib.TMSFNCTreeViewData"].$rtti["TTMSFNCTreeViewNodes"],"FNodes","SetNodes");
    $r.addProperty("ColumnsAppearance",2,$mod.$rtti["TTMSFNCTreeViewColumnsAppearance"],"FColumnsAppearance","SetColumnsAppearance");
    $r.addProperty("NodesAppearance",2,$mod.$rtti["TTMSFNCTreeViewNodesAppearance"],"FNodesAppearance","SetNodesAppearance");
    $r.addProperty("Interaction",2,$mod.$rtti["TTMSFNCTreeViewInteraction"],"FInteraction","SetInteraction");
    $r.addProperty("StretchScrollBars",2,rtl.boolean,"FStretchScrollBars","SetStretchScrollBars",4,{Default: true});
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("GlobalFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCAppearanceGlobalFont"],"FGlobalFont","SetGlobalFont");
    $r.addProperty("OnCustomizeFilterListBox",0,$mod.$rtti["TTMSFNCTreeViewCustomizeFilterListBoxEvent"],"FOnCustomizeFilterListBox","FOnCustomizeFilterListBox");
    $r.addProperty("OnNeedFilterDropDownData",0,$mod.$rtti["TTMSFNCTreeViewNeedFilterDropDownDataEvent"],"FOnNeedFilterDropDownData","FOnNeedFilterDropDownData");
    $r.addProperty("OnFilterSelect",0,$mod.$rtti["TTMSFNCTreeViewFilterSelectEvent"],"FOnFilterSelect","FOnFilterSelect");
    $r.addProperty("OnBeforeDrawColumn",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawColumnEvent"],"FOnBeforeDrawColumn","FOnBeforeDrawColumn");
    $r.addProperty("OnAfterDrawColumn",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawColumnEvent"],"FOnAfterDrawColumn","FOnAfterDrawColumn");
    $r.addProperty("OnBeforeDrawColumnHeader",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawColumnHeaderEvent"],"FOnBeforeDrawColumnHeader","FOnBeforeDrawColumnHeader");
    $r.addProperty("OnAfterDrawColumnHeader",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawColumnHeaderEvent"],"FOnAfterDrawColumnHeader","FOnAfterDrawColumnHeader");
    $r.addProperty("OnBeforeDrawNodeColumn",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawColumnEvent"],"FOnBeforeDrawNodeColumn","FOnBeforeDrawNodeColumn");
    $r.addProperty("OnAfterDrawNodeColumn",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawColumnEvent"],"FOnAfterDrawNodeColumn","FOnAfterDrawNodeColumn");
    $r.addProperty("OnBeforeSortNodes",0,$mod.$rtti["TTMSFNCTreeViewBeforeSortNodesEvent"],"FOnBeforeSortNodes","FOnBeforeSortNodes");
    $r.addProperty("OnAfterSortNodes",0,$mod.$rtti["TTMSFNCTreeViewAfterSortNodesEvent"],"FOnAfterSortNodes","FOnAfterSortNodes");
    $r.addProperty("OnBeforeDrawGroup",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawGroupEvent"],"FOnBeforeDrawGroup","FOnBeforeDrawGroup");
    $r.addProperty("OnAfterDrawGroup",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawGroupEvent"],"FOnAfterDrawGroup","FOnAfterDrawGroup");
    $r.addProperty("OnBeforeDrawNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawNodeEvent"],"FOnBeforeDrawNode","FOnBeforeDrawNode");
    $r.addProperty("OnAfterDrawNode",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawNodeEvent"],"FOnAfterDrawNode","FOnAfterDrawNode");
    $r.addProperty("OnBeforeDrawColumnText",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawColumnTextEvent"],"FOnBeforeDrawColumnText","FOnBeforeDrawColumnText");
    $r.addProperty("OnGetColumnText",0,$mod.$rtti["TTMSFNCTreeViewGetColumnTextEvent"],"FOnGetColumnText","FOnGetColumnText");
    $r.addProperty("OnNodeCompare",0,$mod.$rtti["TTMSFNCTreeViewNodeCompareEvent"],"FOnNodeCompare","FOnNodeCompare");
    $r.addProperty("OnAfterDrawColumnText",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawColumnTextEvent"],"FOnAfterDrawColumnText","FOnAfterDrawColumnText");
    $r.addProperty("OnBeforeDrawGroupText",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawGroupTextEvent"],"FOnBeforeDrawGroupText","FOnBeforeDrawGroupText");
    $r.addProperty("OnGetGroupText",0,$mod.$rtti["TTMSFNCTreeViewGetGroupTextEvent"],"FOnGetGroupText","FOnGetGroupText");
    $r.addProperty("OnAfterDrawGroupText",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawGroupTextEvent"],"FOnAfterDrawGroupText","FOnAfterDrawGroupText");
    $r.addProperty("OnBeforeDrawNodeText",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawNodeTextEvent"],"FOnBeforeDrawNodeText","FOnBeforeDrawNodeText");
    $r.addProperty("OnAfterDrawNodeIcon",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawNodeIconEvent"],"FOnAfterDrawNodeIcon","FOnAfterDrawNodeIcon");
    $r.addProperty("OnAfterDrawNodeExpand",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawNodeExpandEvent"],"FOnAfterDrawNodeExpand","FOnAfterDrawNodeExpand");
    $r.addProperty("OnBeforeDrawNodeIcon",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawNodeIconEvent"],"FOnBeforeDrawNodeIcon","FOnBeforeDrawNodeIcon");
    $r.addProperty("OnBeforeDrawNodeExpand",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawNodeExpandEvent"],"FOnBeforeDrawNodeExpand","FOnBeforeDrawNodeExpand");
    $r.addProperty("OnAfterDrawNodeCheck",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawNodeCheckEvent"],"FOnAfterDrawNodeCheck","FOnAfterDrawNodeCheck");
    $r.addProperty("OnBeforeDrawNodeCheck",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawNodeCheckEvent"],"FOnBeforeDrawNodeCheck","FOnBeforeDrawNodeCheck");
    $r.addProperty("OnGetNodeCheckType",0,$mod.$rtti["TTMSFNCTreeViewGetNodeCheckTypeEvent"],"FOnGetNodeCheckType","FOnGetNodeCheckType");
    $r.addProperty("OnGetNodeText",0,$mod.$rtti["TTMSFNCTreeViewGetNodeTextEvent"],"FOnGetNodeText","FOnGetNodeText");
    $r.addProperty("OnGetNodeData",0,$mod.$rtti["TTMSFNCTreeViewGetNodeDataEvent"],"FOnGetNodeData","FOnGetNodeData");
    $r.addProperty("OnBeforeSizeColumn",0,$mod.$rtti["TTMSFNCTreeViewBeforeSizeColumnEvent"],"FOnBeforeSizeColumn","FOnBeforeSizeColumn");
    $r.addProperty("OnAfterSizeColumn",0,$mod.$rtti["TTMSFNCTreeViewAfterSizeColumnEvent"],"FOnAfterSizeColumn","FOnAfterSizeColumn");
    $r.addProperty("OnGetNodeTrimming",0,$mod.$rtti["TTMSFNCTreeViewGetNodeTrimmingEvent"],"FOnGetNodeTrimming","FOnGetNodeTrimming");
    $r.addProperty("OnGetNodeWordWrapping",0,$mod.$rtti["TTMSFNCTreeViewGetNodeWordWrappingEvent"],"FOnGetNodeWordWrapping","FOnGetNodeWordWrapping");
    $r.addProperty("OnGetNodeHorizontalTextAlign",0,$mod.$rtti["TTMSFNCTreeViewGetNodeHorizontalTextAlignEvent"],"FOnGetNodeHorizontalTextAlign","FOnGetNodeHorizontalTextAlign");
    $r.addProperty("OnGetNodeVerticalTextAlign",0,$mod.$rtti["TTMSFNCTreeViewGetNodeVerticalTextAlignEvent"],"FOnGetNodeVerticalTextAlign","FOnGetNodeVerticalTextAlign");
    $r.addProperty("OnGetColumnTrimming",0,$mod.$rtti["TTMSFNCTreeViewGetColumnTrimmingEvent"],"FOnGetColumnTrimming","FOnGetColumnTrimming");
    $r.addProperty("OnFocusedNodeChanged",0,$mod.$rtti["TTMSFNCTreeViewFocusedNodeChangedEvent"],"FOnFocusedNodeChanged","FOnFocusedNodeChanged");
    $r.addProperty("OnGetColumnWordWrapping",0,$mod.$rtti["TTMSFNCTreeViewGetColumnWordWrappingEvent"],"FOnGetColumnWordWrapping","FOnGetColumnWordWrapping");
    $r.addProperty("OnGetColumnHorizontalTextAlign",0,$mod.$rtti["TTMSFNCTreeViewGetColumnHorizontalTextAlignEvent"],"FOnGetColumnHorizontalTextAlign","FOnGetColumnHorizontalTextAlign");
    $r.addProperty("OnGetColumnVerticalTextAlign",0,$mod.$rtti["TTMSFNCTreeViewGetColumnVerticalTextAlignEvent"],"FOnGetColumnVerticalTextAlign","FOnGetColumnVerticalTextAlign");
    $r.addProperty("OnBeforeUnCheckNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeUnCheckNodeEvent"],"FOnBeforeUnCheckNode","FOnBeforeUnCheckNode");
    $r.addProperty("OnAfterUnCheckNode",0,$mod.$rtti["TTMSFNCTreeViewAfterUnCheckNodeEvent"],"FOnAfterUnCheckNode","FOnAfterUnCheckNode");
    $r.addProperty("OnBeforeCheckNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeCheckNodeEvent"],"FOnBeforeCheckNode","FOnBeforeCheckNode");
    $r.addProperty("OnAfterCheckNode",0,$mod.$rtti["TTMSFNCTreeViewAfterCheckNodeEvent"],"FOnAfterCheckNode","FOnAfterCheckNode");
    $r.addProperty("OnBeforeCollapseNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeCollapseNodeEvent"],"FOnBeforeCollapseNode","FOnBeforeCollapseNode");
    $r.addProperty("OnAfterCollapseNode",0,$mod.$rtti["TTMSFNCTreeViewAfterCollapseNodeEvent"],"FOnAfterCollapseNode","FOnAfterCollapseNode");
    $r.addProperty("OnBeforeExpandNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeExpandNodeEvent"],"FOnBeforeExpandNode","FOnBeforeExpandNode");
    $r.addProperty("OnAfterExpandNode",0,$mod.$rtti["TTMSFNCTreeViewAfterExpandNodeEvent"],"FOnAfterExpandNode","FOnAfterExpandNode");
    $r.addProperty("OnGetNodeIcon",0,$mod.$rtti["TTMSFNCTreeViewGetNodeIconEvent"],"FOnGetNodeIcon","FOnGetNodeIcon");
    $r.addProperty("OnGetNodeIconSize",0,$mod.$rtti["TTMSFNCTreeViewGetNodeIconSizeEvent"],"FOnGetNodeIconSize","FOnGetNodeIconSize");
    $r.addProperty("OnGetNumberOfNodes",0,$mod.$rtti["TTMSFNCTreeViewGetNumberOfNodesEvent"],"FOnGetNumberOfNodes","FOnGetNumberOfNodes");
    $r.addProperty("OnIsNodeExtended",0,$mod.$rtti["TTMSFNCTreeViewIsNodeExtendedEvent"],"FOnIsNodeExtended","FOnIsNodeExtended");
    $r.addProperty("OnIsNodeExpanded",0,$mod.$rtti["TTMSFNCTreeViewIsNodeExpandedEvent"],"FOnIsNodeExpanded","FOnIsNodeExpanded");
    $r.addProperty("OnAfterDrawNodeText",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawNodeTextEvent"],"FOnAfterDrawNodeText","FOnAfterDrawNodeText");
    $r.addProperty("OnIsNodeChecked",0,$mod.$rtti["TTMSFNCTreeViewIsNodeCheckedEvent"],"FOnIsNodeChecked","FOnIsNodeChecked");
    $r.addProperty("OnNodeAnchorClick",0,$mod.$rtti["TTMSFNCTreeViewNodeAnchorClickEvent"],"FOnNodeAnchorClick","FOnNodeAnchorClick");
    $r.addProperty("OnBeforeUpdateNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeUpdateNodeEvent"],"FOnBeforeUpdateNode","FOnBeforeUpdateNode");
    $r.addProperty("OnAfterUpdateNode",0,$mod.$rtti["TTMSFNCTreeViewAfterUpdateNodeEvent"],"FOnAfterUpdateNode","FOnAfterUpdateNode");
    $r.addProperty("OnBeforeSelectNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeSelectNodeEvent"],"FOnBeforeSelectNode","FOnBeforeSelectNode");
    $r.addProperty("OnAfterSelectNode",0,$mod.$rtti["TTMSFNCTreeViewAfterSelectNodeEvent"],"FOnAfterSelectNode","FOnAfterSelectNode");
    $r.addProperty("OnBeforeSelectAllNodes",0,$mod.$rtti["TTMSFNCTreeViewBeforeSelectAllNodesEvent"],"FOnBeforeSelectAllNodes","FOnBeforeSelectAllNodes");
    $r.addProperty("OnAfterSelectAllNodes",0,$mod.$rtti["TTMSFNCTreeViewAfterSelectAllNodesEvent"],"FOnAfterSelectAllNodes","FOnAfterSelectAllNodes");
    $r.addProperty("OnNodeClick",0,$mod.$rtti["TTMSFNCTreeViewNodeClickEvent"],"FOnNodeClick","FOnNodeClick");
    $r.addProperty("OnNodeValueClick",0,$mod.$rtti["TTMSFNCTreeViewNodeValueClickEvent"],"FOnNodeValueClick","FOnNodeValueClick");
    $r.addProperty("OnNodeMouseLeave",0,$mod.$rtti["TTMSFNCTreeViewNodeMouseLeaveEvent"],"FOnNodeMouseLeave","FOnNodeMouseLeave");
    $r.addProperty("OnNodeMouseEnter",0,$mod.$rtti["TTMSFNCTreeViewNodeMouseEnterEvent"],"FOnNodeMouseEnter","FOnNodeMouseEnter");
    $r.addProperty("OnNodeDblClick",0,$mod.$rtti["TTMSFNCTreeViewNodeClickEvent"],"FOnNodeDblClick","FOnNodeDblClick");
    $r.addProperty("OnBeforeUnSelectNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeUnSelectNodeEvent"],"FOnBeforeUnSelectNode","FOnBeforeUnSelectNode");
    $r.addProperty("OnAfterUnSelectNode",0,$mod.$rtti["TTMSFNCTreeViewAfterUnSelectNodeEvent"],"FOnAfterUnSelectNode","FOnAfterUnSelectNode");
    $r.addProperty("OnGetNodeSides",0,$mod.$rtti["TTMSFNCTreeViewGetNodeSidesEvent"],"FOnGetNodeSides","FOnGetNodeSides");
    $r.addProperty("OnBeforeOpenInplaceEditor",0,$mod.$rtti["TTMSFNCTreeViewBeforeOpenInplaceEditorEvent"],"FOnBeforeOpenInplaceEditor","FOnBeforeOpenInplaceEditor");
    $r.addProperty("OnCloseInplaceEditor",0,$mod.$rtti["TTMSFNCTreeViewCloseInplaceEditorEvent"],"FOnCloseInplaceEditor","FOnCloseInplaceEditor");
    $r.addProperty("OnAfterOpenInplaceEditor",0,$mod.$rtti["TTMSFNCTreeViewAfterOpenInplaceEditorEvent"],"FOnAfterOpenInplaceEditor","FOnAfterOpenInplaceEditor");
    $r.addProperty("OnGetInplaceEditor",0,$mod.$rtti["TTMSFNCTreeViewGetInplaceEditorEvent"],"FOnGetInplaceEditor","FOnGetInplaceEditor");
    $r.addProperty("OnCustomizeInplaceEditor",0,$mod.$rtti["TTMSFNCTreeViewCustomizeInplaceEditorEvent"],"FOnCustomizeInplaceEditor","FOnCustomizeInplaceEditor");
    $r.addProperty("OnGetInplaceEditorRect",0,$mod.$rtti["TTMSFNCTreeViewGetInplaceEditorRectEvent"],"FOnGetInplaceEditorRect","FOnGetInplaceEditorRect");
    $r.addProperty("OnNodeChanged",0,$mod.$rtti["TTMSFNCTreeViewNodeChangedEvent"],"FOnNodeChanged","FOnNodeChanged");
    $r.addProperty("OnHScroll",0,$mod.$rtti["TTMSFNCTreeViewScrollEvent"],"FOnHScroll","FOnHScroll");
    $r.addProperty("OnVScroll",0,$mod.$rtti["TTMSFNCTreeViewScrollEvent"],"FOnVScroll","FOnVScroll");
    $r.addProperty("OnBeforeDrawColumnEmptySpace",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawColumnEmptySpaceEvent"],"FOnBeforeDrawColumnEmptySpace","FOnBeforeDrawColumnEmptySpace");
    $r.addProperty("OnAfterDrawColumnEmptySpace",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawColumnEmptySpaceEvent"],"FOnAfterDrawColumnEmptySpace","FOnAfterDrawColumnEmptySpace");
    $r.addProperty("OnBeforeDrawGroupEmptySpace",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawGroupEmptySpaceEvent"],"FOnBeforeDrawGroupEmptySpace","FOnBeforeDrawGroupEmptySpace");
    $r.addProperty("OnAfterDrawGroupEmptySpace",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawGroupEmptySpaceEvent"],"FOnAfterDrawGroupEmptySpace","FOnAfterDrawGroupEmptySpace");
    $r.addProperty("OnIsNodeEnabled",0,$mod.$rtti["TTMSFNCTreeViewIsNodeEnabledEvent"],"FOnIsNodeEnabled","FOnIsNodeEnabled");
    $r.addProperty("OnGetNodeColor",0,$mod.$rtti["TTMSFNCTreeViewGetNodeColorEvent"],"FOnGetNodeColor","FOnGetNodeColor");
    $r.addProperty("OnGetNodeSelectedColor",0,$mod.$rtti["TTMSFNCTreeViewGetNodeColorEvent"],"FOnGetNodeSelectedStrokeColor","FOnGetNodeSelectedStrokeColor");
    $r.addProperty("OnGetNodeDisabledColor",0,$mod.$rtti["TTMSFNCTreeViewGetNodeColorEvent"],"FOnGetNodeDisabledColor","FOnGetNodeDisabledColor");
    $r.addProperty("OnGetNodeTextColor",0,$mod.$rtti["TTMSFNCTreeViewGetNodeTextColorEvent"],"FOnGetNodeTextColor","FOnGetNodeTextColor");
    $r.addProperty("OnGetNodeSelectedTextColor",0,$mod.$rtti["TTMSFNCTreeViewGetNodeTextColorEvent"],"FOnGetNodeSelectedTextColor","FOnGetNodeSelectedTextColor");
    $r.addProperty("OnGetNodeDisabledTextColor",0,$mod.$rtti["TTMSFNCTreeViewGetNodeTextColorEvent"],"FOnGetNodeDisabledTextColor","FOnGetNodeDisabledTextColor");
    $r.addProperty("OnGetNodeHeight",0,$mod.$rtti["TTMSFNCTreeViewGetNodeHeightEvent"],"FOnGetNodeHeight","FOnGetNodeHeight");
    $r.addProperty("OnBeforeReorderNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeReorderNodeEvent"],"FOnBeforeReorderNode","FOnBeforeReorderNode");
    $r.addProperty("OnAfterReorderNode",0,$mod.$rtti["TTMSFNCTreeViewAfterReorderNodeEvent"],"FOnAfterReorderNode","FOnAfterReorderNode");
    $r.addProperty("OnBeforeDropNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeDropNodeEvent"],"FOnBeforeDropNode","FOnBeforeDropNode");
    $r.addProperty("OnAfterDropNode",0,$mod.$rtti["TTMSFNCTreeViewAfterDropNodeEvent"],"FOnAfterDropNode","FOnAfterDropNode");
    $r.addProperty("OnBeforeCutToClipboard",0,$mod.$rtti["TTMSFNCTreeViewBeforeCutToClipboardEvent"],"FOnBeforeCutToClipboard","FOnBeforeCutToClipboard");
    $r.addProperty("OnBeforeCopyToClipboard",0,$mod.$rtti["TTMSFNCTreeViewBeforeCopyToClipboardEvent"],"FOnBeforeCopyToClipboard","FOnBeforeCopyToClipboard");
    $r.addProperty("OnBeforePasteFromClipboard",0,$mod.$rtti["TTMSFNCTreeViewBeforePasteFromClipboardEvent"],"FOnBeforePasteFromClipboard","FOnBeforePasteFromClipboard");
    $r.addProperty("OnAfterCutToClipboard",0,$mod.$rtti["TTMSFNCTreeViewAfterCutToClipboardEvent"],"FOnAfterCutToClipboard","FOnAfterCutToClipboard");
    $r.addProperty("OnAfterCopyToClipboard",0,$mod.$rtti["TTMSFNCTreeViewAfterCopyToClipboardEvent"],"FOnAfterCopyToClipboard","FOnAfterCopyToClipboard");
    $r.addProperty("OnAfterPasteFromClipboard",0,$mod.$rtti["TTMSFNCTreeViewAfterPasteFromClipboardEvent"],"FOnAfterPasteFromClipboard","FOnAfterPasteFromClipboard");
    $r.addProperty("OnBeforeDrawSortIndicator",0,$mod.$rtti["TTMSFNCTreeViewBeforeDrawSortIndicatorEvent"],"FOnBeforeDrawSortIndicator","FOnBeforeDrawSortIndicator");
    $r.addProperty("OnAfterDrawSortIndicator",0,$mod.$rtti["TTMSFNCTreeViewAfterDrawSortIndicatorEvent"],"FOnAfterDrawSortIndicator","FOnAfterDrawSortIndicator");
    $r.addProperty("OnColumnAnchorClick",0,$mod.$rtti["TTMSFNCTreeViewColumnAnchorClickEvent"],"FOnColumnAnchorClick","FOnColumnAnchorClick");
    $r.addProperty("OnBeforeAddJSONNode",0,$mod.$rtti["TTMSFNCTreeViewBeforeAddJSONNodeEvent"],"FOnBeforeAddJSONNode","FOnBeforeAddJSONNode");
    $r.addProperty("OnAfterAddJSONNode",0,$mod.$rtti["TTMSFNCTreeViewAfterAddJSONNodeEvent"],"FOnAfterAddJSONNode","FOnAfterAddJSONNode");
    $r.addProperty("DefaultViewJSONOptions",2,$mod.$rtti["TTMSFNCTreeViewViewJSONOptions"],"FDefaultViewJSONOptions","SetDefaultViewJSONOptions");
    $r.addProperty("OnGetHTMLTemplateValue",0,$mod.$rtti["TTMSFNCTreeViewGetHTMLTemplateValueEvent"],"FOnGetHTMLTemplateValue","FOnGetHTMLTemplateValue");
    $r.addProperty("OnGetHTMLTemplate",0,$mod.$rtti["TTMSFNCTreeViewGetHTMLTemplateEvent"],"FOnGetHTMLTemplate","FOnGetHTMLTemplate");
  });
  this.TTMSFNCTREEVIEWEXPAND = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA" + "AJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNvyMY98AAAAySURBVChT" + "Y6iurcaPQCr+4wZYVHj5ekFZYEBdFUAJTISiAg4gEnBAIxVoAKoCH6qtBgAs4hCpNRg4EQAAAABJRU5ErkJggg" + "==";
  this.TTMSFNCTREEVIEWCOLLAPSE = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUA" + "AAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNvyMY98AAAAmSURB" + "VChTY6iurcaPQCr+4wYDoMLL1wsZQQRJNAMroKIKfKi2GgCBNiGJV4wrvQAAAABJRU5ErkJggg==";
  this.TTMSFNCTREEVIEWEXPANDLARGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAIAAABL1vtsAAAAAXNSR0IArs4" + "c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50" + "Lm5ldCA0LjAuNvyMY98AAABDSURBVDhPY6iuraYQUc+I/2QBehnh5esFRFAOBhg1AgFoYwREAzEIop42R" + "mACZA2YYNQIBKCXEfgBtY2gBFFsRG01AN+TQqHfgmnlAAAAAElFTkSuQmCC";
  this.TTMSFNCTREEVIEWCOLLAPSELARGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAIAAABL1vtsAAAABGdBTUEAALGP" + "C/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC42/Ixj3w" + "AAADRJREFUOE9jqK6tphBRz4j/ZIFRIxBg+Bvh5euFB0EVgQEtjSAejBqBAMPTCEoQxUbUVgMAPoCGIXvOpikAAAAASUVORK5CYII=";
  $mod.$resourcestrings = {sTMSFNCTreeViewFilterAll: {org: "(All)"}};
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTMSFNCTreeViewGroupOpen",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewGroup,function () {
    });
    rtl.createClass($impl,"TTMSFNCTreeViewNodeOpen",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNode,function () {
    });
    rtl.createClass($impl,"TTMSFNCTreeViewColumnOpen",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumn,function () {
    });
    rtl.createClass($impl,"TTMSFNCTreeViewVirtualNodeOpen",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewVirtualNode,function () {
    });
    $impl.GetTickCountX = function () {
      var Result = 0;
      var h = 0;
      var m = 0;
      var s = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(pas.SysUtils.Now(),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }},{get: function () {
          return m;
        }, set: function (v) {
          m = v;
        }},{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = ms + (s * 1000) + (m * 60 * 1000) + (h * 60 * 60 * 1000);
      return Result;
    };
    $impl.AnimateDouble = function (Start, Stop, Delta, Margin) {
      var Result = false;
      Result = true;
      if ((Start.get() > (Stop.get() - Margin)) && (Start.get() < (Stop.get() + Margin))) {
        Start.set(Stop.get());
        Result = false;
      } else {
        Delta = Math.max(Margin,Delta);
        if (Start.get() < Stop.get()) {
          Start.set(Start.get() + Delta)}
         else Start.set(Start.get() - Delta);
      };
      return Result;
    };
    $impl.TTMSFNCTreeViewJSONType = {"0": "jtValue", jtValue: 0, "1": "jtArraySize", jtArraySize: 1, "2": "jtObjectSize", jtObjectSize: 2, "3": "jtArrayIndex", jtArrayIndex: 3};
    $mod.$rtti.$Enum("TTMSFNCTreeViewJSONType",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: $impl.TTMSFNCTreeViewJSONType});
  };
  $mod.$init = function () {
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TTMSFNCTREEVIEWEXPAND);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TTMSFNCTREEVIEWEXPANDLARGE);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TTMSFNCTREEVIEWCOLLAPSE);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TTMSFNCTREEVIEWCOLLAPSELARGE);
  };
},["Math","WEBLib.TMSFNCTreeViewBase","WEBLib.TMSFNCUtils","WEBLib.TMSFNCStyles","WEBLib.Forms","WEBLib.Graphics"]);
rtl.module("WEBLib.TMSFNCCustomSelector",["System","Classes","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCCustomControl","WEBLib.Controls"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 1;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCCustomSelector");
  this.TTMSFNCCustomSelectorItemState = {"0": "isNormal", isNormal: 0, "1": "isHover", isHover: 1, "2": "isDown", isDown: 2, "3": "isSelected", isSelected: 3, "4": "isDisabled", isDisabled: 4};
  this.$rtti.$Enum("TTMSFNCCustomSelectorItemState",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCCustomSelectorItemState});
  rtl.createClass(this,"TTMSFNCCustomSelectorItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FOwner = null;
      this.FRowSpan = 0;
      this.FColumnSpan = 0;
      this.FVisible = false;
      this.FText = "";
      this.FEnabled = false;
      this.FSeparator = false;
      this.FSeparatorHeight = 0.0;
      this.FMargins = null;
      this.FCanDeselect = false;
      this.FCanSelect = false;
      this.FVerticalTextAlign = 0;
      this.FHorizontalTextAlign = 0;
      this.FHint = "";
      this.FDataBoolean = false;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FDataPointer = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FMargins = undefined;
      this.FDataObject = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetColumnSpan = function (Value) {
      if (this.FColumnSpan !== Value) {
        this.FColumnSpan = Value;
        this.FOwner.CalculateItems();
      };
    };
    this.SetRowSpan = function (Value) {
      if (this.FRowSpan !== Value) {
        this.FRowSpan = Value;
        this.FOwner.CalculateItems();
      };
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.FOwner.CalculateItems();
      };
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.FOwner.InvalidateItems();
      };
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.FOwner.InvalidateItems();
      };
    };
    this.SetSeparator = function (Value) {
      if (this.FSeparator !== Value) {
        this.FSeparator = Value;
        this.FOwner.CalculateItems();
      };
    };
    this.SetSeparatorHeight = function (Value) {
      if (this.FSeparatorHeight !== Value) {
        this.FSeparatorHeight = Value;
        this.FOwner.InvalidateItems();
      };
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
    };
    this.SetCanDeselect = function (Value) {
      this.FCanDeselect = Value;
    };
    this.SetCanSelect = function (Value) {
      this.FCanSelect = Value;
    };
    this.SetHorizontalTextAlign = function (Value) {
      if (this.FHorizontalTextAlign !== Value) {
        this.FHorizontalTextAlign = Value;
        this.FOwner.InvalidateItems();
      };
    };
    this.SetVerticalTextAlign = function (Value) {
      if (this.FVerticalTextAlign !== Value) {
        this.FVerticalTextAlign = Value;
        this.FOwner.InvalidateItems();
      };
    };
    this.IsSeparatorHeightStored = function () {
      var Result = false;
      Result = this.FSeparatorHeight !== 5;
      return Result;
    };
    this.MarginsChanged = function (Sender) {
      this.FOwner.CalculateItems();
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner = rtl.as(this.FCollection,$mod.TTMSFNCCustomSelectorItems).FOwner$1;
      this.FSeparator = false;
      this.FColumnSpan = 1;
      this.FCanDeselect = true;
      this.FCanSelect = true;
      this.FRowSpan = 1;
      this.FMargins = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FMargins.FOnChange = rtl.createCallback(this,"MarginsChanged");
      this.FEnabled = true;
      this.FSeparatorHeight = 5;
      this.FVisible = true;
      if (this.FOwner != null) this.FOwner.CalculateItems();
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomSelectorItem.isPrototypeOf(Source)) {
        this.FRowSpan = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FRowSpan;
        this.FColumnSpan = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FColumnSpan;
        this.FVisible = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FVisible;
        this.FText = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FText;
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FEnabled;
        this.FSeparator = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FSeparator;
        this.FSeparatorHeight = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FSeparatorHeight;
        this.FMargins.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FMargins);
        this.FCanDeselect = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FCanDeselect;
        this.FCanSelect = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FCanSelect;
        this.FHint = rtl.as(Source,$mod.TTMSFNCCustomSelectorItem).FHint;
      };
    };
    this.State = function () {
      var Result = 0;
      Result = $mod.TTMSFNCCustomSelectorItemState.isNormal;
      if (!this.FSeparator) {
        if (this.FEnabled) {
          if (this.GetIndex() === this.FOwner.FDownItemIndex) {
            Result = $mod.TTMSFNCCustomSelectorItemState.isDown}
           else if (this.GetIndex() === this.FOwner.FHoveredItemIndex) {
            Result = $mod.TTMSFNCCustomSelectorItemState.isHover}
           else if (this.GetIndex() === this.FOwner.FSelectedItemIndex) Result = $mod.TTMSFNCCustomSelectorItemState.isSelected;
        } else Result = $mod.TTMSFNCCustomSelectorItemState.isDisabled;
      };
      return Result;
    };
    this.Destroy = function () {
      rtl.free(this,"FMargins");
      pas.Classes.TCollectionItem.Destroy.call(this);
      if (this.FOwner != null) this.FOwner.CalculateItems();
    };
    var $r = this.$rtti;
    $r.addProperty("CanSelect",2,rtl.boolean,"FCanSelect","SetCanSelect",4,{Default: true});
    $r.addProperty("CanDeselect",2,rtl.boolean,"FCanDeselect","SetCanDeselect",4,{Default: true});
    $r.addProperty("ColumnSpan",2,rtl.longint,"FColumnSpan","SetColumnSpan",4,{Default: 1});
    $r.addProperty("RowSpan",2,rtl.longint,"FRowSpan","SetRowSpan",4,{Default: 1});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Separator",2,rtl.boolean,"FSeparator","SetSeparator",4,{Default: false});
    $r.addProperty("SeparatorHeight",14,rtl.double,"FSeparatorHeight","SetSeparatorHeight",4,{stored: "IsSeparatorHeightStored"});
    $r.addProperty("Margins",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FMargins","SetMargins");
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("HorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalTextAlign","SetHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("Hint",0,rtl.string,"FHint","FHint");
  });
  rtl.createClass(this,"TTMSFNCCustomSelectorItems",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.CreateItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCCustomSelectorItem;
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner$1;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.CreateItemClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCCustomSelectorAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FStrokeHover = null;
      this.FFillDown = null;
      this.FVerticalSpacing = 0.0;
      this.FStrokeDown = null;
      this.FFillSelected = null;
      this.FHorizontalSpacing = 0.0;
      this.FStrokeSelected = null;
      this.FFill = null;
      this.FFillHover = null;
      this.FStroke = null;
      this.FFillDisabled = null;
      this.FStrokeDisabled = null;
      this.FSeparatorStroke = null;
      this.FFont = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FStrokeHover = undefined;
      this.FFillDown = undefined;
      this.FStrokeDown = undefined;
      this.FFillSelected = undefined;
      this.FStrokeSelected = undefined;
      this.FFill = undefined;
      this.FFillHover = undefined;
      this.FStroke = undefined;
      this.FFillDisabled = undefined;
      this.FStrokeDisabled = undefined;
      this.FSeparatorStroke = undefined;
      this.FFont = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetFillDown = function (Value) {
      this.FFillDown.Assign(Value);
    };
    this.SetFillHover = function (Value) {
      this.FFillHover.Assign(Value);
    };
    this.SetFillSelected = function (Value) {
      this.FFillSelected.Assign(Value);
    };
    this.SetHorizontalSpacing = function (Value) {
      if (this.FHorizontalSpacing !== Value) {
        this.FHorizontalSpacing = Value;
        this.Changed();
      };
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetStrokeDown = function (Value) {
      this.FStrokeDown.Assign(Value);
    };
    this.SetStrokeHover = function (Value) {
      this.FStrokeHover.Assign(Value);
    };
    this.SetStrokeSelected = function (Value) {
      this.FStrokeSelected.Assign(Value);
    };
    this.SetVerticalSpacing = function (Value) {
      if (this.FVerticalSpacing !== Value) {
        this.FVerticalSpacing = Value;
        this.Changed();
      };
    };
    this.SetFillDisabled = function (Value) {
      this.FFillDisabled.Assign(Value);
    };
    this.SetStrokeDisabled = function (Value) {
      this.FStrokeDisabled.Assign(Value);
    };
    this.SetSeparatorStroke = function (Value) {
      this.FSeparatorStroke.Assign(Value);
    };
    this.SetFont = function (Value) {
      this.FFont.AssignSource(Value);
    };
    this.IsHorizontalSpacingStored = function () {
      var Result = false;
      Result = this.FHorizontalSpacing !== 4;
      return Result;
    };
    this.IsVerticalSpacingStored = function () {
      var Result = false;
      Result = this.FVerticalSpacing !== 4;
      return Result;
    };
    this.Changed = function () {
      this.FOwner.CalculateItems();
    };
    this.FontChanged = function (Sender) {
      this.FOwner.InvalidateItems();
    };
    this.FillChanged = function (Sender) {
      this.FOwner.InvalidateItems();
    };
    this.StrokeChanged = function (Sender) {
      this.FOwner.InvalidateItems();
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(13882323,50));
      this.FFillHover = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFillHover.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(10061943,50));
      this.FFillDown = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFillDown.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(9470064,50));
      this.FFillSelected = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFillSelected.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(9470064,50));
      this.FFillDisabled = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FFillDisabled.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(8421504,50));
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStroke.SetColor(11119017);
      this.FStrokeHover = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStrokeHover.SetColor(10061943);
      this.FStrokeDown = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStrokeDown.SetColor(9470064);
      this.FStrokeSelected = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStrokeSelected.SetColor(5197615);
      this.FStrokeDisabled = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FStrokeDisabled.SetColor(11119017);
      this.FSeparatorStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256,1.0]);
      this.FSeparatorStroke.SetColor(11119017);
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FSeparatorStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FFillDown.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FFillHover.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FFillSelected.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FFillDisabled.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FStrokeHover.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FStrokeDown.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FStrokeDisabled.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FStrokeSelected.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FHorizontalSpacing = 4;
      this.FVerticalSpacing = 4;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomSelectorAppearance.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FFill);
        this.FFillHover.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FFillHover);
        this.FFillSelected.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FFillSelected);
        this.FFillDisabled.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FFillDisabled);
        this.FFillDown.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FFillDown);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FStroke);
        this.FStrokeHover.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FStrokeHover);
        this.FStrokeSelected.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FStrokeSelected);
        this.FStrokeDown.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FStrokeDown);
        this.FStrokeDisabled.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FStrokeDisabled);
        this.FVerticalSpacing = rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FVerticalSpacing;
        this.FHorizontalSpacing = rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FHorizontalSpacing;
        this.FSeparatorStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FSeparatorStroke);
        this.FFont.AssignSource(rtl.as(Source,$mod.TTMSFNCCustomSelectorAppearance).FFont);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FFont");
      rtl.free(this,"FFill");
      rtl.free(this,"FFillDown");
      rtl.free(this,"FFillSelected");
      rtl.free(this,"FFillHover");
      rtl.free(this,"FFillDisabled");
      rtl.free(this,"FSeparatorStroke");
      rtl.free(this,"FStroke");
      rtl.free(this,"FStrokeDown");
      rtl.free(this,"FStrokeSelected");
      rtl.free(this,"FStrokeHover");
      rtl.free(this,"FStrokeDisabled");
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("StrokeHover",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStrokeHover","SetStrokeHover");
    $r.addProperty("FillHover",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFillHover","SetFillHover");
    $r.addProperty("StrokeDown",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStrokeDown","SetStrokeDown");
    $r.addProperty("FillDown",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFillDown","SetFillDown");
    $r.addProperty("StrokeSelected",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStrokeSelected","SetStrokeSelected");
    $r.addProperty("FillSelected",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFillSelected","SetFillSelected");
    $r.addProperty("StrokeDisabled",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStrokeDisabled","SetStrokeDisabled");
    $r.addProperty("FillDisabled",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFillDisabled","SetFillDisabled");
    $r.addProperty("VerticalSpacing",14,rtl.double,"FVerticalSpacing","SetVerticalSpacing",4,{stored: "IsVerticalSpacingStored"});
    $r.addProperty("HorizontalSpacing",14,rtl.double,"FHorizontalSpacing","SetHorizontalSpacing",4,{stored: "IsHorizontalSpacingStored"});
    $r.addProperty("SeparatorStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FSeparatorStroke","SetSeparatorStroke");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
  });
  rtl.recNewT(this,"TTMSFNCCustomSelectorPositionItem",function () {
    this.TileSet = false;
    this.$eq = function (b) {
      return this.TileSet === b.TileSet;
    };
    this.$assign = function (s) {
      this.TileSet = s.TileSet;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCCustomSelectorPositionItem",{},this);
    $r.addField("TileSet",rtl.boolean);
  });
  rtl.recNewT(this,"TTMSFNCCustomSelectorDisplayItem",function () {
    this.Item = null;
    this.PageIndex = 0;
    this.Column = 0;
    this.Row = 0;
    this.ColumnSpan = 0;
    this.RowSpan = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Rect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.Rect.$eq(b.Rect) && (this.Item === b.Item) && (this.PageIndex === b.PageIndex) && (this.Column === b.Column) && (this.Row === b.Row) && (this.ColumnSpan === b.ColumnSpan) && (this.RowSpan === b.RowSpan);
    };
    this.$assign = function (s) {
      this.Rect.$assign(s.Rect);
      this.Item = s.Item;
      this.PageIndex = s.PageIndex;
      this.Column = s.Column;
      this.Row = s.Row;
      this.ColumnSpan = s.ColumnSpan;
      this.RowSpan = s.RowSpan;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCCustomSelectorDisplayItem",{},this);
    $r.addField("Rect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("Item",$mod.$rtti["TTMSFNCCustomSelectorItem"]);
    $r.addField("PageIndex",rtl.longint);
    $r.addField("Column",rtl.longint);
    $r.addField("Row",rtl.longint);
    $r.addField("ColumnSpan",rtl.longint);
    $r.addField("RowSpan",rtl.longint);
  });
  this.$rtti.$DynArray("TTMSFNCCustomSelectorItemPosArray$a",{eltype: this.$rtti["TTMSFNCCustomSelectorPositionItem"]});
  this.$rtti.$DynArray("TTMSFNCCustomSelectorItemPosArray",{eltype: this.$rtti["TTMSFNCCustomSelectorItemPosArray$a"]});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemDeselected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemClick",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemBeforeDrawBackground",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItemIndex",rtl.longint],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemAfterDrawBackground",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemBeforeDrawContent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItemIndex",rtl.longint],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemAfterDrawContent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemBeforeDrawText",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItemIndex",rtl.longint],["AText",rtl.string,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorItemAfterDrawText",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItemIndex",rtl.longint],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorBeforeDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorAfterDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomSelectorDisplayList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = $mod.TTMSFNCCustomSelectorDisplayItem.$new();
      Result.$assign(rtl.getObject(this.Get(Index)));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      var v = $mod.TTMSFNCCustomSelectorDisplayItem.$new();
      v.$assign(Value);
      this.Put(Index,v);
    };
  });
  rtl.createClass(this,"TTMSFNCCustomSelector",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FDisplayList = null;
      this.FUpdateCount$1 = 0;
      this.FItems = null;
      this.FRows = 0;
      this.FColumns = 0;
      this.FPageCount = 0;
      this.FAppearance = null;
      this.FSelectedItemIndex = 0;
      this.FFocusedItemIndex = 0;
      this.FHoveredItemIndex = 0;
      this.FDownItemIndex = 0;
      this.FOnItemBeforeDrawText = null;
      this.FOnAfterDraw$1 = null;
      this.FOnItemAfterDrawBackground = null;
      this.FOnItemSelected = null;
      this.FOnItemAfterDrawText = null;
      this.FOnBeforeDraw$1 = null;
      this.FOnItemBeforeDrawBackground = null;
      this.FOnItemDeselected = null;
      this.FOnItemClick = null;
      this.FOnItemBeforeDrawContent = null;
      this.FOnItemAfterDrawContent = null;
      this.FBlockChange = false;
      this.FClosedRemotely = false;
    };
    this.$final = function () {
      this.FDisplayList = undefined;
      this.FItems = undefined;
      this.FAppearance = undefined;
      this.FOnItemBeforeDrawText = undefined;
      this.FOnAfterDraw$1 = undefined;
      this.FOnItemAfterDrawBackground = undefined;
      this.FOnItemSelected = undefined;
      this.FOnItemAfterDrawText = undefined;
      this.FOnBeforeDraw$1 = undefined;
      this.FOnItemBeforeDrawBackground = undefined;
      this.FOnItemDeselected = undefined;
      this.FOnItemClick = undefined;
      this.FOnItemBeforeDrawContent = undefined;
      this.FOnItemAfterDrawContent = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.SetColumns = function (Value) {
      if (this.FColumns !== Value) {
        this.FColumns = Value;
        this.UpdateCalculations();
        this.CalculateItems();
      };
    };
    this.SetRows = function (Value) {
      if (this.FRows !== Value) {
        this.FRows = Value;
        this.UpdateCalculations();
        this.CalculateItems();
      };
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
    };
    this.SetSelectedItemIndex = function (Value) {
      if (this.FSelectedItemIndex !== Value) {
        this.FSelectedItemIndex = Value;
        this.FFocusedItemIndex = Value;
        this.InvalidateItems();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FAppearance.FVerticalSpacing = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FVerticalSpacing,M,D);
      this.FAppearance.FHorizontalSpacing = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FHorizontalSpacing,M,D);
      this.FAppearance.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FFont.FHeight,M,D));
      this.EndUpdate();
    };
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCCustomSelector);
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/" + pas.SysUtils.LowerCase(this.$classname);
      return Result;
    };
    this.GetHintString = function () {
      var Result = "";
      var it = null;
      Result = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.GetHintString.call(this);
      if ((this.FHoveredItemIndex >= 0) && (this.FHoveredItemIndex <= (this.FItems.GetCount() - 1))) {
        it = this.FItems.GetItem$1(this.FHoveredItemIndex);
        Result = it.FHint;
      };
      return Result;
    };
    this.HasHint = function () {
      var Result = false;
      var it = null;
      Result = false;
      if ((this.FHoveredItemIndex >= 0) && (this.FHoveredItemIndex <= (this.FItems.GetCount() - 1))) {
        it = this.FItems.GetItem$1(this.FHoveredItemIndex);
        Result = it.FHint !== "";
      };
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,1,0);
      return Result;
    };
    this.GetDisplayItem = function (AItemIndex) {
      var Result = $mod.TTMSFNCCustomSelectorDisplayItem.$new();
      var I = 0;
      var it = null;
      Result.Rect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      Result.Item = null;
      Result.PageIndex = -1;
      Result.Row = -1;
      Result.Column = -1;
      Result.ColumnSpan = -1;
      Result.RowSpan = -1;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && (it.GetIndex() === AItemIndex)) {
          Result.$assign(this.FDisplayList.GetItem(I));
          break;
        };
      };
      return Result;
    };
    this.GetNextSelectableItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = this.FFocusedItemIndex;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && it.FEnabled && !it.FSeparator && (it.GetIndex() > this.FFocusedItemIndex)) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.GetPreviousSelectableItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = this.FFocusedItemIndex;
      for (var $l = this.FDisplayList.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && it.FEnabled && !it.FSeparator && (it.GetIndex() < this.FFocusedItemIndex)) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.GetNextSelectableRowItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      var disp = $mod.TTMSFNCCustomSelectorDisplayItem.$new();
      Result = this.FFocusedItemIndex;
      if (Result === -1) {
        Result = this.GetNextSelectableItem();
        return Result;
      };
      disp.$assign(this.GetDisplayItem(this.FFocusedItemIndex));
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && it.FEnabled && !it.FSeparator && (it.GetIndex() > this.FFocusedItemIndex) && (disp.Column >= this.FDisplayList.GetItem(I).Column) && (disp.Column <= (this.FDisplayList.GetItem(I).Column + (this.FDisplayList.GetItem(I).ColumnSpan - 1))) && (this.FDisplayList.GetItem(I).Row > disp.Row)) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.GetPreviousSelectableRowItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      var disp = $mod.TTMSFNCCustomSelectorDisplayItem.$new();
      Result = this.FFocusedItemIndex;
      if (Result === -1) {
        Result = this.GetPreviousSelectableItem();
        return Result;
      };
      disp.$assign(this.GetDisplayItem(this.FFocusedItemIndex));
      for (var $l = this.FDisplayList.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && it.FEnabled && !it.FSeparator && (it.GetIndex() < this.FFocusedItemIndex) && (disp.Column >= this.FDisplayList.GetItem(I).Column) && (disp.Column <= (this.FDisplayList.GetItem(I).Column + (this.FDisplayList.GetItem(I).ColumnSpan - 1))) && (this.FDisplayList.GetItem(I).Row < disp.Row)) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.GetFirstSelectableItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = this.FFocusedItemIndex;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && it.FEnabled && !it.FSeparator) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.GetLastSelectableItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = this.FFocusedItemIndex;
      for (var $l = this.FDisplayList.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        it = this.FDisplayList.GetItem(I).Item;
        if ((it != null) && it.FEnabled && !it.FSeparator) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.CreateItemsCollection = function () {
      var Result = null;
      Result = $mod.TTMSFNCCustomSelectorItems.$create("Create$3",[this]);
      return Result;
    };
    this.CalculateItems = function () {
      var $Self = this;
      var itposarr = [];
      var r = 0;
      var newr = 0;
      var c = 0;
      var newc = 0;
      var AItemIndex = 0;
      var AItem = null;
      var cspan = 0;
      var rspan = 0;
      var newcspan = 0;
      var newrspan = 0;
      var I = 0;
      var K = 0;
      var sepc = 0;
      var f = false;
      var APageIndex = 0;
      var hs = 0.0;
      var vs = 0.0;
      var iw = 0.0;
      var ih = 0.0;
      var w = 0.0;
      var h = 0.0;
      var exw = 0.0;
      var exh = 0.0;
      var tx = 0.0;
      var ty = 0.0;
      var pw = 0.0;
      var ph = 0.0;
      var offs = 0.0;
      var itd = $mod.TTMSFNCCustomSelectorDisplayItem.$new();
      function FindNewPos(AItem, ANewR, ANewC, AFound, ARows, ACurRow, AColumns, ACurCol, PosArr) {
        var i = 0;
        var k = 0;
        var cspan = 0;
        var rspan = 0;
        var J = 0;
        var L = 0;
        AFound.set(false);
        for (var $l = ANewR.get(), $end = ARows - 1; $l <= $end; $l++) {
          i = $l;
          for (var $l1 = ANewC.get(), $end1 = AColumns - 1; $l1 <= $end1; $l1++) {
            k = $l1;
            cspan = AItem.FColumnSpan;
            cspan = Math.min(cspan,$Self.FColumns - ANewC.get());
            rspan = AItem.FRowSpan;
            rspan = Math.min(rspan,$Self.FRows - ANewR.get());
            AFound.set(true);
            for (var $l2 = 0, $end2 = rspan - 1; $l2 <= $end2; $l2++) {
              J = $l2;
              for (var $l3 = 0, $end3 = cspan - 1; $l3 <= $end3; $l3++) {
                L = $l3;
                if (PosArr[i + J][k + L].TileSet) AFound.set(false);
              };
            };
            if (AFound.get()) break;
            ANewC.set(ANewC.get() + 1);
          };
          if (AFound.get()) break;
          ANewC.set(0);
          ANewR.set(ANewR.get() + 1);
        };
      };
      if ((pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) || (this.FUpdateCount$1 > 0)) return;
      this.FDisplayList.Clear();
      if (this.FItems.GetCount() === 0) return;
      pw = this.GetCalculationWidth();
      ph = this.GetCalculationHeight();
      hs = this.FAppearance.FHorizontalSpacing;
      vs = this.FAppearance.FVerticalSpacing;
      w = pw - vs;
      iw = w;
      if (this.FColumns > 0) iw = (w - (this.FColumns * hs)) / this.FColumns;
      h = ph - vs - this.GetTotalSeparatorHeight();
      sepc = this.GetTotalSeparatorCount();
      ih = h;
      if ((this.FRows - sepc) > 0) ih = (h - ((this.FRows - sepc) * vs)) / (this.FRows - sepc);
      AItemIndex = 0;
      APageIndex = 0;
      offs = 0;
      while (AItemIndex <= (this.FItems.GetCount() - 1)) {
        c = 0;
        r = 0;
        itposarr = rtl.arraySetLength(itposarr,$mod.TTMSFNCCustomSelectorPositionItem,0,0);
        itposarr = rtl.arraySetLength(itposarr,$mod.TTMSFNCCustomSelectorPositionItem,this.FRows,this.FColumns);
        while (r < this.FRows) {
          while (c < this.FColumns) {
            if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1)) && (APageIndex === 0)) {
              AItem = this.FItems.GetItem$1(AItemIndex);
              if (!AItem.FVisible) {
                AItemIndex += 1;
                continue;
              };
              if (AItem.FSeparator) {
                cspan = this.FColumns;
                rspan = 1;
              } else {
                cspan = AItem.FColumnSpan;
                rspan = AItem.FRowSpan;
              };
              cspan = Math.min(cspan,this.FColumns - c);
              rspan = Math.min(rspan,this.FRows - r);
              exw = (iw * cspan) + (hs * (cspan - 1));
              if (AItem.FSeparator) {
                exh = AItem.FSeparatorHeight}
               else exh = (ih * rspan) + (vs * (rspan - 1));
              tx = (pw * APageIndex) + hs + (iw * c) + (hs * c);
              ty = offs + vs + (ih * r) + (vs * r) + this.GetTopOffset();
              itd.Rect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(tx + AItem.FMargins.FLeft,ty + AItem.FMargins.FTop,(tx + exw) - AItem.FMargins.FRight,(ty + exh) - AItem.FMargins.FBottom));
              itd.Item = AItem;
              itd.PageIndex = APageIndex;
              itd.Column = c;
              itd.Row = r;
              itd.ColumnSpan = cspan;
              itd.RowSpan = rspan;
              this.FDisplayList.Add($mod.TTMSFNCCustomSelectorDisplayItem.$clone(itd));
              newcspan = c;
              newrspan = r;
              newcspan = (newcspan + cspan) - 1;
              newrspan = (newrspan + rspan) - 1;
              for (var $l = r, $end = newrspan; $l <= $end; $l++) {
                I = $l;
                for (var $l1 = c, $end1 = newcspan; $l1 <= $end1; $l1++) {
                  K = $l1;
                  itposarr[I][K].TileSet = true;
                };
              };
              if (AItem.FSeparator) offs = ((offs + AItem.FSeparatorHeight) - (ih * rspan)) + (vs * (rspan - 1));
            };
            AItemIndex += 1;
            c += 1;
            newc = c;
            newr = r;
            f = false;
            if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) FindNewPos(this.FItems.GetItem$1(AItemIndex),{get: function () {
                return newr;
              }, set: function (v) {
                newr = v;
              }},{get: function () {
                return newc;
              }, set: function (v) {
                newc = v;
              }},{get: function () {
                return f;
              }, set: function (v) {
                f = v;
              }},this.FRows,newr,this.FColumns,newc,rtl.arrayRef(itposarr));
            c = newc;
            r = newr;
            if ((c >= this.FColumns) || (r >= this.FRows)) break;
          };
          c = 0;
          r += 1;
          newc = c;
          newr = r;
          f = false;
          if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) FindNewPos(this.FItems.GetItem$1(AItemIndex),{get: function () {
              return newr;
            }, set: function (v) {
              newr = v;
            }},{get: function () {
              return newc;
            }, set: function (v) {
              newc = v;
            }},{get: function () {
              return f;
            }, set: function (v) {
              f = v;
            }},this.FRows,newr,this.FColumns,newc,rtl.arrayRef(itposarr));
          c = newc;
          r = newr;
          if (r >= this.FRows) break;
        };
        APageIndex += 1;
      };
      this.FPageCount = APageIndex;
      this.InvalidateItems();
    };
    this.UpdateCalculations = function () {
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFill.SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundStrokeColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FStroke.SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleDefaultButtonFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FAppearance.FFill.SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFillSelected.SetColor(c);
        this.FAppearance.FFillDown.SetColor(c);
        this.FAppearance.FFillHover.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(c,this.FAppearance.FFill.FColor,25));
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleDefaultButtonStrokeColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FStroke.SetColor(c);
        this.FAppearance.FStrokeSelected.SetColor(c);
        this.FAppearance.FStrokeDown.SetColor(c);
        this.FAppearance.FStrokeHover.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FAppearance.FFont.SetColor(c);
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      this.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FFill.SetColor(16777215);
      this.FStroke.SetColor(12632256);
      this.FAppearance.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(13882323,50));
      this.FAppearance.FFillHover.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(10061943,50));
      this.FAppearance.FFillDown.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(9470064,50));
      this.FAppearance.FFillSelected.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(9470064,50));
      this.FAppearance.FFillDisabled.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(8421504,50));
      this.FAppearance.FStroke.SetColor(11119017);
      this.FAppearance.FStrokeHover.SetColor(10061943);
      this.FAppearance.FStrokeDown.SetColor(9470064);
      this.FAppearance.FStrokeSelected.SetColor(5197615);
      this.FAppearance.FStrokeDisabled.SetColor(11119017);
      this.FAppearance.FFont.SetColor(0);
      this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFillHover.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFillDown.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFillSelected.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFillDisabled.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStrokeHover.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStrokeDown.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStrokeSelected.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStrokeDisabled.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FSeparatorStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
    };
    this.GetTopOffset = function () {
      var Result = 0.0;
      Result = 0;
      return Result;
    };
    this.GetCalculationWidth = function () {
      var Result = 0.0;
      Result = this.GetWidth();
      return Result;
    };
    this.GetCalculationHeight = function () {
      var Result = 0.0;
      Result = this.GetHeight() - this.GetTopOffset();
      return Result;
    };
    this.GetTotalSeparatorHeight = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItem$1(I).FSeparator) Result = Result + this.FItems.GetItem$1(I).FSeparatorHeight + this.FAppearance.FVerticalSpacing;
      };
      return Result;
    };
    this.GetTotalSeparatorCount = function () {
      var Result = 0;
      var I = 0;
      Result = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItem$1(I).FSeparator) Result += 1;
      };
      return Result;
    };
    this.DoItemSelected = function (AItemIndex) {
      if (this.FOnItemSelected != null) this.FOnItemSelected(this,AItemIndex);
    };
    this.DoItemClick = function (AItemIndex) {
      if (this.FOnItemClick != null) this.FOnItemClick(this,AItemIndex);
    };
    this.DoItemDeselected = function (AItemIndex) {
      if (this.FOnItemDeselected != null) this.FOnItemDeselected(this,AItemIndex);
    };
    this.DoItemBeforeDrawBackground = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnItemBeforeDrawBackground != null) this.FOnItemBeforeDrawBackground(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoItemAfterDrawBackground = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnItemAfterDrawBackground != null) this.FOnItemAfterDrawBackground(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoItemBeforeDrawContent = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnItemBeforeDrawContent != null) this.FOnItemBeforeDrawContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoItemAfterDrawContent = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnItemAfterDrawContent != null) this.FOnItemAfterDrawContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoItemBeforeDrawText = function (AGraphics, ARect, AItemIndex, AText, ADefaultDraw) {
      if (this.FOnItemBeforeDrawText != null) this.FOnItemBeforeDrawText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,AText,ADefaultDraw);
    };
    this.DoItemAfterDrawText = function (AGraphics, ARect, AItemIndex, AText) {
      if (this.FOnItemAfterDrawText != null) this.FOnItemAfterDrawText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,AText);
    };
    this.DoBeforeDraw$1 = function (AGraphics, ARect, ADefaultDraw) {
      if (this.FOnBeforeDraw$1 != null) this.FOnBeforeDraw$1(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADefaultDraw);
    };
    this.DoAfterDraw$1 = function (AGraphics, ARect) {
      if (this.FOnAfterDraw$1 != null) this.FOnAfterDraw$1(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DrawItems = function (AGraphics) {
      var I = 0;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.DrawItem(AGraphics,$mod.TTMSFNCCustomSelectorDisplayItem.$clone(this.FDisplayList.GetItem(I)));
      };
    };
    this.Draw = function (AGraphics, ARect) {
      var a = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      a = true;
      this.DoBeforeDraw$1(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) {
        this.DrawItems(AGraphics);
        this.DoAfterDraw$1(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      };
    };
    this.DrawItem = function (AGraphics, ADisplayItem) {
      this.DrawItemBackGround(AGraphics,$mod.TTMSFNCCustomSelectorDisplayItem.$clone(ADisplayItem));
      this.DrawItemContent(AGraphics,$mod.TTMSFNCCustomSelectorDisplayItem.$clone(ADisplayItem));
      this.DrawItemText(AGraphics,$mod.TTMSFNCCustomSelectorDisplayItem.$clone(ADisplayItem));
    };
    this.DrawItemBackGround = function (AGraphics, ADisplayItem) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var it = null;
      var a = false;
      var fr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      it = ADisplayItem.Item;
      if (it != null) {
        if (!it.FSeparator) {
          AGraphics.FFill.Assign(this.FAppearance.FFill);
          AGraphics.FStroke.Assign(this.FAppearance.FStroke);
          if (it.FEnabled) {
            if (it.GetIndex() === this.FDownItemIndex) {
              AGraphics.FFill.Assign(this.FAppearance.FFillDown);
              AGraphics.FStroke.Assign(this.FAppearance.FStrokeDown);
            } else if (it.GetIndex() === this.FHoveredItemIndex) {
              AGraphics.FFill.Assign(this.FAppearance.FFillHover);
              AGraphics.FStroke.Assign(this.FAppearance.FStrokeHover);
            } else if (it.GetIndex() === this.FSelectedItemIndex) {
              AGraphics.FFill.Assign(this.FAppearance.FFillSelected);
              AGraphics.FStroke.Assign(this.FAppearance.FStrokeSelected);
            };
          } else {
            AGraphics.FFill.Assign(this.FAppearance.FFillDisabled);
            AGraphics.FStroke.Assign(this.FAppearance.FStrokeDisabled);
          };
        } else AGraphics.FStroke.Assign(this.FAppearance.FSeparatorStroke);
        r.$assign(ADisplayItem.Rect);
        a = true;
        this.DoItemBeforeDrawBackground(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex(),{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) {
          if (it.FSeparator) {
            AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,pas["WEBLib.TMSFNCTypes"].CenterPointEx(r).Y)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,pas["WEBLib.TMSFNCTypes"].CenterPointEx(r).Y)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown)}
           else {
            AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
            if (this.IsFocused() && (this.FFocusedItemIndex === it.GetIndex())) {
              fr.$assign(r);
              pas["WEBLib.TMSFNCTypes"].InflateRectEx(fr,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
              AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(fr),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
            };
          };
          this.DoItemAfterDrawBackground(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex());
        };
      };
    };
    this.DrawItemContent = function (AGraphics, ADisplayItem) {
      var it = null;
      var a = false;
      it = ADisplayItem.Item;
      if (it != null) {
        a = true;
        this.DoItemBeforeDrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex(),{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) this.DoItemAfterDrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex());
      };
    };
    this.DrawItemText = function (AGraphics, ADisplayItem) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var it = null;
      var str = "";
      var a = false;
      it = ADisplayItem.Item;
      if ((it != null) && (it.FText !== "")) {
        r.$assign(ADisplayItem.Rect);
        str = it.FText;
        a = true;
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-2,-2);
        AGraphics.FFont.AssignSource(this.FAppearance.FFont);
        this.DoItemBeforeDrawText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex(),{get: function () {
            return str;
          }, set: function (v) {
            str = v;
          }},{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) {
          AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),str,false,it.FHorizontalTextAlign,it.FVerticalTextAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          this.DoItemAfterDrawText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex(),str);
        };
      };
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      this.CaptureEx();
      this.FDownItemIndex = this.XYToItem(X,Y);
      this.InvalidateItems();
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var s = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      this.ReleaseCaptureEx();
      s = this.XYToItem(X,Y);
      if ((s === this.FDownItemIndex) && (this.FDownItemIndex !== -1)) {
        this.ProcessSelection(s);
        if (s !== -1) this.DoItemClick(s);
      };
      this.FDownItemIndex = -1;
      this.FHoveredItemIndex = -1;
      this.InvalidateItems();
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var h = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (this.FDownItemIndex > -1) return;
      h = this.XYToItem(X,Y);
      if (h !== this.FHoveredItemIndex) {
        this.FHoveredItemIndex = h;
        this.CancelHint();
        this.InvalidateItems();
      };
    };
    this.HandleKeyDown = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      var $tmp = Key.get();
      if ($tmp === 38) {
        this.FFocusedItemIndex = this.GetPreviousSelectableRowItem();
        this.InvalidateItems();
      } else if ($tmp === 37) {
        this.FFocusedItemIndex = this.GetPreviousSelectableItem();
        this.InvalidateItems();
      } else if ($tmp === 40) {
        this.FFocusedItemIndex = this.GetNextSelectableRowItem();
        this.InvalidateItems();
      } else if ($tmp === 39) {
        this.FFocusedItemIndex = this.GetNextSelectableItem();
        this.InvalidateItems();
      } else if ($tmp === 36) {
        this.FFocusedItemIndex = this.GetFirstSelectableItem();
        this.InvalidateItems();
      } else if ($tmp === 35) {
        this.FFocusedItemIndex = this.GetLastSelectableItem();
        this.InvalidateItems();
      };
      if (Key.get() === 13) {
        this.FDownItemIndex = this.FFocusedItemIndex;
        this.InvalidateItems();
      };
    };
    this.HandleKeyUp = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyUp.apply(this,arguments);
      if (Key.get() === 13) {
        this.FDownItemIndex = -1;
        this.ProcessSelection(this.FFocusedItemIndex);
        this.InvalidateItems();
      };
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FHoveredItemIndex = -1;
      this.InvalidateItems();
    };
    this.ProcessSelection = function (AItemIndex) {
      var it = null;
      var prev = 0;
      if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) {
        it = this.FItems.GetItem$1(AItemIndex);
        if (it.FCanSelect) {
          prev = this.FSelectedItemIndex;
          if (it.FCanDeselect && (it.GetIndex() === this.FSelectedItemIndex)) {
            this.FSelectedItemIndex = -1}
           else this.FSelectedItemIndex = it.GetIndex();
          if (this.FSelectedItemIndex !== -1) this.FFocusedItemIndex = this.FSelectedItemIndex;
          if (it.FCanDeselect && (prev !== -1)) this.DoItemDeselected(prev);
          if (this.FSelectedItemIndex !== -1) this.DoItemSelected(this.FSelectedItemIndex);
        };
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FColumns = 4;
      this.FRows = 4;
      this.FItems = this.CreateItemsCollection();
      this.FDisplayList = $mod.TTMSFNCCustomSelectorDisplayList.$create("Create$1");
      this.FAppearance = $mod.TTMSFNCCustomSelectorAppearance.$create("Create$1",[this]);
      this.FSelectedItemIndex = -1;
      this.FFocusedItemIndex = -1;
      this.FHoveredItemIndex = -1;
      this.FDownItemIndex = -1;
      if (this.IsDesignTime()) this.InitializeDefault();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      rtl.free(this,"FDisplayList");
      rtl.free(this,"FItems");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomSelector.isPrototypeOf(Source)) {
        this.FItems.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelector).FItems);
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomSelector).FAppearance);
        this.FRows = rtl.as(Source,$mod.TTMSFNCCustomSelector).FRows;
        this.FColumns = rtl.as(Source,$mod.TTMSFNCCustomSelector).FColumns;
      };
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
      this.FUpdateCount$1 += 1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.FUpdateCount$1 -= 1;
      if (this.FUpdateCount$1 === 0) this.CalculateItems();
    };
    this.InvalidateItems = function () {
      this.Invalidate();
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
      this.CalculateItems();
    };
    this.InitializeDefault = function () {
    };
    this.XYToItem = function (X, Y) {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = -1;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.FDisplayList.GetItem(I).Rect,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
          it = this.FDisplayList.GetItem(I).Item;
          if ((it != null) && it.FEnabled && !it.FSeparator) {
            Result = it.GetIndex();
            break;
          };
        };
      };
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCDefaultSelector",this.TTMSFNCCustomSelector,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
  });
  $mod.$init = function () {
    pas.Classes.RegisterClass($mod.TTMSFNCCustomSelector);
  };
},["Math","SysUtils","WEBLib.TMSFNCUtils","WEBLib.TMSFNCStyles"]);
rtl.module("WEBLib.TMSFNCCustomPicker",["System","Classes","WEBLib.TMSFNCCustomSelector","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCPopup","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.StdCtrls","WEBLib.ExtCtrls"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$MethodVar("TTMSFNCCustomPickerBeforeDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomPickerAfterDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomPicker",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FExitTimerClose = false;
      this.FDefaultStyle = false;
      this.FKeyDown = 0;
      this.FContent = "";
      this.FEdit = null;
      this.FTimer = null;
      this.FExitTimer = null;
      this.FControlExitTimer = null;
      this.FDown = false;
      this.FPopup = null;
      this.FSelector = null;
      this.FOnItemBeforeDrawText = null;
      this.FOnAfterDraw$1 = null;
      this.FOnItemAfterDrawBackground = null;
      this.FOnItemSelected = null;
      this.FOnItemAfterDrawText = null;
      this.FOnBeforeDraw$1 = null;
      this.FOnItemBeforeDrawBackground = null;
      this.FDropDownHeight = 0.0;
      this.FDropDownWidth = 0.0;
      this.FOnItemDeselected = null;
      this.FOnItemClick = null;
      this.FOnItemBeforeDrawContent = null;
      this.FOnItemAfterDrawContent = null;
      this.FOnPickerBeforeDraw = null;
      this.FOnPickerAfterDraw = null;
      this.FShowFocus$1 = false;
      this.FOnClosePopup = null;
      this.FOnPopup = null;
      this.FOnEditChange = null;
      this.FOldEnter = null;
      this.FOldExit = null;
      this.FEditable = false;
      this.FUpdateCount$1 = 0;
      this.FFont$1 = null;
      this.FPreventDropDown = false;
    };
    this.$final = function () {
      this.FEdit = undefined;
      this.FTimer = undefined;
      this.FExitTimer = undefined;
      this.FControlExitTimer = undefined;
      this.FPopup = undefined;
      this.FSelector = undefined;
      this.FOnItemBeforeDrawText = undefined;
      this.FOnAfterDraw$1 = undefined;
      this.FOnItemAfterDrawBackground = undefined;
      this.FOnItemSelected = undefined;
      this.FOnItemAfterDrawText = undefined;
      this.FOnBeforeDraw$1 = undefined;
      this.FOnItemBeforeDrawBackground = undefined;
      this.FOnItemDeselected = undefined;
      this.FOnItemClick = undefined;
      this.FOnItemBeforeDrawContent = undefined;
      this.FOnItemAfterDrawContent = undefined;
      this.FOnPickerBeforeDraw = undefined;
      this.FOnPickerAfterDraw = undefined;
      this.FOnClosePopup = undefined;
      this.FOnPopup = undefined;
      this.FOnEditChange = undefined;
      this.FOldEnter = undefined;
      this.FOldExit = undefined;
      this.FFont$1 = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.CalcSize = function () {
    };
    this.GetAppearance = function () {
      var Result = null;
      Result = this.FSelector.FAppearance;
      return Result;
    };
    this.GetColumns = function () {
      var Result = 0;
      Result = this.FSelector.FColumns;
      return Result;
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FSelector.FItems;
      return Result;
    };
    this.GetRows = function () {
      var Result = 0;
      Result = this.FSelector.FRows;
      return Result;
    };
    this.GetSelectedItemIndex = function () {
      var Result = 0;
      Result = this.FSelector.FSelectedItemIndex;
      return Result;
    };
    this.SetAppearance = function (Value) {
      this.FSelector.FAppearance.Assign(Value);
    };
    this.SetColumns = function (Value) {
      this.FSelector.SetColumns(Value);
    };
    this.SetItems = function (Value) {
      this.FSelector.FItems.Assign(Value);
    };
    this.SetRows = function (Value) {
      this.FSelector.SetRows(Value);
    };
    this.SetSelectedItemIndex = function (Value) {
      this.FSelector.SetSelectedItemIndex(Value);
    };
    this.GetFill = function () {
      var Result = null;
      Result = this.FSelector.FFill;
      return Result;
    };
    this.GetStroke = function () {
      var Result = null;
      Result = this.FSelector.FStroke;
      return Result;
    };
    this.SetFill$1 = function (Value) {
      this.FSelector.FFill.Assign(Value);
    };
    this.SetStroke$1 = function (Value) {
      this.FSelector.FStroke.Assign(Value);
    };
    this.SetDropDownHeight = function (Value) {
      this.FDropDownHeight = Value;
      if (this.FPopup != null) this.FPopup.SetDropDownHeight(this.FDropDownHeight);
    };
    this.SetDropDownWidth = function (Value) {
      this.FDropDownWidth = Value;
      if (this.FPopup != null) this.FPopup.SetDropDownWidth(this.FDropDownWidth);
    };
    this.IsDropDownHeightStored = function () {
      var Result = false;
      Result = this.FDropDownHeight !== 135;
      return Result;
    };
    this.IsDropDownWidthStored = function () {
      var Result = false;
      Result = this.FDropDownWidth !== 135;
      return Result;
    };
    this.GetPopup = function () {
      var Result = null;
      Result = this.FPopup;
      return Result;
    };
    this.GetSelector = function () {
      var Result = null;
      Result = this.FSelector;
      return Result;
    };
    this.SetShowFocus$1 = function (Value) {
      if (this.FShowFocus$1 !== Value) {
        this.FShowFocus$1 = Value;
        this.Invalidate();
      };
    };
    this.SetContent = function (Value) {
      this.FContent = Value;
      this.UpdateEditText(Value);
    };
    this.SetDefaultStyle = function (Value) {
      if (this.FDefaultStyle !== Value) {
        this.FDefaultStyle = Value;
        this.Invalidate();
      };
    };
    this.SetFnt = function (Value) {
      this.FFont$1.Assign(Value);
    };
    this.DisableEnterEvent = function () {
      if (this.FOnEnter != null) this.FOldEnter = this.FOnEnter;
      this.FOnEnter = null;
    };
    this.DisableExitEvent = function () {
      if (this.FOnExit != null) this.FOldExit = this.FOnExit;
      this.FOnExit = null;
    };
    this.EnableExitEvent = function () {
      this.FOnExit = this.FOldExit;
    };
    this.EnableEnterEvent = function () {
      this.FOnEnter = this.FOldEnter;
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FFont$1.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FFont$1.FHeight,M,D));
      this.FEdit.FMargins.SetRight(this.ScalePaintValue(17));
      this.SetDropDownHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDropDownHeight,M,D));
      this.SetDropDownWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDropDownWidth,M,D));
      this.EndUpdate();
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,9);
      return Result;
    };
    this.GetContent = function () {
      var Result = "";
      if ((this.FEdit != null) && (this.FEdit.FParent != null) && this.FEditable) {
        Result = this.FEdit.GetText()}
       else Result = this.FContent;
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/" + pas.SysUtils.LowerCase(this.$classname);
      return Result;
    };
    this.SetEditable = function (Value) {
      if (this.FEditable !== Value) {
        this.FEditable = Value;
        if (this.FEdit != null) {
          if (this.FEditable) {
            this.FEdit.SetParent(this);
          } else this.FEdit.SetParent(null);
          this.FEdit.SetVisible(this.FEditable);
          this.UpdateEditText(this.GetContent());
          this.FPopup.FStaysOpen = this.FEditable;
        };
        this.Invalidate();
      };
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.GetFill().SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.GetStroke().SetColor(c);
      this.Invalidate();
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      if (this.FPopup != null) this.FPopup.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.DoExit = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.DoExit.call(this);
      this.FControlExitTimer.SetEnabled(true);
      this.Invalidate();
    };
    this.DoEnter = function () {
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      this.DisableEnterEvent();
      this.FTimer.SetEnabled(true);
      this.Invalidate();
    };
    this.DoEditExit = function (Sender) {
      this.FExitTimer.SetEnabled(true);
    };
    this.DoEditEnter = function (Sender) {
      if (!this.FPopup.FIsOpen) this.DoEnter();
    };
    this.UpdateEditText = function (AText) {
      if ((this.FEdit != null) && (this.FEdit.FParent != null) && this.FEditable) this.FEdit.SetText(AText);
    };
    this.DoItemSelected = function (Sender, AItemIndex) {
      this.UpdateEditText("");
      if (this.FOnItemSelected != null) this.FOnItemSelected(this,AItemIndex);
    };
    this.DoItemDeselected = function (Sender, AItemIndex) {
      if (this.FOnItemDeselected != null) this.FOnItemDeselected(this,AItemIndex);
    };
    this.DoItemClick = function (Sender, AItemIndex) {
      if (this.FOnItemClick != null) this.FOnItemClick(this,AItemIndex);
    };
    this.DoItemBeforeDrawBackground = function (Sender, AGraphics, ARect, AItemIndex, AAllowDraw) {
      if (this.FOnItemBeforeDrawBackground != null) this.FOnItemBeforeDrawBackground(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,AAllowDraw);
    };
    this.DoItemAfterDrawBackground = function (Sender, AGraphics, ARect, AItemIndex) {
      if (this.FOnItemAfterDrawBackground != null) this.FOnItemAfterDrawBackground(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoItemBeforeDrawContent = function (Sender, AGraphics, ARect, AItemIndex, AAllowDraw) {
      if (this.FOnItemBeforeDrawContent != null) this.FOnItemBeforeDrawContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,AAllowDraw);
    };
    this.DoItemAfterDrawContent = function (Sender, AGraphics, ARect, AItemIndex) {
      if (this.FOnItemAfterDrawContent != null) this.FOnItemAfterDrawContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoItemBeforeDrawText = function (Sender, AGraphics, ARect, AItemIndex, AText, AAllowDraw) {
      if (this.FOnItemBeforeDrawText != null) this.FOnItemBeforeDrawText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,AText,AAllowDraw);
    };
    this.DoItemAfterDrawText = function (Sender, AGraphics, ARect, AItemIndex, AText) {
      if (this.FOnItemAfterDrawText != null) this.FOnItemAfterDrawText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,AText);
    };
    this.DoBeforeDraw$1 = function (Sender, AGraphics, ARect, AAllowDraw) {
      if (this.FOnBeforeDraw$1 != null) this.FOnBeforeDraw$1(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AAllowDraw);
    };
    this.DoAfterDraw$1 = function (Sender, AGraphics, ARect) {
      if (this.FOnAfterDraw$1 != null) this.FOnAfterDraw$1(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DoPickerBeforeDraw = function (AGraphics, ARect, ADefaultDraw) {
      if (this.FOnPickerBeforeDraw != null) this.FOnPickerBeforeDraw(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADefaultDraw);
    };
    this.DoPickerAfterDraw = function (AGraphics, ARect) {
      if (this.FOnPickerAfterDraw != null) this.FOnPickerAfterDraw(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.Draw = function (AGraphics, ARect) {
      var a = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rf = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      a = true;
      this.DoPickerBeforeDraw(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) {
        this.DrawBackground(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
        r.$assign(ARect);
        r.Right = r.Right - this.ScalePaintValue(15);
        this.DrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        if (this.FShowFocus$1 && this.IsFocused()) {
          rf.$assign(ARect);
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(rf,-1,-1);
          AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rf),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        };
        this.DoPickerAfterDraw(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      };
    };
    this.SelectFirstValue = function () {
    };
    this.SelectLastValue = function () {
    };
    this.SelectNextValue = function () {
    };
    this.SelectPreviousValue = function () {
    };
    this.EditUp = function () {
    };
    this.EditDown = function () {
    };
    this.DoPopup = function (Sender) {
      if (this.FEditable && this.FExitTimer.FEnabled) this.FPreventDropDown = true;
      this.InitializePopup();
      if (this.FSelector != null) this.FSelector.CalculateItems();
      if (this.FOnPopup != null) this.FOnPopup(this);
    };
    this.DoClosePopup = function (Sender) {
      if (this.FOnClosePopup != null) this.FOnClosePopup(this);
    };
    this.EnterTimerChanged = function (Sender) {
      if (this.FEditable && !this.FExitTimerClose) {
        this.DisableExitEvent();
        this.FEdit.SetFocus();
        this.EnableExitEvent();
      };
      this.FExitTimerClose = false;
      this.FTimer.SetEnabled(false);
    };
    this.ExitTimerChanged = function (Sender) {
      var f = false;
      this.FExitTimer.SetEnabled(false);
      this.FExitTimerClose = true;
      f = true;
      if (this.FPopup.FFocusedControl != null) {
        if (pas["WEBLib.Controls"].TCustomControl.isPrototypeOf(this.FPopup.FFocusedControl)) f = !rtl.as(this.FPopup.FFocusedControl,pas["WEBLib.Controls"].TCustomControl).Focused();
      } else if (this.FPopup.FContentControl != null) {
        if (pas["WEBLib.Controls"].TCustomControl.isPrototypeOf(this.FPopup.FContentControl)) f = !rtl.as(this.FPopup.FContentControl,pas["WEBLib.Controls"].TCustomControl).Focused();
      };
      if (this.FPopup.FIsOpen && !this.FDown && f && !this.FPreventDropDown) {
        this.DropDown();
        this.DoExit();
        if (this.CanFocus() && (this.FOnExit != null)) this.FOnExit(this);
      } else if (!this.FPopup.FIsOpen && !this.FDown) {
        this.DoExit();
      };
      this.FPreventDropDown = false;
    };
    this.ControlExitTimerChanged = function (Sender) {
      this.FControlExitTimer.SetEnabled(false);
      if (!this.FEdit.IsFocused()) this.EnableEnterEvent();
    };
    this.EditChange = function (Sender) {
      this.SetContent(this.FEdit.GetText());
      this.DoEditChange();
      if (this.FOnEditChange != null) this.FOnEditChange(this);
    };
    this.DoEditChange = function () {
    };
    this.HandleDialogKey = function (Key, Shift) {
      if (rtl.neSet(Shift,{})) return;
      if (this.FEditable && this.FEdit.IsFocused()) {
        var $tmp = Key.get();
        if ($tmp === 115) {
          if (!(pas.Classes.TShiftState$a.ssAlt in Shift)) this.DropDown();
        };
      };
    };
    this.InitializePopup = function () {
      if (this.FPopup != null) {
        this.FPopup.SetAdaptToStyle(this.GetAdaptToStyle());
        if (!this.FDefaultStyle) {
          this.FPopup.FFillColor = this.GetFill().FColor;
          this.FPopup.FStrokeColor = this.GetStroke().FColor;
        } else {
          this.FPopup.FFillColor = -1;
          this.FPopup.FStrokeColor = -1;
        };
      };
      if (this.FSelector != null) this.FSelector.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.FntChanged = function (Sender) {
      this.Invalidate();
    };
    this.CreateSelector = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.$create("Create$1",[this]);
      return Result;
    };
    this.GetFocusedControl = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.AssignEvents = function () {
      if (this.FSelector != null) {
        this.FSelector.FOnItemSelected = rtl.createCallback(this,"DoItemSelected");
        this.FSelector.FOnItemDeselected = rtl.createCallback(this,"DoItemDeselected");
        this.FSelector.FOnItemClick = rtl.createCallback(this,"DoItemClick");
        this.FSelector.FOnItemBeforeDrawBackground = rtl.createCallback(this,"DoItemBeforeDrawBackground");
        this.FSelector.FOnItemAfterDrawBackground = rtl.createCallback(this,"DoItemAfterDrawBackground");
        this.FSelector.FOnItemBeforeDrawContent = rtl.createCallback(this,"DoItemBeforeDrawContent");
        this.FSelector.FOnItemAfterDrawContent = rtl.createCallback(this,"DoItemAfterDrawContent");
        this.FSelector.FOnItemBeforeDrawText = rtl.createCallback(this,"DoItemBeforeDrawText");
        this.FSelector.FOnItemAfterDrawText = rtl.createCallback(this,"DoItemAfterDrawText");
        this.FSelector.FOnBeforeDraw$1 = rtl.createCallback(this,"DoBeforeDraw$1");
        this.FSelector.FOnAfterDraw$1 = rtl.createCallback(this,"DoAfterDraw$1");
      };
    };
    this.SetGraphicColors = function () {
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupFillColor = this.GetFill().FColor;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultPopupStrokeColor = this.GetStroke().FColor;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColor = this.GetFill().FColor;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColor = this.GetStroke().FColor;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultTextFontColor = this.FFont$1.FColor;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor = 11119017;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(this.GetFill().FColor,20);
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorFocused = pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(this.GetStroke().FColor,20);
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonStrokeColorDisabled = 11119017;
      pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultButtonFillColorDisabled = 13882323;
    };
    this.DrawContent = function (AGraphics, ARect) {
      AGraphics.FFont.Assign(this.FFont$1);
      if (!this.FEnabled) AGraphics.FFont.SetColor(12632256);
    };
    this.DrawBackground = function (AGraphics, ARect) {
      if (!this.FDefaultStyle) {
        this.SetGraphicColors();
      };
      AGraphics.DrawDropDownButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.FDown,this.IsFocused(),true,false,this.GetAdaptToStyle() || !this.FDefaultStyle,this.FPaintScaleFactor);
      if (!this.FDefaultStyle) AGraphics.$class.SetDefaultGraphicColors();
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if (this.CanFocus()) this.SetFocus();
      if (Button === pas["WEBLib.Controls"].TMouseButton.mbLeft) {
        this.FDown = true;
        this.Invalidate();
        this.DropDown();
        if (this.FEditable) {
          this.DisableExitEvent();
          this.FEdit.SetFocus();
          this.EnableExitEvent();
        };
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      this.FDown = false;
      this.Invalidate();
    };
    this.HandleKeyDown = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      if (pas.Classes.TShiftState$a.ssAlt in Shift) {
        var $tmp = Key.get();
        if (($tmp === 38) || ($tmp === 40)) {
          this.DropDown();
          return;
        };
      };
      var $tmp1 = Key.get();
      if ($tmp1 === 36) {
        this.SelectFirstValue()}
       else if ($tmp1 === 35) {
        this.SelectLastValue()}
       else if (($tmp1 === 38) || ($tmp1 === 37)) {
        this.SelectPreviousValue()}
       else if (($tmp1 === 40) || ($tmp1 === 39)) this.SelectNextValue();
      if (rtl.neSet(Shift,{})) return;
      var $tmp2 = Key.get();
      if (($tmp2 === 32) || ($tmp2 === 13) || ($tmp2 === 115)) this.DropDown();
    };
    this.EditKeyDown = function (Sender, Key, Shift) {
      if (this.FOnKeyDown != null) this.FOnKeyDown(Sender,Key,rtl.refSet(Shift));
      this.FKeyDown = Key.get();
    };
    this.EditKeyUp = function (Sender, Key, Shift) {
      if (this.FOnKeyUp != null) this.FOnKeyUp(Sender,Key,rtl.refSet(Shift));
    };
    this.EditKeyPress = function (Sender, Key) {
      var $Self = this;
      function EatKey() {
        Key.set("\x00");
      };
      if (this.FKeyDown in rtl.createSet(38,40)) {
        if (this.FKeyDown === 38) this.EditUp();
        if (this.FKeyDown === 40) this.EditDown();
        EatKey();
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FExitTimerClose = false;
      this.FPreventDropDown = false;
      this.FFont$1 = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont$1.FOnChanged = rtl.createCallback(this,"FntChanged");
      this.FDefaultStyle = true;
      this.FTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FTimer.SetInterval(1);
      this.FTimer.FOnTimer = rtl.createCallback(this,"EnterTimerChanged");
      this.FTimer.SetEnabled(false);
      this.FExitTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FExitTimer.SetInterval(1);
      this.FExitTimer.FOnTimer = rtl.createCallback(this,"ExitTimerChanged");
      this.FExitTimer.SetEnabled(false);
      this.FControlExitTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FControlExitTimer.SetInterval(1);
      this.FControlExitTimer.FOnTimer = rtl.createCallback(this,"ControlExitTimerChanged");
      this.FControlExitTimer.SetEnabled(false);
      this.FEdit = $impl.TTMSFNCCustomPickerEdit.$create("Create$1",[this]);
      this.FEdit.SetTabOrder(0);
      this.FEdit.SetTabStop(true);
      this.FEdit.FOnKeyDown = rtl.createCallback(this,"EditKeyDown");
      this.FEdit.FOnKeyUp = rtl.createCallback(this,"EditKeyUp");
      this.FEdit.FOnExit = rtl.createCallback(this,"DoEditExit");
      this.FEdit.FOnEnter = rtl.createCallback(this,"DoEditEnter");
      this.FEdit.SetAlignWithMargins(true);
      this.FEdit.FMargins.SetLeft(0);
      this.FEdit.FMargins.SetTop(0);
      this.FEdit.FMargins.SetRight(17);
      this.FEdit.FMargins.SetBottom(0);
      this.FEdit.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FEdit.FOnChange = rtl.createCallback(this,"EditChange");
      this.FEdit.FOnKeyPress = rtl.createCallback(this,"EditKeyPress");
      this.FDropDownWidth = 135;
      this.FDropDownHeight = 135;
      this.FShowFocus$1 = true;
      this.FSelector = this.CreateSelector();
      this.AssignEvents();
      this.FPopup = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FPopup.SetDragWithParent(true);
      this.FPopup.FFocusedControl = this.GetFocusedControl();
      this.FPopup.SetContentControl(this.FSelector);
      this.FPopup.SetDropDownWidth(this.FDropDownWidth);
      this.FPopup.SetDropDownHeight(this.FDropDownHeight);
      this.FPopup.FOnPopup = rtl.createCallback(this,"DoPopup");
      this.FPopup.FOnClosePopup = rtl.createCallback(this,"DoClosePopup");
      this.SetWidth(60);
      this.SetHeight(22);
      return this;
    };
    this.Destroy = function () {
      if (this.FFont$1 != null) pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFont$1;
        }, set: function (v) {
          this.p.FFont$1 = v;
        }});
      if (this.FSelector != null) pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FSelector;
        }, set: function (v) {
          this.p.FSelector = v;
        }});
      if (this.FPopup != null) pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FPopup;
        }, set: function (v) {
          this.p.FPopup = v;
        }});
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.DropDown = function () {
      this.DisableExitEvent();
      this.FPopup.SetPlacementControl(this);
      if (!this.FPopup.FIsOpen) {
        this.CalcSize();
        this.FPopup.SetIsOpen(true);
      } else this.FPopup.SetIsOpen(false);
      this.EnableExitEvent();
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
      this.FUpdateCount$1 += 1;
      if (this.FSelector != null) this.FSelector.BeginUpdate();
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      this.FUpdateCount$1 -= 1;
      if (this.FSelector != null) this.FSelector.EndUpdate();
    };
    this.LoadSettingsFromFile = function (AFileName) {
      this.FDefaultStyle = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromFile.apply(this,arguments);
      this.Invalidate();
    };
    this.LoadSettingsFromStream = function (AStream) {
      this.FDefaultStyle = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromStream.apply(this,arguments);
      this.Invalidate();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCDefaultPicker",this.TTMSFNCCustomPicker,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DefaultStyle",2,rtl.boolean,"FDefaultStyle","SetDefaultStyle",4,{Default: true});
    $r.addProperty("Fill",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"GetFill","SetFill$1");
    $r.addProperty("Stroke",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"GetStroke","SetStroke$1");
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont$1","SetFnt");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("OnPopup",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPopup","FOnPopup");
    $r.addProperty("OnClosePopup",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClosePopup","FOnClosePopup");
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTMSFNCOpenCustomSelector",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    rtl.createClass($impl,"TTMSFNCCustomPickerEdit",pas["WEBLib.StdCtrls"].TEdit,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
},["SysUtils","WEBLib.TMSFNCUtils","WEBLib.TMSFNCStyles"]);
rtl.module("WEBLib.TMSFNCControlPicker",["System","Classes","Types","WEBLib.Controls","WEBLib.TMSFNCCustomPicker","WEBLib.TMSFNCCustomSelector","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 1;
  this.BLD_VER = 2;
  rtl.createInterface(this,"ITMSFNCControlPickerBase","{FF82E121-0510-4FF1-8BB8-A40AA5219095}",["PickerGetContent"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("PickerGetContent",1,[],2,rtl.string);
  });
  rtl.createInterface(this,"ITMSFNCControlPickerItems","{D0FBAC5E-B2AA-46AE-AD21-91DF23AD4FCB}",["PickerSelectItem","PickerGetSelectedItem","PickerGetVisibleItemCount","PickerGetItemCount","PickerGetItemHeight","PickerSetItemHeight","PickerGetItemWidth","PickerSetItemWidth","PickerGetNextSelectableItem","PickerGetPreviousSelectableItem","PickerGetFirstSelectableItem","PickerGetLastSelectableItem"],this.ITMSFNCControlPickerBase,function () {
    var $r = this.$rtti;
    $r.addMethod("PickerSelectItem",0,[["AItemIndex",rtl.longint]]);
    $r.addMethod("PickerGetSelectedItem",1,[],2,rtl.longint);
    $r.addMethod("PickerGetVisibleItemCount",1,[],2,rtl.longint);
    $r.addMethod("PickerGetItemCount",1,[],2,rtl.longint);
    $r.addMethod("PickerGetItemHeight",1,[],2,rtl.double);
    $r.addMethod("PickerSetItemHeight",0,[["AValue",rtl.double]]);
    $r.addMethod("PickerGetItemWidth",1,[],2,rtl.double);
    $r.addMethod("PickerSetItemWidth",0,[["AValue",rtl.double]]);
    $r.addMethod("PickerGetNextSelectableItem",1,[["AItemIndex",rtl.longint]],2,rtl.longint);
    $r.addMethod("PickerGetPreviousSelectableItem",1,[["AItemIndex",rtl.longint]],2,rtl.longint);
    $r.addMethod("PickerGetFirstSelectableItem",1,[],2,rtl.longint);
    $r.addMethod("PickerGetLastSelectableItem",1,[],2,rtl.longint);
  });
  rtl.recNewT(this,"TTMSFNCControlPickerFilterItem",function () {
    this.ItemIndex = 0;
    this.ItemText = "";
    this.$eq = function (b) {
      return (this.ItemIndex === b.ItemIndex) && (this.ItemText === b.ItemText);
    };
    this.$assign = function (s) {
      this.ItemIndex = s.ItemIndex;
      this.ItemText = s.ItemText;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCControlPickerFilterItem",{},this);
    $r.addField("ItemIndex",rtl.longint);
    $r.addField("ItemText",rtl.string);
  });
  rtl.createInterface(this,"ITMSFNCControlPickerFull","{3AF9E5D7-2049-4809-920F-BA318E3D8E8D}",["PickerResetFilter","PickerApplyFilter","PickerLookupItem"],this.ITMSFNCControlPickerItems,function () {
    var $r = this.$rtti;
    $r.addMethod("PickerResetFilter",0,[]);
    $r.addMethod("PickerApplyFilter",0,[["ACondition",rtl.string],["ACaseSensitive",rtl.boolean]]);
    $r.addMethod("PickerLookupItem",1,[["ALookupString",rtl.string],["ACaseSensitive",rtl.boolean]],2,$mod.$rtti["TTMSFNCControlPickerFilterItem"]);
  });
  this.TTMSFNCControlPickerStyle = {"0": "csDropDown", csDropDown: 0, "1": "csDropDownList", csDropDownList: 1};
  this.$rtti.$Enum("TTMSFNCControlPickerStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCControlPickerStyle});
  this.TTMSFNCControlPickerDropDownHeightMode = {"0": "chmDropDownHeight", chmDropDownHeight: 0, "1": "chmControl", chmControl: 1, "2": "chmItems", chmItems: 2, "3": "chmPickerHeight", chmPickerHeight: 3};
  this.$rtti.$Enum("TTMSFNCControlPickerDropDownHeightMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCControlPickerDropDownHeightMode});
  this.TTMSFNCControlPickerDropDownWidthMode = {"0": "cwmDropDownWidth", cwmDropDownWidth: 0, "1": "cwmControl", cwmControl: 1, "2": "cwmItems", cwmItems: 2, "3": "cwmPickerWidth", cwmPickerWidth: 3};
  this.$rtti.$Enum("TTMSFNCControlPickerDropDownWidthMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCControlPickerDropDownWidthMode});
  this.$rtti.$MethodVar("TTMSFNCCustomControlPickerItemSelectedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AText",rtl.string],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlPickerOnAdjustDropDownSizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASize",rtl.double,1],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlPickerOnSetContentEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AText",rtl.string,1],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlPickerBeforeDrawContentEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AContent",rtl.string],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomControlPickerAfterDrawContentEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AContent",rtl.string]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomControlPicker",pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCDefaultPicker,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCDefaultPicker.$init.call(this);
      this.FAutoCloseUp = false;
      this.FAutoComplete = false;
      this.FAutoCompleteDelay = 0;
      this.FAutoCompleteNumChar = 0;
      this.FAutoDropDown = false;
      this.FCaseSensitive = false;
      this.FControl = null;
      this.FControlParent = null;
      this.FControlVisible = false;
      this.FControlAlign = 0;
      this.FControlLeft = 0.0;
      this.FControlTop = 0.0;
      this.FControlWidth = 0.0;
      this.FControlHeight = 0.0;
      this.FDropDownHeightMode = 0;
      this.FKeyDown$1 = 0;
      this.FFont$2 = null;
      this.FPrevString = "";
      this.FStyle = 0;
      this.FTick = 0;
      this.FWrapper = null;
      this.FOnAdjustDropDownHeight = null;
      this.FOnAfterDrawPickerContent = null;
      this.FOnBeforeDrawPickerContent = null;
      this.FOnItemSelected$1 = null;
      this.FOnSetContent = null;
      this.FDropDownWidthMode = 0;
      this.FOnAdjustDropDownWidth = null;
      this.FDropDownControlWidth = 0.0;
      this.FDropDownControlHeight = 0.0;
    };
    this.$final = function () {
      this.FControl = undefined;
      this.FControlParent = undefined;
      this.FFont$2 = undefined;
      this.FWrapper = undefined;
      this.FOnAdjustDropDownHeight = undefined;
      this.FOnAfterDrawPickerContent = undefined;
      this.FOnBeforeDrawPickerContent = undefined;
      this.FOnItemSelected$1 = undefined;
      this.FOnSetContent = undefined;
      this.FOnAdjustDropDownWidth = undefined;
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCDefaultPicker.$final.call(this);
    };
    this.SetAutoCloseUp = function (Value) {
      this.FAutoCloseUp = Value;
    };
    this.SetAutoComplete = function (Value) {
      this.FAutoComplete = Value;
    };
    this.SetAutoCompleteDelay = function (Value) {
      this.FAutoCompleteDelay = Value;
    };
    this.SetAutoCompleteNumChar = function (Value) {
      if (Value > 0) {
        this.FAutoCompleteNumChar = Value}
       else this.FAutoCompleteNumChar = 1;
    };
    this.SetAutoDropDown = function (Value) {
      this.FAutoDropDown = Value;
    };
    this.SetControl = function (Value) {
      if (Value === this) return;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.FControl = Value;
      } else {
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FControl != null)) {
          this.FControl.SetParent(this.FControlParent);
          this.FControl.SetVisible(this.FControlVisible);
          this.FControl.SetAlign(this.FControlAlign);
          this.FControl.SetLeft(Math.round(this.FControlLeft));
          this.FControl.SetTop(Math.round(this.FControlTop));
          this.FControl.SetWidth(Math.round(this.FControlWidth));
          this.FControl.SetHeight(Math.round(this.FControlHeight));
        };
        this.FControl = Value;
        if (this.FControl != null) {
          this.FControlParent = this.FControl.FParent;
          this.FControlVisible = this.FControl.FVisible;
          this.FControlAlign = this.FControl.FAlign;
          this.FControl.SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
          this.FControlLeft = this.FControl.GetLeft();
          this.FControlTop = this.FControl.GetTop();
          this.FControlWidth = this.FControl.GetWidth();
          this.FControlHeight = this.FControl.GetHeight();
          this.FControl.SetParent(this.FWrapper);
          this.FControl.SetVisible(true);
          this.FControl.SetLeft(0);
          this.FControl.SetTop(0);
        } else {
          this.FControlParent = null;
          this.FControlVisible = false;
          this.FControlAlign = pas["WEBLib.Controls"].TAlign.alNone;
          this.FControlLeft = 0;
          this.FControlTop = 0;
          this.FControlWidth = 0;
          this.FControlHeight = 0;
        };
        this.UpdatePickerContent();
        this.AdjustDropDownHeight();
        this.AdjustDropDownWidth();
      };
      this.Invalidate();
    };
    this.SetDropDownHeightMode = function (Value) {
      if (Value !== this.FDropDownHeightMode) {
        this.FDropDownHeightMode = Value;
        this.AdjustDropDownHeight();
      };
    };
    this.SetFnt$1 = function (Value) {
      this.FFont$2.AssignSource(Value);
    };
    this.SetItemHeight = function (Value) {
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        if (this.FControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            pi.PickerSetItemHeight(Value)}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) pf.PickerSetItemHeight(Value);
        };
        this.AdjustDropDownHeight();
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SetItemIndex = function (Value) {
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        if ((this.FControl != null) && (Value >= 0) && (Value < this.GetCount())) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            pi.PickerSelectItem(Value)}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) pf.PickerSelectItem(Value);
          this.UpdatePickerContent();
          this.DoPickerItemSelected(this.GetContent(),Value);
          this.Invalidate();
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        var $tmp = this.FStyle;
        if ($tmp === $mod.TTMSFNCControlPickerStyle.csDropDown) {
          this.SetEditable(true);
          this.GetPopup().FFocusedControl = this.FEdit;
          this.GetPopup().FStaysOpen = true;
        } else if ($tmp === $mod.TTMSFNCControlPickerStyle.csDropDownList) {
          this.SetEditable(false);
          if (this.FControl != null) this.GetPopup().FFocusedControl = this.FControl;
          this.GetPopup().FStaysOpen = false;
        };
      };
    };
    this.SetText = function (Value) {
      this.SetContent(Value);
    };
    this.SetCaseSensitive = function (Value) {
      this.FCaseSensitive = Value;
    };
    this.GetItemIndex = function () {
      var Result = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        Result = -1;
        if ((this.FControl != null) && pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
            return pi;
          }, set: function (v) {
            pi = v;
          }})) {
          Result = pi.PickerGetSelectedItem()}
         else if ((this.FControl != null) && pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
            return pf;
          }, set: function (v) {
            pf = v;
          }})) Result = pf.PickerGetSelectedItem();
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
      return Result;
    };
    this.GetItemHeight = function () {
      var Result = 0.0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        Result = 0.0;
        if (this.FControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            Result = pi.PickerGetItemHeight()}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) {
            Result = pf.PickerGetItemHeight()}
           else Result = this.FControlHeight;
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
      return Result;
    };
    this.GetText = function () {
      var Result = "";
      Result = this.GetContent();
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        Result = 0;
        if (this.FControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            Result = pi.PickerGetItemCount()}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) {
            Result = pf.PickerGetItemCount()}
           else Result = 1;
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
      return Result;
    };
    this.ApplyFilter = function (ACondition) {
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        if ((this.FControl != null) && pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
            return pf;
          }, set: function (v) {
            pf = v;
          }})) pf.PickerApplyFilter(ACondition,this.FCaseSensitive);
      } finally {
        $ir.free();
        rtl._Release(pf);
      };
    };
    this.ClearFilter = function () {
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        if ((this.FControl != null) && pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
            return pf;
          }, set: function (v) {
            pf = v;
          }})) pf.PickerResetFilter();
      } finally {
        $ir.free();
        rtl._Release(pf);
      };
    };
    this.LookupItem = function (ALookupString) {
      var Result = $mod.TTMSFNCControlPickerFilterItem.$new();
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        Result.ItemIndex = -1;
        Result.ItemText = "";
        if ((this.FControl != null) && pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
            return pf;
          }, set: function (v) {
            pf = v;
          }})) Result.$assign(pf.PickerLookupItem(ALookupString,this.FCaseSensitive));
      } finally {
        $ir.free();
        rtl._Release(pf);
      };
      return Result;
    };
    this.SetDropDownWidthMode = function (Value) {
      if (Value !== this.FDropDownWidthMode) {
        this.FDropDownWidthMode = Value;
        this.AdjustDropDownWidth();
      };
    };
    this.GetItemWidth = function () {
      var Result = 0.0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        Result = 0.0;
        if (this.FControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            Result = pi.PickerGetItemWidth()}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) {
            Result = pf.PickerGetItemWidth()}
           else Result = this.FControlWidth;
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
      return Result;
    };
    this.SetItemWidth = function (Value) {
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        if (this.FControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            pi.PickerSetItemWidth(Value)}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) pf.PickerSetItemWidth(Value);
        };
        this.AdjustDropDownWidth();
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SetDropDownControlHeight = function (Value) {
      if (this.FDropDownControlHeight !== Value) {
        this.FDropDownControlHeight = Value;
        this.AdjustDropDownHeight();
      };
    };
    this.SetDropDownControlWidth = function (Value) {
      if (this.FDropDownControlWidth !== Value) {
        this.FDropDownControlWidth = Value;
        this.AdjustDropDownWidth();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FFont$2.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FFont$2.FHeight,M,D));
      this.FEdit.FFont.Assign(this.FFont$2);
      this.SetDropDownControlHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDropDownControlHeight,M,D));
      this.SetDropDownControlWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDropDownControlWidth,M,D));
      this.FControlHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FControlHeight,M,D);
      this.FControlWidth = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FControlWidth,M,D);
      this.EndUpdate();
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FControl)) this.FControl = null;
    };
    this.FontChange = function (Sender) {
      this.Invalidate();
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.AdjustDropDownHeight();
      this.SetControl(this.FControl);
    };
    this.DoPickerItemSelected = function (AText, AItemIndex) {
      if (this.FOnItemSelected$1 != null) this.FOnItemSelected$1(this,AText,AItemIndex);
    };
    this.DoAdjustDropDownHeight = function (AHeight, AAllow) {
      if (this.FOnAdjustDropDownHeight != null) this.FOnAdjustDropDownHeight(this,AHeight,AAllow);
    };
    this.DoAdjustDropDownWidth = function (AWidth, AAllow) {
      if (this.FOnAdjustDropDownWidth != null) this.FOnAdjustDropDownWidth(this,AWidth,AAllow);
    };
    this.DoAfterDrawPickerContent = function (AGraphics, ARect, AContent) {
      if (this.FOnAfterDrawPickerContent != null) this.FOnAfterDrawPickerContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AContent);
    };
    this.DoBeforeDrawPickerContent = function (AGraphics, ARect, AContent, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawPickerContent != null) this.FOnBeforeDrawPickerContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AContent,AAllow,ADefaultDraw);
    };
    this.DoSetContent = function (AText, AAllow) {
      if (this.FOnSetContent != null) this.FOnSetContent(this,AText,AAllow);
    };
    this.DrawContent = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var a = false;
      var dd = false;
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.DrawContent.apply(this,arguments);
      if (!this.FEnabled) {
        AGraphics.FFont.SetColor(12632256)}
       else AGraphics.FFont.AssignSource(this.FFont$2);
      r.$assign(ARect);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-3,-3);
      a = true;
      dd = true;
      this.DoBeforeDrawPickerContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.GetContent(),{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }},{get: function () {
          return dd;
        }, set: function (v) {
          dd = v;
        }});
      if (a) {
        if (dd) AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.GetContent(),false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
        this.DoAfterDrawPickerContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.GetContent());
      };
    };
    this.InitializePopup = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.InitializePopup.call(this);
      if (this.FControl != null) {
        this.FControl.SetWidth(Math.round(this.FDropDownWidth));
        this.FControl.SetHeight(Math.round(this.FDropDownHeight));
      };
    };
    this.SelectFirstValue = function () {
      var idx = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectFirstValue.call(this);
        if (this.FControl != null) {
          idx = -1;
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            idx = pi.PickerGetFirstSelectableItem()}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) idx = pf.PickerGetFirstSelectableItem();
          this.NotifyDataBinderEdit();
          this.SetItemIndex(idx);
          this.NotifyDataBinderValueChanged();
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SelectLastValue = function () {
      var idx = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectLastValue.call(this);
        if (this.FControl != null) {
          idx = -1;
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            idx = pi.PickerGetLastSelectableItem()}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) idx = pf.PickerGetLastSelectableItem();
          this.NotifyDataBinderEdit();
          this.SetItemIndex(idx);
          this.NotifyDataBinderValueChanged();
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SelectNextValue = function () {
      var idx = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectNextValue.call(this);
        if (this.FControl != null) {
          idx = -1;
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            idx = pi.PickerGetNextSelectableItem(this.GetItemIndex())}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) idx = pf.PickerGetNextSelectableItem(this.GetItemIndex());
          this.NotifyDataBinderEdit();
          this.SetItemIndex(idx);
          this.NotifyDataBinderValueChanged();
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SelectPreviousValue = function () {
      var idx = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectPreviousValue.call(this);
        if (this.FControl != null) {
          idx = -1;
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            idx = pi.PickerGetPreviousSelectableItem(this.GetItemIndex())}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) idx = pf.PickerGetPreviousSelectableItem(this.GetItemIndex());
          this.NotifyDataBinderEdit();
          this.SetItemIndex(idx);
          this.NotifyDataBinderValueChanged();
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.SetAdaptToStyle = function (Value) {
      var ia = null;
      var $ir = rtl.createIntfRefs();
      try {
        pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SetAdaptToStyle.apply(this,arguments);
        if (this.FWrapper != null) this.FWrapper.SetAdaptToStyle(this.GetAdaptToStyle());
        if ((this.FControl != null) && pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle),{get: function () {
            return ia;
          }, set: function (v) {
            ia = v;
          }})) ia.SetAdaptToStyle(this.GetAdaptToStyle());
      } finally {
        $ir.free();
        rtl._Release(ia);
      };
    };
    this.AdjustDropDownHeight = function () {
      var h = 0.0;
      var a = false;
      if ((this.FControl != null) && (this.FDropDownHeightMode === $mod.TTMSFNCControlPickerDropDownHeightMode.chmItems)) {
        h = this.GetItemHeight() * this.GetVisibleItemCount();
      } else if ((this.FControl != null) && (this.FDropDownHeightMode === $mod.TTMSFNCControlPickerDropDownHeightMode.chmControl)) {
        h = this.FControlHeight;
      } else if (this.FDropDownHeightMode === $mod.TTMSFNCControlPickerDropDownHeightMode.chmPickerHeight) {
        h = this.GetHeight();
      } else h = this.FDropDownControlHeight;
      a = true;
      this.DoAdjustDropDownHeight({get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }},{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) this.SetDropDownHeight(h);
    };
    this.AdjustDropDownWidth = function () {
      var w = 0.0;
      var a = false;
      if ((this.FControl != null) && (this.FDropDownWidthMode === $mod.TTMSFNCControlPickerDropDownWidthMode.cwmItems)) {
        w = this.GetItemWidth() * this.GetVisibleItemCount();
      } else if ((this.FControl != null) && (this.FDropDownWidthMode === $mod.TTMSFNCControlPickerDropDownWidthMode.cwmControl)) {
        w = this.FControlWidth;
      } else if (this.FDropDownWidthMode === $mod.TTMSFNCControlPickerDropDownWidthMode.cwmPickerWidth) {
        w = this.GetWidth();
      } else w = this.FDropDownControlWidth;
      a = true;
      this.DoAdjustDropDownWidth({get: function () {
          return w;
        }, set: function (v) {
          w = v;
        }},{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) this.SetDropDownWidth(w);
    };
    this.UpdateListBoxLookup = function (AText) {
      this.ClearFilter();
      this.ApplyFilter(AText);
      if (this.FAutoDropDown && (AText.length >= this.FAutoCompleteNumChar) && !this.GetPopup().FIsOpen && (this.GetVisibleItemCount() > 0)) this.DropDown();
    };
    this.DeleteFromEdit = function () {
      this.FPrevString = this.FEdit.GetText();
      if (this.FEdit.GetSelLength() === 0) {
        pas.System.Delete({p: this, get: function () {
            return this.p.FPrevString;
          }, set: function (v) {
            this.p.FPrevString = v;
          }},this.FEdit.GetSelStart(),1)}
       else pas.System.Delete({p: this, get: function () {
          return this.p.FPrevString;
        }, set: function (v) {
          this.p.FPrevString = v;
        }},Math.max(1,this.FEdit.GetSelStart() + 1),this.FEdit.GetSelLength());
      this.UpdateListBoxLookup(this.FPrevString);
      if ((this.FPrevString.length < this.FAutoCompleteNumChar) && this.GetPopup().FIsOpen) {
        this.DropDown();
        this.ClearFilter();
      };
    };
    this.EditKeyDown$1 = function (Sender, Key, Shift) {
      this.FKeyDown$1 = Key.get();
      if (this.FKeyDown$1 in rtl.createSet(38,40)) {
        if (this.FKeyDown$1 === 38) this.SelectPreviousValue();
        if (this.FKeyDown$1 === 40) this.SelectNextValue();
        Key.set(0);
      };
      if (this.FKeyDown$1 === 8) this.DeleteFromEdit();
    };
    this.EditKeyPress$1 = function (Sender, Key) {
      var $Self = this;
      var fi = $mod.TTMSFNCControlPickerFilterItem.$new();
      var selPos = 0;
      var selLen = 0;
      var kch = "\x00";
      function EatKey() {
        Key.set("\x00");
      };
      if (!(this.FControl != null)) return;
      kch = Key.get();
      if (this.FKeyDown$1 === 27) {
        if (this.FAutoCloseUp && this.GetPopup().FIsOpen) ;
        this.DropDown();
        return;
      };
      if (this.FKeyDown$1 === 13) {
        if (this.GetPopup().FIsOpen) {
          this.FEdit.SetSelStart(this.FEdit.GetText().length);
          this.FEdit.SetSelLength(0);
          this.ClearFilter();
        };
        this.UpdatePickerContent();
        this.DropDown();
        return;
      };
      if (this.FAutoComplete) {
        if (kch === "\x00") return;
        if (this.FEdit.GetSelLength() === this.FEdit.GetText().length) this.FPrevString = "";
        this.FPrevString = this.FPrevString + kch;
        if (this.FPrevString.length < this.FAutoCompleteNumChar) return;
        this.UpdateListBoxLookup(this.FPrevString);
        fi.$assign(this.LookupItem(this.FPrevString));
        if (fi.ItemIndex >= 0) {
          this.NotifyDataBinderEdit();
          this.SetItemIndex(fi.ItemIndex);
          this.NotifyDataBinderValueChanged();
          selPos = this.FPrevString.length;
          this.SetContent(fi.ItemText);
          this.FEdit.SetSelStart(selPos);
          selLen = this.FEdit.GetText().length - selPos;
          this.FEdit.SetSelLength(selLen);
          EatKey();
          if (this.FAutoCloseUp && (selLen === 0) && this.GetPopup().FIsOpen) this.DropDown();
        };
      };
    };
    this.KeyPress = function (Key) {
      var fi = $mod.TTMSFNCControlPickerFilterItem.$new();
      var kch = "\x00";
      var tick = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.KeyPress.apply(this,arguments);
      if (!(this.FControl != null)) return;
      kch = Key.get();
      if (this.FKeyDown$1 === 27) {
        if (this.GetPopup().FIsOpen) ;
        this.DropDown();
        return;
      };
      if (this.FAutoComplete) {
        if (this.FKeyDown$1 === 8) {
          pas.System.Delete({p: this, get: function () {
              return this.p.FPrevString;
            }, set: function (v) {
              this.p.FPrevString = v;
            }},this.FPrevString.length,1);
          if ((this.FPrevString.length === 1) && this.GetPopup().FIsOpen) {
            this.DropDown();
            this.ClearFilter();
          };
          return;
        };
        if (kch === "\x00") return;
        if (this.FAutoDropDown && !this.GetPopup().FIsOpen) this.DropDown();
        tick = this.FAutoCompleteDelay;
        if (($impl.GetTickCountX() - this.FTick) < tick) {
          this.FPrevString = this.FPrevString + kch}
         else {
          this.FTick = $impl.GetTickCountX();
          this.FPrevString = kch;
        };
      } else {
        if (kch === "\x00") return;
        this.FPrevString = kch;
      };
      fi.$assign(this.LookupItem(this.FPrevString));
      if (fi.ItemIndex >= 0) {
        this.NotifyDataBinderEdit();
        this.SetItemIndex(fi.ItemIndex);
        this.NotifyDataBinderValueChanged();
        this.SetContent(fi.ItemText);
        this.Invalidate();
        if (this.FAutoComplete && (this.GetContent() === this.FPrevString) && this.FAutoCloseUp && this.GetPopup().FIsOpen) this.DropDown();
      };
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.KeyDown.apply(this,arguments);
      this.FKeyDown$1 = Key.get();
    };
    this.CreateSelector = function () {
      var Result = null;
      this.FWrapper = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.$create("Create$1",[this]);
      if (this.FControl != null) {
        this.FControl.SetParent(this.FWrapper);
        this.UpdatePickerContent();
      };
      Result = this.FWrapper;
      return Result;
    };
    this.GetVisibleItemCount = function () {
      var Result = 0;
      var pi = null;
      var pf = null;
      var $ir = rtl.createIntfRefs();
      try {
        Result = 0;
        if (this.FControl != null) {
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
              return pi;
            }, set: function (v) {
              pi = v;
            }})) {
            Result = pi.PickerGetVisibleItemCount()}
           else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
              return pf;
            }, set: function (v) {
              pf = v;
            }})) {
            Result = pf.PickerGetVisibleItemCount()}
           else Result = 1;
        };
      } finally {
        $ir.free();
        rtl._Release(pi);
        rtl._Release(pf);
      };
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.Create$1.apply(this,arguments);
      this.SetWidth(150);
      this.FDropDownControlWidth = this.GetWidth();
      this.FDropDownControlHeight = 150;
      this.SetEditable(true);
      this.FPrevString = "";
      this.FAutoComplete = true;
      this.FAutoCloseUp = false;
      this.FAutoDropDown = false;
      this.FCaseSensitive = false;
      this.FAutoCompleteNumChar = 2;
      this.FAutoCompleteDelay = 500;
      this.FFont$2 = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont$2.FOnChanged = rtl.createCallback(this,"FontChange");
      this.FEdit.FOnKeyDown = rtl.createCallback(this,"EditKeyDown$1");
      this.FEdit.FOnKeyPress = rtl.createCallback(this,"EditKeyPress$1");
      this.FEdit.FFont.Assign(this.FFont$2);
      this.GetPopup().FFocusedControl = this.FEdit;
      this.GetPopup().FStaysOpen = true;
      this.FDropDownHeightMode = $mod.TTMSFNCControlPickerDropDownHeightMode.chmDropDownHeight;
      this.FDropDownWidthMode = $mod.TTMSFNCControlPickerDropDownWidthMode.cwmDropDownWidth;
      if (this.IsDesignTime()) this.SetText("TTMSFNCControlPicker");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFont$2");
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.Destroy.call(this);
    };
    this.CallItemClicked = function (AItemIndex) {
      this.UpdatePickerContent();
      this.ClearFilter();
      this.NotifyDataBinderEdit();
      this.SetItemIndex(AItemIndex);
      this.NotifyDataBinderValueChanged();
      this.DropDown();
      this.Invalidate();
    };
    this.UpdatePickerContent = function () {
      var pb = null;
      var pi = null;
      var pf = null;
      var txt = "";
      var a = false;
      var $ir = rtl.createIntfRefs();
      try {
        txt = this.GetContent();
        if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerBase),{get: function () {
            return pb;
          }, set: function (v) {
            pb = v;
          }})) {
          txt = pb.PickerGetContent()}
         else if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerItems),{get: function () {
            return pi;
          }, set: function (v) {
            pi = v;
          }})) {
          txt = pi.PickerGetContent()}
         else if (pas.SysUtils.Supports$1($ir.ref(3,rtl.queryIntfT(this.FControl,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.ITMSFNCControlPickerFull),{get: function () {
            return pf;
          }, set: function (v) {
            pf = v;
          }})) txt = pf.PickerGetContent();
        a = true;
        this.DoSetContent({get: function () {
            return txt;
          }, set: function (v) {
            txt = v;
          }},{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) this.SetContent(txt);
      } finally {
        $ir.free();
        rtl._Release(pb);
        rtl._Release(pi);
        rtl._Release(pf);
      };
    };
    this.UpdatePickerDropDownSize = function () {
      this.AdjustDropDownHeight();
      this.AdjustDropDownWidth();
    };
    this.UpdateDropDown = function () {
      this.UpdatePickerContent();
      this.DropDown();
      this.Invalidate();
    };
    this.DropDown = function () {
      this.AdjustDropDownHeight();
      this.AdjustDropDownWidth();
      this.GetPopup().SetWidth(Math.round(this.FDropDownWidth));
      this.GetPopup().SetHeight(Math.round(this.FDropDownHeight));
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.DropDown.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCControlPicker",this.TTMSFNCCustomControlPicker,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCControlPicker);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AutoCloseUp",2,rtl.boolean,"FAutoCloseUp","SetAutoCloseUp",4,{Default: false});
    $r.addProperty("AutoDropDown",2,rtl.boolean,"FAutoDropDown","SetAutoDropDown",4,{Default: false});
    $r.addProperty("AutoComplete",2,rtl.boolean,"FAutoComplete","SetAutoComplete",4,{Default: true});
    $r.addProperty("AutoCompleteDelay",2,rtl.longint,"FAutoCompleteDelay","SetAutoCompleteDelay",4,{Default: 500});
    $r.addProperty("AutoCompleteNumChar",2,rtl.longint,"FAutoCompleteNumChar","SetAutoCompleteNumChar",4,{Default: 2});
    $r.addProperty("Control",2,pas["WEBLib.Controls"].$rtti["TControl"],"FControl","SetControl");
    $r.addProperty("CaseSensitive",2,rtl.boolean,"FCaseSensitive","SetCaseSensitive",4,{Default: false});
    $r.addProperty("DropDownControlHeight",2,rtl.double,"FDropDownControlHeight","SetDropDownControlHeight");
    $r.addProperty("DropDownControlWidth",2,rtl.double,"FDropDownControlWidth","SetDropDownControlWidth");
    $r.addProperty("DropDownHeightMode",2,$mod.$rtti["TTMSFNCControlPickerDropDownHeightMode"],"FDropDownHeightMode","SetDropDownHeightMode",4,{Default: $mod.TTMSFNCControlPickerDropDownHeightMode.chmDropDownHeight});
    $r.addProperty("DropDownWidthMode",2,$mod.$rtti["TTMSFNCControlPickerDropDownWidthMode"],"FDropDownWidthMode","SetDropDownWidthMode",4,{Default: $mod.TTMSFNCControlPickerDropDownWidthMode.cwmDropDownWidth});
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont$2","SetFnt$1");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("ItemHeight",3,rtl.double,"GetItemHeight","SetItemHeight");
    $r.addProperty("ItemWidth",3,rtl.double,"GetItemWidth","SetItemWidth");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus$1","SetShowFocus$1",4,{Default: true});
    $r.addProperty("Style",2,$mod.$rtti["TTMSFNCControlPickerStyle"],"FStyle","SetStyle",4,{Default: $mod.TTMSFNCControlPickerStyle.csDropDown});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("OnAdjustDropDownHeight",0,$mod.$rtti["TTMSFNCCustomControlPickerOnAdjustDropDownSizeEvent"],"FOnAdjustDropDownHeight","FOnAdjustDropDownHeight");
    $r.addProperty("OnAdjustDropDownWidth",0,$mod.$rtti["TTMSFNCCustomControlPickerOnAdjustDropDownSizeEvent"],"FOnAdjustDropDownWidth","FOnAdjustDropDownWidth");
    $r.addProperty("OnAfterDrawPickerContent",0,$mod.$rtti["TTMSFNCCustomControlPickerAfterDrawContentEvent"],"FOnAfterDrawPickerContent","FOnAfterDrawPickerContent");
    $r.addProperty("OnBeforeDrawPickerContent",0,$mod.$rtti["TTMSFNCCustomControlPickerBeforeDrawContentEvent"],"FOnBeforeDrawPickerContent","FOnBeforeDrawPickerContent");
    $r.addProperty("OnItemSelected",0,$mod.$rtti["TTMSFNCCustomControlPickerItemSelectedEvent"],"FOnItemSelected$1","FOnItemSelected$1");
    $r.addProperty("OnSetContent",0,$mod.$rtti["TTMSFNCCustomControlPickerOnSetContentEvent"],"FOnSetContent","FOnSetContent");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    $impl.GetTickCountX = function () {
      var Result = 0;
      var h = 0;
      var m = 0;
      var s = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(pas.SysUtils.Now(),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }},{get: function () {
          return m;
        }, set: function (v) {
          m = v;
        }},{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = ms + (s * 1000) + (m * 60 * 1000) + (h * 60 * 60 * 1000);
      return Result;
    };
    rtl.createClass($impl,"TControlOpen",pas["WEBLib.Controls"].TControl,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
},["Math","SysUtils","WEBLib.Graphics","WEBLib.TMSFNCStyles","WEBLib.TMSFNCUtils","WEBLib.StdCtrls"]);
rtl.module("WEBLib.TMSFNCTreeView",["System","Classes","WEBLib.TMSFNCCustomTreeView","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCTreeViewData","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCControlPicker"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.createClass(this,"TTMSFNCTreeView",pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewPublished,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClasses([$mod.TTMSFNCTreeView,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumn,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNode,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeValue]);
    };
    this.DoAfterSelectNode = function (ANode) {
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.DoAfterSelectNode.apply(this,arguments);
      if ((this.FParent != null) && pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.isPrototypeOf(this.FParent) && (this.FParent.FOwner != null) && pas["WEBLib.TMSFNCControlPicker"].TTMSFNCControlPicker.isPrototypeOf(this.FParent.FOwner)) {
        rtl.as(this.FParent.FOwner,pas["WEBLib.TMSFNCControlPicker"].TTMSFNCControlPicker).UpdateDropDown();
      };
    };
    this.DrawBorders = function (AGraphics) {
      var rrt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rrb = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var trl = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var grt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var grb = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var nr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.DrawBorders.apply(this,arguments);
      grt.$assign(this.GetGroupsTopRect());
      grb.$assign(this.GetGroupsBottomRect());
      rrt.$assign(this.GetColumnsTopRect());
      rrb.$assign(this.GetColumnsBottomRect());
      nr.$assign(this.GetContentClipRect());
      trl.$assign(pas["WEBLib.TMSFNCTypes"].RectF(nr.Right + 1,rrt.Bottom,nr.Right + 1,rrb.Top));
      AGraphics.FStroke.Assign(this.FColumnsAppearance.FTopStroke);
      if (((trl.Right - trl.Left) > 0) && ((trl.Bottom - trl.Top) > 0)) {
        if (this.HorizontalScrollBar().FVisible || this.FColumnsAppearance.FStretch) {
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(trl.Right,trl.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(trl.Right,trl.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp)}
         else AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(trl.Right,trl.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(trl.Right,trl.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
      };
      if (this.HorizontalScrollBar().FVisible || this.FColumnsAppearance.FStretch) {
        AGraphics.FStroke.Assign(this.FColumnsAppearance.FTopStroke);
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclTop in this.FColumnsAppearance.FLayouts) && (this.FColumnsAppearance.FTopSize > 0)) {
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrt.Left,rrt.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrt.Left,rrt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrt.Right,rrt.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrt.Right,rrt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp);
        } else if (!((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupLayout.tglTop in this.FGroupsAppearance.FLayouts) || (this.FGroupsAppearance.FTopSize <= 0) || (this.FDisplayGroups.GetCount() === 0)) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrt.Left,rrt.Bottom)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrt.Right,rrt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown);
        AGraphics.FStroke.Assign(this.FColumnsAppearance.FBottomStroke);
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclBottom in this.FColumnsAppearance.FLayouts) && (this.FColumnsAppearance.FBottomSize > 0)) {
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrb.Left,rrb.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrb.Left,rrb.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrb.Right,rrb.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrb.Right,rrb.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp);
        } else if ((!(pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupLayout.tglBottom in this.FGroupsAppearance.FLayouts) || (this.FGroupsAppearance.FBottomSize <= 0) || (this.FDisplayGroups.GetCount() === 0)) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrb.Left,rrb.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rrb.Right,rrb.Top)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp);
        AGraphics.FStroke.Assign(this.FGroupsAppearance.FTopStroke);
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupLayout.tglTop in this.FGroupsAppearance.FLayouts) && (this.FDisplayGroups.GetCount() > 0) && (this.FGroupsAppearance.FTopSize > 0)) {
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grt.Left,grt.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grt.Left,grt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grt.Right,grt.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grt.Right,grt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp);
        };
        if ((!(pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclTop in this.FColumnsAppearance.FLayouts) || (this.FColumnsAppearance.FTopSize <= 0)) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grt.Left,grt.Bottom)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grt.Right,grt.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown);
        AGraphics.FStroke.Assign(this.FGroupsAppearance.FBottomStroke);
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupLayout.tglBottom in this.FGroupsAppearance.FLayouts) && (this.FDisplayGroups.GetCount() > 0) && (this.FGroupsAppearance.FBottomSize > 0)) {
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grb.Left,grb.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grb.Left,grb.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
          AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grb.Right,grb.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grb.Right,grb.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp);
        };
        if ((!(pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclBottom in this.FColumnsAppearance.FLayouts) || (this.FColumnsAppearance.FBottomSize <= 0)) && (this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grb.Left,grb.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(grb.Right,grb.Top)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmLeftUp);
      };
    };
    this.DrawEmptySpaces = function (AGraphics) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var b = false;
      var df = false;
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.DrawEmptySpaces.apply(this,arguments);
      if (this.FColumnsAppearance.FFillEmptySpaces && !this.FStretchScrollBars) {
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclTop in this.FColumnsAppearance.FLayouts) && (this.FColumnsAppearance.FTopSize > 0)) {
          r.$assign(this.GetColumnTopRightEmptyRect());
          b = true;
          df = true;
          AGraphics.FFill.Assign(this.FColumnsAppearance.FTopFill);
          AGraphics.FStroke.Assign(this.FColumnsAppearance.FTopStroke);
          this.DoBeforeDrawColumnEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnEmptySpace.tcesTopRight,{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }},{get: function () {
              return df;
            }, set: function (v) {
              df = v;
            }});
          if (b) {
            if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShiftDownAndExpandWidth);
            this.DoAfterDrawColumnEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnEmptySpace.tcesTopRight);
          };
        };
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclBottom in this.FColumnsAppearance.FLayouts) && (this.FColumnsAppearance.FBottomSize > 0)) {
          r.$assign(this.GetColumnBottomRightEmptyRect());
          b = true;
          df = true;
          AGraphics.FFill.Assign(this.FColumnsAppearance.FBottomFill);
          AGraphics.FStroke.Assign(this.FColumnsAppearance.FBottomStroke);
          this.DoBeforeDrawColumnEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnEmptySpace.tcesBottomRight,{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }},{get: function () {
              return df;
            }, set: function (v) {
              df = v;
            }});
          if (b) {
            if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShiftUpAndExpandWidth);
            this.DoAfterDrawColumnEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnEmptySpace.tcesBottomRight);
          };
        };
      };
      if (this.FGroupsAppearance.FFillEmptySpaces && !this.FStretchScrollBars) {
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupLayout.tglTop in this.FGroupsAppearance.FLayouts) && (this.FGroupsAppearance.FTopSize > 0)) {
          r.$assign(this.GetGroupTopRightEmptyRect());
          b = true;
          df = true;
          AGraphics.FFill.Assign(this.FGroupsAppearance.FTopFill);
          AGraphics.FStroke.Assign(this.FGroupsAppearance.FTopStroke);
          this.DoBeforeDrawGroupEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupEmptySpace.tgesTopRight,{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }},{get: function () {
              return df;
            }, set: function (v) {
              df = v;
            }});
          if (b) {
            if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShiftLeftDown);
            this.DoAfterDrawGroupEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupEmptySpace.tgesTopRight);
          };
        };
        if ((pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupLayout.tglBottom in this.FGroupsAppearance.FLayouts) && (this.FGroupsAppearance.FBottomSize > 0)) {
          r.$assign(this.GetGroupBottomRightEmptyRect());
          b = true;
          df = true;
          AGraphics.FFill.Assign(this.FGroupsAppearance.FBottomFill);
          AGraphics.FStroke.Assign(this.FGroupsAppearance.FBottomStroke);
          this.DoBeforeDrawGroupEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupEmptySpace.tgesBottomRight,{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }},{get: function () {
              return df;
            }, set: function (v) {
              df = v;
            }});
          if (b) {
            if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShiftLeftUp);
            this.DoAfterDrawGroupEmptySpace(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewGroupEmptySpace.tgesBottomRight);
          };
        };
      };
    };
    this.DrawNodeColumns = function (AGraphics) {
      var b = false;
      var df = false;
      var I = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var x = 0.0;
      var w = 0.0;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var crcl = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var hs = 0.0;
      var c = null;
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.DrawNodeColumns.apply(this,arguments);
      cr.$assign(this.GetContentRect());
      crcl.$assign(this.GetContentClipRect());
      hs = this.GetHorizontalScrollPosition();
      for (var $l = 1, $end = this.FColumnCount - 1; $l <= $end; $l++) {
        I = $l;
        if ((I >= 0) && (I < (this.FColumns.GetCount() - 1))) {
          x = pas.System.Int(this.GetColPos(I)) - pas.System.Int(hs);
          w = pas.System.Int(this.GetColWidths(I));
          if ((this.FColumnStroke.FColor !== -1) && (this.FColumnStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone)) {
            AGraphics.FStroke.Assign(this.FColumnStroke);
            b = true;
            df = true;
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,cr.Top,x + w,cr.Bottom));
            this.DoBeforeDrawColumn(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),I,{get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }},{get: function () {
                return df;
              }, set: function (v) {
                df = v;
              }});
            if (b) {
              if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShiftRightAndShrinkHeight);
              this.DoAfterDrawColumn(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),I);
            };
          };
        };
      };
      if (this.FNodeStructure.GetCount() > 0) {
        for (var $l1 = 0, $end1 = this.FColumnCount - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1))) {
            c = this.FColumns.GetItem$1(I);
            x = pas.System.Int(this.GetColPos(I)) - pas.System.Int(hs);
            w = pas.System.Int(this.GetColWidths(I));
            b = true;
            df = true;
            AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
            AGraphics.FStroke.Assign(this.FNodesAppearance.FColumnStroke);
            if (!c.FUseDefaultAppearance) {
              AGraphics.FStroke.Assign(c.FStroke);
              AGraphics.FFill.Assign(c.FFill);
            };
            r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x,crcl.Top,x + w,crcl.Bottom));
            this.DoBeforeDrawNodeColumn(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),I,{get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }},{get: function () {
                return df;
              }, set: function (v) {
                df = v;
              }});
            if (b) {
              if (df) AGraphics.DrawRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShiftRightAndShrinkHeight);
              this.DoAfterDrawNodeColumn(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),I);
            };
          };
        };
      };
    };
    this.DrawNode = function (AGraphics, ARect, ANode, ACaching, AOffsetX, AOffsetY) {
      var str = "";
      var b = false;
      var df = false;
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var titr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var bmp = null;
      var bmpnr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var extr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var AColor = 0;
      var AStrokeColor = 0;
      var sts = 0;
      var stp = 0;
      var bmpn = null;
      var ha = 0;
      var va = 0;
      var c = null;
      var ww = false;
      var trim = 0;
      var en = false;
      var colw = 0.0;
      var chk = 0;
      var chkr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var chkbmp = null;
      var ck = false;
      var ext = false;
      var lr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpexr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dexr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sel = false;
      var cl = null;
      var rfoc = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var p = null;
      var lp = null;
      var n = null;
      var rsel = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ns = 0.0;
      var dpi = false;
      var g = null;
      var bmpa = null;
      var bt = null;
      var s = {};
      var ro = 0;
      var corners = {};
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.DrawNode.apply(this,arguments);
      if (!(ANode != null) || ((this.FDragNode === ANode) && this.FDragModeStarted)) return;
      dpi = this.FResourceScaleFactor > 1.0;
      en = true;
      this.DoIsNodeEnabled(ANode,{get: function () {
          return en;
        }, set: function (v) {
          en = v;
        }});
      ext = false;
      this.DoIsNodeExtended(ANode,{get: function () {
          return ext;
        }, set: function (v) {
          ext = v;
        }});
      sel = this.IsVirtualNodeSelected(ANode);
      if (en) {
        if (sel) {
          if (ext) {
            AGraphics.FFill.Assign(this.FNodesAppearance.FExtendedSelectedFill);
            AGraphics.FStroke.Assign(this.FNodesAppearance.FExtendedSelectedStroke);
          } else {
            AGraphics.FFill.Assign(this.FNodesAppearance.FSelectedFill);
            AGraphics.FStroke.Assign(this.FNodesAppearance.FSelectedStroke);
          };
          AColor = AGraphics.FFill.FColor;
          AStrokeColor = AGraphics.FStroke.FColor;
          this.DoGetNodeSelectedColor(ANode,{get: function () {
              return AColor;
            }, set: function (v) {
              AColor = v;
            }});
          this.DoGetNodeSelectedStrokeColor(ANode,{get: function () {
              return AStrokeColor;
            }, set: function (v) {
              AStrokeColor = v;
            }});
          AGraphics.FFill.SetColor(AColor);
          AGraphics.FStroke.SetColor(AStrokeColor);
        } else {
          if (ext) {
            AGraphics.FFill.Assign(this.FNodesAppearance.FExtendedFill);
            AGraphics.FStroke.Assign(this.FNodesAppearance.FExtendedStroke);
          } else {
            AGraphics.FFill.Assign(this.FNodesAppearance.FFill);
            AGraphics.FStroke.Assign(this.FNodesAppearance.FStroke);
          };
          AColor = AGraphics.FFill.FColor;
          AStrokeColor = AGraphics.FStroke.FColor;
          this.DoGetNodeColor(ANode,{get: function () {
              return AColor;
            }, set: function (v) {
              AColor = v;
            }});
          this.DoGetNodeStrokeColor(ANode,{get: function () {
              return AStrokeColor;
            }, set: function (v) {
              AStrokeColor = v;
            }});
          AGraphics.FFill.SetColor(AColor);
          AGraphics.FStroke.SetColor(AStrokeColor);
        };
      } else {
        if (ext) {
          AGraphics.FFill.Assign(this.FNodesAppearance.FExtendedDisabledFill);
          AGraphics.FStroke.Assign(this.FNodesAppearance.FExtendedDisabledStroke);
        } else {
          AGraphics.FFill.Assign(this.FNodesAppearance.FDisabledFill);
          AGraphics.FStroke.Assign(this.FNodesAppearance.FDisabledStroke);
        };
        AColor = AGraphics.FFill.FColor;
        AStrokeColor = AGraphics.FStroke.FColor;
        this.DoGetNodeDisabledColor(ANode,{get: function () {
            return AColor;
          }, set: function (v) {
            AColor = v;
          }});
        this.DoGetNodeDisabledStrokeColor(ANode,{get: function () {
            return AStrokeColor;
          }, set: function (v) {
            AStrokeColor = v;
          }});
        AGraphics.FFill.SetColor(AColor);
        AGraphics.FStroke.SetColor(AStrokeColor);
      };
      df = true;
      b = true;
      this.DoBeforeDrawNode(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ANode,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }},{get: function () {
          return df;
        }, set: function (v) {
          df = v;
        }});
      if (b) {
        if (df) {
          rsel.$assign(ARect);
          if (sel && !ext) {
            var $tmp = this.FNodesAppearance.FSelectionArea;
            if ($tmp === pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewSelectionArea.tsaFull) {
              if ((this.FStroke.FKind !== pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone) && (this.FStroke.FColor !== -1)) {
                rsel.Left = 1}
               else rsel.Left = 0;
            } else if ($tmp === pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewSelectionArea.tsaFromText) {
              if (rtl.length(ANode.FTextRects) > 0) rsel.Left = ANode.FTextRects[0].Left;
            };
          };
          s = rtl.refSet(pas["WEBLib.TMSFNCGraphicsTypes"].AllSides);
          ro = 0;
          corners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight);
          this.DoGetNodeSides(ANode,{get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }});
          this.DoGetNodeRounding(ANode,{get: function () {
              return ro;
            }, set: function (v) {
              ro = v;
            }},{get: function () {
              return corners;
            }, set: function (v) {
              corners = v;
            }});
          if (ro > 0) {
            ro = Math.min(pas.System.Trunc(Math.min(rsel.Right - rsel.Left,rsel.Bottom - rsel.Top) / 2),ro);
            AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rsel),ro,rtl.refSet(corners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmNone);
          } else AGraphics.DrawRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rsel),rtl.refSet(s),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmNone);
          if ((ANode === this.GetFocusedVirtualNode()) && this.IsFocused() && this.FNodesAppearance.FShowFocus) {
            rfoc.$assign(rsel);
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(rfoc,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
            AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rfoc),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          };
        };
        if (!this.FCompactMode) {
          sts = this.GetFirstVisibleColumn();
          stp = this.GetLastVisibleColumn();
          if (ext) stp = Math.min(sts,stp);
          for (var $l = sts, $end = stp; $l <= $end; $l++) {
            I = $l;
            cl = null;
            if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1))) cl = this.FColumns.GetItem$1(I);
            if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FExpandRects) - 1)) && this.FNodesAppearance.FShowLines && (I === this.FNodesAppearance.FExpandColumn) && (this.FNodesAppearance.FExpandWidth > 0)) {
              r.$assign(ANode.FExpandRects[I - sts]);
              pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(r,AOffsetX,AOffsetY);
              AGraphics.FStroke.Assign(this.FNodesAppearance.FLineStroke);
              if (this.FNodesAppearance.FLineStroke.FKind in rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDash,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDot,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDot,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDotDot)) AGraphics.StartSpecialPen();
              ns = this.FNodesAppearance.FLevelIndent;
              lr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + (this.FNodesAppearance.FExpandWidth / 2),ARect.Top,r.Left + (this.FNodesAppearance.FExpandWidth / 2) + (ns / 2),ARect.Bottom));
              AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(lr.Left,lr.Top + ((lr.Bottom - lr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(lr.Right,lr.Top + ((lr.Bottom - lr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
              if (this.FVisibleNodes.GetCount() > 1) {
                n = ANode;
                p = n.GetParent();
                dr.$assign(lr);
                while (p != null) {
                  if (((n === ANode) && (n.FIndex <= (p.FChildren - 1))) || ((n !== ANode) && (n.FIndex < (p.FChildren - 1)))) {
                    if (n.FIndex < (p.FChildren - 1)) {
                      AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp)}
                     else AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top + ((dr.Bottom - dr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
                  };
                  n = p;
                  p = n.GetParent();
                  pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(dr,-ns,0);
                };
                if ((this.FNodeStructure.GetCount() - ANode.FTotalChildren - 1) > 0) {
                  p = ANode.GetParent();
                  if (!(p != null)) {
                    if (ANode.FRow === (this.FNodeStructure.GetCount() - ANode.FTotalChildren - 1)) {
                      AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top + ((dr.Bottom - dr.Top) / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
                    } else if (ANode.FRow === 0) {
                      AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top + ((dr.Bottom - dr.Top) / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,pas.System.Int(dr.Bottom) - 0.5)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
                    } else AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
                  } else if (p != null) {
                    lp = p;
                    p = p.GetParent();
                    dr.$assign(lr);
                    pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(dr,-ns,0);
                    while (p != null) {
                      lp = p;
                      p = p.GetParent();
                      pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(dr,-ns,0);
                    };
                    if ((lp != null) && (lp.FRow < (this.FNodeStructure.GetCount() - lp.FTotalChildren - 1))) AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(dr.Left,dr.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightUp);
                  };
                };
              };
              if (this.FNodesAppearance.FLineStroke.FKind in rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDash,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDot,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDot,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskDashDotDot)) AGraphics.StopSpecialPen();
            };
            if ((cl != null) && !cl.FUseDefaultAppearance && !ext) {
              AGraphics.FFont.Assign(cl.FFont)}
             else {
              if (ext) {
                AGraphics.FFont.Assign(this.FNodesAppearance.FExtendedFont)}
               else AGraphics.FFont.Assign(this.FNodesAppearance.FFont);
            };
            colw = this.GetColWidths(I);
            if ((colw > 0) || ext) {
              if (en) {
                if (sel) {
                  if (ext) {
                    AColor = this.FNodesAppearance.FExtendedSelectedFontColor}
                   else AColor = this.FNodesAppearance.FSelectedFontColor;
                  this.DoGetNodeSelectedTextColor(ANode,I,{get: function () {
                      return AColor;
                    }, set: function (v) {
                      AColor = v;
                    }});
                  AGraphics.FFont.SetColor(AColor);
                } else {
                  if ((cl != null) && !cl.FUseDefaultAppearance && !ext) {
                    AColor = cl.FFont.FColor}
                   else {
                    if (ext) {
                      AColor = this.FNodesAppearance.FExtendedFontColor}
                     else AColor = this.FNodesAppearance.FFont.FColor;
                  };
                  this.DoGetNodeTextColor(ANode,I,{get: function () {
                      return AColor;
                    }, set: function (v) {
                      AColor = v;
                    }});
                  AGraphics.FFont.SetColor(AColor);
                };
              } else {
                if (ext) {
                  AColor = this.FNodesAppearance.FExtendedDisabledFontColor}
                 else AColor = this.FNodesAppearance.FDisabledFontColor;
                this.DoGetNodeDisabledTextColor(ANode,I,{get: function () {
                    return AColor;
                  }, set: function (v) {
                    AColor = v;
                  }});
                AGraphics.FFont.SetColor(AColor);
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FCheckRects) - 1)) && ((I - sts) <= (rtl.length(ANode.FCheckStates) - 1))) {
                chk = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone;
                this.DoGetNodeCheckType(ANode,I,{get: function () {
                    return chk;
                  }, set: function (v) {
                    chk = v;
                  }});
                if (chk !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntNone) {
                  chkbmp = null;
                  ck = ANode.FCheckStates[I - sts];
                  this.DoIsNodeChecked(ANode,I,{get: function () {
                      return ck;
                    }, set: function (v) {
                      ck = v;
                    }});
                  var $tmp1 = chk;
                  if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntCheckBox) {
                    chkbmp = this.GetCheckBoxBitmap(ck,false,true)}
                   else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeCheckType.tvntRadioButton) chkbmp = this.GetRadioButtonBitmap(ck,false,true);
                  if (chkbmp != null) {
                    chkr.$assign(ANode.FCheckRects[I - sts]);
                    pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(chkr,AOffsetX,AOffsetY);
                    b = true;
                    this.DoBeforeDrawNodeCheck(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(chkr),I,ANode,chkbmp,{get: function () {
                        return b;
                      }, set: function (v) {
                        b = v;
                      }});
                    if (b) {
                      AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(chkr),chkbmp,true,false,true,false);
                      this.DoAfterDrawNodeCheck(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(chkr),I,ANode,chkbmp);
                    };
                  };
                };
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FBitmapRects) - 1))) {
                bmpn = null;
                this.DoGetNodeIcon(ANode,I,false,{get: function () {
                    return bmpn;
                  }, set: function (v) {
                    bmpn = v;
                  }});
                if (!(bmpn != null) && dpi) this.DoGetNodeIcon(ANode,I,true,{get: function () {
                    return bmpn;
                  }, set: function (v) {
                    bmpn = v;
                  }});
                if ((bmpn != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmpn)) {
                  bmpnr.$assign(ANode.FBitmapRects[I - sts]);
                  pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(bmpnr,AOffsetX,AOffsetY);
                  b = true;
                  this.DoBeforeDrawNodeIcon(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bmpnr),I,ANode,bmpn,{get: function () {
                      return b;
                    }, set: function (v) {
                      b = v;
                    }});
                  if (b) {
                    AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bmpnr),bmpn,true,false,true,false);
                    this.DoAfterDrawNodeIcon(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bmpnr),I,ANode,bmpn);
                  };
                };
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FExpandRects) - 1)) && (ANode.FChildren > 0) && (I === this.FNodesAppearance.FExpandColumn) && (this.FNodesAppearance.FExpandWidth > 0)) {
                if (dpi) {
                  if (ANode.GetExpanded()) {
                    bmp = this.FNodesAppearance.FCollapseNodeIconLarge}
                   else bmp = this.FNodesAppearance.FExpandNodeIconLarge;
                } else {
                  if (ANode.GetExpanded()) {
                    bmp = this.FNodesAppearance.FCollapseNodeIcon}
                   else bmp = this.FNodesAppearance.FExpandNodeIcon;
                };
                bmpa = null;
                if (this.GetAdaptToStyle()) {
                  bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
                  bmpa.SetSize(bmp.GetWidth(),bmp.GetHeight());
                  g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
                  try {
                    if (g.BeginScene()) {
                      g.FFill.SetColor(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor);
                      g.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
                      g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
                      g.FStroke.SetColor(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultTextFontColor);
                      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,bmp.GetWidth(),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                      g.FStroke.SetWidth(this.ScalePaintValue(2));
                      if (!ANode.GetExpanded()) g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rtl.trunc(bmp.GetWidth() / 2),0)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(rtl.trunc(bmp.GetWidth() / 2),bmp.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
                      g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(0,rtl.trunc(bmp.GetHeight() / 2))),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bmp.GetWidth(),rtl.trunc(bmp.GetHeight() / 2))),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
                      g.EndScene();
                    };
                  } finally {
                    g = rtl.freeLoc(g);
                  };
                };
                bmpexr.$assign(ANode.FExpandRects[I - sts]);
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(bmpexr,AOffsetX,AOffsetY);
                b = true;
                this.DoBeforeDrawNodeExpand(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bmpexr),I,ANode,bmp,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }});
                if (b) {
                  if (dpi) {
                    dexr.$assign(bmpexr);
                    pas["WEBLib.TMSFNCTypes"].InflateRectEx(dexr,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
                  } else {
                    dexr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(bmpexr.Left + ((bmpexr.Right - bmpexr.Left - bmp.GetWidth()) / 2)),pas.System.Int(bmpexr.Top + ((bmpexr.Bottom - bmpexr.Top - bmp.GetHeight()) / 2)),pas.System.Int(bmpexr.Left + ((bmpexr.Right - bmpexr.Left - bmp.GetWidth()) / 2)) + bmp.GetWidth(),pas.System.Int(bmpexr.Top + ((bmpexr.Bottom - bmpexr.Top - bmp.GetHeight()) / 2)) + bmp.GetHeight()));
                  };
                  if (this.GetAdaptToStyle() && (bmpa != null)) {
                    bt = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
                    try {
                      bt.Assign(bmpa);
                      AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(dexr),bt,true,false,true,false);
                    } finally {
                      bt = rtl.freeLoc(bt);
                    };
                    bmpa = rtl.freeLoc(bmpa);
                    bmpa = null;
                  } else {
                    AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(dexr),bmp,true,false,true,false);
                  };
                  this.DoAfterDrawNodeExpand(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bmpexr),I,ANode,bmp);
                };
                if (bmpa != null) bmpa = rtl.freeLoc(bmpa);
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FTextRects) - 1)) && ANode.GetTitleExpanded(I - sts)) {
                txtr.$assign(ANode.FTextRects[I - sts]);
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(txtr,AOffsetX,AOffsetY);
                pas["WEBLib.TMSFNCTypes"].InflateRectEx(txtr,this.ScalePaintValue(-2),0);
                c = null;
                if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1))) c = this.FColumns.GetItem$1(I);
                ha = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
                va = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
                ww = false;
                trim = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
                if (c != null) {
                  ha = c.FHorizontalTextAlign;
                  va = c.FVerticalTextAlign;
                  ww = c.FWordWrapping;
                  trim = c.FTrimming;
                };
                this.DoGetNodeTrimming(ANode,I,{get: function () {
                    return trim;
                  }, set: function (v) {
                    trim = v;
                  }});
                this.DoGetNodeWordWrapping(ANode,I,{get: function () {
                    return ww;
                  }, set: function (v) {
                    ww = v;
                  }});
                this.DoGetNodeHorizontalTextAlign(ANode,I,{get: function () {
                    return ha;
                  }, set: function (v) {
                    ha = v;
                  }});
                this.DoGetNodeVerticalTextAlign(ANode,I,{get: function () {
                    return va;
                  }, set: function (v) {
                    va = v;
                  }});
                str = "";
                this.DoGetNodeText(ANode,I,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                    return str;
                  }, set: function (v) {
                    str = v;
                  }});
                b = true;
                this.DoBeforeDrawNodeText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),I,ANode,str,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }});
                if (b) {
                  if ((this.FInplaceEditorActive && ((this.FUpdateNodeColumn !== I) || (this.GetFocusedVirtualNode() !== ANode))) || !this.FInplaceEditorActive) AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,0,-1,-1,true,false,-1,-1);
                  this.DoAfterDrawNodeText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),I,ANode,str);
                };
              };
              if ((cl != null) && !cl.FUseDefaultAppearance) {
                AGraphics.FFont.Assign(cl.FTitleFont)}
               else AGraphics.FFont.Assign(this.FNodesAppearance.FTitleFont);
              if (en) {
                if (sel) {
                  AColor = this.FNodesAppearance.FSelectedTitleFontColor;
                  this.DoGetNodeSelectedTitleColor(ANode,I,{get: function () {
                      return AColor;
                    }, set: function (v) {
                      AColor = v;
                    }});
                  AGraphics.FFont.SetColor(AColor);
                } else {
                  if ((cl != null) && !cl.FUseDefaultAppearance) {
                    AColor = cl.FTitleFont.FColor}
                   else AColor = this.FNodesAppearance.FTitleFont.FColor;
                  this.DoGetNodeTitleColor(ANode,I,{get: function () {
                      return AColor;
                    }, set: function (v) {
                      AColor = v;
                    }});
                  AGraphics.FFont.SetColor(AColor);
                };
              } else {
                AColor = this.FNodesAppearance.FDisabledTitleFontColor;
                this.DoGetNodeDisabledTitleColor(ANode,I,{get: function () {
                    return AColor;
                  }, set: function (v) {
                    AColor = v;
                  }});
                AGraphics.FFont.SetColor(AColor);
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FTitleRects) - 1))) {
                titr.$assign(ANode.FTitleRects[I - sts]);
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(titr,AOffsetX,AOffsetY);
                pas["WEBLib.TMSFNCTypes"].InflateRectEx(titr,this.ScalePaintValue(-2),0);
                c = null;
                if ((I >= 0) && (I <= (this.FColumns.GetCount() - 1))) c = this.FColumns.GetItem$1(I);
                ha = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
                va = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
                ww = false;
                trim = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
                if (c != null) {
                  ha = c.FTitleHorizontalTextAlign;
                  va = c.FTitleVerticalTextAlign;
                  ww = c.FTitleWordWrapping;
                  trim = c.FTitleTrimming;
                };
                this.DoGetNodeTitleTrimming(ANode,I,{get: function () {
                    return trim;
                  }, set: function (v) {
                    trim = v;
                  }});
                this.DoGetNodeTitleWordWrapping(ANode,I,{get: function () {
                    return ww;
                  }, set: function (v) {
                    ww = v;
                  }});
                this.DoGetNodeTitleHorizontalTextAlign(ANode,I,{get: function () {
                    return ha;
                  }, set: function (v) {
                    ha = v;
                  }});
                this.DoGetNodeTitleVerticalTextAlign(ANode,I,{get: function () {
                    return va;
                  }, set: function (v) {
                    va = v;
                  }});
                str = "";
                this.DoGetNodeTitle(ANode,I,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeTextMode.tntmDrawing,{get: function () {
                    return str;
                  }, set: function (v) {
                    str = v;
                  }});
                b = true;
                this.DoBeforeDrawNodeTitle(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(titr),I,ANode,str,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }});
                if (b) {
                  AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(titr),str,ww,ha,va,trim,0,-1,-1,true,false,-1,-1);
                  this.DoAfterDrawNodeTitle(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(titr),I,ANode,str);
                };
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FExtraRects) - 1))) {
                extr.$assign(ANode.FExtraRects[I - sts]);
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(extr,AOffsetX,AOffsetY);
                b = true;
                this.DoBeforeDrawNodeExtra(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(extr),I,ANode,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }});
                if (b) {
                  this.DoDrawNodeExtra(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(extr),I,ANode);
                  this.DoAfterDrawNodeExtra(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(extr),I,ANode);
                };
              };
              if (((I - sts) >= 0) && ((I - sts) <= (rtl.length(ANode.FTitleExtraRects) - 1))) {
                extr.$assign(ANode.FTitleExtraRects[I - sts]);
                pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(extr,AOffsetX,AOffsetY);
                b = true;
                this.DoBeforeDrawNodeTitleExtra(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(extr),I,ANode,{get: function () {
                    return b;
                  }, set: function (v) {
                    b = v;
                  }});
                if (b) {
                  this.DoDrawNodeTitleExtra(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(extr),I,ANode);
                  this.DoAfterDrawNodeTitleExtra(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(extr),I,ANode);
                };
              };
            };
          };
        };
        this.DoAfterDrawNode(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ANode);
      };
    };
    this.DrawGroup = function (AGraphics, ARect, AGroup, AStartColumn, AEndColumn, AKind) {
      var b = false;
      var df = false;
      var str = "";
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var grp = null;
      var def = false;
      grp = null;
      def = true;
      if ((AGroup >= 0) && (AGroup <= (this.FGroups.GetCount() - 1))) {
        grp = this.FGroups.GetItem$1(AGroup);
        if (!grp.FUseDefaultAppearance) {
          def = false;
          var $tmp = AKind;
          if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
            AGraphics.FStroke.Assign(grp.FTopStroke);
            AGraphics.FFill.Assign(grp.FTopFill);
          } else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) {
            AGraphics.FStroke.Assign(grp.FBottomStroke);
            AGraphics.FFill.Assign(grp.FBottomFill);
          };
        };
      };
      if (def) {
        var $tmp1 = AKind;
        if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
          AGraphics.FStroke.Assign(this.FGroupsAppearance.FTopStroke);
          AGraphics.FFill.Assign(this.FGroupsAppearance.FTopFill);
        } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) {
          AGraphics.FStroke.Assign(this.FGroupsAppearance.FBottomStroke);
          AGraphics.FFill.Assign(this.FGroupsAppearance.FBottomFill);
        };
      };
      b = true;
      df = true;
      this.DoBeforeDrawGroup(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AGroup,AStartColumn,AEndColumn,AKind,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }},{get: function () {
          return df;
        }, set: function (v) {
          df = v;
        }});
      if (b) {
        if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmNone);
        if (def) {
          var $tmp2 = AKind;
          if ($tmp2 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
            AGraphics.FFont.Assign(this.FGroupsAppearance.FTopFont)}
           else if ($tmp2 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) AGraphics.FFont.Assign(this.FGroupsAppearance.FBottomFont);
        } else if (grp != null) {
          var $tmp3 = AKind;
          if ($tmp3 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
            AGraphics.FFont.Assign(grp.FTopFont)}
           else if ($tmp3 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) AGraphics.FFont.Assign(grp.FBottomFont);
        };
        txtr.$assign(ARect);
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(txtr,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
        str = this.GetGroupText(AGroup);
        this.DoGetGroupText(AGroup,AKind,{get: function () {
            return str;
          }, set: function (v) {
            str = v;
          }});
        b = true;
        this.DoBeforeDrawGroupText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),AGroup,AStartColumn,AEndColumn,AKind,str,{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        if (b) {
          var $tmp4 = AKind;
          if ($tmp4 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupTop) {
            if (this.FGroupsAppearance.FTopVerticalText) {
              AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,false,this.FGroupsAppearance.FTopHorizontalTextAlign,this.FGroupsAppearance.FTopVerticalTextAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,-90,-1,-1,true,false,-1,-1)}
             else AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,false,this.FGroupsAppearance.FTopHorizontalTextAlign,this.FGroupsAppearance.FTopVerticalTextAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          } else if ($tmp4 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikGroupBottom) {
            if (this.FGroupsAppearance.FBottomVerticalText) {
              AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,false,this.FGroupsAppearance.FBottomHorizontalTextAlign,this.FGroupsAppearance.FBottomVerticalTextAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,90,-1,-1,true,false,-1,-1)}
             else AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,false,this.FGroupsAppearance.FBottomHorizontalTextAlign,this.FGroupsAppearance.FBottomVerticalTextAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          };
          this.DoAfterDrawGroupText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),AGroup,AStartColumn,AEndColumn,AKind,str);
        };
        this.DoAfterDrawGroup(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AGroup,AStartColumn,AEndColumn,AKind);
      };
    };
    this.DrawColumn = function (AGraphics, ARect, AColumn, AKind) {
      var b = false;
      var str = "";
      var df = false;
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var def = false;
      var col = null;
      var trim = 0;
      var ha = 0;
      var va = 0;
      var ww = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var sr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var szd = 0.0;
      var szr = 0.0;
      var szt = 0.0;
      pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.DrawColumn.apply(this,arguments);
      r.$assign(ARect);
      def = true;
      col = null;
      if ((AColumn >= 0) && (AColumn <= (this.FColumns.GetCount() - 1))) {
        col = this.FColumns.GetItem$1(AColumn);
        if (!col.FVisible) return;
        if (!col.FUseDefaultAppearance) {
          def = false;
          var $tmp = AKind;
          if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
            AGraphics.FStroke.Assign(col.FTopStroke);
            AGraphics.FFill.Assign(col.FTopFill);
          } else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) {
            AGraphics.FStroke.Assign(col.FBottomStroke);
            AGraphics.FFill.Assign(col.FBottomFill);
          };
        };
      };
      if (def) {
        var $tmp1 = AKind;
        if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
          AGraphics.FStroke.Assign(this.FColumnsAppearance.FTopStroke);
          AGraphics.FFill.Assign(this.FColumnsAppearance.FTopFill);
        } else if ($tmp1 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) {
          AGraphics.FStroke.Assign(this.FColumnsAppearance.FBottomStroke);
          AGraphics.FFill.Assign(this.FColumnsAppearance.FBottomFill);
        };
      };
      b = true;
      df = true;
      this.DoBeforeDrawColumnHeader(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AColumn,AKind,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }},{get: function () {
          return df;
        }, set: function (v) {
          df = v;
        }});
      if (b) {
        if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmNone);
        sr.$assign(r);
        szt = 0;
        if (col != null) {
          if (col.FFiltering.FEnabled) {
            szd = col.FFiltering.FButtonSize;
            dr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(r.Right - szd - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - szd) / 2)),Math.round(r.Right - this.ScalePaintValue(4)),Math.round(r.Top + ((r.Bottom - r.Top - szd) / 2) + szd)));
            AGraphics.DrawDropDownButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(dr),false,false,true,true,this.GetAdaptToStyle(),this.FPaintScaleFactor);
            sr.Right = dr.Left;
            szt = szt + szd + this.ScalePaintValue(4);
          };
          if (col.FExpandable) {
            szr = col.FExpandingButtonSize;
            sr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(sr.Right - szr - this.ScalePaintValue(6)),Math.round(sr.Top + ((sr.Bottom - sr.Top - szr) / 2)),Math.round(sr.Right - this.ScalePaintValue(6)),Math.round(sr.Top + ((sr.Bottom - sr.Top - szr) / 2) + szr)));
            if (col.FExpanded) {
              AGraphics.DrawCompactButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(sr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCompactState.gcsExpanded,false,false,true,false,this.FPaintScaleFactor)}
             else AGraphics.DrawCompactButton(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(sr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCompactState.gcsCollapsed,false,false,true,false,this.FPaintScaleFactor);
            sr.Right = sr.Left;
            szt = szt + szr + this.ScalePaintValue(6);
          };
          if ((col.FSortKind !== pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskNone) && (this.FSortColumn === AColumn)) {
            szr = this.ScalePaintValue(8);
            sr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(sr.Right - szr - this.ScalePaintValue(6)),Math.round(sr.Top + ((sr.Bottom - sr.Top - szr) / 2)),Math.round(sr.Right - this.ScalePaintValue(6)),Math.round(sr.Top + ((sr.Bottom - sr.Top - szr) / 2) + szr)));
            this.DrawSortIndicator(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(sr),this.FColumnsAppearance.FSortIndicatorColor,AColumn,col.FSortIndex,col.FSortKind);
            szt = szt + szr + this.ScalePaintValue(6);
          };
        };
        if (def) {
          var $tmp2 = AKind;
          if ($tmp2 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
            AGraphics.FFont.Assign(this.FColumnsAppearance.FTopFont)}
           else if ($tmp2 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) AGraphics.FFont.Assign(this.FColumnsAppearance.FBottomFont);
        } else if (col != null) {
          var $tmp3 = AKind;
          if ($tmp3 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
            AGraphics.FFont.Assign(col.FTopFont)}
           else if ($tmp3 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) AGraphics.FFont.Assign(col.FBottomFont);
        };
        str = this.GetColumnText(AColumn);
        this.DoGetColumnText(AColumn,AKind,{get: function () {
            return str;
          }, set: function (v) {
            str = v;
          }});
        ha = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
        va = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
        ww = false;
        trim = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
        if (col != null) {
          ha = col.FHorizontalTextAlign;
          va = col.FVerticalTextAlign;
          ww = col.FWordWrapping;
          trim = col.FTrimming;
        };
        this.DoGetColumnTrimming(AColumn,AKind,{get: function () {
            return trim;
          }, set: function (v) {
            trim = v;
          }});
        this.DoGetColumnWordWrapping(AColumn,AKind,{get: function () {
            return ww;
          }, set: function (v) {
            ww = v;
          }});
        this.DoGetColumnHorizontalTextAlign(AColumn,AKind,{get: function () {
            return ha;
          }, set: function (v) {
            ha = v;
          }});
        this.DoGetColumnVerticalTextAlign(AColumn,AKind,{get: function () {
            return va;
          }, set: function (v) {
            va = v;
          }});
        b = true;
        txtr.$assign(r);
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(txtr,this.ScalePaintValue(-3),this.ScalePaintValue(-3));
        txtr.Right = Math.max(txtr.Left,txtr.Right - szt);
        this.DoBeforeDrawColumnText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),AColumn,AKind,str,{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        if (b) {
          var $tmp4 = AKind;
          if ($tmp4 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnTop) {
            if (this.FColumnsAppearance.FTopVerticalText) {
              AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,-90,-1,-1,true,false,-1,-1)}
             else AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,0,-1,-1,true,false,-1,-1);
          } else if ($tmp4 === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewCacheItemKind.ikColumnBottom) {
            if (this.FColumnsAppearance.FBottomVerticalText) {
              AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,90,-1,-1,true,false,-1,-1)}
             else AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),str,ww,ha,va,trim,0,-1,-1,true,false,-1,-1);
          };
          this.DoAfterDrawColumnText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),AColumn,AKind,str);
        };
        this.DoAfterDrawColumnHeader(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,AKind);
      };
    };
    this.DrawSortIndicator = function (AGraphics, ARect, AColor, AColumn, ASortIndex, ASortKind) {
      var pth = null;
      var vertt = 0;
      var c = 0;
      var txtr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var b = false;
      c = AColor;
      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      AGraphics.FFill.SetColor(c);
      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      AGraphics.FStroke.SetColor(c);
      b = true;
      this.DoBeforeDrawSortIndicator(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ASortIndex,ASortKind,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      if (b) {
        vertt = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
        txtr.$assign(ARect);
        pth = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
        try {
          var $tmp = ASortKind;
          if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskAscending) {
            vertt = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing;
            pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ((ARect.Right - ARect.Left) / 2),ARect.Top));
            pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom));
            pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom));
            txtr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top + this.ScalePaintValue(2),ARect.Right,ARect.Bottom + this.ScalePaintValue(2)));
          } else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodesSortKind.nskDescending) {
            vertt = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
            pth.MoveTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top));
            pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top));
            pth.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ((ARect.Right - ARect.Left) / 2),ARect.Bottom));
            txtr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left,ARect.Top - this.ScalePaintValue(2),ARect.Right,ARect.Bottom - this.ScalePaintValue(2)));
          };
          pth.ClosePath();
          AGraphics.DrawPath(pth,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
          if (ASortIndex !== -1) {
            AGraphics.FFont.SetColor(16777215);
            pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(AGraphics.FFont,9,1);
            AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(txtr),pas.SysUtils.IntToStr(ASortIndex),false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,vertt,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          };
        } finally {
          pth = rtl.freeLoc(pth);
        };
        this.DoAfterDrawSortIndicator(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AColumn,ASortIndex,ASortKind);
      };
    };
    this.PickerGetContent = function () {
      var Result = "";
      var n = null;
      Result = "";
      if (this.SelectedVirtualNodeCount() > 0) {
        n = this.GetSelVirtualNode(0);
        Result = n.GetText(0);
      };
      return Result;
    };
    this.PickerSelectItem = function (AItemIndex) {
      var n = null;
      n = this.GetNodeFromNodeStructure(AItemIndex);
      if (n != null) {
        this.SelectVirtualNode(n);
        this.ScrollToVirtualNode(n,true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
      };
    };
    this.PickerGetSelectedItem = function () {
      var Result = 0;
      Result = this.GetSelectedVirtualNodeRow();
      return Result;
    };
    this.PickerGetVisibleItemCount = function () {
      var Result = 0;
      Result = this.GetVisibleNodeCount();
      return Result;
    };
    this.PickerGetItemCount = function () {
      var Result = 0;
      Result = this.GetTotalVirtualNodeCount();
      return Result;
    };
    this.PickerGetItemHeight = function () {
      var Result = 0.0;
      Result = this.FNodesAppearance.FFixedHeight;
      return Result;
    };
    this.PickerSetItemHeight = function (AValue) {
      this.FNodesAppearance.SetFixedHeight(AValue);
    };
    this.PickerGetItemWidth = function () {
      var Result = 0.0;
      if (this.FColumns.GetCount() > 0) {
        Result = this.GetWidth() / this.FColumns.GetCount()}
       else Result = 0;
      return Result;
    };
    this.PickerSetItemWidth = function (AValue) {
    };
    this.PickerGetNextSelectableItem = function (AItemIndex) {
      var Result = 0;
      var n = null;
      var nf = null;
      Result = -1;
      n = this.GetNodeFromNodeStructure(AItemIndex);
      if (n != null) {
        nf = this.GetNextFocusableNode(n);
        if (nf != null) Result = nf.FRow;
      };
      return Result;
    };
    this.PickerGetPreviousSelectableItem = function (AItemIndex) {
      var Result = 0;
      var n = null;
      var nf = null;
      Result = -1;
      n = this.GetNodeFromNodeStructure(AItemIndex);
      if (n != null) {
        nf = this.GetPreviousFocusableNode(n);
        if (nf != null) Result = nf.FRow;
      };
      return Result;
    };
    this.PickerGetFirstSelectableItem = function () {
      var Result = 0;
      Result = this.GetFirstVisibleVirtualNodeRow();
      return Result;
    };
    this.PickerGetLastSelectableItem = function () {
      var Result = 0;
      Result = this.GetLastVisibleVirtualNodeRow();
      return Result;
    };
    this.PickerResetFilter = function () {
      if (this.FFilter.GetCount() > 0) this.RemoveFilters();
    };
    this.PickerApplyFilter = function (ACondition, ACaseSensitive) {
      var f = null;
      f = this.FFilter.Add$1();
      f.FCondition = ACondition;
      f.FCaseSensitive = ACaseSensitive;
      this.ApplyFilter();
    };
    this.PickerLookupItem = function (ALookupString, ACaseSensitive) {
      var Result = pas["WEBLib.TMSFNCControlPicker"].TTMSFNCControlPickerFilterItem.$new();
      var vn = null;
      Result.ItemIndex = -1;
      Result.ItemText = "";
      vn = this.LookupNode(ALookupString + "*",false,-1,ACaseSensitive,true,true);
      if (vn != null) {
        Result.ItemIndex = vn.FRow;
        Result.ItemText = vn.GetText(0);
      };
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCControlPicker"].ITMSFNCControlPickerFull);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTMSFNCTreeViewColumnOpen",pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumn,function () {
    });
  };
},["Math","SysUtils","WEBLib.TMSFNCUtils","WEBLib.Graphics","WEBLib.TMSFNCCustomSelector"]);
rtl.module("WEBLib.TMSFNCListBox",["System","Classes","WEBLib.TMSFNCTreeView","WEBLib.TMSFNCStyles","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCTreeViewData","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCCustomTreeView","WEBLib.TMSFNCBitmapContainer","TypInfo","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCControlPicker","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 4;
  this.BLD_VER = 1;
  this.CLP_FMT = "#LISTBOX#";
  this.$rtti.$Class("TTMSFNCCustomListBox");
  this.$rtti.$Class("TTMSFNCListBoxInteraction");
  rtl.createClass(this,"TTMSFNCListBoxItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FTag = 0;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FListBox = null;
      this.FText = "";
      this.FDBKey = "";
      this.FChecked = false;
      this.FDataBoolean = false;
      this.FWordWrapping = false;
      this.FTrimming = 0;
      this.FTextAlign = 0;
      this.FSelectedTextColor = 0;
      this.FTextColor = 0;
      this.FDisabledTextColor = 0;
      this.FEnabled = false;
      this.FBitmapName = "";
      this.FBitmap = null;
      this.FHeight = 0.0;
      this.FDataPointer = null;
      this.FBitmapHeight = 0.0;
      this.FBitmapWidth = 0.0;
    };
    this.$final = function () {
      this.FDataObject = undefined;
      this.FListBox = undefined;
      this.FBitmap = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.UpdateItem();
      };
    };
    this.SetHeight = function (Value) {
      if (this.FHeight !== Value) {
        this.FHeight = Value;
        this.UpdateItem();
      };
    };
    this.SetTrimming = function (Value) {
      if (this.FTrimming !== Value) {
        this.FTrimming = Value;
        this.UpdateItem();
      };
    };
    this.SetWordWrapping = function (Value) {
      if (this.FWordWrapping !== Value) {
        this.FWordWrapping = Value;
        this.UpdateItem();
      };
    };
    this.SetTextAlign = function (Value) {
      if (this.FTextAlign !== Value) {
        this.FTextAlign = Value;
        this.UpdateItem();
      };
    };
    this.SetSelectedTextColor = function (Value) {
      if (this.FSelectedTextColor !== Value) {
        this.FSelectedTextColor = Value;
        this.UpdateItem();
      };
    };
    this.SetTextColor = function (Value) {
      if (this.FTextColor !== Value) {
        this.FTextColor = Value;
        this.UpdateItem();
      };
    };
    this.SetDisabledTextColor = function (Value) {
      if (this.FDisabledTextColor !== Value) {
        this.FDisabledTextColor = Value;
        this.UpdateItem();
      };
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.UpdateItem();
      };
    };
    this.SetBitmapName = function (Value) {
      if (this.FBitmapName !== Value) {
        this.FBitmapName = Value;
        this.UpdateItem();
      };
    };
    this.SetBitmap = function (Value) {
      if (this.FBitmap !== Value) {
        this.FBitmap.Assign(Value);
      };
    };
    this.SetChecked = function (Value) {
      var l = null;
      var n = null;
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        l = this.ListBox();
        if (l != null) {
          n = l.GetNodeForItemIndex(this.GetIndex());
          if ((n != null) && (n.FCheckStates[0] !== this.FChecked)) {
            if (this.FChecked) {
              l.FTreeView.CheckVirtualNode(n,0,false)}
             else l.FTreeView.UnCheckVirtualNode(n,0,false);
          };
          if (l.FTreeView != null) l.FTreeView.Invalidate();
        };
      };
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      var l = null;
      Result = null;
      l = this.ListBox();
      if (l != null) Result = l.GetBitmapContainer();
      return Result;
    };
    this.GetStrippedHTMLText = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(this.FText);
      return Result;
    };
    this.IsHeightStored = function () {
      var Result = false;
      Result = this.FHeight !== -1;
      return Result;
    };
    this.IsBitmapHeightStored = function () {
      var Result = false;
      Result = this.FBitmapHeight !== -1;
      return Result;
    };
    this.IsBitmapWidthStored = function () {
      var Result = false;
      Result = this.FBitmapWidth !== -1;
      return Result;
    };
    this.SetBitmapHeight = function (Value) {
      this.FBitmapHeight = Value;
    };
    this.SetBitmapWidth = function (Value) {
      this.FBitmapWidth = Value;
    };
    this.UpdateItem = function () {
      var l = null;
      l = this.ListBox();
      if (l != null) l.UpdateItems();
    };
    this.Changed$1 = function (Sender) {
      this.UpdateItem();
    };
    this.BitmapChanged = function (Sender) {
      this.UpdateItem();
    };
    this.ListBox = function () {
      var Result = null;
      Result = this.FListBox;
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FListBox = rtl.as(this.FCollection,$mod.TTMSFNCListBoxItems).ListBox();
      this.FTextColor = 0;
      this.FHeight = -1;
      this.FBitmapWidth = -1;
      this.FBitmapHeight = -1;
      this.FEnabled = true;
      this.FSelectedTextColor = 16777215;
      this.FDisabledTextColor = 12632256;
      this.FWordWrapping = false;
      this.FTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading;
      this.FTrimming = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"BitmapChanged");
      if (this.FListBox != null) this.Assign(this.FListBox.FDefaultItem);
      this.UpdateItem();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas.Classes.TCollectionItem.Destroy.call(this);
      this.UpdateItem();
    };
    this.SaveToString = function (ATextOnly) {
      var Result = "";
      var s = "";
      if (!(this.FListBox != null)) return Result;
      Result = "";
      Result = Result + this.FText;
      if (!ATextOnly) Result = Result + "{0}";
      if (!ATextOnly) {
        Result = Result + pas.SysUtils.BoolToStr(this.FChecked,false) + ";";
        Result = Result + this.FBitmapName + ";";
        Result = Result + pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SaveBitmapToHexStr(this.FBitmap) + ";";
        Result = Result + s;
      };
      if (!ATextOnly) {
        Result = Result + "{0}";
        Result = Result + pas.SysUtils.BoolToStr(this.FEnabled,false);
      };
      return Result;
    };
    this.IsSelected = function () {
      var Result = false;
      var i = 0;
      Result = false;
      if (this.FListBox != null) {
        for (var $l = 0, $end = this.FListBox.SelectedItemCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.FListBox.GetSelItem(i) === this) {
            Result = true;
            break;
          };
        };
      };
      return Result;
    };
    this.LoadFromString = function (AString) {
      var k = 0;
      var a = null;
      var s = null;
      var y = 0;
      var st = "";
      var ps = 0;
      var subst = "";
      a = pas.Classes.TStringList.$create("Create$1");
      try {
        st = AString;
        while (st !== "") {
          ps = pas.System.Pos("{0}",st);
          if (ps === 0) {
            a.Add(st);
            break;
          };
          subst = pas.System.Copy(st,1,ps - 1);
          a.Add(subst);
          pas.System.Delete({get: function () {
              return st;
            }, set: function (v) {
              st = v;
            }},1,(ps - 1) + "{0}".length);
        };
        for (var $l = 0, $end = a.GetCount() - 1; $l <= $end; $l++) {
          k = $l;
          if (a.Get(k) !== "") {
            if (k === 0) {
              this.SetText(a.Get(k))}
             else if (k === 1) {
              s = pas.Classes.TStringList.$create("Create$1");
              try {
                pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Split(";",a.Get(k),s,false);
                for (var $l1 = 0, $end1 = s.GetCount() - 1; $l1 <= $end1; $l1++) {
                  y = $l1;
                  if (s.Get(y) !== "") {
                    if (y === 0) {
                      this.SetChecked(pas.SysUtils.StrToBool(s.Get(y)))}
                     else if (y === 1) {
                      this.SetBitmapName(s.Get(y))}
                     else if (y === 2) pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.LoadBitmapFromHexStr(s.Get(y),this.FBitmap);
                  };
                };
              } finally {
                s = rtl.freeLoc(s);
              };
            } else if (k === 2) this.SetEnabled(pas.SysUtils.StrToBool(a.Get(k)));
          };
        };
      } finally {
        a = rtl.freeLoc(a);
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCListBoxItem.isPrototypeOf(Source)) {
        this.FTag = rtl.as(Source,$mod.TTMSFNCListBoxItem).FTag;
        this.FText = rtl.as(Source,$mod.TTMSFNCListBoxItem).FText;
        this.FTrimming = rtl.as(Source,$mod.TTMSFNCListBoxItem).FTrimming;
        this.FWordWrapping = rtl.as(Source,$mod.TTMSFNCListBoxItem).FWordWrapping;
        this.FTextAlign = rtl.as(Source,$mod.TTMSFNCListBoxItem).FTextAlign;
        this.FTextColor = rtl.as(Source,$mod.TTMSFNCListBoxItem).FTextColor;
        this.FSelectedTextColor = rtl.as(Source,$mod.TTMSFNCListBoxItem).FSelectedTextColor;
        this.FDisabledTextColor = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDisabledTextColor;
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCListBoxItem).FEnabled;
        this.FBitmapName = rtl.as(Source,$mod.TTMSFNCListBoxItem).FBitmapName;
        this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCListBoxItem).FBitmap);
        this.FHeight = rtl.as(Source,$mod.TTMSFNCListBoxItem).FHeight;
        this.FBitmapHeight = rtl.as(Source,$mod.TTMSFNCListBoxItem).FBitmapHeight;
        this.FBitmapWidth = rtl.as(Source,$mod.TTMSFNCListBoxItem).FBitmapWidth;
        this.FDataPointer = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataPointer;
        this.FDataBoolean = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataBoolean;
        this.FDataObject = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataObject;
        this.FDataString = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataString;
        this.FDataInteger = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataInteger;
        this.AssignData(Source);
      };
    };
    this.AssignData = function (Source) {
      if ($mod.TTMSFNCListBoxItem.isPrototypeOf(Source)) {
        this.FDataString = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataString;
        this.FDataBoolean = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataBoolean;
        this.FDataObject = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataObject;
        this.FDataInteger = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataInteger;
        this.FDataPointer = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDataPointer;
        this.FDBKey = rtl.as(Source,$mod.TTMSFNCListBoxItem).FDBKey;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapWidth",14,rtl.double,"FBitmapWidth","SetBitmapWidth",4,{stored: "IsBitmapWidthStored"});
    $r.addProperty("BitmapHeight",14,rtl.double,"FBitmapHeight","SetBitmapHeight",4,{stored: "IsBitmapHeightStored"});
    $r.addProperty("BitmapName",2,rtl.string,"FBitmapName","SetBitmapName");
    $r.addProperty("WordWrapping",2,rtl.boolean,"FWordWrapping","SetWordWrapping",4,{Default: false});
    $r.addProperty("Trimming",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],"FTrimming","SetTrimming",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone});
    $r.addProperty("TextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTextAlign","SetTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor",4,{Default: 0});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",4,{Default: 16777215});
    $r.addProperty("DisabledTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledTextColor","SetDisabledTextColor",4,{Default: 12632256});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Height",14,rtl.double,"FHeight","SetHeight",4,{stored: "IsHeightStored"});
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",4,{Default: 0});
  });
  this.TTMSFNCListBoxItemsSortMode = {"0": "ismAscending", ismAscending: 0, "1": "ismDescending", ismDescending: 1};
  this.$rtti.$Enum("TTMSFNCListBoxItemsSortMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCListBoxItemsSortMode});
  this.TTMSFNCListBoxItemsSortKind = {"0": "iskNone", iskNone: 0, "1": "iskAscending", iskAscending: 1, "2": "iskDescending", iskDescending: 2};
  this.$rtti.$Enum("TTMSFNCListBoxItemsSortKind",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCListBoxItemsSortKind});
  rtl.createClass(this,"TTMSFNCListBoxItems",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FListBox = null;
    };
    this.$final = function () {
      this.FListBox = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.GetItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCListBoxItem;
      return Result;
    };
    this.Compare = function (AItem1, AItem2, ACaseSensitive, ASortingMode) {
      var Result = 0;
      var l = null;
      Result = 0;
      l = this.ListBox();
      if (!(l != null)) return Result;
      if (!ACaseSensitive) {
        Result = pas.SysUtils.AnsiCompareStr(pas.SysUtils.UpperCase(AItem1.GetStrippedHTMLText()),pas.SysUtils.UpperCase(AItem2.GetStrippedHTMLText()))}
       else Result = pas.SysUtils.AnsiCompareStr(AItem1.GetStrippedHTMLText(),AItem2.GetStrippedHTMLText());
      var $tmp = ASortingMode;
      if ($tmp === $mod.TTMSFNCListBoxItemsSortMode.ismDescending) Result = Result * -1;
      l.DoItemCompare(AItem1,AItem2,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.QuickSort = function (L, R, ACaseSensitive, ASortingMode) {
      var $Self = this;
      var I = 0;
      var J = 0;
      var p = 0;
      var SortList = null;
      function ExchangeItems(Index1, Index2) {
        var Save = undefined;
        Save = SortList.Get(Index1);
        SortList.Put(Index1,SortList.Get(Index2));
        SortList.Put(Index2,Save);
      };
      SortList = $Self.FItems;
      do {
        I = L;
        J = R;
        p = (L + R) >>> 1;
        do {
          while (this.Compare(this.GetItem$1(I),this.GetItem$1(p),ACaseSensitive,ASortingMode) < 0) I += 1;
          while (this.Compare(this.GetItem$1(J),this.GetItem$1(p),ACaseSensitive,ASortingMode) > 0) J -= 1;
          if (I <= J) {
            ExchangeItems(I,J);
            if (p === I) {
              p = J}
             else if (p === J) p = I;
            I += 1;
            J -= 1;
          };
        } while (!(I > J));
        if (L < J) this.QuickSort(L,J,ACaseSensitive,ASortingMode);
        L = I;
      } while (!(I >= R));
    };
    this.ListBox = function () {
      var Result = null;
      Result = this.FListBox;
      return Result;
    };
    this.Create$3 = function (AListBox) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AListBox,this.GetItemClass());
      this.FListBox = AListBox;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Add$2 = function (AText) {
      var Result = null;
      var it = null;
      it = this.Add$1();
      it.SetText(AText);
      Result = it;
      return Result;
    };
    this.AddStrings = function (AItems, AClear) {
      var s = "";
      var l = null;
      l = this.ListBox();
      if (l != null) l.BeginUpdate();
      try {
        if (AClear) this.Clear$1();
        var $in = AItems.GetEnumerator();
        try {
          while ($in.MoveNext()) {
            s = $in.GetCurrent();
            this.Add$2(s);
          }
        } finally {
          $in = rtl.freeLoc($in)
        };
      } finally {
        if (l != null) l.EndUpdate();
      };
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.Clear$1 = function () {
      var l = null;
      l = this.ListBox();
      if (l != null) l.BeginUpdate();
      pas.Classes.TCollection.Clear.call(this);
      if (l != null) l.EndUpdate();
    };
    this.Sort$1 = function (ACaseSensitive, ASortingMode) {
      var l = null;
      l = this.ListBox();
      if (l != null) {
        l.FSortMode = ASortingMode;
        l.BeginUpdate();
        this.BeginUpdate();
        if (this.GetCount() > 1) this.QuickSort(0,this.GetCount() - 1,ACaseSensitive,ASortingMode);
        this.EndUpdate();
        l.EndUpdate();
      };
    };
    this.FindItem = function (AText) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.GetItem$1(I).FText === AText) {
          Result = this.GetItem$1(I);
          return Result;
        };
      };
      return Result;
    };
  });
  rtl.createClass(this,"TTMSFNCListBoxLookup",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetAutoSelect = function () {
      var Result = false;
      Result = false;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) Result = this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FAutoSelect;
      return Result;
    };
    this.GetCaseSensitive = function () {
      var Result = false;
      Result = false;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) Result = this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FCaseSensitive;
      return Result;
    };
    this.GetEnabled = function () {
      var Result = false;
      Result = false;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) Result = this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FEnabled;
      return Result;
    };
    this.GetIncremental = function () {
      var Result = false;
      Result = false;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) Result = this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FIncremental;
      return Result;
    };
    this.SetAutoSelect = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FAutoSelect = Value;
    };
    this.SetCaseSensitive = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FCaseSensitive = Value;
    };
    this.SetEnabled = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FEnabled = Value;
    };
    this.SetIncremental = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null)) this.FOwner.FListBox.FTreeView.FInteraction.FLookup.FIncremental = Value;
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("CaseSensitive",3,rtl.boolean,"GetCaseSensitive","SetCaseSensitive",4,{Default: false});
    $r.addProperty("Enabled",3,rtl.boolean,"GetEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Incremental",3,rtl.boolean,"GetIncremental","SetIncremental",4,{Default: true});
    $r.addProperty("AutoSelect",3,rtl.boolean,"GetAutoSelect","SetAutoSelect",4,{Default: true});
  });
  rtl.createClass(this,"TTMSFNCListBoxFiltering",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetDropDownHeight = function () {
      var Result = 0;
      Result = 120;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null) && (this.FOwner.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FOwner.FListBox.FTreeView.FColumns.GetItem$1(0).FFiltering.FDropDownHeight;
      return Result;
    };
    this.GetDropDownWidth = function () {
      var Result = 0;
      Result = 100;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null) && (this.FOwner.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FOwner.FListBox.FTreeView.FColumns.GetItem$1(0).FFiltering.FDropDownWidth;
      return Result;
    };
    this.GetEnabled = function () {
      var Result = false;
      Result = false;
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null) && (this.FOwner.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FOwner.FListBox.FTreeView.FColumns.GetItem$1(0).FFiltering.FEnabled;
      return Result;
    };
    this.SetDropDownHeight = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null) && (this.FOwner.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FOwner.FListBox.FTreeView.FColumns.GetItem$1(0).FFiltering.FDropDownHeight = Value;
    };
    this.SetDropDownWidth = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null) && (this.FOwner.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FOwner.FListBox.FTreeView.FColumns.GetItem$1(0).FFiltering.FDropDownWidth = Value;
    };
    this.SetEnabled = function (Value) {
      if ((this.FOwner != null) && (this.FOwner.FListBox != null) && (this.FOwner.FListBox.FTreeView != null) && (this.FOwner.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FOwner.FListBox.FTreeView.FColumns.GetItem$1(0).FFiltering.SetEnabled(Value);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Enabled",3,rtl.boolean,"GetEnabled","SetEnabled",4,{Default: false});
    $r.addProperty("DropDownWidth",3,rtl.longint,"GetDropDownWidth","SetDropDownWidth",4,{Default: 100});
    $r.addProperty("DropDownHeight",3,rtl.longint,"GetDropDownHeight","SetDropDownHeight",4,{Default: 120});
  });
  this.TTMSFNCListBoxMouseEditMode = {"0": "lmemDoubleClick", lmemDoubleClick: 0, "1": "lmemSingleClick", lmemSingleClick: 1, "2": "lmemSingleClickOnSelectedItem", lmemSingleClickOnSelectedItem: 2};
  this.$rtti.$Enum("TTMSFNCListBoxMouseEditMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCListBoxMouseEditMode});
  this.TTMSFNCListBoxClipboardMode = {"0": "lcmNone", lcmNone: 0, "1": "lcmTextOnly", lcmTextOnly: 1, "2": "lcmFull", lcmFull: 2};
  this.$rtti.$Enum("TTMSFNCListBoxClipboardMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCListBoxClipboardMode});
  this.TTMSFNCListBoxDragDropMode = {"0": "ldmNone", ldmNone: 0, "1": "ldmMove", ldmMove: 1, "2": "ldmCopy", ldmCopy: 2};
  this.$rtti.$Enum("TTMSFNCListBoxDragDropMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCListBoxDragDropMode});
  this.TTMSFNCListBoxSorting = {"0": "lcsNone", lcsNone: 0, "1": "lcsNormal", lcsNormal: 1, "2": "lcsNormalCaseSensitive", lcsNormalCaseSensitive: 2};
  this.$rtti.$Enum("TTMSFNCListBoxSorting",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCListBoxSorting});
  rtl.createClass(this,"TTMSFNCListBoxInteraction",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FListBox = null;
      this.FLookup = null;
      this.FFiltering = null;
    };
    this.$final = function () {
      this.FListBox = undefined;
      this.FLookup = undefined;
      this.FFiltering = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetMultiSelect = function () {
      var Result = false;
      Result = false;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FInteraction.FMultiSelect;
      return Result;
    };
    this.SetMultiSelect = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FInteraction.SetMultiSelect(Value);
    };
    this.GetClipboardMode = function () {
      var Result = 0;
      var i = 0;
      Result = $mod.TTMSFNCListBoxClipboardMode.lcmNone;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        i = this.FListBox.FTreeView.FInteraction.FClipboardMode;
        Result = i;
      };
      return Result;
    };
    this.GetDragDropMode = function () {
      var Result = 0;
      var i = 0;
      Result = $mod.TTMSFNCListBoxDragDropMode.ldmNone;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        i = this.FListBox.FTreeView.FInteraction.FDragDropMode;
        Result = i;
      };
      return Result;
    };
    this.GetReorder = function () {
      var Result = false;
      Result = false;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FInteraction.FReorder;
      return Result;
    };
    this.GetTouchScrolling = function () {
      var Result = false;
      Result = true;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FInteraction.FTouchScrolling;
      return Result;
    };
    this.SetDragDropMode = function (Value) {
      var i = 0;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        i = Value;
        this.FListBox.FTreeView.FInteraction.SetDragDropMode(i);
      };
    };
    this.SetFiltering = function (Value) {
      this.FFiltering.Assign(Value);
    };
    this.SetLookup = function (Value) {
      this.FLookup.Assign(Value);
    };
    this.SetReorder = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FInteraction.SetReorder(Value);
    };
    this.SetTouchScrolling = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FInteraction.SetTouchScrolling(Value);
    };
    this.SetClipboardMode = function (Value) {
      var i = 0;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        i = Value;
        this.FListBox.FTreeView.FInteraction.FClipboardMode = i;
      };
    };
    this.GetSorting = function () {
      var Result = 0;
      Result = $mod.TTMSFNCListBoxSorting.lcsNone;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) {
        var $tmp = this.FListBox.FTreeView.FColumns.GetItem$1(0).FSorting;
        if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNone) {
          Result = $mod.TTMSFNCListBoxSorting.lcsNone}
         else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNormal) {
          Result = $mod.TTMSFNCListBoxSorting.lcsNormal}
         else if ($tmp === pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNormalCaseSensitive) Result = $mod.TTMSFNCListBoxSorting.lcsNormalCaseSensitive;
      };
      return Result;
    };
    this.SetSorting = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) {
        var $tmp = Value;
        if ($tmp === $mod.TTMSFNCListBoxSorting.lcsNone) {
          this.FListBox.FTreeView.FColumns.GetItem$1(0).SetSorting(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNone)}
         else if ($tmp === $mod.TTMSFNCListBoxSorting.lcsNormal) {
          this.FListBox.FTreeView.FColumns.GetItem$1(0).SetSorting(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNormal)}
         else if ($tmp === $mod.TTMSFNCListBoxSorting.lcsNormalCaseSensitive) this.FListBox.FTreeView.FColumns.GetItem$1(0).SetSorting(pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewColumnSorting.tcsNormalCaseSensitive);
      };
    };
    this.Create$1 = function (AListBox) {
      this.FListBox = AListBox;
      this.FLookup = $mod.TTMSFNCListBoxLookup.$create("Create$1",[this]);
      this.FFiltering = $mod.TTMSFNCListBoxFiltering.$create("Create$1",[this]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FLookup");
      rtl.free(this,"FFiltering");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCListBoxInteraction.isPrototypeOf(Source)) {
        this.FLookup.Assign(rtl.as(Source,$mod.TTMSFNCListBoxInteraction).FLookup);
        this.FFiltering.Assign(rtl.as(Source,$mod.TTMSFNCListBoxInteraction).FFiltering);
      };
    };
    var $r = this.$rtti;
    $r.addProperty("MultiSelect",3,rtl.boolean,"GetMultiSelect","SetMultiSelect",4,{Default: false});
    $r.addProperty("TouchScrolling",3,rtl.boolean,"GetTouchScrolling","SetTouchScrolling",4,{Default: true});
    $r.addProperty("ClipboardMode",3,$mod.$rtti["TTMSFNCListBoxClipboardMode"],"GetClipboardMode","SetClipboardMode",4,{Default: $mod.TTMSFNCListBoxClipboardMode.lcmNone});
    $r.addProperty("Reorder",3,rtl.boolean,"GetReorder","SetReorder",4,{Default: false});
    $r.addProperty("DragDropMode",3,$mod.$rtti["TTMSFNCListBoxDragDropMode"],"GetDragDropMode","SetDragDropMode",4,{Default: $mod.TTMSFNCListBoxDragDropMode.ldmNone});
    $r.addProperty("Lookup",2,$mod.$rtti["TTMSFNCListBoxLookup"],"FLookup","SetLookup");
    $r.addProperty("Filtering",2,$mod.$rtti["TTMSFNCListBoxFiltering"],"FFiltering","SetFiltering");
    $r.addProperty("Sorting",3,$mod.$rtti["TTMSFNCListBoxSorting"],"GetSorting","SetSorting",4,{Default: $mod.TTMSFNCListBoxSorting.lcsNone});
  });
  this.TTMSFNCListBoxItemHeightMode = {"0": "lihmFixed", lihmFixed: 0, "1": "lihmVariable", lihmVariable: 1};
  this.$rtti.$Enum("TTMSFNCListBoxItemHeightMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCListBoxItemHeightMode});
  rtl.createClass(this,"TTMSFNCListBoxItemsAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FListBox = null;
    };
    this.$final = function () {
      this.FListBox = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetFont = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FFont;
      return Result;
    };
    this.GetSelectedFill = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FSelectedFill;
      return Result;
    };
    this.SetFont = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FFont.Assign(Value);
    };
    this.SetSelectedFill = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FSelectedFill.Assign(Value);
    };
    this.GetSelectedStroke = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FSelectedStroke;
      return Result;
    };
    this.SetSelectedStroke = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FSelectedStroke.Assign(Value);
    };
    this.GetDisabledFill = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FDisabledFill;
      return Result;
    };
    this.GetDisabledStroke = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FDisabledStroke;
      return Result;
    };
    this.GetFill = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FFill;
      return Result;
    };
    this.GetStroke = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FStroke;
      return Result;
    };
    this.SetDisabledFill = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FDisabledFill.Assign(Value);
    };
    this.SetDisabledStroke = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FDisabledStroke.Assign(Value);
    };
    this.SetFill = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FFill.Assign(Value);
    };
    this.SetStroke = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.FStroke.Assign(Value);
    };
    this.GetHeightMode = function () {
      var Result = 0;
      var i = 0;
      Result = $mod.TTMSFNCListBoxItemHeightMode.lihmFixed;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        i = this.FListBox.FTreeView.FNodesAppearance.FHeightMode;
        Result = i;
      };
      return Result;
    };
    this.SetHeightMode = function (Value) {
      var i = 0;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        i = Value;
        this.FListBox.FTreeView.FNodesAppearance.SetHeightMode(i);
      };
    };
    this.GetFixedHeight = function () {
      var Result = 0.0;
      Result = 0;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FFixedHeight;
      return Result;
    };
    this.SetFixedHeight = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.SetFixedHeight(Value);
    };
    this.GetShowFocus = function () {
      var Result = false;
      Result = true;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FNodesAppearance.FShowFocus;
      return Result;
    };
    this.SetShowFocus = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FNodesAppearance.SetShowFocus(Value);
    };
    this.Create$1 = function (AListBox) {
      this.FListBox = AListBox;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && this.FListBox.IsDesignTime()) {
        this.FListBox.FTreeView.FNodesAppearance.FDisabledFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
        this.FListBox.FTreeView.FNodesAppearance.FDisabledStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      };
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Font",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"GetFont","SetFont");
    $r.addProperty("Fill",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"GetFill","SetFill");
    $r.addProperty("Stroke",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"GetStroke","SetStroke");
    $r.addProperty("SelectedFill",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"GetSelectedFill","SetSelectedFill");
    $r.addProperty("SelectedStroke",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"GetSelectedStroke","SetSelectedStroke");
    $r.addProperty("DisabledFill",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"GetDisabledFill","SetDisabledFill");
    $r.addProperty("DisabledStroke",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"GetDisabledStroke","SetDisabledStroke");
    $r.addProperty("HeightMode",3,$mod.$rtti["TTMSFNCListBoxItemHeightMode"],"GetHeightMode","SetHeightMode",4,{Default: $mod.TTMSFNCListBoxItemHeightMode.lihmFixed});
    $r.addProperty("FixedHeight",3,rtl.double,"GetFixedHeight","SetFixedHeight");
    $r.addProperty("ShowFocus",3,rtl.boolean,"GetShowFocus","SetShowFocus",4,{Default: true});
  });
  this.$rtti.$DynArray("TTMSFNCListBoxItemArray",{eltype: rtl.longint});
  rtl.createClass(this,"TTMSFNCListBoxHeader",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FListBox = null;
    };
    this.$final = function () {
      this.FListBox = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetVisible = function () {
      var Result = false;
      Result = false;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclTop in this.FListBox.FTreeView.FColumnsAppearance.FLayouts;
      return Result;
    };
    this.SetVisible = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) {
        if (Value) {
          this.FListBox.FTreeView.FColumnsAppearance.SetLayouts(rtl.createSet(pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewColumnsLayout.tclTop))}
         else this.FListBox.FTreeView.FColumnsAppearance.SetLayouts({});
      };
    };
    this.GetText = function () {
      var Result = "";
      Result = "";
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FListBox.FTreeView.FColumns.GetItem$1(0).FText;
      return Result;
    };
    this.SetText = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FListBox.FTreeView.FColumns.GetItem$1(0).SetText(Value);
    };
    this.GetFill = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FColumnsAppearance.FTopFill;
      return Result;
    };
    this.GetHorizontalTextAlign = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FListBox.FTreeView.FColumns.GetItem$1(0).FHorizontalTextAlign;
      return Result;
    };
    this.GetSize = function () {
      var Result = 0.0;
      Result = 25;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FColumnsAppearance.FTopSize;
      return Result;
    };
    this.GetStroke = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FColumnsAppearance.FTopStroke;
      return Result;
    };
    this.SetFill = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FColumnsAppearance.FTopFill.Assign(Value);
    };
    this.SetHorizontalTextAlign = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FListBox.FTreeView.FColumns.GetItem$1(0).SetHorizontalTextAlign(Value);
    };
    this.SetSize = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FColumnsAppearance.SetTopSize(Value);
    };
    this.SetStroke = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FColumnsAppearance.FTopStroke.Assign(Value);
    };
    this.GetVerticalTextAlign = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FListBox.FTreeView.FColumns.GetItem$1(0).FVerticalTextAlign;
      return Result;
    };
    this.SetVerticalTextAlign = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FListBox.FTreeView.FColumns.GetItem$1(0).SetVerticalTextAlign(Value);
    };
    this.GetFont = function () {
      var Result = null;
      Result = null;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FColumnsAppearance.FTopFont;
      return Result;
    };
    this.GetTrimming = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FListBox.FTreeView.FColumns.GetItem$1(0).FTrimming;
      return Result;
    };
    this.GetWordWrapping = function () {
      var Result = false;
      Result = false;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) Result = this.FListBox.FTreeView.FColumns.GetItem$1(0).FWordWrapping;
      return Result;
    };
    this.SetFont = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FColumnsAppearance.FTopFont.Assign(Value);
    };
    this.SetTrimming = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FListBox.FTreeView.FColumns.GetItem$1(0).SetTrimming(Value);
    };
    this.SetWordWrapping = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null) && (this.FListBox.FTreeView.FColumns.GetCount() > 0)) this.FListBox.FTreeView.FColumns.GetItem$1(0).SetWordWrapping(Value);
    };
    this.GetSortIndicatorColor = function () {
      var Result = 0;
      Result = 16297243;
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) Result = this.FListBox.FTreeView.FColumnsAppearance.FSortIndicatorColor;
      return Result;
    };
    this.SetSortIndicatorColor = function (Value) {
      if ((this.FListBox != null) && (this.FListBox.FTreeView != null)) this.FListBox.FTreeView.FColumnsAppearance.SetSortIndicatorColor(Value);
    };
    this.Create$1 = function (AListBox) {
      this.FListBox = AListBox;
      return this;
    };
    var $r = this.$rtti;
    $r.addProperty("Visible",3,rtl.boolean,"GetVisible","SetVisible",4,{Default: false});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Fill",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"GetFill","SetFill");
    $r.addProperty("Font",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"GetFont","SetFont");
    $r.addProperty("Stroke",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"GetStroke","SetStroke");
    $r.addProperty("HorizontalTextAlign",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"GetHorizontalTextAlign","SetHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalTextAlign",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"GetVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("WordWrapping",3,rtl.boolean,"GetWordWrapping","SetWordWrapping",4,{Default: false});
    $r.addProperty("Trimming",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],"GetTrimming","SetTrimming",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone});
    $r.addProperty("Size",3,rtl.double,"GetSize","SetSize");
    $r.addProperty("SortIndicatorColor",3,pas["WEBLib.Graphics"].$rtti["TColor"],"GetSortIndicatorColor","SetSortIndicatorColor",4,{Default: 16297243});
  });
  rtl.createClass(this,"TTMSFNCListBoxCopyItems",this.TTMSFNCListBoxItems,function () {
  });
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeDrawSortIndicatorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASortIndex",rtl.longint],["ASortKind",this.$rtti["TTMSFNCListBoxItemsSortKind"]],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterDrawSortIndicatorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASortIndex",rtl.longint],["ASortKind",this.$rtti["TTMSFNCListBoxItemsSortKind"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxNeedFilterDropDownDataEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AValues",pas.Classes.$rtti["TStrings"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxItemAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AAnchor",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxHeaderAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AAnchor",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeReorderItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromItem",this.$rtti["TTMSFNCListBoxItem"]],["AToItem",this.$rtti["TTMSFNCListBoxItem"]],["ACanReorder",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterReorderItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromItem",this.$rtti["TTMSFNCListBoxItem"]],["AToItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeDropItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromItem",this.$rtti["TTMSFNCListBoxItem"]],["AToItem",this.$rtti["TTMSFNCListBoxItem"]],["ACanDrop",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterDropItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFromItem",this.$rtti["TTMSFNCListBoxItem"]],["AToItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeCopyToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanCopy",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeCutToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanCut",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforePasteFromClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACanPaste",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterCopyToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterCutToClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterPasteFromClipboardEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeDrawItemTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AText",rtl.string],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterDrawItemTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxItemSelectedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxItemClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxItemMouseEnterEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxItemMouseLeaveEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxScrollEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["APosition",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxGetItemHeightEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AHeight",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeDrawItemIconEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AIcon",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterDrawItemIconEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AIcon",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeDrawItemCheckEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["ACheck",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterDrawItemCheckEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["ACheck",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxBeforeDrawItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxAfterDrawItemEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AItem",this.$rtti["TTMSFNCListBoxItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxItemCompareEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Item1",this.$rtti["TTMSFNCListBoxItem"]],["Item2",this.$rtti["TTMSFNCListBoxItem"]],["ACompareResult",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCListBoxFilterSelectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACondition",rtl.string,1]]), methodkind: 0});
  this.TTMSFNCListBoxFilterOperation = {"0": "lfoSHORT", lfoSHORT: 0, "1": "lfoNONE", lfoNONE: 1, "2": "lfoAND", lfoAND: 2, "3": "lfoXOR", lfoXOR: 3, "4": "lfoOR", lfoOR: 4};
  this.$rtti.$Enum("TTMSFNCListBoxFilterOperation",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCListBoxFilterOperation});
  rtl.createClass(this,"TTMSFNCListBoxFilterData",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCondition = "";
      this.FCaseSensitive = false;
      this.FSuffix = "";
      this.FPrefix = "";
      this.FOperation = 0;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FCaseSensitive = true;
      return this;
    };
    this.Assign = function (Source) {
      var ASrcFilterData = null;
      ASrcFilterData = rtl.as(Source,$mod.TTMSFNCListBoxFilterData);
      if (ASrcFilterData != null) {
        this.FCondition = ASrcFilterData.FCondition;
        this.FCaseSensitive = ASrcFilterData.FCaseSensitive;
        this.FPrefix = ASrcFilterData.FPrefix;
        this.FSuffix = ASrcFilterData.FSuffix;
        this.FOperation = ASrcFilterData.FOperation;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Condition",0,rtl.string,"FCondition","FCondition");
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive",4,{Default: true});
    $r.addProperty("Prefix",0,rtl.string,"FPrefix","FPrefix");
    $r.addProperty("Suffix",0,rtl.string,"FSuffix","FSuffix");
    $r.addProperty("Operation",0,$mod.$rtti["TTMSFNCListBoxFilterOperation"],"FOperation","FOperation");
  });
  rtl.createClass(this,"TTMSFNCListBoxFilter",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.GetItem.call(this,Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      pas.Classes.TCollection.SetItem.call(this,Index,Value);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TTMSFNCListBoxFilterData);
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      if (this.GetCount() === 1) {
        Result.FOperation = $mod.TTMSFNCListBoxFilterOperation.lfoNONE}
       else Result.FOperation = $mod.TTMSFNCListBoxFilterOperation.lfoAND;
      return Result;
    };
    this.Insert$1 = function (index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,index);
      return Result;
    };
  });
  this.$rtti.$DynArray("TTMSFNCListBoxFilteredItems",{eltype: this.$rtti["TTMSFNCListBoxItem"]});
  rtl.createClass(this,"TTMSFNCCustomListBox",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FUpdateCount$1 = 0;
      this.FSaveSelectedItemIndex = 0;
      this.FScrollToItem = false;
      this.FCopyItems = null;
      this.FAccepted = false;
      this.FItems = null;
      this.FTreeView = null;
      this.FDefaultItem = null;
      this.FItemsAppearance = null;
      this.FOnItemSelected = null;
      this.FInteraction = null;
      this.FHeader = null;
      this.FOnItemAnchorClick = null;
      this.FOnAfterCutToClipboard = null;
      this.FOnBeforePasteFromClipboard = null;
      this.FOnAfterReorderItem = null;
      this.FOnBeforeDropItem = null;
      this.FOnBeforeDrawItemText = null;
      this.FOnVScroll = null;
      this.FOnBeforeCopyToClipboard = null;
      this.FOnItemDblClick = null;
      this.FOnBeforeDrawItemCheck = null;
      this.FOnAfterDrawItemIcon = null;
      this.FOnBeforeDrawItem = null;
      this.FOnAfterPasteFromClipboard = null;
      this.FOnItemClick = null;
      this.FOnAfterDropItem = null;
      this.FOnAfterDrawItemText = null;
      this.FOnItemCompare = null;
      this.FOnBeforeCutToClipboard = null;
      this.FOnBeforeReorderItem = null;
      this.FOnNeedFilterDropDownData = null;
      this.FOnAfterCopyToClipboard = null;
      this.FOnFilterSelect = null;
      this.FOnAfterDrawItemCheck = null;
      this.FOnAfterDrawItem = null;
      this.FOnBeforeDrawItemIcon = null;
      this.FFilter = null;
      this.FOnBeforeDrawSortIndicator = null;
      this.FOnAfterDrawSortIndicator = null;
      this.FOnItemMouseLeave = null;
      this.FOnItemMouseEnter = null;
      this.FSortMode = 0;
      this.FOnHeaderAnchorClick = null;
      this.FGlobalFont = null;
    };
    this.$final = function () {
      this.FCopyItems = undefined;
      this.FItems = undefined;
      this.FTreeView = undefined;
      this.FDefaultItem = undefined;
      this.FItemsAppearance = undefined;
      this.FOnItemSelected = undefined;
      this.FInteraction = undefined;
      this.FHeader = undefined;
      this.FOnItemAnchorClick = undefined;
      this.FOnAfterCutToClipboard = undefined;
      this.FOnBeforePasteFromClipboard = undefined;
      this.FOnAfterReorderItem = undefined;
      this.FOnBeforeDropItem = undefined;
      this.FOnBeforeDrawItemText = undefined;
      this.FOnVScroll = undefined;
      this.FOnBeforeCopyToClipboard = undefined;
      this.FOnItemDblClick = undefined;
      this.FOnBeforeDrawItemCheck = undefined;
      this.FOnAfterDrawItemIcon = undefined;
      this.FOnBeforeDrawItem = undefined;
      this.FOnAfterPasteFromClipboard = undefined;
      this.FOnItemClick = undefined;
      this.FOnAfterDropItem = undefined;
      this.FOnAfterDrawItemText = undefined;
      this.FOnItemCompare = undefined;
      this.FOnBeforeCutToClipboard = undefined;
      this.FOnBeforeReorderItem = undefined;
      this.FOnNeedFilterDropDownData = undefined;
      this.FOnAfterCopyToClipboard = undefined;
      this.FOnFilterSelect = undefined;
      this.FOnAfterDrawItemCheck = undefined;
      this.FOnAfterDrawItem = undefined;
      this.FOnBeforeDrawItemIcon = undefined;
      this.FFilter = undefined;
      this.FOnBeforeDrawSortIndicator = undefined;
      this.FOnAfterDrawSortIndicator = undefined;
      this.FOnItemMouseLeave = undefined;
      this.FOnItemMouseEnter = undefined;
      this.FOnHeaderAnchorClick = undefined;
      this.FGlobalFont = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.SetDefaultItem = function (Value) {
      this.FDefaultItem.Assign(Value);
    };
    this.SetItemsAppearance = function (Value) {
      this.FItemsAppearance.Assign(Value);
    };
    this.GetItemIndex = function () {
      var Result = 0;
      Result = -1;
      if ((this.FTreeView != null) && (this.FTreeView.SelectedVirtualNodeCount() > 0) && (this.FTreeView.GetSelVirtualNode(0) != null)) Result = this.FTreeView.GetSelVirtualNode(0).FRow;
      return Result;
    };
    this.SetItemIndex = function (Value) {
      this.SelectItem(Value);
    };
    this.SetInteraction = function (Value) {
      this.FInteraction.Assign(Value);
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetBitmapContainer();
      return Result;
    };
    this.SetBitmapContainer = function (Value) {
      this.FTreeView.SetBitmapContainer(Value);
    };
    this.SetHeader = function (Value) {
      this.FHeader.Assign(Value);
    };
    this.GetSelectedItem = function () {
      var Result = null;
      Result = null;
      if ((this.GetItemIndex() >= 0) && (this.GetItemIndex() <= (this.FItems.GetCount() - 1))) Result = this.FItems.GetItem$1(this.GetItemIndex());
      return Result;
    };
    this.SetSelectedItem = function (Value) {
      if (Value != null) this.SetItemIndex(Value.GetIndex());
    };
    this.GetSelItem = function (AIndex) {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.GetItemForNode(this.FTreeView.GetSelVirtualNode(AIndex));
      return Result;
    };
    this.GetVerticalScrollBarVisible = function () {
      var Result = false;
      Result = true;
      if (this.FTreeView != null) Result = this.FTreeView.FVerticalScrollBarVisible;
      return Result;
    };
    this.SetVerticalScrollBarVisible = function (Value) {
      if (this.FTreeView != null) this.FTreeView.SetVerticalScrollBarVisible(Value);
    };
    this.GetFill = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.FFill;
      return Result;
    };
    this.GetStroke = function () {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.FStroke;
      return Result;
    };
    this.SetFill$1 = function (Value) {
      if (this.FTreeView != null) this.FTreeView.FFill.Assign(Value);
    };
    this.SetStroke$1 = function (Value) {
      if (this.FTreeView != null) this.FTreeView.FStroke.Assign(Value);
    };
    this.GetFilteredItems = function () {
      var Result = [];
      var I = 0;
      var li = null;
      for (var $l = 0, $end = this.FTreeView.FVisibleNodes.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        Result = rtl.arraySetLength(Result,null,rtl.length(Result) + 1);
        li = this.GetItemForNode(this.FTreeView.FVisibleNodes.GetItem(I));
        Result[rtl.length(Result) - 1] = li;
      };
      return Result;
    };
    this.SetGlobalFont = function (Value) {
      this.FGlobalFont.Assign(Value);
    };
    this.DataGetItemIndex = function () {
      var Result = 0;
      Result = this.GetItemIndex();
      return Result;
    };
    this.DataSetItemIndex = function (AValue) {
      this.SetItemIndex(AValue);
      this.FSaveSelectedItemIndex = AValue;
      this.FScrollToItem = true;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/" + pas.SysUtils.LowerCase(this.$classname);
      return Result;
    };
    this.GetSubComponentArray = function () {
      var Result = [];
      Result = rtl.arraySetLength(Result,null,1);
      Result[0] = this.FTreeView;
      return Result;
    };
    this.IsAppearanceProperty = function (AObject, APropertyName, APropertyType) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.IsAppearanceProperty.call(this,AObject,APropertyName,APropertyType);
      Result = Result || (APropertyName === "Header");
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,1,0);
      return Result;
    };
    this.CreateItems = function () {
      var Result = null;
      Result = $mod.TTMSFNCListBoxItems.$create("Create$3",[this]);
      return Result;
    };
    this.GetItemIndexForNode = function (ANode) {
      var Result = 0;
      Result = -1;
      if (ANode != null) Result = ANode.FRow;
      return Result;
    };
    this.GetItemForNode = function (ANode) {
      var Result = null;
      var i = 0;
      Result = null;
      i = this.GetItemIndexForNode(ANode);
      if ((i >= 0) && (i <= (this.FItems.GetCount() - 1))) Result = this.FItems.GetItem$1(i);
      return Result;
    };
    this.GetNodeForItemIndex = function (AItemIndex) {
      var Result = null;
      Result = null;
      if (this.FTreeView != null) Result = this.FTreeView.GetNodeForRow(AItemIndex);
      return Result;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCCustomListBox);
    };
    this.ApplyStyle = function () {
      var I = 0;
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FDefaultItem.SetTextColor(c);
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FItems.GetItem$1(I).SetTextColor(c);
        };
      };
    };
    this.ResetToDefaultStyle = function () {
      var I = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      this.FDefaultItem.SetTextColor(0x454545);
      this.FDefaultItem.SetSelectedTextColor(this.FDefaultItem.FTextColor);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FItems.GetItem$1(I).SetTextColor(0x454545);
        this.FItems.GetItem$1(I).SetSelectedTextColor(this.FDefaultItem.FTextColor);
      };
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      if (this.FTreeView != null) this.FTreeView.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.UpdateItems = function () {
      var sel = null;
      if (this.IsDestroying()) return;
      if ((this.FTreeView != null) && (this.FUpdateCount$1 === 0)) {
        sel = this.GetSelectedItem();
        this.FTreeView.BeginUpdate();
        this.FTreeView.ClearNodeList();
        this.FTreeView.EndUpdate();
        this.SetSelectedItem(sel);
      };
    };
    this.DoGetNodeHeight = function (Sender, ANode, AColumn, AHeight) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) {
        if (this.FItems.GetItem$1(ANode.FRow).FHeight > -1) AHeight.set(this.FItems.GetItem$1(ANode.FRow).FHeight);
      };
    };
    this.DoGetNodeIcon = function (Sender, ANode, AColumn, ALarge, AIcon) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) {
        if ((this.GetBitmapContainer() != null) && (this.FItems.GetItem$1(ANode.FRow).FBitmapName !== "")) AIcon.set(this.GetBitmapContainer().FindBitmap$1(this.FItems.GetItem$1(ANode.FRow).FBitmapName));
        if (!(AIcon.get() != null)) AIcon.set(this.FItems.GetItem$1(ANode.FRow).FBitmap);
      };
    };
    this.DoGetNodeIconSize = function (Sender, ANode, AColumn, ALarge, AIcon, AIconWidth, AIconHeight) {
      var w = 0.0;
      var h = 0.0;
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) {
        w = this.FItems.GetItem$1(ANode.FRow).FBitmapWidth;
        if (w !== -1) AIconWidth.set(w);
        h = this.FItems.GetItem$1(ANode.FRow).FBitmapHeight;
        if (h !== -1) AIconHeight.set(h);
      };
    };
    this.DoGetNumberOfNodes = function (Sender, ANode, ANumberOfNodes) {
      if (ANode.FLevel === -1) ANumberOfNodes.set(this.FItems.GetCount());
    };
    this.DoGetNodeText = function (Sender, ANode, AColumn, AMode, AText) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) AText.set(this.FItems.GetItem$1(ANode.FRow).FText);
    };
    this.DoGetNodeTrimming = function (Sender, ANode, AColumn, ATrimming) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) ATrimming.set(this.FItems.GetItem$1(ANode.FRow).FTrimming);
    };
    this.DoGetNodeWordWrapping = function (Sender, ANode, AColumn, AWordWrapping) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) AWordWrapping.set(this.FItems.GetItem$1(ANode.FRow).FWordWrapping);
    };
    this.DoGetNodeHorizontalTextAlign = function (Sender, ANode, AColumn, AHorizontalTextAlign) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) AHorizontalTextAlign.set(this.FItems.GetItem$1(ANode.FRow).FTextAlign);
    };
    this.DoGetNodeVerticalTextAlign = function (Sender, ANode, AColumn, AVerticalTextAlign) {
      AVerticalTextAlign.set(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter);
    };
    this.DoGetNodeTextColor = function (Sender, ANode, AColumn, ATextColor) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) ATextColor.set(this.FItems.GetItem$1(ANode.FRow).FTextColor);
    };
    this.DoGetNodeSelectedTextColor = function (Sender, ANode, AColumn, ASelectedTextColor) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) ASelectedTextColor.set(this.FItems.GetItem$1(ANode.FRow).FSelectedTextColor);
    };
    this.DoGetNodeDisabledTextColor = function (Sender, ANode, AColumn, ADisabledTextColor) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) ADisabledTextColor.set(this.FItems.GetItem$1(ANode.FRow).FDisabledTextColor);
    };
    this.DoIsNodeEnabled = function (Sender, ANode, AEnabled) {
      if ((ANode.FRow >= 0) && (ANode.FRow <= (this.FItems.GetCount() - 1))) AEnabled.set(this.FItems.GetItem$1(ANode.FRow).FEnabled);
    };
    this.DoAfterSelectNode = function (Sender, ANode) {
      this.NotifyDataBinderSetActiveRecord();
      if (this.FOnItemSelected != null) this.FOnItemSelected(this,this.GetItemForNode(ANode));
      if ((this.FParent != null) && pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.isPrototypeOf(this.FParent) && (this.FParent.FOwner != null) && pas["WEBLib.TMSFNCControlPicker"].TTMSFNCControlPicker.isPrototypeOf(this.FParent.FOwner)) {
        rtl.as(this.FParent.FOwner,pas["WEBLib.TMSFNCControlPicker"].TTMSFNCControlPicker).UpdateDropDown();
      };
    };
    this.DoNeedFilterDropDownData = function (Sender, AColumn, AValues) {
      if (this.FOnNeedFilterDropDownData != null) this.FOnNeedFilterDropDownData(this,AValues);
    };
    this.DoFilterSelect = function (Sender, AColumn, ACondition) {
      if (this.FOnFilterSelect != null) this.FOnFilterSelect(this,ACondition);
    };
    this.DoBeforeDrawSortIndicator = function (Sender, AGraphics, ARect, AColumn, ASortIndex, ASortKind, ADefaultDraw) {
      var i = 0;
      var sk = 0;
      if (this.FOnBeforeDrawSortIndicator != null) {
        i = ASortKind;
        sk = i;
        this.FOnBeforeDrawSortIndicator(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ASortIndex,sk,ADefaultDraw);
      };
    };
    this.DoAfterDrawSortIndicator = function (Sender, AGraphics, ARect, AColumn, ASortIndex, ASortKind) {
      var i = 0;
      var sk = 0;
      if (this.FOnAfterDrawSortIndicator != null) {
        i = ASortKind;
        sk = i;
        this.FOnAfterDrawSortIndicator(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ASortIndex,sk);
      };
    };
    this.DoBeforeDrawNode = function (Sender, AGraphics, ARect, ANode, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawItem != null) this.FOnBeforeDrawItem(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),AAllow,ADefaultDraw);
    };
    this.DoAfterDrawNode = function (Sender, AGraphics, ARect, ANode) {
      if (this.FOnAfterDrawItem != null) this.FOnAfterDrawItem(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode));
    };
    this.DoItemCompare = function (AItem1, AItem2, ACompareResult) {
      if (this.FOnItemCompare != null) this.FOnItemCompare(this,AItem1,AItem2,ACompareResult);
    };
    this.DoBeforeDrawNodeText = function (Sender, AGraphics, ARect, AColumn, ANode, AText, AAllow) {
      if (this.FOnBeforeDrawItemText != null) this.FOnBeforeDrawItemText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),AText,AAllow);
    };
    this.DoAfterDrawNodeText = function (Sender, AGraphics, ARect, AColumn, ANode, AText) {
      if (this.FOnAfterDrawItemText != null) this.FOnAfterDrawItemText(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),AText);
    };
    this.DoClick = function (Sender) {
      this.Click();
    };
    this.DoDblClick = function (Sender) {
      this.DblClick();
    };
    this.DoBeforeDrawNodeIcon = function (Sender, AGraphics, ARect, AColumn, ANode, AIcon, AAllow) {
      if (this.FOnBeforeDrawItemIcon != null) this.FOnBeforeDrawItemIcon(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),AIcon,AAllow);
    };
    this.DoAfterDrawNodeIcon = function (Sender, AGraphics, ARect, AColumn, ANode, AIcon) {
      if (this.FOnAfterDrawItemIcon != null) this.FOnAfterDrawItemIcon(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),AIcon);
    };
    this.DoBeforeDrawNodeCheck = function (Sender, AGraphics, ARect, AColumn, ANode, ACheck, AAllow) {
      if (this.FOnBeforeDrawItemCheck != null) this.FOnBeforeDrawItemCheck(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),ACheck,AAllow);
    };
    this.DoAfterDrawNodeCheck = function (Sender, AGraphics, ARect, AColumn, ANode, ACheck) {
      if (this.FOnAfterDrawItemCheck != null) this.FOnAfterDrawItemCheck(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),this.GetItemForNode(ANode),ACheck);
    };
    this.DoNodeAnchorClick = function (Sender, ANode, AColumn, AAnchor) {
      if (this.FOnItemAnchorClick != null) {
        this.FOnItemAnchorClick(this,this.GetItemForNode(ANode),AAnchor)}
       else pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
    };
    this.DoColumnAnchorClick = function (Sender, AColumn, AAnchor) {
      if (this.FOnHeaderAnchorClick != null) {
        this.FOnHeaderAnchorClick(this,AAnchor)}
       else pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
    };
    this.DoNodeClick = function (Sender, ANode) {
      if (this.FOnItemClick != null) this.FOnItemClick(this,this.GetItemForNode(ANode));
    };
    this.DoNodeMouseEnter = function (Sender, ANode) {
      if (this.FOnItemMouseEnter != null) this.FOnItemMouseEnter(this,this.GetItemForNode(ANode));
    };
    this.DoNodeMouseLeave = function (Sender, ANode) {
      if (this.FOnItemMouseLeave != null) this.FOnItemMouseLeave(this,this.GetItemForNode(ANode));
    };
    this.DoNodeDblClick = function (Sender, ANode) {
      if (this.FOnItemDblClick != null) this.FOnItemDblClick(this,this.GetItemForNode(ANode));
    };
    this.DoVScroll = function (Sender, APosition) {
      if (this.FOnVScroll != null) this.FOnVScroll(this,APosition);
    };
    this.DoTreeViewMouseWheelDown = function (Sender, Shift, MousePos, Handled) {
      if (this.FOnMouseWheelDown != null) this.FOnMouseWheelDown(this,rtl.refSet(Shift),pas.Types.TPoint.$clone(MousePos),Handled);
    };
    this.DoTreeViewMouseWheelUp = function (Sender, Shift, MousePos, Handled) {
      if (this.FOnMouseWheelUp != null) this.FOnMouseWheelUp(this,rtl.refSet(Shift),pas.Types.TPoint.$clone(MousePos),Handled);
    };
    this.DoTreeViewKeyDown = function (Sender, Key, Shift) {
      if (this.FOnKeyDown != null) this.FOnKeyDown(this,Key,rtl.refSet(Shift));
    };
    this.DoTreeViewKeyUp = function (Sender, Key, Shift) {
      if (this.FOnKeyUp != null) this.FOnKeyUp(this,Key,rtl.refSet(Shift));
    };
    this.DoTreeViewKeyPress = function (Sender, AChar) {
      if (this.FOnKeyPress != null) this.FOnKeyPress(this,AChar);
    };
    this.DoBeforeCutToClipboard = function (Sender, ACanCut) {
      if (this.FOnBeforeCutToClipboard != null) this.FOnBeforeCutToClipboard(this,ACanCut);
    };
    this.DoBeforeCopyToClipboard = function (Sender, ACanCopy) {
      if (this.FOnBeforeCopyToClipboard != null) this.FOnBeforeCopyToClipboard(this,ACanCopy);
    };
    this.DoBeforePasteFromClipboard = function (Sender, ACanPaste) {
      if (this.FOnBeforePasteFromClipboard != null) this.FOnBeforePasteFromClipboard(this,ACanPaste);
    };
    this.DoAfterCutToClipboard = function (Sender) {
      if (this.FOnAfterCutToClipboard != null) this.FOnAfterCutToClipboard(this);
    };
    this.DoAfterCopyToClipboard = function (Sender) {
      if (this.FOnAfterCopyToClipboard != null) this.FOnAfterCopyToClipboard(this);
    };
    this.DoAfterPasteFromClipboard = function (Sender) {
      if (this.FOnAfterPasteFromClipboard != null) this.FOnAfterPasteFromClipboard(this);
    };
    this.DoBeforeReorderItem = function (AFromItem, AToItem, ACanReorder) {
      if (this.FOnBeforeReorderItem != null) this.FOnBeforeReorderItem(this,AFromItem,AToItem,ACanReorder);
    };
    this.DoAfterReorderItem = function (AFromItem, AToItem) {
      if (this.FOnAfterReorderItem != null) this.FOnAfterReorderItem(this,AFromItem,AToItem);
    };
    this.DoBeforeDropItem = function (AFromItem, AToItem, ACanDrop) {
      if (this.FOnBeforeDropItem != null) this.FOnBeforeDropItem(this,AFromItem,AToItem,ACanDrop);
    };
    this.DoAfterDropItem = function (AFromItem, AToItem) {
      if (this.FOnAfterDropItem != null) this.FOnAfterDropItem(this,AFromItem,AToItem);
    };
    this.CustomizeTreeView = function (ATreeView) {
    };
    this.DoCustomDragOver = function (Sender, Source, Point, Accept) {
      Accept.set((this.FInteraction.GetDragDropMode() !== $mod.TTMSFNCListBoxDragDropMode.ldmNone) && pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.isPrototypeOf(Source) && (rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FDragNode != null));
      this.FAccepted = Accept.get();
    };
    this.DoCustomDragDrop = function (Sender, Source, Point) {
      var di = null;
      var dragi = null;
      var li = null;
      var dragn = null;
      var b = false;
      if (this.FAccepted && (Source != null) && pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView.isPrototypeOf(Source) && $mod.TTMSFNCCustomListBox.isPrototypeOf(rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent) && (Source.FInteraction.FDragDropMode !== pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewDragDropMode.tdmNone)) {
        dragn = rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FDragNode;
        if (dragn != null) {
          dragi = rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.GetItemForNode(dragn);
          di = this.XYToItem(Point.X,Point.Y);
          if ((di !== dragi) && (dragi != null)) {
            b = true;
            this.DoBeforeDropItem(dragi,di,{get: function () {
                return b;
              }, set: function (v) {
                b = v;
              }});
            if (b) {
              this.BeginUpdate();
              rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.BeginUpdate();
              if (di != null) {
                var $tmp = rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.FInteraction.GetDragDropMode();
                if ($tmp === $mod.TTMSFNCListBoxDragDropMode.ldmMove) {
                  if (rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent === this) {
                    dragi.SetIndex(di.GetIndex());
                  } else {
                    li = this.FItems.Add$1();
                    li.Assign(dragi);
                    li.SetIndex(di.GetIndex());
                    rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.FItems.Delete(dragi.GetIndex());
                  };
                } else if ($tmp === $mod.TTMSFNCListBoxDragDropMode.ldmCopy) {
                  li = this.FItems.Add$1();
                  li.Assign(dragi);
                  li.SetIndex(di.GetIndex());
                };
              } else {
                li = this.FItems.Add$1();
                li.Assign(dragi);
                var $tmp1 = rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.FInteraction.GetDragDropMode();
                if ($tmp1 === $mod.TTMSFNCListBoxDragDropMode.ldmMove) rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.FItems.Delete(dragi.GetIndex());
              };
              rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FDragNode = null;
              rtl.as(Source,pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView).FParent.EndUpdate();
              this.EndUpdate();
              this.DoAfterDropItem(dragi,di);
            };
          };
        };
      };
    };
    this.DoCustomReorder = function (Sender, AFromNode, AToNode) {
      var it = null;
      var itt = null;
      var b = false;
      if (!(AFromNode != null) || !(AToNode != null)) return;
      b = true;
      it = this.GetItemForNode(AFromNode);
      itt = this.GetItemForNode(AToNode);
      this.DoBeforeReorderItem(it,itt,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      if (b) {
        this.BeginUpdate();
        it.SetIndex(itt.GetIndex());
        this.EndUpdate();
        this.DoAfterReorderItem(it,itt);
      };
    };
    this.DoCopyToClipboard = function (Sender) {
      this.CopyToClipboard(this.FInteraction.GetClipboardMode() === $mod.TTMSFNCListBoxClipboardMode.lcmTextOnly);
    };
    this.DoCutToClipboard = function (Sender) {
      this.CutToClipboard(this.FInteraction.GetClipboardMode() === $mod.TTMSFNCListBoxClipboardMode.lcmTextOnly);
    };
    this.DoPasteFromClipboard = function (Sender) {
      this.PasteFromClipboard();
    };
    this.DoColumnSort = function (Sender, AColumn, ASortMode) {
      var i = 0;
      i = ASortMode;
      this.FItems.Sort$1(this.FInteraction.GetSorting() in rtl.createSet($mod.TTMSFNCListBoxSorting.lcsNormalCaseSensitive),i);
    };
    this.DoLookup = function (Sender, ALookupString) {
      this.LookupItem(ALookupString,this.FInteraction.FLookup.GetCaseSensitive(),this.FInteraction.FLookup.GetAutoSelect());
    };
    this.PickerGetContent = function () {
      var Result = "";
      Result = "";
      if (this.GetItemIndex() >= 0) Result = this.FItems.GetItem$1(this.GetItemIndex()).FText;
      return Result;
    };
    this.PickerSelectItem = function (AItemIndex) {
      if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) this.SetItemIndex(AItemIndex);
    };
    this.PickerGetSelectedItem = function () {
      var Result = 0;
      Result = this.GetItemIndex();
      return Result;
    };
    this.PickerGetVisibleItemCount = function () {
      var Result = 0;
      if (this.FTreeView != null) {
        Result = this.FTreeView.FVisibleNodes.GetCount()}
       else Result = 0;
      return Result;
    };
    this.PickerGetItemCount = function () {
      var Result = 0;
      Result = this.FItems.GetCount();
      return Result;
    };
    this.PickerGetItemHeight = function () {
      var Result = 0.0;
      Result = this.FItemsAppearance.GetFixedHeight();
      return Result;
    };
    this.PickerSetItemHeight = function (AValue) {
      this.FItemsAppearance.SetFixedHeight(AValue);
    };
    this.PickerGetItemWidth = function () {
      var Result = 0.0;
      Result = this.GetWidth();
      return Result;
    };
    this.PickerSetItemWidth = function (AValue) {
    };
    this.PickerGetNextSelectableItem = function (AItemIndex) {
      var Result = 0;
      if (AItemIndex < (this.FItems.GetCount() - 1)) {
        Result = AItemIndex + 1}
       else Result = AItemIndex;
      return Result;
    };
    this.PickerGetPreviousSelectableItem = function (AItemIndex) {
      var Result = 0;
      if (AItemIndex > 0) {
        Result = AItemIndex - 1}
       else Result = AItemIndex;
      return Result;
    };
    this.PickerGetFirstSelectableItem = function () {
      var Result = 0;
      if (this.FItems.GetCount() > 0) {
        Result = 0}
       else Result = -1;
      return Result;
    };
    this.PickerGetLastSelectableItem = function () {
      var Result = 0;
      if (this.FItems.GetCount() > 0) {
        Result = this.FItems.GetCount() - 1}
       else Result = -1;
      return Result;
    };
    this.PickerResetFilter = function () {
      this.RemoveFilter();
    };
    this.PickerApplyFilter = function (ACondition, ACaseSensitive) {
      this.ApplyFilter();
    };
    this.PickerLookupItem = function (ALookupString, ACaseSensitive) {
      var Result = pas["WEBLib.TMSFNCControlPicker"].TTMSFNCControlPickerFilterItem.$new();
      var it = null;
      it = this.LookupItem(ALookupString,ACaseSensitive,false);
      Result.ItemIndex = it.GetIndex();
      Result.ItemText = it.FText;
      return Result;
    };
    this.SetFonts = function (ASetType) {
      var I = 0;
      this.BeginUpdate();
      this.FGlobalFont.ApplyChange(this.FItemsAppearance.GetFont(),ASetType);
      this.FGlobalFont.ApplyChange(this.FHeader.GetFont(),ASetType);
      if (ASetType === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCAppearanceGlobalFontType.aftColor) {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FItems.GetItem$1(I).SetTextColor(this.FGlobalFont.FColor);
          this.FItems.GetItem$1(I).SetSelectedTextColor(this.FGlobalFont.FColor);
        };
      };
      this.EndUpdate();
    };
    this.Create$1 = function (AOwner) {
      var c = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FFilter = $mod.TTMSFNCListBoxFilter.$create("Create$3",[this]);
      this.FHeader = $mod.TTMSFNCListBoxHeader.$create("Create$1",[this]);
      this.FItemsAppearance = $mod.TTMSFNCListBoxItemsAppearance.$create("Create$1",[this]);
      this.FDefaultItem = $mod.TTMSFNCListBoxItem.$create("Create$1",[null]);
      this.FItems = this.CreateItems();
      this.FInteraction = $mod.TTMSFNCListBoxInteraction.$create("Create$1",[this]);
      this.FCopyItems = $mod.TTMSFNCListBoxCopyItems.$create("Create$3",[null]);
      this.FTreeView = pas["WEBLib.TMSFNCTreeView"].TTMSFNCTreeView.$create("Create$1",[this]);
      this.FTreeView.FStored = false;
      this.FTreeView.SetParent(this);
      this.FTreeView.FColumns.Clear();
      c = this.FTreeView.FColumns.Add$1();
      c.SetText("Header");
      c.SetHorizontalTextAlign(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter);
      this.FTreeView.ClearNodes();
      this.FTreeView.FColumnsAppearance.SetLayouts({});
      this.FTreeView.SetStretchScrollBars(true);
      this.FTreeView.FNodesAppearance.SetExpandColumn(-1);
      this.FTreeView.FNodesAppearance.SetLevelIndent(0);
      this.FTreeView.FNodesAppearance.SetShowLines(false);
      this.FTreeView.FNodesAppearance.SetExpandWidth(0);
      this.FTreeView.FNodesAppearance.SetExpandHeight(0);
      this.FTreeView.FNodesAppearance.SetSelectionArea(pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCTreeViewSelectionArea.tsaFull);
      this.FTreeView.FOnGetNumberOfNodes = rtl.createCallback(this,"DoGetNumberOfNodes");
      this.FTreeView.FOnGetNodeHeight = rtl.createCallback(this,"DoGetNodeHeight");
      this.FTreeView.FOnGetNodeIcon = rtl.createCallback(this,"DoGetNodeIcon");
      this.FTreeView.FOnGetNodeIconSize = rtl.createCallback(this,"DoGetNodeIconSize");
      this.FTreeView.FOnGetNodeTrimming = rtl.createCallback(this,"DoGetNodeTrimming");
      this.FTreeView.FOnGetNodeWordWrapping = rtl.createCallback(this,"DoGetNodeWordWrapping");
      this.FTreeView.FOnGetNodeTextColor = rtl.createCallback(this,"DoGetNodeTextColor");
      this.FTreeView.FOnGetNodeSelectedTextColor = rtl.createCallback(this,"DoGetNodeSelectedTextColor");
      this.FTreeView.FOnGetNodeDisabledTextColor = rtl.createCallback(this,"DoGetNodeDisabledTextColor");
      this.FTreeView.FOnGetNodeText = rtl.createCallback(this,"DoGetNodeText");
      this.FTreeView.FOnGetNodeHorizontalTextAlign = rtl.createCallback(this,"DoGetNodeHorizontalTextAlign");
      this.FTreeView.FOnGetNodeVerticalTextAlign = rtl.createCallback(this,"DoGetNodeVerticalTextAlign");
      this.FTreeView.FOnIsNodeEnabled = rtl.createCallback(this,"DoIsNodeEnabled");
      this.FTreeView.FOnAfterSelectNode = rtl.createCallback(this,"DoAfterSelectNode");
      this.FTreeView.FOnNeedFilterDropDownData = rtl.createCallback(this,"DoNeedFilterDropDownData");
      this.FTreeView.FOnFilterSelect = rtl.createCallback(this,"DoFilterSelect");
      this.FTreeView.FOnBeforeDrawNode = rtl.createCallback(this,"DoBeforeDrawNode");
      this.FTreeView.FOnAfterDrawNode = rtl.createCallback(this,"DoAfterDrawNode");
      this.FTreeView.FOnAfterDrawNodeIcon = rtl.createCallback(this,"DoAfterDrawNodeIcon");
      this.FTreeView.FOnBeforeDrawNodeIcon = rtl.createCallback(this,"DoBeforeDrawNodeIcon");
      this.FTreeView.FOnAfterDrawNodeCheck = rtl.createCallback(this,"DoAfterDrawNodeCheck");
      this.FTreeView.FOnBeforeDrawNodeCheck = rtl.createCallback(this,"DoBeforeDrawNodeCheck");
      this.FTreeView.FOnBeforeDrawNodeText = rtl.createCallback(this,"DoBeforeDrawNodeText");
      this.FTreeView.FOnAfterDrawNodeText = rtl.createCallback(this,"DoAfterDrawNodeText");
      this.FTreeView.FOnNodeAnchorClick = rtl.createCallback(this,"DoNodeAnchorClick");
      this.FTreeView.FOnBeforeDrawSortIndicator = rtl.createCallback(this,"DoBeforeDrawSortIndicator");
      this.FTreeView.FOnAfterDrawSortIndicator = rtl.createCallback(this,"DoAfterDrawSortIndicator");
      this.FTreeView.FOnNodeClick = rtl.createCallback(this,"DoNodeClick");
      this.FTreeView.FOnNodeMouseLeave = rtl.createCallback(this,"DoNodeMouseLeave");
      this.FTreeView.FOnNodeMouseEnter = rtl.createCallback(this,"DoNodeMouseEnter");
      this.FTreeView.FOnNodeDblClick = rtl.createCallback(this,"DoNodeDblClick");
      this.FTreeView.FOnVScroll = rtl.createCallback(this,"DoVScroll");
      this.FTreeView.FOnBeforeCutToClipboard = rtl.createCallback(this,"DoBeforeCutToClipboard");
      this.FTreeView.FOnBeforeCopyToClipboard = rtl.createCallback(this,"DoBeforeCopyToClipboard");
      this.FTreeView.FOnBeforePasteFromClipboard = rtl.createCallback(this,"DoBeforePasteFromClipboard");
      this.FTreeView.FOnAfterCutToClipboard = rtl.createCallback(this,"DoAfterCutToClipboard");
      this.FTreeView.FOnAfterCopyToClipboard = rtl.createCallback(this,"DoAfterCopyToClipboard");
      this.FTreeView.FOnAfterPasteFromClipboard = rtl.createCallback(this,"DoAfterPasteFromClipboard");
      this.FTreeView.FOnColumnAnchorClick = rtl.createCallback(this,"DoColumnAnchorClick");
      this.FTreeView.FOnMouseWheelDown = rtl.createCallback(this,"DoTreeViewMouseWheelDown");
      this.FTreeView.FOnMouseWheelUp = rtl.createCallback(this,"DoTreeViewMouseWheelUp");
      this.FTreeView.FOnKeyDown = rtl.createCallback(this,"DoTreeViewKeyDown");
      this.FTreeView.FOnKeyUp = rtl.createCallback(this,"DoTreeViewKeyUp");
      this.FTreeView.FOnKeyPress = rtl.createCallback(this,"DoTreeViewKeyPress");
      this.FTreeView.FOnCustomReorder = rtl.createCallback(this,"DoCustomReorder");
      this.FTreeView.FOnCustomDragOver = rtl.createCallback(this,"DoCustomDragOver");
      this.FTreeView.FOnCustomDragDrop = rtl.createCallback(this,"DoCustomDragDrop");
      this.FTreeView.FOnCustomCopyToClipboard = rtl.createCallback(this,"DoCopyToClipboard");
      this.FTreeView.FOnCustomCutToClipboard = rtl.createCallback(this,"DoCutToClipboard");
      this.FTreeView.FOnCustomPasteFromClipboard = rtl.createCallback(this,"DoPasteFromClipboard");
      this.FTreeView.FOnCustomColumnSort = rtl.createCallback(this,"DoColumnSort");
      this.FTreeView.FOnCustomLookup = rtl.createCallback(this,"DoLookup");
      this.FTreeView.FOnClick = rtl.createCallback(this,"DoClick");
      this.FTreeView.FOnDblClick = rtl.createCallback(this,"DoDblClick");
      this.CustomizeTreeView(this.FTreeView);
      this.FTreeView.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FGlobalFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCAppearanceGlobalFont.$create("Create$1",[this]);
      this.SetWidth(200);
      this.SetHeight(220);
      if (this.IsDesignTime()) this.InitSample();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FGlobalFont");
      rtl.free(this,"FFilter");
      rtl.free(this,"FCopyItems");
      rtl.free(this,"FHeader");
      rtl.free(this,"FDefaultItem");
      rtl.free(this,"FInteraction");
      rtl.free(this,"FItems");
      rtl.free(this,"FTreeView");
      rtl.free(this,"FItemsAppearance");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomListBox.isPrototypeOf(Source)) this.FTreeView.Assign(rtl.as(Source,$mod.TTMSFNCCustomListBox).FTreeView);
    };
    this.AddItem = function (AText) {
      var Result = null;
      Result = this.FItems.Add$1();
      Result.SetText(AText);
      return Result;
    };
    this.XYToItem = function (X, Y) {
      var Result = null;
      var n = null;
      Result = null;
      if (this.FTreeView != null) {
        n = this.FTreeView.XYToNode(X,Y,0);
        if ((n != null) && (n.FRow >= 0) && (n.FRow <= (this.FItems.GetCount() - 1))) Result = this.FItems.GetItem$1(n.FRow);
      };
      return Result;
    };
    this.XYToItemIndex = function (X, Y) {
      var Result = 0;
      var it = null;
      Result = -1;
      it = this.XYToItem(X,Y);
      if (it != null) Result = it.GetIndex();
      return Result;
    };
    this.SelectedItemCount = function () {
      var Result = 0;
      Result = 0;
      if (this.FTreeView != null) Result = this.FTreeView.SelectedVirtualNodeCount();
      return Result;
    };
    this.GetItemsFromClipboard = function () {
      var Result = null;
      var s = "";
      var a = null;
      var AItem = null;
      var I = 0;
      var CurrStr = "";
      var templ = null;
      if (pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.HasFormat(pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoardFormat.cfText)) {
        s = pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.GetText();
        if (pas.System.Pos($mod.CLP_FMT,s) > 0) {
          templ = $mod.TTMSFNCCustomListBox.$create("Create$1",[null]);
          a = pas.Classes.TStringList.$create("Create$1");
          try {
            s = pas.SysUtils.StringReplace(s,$mod.CLP_FMT,"",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
            a.SetTextStr(s);
            try {
              for (var $l = 0, $end = a.GetCount() - 1; $l <= $end; $l++) {
                I = $l;
                CurrStr = a.Get(I);
                AItem = templ.AddItem("");
                AItem.LoadFromString(CurrStr);
              };
            } finally {
            };
          } finally {
            this.FCopyItems.Assign(templ.FItems);
            a = rtl.freeLoc(a);
            templ = rtl.freeLoc(templ);
          };
        };
      };
      Result = this.FCopyItems;
      return Result;
    };
    this.LookupItem = function (ALookupString, ACaseSensitive, AAutoSelect) {
      var Result = null;
      var v = "";
      var it = null;
      var i = 0;
      var s = "";
      Result = null;
      v = ALookupString;
      if (!ACaseSensitive) v = pas.SysUtils.UpperCase(v);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        it = this.FItems.GetItem$1(i);
        s = it.GetStrippedHTMLText();
        if (!ACaseSensitive) s = pas.SysUtils.UpperCase(s);
        if (pas.System.Pos(v,s) === 1) {
          Result = it;
          break;
        };
      };
      if ((Result != null) && this.IsItemSelectable(Result) && AAutoSelect) {
        this.SelectItem(Result.GetIndex());
        this.ScrollToItem(Result.GetIndex());
      };
      return Result;
    };
    this.IsItemSelectable = function (AItem) {
      var Result = false;
      Result = true;
      if (AItem != null) {
        Result = AItem.FEnabled;
        if (!(this.FTreeView.FVisibleNodes.IndexOf(this.GetNodeForItemIndex(AItem.GetIndex())) > -1)) Result = false;
      };
      return Result;
    };
    this.RemoveItem = function (AItem) {
      if (AItem != null) this.FItems.Delete(AItem.GetIndex());
    };
    this.DoEnter = function () {
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      if (this.FTreeView != null) {
        if (this.FTreeView.GetAllowFocus()) {
          this.FTreeView.SetFocus();
        };
        this.FTreeView.Invalidate();
      };
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.BeginUpdate.call(this);
      if (this.FTreeView != null) {
        if (this.FUpdateCount$1 === 0) this.FSaveSelectedItemIndex = this.GetItemIndex();
        this.FUpdateCount$1 += 1;
        this.FTreeView.BeginUpdate();
        this.FTreeView.ClearNodeList();
      };
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.EndUpdate.call(this);
      if (this.FTreeView != null) {
        this.FUpdateCount$1 -= 1;
        this.FTreeView.EndUpdate();
        if (this.FUpdateCount$1 === 0) this.SetItemIndex(this.FSaveSelectedItemIndex);
      };
    };
    this.InitSample = function () {
      this.BeginUpdate();
      this.FItems.Clear$1();
      this.ResetToDefaultStyle();
      this.AddItem("Bugfix 376");
      this.AddItem("Bugfix 378");
      this.AddItem("Customer Update");
      this.AddItem("Install New server");
      this.AddItem("Meeting: Next Phase");
      this.AddItem("Release Planning");
      this.EndUpdate();
    };
    this.UnSelectAllItems = function () {
      if (this.FTreeView != null) this.FTreeView.UnSelectAllVirtualNodes();
    };
    this.LoadSettingsFromFile = function (AFileName) {
      var c = 0;
      var I = 0;
      c = this.FDefaultItem.FTextColor;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromFile.apply(this,arguments);
      if ((c === this.FDefaultItem.FTextColor) && (c !== this.FItemsAppearance.GetFont().FColor)) {
        this.FDefaultItem.SetTextColor(this.FItemsAppearance.GetFont().FColor);
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FItems.GetItem$1(I).SetTextColor(this.FDefaultItem.FTextColor);
        };
      };
    };
    this.LoadSettingsFromStream = function (AStream) {
      var c = 0;
      var I = 0;
      c = this.FDefaultItem.FTextColor;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromStream.apply(this,arguments);
      if ((c === this.FDefaultItem.FTextColor) && (c !== this.FItemsAppearance.GetFont().FColor)) {
        this.FDefaultItem.SetTextColor(this.FItemsAppearance.GetFont().FColor);
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FItems.GetItem$1(I).SetTextColor(this.FDefaultItem.FTextColor);
        };
      };
    };
    this.ScrollToItem = function (AItemIndex) {
      var t = null;
      if (this.FTreeView != null) {
        if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) {
          t = this.FTreeView;
          t.ScrollToVirtualNode(t.GetNodeForRow(AItemIndex),true,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
        };
      };
    };
    this.SelectItem = function (AItemIndex) {
      var t = null;
      var n = null;
      if (this.FTreeView != null) {
        t = this.FTreeView;
        if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) {
          n = t.GetNodeForRow(AItemIndex);
          t.SelectVirtualNode(n);
          if (this.FScrollToItem) t.ScrollToVirtualNode(n,false,pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewNodeScrollPosition.tvnspTop,false);
        } else t.SelectVirtualNode(null);
      };
      this.FScrollToItem = false;
    };
    this.SelectItems = function (AItemIndexes) {
      var t = null;
      var I = 0;
      var na = [];
      if (this.FTreeView != null) {
        t = this.FTreeView;
        na = rtl.arraySetLength(na,null,rtl.length(AItemIndexes));
        for (var $l = 0, $end = rtl.length(AItemIndexes) - 1; $l <= $end; $l++) {
          I = $l;
          na[I] = t.GetNodeForRow(AItemIndexes[I]);
        };
        t.SelectVirtualNodes(rtl.arrayRef(na));
      };
    };
    this.LoadFromStrings = function (AStrings) {
      var I = 0;
      this.BeginUpdate();
      this.FItems.Clear$1();
      for (var $l = 0, $end = AStrings.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FItems.Add$1().SetText(AStrings.Get(I));
      };
      this.EndUpdate();
    };
    this.SaveToStrings = function (AStrings) {
      var I = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        AStrings.Add(this.FItems.GetItem$1(I).FText);
      };
    };
    this.CutToClipboard = function (ATextOnly) {
      var I = 0;
      this.BeginUpdate();
      this.CopyToClipboard(ATextOnly);
      for (var $l = this.SelectedItemCount() - 1; $l >= 0; $l--) {
        I = $l;
        this.RemoveItem(this.GetSelItem(I));
      };
      this.EndUpdate();
    };
    this.CopyToClipboard = function (ATextOnly) {
      var s = "";
      var I = 0;
      var it = null;
      var cl = null;
      cl = pas["WEBLib.TMSFNCTreeViewData"].TTMSFNCTreeViewIntegerList.$create("Create$1");
      try {
        s = "";
        for (var $l = 0, $end = this.SelectedItemCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = this.GetSelItem(I);
          if ((it != null) && (cl.IndexOf(it.GetIndex()) === -1)) {
            s = s + it.SaveToString(ATextOnly) + pas["WEBLib.TMSFNCCustomTreeView"].ENDOFLINE;
            cl.Add(it.GetIndex());
          };
        };
        if (s !== "") pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.SetText($mod.CLP_FMT + s);
      } finally {
        cl = rtl.freeLoc(cl);
      };
    };
    this.PasteFromClipboard = function () {
      var s = "";
      var a = null;
      var AItem = null;
      var I = 0;
      var CurrStr = "";
      if (pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.HasFormat(pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoardFormat.cfText)) {
        s = pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.GetText();
        if (pas.System.Pos($mod.CLP_FMT,s) > 0) {
          a = pas.Classes.TStringList.$create("Create$1");
          try {
            s = pas.SysUtils.StringReplace(s,$mod.CLP_FMT,"",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
            a.SetTextStr(s);
            try {
              for (var $l = 0, $end = a.GetCount() - 1; $l <= $end; $l++) {
                I = $l;
                CurrStr = a.Get(I);
                AItem = this.AddItem("");
                AItem.LoadFromString(CurrStr);
              };
            } finally {
            };
          } finally {
            a = rtl.freeLoc(a);
          };
        };
      };
    };
    this.Sort = function (ACaseSensitive, ASortingMode) {
      this.FItems.Sort$1(ACaseSensitive,ASortingMode);
    };
    this.ClearSorting = function () {
      if (this.FTreeView != null) this.FTreeView.ClearSorting();
    };
    this.ApplyFilter = function () {
      var I = 0;
      var ft = null;
      var o = 0;
      if (this.FTreeView != null) {
        this.FTreeView.FFilter.Clear();
        for (var $l = 0, $end = this.FFilter.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          ft = this.FTreeView.FFilter.Add$1();
          ft.FColumn = 0;
          ft.FCondition = this.FFilter.GetItem$1(I).FCondition;
          ft.FCaseSensitive = this.FFilter.GetItem$1(I).FCaseSensitive;
          ft.FPrefix = this.FFilter.GetItem$1(I).FPrefix;
          ft.FSuffix = this.FFilter.GetItem$1(I).FSuffix;
          o = this.FFilter.GetItem$1(I).FOperation;
          ft.FOperation = o;
        };
        this.FTreeView.ApplyFilter();
      };
    };
    this.RemoveFilter = function () {
      if (this.FTreeView != null) this.FTreeView.RemoveFilter();
    };
    this.RemoveFilters = function () {
      if (this.FTreeView != null) this.FTreeView.RemoveFilters();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCStylesManager);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCControlPicker"].ITMSFNCControlPickerFull);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCListBox",this.TTMSFNCCustomListBox,function () {
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCCustomListBox.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClasses([$mod.TTMSFNCListBox,$mod.TTMSFNCListBoxItem]);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCStylesManager);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCControlPicker"].ITMSFNCControlPickerFull);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Fill",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"GetFill","SetFill$1");
    $r.addProperty("Stroke",3,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"GetStroke","SetStroke$1");
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("ItemsAppearance",2,$mod.$rtti["TTMSFNCListBoxItemsAppearance"],"FItemsAppearance","SetItemsAppearance");
    $r.addProperty("DefaultItem",2,$mod.$rtti["TTMSFNCListBoxItem"],"FDefaultItem","SetDefaultItem");
    $r.addProperty("Items",2,$mod.$rtti["TTMSFNCListBoxItems"],"FItems","SetItems");
    $r.addProperty("Header",2,$mod.$rtti["TTMSFNCListBoxHeader"],"FHeader","SetHeader");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",4,{Default: -1});
    $r.addProperty("Interaction",2,$mod.$rtti["TTMSFNCListBoxInteraction"],"FInteraction","SetInteraction");
    $r.addProperty("OnItemSelected",0,$mod.$rtti["TTMSFNCListBoxItemSelectedEvent"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("VerticalScrollBarVisible",3,rtl.boolean,"GetVerticalScrollBarVisible","SetVerticalScrollBarVisible",4,{Default: true});
    $r.addProperty("GlobalFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCAppearanceGlobalFont"],"FGlobalFont","SetGlobalFont");
    $r.addProperty("OnNeedFilterDropDownData",0,$mod.$rtti["TTMSFNCListBoxNeedFilterDropDownDataEvent"],"FOnNeedFilterDropDownData","FOnNeedFilterDropDownData");
    $r.addProperty("OnFilterSelect",0,$mod.$rtti["TTMSFNCListBoxFilterSelectEvent"],"FOnFilterSelect","FOnFilterSelect");
    $r.addProperty("OnBeforeDrawItem",0,$mod.$rtti["TTMSFNCListBoxBeforeDrawItemEvent"],"FOnBeforeDrawItem","FOnBeforeDrawItem");
    $r.addProperty("OnAfterDrawItem",0,$mod.$rtti["TTMSFNCListBoxAfterDrawItemEvent"],"FOnAfterDrawItem","FOnAfterDrawItem");
    $r.addProperty("OnItemCompare",0,$mod.$rtti["TTMSFNCListBoxItemCompareEvent"],"FOnItemCompare","FOnItemCompare");
    $r.addProperty("OnAfterDrawItemIcon",0,$mod.$rtti["TTMSFNCListBoxAfterDrawItemIconEvent"],"FOnAfterDrawItemIcon","FOnAfterDrawItemIcon");
    $r.addProperty("OnBeforeDrawItemIcon",0,$mod.$rtti["TTMSFNCListBoxBeforeDrawItemIconEvent"],"FOnBeforeDrawItemIcon","FOnBeforeDrawItemIcon");
    $r.addProperty("OnBeforeDrawItemText",0,$mod.$rtti["TTMSFNCListBoxBeforeDrawItemTextEvent"],"FOnBeforeDrawItemText","FOnBeforeDrawItemText");
    $r.addProperty("OnAfterDrawItemText",0,$mod.$rtti["TTMSFNCListBoxAfterDrawItemTextEvent"],"FOnAfterDrawItemText","FOnAfterDrawItemText");
    $r.addProperty("OnAfterDrawSortIndicator",0,$mod.$rtti["TTMSFNCListBoxAfterDrawSortIndicatorEvent"],"FOnAfterDrawSortIndicator","FOnAfterDrawSortIndicator");
    $r.addProperty("OnBeforeDrawSortIndicator",0,$mod.$rtti["TTMSFNCListBoxBeforeDrawSortIndicatorEvent"],"FOnBeforeDrawSortIndicator","FOnBeforeDrawSortIndicator");
    $r.addProperty("OnItemAnchorClick",0,$mod.$rtti["TTMSFNCListBoxItemAnchorClickEvent"],"FOnItemAnchorClick","FOnItemAnchorClick");
    $r.addProperty("OnItemClick",0,$mod.$rtti["TTMSFNCListBoxItemClickEvent"],"FOnItemClick","FOnItemClick");
    $r.addProperty("OnItemMouseLeave",0,$mod.$rtti["TTMSFNCListBoxItemMouseLeaveEvent"],"FOnItemMouseLeave","FOnItemMouseLeave");
    $r.addProperty("OnItemMouseEnter",0,$mod.$rtti["TTMSFNCListBoxItemMouseEnterEvent"],"FOnItemMouseEnter","FOnItemMouseEnter");
    $r.addProperty("OnItemDblClick",0,$mod.$rtti["TTMSFNCListBoxItemClickEvent"],"FOnItemDblClick","FOnItemDblClick");
    $r.addProperty("OnVScroll",0,$mod.$rtti["TTMSFNCListBoxScrollEvent"],"FOnVScroll","FOnVScroll");
    $r.addProperty("OnBeforeReorderItem",0,$mod.$rtti["TTMSFNCListBoxBeforeReorderItemEvent"],"FOnBeforeReorderItem","FOnBeforeReorderItem");
    $r.addProperty("OnAfterReorderItem",0,$mod.$rtti["TTMSFNCListBoxAfterReorderItemEvent"],"FOnAfterReorderItem","FOnAfterReorderItem");
    $r.addProperty("OnBeforeDropItem",0,$mod.$rtti["TTMSFNCListBoxBeforeDropItemEvent"],"FOnBeforeDropItem","FOnBeforeDropItem");
    $r.addProperty("OnAfterDropItem",0,$mod.$rtti["TTMSFNCListBoxAfterDropItemEvent"],"FOnAfterDropItem","FOnAfterDropItem");
    $r.addProperty("OnBeforeCutToClipboard",0,$mod.$rtti["TTMSFNCListBoxBeforeCutToClipboardEvent"],"FOnBeforeCutToClipboard","FOnBeforeCutToClipboard");
    $r.addProperty("OnBeforeCopyToClipboard",0,$mod.$rtti["TTMSFNCListBoxBeforeCopyToClipboardEvent"],"FOnBeforeCopyToClipboard","FOnBeforeCopyToClipboard");
    $r.addProperty("OnBeforePasteFromClipboard",0,$mod.$rtti["TTMSFNCListBoxBeforePasteFromClipboardEvent"],"FOnBeforePasteFromClipboard","FOnBeforePasteFromClipboard");
    $r.addProperty("OnAfterCutToClipboard",0,$mod.$rtti["TTMSFNCListBoxAfterCutToClipboardEvent"],"FOnAfterCutToClipboard","FOnAfterCutToClipboard");
    $r.addProperty("OnAfterCopyToClipboard",0,$mod.$rtti["TTMSFNCListBoxAfterCopyToClipboardEvent"],"FOnAfterCopyToClipboard","FOnAfterCopyToClipboard");
    $r.addProperty("OnAfterPasteFromClipboard",0,$mod.$rtti["TTMSFNCListBoxAfterPasteFromClipboardEvent"],"FOnAfterPasteFromClipboard","FOnAfterPasteFromClipboard");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTMSFNCTreeViewOpen",pas["WEBLib.TMSFNCTreeView"].TTMSFNCTreeView,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCControlPicker"].ITMSFNCControlPickerFull);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
      rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    rtl.createClass($impl,"TTMSFNCCustomTreeViewOpen",pas["WEBLib.TMSFNCCustomTreeView"].TTMSFNCCustomTreeView,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
      rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    rtl.createClass($impl,"TTMSFNCCustomListBoxOpen",$mod.TTMSFNCCustomListBox,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCStylesManager);
      rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
      rtl.addIntf(this,pas["WEBLib.TMSFNCControlPicker"].ITMSFNCControlPickerFull);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    rtl.createClass($impl,"TShadowedCollection",pas.Classes.TPersistent,function () {
      this.$init = function () {
        pas.Classes.TPersistent.$init.call(this);
        this.FItemClass = null;
        this.FItems = null;
      };
      this.$final = function () {
        this.FItemClass = undefined;
        this.FItems = undefined;
        pas.Classes.TPersistent.$final.call(this);
      };
    });
  };
},["WEBLib.TMSFNCUtils","WEBLib.Controls","SysUtils","WEBLib.Graphics","WEBLib.TMSFNCCustomSelector"]);
rtl.module("WEBLib.TMSFNCBitmapSelector",["System","Classes","WEBLib.TMSFNCCustomSelector","WEBLib.TMSFNCTypes","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCGraphics"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCCustomBitmapSelector");
  this.TTMSFNCBitmapSelectorBitmapAlign = {"0": "baLeft", baLeft: 0, "1": "baCenter", baCenter: 1, "2": "baRight", baRight: 2};
  this.$rtti.$Enum("TTMSFNCBitmapSelectorBitmapAlign",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCBitmapSelectorBitmapAlign});
  rtl.createClass(this,"TTMSFNCBitmapSelectorItem",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.$init.call(this);
      this.FOwner$1 = null;
      this.FBitmap = null;
      this.FBitmapAlign = 0;
      this.FBitmapName = "";
      this.FBitmapSize = 0.0;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FBitmap = undefined;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.$final.call(this);
    };
    this.SetBitmap = function (Value) {
      if (this.FBitmap !== Value) {
        this.FBitmap.Assign(Value);
        this.FOwner$1.InvalidateItems();
      };
    };
    this.SetBitmapAlign = function (Value) {
      if (this.FBitmapAlign !== Value) {
        this.FBitmapAlign = Value;
        this.FOwner$1.InvalidateItems();
      };
    };
    this.SetBitmapName = function (Value) {
      if (this.FBitmapName !== Value) {
        this.FBitmapName = Value;
        this.FOwner$1.InvalidateItems();
      };
    };
    this.SetBitmapSize = function (Value) {
      if (this.FBitmapSize !== Value) {
        this.FBitmapSize = Value;
        this.FOwner$1.InvalidateItems();
      };
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FOwner$1.GetBitmapContainer();
      return Result;
    };
    this.IsBitmapSizeStored = function () {
      var Result = false;
      Result = this.FBitmapSize !== 0;
      return Result;
    };
    this.GetDisplayBitmap = function () {
      var Result = null;
      Result = null;
      if ((this.FBitmap != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FBitmap)) {
        Result = this.FBitmap}
       else if ((this.FOwner$1 != null) && (this.FOwner$1.GetBitmapContainer() != null) && (this.FBitmapName !== "")) Result = this.FOwner$1.GetBitmapContainer().FindBitmap$1(this.FBitmapName);
      return Result;
    };
    this.BitmapChanged = function (Sender) {
      this.FOwner$1.InvalidateItems();
    };
    this.Create$1 = function (ACollection) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner$1 = rtl.as(this.FCollection,$mod.TTMSFNCBitmapSelectorItems).FOwner$2;
      this.FBitmapAlign = $mod.TTMSFNCBitmapSelectorBitmapAlign.baCenter;
      this.FBitmapSize = 0;
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"BitmapChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.Assign.apply(this,arguments);
      if ($mod.TTMSFNCBitmapSelectorItem.isPrototypeOf(Source)) {
        this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCBitmapSelectorItem).FBitmap);
        this.FBitmapName = rtl.as(Source,$mod.TTMSFNCBitmapSelectorItem).FBitmapName;
        this.FBitmapSize = rtl.as(Source,$mod.TTMSFNCBitmapSelectorItem).FBitmapSize;
        this.FBitmapAlign = rtl.as(Source,$mod.TTMSFNCBitmapSelectorItem).FBitmapAlign;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapName",2,rtl.string,"FBitmapName","SetBitmapName");
    $r.addProperty("BitmapAlign",2,$mod.$rtti["TTMSFNCBitmapSelectorBitmapAlign"],"FBitmapAlign","SetBitmapAlign",4,{Default: $mod.TTMSFNCBitmapSelectorBitmapAlign.baCenter});
    $r.addProperty("BitmapSize",14,rtl.double,"FBitmapSize","SetBitmapSize",4,{stored: "IsBitmapSizeStored"});
  });
  rtl.createClass(this,"TTMSFNCBitmapSelectorItems",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.$init.call(this);
      this.FOwner$2 = null;
    };
    this.$final = function () {
      this.FOwner$2 = undefined;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.$final.call(this);
    };
    this.GetItem$2 = function (Index) {
      var Result = null;
      Result = this.GetItem$1(Index);
      return Result;
    };
    this.SetItem$2 = function (Index, Value) {
      this.SetItem$1(Index,Value);
    };
    this.CreateItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCBitmapSelectorItem;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.Create$3.apply(this,arguments);
      this.FOwner$2 = rtl.as(AOwner,$mod.TTMSFNCCustomBitmapSelector);
      return this;
    };
    this.Add$2 = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.Add$1.call(this);
      return Result;
    };
    this.Insert$2 = function (Index) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.Insert$1.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorBitmapSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABitmap",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorBitmapDeselected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABitmap",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomBitmapSelector",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCDefaultSelector,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCDefaultSelector.$init.call(this);
      this.FOnBitmapSelected = null;
      this.FOnBitmapDeselected = null;
      this.FBitmapContainer = null;
    };
    this.$final = function () {
      this.FOnBitmapSelected = undefined;
      this.FOnBitmapDeselected = undefined;
      this.FBitmapContainer = undefined;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCDefaultSelector.$final.call(this);
    };
    this.GetSelectedBitmap = function () {
      var Result = null;
      Result = this.FindBitmapByItem(this.FSelectedItemIndex);
      return Result;
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
      this.InvalidateItems();
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FItems;
      return Result;
    };
    this.SetItems$1 = function (Value) {
      this.GetItems().Assign(Value);
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,0);
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
    };
    this.DoItemSelected = function (AItemIndex) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemSelected.apply(this,arguments);
      if (this.FOnBitmapSelected != null) this.FOnBitmapSelected(this,this.FindBitmapByItem(AItemIndex));
    };
    this.DoItemDeselected = function (AItemIndex) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemDeselected.apply(this,arguments);
      if (this.FOnBitmapDeselected != null) this.FOnBitmapDeselected(this,this.FindBitmapByItem(AItemIndex));
    };
    this.CreateItemsCollection = function () {
      var Result = null;
      Result = $mod.TTMSFNCBitmapSelectorItems.$create("Create$3",[this]);
      return Result;
    };
    this.DrawItemContent = function (AGraphics, ADisplayItem) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var it = null;
      var itbmp = null;
      var a = false;
      var sz = 0.0;
      var bmp = null;
      var bmpr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var w = 0.0;
      var h = 0.0;
      var bmpdr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      it = ADisplayItem.Item;
      if ((it != null) && $mod.TTMSFNCBitmapSelectorItem.isPrototypeOf(it)) {
        r.$assign(ADisplayItem.Rect);
        a = true;
        this.DoItemBeforeDrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),it.GetIndex(),{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) {
          itbmp = rtl.as(it,$mod.TTMSFNCBitmapSelectorItem);
          bmp = itbmp.GetDisplayBitmap();
          if (bmp != null) {
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-2,-2);
            sz = r.Bottom - r.Top;
            if (itbmp.FBitmapSize > 0) sz = itbmp.FBitmapSize;
            var $tmp = itbmp.FBitmapAlign;
            if ($tmp === $mod.TTMSFNCBitmapSelectorBitmapAlign.baLeft) {
              bmpr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Left + sz,r.Bottom))}
             else if ($tmp === $mod.TTMSFNCBitmapSelectorBitmapAlign.baCenter) {
              bmpr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + ((r.Right - r.Left - sz) / 2),r.Top,r.Left + ((r.Right - r.Left - sz) / 2) + sz,r.Bottom))}
             else if ($tmp === $mod.TTMSFNCBitmapSelectorBitmapAlign.baRight) bmpr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right - sz,r.Top,r.Right,r.Bottom));
            w = 0;
            h = 0;
            $mod.GetAspectSize({get: function () {
                return w;
              }, set: function (v) {
                w = v;
              }},{get: function () {
                return h;
              }, set: function (v) {
                h = v;
              }},bmp.GetWidth(),bmp.GetHeight(),bmpr.Right - bmpr.Left,bmpr.Bottom - bmpr.Top,bmpr.Right - bmpr.Left,bmpr.Bottom - bmpr.Top,true,false,false);
            bmpdr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(bmpr.Left + ((bmpr.Right - bmpr.Left - w) / 2),bmpr.Top + ((bmpr.Bottom - bmpr.Top - h) / 2),bmpr.Left + ((bmpr.Right - bmpr.Left - w) / 2) + w,bmpr.Top + ((bmpr.Bottom - bmpr.Top - h) / 2) + h));
            bmpdr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Math.round(bmpdr.Left),Math.round(bmpdr.Top),Math.round(bmpdr.Right),Math.round(bmpdr.Bottom)));
            AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(bmpdr),bmp,true,false,true,false);
          };
          this.DoItemAfterDrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),it.GetIndex());
        };
      };
    };
    this.DrawItemText = function (AGraphics, ADisplayItem) {
      var it = null;
      var bmp = null;
      var dps = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorDisplayItem.$new();
      var sz = 0.0;
      if ((ADisplayItem.Item != null) && $mod.TTMSFNCBitmapSelectorItem.isPrototypeOf(ADisplayItem.Item)) {
        it = rtl.as(ADisplayItem.Item,$mod.TTMSFNCBitmapSelectorItem);
        bmp = it.GetDisplayBitmap();
        if (bmp != null) {
          dps.$assign(ADisplayItem);
          sz = dps.Rect.Bottom - dps.Rect.Top;
          if (it.FBitmapSize > 0) sz = it.FBitmapSize;
          var $tmp = it.FBitmapAlign;
          if ($tmp === $mod.TTMSFNCBitmapSelectorBitmapAlign.baLeft) {
            dps.Rect.Left = dps.Rect.Left + sz + 4}
           else if ($tmp === $mod.TTMSFNCBitmapSelectorBitmapAlign.baRight) dps.Rect.Right = dps.Rect.Right - sz - 4;
          pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DrawItemText.call(this,AGraphics,pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorDisplayItem.$clone(dps));
        } else pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DrawItemText.apply(this,arguments);
      } else pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DrawItemText.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.Create$1.apply(this,arguments);
      this.SetWidth(135);
      this.SetHeight(135);
      return this;
    };
    this.LoadFromBitmapContainer = function () {
      var I = 0;
      var it = null;
      if (!(this.GetBitmapContainer() != null)) return;
      this.BeginUpdate();
      this.GetItems().Clear();
      for (var $l = 0, $end = this.GetBitmapContainer().GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = this.GetItems().Add$2();
        it.SetBitmapName(this.GetBitmapContainer().GetItems().GetItemEx(I).FName);
      };
      this.EndUpdate();
    };
    this.FindItemByBitmap = function (ABitmap) {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = -1;
      for (var $l = 0, $end = this.GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = rtl.as(this.GetItems().GetItem$2(I),$mod.TTMSFNCBitmapSelectorItem);
        if (it.GetDisplayBitmap() === ABitmap) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.FindBitmapByItem = function (AItem) {
      var Result = null;
      var I = 0;
      var it = null;
      Result = null;
      for (var $l = 0, $end = this.GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = rtl.as(this.GetItems().GetItem$2(I),$mod.TTMSFNCBitmapSelectorItem);
        if (it.GetIndex() === AItem) {
          Result = it.GetDisplayBitmap();
          break;
        };
      };
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCBitmapSelector",this.TTMSFNCCustomBitmapSelector,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClasses([$mod.TTMSFNCBitmapSelector,$mod.TTMSFNCBitmapSelectorItem]);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",2,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("Rows",2,rtl.longint,"FRows","SetRows",4,{Default: 4});
    $r.addProperty("Columns",2,rtl.longint,"FColumns","SetColumns",4,{Default: 4});
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCBitmapSelectorItems"],"GetItems","SetItems$1");
    $r.addProperty("OnBitmapSelected",0,$mod.$rtti["TTMSFNCCustomSelectorBitmapSelected"],"FOnBitmapSelected","FOnBitmapSelected");
    $r.addProperty("OnBitmapDeselected",0,$mod.$rtti["TTMSFNCCustomSelectorBitmapDeselected"],"FOnBitmapDeselected","FOnBitmapDeselected");
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("OnItemSelected",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemSelected"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("SelectedItemIndex",2,rtl.longint,"FSelectedItemIndex","SetSelectedItemIndex",4,{Default: -1});
    $r.addProperty("OnItemBeforeDrawBackground",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawBackground"],"FOnItemBeforeDrawBackground","FOnItemBeforeDrawBackground");
    $r.addProperty("OnItemAfterDrawBackground",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawBackground"],"FOnItemAfterDrawBackground","FOnItemAfterDrawBackground");
    $r.addProperty("OnItemBeforeDrawContent",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawContent"],"FOnItemBeforeDrawContent","FOnItemBeforeDrawContent");
    $r.addProperty("OnItemAfterDrawContent",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawContent"],"FOnItemAfterDrawContent","FOnItemAfterDrawContent");
    $r.addProperty("OnBeforeDraw",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorBeforeDraw"],"FOnBeforeDraw$1","FOnBeforeDraw$1");
    $r.addProperty("OnAfterDraw",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorAfterDraw"],"FOnAfterDraw$1","FOnAfterDraw$1");
    $r.addProperty("OnItemBeforeDrawText",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawText"],"FOnItemBeforeDrawText","FOnItemBeforeDrawText");
    $r.addProperty("OnItemAfterDrawText",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawText"],"FOnItemAfterDrawText","FOnItemAfterDrawText");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.GetAspectSize = function (w, h, ow, oh, nw, nh, crw, crh, asp, st, cr) {
    var arc = 0.0;
    var ar = 0.0;
    if (asp) {
      if ((ow > 0) && (oh > 0) && (nw > 0) && (nh > 0)) {
        if ((ow < nw) && (oh < nh) && !st) {
          w.set(ow);
          h.set(oh);
        } else {
          if ((ow / oh) < (nw / nh)) {
            h.set(nh);
            w.set((nh * ow) / oh);
          } else {
            w.set(nw);
            h.set((nw * oh) / ow);
          };
        };
      } else {
        w.set(0);
        h.set(0);
      };
    } else {
      if (st) {
        w.set(nw);
        h.set(nh);
      } else {
        w.set(ow);
        h.set(oh);
        if (cr) {
          if ((w.get() >= h.get()) && (w.get() > 0)) {
            h.set((crw / w.get()) * h.get());
            w.set(crw);
          } else if ((h.get() >= w.get()) && (h.get() > 0)) {
            w.set((crh / h.get()) * w.get());
            h.set(crh);
          };
          if (h.get() === 0) {
            ar = 1}
           else ar = w.get() / h.get();
          if (crh === 0) {
            arc = 1}
           else arc = crw / crh;
          if ((ar < 1) || (arc > ar)) {
            h.set(crw / ar);
            w.set(crw);
          } else {
            w.set(ar * crh);
            h.set(crh);
          };
        };
      };
    };
  };
},["WEBLib.TMSFNCUtils","Types"]);
rtl.module("WEBLib.TMSFNCColorWheelResources",["System"],function () {
  "use strict";
  var $mod = this;
  this.GetColorWheelResource = function () {
    var Result = "";
    Result = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAACqeElEQVR4Xuz9BbhVZdjufQM2onR3SSPdId0h3d0p3VLSISkp3S3S3SIhKSmpgISUNDLn9" + "xvP5j3e3N+u59nv3vt9psdfFnOOcd/3uK9znec1FmvNFeH/i49aEUJxa0YIpawdIZS6foTQ+EYRQ+OboVXE0LG2EcPhjpHC4c7ohl7oi/4YhCEYgdH4FhMw2TlTnTvTGLMw15iLjR+wNEIo9ttp//3xv9qjVIRw8TIRQiUqRAxt+zJi6HC1SKG/ahFEvXfC4YZo+m443AKt0f69cPgrdEUP9H4/HP4aA/ENhmEUxnptPCZhCqY793vMwXxjLsJS" + "c6yIFLq72pxrI4ZWrreGTRFCRd4u698f/zM+CkYItSwcMTy8eMTww1IKXE6hKyl6FdQghDqoTyCNPwiHm6EV2n7IrdAZ3T7iVuiL/hiMoRiB0RiHifjOsdMwE7ONMQ8LscTYy82xCj+Ycx02WsPmSKHQNmvaGSHUa3eEULO3y/33x/+oj88jhBJmixCqkytiaGk+QiqkiEUVs4TClkEFha6s4NUIoBbqEkVDNI3MrdD6Y26Fr6JwK/RAb3yNgZ9" + "wKwzDKIz13HhMwhTMwCznzsECYy3GMmOvxBpz/YgN5t5sDVutZQd2W9s+a/zJWn+OGPr+sLWfjhCO9/Zy/v3x/+YjVYRQorQRQlUyRAzt+TxS6J8cCpVHwQooXGFFLKaYpRS1nAJXUuwqqKH4tQmhPhoTSTO0+pRboWNUboVu6BWNW6E/BmMoRmA0xmEivsM0x87EbMwzxkIsMeYKrDLHD1hnzo3m3oLt1rLLmvZa2wFr/Nlaj1jzMWs/ESn07J" + "RrORMhVPKCa3t7mf/++O/1SBYhVBijU0cKPUmnIJkUJqsC5VSovApWUOGKKGAJhSyjqOUVt7JCV1P0mqhLBA2JoglaROdWaB+DW6EresTkVvgaA/ENhmMUxmI8JmEqZmCWc+ZiARYbaxlWGnsNfjTXBnNuxjZr2Gkte6xpv7UdtMZD1nrUmo9b+ynXcMa1nHdNF13blQjhAVcjhPK/vex/f/zbPMLvxrbJCSKGtifRp6S0+WkUIoOCfK4w2RUot" + "0LlV7TCilcUJRWzLCoqbhVFrq7gtRW/PhoRRLNY4XBLtI0dDndAZ3SLw63QFwPicisMxQiMwThMxHden4aZmIP5zl2EpVhhzNVYa4715tqIrebeYQ27rGWvNR3Az9Z4BMes+aS1/+oazrmWC67pkmu76hqvu9abrvlmhHD2cIRwpLeb8e+Pf41H1AjhL2JGDB2Ipx9J5DM6mU1PpQBpFSKjgmTx2Z9DcfJwhAIK9oXiFVfE0opZXlEro6pC10Rd" + "hW9ACE3QgkBao308boWu8bkVeuPrBNwKQzAcozAW4zEZUzEDsxw7Fwuw2BjLsNKYa7DOHBuw2ZzbzL2T0PZYy34ctLbD1viLtZ6w5lPWfsY1nHctv7mmK67tumv8w7Xecs13XPtfEUM77kUI5Xq7Lf/++K99fBAhVOzjiKGz0Xzmxra58W1yYpud3MZ/pgDpFSKzz/hsCpNLgfIpVCEFK6pwJRWxrGJWUNQvFbe6QtdW9HpoRATNiKIl2ibkVui" + "ciFuhV2Juhf4YjKEYkYRbYRwm4jvPTcf3mIP5zluEpVhhrNVYa+z12GSurebcgd3WsM9afrKmQ9Z21BqPWetJa/7V2s+5houu5bJruurafneNNwnstmu+59of2INH74TePIkYOvgsQrjA223698d/3iP8boQIoXzvRQzv+kgMfGIzY9jUODY3AUEltdkpbXoan+EZFOFzxcihMLkVqIBCFVawYgpXSgHLKWQlBa2quDUVuY6CN1D8JmhOEK2JpB" + "2+Ssqt0CMZt8LXGJicW2E4RmEsJmAypmIGZmGuYxdiCZYbYxV+MOY6bDTHFnNtxy5z77WG/dZy0JoOW9sv1njCWk9b81lrv+AaLrmWK67pumu74Rr/dK13XPNfBPbQHvxtL57Zkxf25rU9CnGwf4/I/9Tjo1DCiO+GFkXiUO/bvMg2MarNjElQ8WxuIp/JyWx2Khufzmd4JkXIqiA5FSavAhVUqCKKVkLxyihiBcX8UlGro5Yi11PsRgrflAhao" + "i1hdEDnFNwqJbdCXwxIxa0wFCMxBuNScytM8fF0fI85mI9FzlmKFcZZjbXGXI/N5tiKHebcbe591vCTtRzCUes7bp2n8CuRnbP2i67hsmu55pr+cG23XONt13rPNT9w7Y/twVMCe25PXtmbN/YpHCkUDkV8OZHAEr7dxX9//J8eUUKVIn0UfviOjXvPxn2AKD6OZjNj2dT4NjexTU5usz/zmZ3e5mdWiGwKklth8hNUYUUqRkylFK6sIlZUzCqK" + "WkNx6yh0AzRW+OZE0Jog2uErYumCHp9xK3ydhlthCIan5Vb4FhMwGVMxE7MxzzELsQTLnbsKPxhrHTYaewu2m2uXOfea+4B1/Iwj1nTM2k5Y42lrPWvNF6z9kmu46lp+d003XNufrvGua73vmh+59if24Jm9eGlP/rE3IXsUfu9NOPzOq3Ao0rP7oQhPSr3dzX9/EFTsiFFDV9+xce+y//dt3oc2L7II+AQx/D2O1xLY3KQ2OaXNTmPTM9r8LAq" + "RQ0Hy+OwvoDhfKFRxBSutcOUVsLJiVlPUWopbV5EbKnhTtCSANsTQAZ0IpFs6boW+6bkVBmMoRmbgVhiHSZiC6fgeczDfMYuwDCudvwY/YoMxNxt7G3aaa4859+OgNRyylqPWdNzaTlnjGWs9b82/Wftl13DNtfzhmm65tjuu8S/X+sA1P3btT+3BC3vxyp6E7E04cshmvbZpL2zeU+J6HApFfHgqHOFG5Le7+//RR+xQ/UixQ+feYf/v2bwPbN" + "5HIuBjGxjFBkZFTB/H9VwiryezyalsdjqbnsnmZ1WInD7j8ypKQQUqqlAlFayswlVUwCoKWV1BaytufUVurODNFb4VIbTDV8TRJSO3Qm98nYlbYUhmboVR+BYTMBnTMBOzMQ8LsQTLnbMKPxhjPTYadwt2mGOX+fbigLl/toYj1nLMmk5a26/WeM5aL1jzJWu/6hp+dy03XdNt13bPNd53rY9c8xPX/twevLQX/9iTsE/CcJR/bNZLm/bM5j2xi" + "Y+4133ReO9sKMKfdd7u8v+HHmlCn0RMGN71ToJQ6F2foe/bwA9tYGQxEMUmfmoToxFbdBsZC/H8PbHnkzvmM8emt+mZbX52n+m5FSO/whRWoGIKVUrByilcJQWsqpA1FbWuAjdEU8VuofBtiKADQXRCt8/D4Z7om8WdIAZn5VYYiTEYl41bYQqmYxbmYoHXFmMZVmKNc3/EBmNtxjZj7zTPHuw350FzH7aGX3DCmk5Z2xlrPG+tv1nzFWu/7hpu" + "ENgt13THtf3lGh+61r9d8zPX/sIevLYXIXsSji4Co72yWdwqylOb99gmPrCZ97jXHe5181Uowu9rNfbvvd31/8UfyUM5IyYL/fSODXzPBn5gAz/yWfqxTfzEJkYltOg2MoaNjEVocWxmAh8n8VxKr6dxXEbnZHFuDoLKoxgFFaaIApVQqDIKVkHhvlTA6opZW1HrK24jhW6m4K3QjgA6EkMXAumB3tm5FQbm4FYYjlE5uRUmYDKmYSZmYx4WYSl" + "WOHY11mK9MTZhqzF3YLc59pnrJ3P+jKPWcMxaTlrTr9Z2zhovcrLL1nzN2n93DTcJ7LZruufaHrjGx671iWt+7tpf2YM39iIcRwTGEoExuFV0bvXp3zbvoU28bzPv2tQ/be4N7nWde13ZHYpwKefb3f9f9JE2VCJS6tCbd23g+8TwoU2MbBOj4FNCi4oYNjOmzYxNbHFtaHwbmpDYkvk4lefTeT2TTc/qnJzGyGesQgpTVIFKElRZBauocFUUsI" + "ZC1lHQBorbRJFbKHZrhW+PToTQjTB65uJW6J+bW2EoRubhVhiHSZiSl1thFuZigecWYxlWYo1zfsQGbDHWduw09l5z7DfXQRw29y/WcMJaTlvTWWu7YI2/WesVArtu7Tdcw5+u5a5r+su1PXKNf7vWZ675pWv/xx6E7EU4PreKy61iP7dZIjA6t4rKrT7lVlFu29SbNvcPm3yNuC5zr4tPQhEu5Hlbhf+FHoXD70bIEJofKV3o5Xs28QOb+KFN/" + "Bif2MioPluj2cyYNjMWscWxofGQgNAS2dQkNjW5Pz+zyek9n9lx2Z2T27n5jVHYmMUJqrRClVewygpXTQFrKWQ9BW2ksM0UuaVit1X0jgTQhSC6ozeh9MvHrfANhufnVvgWEwpwK0zDTMzGPCzCUqxwzGqsxXrnbsJW4+3AbmPvM89POGTOo+Y+bg2nrOWMNZ2ztovWeNlar1nzH9Z+yzXcdi33XNMD1/bYnjx1rS9c8yvX/sYehBNzq4TcKoEI" + "jMet4nCrWNwq5l828Q5xcatPuFXk6zb5is3+TTSeJ66zf4cinJ4hGiO+rcr/Ao8soRWRbOB7+MAmfmQTP8YnPluj2szoNjMmYhNcXJsa36YmJJzENjapjU1GbClsbhofZ/B8Fq/ncGwe5xR0fhFjlTBuGYWqoGBfKlwNBaytkPUVtLHiNkdrxW6v6J0IoCsx9CSOvuhfkFthaCFuhTGFuRUmYQqmYxbmYgEWYzlW4Qesc85GbDHGduwy5l4cMMf" + "P5jpizl/MfdIaTuOsNV2wtkvWeNVaf7fmm9b+p2u461ruu6ZHru2JvXjmWl/ah3/sQdgehJNp2JNwq8TcKiG3iq9hjysCY4vAmNwqOreK+rvNvWqTL9nsizb9HHH9Gg5HOhkORTi28G1V/id+pAp9EDFHeNk7NvE9m/gBPrKRH9vITxHNZsYgtlg2NA7i2dQExJbIxiaxscmIJ7nNTWlzUxNUWn9m8vesXsvluHyOL+S8osYpabxyxq9krqoKV1" + "MB6ypmQ0VtqrgtFbmNYndAZ8XvTgi9iaLfF9wK3xThVhhVlFthAiZjWjFuhdmYj0VYihVeW4212IBNzt2KncbaY9x9+Mkch8111JzHccoazljLeWv6zdqucLJr1vqHNd+y9juu4S/X8tA1PXZtT13jC9f62jWHXHs4tQhMya2Sc6ukGvYkIjARt0rAreJxqzi3bKYIjCECo3GrT7nVx+dt+hmbf0oRjovGX/Rdh6ZwrnfeVul/skf68PsR84ZWv" + "mMT37eJHyKyYkdBVBsazYbGsKGxEdemxie4hDY2MZLa3OQEl9IGp7LBn9ngtMSW3iZn9mc2z+X2Wn7HfeG84s4vbZzyxq1s/OrmqqWA9RWysYI2U9zWitxOsb9S+K4E0BN9CKI/kQzG0OLh8IgS3ArjMKkkt8IMzMJcLMASLMcq/IB1jt2ILdhujF3G2osDxv7ZHEdwzJwnzf2rNZyzlovWdMnarlrj79Z605pvW/s913DftTyyB09c23PX+Mq1" + "vnHN4XQiMC23+kzDnkoEpuRWyblVUm6VmFslFIHxRWBcbhWbW8XgVtEuENdZm37a5p9UhGPEdYS4fiauA9//TxmLEQuFlr9jI9+3kR8iss38xGZGRXQbGhOxiS6ujY1vYxMhic1NSnApbHAqG5yaaNLY5HQ2OQOhZbLRnyOHv+fxWkHHFHF8CeeVMU5F41Uxbg1z1TFnA/M3UdAWCttGgTsodmdF70YAvQihHwYSxzeluBVGleZWmFAmHP4O0zA" + "Ts8tyKyzCUqzw3Gr8iA3Y7Jxt2GmMPdhvzIPGPoxfzHXCnKfMfdYazlvLb9Z0xdquW+MNa71lzXes/S/X8NC1/O2anrm2F679tWsNueZwRm6VQQSm41ZpuFVqbpVSw55cw56UWyURgYm4VXxuFfeyzRWBMblVdG4VlVtF4VaRjyrGIeL6ibj2EdfuRW/L9T/BozqnKkZUNvJ9fGgzI9vMKIhqQ6Mjpk2Ng3g2NoGNTURsSZDMBqe0wals8GdIa5" + "PTI6ONzkxsWWx2VoLK6c98nivktaKOK+Wccs6vZKyqxqxljnrma2TuZtbQSmHbKXBHhe6i6D0Uvw8hfE0UgzCUWEaU41YYV55bYQpmVOBWmIsFWILlWIUfsM4xG7EVO5y7C/uM9ZMxf8YRcxw310lz/mruc9Zw0VouW9M1a/vdGm9a621rvmftD1zDY9fyxDU9d22vXPMb1xrOyq2yiMBM3Cojt0qvYU8rAj/jVqm4VQpulYxbJdGwJxKBCbhVP" + "G4Vh1vF5FbRT9j8XxThsGL8rCgHiGsvce0iru0a+mX/g8diaT1VafFnM9+3mR8isg2Ngqg2NTpi2tg4iGdzE9jcxEhqg5Pb4JTElhppbHQ6G53BRmcits9tdlabnY2r5bDhuZHfx4U9X9wxpR1b3nlfGqO68Wobu745GpuvublbW097Re6k2N0UvhcB9MMAgviGQIZV5FYYW4lbYTKmVeZWmIP5WPQlt8JKH6/Bj9iAzY7dhp3YY4z9OGjMw8b+" + "xRwncNqcZ819wRouWcsVa7pubTes8U9rvWvNf1n7Q9fwt2t55ppeurZ/XGPItYZzcKts3Cqrhv1zEZhJBGbgVum4VRoNe2pulVIEJheBSblVYm6VQMMeT8MeRwTG5FbRuVVUbhWFW0Xepzi7iWsHcW0lrk3E1f9/3O+QiFheo24j38eHNjMyPkFUmxrDpsZCXBsbHwmJLjGS2uTkNjkVPrPRaW10ehudkdgyI4sNz2bDsxNbTpue26bnJbYCKOL" + "vJbxW1jEVnVPFuTWMU9eYDY3d1Hwtzd3WGjpaUxfF7q7ovRX/a0IYhCHEMYJgxmBcFW6FKVXdCWJWNW6FhViC5ViFtVjv9U3Yih3O2Y19xvgJh4x51NjHccpcZ8x5ztwXreGytVyzpj+s7ZY13rHWe9b8wNofu4anruWFa3rl2t64xnBebpWbW+UUgdlFYDZu9Tm3yqxhzygC02vY03Krz7hVKm6VXMOeVAQmFoEJRWB8bhWXW8XiVjEOKsZ+4t" + "qjODsVaRtxbSGujcS1/n/AWAy+TlU5tOIdG/q+zfwQkW1oFES1qTEQy8bGRXybmxBJbHAypLDJqWzyZ0hLcBlsdiabnRlZbXh2Ysth03PZ9DyEls/GF7DxhVDUx6U8X87rlRxbzTm1jFHPWI2M28w8rczZzvxfWUtX6+ppjX0VfwAhDCaKYRhFKGOrcytMrsGtMLMmt8J8LMIyrMQa/IgN2Ixtjt2Fvc49gJ+NdcSYx3DSHKfNddacF8x9yRquW" + "svv1nTTtf9pjXet9b41P7L2J67huWt56Tr/cW1hn0zh/Br2fNwqD7fKxa1ycKtsIjCLCMzMrTJxq/TcKi23+kwEphKBKbhVMm6VhFsl1LDH17DHFYGxRGAMbhWVW0XhVpG3KtYm4lpPXGvDoQirZv+PFYvVQvMj2dD38KENjYwoiGpjYyCWzY2L+DY4IZLY5GRIYaNT2+g0SGezMxBCJnxu07Pa9Ow2PSdy2/i8BJff5he0+YWJ7QsFKI7S/l7e" + "8186prpjazu3vjGaGLOF8duYp4M5O5u/uzX1xtfWOZAIhhDECOIYjXG1uFVtboUZdbgV5mJhXW6F5ViNtVjv+U3Yih3Y7Zx9+MkYh4x1FMeNfcocZ8x13py/4Yo1XLOWP6zplrXdcc1/WetDa35s7U9dwwvX8to1hVxb+AsRWJhbFeRW+blVXg17bm6Vk1tl51ZZudXnGvZMGvYM3Codt0rDrVJzqxTcKpkITCICE4rA+CIwLreKxa1icKuo3Cr" + "KZsXaoGg/Kt4P4XCklcS1dOTbqv6//KgVKhGpVujlezb1A0S2qZ8gqo2NjliIa4PjI6FNTmKDkyEFUhNdGpudDhlteGYbngXZbHoOwsiFPDY/n80vYPMLEdsXClBUAYoRWglFKOPjip6r4vUajqvrnIbOb2q8lsZta46O5upi/p7W0sfa+lvnYEIYhpGEMZZYJtTjVpiGmfW5FeY34FZYhpVYg3XYiC3Y7phd2OucA/jZOEdwzJgnjf0rzpnvIi" + "6Z+6rr/91ablrTbWu7Z40PrPWRNT+x9ueu4ZVreeOawiVEYDFuVUTD/oWGvZAILMCt8nGrPNwql4Y9hwjMJgKzcKvM3CoDt0qnYU+jYU8tAlNwq2QiMAm3Ssit4mvY4+5SlO2KIwKjbiSudYq2VvFWh8PvrgiHIi1+FoqwKPfb6v6/9GgUyhmpXujNezb1A3yEKDY2KqLb3JiIi/g2OCGSKGgypLDRqZHGZqdDRkXPbNOzILuNz4ncNj+Pzc9v8" + "wsSW2EUUYSiilCc2EoqRGmFKEdslXxc1fO1vF7P8Y2c19wYrY3X3tidzNXNvL2soZ/1DLS+IdY6nChGYxyRTGzIrTC9EbfC3MbcCkuwHKubcCus9/EmbMNO7Hbsfhx07mH8YqwTxjyFM+Y4b67fzHnF3Net4Ya13LKmu9b2lzU+tNa/rfmZtb90Da9dS8g1hUtzq5IisLgILMqtinCrQhr2ghr2/CIwjwjMxa1ycqtsGvYsGvbMIjCDCEwnAtNw" + "q1TcKgW3SsatkojAhCIwvgiMIwJjisDo3Coqt4qyRvFWKuIy4lqs31rwJhRhbo63Vf7v/GgS+iRi49BP79rcD2zsR/gYUW1udMREHJscHwltchIks9EpkNpmp0E6ZLTpmW16FmSz8TltfG7kJbgCClAQhRWhqCIUI7YSClFKIcoQWjnFqKAYlf1Z3XO1vdbAcU0c38L5bYzTwbhdzNHDXH3M/bV1DLKmodY30nrHWv94TCaaaU25FWY341ZYhGV" + "Y2ZxbYR02YovntmMX9uKAc37GEWMcM9ZJ/Grsc+a4aK7L5rxm7j+s4aa13Had96ztgTU+ttan1vzc2l+5hjeuJVyeW5UTgWVEYCluVYJbFROBRUVgYW5VkFsV4FZ5uVVuEZhTBGbjVlm4VWZulYFbpdOwp+FWqTTsKbhVMhGYhFsl5FbxuFUcbhWTW0UXgZ+uUrzlirhEk7xQvzWPuOZsE4sfva32f79HxGbhXe/Y1PfxIT7GpzY3GmIijk2Oh4" + "RIYqOTIYXNTo00NjwdMtr0z5HVxmdHTpufG3kVoIACFMIXhFFUIYorREmFKI2yxFZeQSoqSCViq6IoNXxc13MNvd7Usa2c1875Xxmvq7F7mqevOQeY/xtrGW5do63zW+ueSCxTML0Ft2rJrbAQS1pxK6zGWqzHZmzDTuxxzH4cxGHn/mKMEzhtzLPGvmCOS+a6as7r5r5hDX9ay11rum9tj6zxb2t9Zs0vrf0f1xByLeFK3KoityrPrcpq2EuLw" + "JLcqji3KsqtvuBWhTTsBURgXhGYm1vl5FbZuVVWbvW5CMyoYU/HrdJwq9TcKgW3SsatknCrhNwqnoY9jgiMKQKjrVC8pYq4SDHnK+oc4vpevzV98dty/3d6tAnVf6dVKPSezf0QH+MTRLPBMRAb8Wx0AiRGMpudAqlteBqkQ0Yb/zmy2vwcyKUAeZBPEQoqQiF8oRDFFKIESilGGYIrpyAVFKQSsX2pKFUUpRqh1fJnPX9v7LXmjmvt+PbO62Sc" + "7sbsbeyvzTPQ3EOsZYR1jbHO8Zhs7VNbcyvMacOtsKgtt8JKrME6bMQWbMdu7MNPjj2Eo849jlPGOmPMc7hojsvmu4Y/zH3LGu5Yyz1remhtj63xqet5Yc2vrf2NawhX41ZVuFVlblVJBFbgVuW4VRluVUrDXkLDXoxbfSECC3GrAtwqn4Y9j4Y9l4Y9uwjMKgI/51YZuVU6DXsabpVKw55Cw55Mw55YBCYQgfFEYGxuFUMERlusiNwq8jxFnaW" + "Zn6nfmvomFOG78m+r/m/8aB+KHald6Ny77UQgIuMTRLXJMRAbcW10AiRGUpudAqmRxqanQ0ab/jmy2vjsyIU8ip1PAQqiMMEVQXHFKKEYpVBWQcorSEViq6woVVBVYaoTUU3Fqa049f3ZxHMtHNPGsR2d18UYPYzVx/j9zTPYvMOsYZT1fGt9E6z3O0x3Dd+351ZY2IFbYQVWd+RWWI/N2Iad2OO1/TiIw875BSeMcdpYZ3HB2JfMcdVcv5vzpr" + "lvu7a71nLfmh65nifW+Nx1vLTmf6w97BrCNTXs1TXsVblVFW5ViVtV1LCXF4FlRGApblWCWxXjVkW4VWERWFAE5uNWebhVLm6VnVtl1bBnFoEZNOzpRGAaEZhKBKbgVklFYGJulYBbxeVWsblVDG4VlVt9wq0if6+40/VbU0TipF9DEcbEeFv9f7tHxK9CV9/5ilviI0RBVBsdHbEQF/FtdiIkRXIbngppkM7GZ0RmZLX5OZBLAfIgnyIURGGFK" + "ILiilFSMUqjLFGUV5SK+FJhqipMNaKpoTi1FKcOIdVToIZo6u8tvdbOMV85vqtzexqrnzEHGn+IuUaYd4w1jLOmSdY41Zpnuo7ZmN+JW2EZVnYOh3/AOmzEFuzAbuzDT445hKM47txTOGOs88b8zdhXzHHNXDfMecvcd6zhL9fz0Jr+tran1vjCWl9bc8jaw/VEYB1uVYtb1eBW1TTsVUVgZRFYkVuV51ZlNeyluVVJDXtxEViEWxXmVgW5VT5u" + "lYdb5RKB2UVgVhGYmVtlEIHpuFUabpWKWyXnVkm5VSINe3xuFZdbxVqgiHNFIreKMkNxpyryZJE4gbi+Pf62/P9Gj66hSu905ZL4EB/jU0TrIqoRB/GRyKYnQXKksumfIR0y2vjMyILsCpALeRQhHwqisGIUUYziKKkgpVFOUSooSiV8qTBViaS64tRUnNqoq0D1ia2hIjVSpOb+bO259l7r7NjuzultjK+NNci4Q80x0lxjzT3BOr6zrunW+b1" + "1z8UC17Okm94Kq7EW67tzK2zDTuzx3AH8jCOOP4aTzj2Nc8a6aMxLxr5qjt/NddOct819zxoeWMsja3pibc+t8ZW1vrHmcCMR2JBb1edWdTXstUVgTW5VnVtV5VZfcqtKIrCChr0styotAktyq+LcqoiGvbCGvaCGPR+3ysOtcnGr7NwqC7fKzK0ycKt0GvbPuFVKDXtyEZhEw55Iwx5fBMYRgTFnK+ZMRZ2muN8p8kTFHicSR4fCEUb/G/3kde" + "9Qwkg9ww/f7cklERmf9OBWiInYiIeENj4JkiGljf8MaZHB5mdGFmRDTkXIg3wKURCFFaMIiitISZRWlHKooDCVFKYKqilODcWphToKVI/YGihSI0VqTGxNFaoF2vi4o+e7OKaHY/s4d4BxvjHecGOPNt84c0/CFGubgdnWO8/6F2GZa1uJH3pxK2zEVuzAbuzDTzjkmKM47pxTOGOM88b6zfVdMfZ13DDXn+a8a+6/rOGha/jbmp5Z+0trfG2tI" + "WsON+VWjTXsjURgA25Vj1vV4Va1uFUNDXs1EfilCKzErSpwq7LcqrSGvaQILC4Ci3CrwtyqILfKx63ycKucGvZs3CqLhj2zCEyvYU8rAj8TgSlFYDIRmFgEJhSB8URgbBEYQwRGnaK4kxR5vGKPFYmjuNbwP8IR+kd5q4Z/pUf/8LsR+4YWvdOXO+IjROljfsRALMRFgt7WiaRIidQ2Py0yIBOyKEJ25FSE3MiHgopRGEVQXFFKoozClENFhams" + "MFVQjehqoLYi1VWk+orUgGAao4liNVOsFoTUSsHa+fMrf+/mtV6O6+ecgc4dYpwRxh1jjvHmm2z+adbzvbXNwQJrXuI6lmO1a1yLDdiMbdiFvTiAn3EExxx7Er8695wxLuKyMa8Z+w9z3DTXHddxz9wPrOGxtTy1pufW9soa31hvuBW3aiECm4nAJtyqMbdqoGGvr2Gvy61qicAa3Koat6qiYa/MrSqKwHIisAy3KsmtinOrIhr2whr2ghr2fCI" + "wt4Y9pwjMJgKziMBMIjC9CEwrAlOLwBQiMKkITCwCE3CruCIwlgiMIQI/naDI3yr2aEUfIRKHEtfgaWHd0FtV/Cs8+ofyRRrAFfEhPu5vXkRHTMRB/K+5KpIiBVIhTT/XgUz4HNkUIidyI69iFERhFFGU4iipKGVQXmEqorLiVEV1BaqJ2opUlzDqK1RDNFGsporVXLFaEltrBWurYO3R2cfdPd/b6187drDzhhljlPG+NfZE80wx5wzzz7Keed" + "a3CEuteyXWuKZ12Oh6t2IHdmMffsJhr/2CE449jbPOvYBLxrpqzOvGvmGOP81115z3rf2RNfxtLc+s6aW1/WONYZ8U4bbcqjW3asmtmmvYm4rAJiKwIbeqz63qcqva3KqmCKyuYa/CrSpzq4rcqjy3KqNhLykCi4vAIiKwsAgswK3yisDcIjAnt8rGrT4XgZm4VTpulUYEpuJWyblVEm6VSATG51ZxuFVMERh9HNcao9gjFX2Y4n8TDkcaGA5F6" + "J/trSr+2x8RB4d3vTuYKyIyoiAaYiD2IC6KhEiC5EiFzwZaPzIis0JkRQ7kRl4FKYBCKKIoxVESpRWmHCoqTmVUVaDqqKlIdVBPoRooVCM0UaxmhNJCwVopWBu0U7QOitYRXdDD3/t6foDjvnH8cOePMc44Y042/lRzzTTvHOtYYF2LrXU5Vlv/WmxwfZuxDbuwFwfwM47gmGNO4oxzzuGiMS4b65ox/zD2LXPcMddf5nxo7sfW8NRaXljTa2t7" + "Y43hjtyqA7dqx63aiMBWIrAFt2rGrZpo2BtxqwYa9noisDa3qsmtqnOrKtyqsoa9oggsJwJLi8CS3Kq4CCzCrQpxqwLcKi+3ysWtcnCrrNwqM7fKyK3ScavPuFVKbpVMw56EWyXkVvFEYGxuFYNbRR2l2MMVfQjXcqHv9OdafTe+lcV/42NIqFikYaHQe0QbCPdjfIroiDWUeyIBEiMZUiK1daRFBmRGVmLPjlzIgwKKUghfoLj1lkRplFOciqi" + "sQFVRXZFqoo5C1UMDxWqEpgrWXMFaorWitVW09sTWUeE6KVxnYuumeL183M9zA70+1HEjnTfW+ROM9Z1xp5tjlnnnWcdCLLW2lda7Butcx0ZsxQ7Xuhv7cRCHPfcLTuC0Y8/ignMvGeMqfjfmTWPfNsddc9035yNzP7GG59byypr+sbawNYY7a9g7adg7isD23Kott2rNrVqKwOYa9qbcqhG3asCt6nGr2hr2mhr26iKwigisLAIriMBy3Ko0ty" + "rJrYpp2L/gVoW4VQENex4Ney5ulV3DnkXDnplbZdCwp9WwpxaBKbhVMg17Yg17Am4Vl1vFEoHRReCnLvJjFxVE1Xv9NPK9X4Ui9Pxv/7fEiKNCZ/Vu4Q8QGZ8gGneMiTiIj0RIiuRIZS1pkB6ZkAXZiT4n8iA/CirOFyiGEtZdGuVQQYEqoyqqK1RN1HFN9dBAsRqhKeE1d40t0Ubh2ilce4X7Cp0JrQu6KWAPBeyNr/19sKIO8/oox3/rvEnGm" + "WrMmcafY6755l5sLcuxyvrWWvMGbHY927ALe3EAh3AUx3HKMWdw3jm/OfcKrhvrhjFvGfuOOf4y10Nz/m3uZ9bwwlpeW1/I2sI9RGA3EdiFW3XiVl9xq/Ya9nYisA23asmtmnOrptyqkYa9gQisJwJrc6ua3Ko6t6rCrSpzqwoa9nLcqrQILKFhL6Zh/0IEFhSB+TXseURgThGYTcP+uQjMJALTi8A0GvZUIjC5CEzCrRJq2ONr2OModEwXFs2F" + "fGLTI9voD2ymu7dQxG7b38rjv/LxbfiLd8zxXtDD+TMKoiI6YiMeEiCJKE6GlPgM6ZARnxN9NuRAbuSz1oIojKIooTilUBYVFKgSqqC666mJOqinWA0UqxGaormitXStbdBO4TooXCd0du1dFbC7Ava0B70Vsa8iDvDnN54b7rUxjhvvnMnGmGas74091xwLzbnUGlZY0xqss9aN1r8VO7Ab+13nQRz28S84gdM469iLzrmEq8b43Vg3jXnb2Pf" + "M8cA6H5nzibmfW8Mra3ljTeE+IrA3t+rJrbpzq64a9s4i8CsR2IFbteNWbTTsLTXszblVUxHYiFs14Fb1uFVtblWTW1XnVlVEYCUNewURWFYElhKBJURgURFYWAQWFIH5RGBuEZhDBGYTgZlFYEYRmE4EfiYCU2rYk4nAxIqdwEXFdSGxbFR0C49q0R/bzA99NrzXnWt1CYUidP7srUr+Cx873QlOCB1411wfIDI+QTTERBzEJ+5ESIoUSI20yI" + "DM3DQrsiMX8qKANRdGURRHKYUqi/KopEhVUA01XVcd1EMDBWuEporWAq1cbxu0V7yOitcJXRSwmz3ooYi90Ech+9mP/sQ2UDGH+Hik58Y6ZoJjpzh3hjFmG2++sReZZ5l5V1nHWutaj83Wuw27XMteHMAhHMVxnPLaGZx37G+44tzrxrhhrD+NedfY983x0Fx/m/OZuV9awz/WErKm8Nfcqh+36qNh7yUCe3CrbtyqC7fqpGHvIALbicA23KoVt" + "2rBrZpyq0Ya9gYa9noa9toa9poisJoI/JJbVRKB5blVWW5VilsVF4FFuFUhEVhABOblVrlEYHYRmFUEZhKBGURgWhGYWgSmcEFJXUQQQfFtbBwLjmmx0XwmfMJmI8vwD+T3u524VodN/3V3iFNC+SOZ7z18hCiIiuBONDbiISGSIDlSIQ0nTYdMyIJsyIk8yG/dhVAExVCSMMugPCriS8Wqhhqo7frqoYGCNUJTtFC4VmjrutujowJ2RldF7G4f" + "eipib/RVyK/tyQDFHKiY3xDaMH+O8tw4r01y7FTnzHTuHOMsMOYSc63AGnOvs5aN1rcFO6x7N/bjIA7jGE7iV5xzzEVcds415/5hjFu4Y8x7xn5gjsfmemrOF+Z+ZU1vrCU8mFsN1LAPEIH9uFVfbtWbW/XgVt1EYFcR2JlbdeRW7TXsbblVKw17CxHYVAQ2EoENuFU9EVhbBNbgVtW41ZfcqiK3Ks+tynCrktyqGLcqwq0Kcqv83CqPCMzJrbJ" + "xqywiMKMIDIqWxgWksvDkFpzEYhNaaFyfBbHZf/A1pU81sR9rXj90K/6eW/BI7dwhtvz8rVr+8x8Rp4W2v0vMHyAyPkE0xEQcxEciJEUKThq4aVpkQGZkRQ7ktu58KIgvUBQlCLQ0yqEiviTKqqiB2qjrOhugkaI1RXO0Ury2aO/6O6KzAnZFd6LrZT96o69i9lfMgRikmN9gKLENt09jfDzenk12zHTHznLePOMsMuYy468y3w/mXo/N1rTNOn" + "dhLw64jkM4iuM45bmzOI/fHHvVOddxwxh/GuuuMe8b+5E5npjrmTlfmvsfawlZS3got/pGBA7iVgO51dca9r4a9t7cqie36s6tunKrTiKwo4a9vQhsKwJbicDm3Kopt2rErRpwq7rcqpaGvQa3qqphr6xhr6BhL8etSmvYS3CrotzqCw17QW6Vj1vl5lY5RGBWxcts4RksOK3FprZxKSwyqc+ARNwqvgiMIwJjisBo7jY+cSsb+SuiaM+1WnOtF" + "pveyuU/8/F9qHCk790J6us+wsccMypiIDbiISGSIDlSIQ3SI5P1ZkF25EJeFEBhFPUJUhylUBYVUNm1VUV11EJdhauPRmiK5orXEm0UsD06orO96IruCtlLIfugn73pr5gDMZjghtinYYo6QlFH2a+x/pzo71O8NsMxs50z3/mLjbPcmKvN8aP5NlrDFuywtt3Yb90HcRjHcBK/4pzXLuKyY6/hD+feMsYdY/1lzIfG/tuanprrhTlfmztkHeFR" + "3GoEtxrGrYZo2AeLwIHcqj+36set+nCrnhr27iKwqwjsLAI7cqv2IrANt2rJrZpr2Jtyq0bcqr4IrKthryUCq4vAKiKwkoa9gggsq2EvpWEvLgKLaNgLcav8Gva8iprL4rNbcBYbkckC09ugND77UrH25Gw+iT4ioQiMJwKDf1aJIQI/7UQMHbhWG67VUq/V1B1i4/+CO8Q5odHvmP8DREbwD97REBNxEB+JkDS4U8VnSIeMyIxsyIngEyMfxy2" + "EL1AMJVEG5V1bJVRBNdREHcKsj4ZoguYK2BJt0N4+dERnReyK7uilmH3sTT8MUNBB+EZRhyrqcPs1EqMVdizG2btJ/pzque+9PtexC5231BgrjfWDsdebZ5N5t1nLTuy1zgM4hKM4jtM4iwu45Jir+N05N5172xj3jHXfmI+M/cQcz831ypz/mDv8LVGN1bCP5lYjReBwETiUW33DrQZp2Ptr2PuJwD4isCe36s6tunKrztyqI7dqp2FvIwJbat" + "iba9ibiMCGIrC+CKwjAmuKwGoisIoIrCQCy4vAMiKwpAgspmH/QgQWtPB8FpvbInNYXFYLy0z1GVlqWnYafK0ohQhMyq0SicD4IjCOCIwpAqOJwE/aEkWrcPj95uHwO03EYYO+b1Xzn3jMDyWKtCD05D3r+BAf41NCj47YiIfgn5aSIPiibSqkQXoEd7BZEPSGuZAXBVAYRVECpVHO9VXEl6iKGqhNqPXQAE3QDC0Jsw3aoaP96Iyu6K6YvdBHQ" + "fthgH0ahG8UdqjCjrBnozBGcb9V3PHENsEeTsY0f5/l+XmOW+T4Zc5bbYy1xt2ALebaYe7d2G9dB3HEmo/hJH7FOc/9hiuOuYY/nHPLuXfwl7EeGvNvYz8zxwtzvTZnyNzhCSJwvIb9W241mluN4lYjNOxDReA3InAQt+rPrfpxqz7cqie36q5h78qtOonADiKwnQhsw61aiMBmIrAxt2ogAuuJwNoisIYIrCoCK4vACiKwrAgsLQKDzS9qoYUt" + "sICF5bUpuSg+O2vPwkqDrw2lF4FpRGAqDXtybpVEBCYQgXFFYCwRGL0dMbQmihbE0ZRrNeJa9W6EIzSM9lY9/38ei0NV3iHw9/ERoiAqYiIO4iMRkiL4p6bUHDYtMiAzsiEn8iA/CiFw4eKurRTKoAIqoQqqoxbx1kUDNEZTtCDQ1miHDvakE7qiO3opah/0U9QBGGy/hmCYwo4guFEYY//GKfAETLSPkzGF2Gb4c7aiL/D6EsetcM4aY6wz3iZ" + "jbzPfTuy1hgM4ZH1HcQKncRYXcMlrV/G7Y2867zbuGeOBsR4b84mxn5vjlbnemDM8hVtNFoETudV4bjWOW40RgaNE4AhuNYxbDeFWg7nVAA17Pw17HxHYU8PenVt1EYFficAO3Kott2rNrVpwq6YisDG3asCt6nKrWiKwOreqIgIricDyNr+MRZaysGIW9YUFFaL24G4qN7fKIQKzisDMIjCDCEwrAlNr2FOIwKQiMJEIjC8C44jAGCIwakuiaE" + "YcjYmkAdeqw7Vq/KffeyvistCedwn9A0TGp4jOTWMhLhIgMZIjFdIgPTIhC7IjF/KigOsqjKIogdIoh4r4EtV8MtVEHdRHIzRBc4JthbZoj072pgu6o5ei9kE/DFDYwRhi34ZhpOKOxlgFHmcfJ2ASwX2n0FPt6XSFnom5Pl7o+aVeX+X4tc7dYJwtxtxujt3m3I+D1nIEx3ASZ3Aev+EKrjvmBv50zl3n3jfGQ2P9bcxnxn5pjn/MFTJneDq3m" + "sqtvtOwT9KwTxCB47jVWG41mluN1LAP07APEYGDRWB/EdiPW/XhVj25VTdu1YVbfaVhb8+t2nKrVhr25tyqCbdqxK3qc6s63Komt6qmAF9aXEWLCiKitE0o4bOsqM+uwtyqAFHlFYG5RGDwFewsIjCTCExPVGk07ClFYDIRmFgEJhCBcUVgLBEYTQR+0oQ4iOqDupr4Wpr46ivfyuc/8lgaShhpVeif96zrQ3yMqIiB4DtY4yEhkiIFUiMtMojy" + "4J+gsiIH8iA/CiG40y2OUiiLCqjsk6kqaqA26qEhGqMZIbdEG7THV/anM7qhJ3oTZD8MwCDFHYJhGGkPRyvwWIxX5ImYbE+nKPQ0hZ6B7xV7NuZhsb8v99pqx/3onI3O32qcncbdY54D5j6Eo9Z0AqdxFhdwCde89gduOva2c+4594ExHhvrqTFfGPuVOd6YKzyLW33PrWaIwGkicAq3msytJnKr8Rr2sSJwtAgcKQKHcash3GoQt+rPrfpp2Ht" + "zqx7cqpsI7Kxh76hhby8C23Crlhr2Zhr2xhr2htyqroY92NQaFhVEQmWLqEDhZam7FOssLpe/4FaFRGB+EZhbBOYQgVlFYPCPuhmIKviWlNQiMLkITEJUCUVgPBEYWwTGEIHBT8x8XI9IaovDGuKwyutQhNIfvFXR/8NjbajOO9b2Pj7CJ8QfDTERB/GRGMkQfK/YZ0iHTMiC7Aj+SSovCqAwinLlEiiNcqiIL1ENNVEH9e1FIzRFC7RGO3Qk2s" + "7oih7oTZR90R+D7N03GIaRCjwaYxV5PCba08mYqtjTFXsmZin4HPs8l9gWKPoSH6/w3BrHrHfsZudtN9Zu7DP+QfMdtoZjOIkzOI/fcAXXccMxfzr2rnPum/+RMZ4Y65kxXxr7H3OEzRWeq2GfIwK/51YzudV0bjVFwz5ZBE4UgeO51VhuNZpbjeRWw7jVNxr2QSKwv4a9r4a9twjsIQK7isBOIrCDhr2dCGwtAluIwKYa9kbBZlpQHQup6aKrm" + "fxLyq7INsuJwNIisIRmr6g7mcIisIAIzCsCg3/EzSYCg29BySgC04nAz0RgSn1VMhEYfI95fBEYRwTGFIHR6ovDOkRSk1iqisPK4XCE8pXfquj//oi4PrT0XcL/AB/jU0RHLAQ/1JEQSZAcqZAGGZCZA2dFDuRGPhREEQRf/C2FsqiAyqiKGvahNuqhIZqgOVqhLToQdid0QXf0Ql9C7Y+B+MYeDsUIjFbksRiPiYo9GVPt73QFn4nZij7XXs/D" + "AoVfZM+XKv4qH6/12gbHbHHODufvMd4B4x/CUXOewGnrOYuLuIxrnvsDtxxzx/F/4aFz/zbnU2O9MOZrY4fMEV7ErRaIwHncai63mq1hnykCp4vAqdxqMreayK3Gc6uxGvbRGvYRInCoCPxGBA4UgV+LwL4isJcI7C4Cu4jAr0RgBxHYVgS2sqHNLaaJi2ho8nomru0zKLgrqioCK4vACiKwrAgsJQKLicAvRGBBEZhPBOYWgTlEYFZ3gZlFYHo" + "RmEYEpiKq5CIwiQhMIALjElUsERhdBH5aSxxWI5YvxWFFcVj2P/4TPZE46nsIfpw/CqIiBmIjPhIhKYLvx0+NdMiIz5ENwbf95EEBFEZRlEDp4Ot1qIgvUQ01URcN0BjN0AJtfPK1R0d0Rjf0RB8C/hoDMRhD7eUIjMJYjFfwiZis4FMx3T7PxGxFn4v5Cr/Ivi9W/KWKv9z+r/bnj57b5LVtjt3lvH3G+Ml4h81xDCfNfQbn8Ruu4Hfc9Npt3H" + "Psfec8cu4TYzw31itjvjF2eDlRLeVWi7nVQg37fBE4l1vN4lYzudV0bjVVwz5Zwz5RBI7nVmNF4CgROIJbDRWBg0XgQG7Vj1v1EYE9RWA3EdhZBHa0ue0sorXJA6tvZtJGFF2fVdYRgTVFYDUR+KUIDL4SXW6CYnCrEiKwqAgsLALzi8A8/RVPBGYTgZ+LwIxElVYEphaBwU/CJCWq4Of44onA2CIwhgiMWp37VCGWSkRTThyWevFWRv+Xx7ZQy" + "3c46/v4CFEQDTERBwmQGMmQEp8hPTK5vuA7X7MjN/KhIL5A8A/sJVEGFVAZVVEDtVEPDX3SBb1nc7QKPgERfCJ2Qlf04PS90Q8DMAhD7OdwjMIYjCPIiZis4FMxHd/b7zmYp/ALFH4Rltj/ZYq/AqvU4Qes9/Fmr2133G7H73fuz8Y6atwT5jqNs7hoLZdxzcd/4BbuOOYvxz50zt/OfWaMl+Z4bcyQscOrNOwruNUyEbiEWy3kVgu41TxuNVvD" + "PlMETheBU0TgZG41kVuNE4FjuNUobjWcWw3hVoO4VX9u1VcE9uZWPWx8VwvoZOIOFt/WZ04rnzHNWXITdtyQWwVfu6ktAmuIwKoisJIILE9UZURgSREYfGvJFyKwoL4qrwjMJQKzi8As+qpMIjB9e0UWgSlFYDJ9VeJG3EUExhGBMWsQhwiMIgI/Kk80ZcRhSXeHxRu/VdP//oi4Mzz8XbH9AYJ3uPkU0RELcZEQSZAcwY+opUEGZEZW5EAe5Ef" + "wPWZFUBylUc4nWEV8iWqoiTqoj8ZohpYIetH2+ApdOH139EJf9MdAfGNPh2EkxmAcJhDoZEzFdMWfiTn2fR4WYDEBLCWA5VihFquJ4AciWKsmG/y51XM7vbbXcT85/rDzfzHWSWOfwXnzXsJV/I6bnruNe4554NjHznni3OfGeGWsN8YMr+VWP2jYV3OrFdxqObdaqmFfpGFfIALnicDZ3Gomt5rOraZq2CdzqwncapyGfTS3GsmthmnYv9GwD+" + "RWX3OrPhbQ06TdTdbFRF9RcTsW2ZoFtxSBTblVI25VXwTWEYE1RWA1ERj8Y2xFEVhWBJYSgcWJqoi+qpAIzCcC84jAHPqqrJ0UVQRmEIFpiCqVviq5CEwiAhMQVVx9VSwRGJ2oPqlALGWJppQ4LEZYRfq9ldP//oi4J/wweJO3D/ExPkUMxPZJEg+JkBQpkBrpkBGfIxtyIi8KoDCKogTKoDwqoQqqozbqIfiicRM0t1+t0BYd0Ald0QN90A8Df" + "KIOxlCMwGh8iwmEOwlTMB0ziXI25mGBGizGUiJYTgSrsEZNfiCEH7GeGDapzzZ/7vL8PscddPwR5x7HaeOdNcdFXMY13MCfuOu1+455iL+d88zYL43xj7FCxgyv51Y/cqsfuNUaDftKEbhcBC4VgYu41QJuNY9bzeJWM0XgdA37FG41SQSO17B/q2EfLQJHiMChGvbBNmqASftZZGDhPXx2dGWPnVhjBxHYVgS2csfQnKiaiMDgny/qisBaRFXd" + "XWAVd4GVRGB5EVhGBJbQVxUVgYVFYAERmFdflVMEZhOBnxNVBn1VWhGYWgSmEIFJ9FUJ9VXxRGBsfVWMikRSjliI6sPihFVEn1XwzFs5vX0cCBePxGnfw0eIgqiIgTiIj0RIhpT4DOmRCVmQHbmRDwXxBYqhFMrakwqojKqoiTqoj0ZoipZog/b4Cl3QHb18kvZFfwzCEAzHKIwl+vGYiO8wDTPt/WzMxQJiXIylRLAcK7FGXdYSwjpsIIZNarS" + "FILb7c4+/H/D8Icf94ryTxjhjzPP4zXxX8Ttu4rbn7nn9AR479qlzXjj3tTHeGC+8hVtt4lYbNOzrROBabrWGW63kVsu51VJutUjDvkDDPlcEzhKBMzTs00TgdyJwoggcLwLHisBRNnG4CYeYZJAJ+lNvX7bYi912F4FdRGBHEdhOBLYWgS1EYFMR2EgE1heBdYiqpgisKgIri8AKIrCsvqqkCCwmAr8gquAnWvKJwFwiMLu+Kou+KlML7iECPy" + "OqlPqqZPqqREQVX18VR18VQwRGLU0sJYimKPEUDocj5eda+TO8VZXHT6ES77iG9xG8ReUniIZYCN6vKwESIzlSIQ3SIzOCH7jNgdzIj0IoguD7+ksj+I7ZivgS1VELdRH8w3xjNEcrn5TBF5M7oBO6Iriz7o2gZx2AwRiGkRgjGb7FBEzGVMzALDWYi/lYRJhLsRwriWEN1qrPOmwkiM0EsRXb1Wsnwe3150+eP+L144495byzxrlo3Mu4jhv4E" + "3dx32uPHPPEsc+d89K5/xgjbKzwdg37VhG4WQRu5FbruNVabrWGW63UsC8XgUtF4EIROF8EzhGBs7jVDBE4VQROFoETRGBwkaNNMMJCh1LuYKodwA77icDeIjD4GkxXEdhJBHYQgW3dBbYSgc1EYGMRGHyLSF0RWEsEVhOBXxJVRREYfA94KRFYXAQW0VcVEoH5RWBufVUOfVVWEZiZqNLrq9Loq1KJwGT6qsT6qgQiMA5RxdRXRStJLET1EVG9" + "X0CflZewcv7vwop4JLTtXdfyAYI31v0UwVtWxkI8JETw/l3JkRppkcEn1OfIhpzIgwIojKIogTIoj0qoihoIvjetHhqiCVqgNYJ/AuuIzuiOXuiL/hgkEYZgOEZhLMZjEqZguhp8jzmYh0VYQrDLsQpriHEt1qnTRmwmiq3YQRi71G03YezDz/5+1PMnHPOr48879zdjXcXv5rmJOz7+Cw+99rdjnjr2hXNeOzdkjPBuEbhLBO7gVlu51WYN+0Y" + "N+zoN+1oRuEYEruRWy7nVEhG4UATO41ZzROD3InC6CAwuapLBxxt0LMWOotbhbHWICBwkAvuLwL4isJcI7CYCO4vAjiIw+EfV1iKwBVE1cRfY0F1gPRFYWwRWF4FVhiiGCCwvAssQVQl9VVERGPxQZwF9VR4RmFMEZtNXZdZXZdBXpSWq4D2nkuurkojAhPqquPqqWCIwejHC+oJoiOqDvOIwlzjMvuCtrAjreOjwuz5RPsTH+BQxEBvxkAhJkQ" + "KpkQ4Z8TmC96DIhbwogC9QDCVRFhVQGVVRE3VQH8H3qjXj+C3RBu3xFbqiB3qjHwZgMIZiJMZgHIK0+E4NpmEmZmMuFmAx4S/DCqzBWuJch43qtQXbCGMHdhHHHvXbRxwHcMjHxzx3yjFnHX/BuZdx3Zg38Cfu4r7nHnn9CZ479pVz3jg3fEAE7uNWe7jVLm61QwRuE4FbuNVGbrWOW63lVqu51QputYxbLeZWCzTsc7nVLJsyw6BTDTiZWidQ6" + "jg2OEYEjhCBQ0XgYBE4QAT2E4G9RWAPouoy3+aJwPYisI0IbElUwTeyNRKB9UVgHaKqqa+qKgIrE1UFfVVZEVhSBBbTV32hryogAvOKwFz6qmz6qs9FYEZ9VTp9VWoRmIKokuqrgvf5jEdUsfVV0YsQS0GiyUc8uQkrO2Fl+fE/qOpkKG6kk6G/3nNdHyIKgrcFj4E4iI9ESIaU+AzpkQlZkB25kQ/B2wcUQXGUQjlUxJeohlqoiwZojOZohbbo" + "gM7ohp7og68xCEOCO28Ed+BjMR6TMAXT8T3mYD4W+aRfihVYjR+wTr02YjO2EeRO7CaQvdhPJD+p5c8EcgTHfXza8+cc85vjrzr/d9zCHfyFh/jba88c89Kxr50Tcm74Z271E7far2HfKwJ3i8Cd3Gobt9rMrTZyq3Ua9h807Ku51QputVQELuJW8w06x2CB9U6n8imsdJIIHC8Cx4rAUSJwuAj8RgQOFIFfi8A+IrCnvqqrCAy+9aMDUbXVV7U" + "Sgc1EYGOiaqCvqisCaxJVNX3Vl/qqir0Ji6hK6auCHz3/QgQGb5yRT1+VWwRmJ6os+qpM+qp0RPWZviqlviopUSXSV8XXV8UmqhiFiCU/YRHVhzn0WVkJK9ONUIRUH0SIcCqUMpJPmPcQ/GaMKIiGmIiDBAjegDcZUiEN0iMzsiIHgnfQyY9CKIISKI3gB3UrIfgRuOoIfrikHhqiCYLvtG2NduiILuiOXuiL4J/KBmMoRuhrR+NbTAx6XAS97k" + "zMxjwsxBIsxyq1+gE/YgM2E+hW7MBuAtyLA2p5EIeI5AiR/KKuJ/x5xnMXvH7ZsdecewN/4i4e4DGeeu25Y1459o1zwr9wqyMa9kMi8KAIPMCt9nKr3Rr2HRr2rRr2zSJwgwj8UcO+RsO+SgQGi11ioIUGmUehs1nfTBE4TQROFoETROC3InC0CBwhAoeKwMEisD9R9dVX9RKB3UVgF31VRxHYzl1gaxHYXF/VRF/VcLhNF4G19FXV9VVVRGBFf" + "VXwo+alRWAJoiqiryqkr8pPVLn1VTn0VVmJKpO+Kr2+Kg1RpdRXJdNXJSaq+PqqOPqqmEQVNQ/R5CSerESUWQOfXp+V+eMIEX4LpX6HG7+Pj/AJoiEW4iIBkiA5UiF479QMyIxsyIk8KIDCKIoSKIPyqISqqIHaqI9GaIqWaIP2+Apd0AO90Q8D8A2GYSTGYDwmYQqm43sEve98NVqEpViB1ViL9diErYxhB3ZhLw4Q60EcUtejOEYsx4nllBqf" + "9fFFz13x+u+OveX8O/gLD/G355557aVj/nFsyDnh4yLwGLc6wq0OcauD3Gq/CNwrAneJwB0icKsI3CQC14vAtRa92iArTLqUshexzvncao4I/F4ETheBU0TgJKIaLwLHiMCRIjD4x9Fv9FUDRGA/EdhbBPbQV3WZZhNFYHuiaqOvaqGvaioCGxFVfX1VbRFYg6iq6qsq6avKE1UZfVUJfVVRoiqsr8qvr8pDVDn1VVn1VZmJKoNmPXj34VRElVy" + "znlhflYCo4uqrYuqrgt9d80k24vmciDJo4NMSVqpPI0S4GBr/Dlf+AJHxCaIjFuIiIZIgOVIjLTLic2RDLgRvKlcAX6AYSqIMKqAyqqIm6qA+GqMZWqItOqATuqEn+uBrDLL/wT/0D8cojMUETEbw9cQZmIV5WIglWI5V+AHrsJExbMF27MIe7MdBKXQIR9X3GE4QzCmC+VWtz/nzkr9f8/oN/On4e3iAx3jquRd47Zg3jg3/yq1OcasT3OoYtz" + "qiYT/ErQ6KwP0icA+32iUCt4vALS5so5PXOTGw1FUsbzmrXCJLF4rAuSJwlgicIQKn6qsmbyIsEThWBI4SgcP1VUMWi0MR+LUI7KOv6iECu4rATvqqDvqqNiKwJVE101c1FoH1RWAdfVVNfVVVERi8IUYFfVUZfVVJzXoxfVVhfVUBzXrwdorB+3Vm06x/rq/KQFRpNeup9VXJiSqJZj2BviouUcXKRSzZiYaoImckrLSElZqwUo6PEPFKaPy7r" + "vcDRManiI7g9/zEQ0IkRQqkRjpkxOfIjlzIh4L4AsH7gZVC8E47FfElqiF424G6CH6gtzGCH5VrhbboiM7ohl7oi/4YjKEYgeAf/sdhIr7DNMzEHMzHIkawFEFPvBo/YgMCg9iGndiNfVLoJxzCURxT5xM4TYRncI5wLqr7ZR9f9/xNx9zBX859hCc+fo6XXvvHMWHHhs9xqzMa9lMa9hPc6hi3OsKtDnGrn7jVPhG4m1vtMMBWEwQWup7drWV1" + "q0XgChG4VAQGXyOZLwJni8CZInAaUX0nAieKwG+JKvgWjhEicKgIHERU/fVVfUVgT6Lqpq/qrK/qSFRt9VWt9FXNiaoxUQU/Ql5XXxW8AUY1fdWXRFWBqMrqq0oRVTGi+kJfVZCo8mrWc+mrshPV55r1jPqq4A34U2vWU+irkhBVQs16PKKKRVTRsxANUUVOR0SfEVYKfVZSwrpOWD6ZPsDH+BQxEBvxkAhJEfxGjc+QDhmRBdmRG/lQEEVQHKV" + "QDhURvPNOddRCPTREEzRHawQ/OvcVuqA7eqEfBmAwgu99G4kxGIdJmILgn9hmYS4WYDGWYRV+QNAjb8QWbMcudd2LA/gZR3AMJ7Q8p3EW5wn0otpfIpyr/vzD3//0/D3HPcBjPMULz732Wsgx4Usa9osi8LwIPMOtTnGrExr2Y9zqCLf6WcN+wAL2OmEXJW5nj1vY4kYRGNxV/CACV7oLXCYCF4vABSJwDlF9LwKDf/ScQlST9FXjROAYEThSBA" + "7VVwXfNjtABPbTV/XSV3UXgV30VR31Ve30Va2/scn6qiZE1ZCo6uqrahFVdc36l/qqikRVVrNeSl9VnKiKaNYL6qvyEVUuzXp2fVUWosqoWU9HVKmJKoVmPam+KqFmPZ5mPTZRRc9ENOmJh6g+SOnOMClhJSKsbceOvcupP8THiIoYiI34SIRkSInPEPyGjUzIghzIjXwohCII3iKzNMqhEqqgOmqjHhqiKVqgNdrjK3RBD/RGPwzENxiGUQi+F" + "248gu8ymYoZ6jUr+FcRLMQSrMBqrMV6bMI27MAe7MdBHMYvWp7jOIUzOM9ULuIyDVzBNQK64c87nvvL64+c8wTPffzKc2+8Fr4mAq9wq8vc6iK3Oq9hPyMCT2nYj2vYj1roIQcfpMT91LqbvQWN3lYRuEkErheBa/VVq0TgchG4RAQu1FfNE4Gz3AXO0FdN1VdNWuniRWDwXYwj9VXD9FXfENVAfVU/fVVvouqhr+pCVF8RVTt9VWuiaqFZb6qv" + "aqivqqdZr6Wvqk5UVTTrFfVV5YiqtGa9uL6qCFEV0qznI6rcRJVds56FqIJfE5JOs/4ZUaUkqqSa9UREFU+zHpuoYhDVp2mIh6g+TEZYicPHIsY6FiGi638PHyIKoiIG4iA+EiMZUiIN0iMTsiIHciM/CqEoSqA0yqMSqqAGaqMeGqEpWiJ4e4L26ISu6IE++BoDMQTDMQrfYgImYxpmYjbmYxGWYgXW4EdswGZsxy7sZR4HAgNBYCTHcBK/4hw" + "uSqzLuIrr9HCDiG7hro8feP1vPMNL/OO5kNfCf3Cr69zqKre6LAIvisBzIvBXEXjSQMeoMLDGn1nbARG4VwTuEoHbROBmotqgr/pRBK4RgStE4FJ91aKthCUCZ+urgu/7mSoCJxPVBH3VWH3VKKIarq8aQlQDieprfVVvouqhWe+qr+pEVO0168EbW7QgqqZE1UizXo+oamvWaxBVFaKqpFkvp1kvTVQlNOtFiKqQZj14Y/3cRJVDs56VqDIRVX" + "rN+mdElZKokmnWExFVfHeAsYkqBlFFTUVYRPVhYmJKEA5HjBOOEMkn13v4EFEQFcGvF46D+EiMZEiFNEiP4PcDZUUO5EF+FEbwNuQlELzBb3lUQlXUQB0E7yPWCME79LREG3RAJ3RDT/TB1xiEIRiB0fgWwXfyfodp+B5zMB+LsQzBP8X9gHXYiC3YgeCOfx9+wmH8ghM4jbO4ILUu4Qqu4wZu0cZtgvzLn4/8/Qme4xXeeC58m1vd0rDf0LBfF" + "4FXROAlERgMdpb6TlPeCbZ2lKgOach+EoH7ROBuEbhDBG7RV20UgetE4BqiWqmvWiYCFxHVfH3VHBE4k6im6au+01dNIKpv9VWj9VXDNetD9FWDiOprzXoffVXwo+BdNeud9FUdiKqNZr2lZr0pUTXSrAfvVFfbHWANzXpVoqpEVOU166WJqoRmvahmvRBR5des5yGqHO4As2rWMxFVeneAaYgqJVElcweYmKjiuwOMQ1QxiCpqcuJJQkRE9V7c" + "cDhSTMLySfYePkIURENMxEECJEbwizxTIQ3SIzOyIifyID8KoyhKogzKozKqIngrzTqoj8ZohpYI3rGnAzqhG3qiL/pjEIIfuRuBMRiHiZiC4Dt7v8ccLMBiLMcqKfQD1mMTtmIH9mA/DuIIjuEkfsU5/IYruIYbuEUft3GP+dzHYx8/8/xL/OPjsOfCd0XgbW51i1v9IQKvWcAVL1ykxnMs7VcReFIEBncHh0XgQRG4XwTuIaod+qqtInATUQX" + "/ePmDvmoVUS3TVy0mqgVENUdf9b2+ajpRfadZn0hU44hqtGZ9BFEN0awP0qz3J6q+mvWemvVuRNVJs95BXxW8t1NLzXozomqkWa+vWa9DVDU061WJqhJRldeslyGqkkRVVLNemKjyuwPMQ1Q5iSqrO8DMRJXeHWAaokpFVMncASYmqvjuAOMEvyGeqKISVRSi+oio3otFWNEIi4O/h48QBdEQ/Mb9uEiAxEiOVEiLDMiMrMiJPCiAwiiKkiiDCq" + "iMaqiJOmiAxmiGVmiLDuiMbgjeG6Mv+mMwhmIkxmAcgh9umYLpmIW5WIAlWI7VWIv12Ixt2Ingi+AH8DOO4jhO4Qwu4BKu4nf6uInbuIf7eMiInuCFj18j5OPwQ251n1vd41a3udVNT/5OcVdZ2SUReD5o3IjqlL7quAg8IgJ/JqrgK7J7ROBOotqmr9qkr1pPVGv1Vav0Vcs160v0VQv0VXOJapZmfTpRTdGsT9SsBz/PNkazPkKzPpSoBmnW+" + "xNVX6LqqVnvRlSdiaqDZr0tUbXSrDcjqsZEVZ+o6hBVTXeAVYmqMlGVdwdYhqhKElXwu2QKE1UBd4B5iConUWV1B5iZqDK4A0xDVKmIKpk7wMRElYCo4hBVTKKKmpB4iOojonovOmF9Qlg+4d7HR4iCaIiJuEiA4JelJ0cqpEUGZEY25ETw284KoDCKoSTKoAIqoxpqoi4aoDGaoRXaoiM6oxt6oS8GYDCGYiTGYDwmYQpmYBbmYiGWYAVWYy02" + "YDO2YRf24iccwlGcwGmcxQVcxjX8gcCA7uI+HuJvPflTvPTxPwg/Jaq/udVDDft9L9yhtlus7A8ReE0EXhaBF/RVZ0Vg8DWM40QVfAX2kL7qAFHt1Vft0ldtI6rgWyw26KvWEtVqzfpyolpCVAs163OJKvgJkOlENYWoJmnWxxHVGKIaQVRDiWqwZn2AZr0vUfXSrHcjqs5E1ZGo2hJVK3eAzYiqsTvA+u4A6xBVTXeAVYmqMlGVdwdYhqhKVlQ" + "8d4CFiaqAO8Dg9/flJKpsRJWZqDJkJyyiSkVUyYgqMVElSEFYRBWTqKLGIx6i+oio3v+EsCITFjd/Hx/hE0RDTMRFAgS/iT85UiEtgl9LnBnBL/zMibwogMIohuD3CpVFBVRGNdREXTRA8MbAzdEKbdERndEdvdAXAzAYwzASYxD8APEkBD+aNwOzMA8LsQTBdwCvRvC9dRuwGdsRfKPBPgT/hHcIv+AETuMcgq8UXEbQg99AkG738ACP8RQv8B" + "ohhF9o2IMnH1PZAzZ3l6j+1KjdEIFB1x/cVl68anCiOh185VVfdZSoDh2zCH3VXqLapVnfRlSbiWqDZv1HolqtWQ++Z3oJUS3UrM8jqlnuAGcQ1RSimqRZH0dUY9wBjtSsDyWqwUQ1gKj6ElUvd4DdiapzD5tKVG2JqpU7wGZEFbyldAOiqkNUNesRFlFVJqoK7gDLElXwG6+KEVVhoipQRFGJKmc+RSaqzESVIQthEVWqdMRAVImJKkFSwiKqm" + "EQVLTbxENVHnxJTZML6gLB8Ar6Pj/AJoiEm4iIBkiA5UiMtMiAzsiEngl8AWgCFUQwlURYV8CWC3+BRE3XRAE3QHMEbBbdF8BacndEdvdAXAxC8088wjMRYjMckTMUMBD+qNw8LsQQrsBo/YgOC77Xbjl3Yh59wGME/6Z3AaZzDRVzBddxE0JPfQ5B2f+M5XuENPYXf+OClCHwmAv8mqof6qqARC7r8G0R1XV91JfhimL7qHFGdJqoTmvVfiOoQ" + "Uf1EVHuJapdmfTtRBd9luEGz/iNRrSaqFUS1hKgWEtU8oprlDnAGUU0hqklENZ6oxhDVSKIaSlSD3QEOIKq+RNWLqLoTVeeuNpWognf5Dd5CujlRNW5q84mqDlHVrE1YRFWZqCoQVVmiKlla8YiqMFEVIKrgV9jmzK3IRJWZqDIQVRqiSvUZMRBVYqJKQFRxiComUUUjqk+I6qOPiekDwnqXsMJvwu/jI3yCaIiJuEiAJEiO1EiLDMiMbMiJvCi" + "AwiiGkiiLCvgS1VATddEATdAcrdAWHdEZ3dELfTEAgzEMIzEW4zEJUzEDszAPC7EEK7AaP2IDtmA7dmEffsJh/IITOI1zuIgruI6buI17eIi/8RyvEPwXDonA1yLwRZCPIvARt7ovAu+IwFv6qj9EYPCV1Uv6qgsi8Iy+6pS+6rgIPKKv+llftV+zvkdftUNftVUEbtJXrROBwU92rNJXLdOsL9ZXzReBczTr3+urpmnWv9OsTxCB32rWR+urhr" + "sDHKJZD95Z7mt3gH006z1EYFfNeid9VXt3gG30VcEb3zfVrDfUV9VzB1hbs169ajhcxR1gJX1VOX1Vac16cX1VEXeABTXr+URgbs16Dn1VFneAmTTr6dwBfuYOMKW+KmnicDiRZj1enHA4dsxwOHq0cPhTEfjxR+HwB++Hw+9GCoT1irBeEdYrwnpFWK8I6xVhvSKsV4T1irBehVMhLTIgM7IhJ/KiAAqjGEqiLCqgMqqhJuqiARqjOVqhLTqiM" + "7qjF/piAAZjGEZiDMZjEqZiBmZhHhZiCVZgNX7EBmzGduzCPvyEQ/gFJ3Aa53ARl3EdN3Ab9/AAj/EUL8Ivw68RQvgNt3qlYX8edPUa9kca9r807HcI6xZh/R582Z6wgn9sPE9YwbdKnHQXeIywjhDWQcLaT1i73QXucBcY/CTHRsJaR1g/ENZKwlpGWMGPas8nrDmENZOwphHW5HHERVjfEtYowhpOWEMIayBhfU1YvQmrB2F1Iazgje7bE1ab" + "ZsRFWE0JqyFhBb/JqhZhBb+HrwphVSSscoRVirCKE1bwi7YLElY+wspFWNkJKwthZSSsdIT1GWGlIKykhJWQsOIRVuyoxBWFuAgrMmF98C/Cek5YzwnreTgKoiEm4iIBEiM5UiEtMiAzsiEn8qAACqMYSqIMKqAyqqEm6qABGqMZWqEtOqIzuqEX+mIABmMoRmIMxmMSpmAGZmEuFmIJVmA11mIDNmMbdmEvfsIhHMUJnMZZXMBlXAs/C/+BW7i" + "L+3iIv/HUfy/9+Q9YlS6eWwVfe3gmBv8Wgw/F4D0xeNudYPCPi79fEIlnw+HfCOv88XD4V8I6+TNxHZDHhHWQsIKf3NhNWDvWi8S1xEVY65aH/+VHs1cS1tK54fAiwpo/PRyeTVgzCWsaYQXvHDdhhP6AsEYR1vD+4fA3hBW8NXS/bsRFWD0IqwthfUVY7QmrNWG1qK8PIayGhFWPsGoRVvXy+pUyxEVY5QirFGEVJ6wv8hAXYeUjrFyElZ2wsh" + "BWRsJKl0xfRFgpCCspYSUkrHiEFYuwohPWp4QV+V+E9Xf4PXyEKIiGmIiDBEiM5EiFtMiAzMiKnMiDAiiMoiiJMqiAyqiKmqiDBmiMZmiFtuiAzuiGXuiL/hiMoRiJMRiHSZiC6ZiFuViAJViO1ViL9diMbdiJPTiAn3EEx3EKZ3ABl3AVv+MmbuMu7vOsh3iC5/7+Gm98HA4R1WuiesGtnorBx+4EH2ja7wb/uKi/uqG/uq6/Cr6h6yJhndNf/" + "UpYJwjrF/3V4Z36LcLap7/aRVjbCSv4UewNhPXjYuJaoN8irKWEFbzX0jzCCt4pbgZhTSWsyYQ1nrDGDiIuwhpGWN/01G8RVj/C6t1Bv0VYXQgr+E1V7QirNWE1J6wmNYiLsOoSVi3CqkZYXxJWxaL6LcIqRVjFCesLwiqYlbgIKxdhZSeszwkrI2GlJazUhJWCsJIQVkLCikdYsQgr+nv6rX8R1iPCekRYjwjrEWE9IqxHhPWIsB4R1iPCekRY" + "j8JpkB6ZkRU5kQf5URhFURJlUB6VURU1UQf10RjN0BJt0QGd0A090Rf9MQhDMQJjMA4TMQXT8T3mYAEWYzlWkcEPWI9N2Iod2IP9OIgjOIaT+BXn8Buu4Br+EIK3cBv3SCv477GPA/96iX98rLHiWkT1iqiec6u/udUjbnWfW90Rg8E3cP3xazh8zd3gJY37hcPh8FmN+2mN+3HCOqpxP6Rx/4mw9mrcd2nctxNW8AYSGwhrLWGt1riv+F4zT1g" + "LvyMuwppFWDNGa+YJa5LGfTxhjSGs4A3shxHWYMIa0Im4CKsXYXVvqZknrI6NiIuwWhFWc8JqQlgNKhEXYdUkrODX/39JWBUIq2x+4iKsYoT1BWEVIKy86YmLsLIR1ueElYGw0sYnLsJKHoO4CCshYcUlrFiEFe1fhPUXYf0V/hBREBUxEQfxkRjJkAppkB6ZkRU5kAf5URhFUQJlUB6VUBU1UAf10QjN0BJt0AGd0BU90QdfYxCGYARG41tMxH" + "eYhu8xB/OxGMuwEmuwDhuxBTuwG/vwEw7jF5zAaZwlnwu4hCu4zqtu4Fb4DnHd8cwdcrrLte5xraD7usu1xF+IqF4T1QuiCr7l4bGm/QG3uicGb4vBm2Lwd251VQxe0l+d11+d2aeZ301chHVE4x78yPUBwgreMGKnO8JthLXJHeF6d4RrCSt4R7jl7giXENYCd4Rz3RHOIqzp7ginEFbwhvXj3BGO6RMOjyCsoe4IBxNW8Bup+rYhLsLq5o6wM" + "2F1JKy27ghbEVYzwmpMWA0Iq447wpqEVY2wKhciLsIqS1glcxAXYRXORFyElZewcqYkLsLKTFgZCCstYaUirOSElYSwEnxIXIQVi7Ai2qT38CGiICpiIA7iIxGSISXSID0yIStyIDfyoxCKogRKozwqoQpqoDbqoRGaoiXaoD06oSt6oA++xkAMwXCMwreYgMmYhpmYjXlYhKVYgTX4ERuwGduxC3vJ5AB+xhEcw0n8inO4GP5Tr/WnSLxFXLc4" + "103/v/kvEnvg+ceOeYaXPv7HcyGvhd8Q1Suiei4CnxDVI251n1vd5VZ/cqsb3Oq6GLwiBi+KweCHFH8Vg8GPWB/TXx3RuB/UuO/XX+3RuO9YqpknrOAd4NbN1swT1qqpmvnJmnnCCt7iee4od4qENZ2wpgwMhycS1rje7hR7EBdhDf0qHB7UPhzuT1h9WoTDPQmrG2F1qhf+l1+Q3bZ6ONyyCnERVuNy4XB9wqpDWDWLhMNVCasyYZXPHQ6XIay" + "ShFWUsAoTVoHPwuE8hJWTsLImIi7CyhA7HE5DWKkIK/nH4XBiwkpAWHEiElbo5rF3bdSH+BhREQOxER+JkAwp8RnSIROyIAdyIx8KoQhKoDTKoRKqoDpqox4aoilaoDXa4yt0QQ/0Rj8MxDcYhlEYi/GYjKmYobCzMA8LsQTLsRprsR6bsBU7sAf7cRCH8QtfOo5TOIPzpHQRl3VaV3CNvG7487bn/vLRIzzBc7zy3BuvhUPi7x9OFXzX3zOi+l" + "tv9VBv9Zfe6g63usWt/uBW18TgZTF4gVud5VanxeAJMfiL/uqQ/uonMbhPf7Vb475d476FsDbqr9a5I1xDWCs17svG67cIa747wjnDNPPfaOYJ67t+mnnC+pawRnfRzBPWkHbE1dqdImH1IayeDcPhroTVqRZxEVYbwmpZ0Z0iYTUirPrFw+HahFWDsKrkC4crEVb57MSVJRwuQVhF04XDhQgrP2HlSRoO5yCsrPGIi7DSE1aaT8PhlISVjLASv" + "xsOxY94jLCuj3/XJn2Aj/EpYiA24iERkiIFPkM6ZEQWZEdu5ENBFEFxlEI5VMSXqI5aqIuGaILmaI12+Apd0B290A8DMBjDMBJjMA6TMAXTMQtzsQCLsQwr8QPWYSO2YDt2EcpeHMDPOIJjOEFCp3CGV53HRbK6RF5X/fmH///ptbuOe4DHeIoXnnvttZDjwm+I6jVRvSCqp0T1mKgenBCJ3Oq23uomt/qdW13lVpfcDQZvBHFGDJ4Sg8fF4FEx" + "eEgMHhCDe/VXu/RX28TgZv3VBv3VWo37Gv1V8Eb0SzXuiwhrnsZ9tjvCmQM08/qrye4IJ3TXzBPWKHeEwwnrG437wObE1UQzT1jBr/HvSlhfEVb7L4mLsFqUJa5SmnnCqvcFcRV0p0hYVXIRF2GVI6zSGYmLsIqkJq4UxEVYuRMSF2FlIaxM0YmLsD4jrJQfEBdhJYo4nrCuENZVwroajoxPER2xEQ8JkRQpkBrpkBGfIztyIS8K4gsUQymURUV" + "8iWqoibpogMZojlZoi47ojG7ohb7oj8EYihEYjXGYiO8wDTMxB/OxiBCWYgVWYy02YBO2Yid2Yx8x/IRDOIJjZHQCp7TwZ8jqHC7477I/r3v+po/u4C/nPsITHwdfoHjptX8cw4a4lvh7SVTPiOoJUT0iqvsi8C63Cn50+obe6jq3usKtfuNW57jVr9zqJLcK3tntiBj8WQzuF4N79Fc7xeA2MbhJf7Vef7VWDK7SXy3XXy3RuC8Ug/P0V7M07j" + "MIa6r+apLGfbw7wrH6q5Ea9+AXX39DWAPcEfZrQFyE1b2mO8VqxOWOsF0Fd4qE1YKwmhQjLsKqR1i18hIXYX1JWBU/Jy7CKpXWnSJhFSGsgkncKRJWbsLKHou4CCsTYaWLTFyElfKdcCgpYUUIXRz/jk36AJHxCaIjFuIiIZIgOVIjLTLgc2RDLuRFARRGMZREGVRAZVRFTdRBfTRGM7REW3RAJ3RFT/TB1xik2EMwHKMwFhMwGVMxA7MwDwuxB" + "MuxCj9gncJvxBZsxy7swX5iOIhDOMKnjpHTCZzSyv9KXuf8ecn/r3nthmP+dM49PMBjPPXcC6+9dswbx4ZDeqrXRPWCqJ4S1WOiekhU90TgbRF4y53g79zqmt4qeC+kC9zqLLc67W7whBj8RQwe5lY/cat9c0WiGNwhBreKwU36q3Vi8AcxuEp/tUx/tZiwFojBufqr7zXu08XgFP3VRI37OMIao78aqXEf6o5wMGEN0Lj3dUfYi7C6a9w7E1ZH" + "wmrnjrBVSXeKhNXEHWGDAu4UCauWO8Jq2YjLHWHFDJp5wipFWMWSu1MkrIIJNPNx3SkSVnbC+vyTcDgjYaV7350iYaWMEAjrAo2dD7+Pj/AJoiEW4iIBkiA5UiENMiAzsiEn8qAACqMoSqAMyqMSqqIGaqM+GqEpWqIN2uMrdEEP9EY/DMA3GIaRGIPxmIQpmI7vMQfzFXkRlmIFVmMt1mOT4m/FDuzCXuI5gIM4REpH3B8ew3HSOqWlP+vji56" + "/4vXf/e2WMe7gLwRfoPjbc8+89tIx/zg25JzwGz3VK6J6TlRPiOoRUd0nqrsiMHh7mhsi8Dq3usKtfuNW57lV8P6Tp7jVcW51lFsd4lYHxOBeMbhLDG4Xg5vF4EYx+KMYXCMGV+qvlumvFonB+fqrOfqrmYQ1TQx+p7+aqHEPfj3/aP3VCP3VEI37IP1Vf417H3eEPQmrm8a9szvCDoTVVuPeyh1hM8JqrHFv4I6wDmHV1LhXI6zKhFXBHWGZVJ" + "p5wirmjvALwipAWHljauajuVMkrM8/0swTVlrCyhzhY8I6lTKSTXoPHyEKoiEm4iABEiMZUiEN0iMTsiIHciM/CqEISqA0yqESqqA6aqMeGqIJWqA12qEjuqA7eqEv+mMwhmKEIo7Gt5iA7zANMzEb87AQS7BcsVfhB/yIDdhMMluxA7sJYS/286mDOERSR0jrF/+d8OcZ/7/g9cuOvebcG/gTd/EAj/DUa88d88q5b5wTDmnUX+upXhLVM6L6m" + "6geEtVfIvCOCLxFVME7tl1zJxi83+RFvdU5bvUrtzrJrY5p2oM3lP9ZDB4Qg3u41U5utU0MbhaD68Vg8PvuVnOrFWJwiRhcKAbn6a+CX2g9UwwGv45/sv5qgsZ9rBgcpb8arr8aIgYH6q++1l/10bj30F911bh30rh3IKw2GveWGvdmhNVI417fHWEdwqqhca/qjrASYZXXuJdxR1iSsIq6IywcR79FWHncEeaMQlyEldkdYYZI/5uwLsSOFDp5" + "9z0b9SGiICpiIA7iIxGSISU+QzpkQhZkR27kQ0EUQXGUQjlUxJeohpqoiwZojGYK0wpt0QGd0Q090QdfYxC+wXCMwliMxyRMwXQi+B5zMB+LsBQrsFrRf8A6bFT8zdiGnQS0G3vDR4nriJ7riIb+sP8f/heJnfb8Ocf95m9X8buxbuEOgq+APfRc8PX7Z4556djXzgmRZ/iNRv2Vnuo5UT0lqkdE9YCo7onA20R1k6h+F4FXReAlorpAVGe51Wl" + "udYJb/cKtDnGrg9xqP7cKfkPUDjG4VQxuEoPruNUP3GqVGFwuBoNfYL1AfzVXDM4SgzPE4BT91ST91XgxOEYMjtRfDSOsb8TgQP1VP417b8Lqob/qor/6SuPeXn/VWn/VQuPeVH/VUH9VT+Nem7BqaNyruCOsRFjlNe6l3RGWIKwiGvdC7gjzE1ZujXsOd4RZ3wuHMkW8HkoV4T+8g3LE0PHD79qoD23Ux/gUMRAb8ZAISZECqZEOGfE5siMX8q" + "IAvkAxlERZVEBlVEVN1EF9NEIztEQbtMdX6IIe6I1+GIDBGEoIIzEG4zAR32EaZmIW5iryAizGMqzAGkVfi3XYSDhbsI0IdmAXOe3hWftI6wAO+fiY50766Kzjgg7ssjGu44bx/8RdH9/HI689cUzwL5CvnPPGuaxGI69RD97T6Jn4+5uoHhLVfaK6S1R/EtUNERi85fIVEfibO8Hz3OqM3uqU3ir4nSpH9VY/c6sD3Govt9rFrbZzqy3caoO7w" + "XXuBteIwZVicJkYXCwG54vBOWLwezE4XQx+p7+aKAbHicEx+qsR+quhYnCwGBygv+qrv+pFWN31V130Vx0Jq53+qrX+qjlhNdFfNdS419W419JfVddffalxr0hY5TTupTTuxQmriP6qkMY9H2Hl1rhnd0eYJeLbNwXxiBg6svJdG/UBIuNTREcsxENCJEFypEZaZMDnyIacyIMCKIyiKIEyKI9KqIoaqI16aIgmaIHWCtQOHdEZ3dALfdEfgzAE" + "wzEKYzFeQSdhCqbje8zBPEVeiCVYjpUKvgZrCWcdNmIzAWzlVTuwi6x28659+Nnfj3rthGN+dc55z/xmzKv4HTdxG395/iEeO+apY18457VzQ8YIh7jUa6J6oad6Kv6C95F8QFTBu+DeIapbIvCPlSKRqC4vEYki8JwI/JVbnRSBx7jVEW4V/B67/dxqD7faya22ado3i8ENYnAtt1rNrVZwq6XuBheJwflicLYYnCkGp4nB78TgBDH4rf5qtP5" + "qhBgcIgYH6a/666/6iMGeYrCb/qqz/qqjGGyrv2qlv2pOWI31Vw30V3UJq6b+qpr+6kuNewXCKqu/KqVxL0ZYX+ivCmrc8xJWLv1V9giT38rKI/RTiXds1PuIjE8QDTERFwmQGMmQCmmQHpmRFTmQG/lRCEVQHKVtfDlUxJeohlqoiwZojGZohbbogE7oih7ojX4KNwCDMRQjMBrfYgImK+pUzMD3mIv5irwQS7GcZFZijaKvxToetRGbyWkrWW" + "0XjMF/e338k+eO+OiY408596yxLiL4AsU13MCfuOu5+3jkmCeODb5/4qVz/zGG7OJaXOoVUT0jqidE9Yio7hPVXU51m6huiMDrIvAqUf0mAs8T1VkReIpbBb+37hdudYhb/cSt9nGr3dxqB7fayq02cat13OoHbrWKWy0Xg0vE4EIxOFcMzuJWM8TgVDE4SQxOEINj9VejxOBwMThEDA7UX30tBvuIwR76q676q05isL3+qo3+qqX+qhlhNdJf1" + "ddf1SGsmvqrqvqryhr3CvqrMvqrkhr3YoRVWH9VQOOel7ByRvg/vKNfaF+RSKH9ofds1EeIgqiIgTiIj0RIhpT4DOmRCVmQHbmRDwXxBYqhFMqiAiqjKmqiDuqjEZqiBdooUDt8hS7ojl7oi/4YhCEYroijMBbjMRHfYRqxzMRszMUChV6EpYq9HCuJZw3WKvw6ctqATUJxC3ltxx7/P/A2IIMO7KRnfsV5Y/+Gq/gdN3Eb97z2AI8d+9S4L5wb" + "fAfYG2OFQ1u4lru/F0T1lKj+JqqHnOovorpDVLeI6g991TUReFkEXhSB54jq12lc6zuu5U7wiDvBn90JHuBWe7nVLm61nVtt0bRv1LT/qGlfo2lfKQaXcavF3GoBt5rjbvB7MThdDE4Rg5O41Tj91RgxOFIMDhODg8XgADHYTwz2FoPd9VddCOsrMdhef9Vaf9VCf9VUf9VQf1VPf1VbDNbQX1XRX1UirPL6qzL6qxIa96L6q8L6q/yR3oRyR0j" + "3VlX/4RExvOfhezbqQ3yMTxEDsREPiZAUKZAa6ZARnyMbciIvCqAwiqIEyqC8za+EKqiOWqiHhmiC5miFtuiATuiKHorcG/0wAIMxFCMwWjG/xXhMwhSFnY6ZmKXA87AAi4hnKZYr+EoyWo0f+NWPZLWedwX/bfPxLs/vc8xBfztijOM4bdzgCxTBV8Au4xr+wJ+447Xgn7iD758IvkHnmXNfGuMfY4WMGX6znmu5+3uuUX/CqR4R1QOiukdUt4" + "nqJlH9TlRXieqSCLwgAs8S1WkReEIE/iICD3Org9xqP7faw612cqtt3Gozt9rArdZyq9XcagW3WsqtFmna54nBOWJwJreaxq2+41YTxeC3YnC0GBzBrYaKwcFisL8Y7CsGe+mvuonBzmKwoxhsp79qLQabi8Em+quG+qu6YrCWGKyuv6qiv6ooBsvpr0rrr4oTVhH9VcGI/5c3tw0eoZ293rVZHyAyPkV0xEJcJEASJEcqpEEGm5oZWZEDeZAfh" + "VAExVEaZVERX6IaaqIO6qMRmhFAS7RGe3yFLuiOXuiDrxVvIL7BMIzEaIxT0AmYjCkKOx0zMZt45mGBQi/CUsVezqdWYDVJreFba8lrgz+3+PtOr+91XNCBBS3+L8Y7afwzOI/frOEqfvfxTdzGPcc8cOxj5zxx7nNjvDLWG2OGQ1zqNZd66e7vmUb9bz3VQ6L6i6juENWf+qobs0UiUV0hqt/0VedF4BkReEoEHieq4NflH3In+JM7wX3uBHfr" + "rXborbbqrTZyq/V6qx+41SputZxbLRGDC7nVPG41i1vN0LRP5VaTxeB4MfitGBzFrYaLwSFicJAY/FoM9uFWPcVgVzHYSQx2EINtCaulGGwmBhvrrxoQVl0xWFN/VU1/9SVhVRSDZfVXpfRXxcVg0QhfvVXT/+ER2tbsHZv1Pj5CFERDTMRBfCRGMqTEZzY1PTIhC7IjF/KhIL5AMZREGZRHZVRFDdRGPUVpiCZojlZoiw7ohK4K1gO90Q8DMEg" + "Bh2A4RmGMYo7DREwmk6mYjpkKPBvzFHkBAS3EElJaxq9WkNUq8lrzLxIL/GstyazjkeuF8gbd4UZN/CZN/CautZlrbeZaW7jWFq61mWttDt/y2h0E36Dz0DnBtxc+M8ZLY702ZsjY4TdE9YpLvSCqpxr1x3qqB0QV/P6520R1k6j+IKqrRHWZqIJfMH1OBP4qAk+KwGMi8IgI/FkEHhCBe0XgLm61jVtt5lYbuNWP3GoNt1rJrZZxq8XcaoGmfY" + "6m/XsxON3d4BQxOIlbjdO0jykjEsXgMDH4jRgcIAb7uRvsLQZ7iMGuYvArMdheDLYRgy3FYFP9VSP9VX0xWEcM1tBfVdVfVRaD5fVXZfRXJQmrWIQGb9X0f35EslHv4UNEQVTEQGzERyIkRQqkRlpkxOfIhpzIgwIojKIogdI2vxwq4ktUQ03UQX00RjO0UKDWaIeO6Ixu6KlofdAPAzFYAYdiBEYRzFiMx0RFnYypCjsdM0lnFuYq8nxSWojFA" + "nEpaS3332p//ui5TT7a5vhdzt3nmeD+8TCOmeuk+c/gPH5D8C+Qv3v+Bv50zF3cd84j5z4xV/AN0q+MGfx4RzhEVP9wqZeLuRZR/a1Rf0RU98XfXaL6k6huEFXwC6WvENUlojovAs8Q1WkReEIE/iICD3OrgyJwP7faza12uBPcyq02cav13Gott1qtt1rBrZZyq4Xcaj63ms2tZnKradzqO241UQyOE4OjxeAIMTiUWw12NzhADPYVg73EYHcx" + "2JlbfSUG24nB1mKwhf6qqRhsKAbricHa+qsaYrCKGKwkBsvrr8pEevFWRv/3R8TQuu/ftWEf4GN8iuiIhbhIiCRIjlRIg/TIbHOzIgdyIx8KogiKoxTKogIqoypqKEZt1ENDNEFztEJbReqATuiC7uil8H3xNQbiG0UcihEYrZhjMV5BJ2Iy8UzBdMWdiVlENIdXzSOpBXxrEXkt9ecq/1/7NiC3OH6HZ/YY7wAOmeOoV48j+Pr9WVzEZVzz3B+" + "45ZjgO8D+MvcD5z42xlNjvTDma2OHzBMOib7XXOqF6Hvq7i/4LZkPiOovorpDVLeI6g+iukZUl4nqogg8R1S/EtVJEXicqI6KwJ+51QEN+z4RuEvDvv0rjXx7kdjGXSK3+oFbreJWy7nVEm61kFvN5VazuNUMTftUTftkMTiBW33LrUZxq+HcaogYHCQG+4vBPmKwJ7fq5m6wsxjsIAbbisFWYrC5GGwsBhuIwbpisBZhVReDX4rBivqrchFnvp" + "XR/8MjtLbOOzbsfXyET2xcNMREHMRHYiRDSnyGdMiELMiOXMiLAiiMoja+BEqjHCriS1RDTdRBfYVphKZogdZoh46K1Qld0QO9Fa4v+mOQAn6DYRipkKMxlnjGY6KiTsZU4pmuuDMwi5zm8Ky5pLWAfy3x8QrPrfHResdudt52Y+z2bPAFioPmO4xj1nESZ3AevyH4/onrXruBPx171zn3nfvIGE+M9cx8L439jzlYB9fiUi+J6vn3Gnl3f4+I6" + "j5R3SWq20R1k6h+J6qrRHVJX3VBX3WWqE6LwBMi8BeiOiwCD4rA/SJwjwjcKQK3cavN3GoDt/qRW63hViu51TJutZhbzedWc7jV99xqOreawq0mcavx3GqMpn2kpn2YGPyGWw3kVv24Ve+MIlEMdhWDncRgBzHYRgy2FIPNxGBjMVhfDNYRgzXFYDUxWPkdrhXhP/5r5SKEl8WLFFr17D0b9iE+RlTEQGzEQ0IkRQqkRlpksLmZkRU5kAf5UQhF" + "UBylUBYVFKEyqqIGaqMeGqKx4jRDS7RBe3ylWJ3RDT3QW+H6oT8GEcUQDFPIkRitmGMxXkEnYjIJTVHYabxqBkl9T1qzMQ+L/H+511Y77kd/2+j8rcbaadw95jmAQ444iuAfiE7jLC7gkueuIvgOsJu47Zx7zn1gjMfGemreF8YOfkDtjbnCIS71mku9IKqn00Siu7+HRPUXUd0hqltE9QdRXSeqK0T1m77qPFGdIapTIvA4UR0lqkMi8CcRuE8" + "E7uZWO7jVVg37pmYisbFIdCe42p3gCm61lFstdCc4j1vN5lYzudU0bvUdt5rIrcZxq9FicAS3GsqtBnOrAZr2vmKwlxjsLga7cKuO3Kq9GGwtBluIwaZisFFUkSgGa4vBGmKwSqS/w9UjvP9WRf/Pj4ihZXvetWkfIDI+tXHREQtxkQCJkQwpkQbpkQlZkB25kNdmF0BhFEUJlEY5VMSXClENNVEH9dEITRSnOVqhLdor1Ffogm7oSQh90E/x+m" + "MwhijiMIxUyNEENBbjFHQCGU3Cd/xqKllNF4zBf4HEFnp+qWNW+tsPzl1vnM2eDb5AEXwFbL+5D1rPYRzDSQT/xH0ewTfoXPH6ddxw7J+449z7xnhorODnh54Z+6U5XpsrRNbhN1zq1VSuRVRPJnEtd38PiOoeUd0mqptE9TtRXSWqy0R1kajOEdWv+qqT+qpjRHVEBP4sAg8Q1V4N+y4RuF0EbhGBG0XgOhH4A7daxa2WcavF3GoBt5rLrWZxq" + "xncaiq3msytJnCrb7nVKE37cE37EE37IDHYn1v15VY9uVU3btWZW3UUg23FYCsx2JxbNXE32FAM1hODtcRg9Yj/iV/dGzxCi/X3i8XhYnG4WBO/mGstFoeLxeFicbhYE7+Yay3mWou51iKutYhrLeJai7jWIk38Iq61iGst4lqL3CEu5FoLudZCd4gL3SEuDFdCFVRXjFqoiwZojKaK0wKt0Q4dCKYTuqK7ovVEH4XrhwGKNxhDiGcYRijkKIwh" + "oHEKOp6cJvKsyaQ1BTMw23MLvL7EcUEHtsYz64y1yfjbsNOcex1xAIes8SiO4zTO4gIuee0qfnds8A3St3HPGA+M9diYT4z93ByvzBX8/HY4JPr+4VIvudSz8VzrW67l7u++Rv2unupPorpBVNeJ6soArkVU54nqDFGd1ledIKpfiOqwCDxIVPuJao8I3CkCt4nAzSJwA7daW0skVheJ3GqpO8FF7gTnuxOcU0okcqvp3GqKpn2S3mo8txrDrUZ" + "yq2Hc6htuNZBbfc2t+mjae2jauyYSiWKwA7dqw61acqtmYrCxGGwgBjVPoVr/x6+2/8ceofmJIoUWPHnPpn2Ij/GpzYuO2IiHhEiC5EiFNEiPTMiC7DY5F/KiAAqjKEqgNFGUQ0VURlXUQG1FqYcGaIJmCtQSbdBOoTqgM7oqWHf0RB+F64f+5DJIAb/BUCIaoZCjMJqUvuVX48lqAu+ajEBiszw/z0eLHL/MuauMsdZ4G7wSfAVsh/l3Y791Hc" + "RhRx/DSQTfoHPOcxdxxTHX8Idzbjn3jjH+MtZDYwY//fjMGl6Y67U5Q+YOv+FSr7jUCy71lEs9JqoHRHVPo35HT3WLqP7gVNeI6jJRXSSqc0T1q77qpL7qGFEd0Vcd0lcdIKq9InC3CNwuArdyq00icL0I/EHDvkoELheBS0TgQm41j1vN5lYzudU0bvUdt5rIrb7lVqO51QhuNVTTPljTPkDT3k8M9uJW3blVF271Fbdqp2lvo2lvIQabisFGY" + "rBexBvhhhGi/Qfx/Kce4bkD3rFhHyAyPkE0xEQcxEciJLWhKZAaaZERmZEVOZAb+Wx4QXyBYiiJMiivCJVQBdVQE3UUpT4aooniNEdLtFGkduiITgTRFd0VrSf6KFw/9CegQQr4DYYq4nA+NZKcRpPVWN4V/DfJx1M9N9NHcx230HlBi7/SeMEXKNaZa5NXt2Gn9ey1zgM4hKM4jlM4iwu45JjgG6R/xw3n3jbGXWPdN2bwE5BPzBH8/PYrc/5j" + "blXkWlzqJVE9E31PhotEorpPVHeJ6k+iukFUvxPVVaK6RFQXiOosUZ3WV50gql+I6rC+6qAI3E9Ue0TgTqLaJgI3i8ANIvBHbrVGBK7kVsu41WK91QJuNZdbzdJbzeBWU7nVZG41nluN5VajuNVwbjWEWw3iVv25VV9u1ZNbddO0d9a0dxSD7cRgK27VnFs14VYNInR6q5r/jEdodv5IoZmh92zchzbtY0RFDMRGPCREEiRHKqSxsemRCVmQHbm" + "QF/lR2KYXQXGUQllUUIRKqIrqqKUgdVEfjRSmKZqjJdG0QXuF6ojO6Kpg3dGTgPooXD/0V7yBBDRYAYdgGEmNEIqjyGssJvj/lLcBOdvf5jt/sbGWG3u1V34070ZssZbgH4h2Yz8OOuMwjuEkfvXcOVzEZcdec84fuGWMO8b6y5gPrOuxOZ6a64W1vDZ3yBrCIS71mku9EH1PRd/jwSJxoEaeqO4Q1S2i+oOorhHVZaK6SFTnieqMvuqUZv04UR" + "0lqkP6qp9E4D4RuFsE7iCqrSJwE1GtF4FrudVqbrVCBC4tLhKLiEQROEfD/j23mu5OcIo7wYncahy3GqO3GsmthnGrb7jVQE17P27VW9PeQwx25VaduFUHbtWWW7XkVk0jvQo1iZDjrWr+8x4RQ9O2v2vTPkBkfIJoiIk4NjE+EiEpUiA10iIDMiOrTc6B3MiHgvgCRW18CZRGOVRUhMqoihqopdh10QCNFKcpmqOVIrVFe4XqiM4E0hXdFa2no" + "vVGXyL6WvEGktIgfvUNhvKu4L8xJDbe85N9NN2xs5w3zzPBPWTwBYpV5vsB6x2xybq2YZf17sUBBN+gcxTHcQpncd4xv+GKc64794Zx/rTGu8a8b22PzPHEXM+s6aW5/7GGkLWE33Cpl1zqOZd6QlSPvuZafUWiu7/bRHWTqH4nqqtEdYmoLhDVWaI6ra86SVTHiOoIUf0sAg8Q1V591S4RuF0EbhGBG4lqnYb9BxG4SgQuF4FLROBCbjWPW83m" + "VjO41TRu9R23msCtvuVWo7nVCG41lFsN5lYDuFVfbtWLW3XnVl241Vea9vaa9taa9hYRN72Vy3/BI/xd9kg27D18iCiIihiIjXhIiCRIblNTIg3SISOyIJuNzok8yI9CKIJiNr8kyqA8KirEl6iGGgpSG/XQQGEaoanitEAromiL9grVEZ0Uqwu6EVAPReutaH3Rj1f1J6mBfGsweQ3z5yh/H+e1SW87sJnOn2OsBcZdYo4VXg2+xPqj9WzEFuv" + "cgd3O2I+DOIxfEHz/6q9eO4eLjr2Ma879wxg3jXXbmPeM/cAcj8311JwvzP3KGt5YSzjEpV4T1Asu9YxL/U1UD4nqrx5cy93fnxr1G0R1naiuENVvRHWeqM4Q1SmiOk5UvxDVYRF4UF+1n6j2iMCd7gK3icDNInADUf0oAteIwJUicBlRLeZWC/KIRG41i1tN/5xrZdTIc6vx7gTHuhMcxa2Gc6sh3GqQ3qo/t+rDrXpyq27cqjO36vieSIwUDr" + "WN8NlbtfwXPML9I0UMTdjxrk37AJHxic2LhpiIg/hIhKRIgdQ2Ni0yIBOyIjty2ey8KIBCKGrji6MUyqC8IlTCl6imGDVRG/UUpQEaEU5TtFCgVmijSO3QgWS+Uqwu6KZgPYioFyn14Vd9yepr94wDMeRf/GuwmYa4iqG8ZrhAGyEOgy9QjOJao7nWGK41VhM/lmt9G95s3cE/ce/CXhxwfYdw1MfHcQpncN6xvznnCq4b44ax/jTmHWPfN8dDa" + "wze3uSZuV9aw2trCVlT+A2XekVQz0Xfk14ikageENU9orrt7u+mRv13PdU1orpMVBeJ6pw7wF+J6iRRHSOqo0T1swg8QFT7iGq3CNxBVFv1VZtE4DoRuFYErhaBKzTsS0XgIg37PA37HBH4vQicxq2+41YTudU4bjWGW43kVsO41WBuNZBbfc2tenOrHtyqK7fqxK06RFz9Vin/FY/QmFzvhMa+ec+mfYgoiIroiI14NjIBEiMZUuIzpLO5GfE5" + "siEHctvsfCiIwihq40ugFMqigiJUQhVUV/iaqK0o9dBAYRqhqeI0R0sCaoN2CtVBob4in87oqmDdeVVPkurNt/r6b4A/v/HccB+Ncex45wQt/jTjfW/suV5ZaM6l1hB8DX+Ntf1ovRux1Rk7sBv7cRCHEXyD9AmcdsxZXHDOJedexe/GumnM28a+Z60PzPXInE/MHbxB0ytreWNN4RBB/cOlXoq+Z6Lvb9H3qLNIJKq7RPUnUd3QqF/XU10lqku" + "c6gJRnSWq00R1gqh+IarD+qqDRLWfqPaIwJ36qm1EtUUEbhCBP4rAH7jVSqJaJgIXi8AFInCuCJzFrWZwq6ncajK3mpBMJLoTHM2tRnCroe4EB3Or/tyqL7fqxa266606R3odah8h0VuV/Nc9IoZGHnzXhn2AyPgE0RATcRAfCW1mEiRHKqRBepubCZ8jG3Iij83Oj4L4QmGLoQRKo6wiVEBlhaiC6qipILVRT1EaoBHxNFWc5mipQG0IqC3aK1" + "RHIurEq7qQVDe+1YO8er+VWOBfwxwzyjnfOneScaYad4Y5gq+AzTf/Yix31CrrXIv1rmEztmGXa9yLA/gZRz13HKdwxrHn8ZtzrxjjmvH+QPAGAXfM/Je5Hprzbyt5ag0vrOW1NYWsLfyGS73mUi+41FPR91j0PRB999qKRKK6RVR/ENU1orpMVBeJ6hxRnSGqU0R1nKiOatYP6at+Iqp9RLVbBO4gqq1EtUkErieqtfqq1SJwhQhcKgIXicD53" + "GpOeq6lYZ+uYZ8iAieJwPEJRSK3GsWthnOrIdxqILf6mlv14VY9uVXX/xa3+t8e4eEFIoWGukMcxrWGuUMcFv7UBkZHLMRFAiRGUhuaEqmRFhmQ2QZnQXbkQh4FLYBC+MLGF0NJlFaAsqiIygpRBdUJoSZqK0o9NFCYRgrTFM2JqIUCtSaitmivUB3I6Sue1Zm0uvqvl4/7eW6gj4Y6dqTzxnpmgrG+M+50c8zy6jzzL7Sepda30prXYB02Omsr" + "dmA39uMgDuMXnHDMaZzFBedeMsZVY/1uzBvGvm2Ou+a6b85H1vvEGoK3l3tlTf9Ym1zhWlzqJZd6zqWeENUjorov+u624FpEdZOofieqq0R1iaguENVZojpNVCeJ6heiOkJUPxPVAaLaq6/apa/aTlRbROBGfdU6ovpBBK4SgctF4BJutVAEzhOBs0XgTBE4TQR+x60mcqtx3GoMtxrBrYZxq8HcagC36setekd6EeoRIetbdfy3PSKGB+96x6Z" + "9gMiIgmiIYRNjIx4SIgmS29SU+AzpkBGZbXJW5EAum50XBVAIRWx8cZS0+aVRTvErojKqKEZ1xaiJ2gpSDw0IqJHCNEEzxWlBRK0UqA2vakdSHfhWR/Lq4s8e/t/3bUB+42/DnT/aWOOMO8krU80309xzrGOBoxZb63Ksdh1rsR6bXec2BN+/uhcH8DOOeO0Ygh9QO+Occ7hojMvGumbMP4x9yxzB++fcM+cD635sDU+t5YU1vbbWN9YYDnGp1w" + "T1QvQ91U89JqqHRPVXM67VmGsR1Q2iuk5UV4jqN6I6T1RniOoUUR3XrB91B3iIqA4S1T6i2qOv2klU24hqswjcQFQ/isA1InAlUS0TgYtF4AIROFcEzhKBM7jVVG41OZ5I1LB/G4NrReVaUbgWtxr0vkh8JxzqG3HjW1n8KzxC/XNFsmnv4UMb9zE+RXTERBwbGR+JkBTJbWoqpEF6ZLLBnyMbctro3MiLAja8MIqguKKXRBkFKIeKilAZVRSiO" + "moSUG0FqYv6BNNQYRorTFM0J6SW5NSarNryruC/Tj7u7vnePvra8YOdN8wYo4wZfIFiormmeHWGdcyyrnnWuQhLHb0Sa1zXOmx0zVuxA7uxDz95Pvj5oV9wwrGncda5F4xzCVeNed3YN8zxp7numvO+uR9aw9/W8syaXlrvP9YY8ukQfkNQr0Tfc9H3hEs90qTfJ6p7DTXy9blWXa5FVFeJ6hJRXSSqc0T1K1GdJKpjmvUjRPUzUR0gqr36qt2a" + "9R1EtVVftUkErieqtSJwNVGtIKqlInCRCJwvAucQ1fca9ukicIoInCgCx4nAMSJwJLcaxq2+cSc40J1g/wiZ36riX+HxL3eIfSa+Y9Pex0eIYvM+RXTEQlwksJmJkRQpkNrGpkV6ZLLBWZANOW10buRDQeUvjCI2vjhK2vwyKKcAFVCZgKqgmmLUIJRaqKso9RWlAQE1Vpgm5NSMZ7UgrVZoh688181HvRwXdGADnT/EOCOMOcb448052fzTEPw" + "D0RxHLrDmJVjuWla7xrVYj83Yhp3YiwP4GUdwzLEnnfMrzhnjorEuG/Ma/jDHTXPdNuc9cz+whsfW8tSanltb8Pa+b6w1HOJS/3CpF1zqmej7m0s95FJ/cam7RPVnLa5Vg2u5+7uiUf+NqM6Lv7NEdZqoThDVL0R1mKgOEtV+otqjr9pJVNuIaou+aoMIXKev+kFftYqolovAJSJwoQicJwJni8AZInCqCPxOBE4Qgd9yq9EfiURuNZRbDYo4+K" + "0i/hUfod4JI4V63H/Xxn2AyPjE5kVFTMRGPBuZEEmQDCmV9jOkRQYbnBlZkM1G50Qem50PBVHYphdBcZIoidIKUA4VFKESAX2JaopRQzFqEVEd1FOUBqTUiF81JqumvKsFAol19HwXr/dwfB/nDTDON54dbuzR5hvn1YmYYj0zrG+29c5z9CIsc20r8QPWEctGbMEO7Ebw80M/ee0QjuK4c04heIOA88b6zZhXjH3dPDdcU/AOYHfNHbx/4UNrC" + "d599Zm1vbTG19YasubwGy71iks951JPudRjonpQh2txqdtEdZOo/iCqa+7+LhPVRT3VOfF3hqhOEtVxojpKVIeI6iei2qev2k1UO4hqK1FtEoHriWqtvmq1CFxBVEtF4GKimk9Uc0TgLBE4XQROEYGTuNV4EThWwz5Kwz484vVw/whR3qrhX/kR6l4qUqirRr6rSOwqErtyrS76rS7E1UUkdhGJnUViZ+LqLBI7i8ROxNVJv9WJuL4irq+Iq6Nm" + "vqN+qyNxdSCuDsTVnrjaE1c74mpHXG2Jqw1xtSGu1sTVirhahasSUXXFqKkYtflUXXKqj4Z8qxF5NfNna/9v7/VOju3unKDFD+4fBxl3qFdGmm+suSdYy3eOmmad31v7XCxwTUuwnEBWYy3WG2UztmEn9nhuPw7iiGOP4aRzT+OcsS4a85Kxgzdo+t1cN81529z3rOGBtTyypifW9twaX1l78O734RCX+odLvSSoZ1zqb9H3iKjui767VbkWUd0" + "gqutEdZWoLhHVBaI6S1SnieoEUR1zB3iEqH4mqgP6qr2a9V1EtZ2otmjWN4rAdUT1g75qlQhcLgKX6KsWisB5InC2CJwpAqdxq+9E4EQROE7DPibS69CYCLnequDf5hEx1OnUOzbtfXyEKPjUBkZHLMS1kfGRCEmR3KamQhqks7kZkNkGZ0V25CKcPDY7HwqisE0vYtOLoyQBlUZZBShPLBUVobIiVEE1IqpBSrVIqg7fqkteDd9KrKXng4D8yt" + "+6OrenMfoZd6Dxh5hvhHnHOGKcNU2yxqnWPQOznTGfKBZhGVYSyRqsw0ZswXbsxj785JhDOOq84zhljDPGO4/fjH3FHNfM9Yc5g/cvDN4g8y9reWhNf1vbU2t8Ya2vrTlk7eE3BPWaS70QfU+51GMu9VA/9Zfou6OfulWeaxHVNaK6TFS/EdV5ojpDVKc41XGiOkpUh4jqJ6Lap6/aQ1Q7iWobUW0WgRuI6keiWiMCV+qrlhHVYhG4QATOFYGzi" + "GqGCJwqAieLwAki8NsI+9+W/9/wEW4ROWKo/dl3bdoHiIxPbF5UxEBsxLWRCZAYSW1oCqRW2DRIhww2+HNktcnZkctG50E+4imIwja9iE0vhhIEVMrml0V5BahARJUUoYogrEpO1VGTdwX/1SexJp5v4aM2ju3onC6e6WG8Psbt75XB5h1mDaOs6VtHTcB31hx8/8T3mEsQCwljCZYj+AbptViPzdiGndjjtf0Ifn77sHN+ce4JnDbWWWNewCVz" + "BG8v97s5b7q+P63hrrXct6ZH1vbEGp9b60tr/sfaw64h/A+XesmlnnOpJ0T1iEvd51J3ieq2fupmKY18Ca5FVJeI6gJRnSWqX4nqJFEdI6ojRPUzUR0gqr1EtYuothPVVs36JhG4jqjWEtVqEbiCqJYS1SIROF8EzhGB34vA6SJwigicGPF0eNl/4rtD/9UeoVZ1IoVavXrPpn2IyPjE5kVDDMRWwHhIgMQ2NBlSILWNTYN0NjcjPrfBWZEduQg" + "oj83OhwI2vBC+IKJiNr6EjS9FQGVQTgEqKEAlXlWZpKrwrWrkVdOf9fy/kdeaO6a1v7V3bifjdPNsb+N/bZ7gS6xDrGGEo8ZY33jrnWz9U50xE8F3gM3HIgJZhpVYg3XYiOAH1LZjF/bhJ8cewlHnHjPOKZwx5jljXzTHZXNdM+cf5r5lDcHb+95zXQ+s7bE1PrXWF9Yc/P6ON64hHOJSrwnqBZd6yqX+JqqHmvS/uNQdorpFVDeKisQvNPKFuB" + "ZRnSeqM0R1iqhOENUvRHXYHeBBd4D7iWoPUe0kqm1EtVlftYGofiSqNfqqVfqq5US1WAQuJKp5RDVbBM4UgVMjPQ9NjlDubdX/Oz1Czde+Y9Pex4f42OZ9imiIiTg2Mh4S2swkSIYUNjUV0ih2OmS0wZmR1SZnR04bnZt48qKADS9kw79AUSIqbuNL2vjSRFSWlMrzqwpkVUnnVQU1/L+u5xv6qKljWzqvnTGCe8jgCxQ9zdPXqwPM/421DLe2U" + "Y781tqD75/4DtOJYRbmOnshlhDJcqzGWqzHJmzFTuxxzH4cdM5h/GKMEzhtzLPGvmCO38x1xZzXzX3DGv60lrvWdN/aHlpj8OsVnlnzS2v/xzWEXEv4DZd6RVDPudQT0feYqB6IvnvFuRZR3SSq34nqWn6RmFcj7+7vnEb9V6I6SVTHOdURojpEVD8R1T6i2k1UO4hqq2Z9E1GtJ6q1RLVaX7WCqJaKwEX6qvlENVcEfi8Cp0eY9rba/x0f4Rbv" + "RQw12v2OTfsAH9m4j/EpotvAmIiD+DYyIZIQTTKkQCobm8bGpkMGZLbBWYgnG3La6Nw2Oi8KEFFBG16YiIqgmI0vYeNL8aoyJFVW11WevCr7s7r/1/ZaA8cFHVgL57cxVgdjdjZHd3P2NvfX1hL8A9FQ6xxp3WMVfjwmO2sqMczEbMwnjkVYhpVYQzDBD6gFPwG5BduxC3sdewA/I3j/nGPGOolfjX3OHBfNddmc18wdvL3vTau8bU33rO2BNT6" + "21qfW/Nzag98+9Ma1hEME9Q9BvRB9z7jU31zqoej7S/TdFX1/atJvENV1orpCVL8R1QV3f2c16qeJ6oT4+4WoDhPVQaI6QFR7iWoXUW3XrG8hqo1EtY6oftBXrSKq5US1RF+1kKjmEdXsiOvdBb77ttr/nR+hRjkjheo/edemfYCPbFwUREV0xYyJuIhvMxMiiQ1NhhQ2NTXS2Nh0yEAWmW1wFmSzyTkJKBfy2Oz8NrsgERWy4UWIqCiKk1NJsi" + "pNXuX+RWLlnFXByBWtorKSfkkCVYVTNXFYXRwGX16tFe5lDf2sZ6D1DXHkcAUfjeAbdCYSwRRMd/YszMVCAlmC5ViNtViPTdiKnY7ZjeDtTX5y7iEcNdZxY54y/hnznMdv5rxi7uvWcMNagjcov2ttwa9XeGitwS+HeWbtL1zDa9cSck3hN1zqFZd6zqWecqnHXOoBl7pHVHdE303R94fou0ZUl4nqIlGdI6pfieoUUR0nqqNEdYiofiKqfUS1m" + "6h2aNa3uQPcRFQbiOpHfdUazfpKolqmr1qsr1oQ8Ulo7n/hN/D9qz9CdfNECtX6+12b9oFNi4woiEow0RHLJsZFfBuZEElsZjKkIJxUSGNj0yGDzc1MIlmQzSbnsMm5CCgP8tnsAoRU0IZ/QU5FeFYx0irhvzI+rui5Kl6v4bi6zmvomabGaWnctl7paL4u5u5hHX2sLfgXyMHWO1SxRyr6WGeNx2RimIbgG6TnYD4WYRmxrMQa/Ijg57e3YDt2" + "Ya9zDuBnYxxB8PZyJ439qznOmuuClV0yd/D+0b9by01rum1t96zxvrU+suYn1v7cNbxyLf+4pnCIS/3DpV5yqWdc6m+CeqSfus+l7hLVn0R1I4dIFH1XieoSUV0gqrNE9StRnSCqY0R1hKh+JqoDRLWXqHYR1XbN+hai2khU64lqrb5qNVGtIKolke6HlkTI+La6/y8/QtVnRLJp79m0DxHZxkVBVMSwgbEQl3DiI6HNTIJkNjSFDU2FNMSTDul" + "tbiab+zmykkx2m5zTJucmorxElB8FSaoQ3/oCxVHa38t7vrLjqvtbbefWN04Tz7YwRxtzdfBqZ2vobj29re9rax3o6CEKPkLhg+8AG0cEkzDFCNMxizjmYiGCH1BbjlX4AeuxCVuxw7G7sc+5P+GQsY7iuLFPmeOMuYK39/3N3Fes4Zq1/GFNt6wt+P0df1nrQ2t+bO1PXecL1/LaNb1xbeE3XOo1l3pBVE9F32Oieij6/uJSd/RTt4jqD036tU" + "wiMb1IJKrzRHWGqE4R1XGiOkpUh4nqIFHtJ6o9RLVTs75N/G0mqg1E9aO+6of3uFakcGh5hH+Dr67/1z7CESJGCFVe+I5Ne8+mfYjINi4KohJODMSyiXER30YmRBKbmQwpCCiVTf0MaYkjvc3NZHMzIwvpZLPJOWxyLj6Vh5zy6bjyk1bwX1Efl/RcOR9Vcmw159QyRj1jNTJuM+O3Mmc7839lLV0d1dMa+ypw8P0TgxV8GEY5cywRTEDwDdLTM" + "BNzCGQ+FmEZViL4+e0fscHrm7ENu5y3Fwfws7EOG/MXnDDHaXOdNecFc1+yhqvWEvx6hZvW9qc13rXW+67ikbU/ca3PXctL1/SPawv7NAr/Q1CvRN9zLvWESz3iUvdF310udZtL3dSk/05UV9Nyrc+4VkqRSFS/EtVJojpGVEeI6meiOkBU+4hqN6faQVRbiWoTUa0nKrdioTURvntb0f+xHhFD5aa8Y9Pes2kfIrKNi4KoiGEDYyl6HMSzkQmR" + "2GYmJYjkSGlTP7OpaZGOiDLa3Mw293MCyobswjAnSeVGXvIqgCL+X8JrZR1X0fFVnFvDOHU828D4Tc3V0txtHRH8A1FnIuuusL0d/TUGKXbwHWAjFD/4/tVxRpiEKUQxHbMQ/IDaQizBcqzCD1iPTQjeP2eHc4J3/9pnjJ+MdwhHjX3cHCdxxpznzH3RGi5byzV78Ye13bLG29Z6z5ofWPtj1/DUtbxwTcGvF33jGsMhLvWaS73gUs+41N9c6iG" + "X+ouo7hDVn1zqBpe6TlRXiOq35FwrKddKpJF393dCo/4LUR0mqoNEtZ+o9hDVLqLaTlRbiGojUa0P3vT/f9RHuPo7EUOl3KiWIq6SxFWSuEoQVwniKq7nKq6hL0ZcRYmraDgBaSS2mUmR3IamtKGpfZamQTobm4GIMtnczKSUlV9lI6scvCv4L5BYYc8X91Fpx5Z3bmXPVDdW8AWK+uZp7NXm5m5tHe2tqRORdVPYXuiryAOc9Y2iD8MoAhiLCQ" + "QxGcHPD8004hzMxyIsRfAGAWvwIzY4ZjO2Yadz9yB4/8KDOGzsX8xxwlyncdYqL1jDb9ZyxZquW9sNa/zTWu9ac/D70x667uC3Pz5zzS9d2z+uMeTTKfyGS73iUs+51FOCeiz6Huin7hHVbaK6mVokcqlrRHWZqC4S1Tmi+pWoTrr7O65RP6qn+v+1d5/RUpTZGse7G5CcBSQKShIRkSAYBgczRlRUFFFEFBFFJIgwhIsgQxDJIjmIBEFykAySJ" + "MeD5HDIOWeovr/y8mHWXWu+3GuAkWL94Zzuqvfdez9P77fo06dqieVvEVPNZ6q5TDWbqaYz1Y/RdvFw1bmmNwFGg4eHJlGwZEjBPKkULg3SK15GZGaCrIp4C3IoZC7myIO8CnqbguZnooKKWpiBiqAoO92F4vrWPexV2r/3+76c5x623xOOedrxzxvrJWO+ao4q5qtm7hr2eJ+AtQn5MUHrE7aRI/5B6OaM9jnCz6+2Q0ejdEZ3puiJ3gh/A3IQ" + "owzBcIzEaI+Nw0RMwXTHzMIcY8zHImMuxjJzrDTXGnMmmHuDGDaLZZuYdoptlxj3yuKAmA+L/ZgcTsrltJzOye2iHMO7b8cDXeqyLnWBoc7qUqcsfcctfUd1qUPOp/Yz1R5LX2IeXYuptjLVJqb6hanWMdVqplqhUy1lqsVMtZCp5iWLB3OSBMHMaPdr31T/skWDcn2SKFgypFC0VEijcOlZIiMyK2AWBsqG7AqZSyFzs8ytyKegtzNPAUUtxEp" + "3sNSdFsWietfdCC1W1uMP2qe87x5zbAVjPGfMF439inleN++bRKvOZO8R8AN71iFoPcKGH9Bp7Khm+C+ityZ+W3RghE7oih5G7IW+GMAs32IoRmCUx8ZgAibbdypmYLYxfsICY/5s7KVYYa7V5lxr7vD2ChvFskVM28WWKMY9Yg3vn3ZQ7EfkcFwup+R0Vm7n5XhJroGc41cY6pIudV6XOqNLndSljln6DutSB3Wpfc6ndjuf2ul8als2XYupNj" + "LVeqZay1SrmGo5Uy1hqkU61QKdak60+1W5rqPt12XxPua6j7nKMldZ5irDXPfG0yEDA2VSwCzIpojZmSinQuZWyDzskxe36VP5UZClCutd4Z9iLFbCY2V89YB9H3LMo45/0jjPGLeiZyqZq7J5qxIs/AFR+BPI9wn5ob3rErYBGhH5H8RuQfTwA9JtjNIOHZmhM7ozR0/0Rvj724MwBMMwEqMxzn4TMQXTHDsTc4w1DwuNHV4/epm5wqvfrzF3g" + "hg2iGWTmLaKLby91S6x7hXzAfU4JIejcgnvX3tabuHdty/I9bKc415e8cu61AVd6qwudVqXOqFLHdWlDjHVAV1qD1PtYqodzqe2Op/alEHXsvwlMNUaplrJVMuYajFTLbgelr9/t8UjsWhQyrJYirlKxpMjJVukVrh0yKB4mRjoZgXMilsUMQcT5VLIPEyUVzHzsdTt+lYB9irs37v8fY/nStvvft+Vc9zDxnnco08b+3lzhW+xvspkVYj2FvHe" + "sWdNNvyAoHUQfgLsU0c2JnYztCR8ayZoiw4If0GtK3qgF5P0xQB8i6EYgVGeG4PxmOyYHxFeIHM2wsv7zscicywx13JzrjJ/eP+O9QjvPrSFmbaJcadYd4t5n9jD24sekctxOZ2U2xl1OK8Gl+QcyD8e6FKXdKnzutQZXeokUx239B1hqoOWvn1O0ncz1U6m2s5UW5hqY2pdK6WuldySyFQrmGpptMv1a6p/3YLiA2IMlFTBkiOloqVmjLQKlx4" + "ZGSWzAmZRwGzMkx05WSk38uhZefWu8E8hX9/pseK+KmXfso77m0fKGy98g6KCOZ4lzgtEepmJX7NX+BPItwn4LiFrOeIjRvuEuA0I/RnCD0i3MMrnaMMI7dERnRmjO3qiN/pjEIZgGL7HDxhn34mYgmnGmIk5xpxn7IVYbK5l5lxh7tViWCeWX8S0SWxbxbhDrLvEvEfs++VwSC5H5RTefTu8vftZuV6Q82Uvr7gaxC/rUhcZ6pwuddrSd0KXOq" + "pLHbb0HbD07bX07bL07UirazHVZqbawFQJSXWtWDxYeY2+pfB/2iyLkaBo+1hQ5GxSBroJKRQtlaKlRTqvxgyKl4lxblbArAp4i16Vg6VyOuvKzV75/FvQ30U8V8x+4RlYGcc+YJyHPPooMZ5k1mc8W5FI4Q+IKhPsDcJVs/c7hKxJ0PATYB87sj4+JXYTojdDSwZojbZG7IBO6MogPdALfTEA4fVzhiK8+tco+4zBeExy7I+YbqxZmGvs+eZYZ" + "L4lWG7uVWII7z6UIKYNYtssxm1i3clMu8W+Tw4H1OawnI7J7aQcz8j1nJwvyv2KGsQDhrrEUOd1qbO61Cld6rgudUSXOqhL7del9jBVoqVvu6Vvy02WxKTxYH3saLDuWnrz87fcggJlokGBK0kU6yakYKJUipZG0dIxUXpkYqLMyMJO2SyK2dkr568Wy+WIPMp+KxnykeU2UuUnZQG9opAFqbDl8A6n1kWcxBd1En+Xk/hiTuLvdhJf3El8+Omv" + "ErpWCV2rpK5VStcqrWuVjjclfAu0YoQ2aM8UHdEZ3dGTUXqjHwZhiMeG4XuE1y8c65gJmGyMaZhpzNn4yRzh7RV+NudSrBDDarGsE9MvYtskxi3MtF3MiWLfI4f9Xj6H5BTe3v24HE/J9aycL8j9shoEahG/oktd1KXO6VJndKmTutQxXeowUx1wPrWXqXYz1U6m2mbp2xw9Hay/Vn5M83ttwW2lokHeGUkUKxmSK1hKJkqtaGlZKJ3CZWSnTHr" + "WzayV1Z8c/s3jsds9X+jqGVhxx5ZS9LKK/zfP/J0YjxGlgj2eJdALxHrZnq/hDQJWI2QNvE/UDx39MZHr41OCNyF+M7REa6O2RQfG6ISu6IFe6IsBGIzvMAKj7DsG4x07CT9iujHDq9/PxXxzLTJneIOY5VgpljViSsAGZtos1m1i3iH2XXLYK5cDcjost2NyPCnX03I+pwoX1eCKWsQDXeqyLnVBlzqrS51iqBO61FFL3yFL335L3x7nU4lMtS" + "06KdjyZ/9A+Y/aglwpI0HOYbEgx5WkinUTE6VQsFRIw0hp9av0+lZG3IzQYrk9ns/zBe1fhMGKKXZJRS+j+OE7YA959hGiPOGV/jSBnrfnSwR7lXBVCPiWo6oT8z3d7APi1sEnRmlI9M/QlAFaoBUztEF7dERnJumGnuiNfhiIIZ4bhu8RXn11rGMnYLKxphp3Bmab4ycsMOfP5l4qhhViWSWmtWJbL8aNYt0i5u1iT5TDbrnsk9NBGR+R43GGO" + "iXns3I/rwaX1CJQk/gVXeqSLnWeoc7oUid1qWO61BFd6qClb2/sXLA70is++8/66MufuQXZnokGWRKSKFYyxUquT6Vkp9TOuNKwVnr9K7Ovs3ksl6/yMlx+xb3j1/8/ZidnDj0jl8Upt66Vx3KY13KYz3J4m+Xwdl0rv65VQNcq6CS+kJP4wk7iww9Hh5++LxKvS+z6aET4Jmhu1Jb4Am0ZowM6oSt6ILxAUx+El5cbjO8w3L4jMRrjjDEJU4w5" + "DTPNMcdc88y7EOHtrZaJJbw53xqxJYhxg1g3iXmr2HfIYZdc9sppv9wOy/GoXE/I+bTcz6nBBbW4rCZxtYlfZqgLutRZXeq0LnVClzqqSx2Krgv2/dGf/LzWtiBdpmiQflUsSB8kVaybWCoFUrFXWmT0d1YWy6GYtzLe7YpbSJGLerQ4y5VS/LKefVAX+ztRHiXOk/Z8hlAVCVaJcJUdVYWQbxH0HdQk7gdGqYNPCB7+gtpnDNAULZihFdqgPXN" + "0RHj9nG7oid7oh4EIL5A5FOHlfX9w7FhMMNZkTDX2DMw2V3j3ofnm/xlLxLJcTKvEFt5edL1Yw5sjbxH7NjnslMtuOe2T20E5HpHrMTmfVIkzanBejS6qSaA28UCXuqRLndelzuhSJ2OXgmORBfH4H/UZ9ethi6d5MBqk2J2ErZLpXeGf0GIZWOxmRcyumLkVNZ9HCjJY+AZFMc+UUPx7ifCAV3Y5e4U/gXyCQE/Z+zmCvYhXCPg6qjo6/ID0u8" + "SthQ8JXZfo9dEITYzcHC0Z4gu0RQd8ha7ogW/QBwMwGN9huGNGIrxA+ThMxBRjTzPHTMwx5zxzLxTDYkYK7/64AqvFuE6sv4h5k9i3ymGHXBKZaY/c9svxEEMdlfMJuZ9Sg7NqcUFNLqtN4GUYv6JLXdSlzkUTgzO/869oXbdbPJImGiTpFYvHlCyJ8iXTq5Ir7/+cgeVS1LyKm1+RCyv2XYp+D5OVJkL4A6K/MVl5ez5GoAqEepZgLxCukiMrE" + "/ENYlYj7DuoaaTaxA5/Qa0e4RviMyZoihZoZZY2aI+O6Ixu+Bq90Q8D8a19h2IERhljDMYbM7x/x1RzTDfXLMw193wxLBLLEjEtF9sqMa4Va4KYN4h9sxy2yWWnnHbLbZ8cD8j1sJyPyf2kGpxWi3NqclFtrqhRPIjFg0vRVrrU7/TLpP8pW/iOcBApkSyITkkZxC6mjSdV5mTKnpwUKciTioSp9Ynw7dV0TpXTWw4zOInPpGtldhJ/s5P4LLpW" + "Vifx2ZzE3+IkPruulUPXyhl/E9WJ+y6Ra+FDI9ZFfeI3QhNmaI6WaI226MAkX6ErwusXfuOxPuiPQRiC4Y4didHGGoeJxp6Caeaaac45mCeG8O6PP4tpqdhWiHG1WNeJ+Rexb5TDFrlsl1Oi3PbIcb9cD8r5iNyPq8EptTirJueD2PmLanQh+C2vpfAX2VIGkTJpgujMDEEsyKKY2RU1t+LmU+SCil1E0YtZMEsQ4F5i3E+Ucl7pDxPocUI9RbB" + "nCfcCAV/Ga8R8g6jVjFQDNQldG3WIXg8NmaAxmpqlBVohvEBTO4SXl+uMbvgavdAPA/GtY4ZihDFGYYwxx2OSOcLbW0035yxzzxXDfCwS02KxLRNjePftNWJOEPsGOWyWyzY57ZDbLv+V2SvXA3I+LPejanAiiF06HUTHMNRvcymhv/KWNogUzBxEf8xmicyluHkVOXyLtbCiF1X84kxWihBlCfKgV3r4AZ1HCfUkwZ4h3PN4iYivErMKUd9EdQ" + "K/S+xa+IjwddEAjRihCcLr57RkjtZoiw74Cl3QA9+gj336YxCGOHYYvscPxhyLCeaYbK6pmGHu2WIIby+6QFw/Y6kYV4h3NdaKfb0cNspli5y2yy1Rjrvluk/OB+V+mKEOB//PK+nd2P7XZonMEkTuzsFgeSyRtzu/KKTodyr+3V7RJQlRhiAPEKYcgR4m1ONe/U8RLfyA9ItEfJmYr6EqcasRuQZqErw26hC/HhqiMUM0RXiBplZog3boiM7oh" + "q8RXj+6LwY6Jry9wlCMMNYojDb2eEwy1xRzTscsMcwRyzwxLRTbYjEuE+tKMa8Re4IcNshlk5y2ym2HHBPlulfOB724rlbixvZ7bXktkWiaP4jtuUPx7/KKvocQpQlyH2HCT4CVJ9RjBKtAuGcIWJGQlfAqUcNfUHsL1Qn9HsFr4SPUZYIGaIQmTNEcLdEabdEBXyG8vG939LRfH/THIAwxxjCEdx/6wdhjzTEBk8051dwzMFss4c2RF4htkRiX" + "iHW5mFeJfa0c1stlo5w2B9E924PIJzuDv8q75tfQdms8kqFwEClbNIj+cLdzj5IEKUuYBwj0EKEeIdgThHuagM/hRWK+QtTXUJXA1QhdA+8TvjbqoB4jNERjNEULhNcvbIN2+NL3ndANX6MXwtsrDHDsYHyH4cYcidHmGGeuiZhi7mlimCmeOZgntoViXCzWZWJeIfbVQezUOrkkBJE7t8vtapo3tj9zyx9EkpeMRyreG0SH3e9/TOUIVZ5gj6E" + "C8Z4lYkViViJqZVQh8luoTvD3UIv4H6EuGjBEIzRBc7Rkktb4Jzr4Prx+dBd0R0/0cUx/DMQQYw3D98b+AWPNNd68kzFVDNPFMktMc8U3H4vEujiI9l0p9nU33ti89rcHg8jb5YNIs0eC6PonnPg+TcTnCfoiXiHu66hK6LdRg+jvozYTfIx6aMgUjRFev7AFPkcbtMOX6ISu+Nq+vdAXA4wxGN8ZczhGmmM0xplzovmnYGoQuzJDTHODSN15wb" + "+5h/KN7frYnrC0PPsr0SEvBNEJlZy/VGa2KoR+C9XxHvFr4SNGqIsGaIQmDNIMLdEa/0R7fOW5LuiOnujt2H4YaKxvMRQjzDEqiCaONee4INJjihgmBpE7roZ1Y/tP2560bL4RRFJXCSLpqgaRLtWCaJcaqBlEV9aOR3WtmK4V07ViulZM14rpWjFdKxb/Au3wJTqhK3o4pqdjexujPwYZc7DxQ7qY6+q0f6EtEvlvLj6dTNsMZuwAAAAASUVOR" + "K5CYII=";
    return Result;
  };
  this.GetColorWheelResource125 = function () {
    var Result = "";
    Result = "TTMSFNCCOLORWHEELPICTURE125";
    return Result;
  };
  this.GetColorWheelResource150 = function () {
    var Result = "";
    Result = "TTMSFNCCOLORWHEELPICTURE150";
    return Result;
  };
  this.GetColorWheelResource175 = function () {
    var Result = "";
    Result = "TTMSFNCCOLORWHEELPICTURE175";
    return Result;
  };
  this.GetColorWheelResource200 = function () {
    var Result = "";
    Result = "TTMSFNCCOLORWHEELPICTURE200";
    return Result;
  };
});
rtl.module("WEBLib.TMSFNCColorWheel",["System","WEBLib.ExtCtrls","WEBLib.Controls","Web","Classes","Types","WEBLib.Graphics","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCImage","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCTypes","WEBLib.TMSFNCEdit","WEBLib.TMSFNCStyles","WEBLib.TMSFNCUtils"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 1;
  this.BLD_VER = 0;
  rtl.createClass(this,"TTMSFNCRGBTrackBar",pas["WEBLib.ExtCtrls"].TWebTrackBar,function () {
    this.SetValue = function (Value) {
      this.SetPosition(Math.round(Value));
    };
    this.GetV = function () {
      var Result = 0.0;
      Result = this.GetPosition();
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.SetMax(255);
      this.SetWidth(100);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCImageColor",pas["WEBLib.TMSFNCImage"].TTMSFNCImage,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCImage"].TTMSFNCImage.$init.call(this);
      this.FDPIChanged = false;
      this.FMouseDown = false;
      this.FImageLoaded = false;
      this.FPixelColor = 0;
      this.FOnColorChanged = null;
      this.FX = 0.0;
      this.FY = 0.0;
      this.FImgDt = null;
      this.FOffS = 0;
      this.Fsc = 0.0;
    };
    this.$final = function () {
      this.FOnColorChanged = undefined;
      this.FImgDt = undefined;
      pas["WEBLib.TMSFNCImage"].TTMSFNCImage.$final.call(this);
    };
    this.SetPixelColor = function (Value) {
      if (this.FPixelColor !== Value) this.FPixelColor = Value;
    };
    this.SetX = function (Value) {
      if (this.FX !== Value) this.FX = Value;
    };
    this.SetY = function (Value) {
      if (this.FY !== Value) this.FY = Value;
    };
    this.SetCoordinates = function (AX, AY) {
      var a = 0.0;
      var b = 0.0;
      var angle = 0.0;
      var r = 0.0;
      var cp = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      cp.$assign(this.GetCenterPoint());
      r = this.GetRadius() - (1 * this.Fsc);
      a = Math.abs(cp.X - AY);
      b = Math.abs(cp.Y - AX);
      if (a === 0) a = 1;
      if (b === 0) b = 1;
      angle = (Math.atan(a / b) * 180) / Math.PI;
      if ((AX >= cp.X) && (AY <= cp.Y)) {
        angle = 360 - angle}
       else if ((AX <= cp.X) && (AY >= cp.Y)) {
        angle = 180 - angle}
       else if ((AX <= cp.X) && (AY <= cp.Y)) angle = 180 + angle;
      angle = pas.Math.DegToRad(angle);
      this.FX = (cp.X - 0.5) + (r * Math.cos(angle));
      this.FY = (cp.Y - 0.5) + (r * Math.sin(angle));
    };
    this.PtInColorWheel = function (X, Y) {
      var Result = false;
      Result = (pas.System.Sqr$1(X - (75 * this.GetDPIScale())) + pas.System.Sqr$1(Y - (75 * this.GetDPIScale()))) <= pas.System.Sqr$1(74 * this.GetDPIScale());
      return Result;
    };
    this.DoAfterDraw = function (AGraphics, ARect) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.DoAfterDraw.apply(this,arguments);
      if (this.FDPIChanged) {
        this.FDPIChanged = false;
        this.MapPixels();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.FDPIChanged = true;
    };
    this.ColorChanged = function () {
      if (this.FOnColorChanged != null) this.FOnColorChanged(this);
    };
    this.BitmapLoaded = function (Sender) {
      this.FImageLoaded = true;
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      this.CaptureEx();
      this.FMouseDown = true;
      if (this.PtInColorWheel(X,Y)) {
        this.SetPixelColor(this.XYToColor(X,Y));
        this.ColorChanged();
        this.Invalidate();
      };
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (this.FMouseDown) {
        if (this.PtInColorWheel(X,Y)) {
          this.SetPixelColor(this.XYToColor(X,Y));
        } else {
          this.SetCoordinates(X,Y);
          this.SetPixelColor(this.XYToColor(this.FX,this.FY));
        };
        this.ColorChanged();
        this.Invalidate();
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      this.FMouseDown = false;
      this.ReleaseCaptureEx();
    };
    this.GetDPIScale = function () {
      var Result = 0.0;
      Result = this.FPaintScaleFactor;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCImage"].TTMSFNCCustomImage.Create$1.apply(this,arguments);
      this.SetWidth(150);
      this.SetHeight(150);
      this.SetX((this.GetWidth() / 2) * this.GetDPIScale());
      this.SetY((this.GetHeight() / 2) * this.GetDPIScale());
      this.FImageLoaded = false;
      this.FDPIChanged = false;
      this.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
      this.FOnBitmapChanged = rtl.createCallback(this,"BitmapLoaded");
      return this;
    };
    this.Destroy = function () {
      this.UnmapPixels();
      pas["WEBLib.TMSFNCImage"].TTMSFNCCustomImage.Destroy.call(this);
    };
    this.Draw = function (AGraphics, ARect) {
      pas["WEBLib.TMSFNCImage"].TTMSFNCCustomImage.Draw.apply(this,arguments);
      if (this.FImageLoaded) {
        this.FImageLoaded = false;
        this.MapPixels();
      };
      AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
      AGraphics.FStroke.SetColor(0);
      AGraphics.DrawEllipse(this.FX - this.ScalePaintValue(5),this.FY - this.ScalePaintValue(5),this.FX + this.ScalePaintValue(5),this.FY + this.ScalePaintValue(5),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      AGraphics.FStroke.SetColor(16777215);
      AGraphics.DrawEllipse(this.FX - this.ScalePaintValue(4),this.FY - this.ScalePaintValue(4),this.FX + this.ScalePaintValue(4),this.FY + this.ScalePaintValue(4),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.MapPixels = function () {
      if (this.GetWidth() !== 0) {
        this.Fsc = Math.round((this.GetCanvas().FElementCanvas.width / this.GetWidth()) * 100) / 100}
       else this.Fsc = 1.0;
      this.FImgDt = this.GetCanvas().FContext.getImageData(0,0,Math.round(this.GetWidth() * this.Fsc),Math.round(this.GetHeight() * this.Fsc));
    };
    this.UnmapPixels = function () {
    };
    this.XYToColor = function (X, Y) {
      var Result = 0;
      this.FOffS = (Math.round(X * this.Fsc) + (Math.round(Y * this.Fsc) * Math.round(this.GetWidth() * this.Fsc))) * 4;
      Result = pas["WEBLib.Graphics"].RGB(this.FImgDt.data[this.FOffS + 0],this.FImgDt.data[this.FOffS + 1],this.FImgDt.data[this.FOffS + 2]);
      return Result;
    };
    this.GetCenterPoint = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].PointF(this.GetWidth() / 2,this.GetHeight() / 2));
      return Result;
    };
    this.GetRadius = function () {
      var Result = 0.0;
      Result = this.GetWidth() / 2;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.recNewT(this,"TTMSFNCColorWheelHSColor",function () {
    this.Hue = 0.0;
    this.Saturation = 0.0;
    this.$eq = function (b) {
      return (this.Hue === b.Hue) && (this.Saturation === b.Saturation);
    };
    this.$assign = function (s) {
      this.Hue = s.Hue;
      this.Saturation = s.Saturation;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCColorWheelHSColor",{},this);
    $r.addField("Hue",rtl.double);
    $r.addField("Saturation",rtl.double);
  });
  this.$rtti.$MethodVar("TTMSFNCCustomColorWheelBeforeDrawSelectedColorPanelEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARectF",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASelectedColor",pas["WEBLib.Graphics"].$rtti["TColor"]],["AAllow",rtl.boolean,1],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomColorWheelAfterDrawSelectedColorPanelEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARectF",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ASelectedColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomColorWheelSelectedColorChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASelectedColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomColorWheelRValueChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AR",rtl.longint],["ASelectedColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomColorWheelGValueChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AG",rtl.longint],["ASelectedColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomColorWheelBValueChangedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AB",rtl.longint],["ASelectedColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomColorWheel",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FImage = null;
      this.FREdit = null;
      this.FGEdit = null;
      this.FBEdit = null;
      this.FHEXEdit = null;
      this.FRTrackBar = null;
      this.FGTrackBar = null;
      this.FBTrackBar = null;
      this.FSelectedColor = 0;
      this.FGValue = 0;
      this.FRValue = 0;
      this.FBValue = 0;
      this.FHSColor = $mod.TTMSFNCColorWheelHSColor.$new();
      this.FOnBValueChanged = null;
      this.FOnGValueChanged = null;
      this.FOnAfterDrawSelectedColorPanel = null;
      this.FOnSelectedColorChanged = null;
      this.FOnRValueChanged = null;
      this.FOnBeforeDrawSelectedColorPanel = null;
      this.FFont$1 = null;
    };
    this.$final = function () {
      this.FImage = undefined;
      this.FREdit = undefined;
      this.FGEdit = undefined;
      this.FBEdit = undefined;
      this.FHEXEdit = undefined;
      this.FRTrackBar = undefined;
      this.FGTrackBar = undefined;
      this.FBTrackBar = undefined;
      this.FHSColor = undefined;
      this.FOnBValueChanged = undefined;
      this.FOnGValueChanged = undefined;
      this.FOnAfterDrawSelectedColorPanel = undefined;
      this.FOnSelectedColorChanged = undefined;
      this.FOnRValueChanged = undefined;
      this.FOnBeforeDrawSelectedColorPanel = undefined;
      this.FFont$1 = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetSelectedColor = function (Value) {
      if (this.FSelectedColor !== Value) {
        this.FSelectedColor = Value;
        this.FRValue = this.ColorToRValue(this.FSelectedColor);
        this.FREdit.SetT(pas.SysUtils.IntToStr(this.FRValue));
        this.FGValue = this.ColorToGValue(this.FSelectedColor);
        this.FGEdit.SetT(pas.SysUtils.IntToStr(this.FGValue));
        this.FBValue = this.ColorToBValue(this.FSelectedColor);
        this.FBEdit.SetT(pas.SysUtils.IntToStr(this.FBValue));
        this.FHEXEdit.SetT(pas.SysUtils.IntToHex(this.FRValue,2) + pas.SysUtils.IntToHex(this.FGValue,2) + pas.SysUtils.IntToHex(this.FBValue,2));
        this.FRTrackBar.FOnChange = null;
        if (this.FRTrackBar.GetV() !== this.FRValue) {
          this.FRTrackBar.SetValue(this.FRValue);
          this.DoRValueChanged(this.FRValue,this.FSelectedColor);
        };
        this.FRTrackBar.FOnChange = rtl.createCallback(this,"RTrackBarChanged");
        this.FGTrackBar.FOnChange = null;
        if (this.FGTrackBar.GetV() !== this.FGValue) {
          this.FGTrackBar.SetValue(this.FGValue);
          this.DoGValueChanged(this.FGValue,this.FSelectedColor);
        };
        this.FGTrackBar.FOnChange = rtl.createCallback(this,"GTrackBarChanged");
        this.FBTrackBar.FOnChange = null;
        if (this.FBTrackBar.GetV() !== this.FBValue) {
          this.FBTrackBar.SetValue(this.FBValue);
          this.DoBValueChanged(this.FBValue,this.FSelectedColor);
        };
        this.FBTrackBar.FOnChange = rtl.createCallback(this,"BTrackBarChanged");
        this.FHSColor.$assign(this.RGBToHS(this.FRValue,this.FGValue,this.FBValue));
        this.SetIndicator();
        this.DoSelectedColorChanged(this.FSelectedColor);
        this.Invalidate();
      };
    };
    this.SetBValue = function (Value) {
      if (this.FBValue !== Value) {
        this.FBValue = Value;
        this.FBEdit.SetT(pas.SysUtils.IntToStr(Value));
        this.FHEXEdit.SetT(pas.SysUtils.IntToHex(this.FRValue,2) + pas.SysUtils.IntToHex(this.FGValue,2) + pas.SysUtils.IntToHex(this.FBValue,2));
        this.FBTrackBar.SetValue(this.FBValue);
        this.FSelectedColor = this.RGBToGraphicsColor(this.FRValue,this.FGValue,this.FBValue);
        this.FHSColor.$assign(this.RGBToHS(this.FRValue,this.FGValue,this.FBValue));
        this.SetIndicator();
        this.DoBValueChanged(this.FBValue,this.FSelectedColor);
        this.DoSelectedColorChanged(this.FSelectedColor);
        this.Invalidate();
      };
    };
    this.SetGValue = function (Value) {
      if (this.FGValue !== Value) {
        this.FGValue = Value;
        this.FGEdit.SetT(pas.SysUtils.IntToStr(Value));
        this.FHEXEdit.SetT(pas.SysUtils.IntToHex(this.FRValue,2) + pas.SysUtils.IntToHex(this.FGValue,2) + pas.SysUtils.IntToHex(this.FBValue,2));
        this.FGTrackBar.SetValue(this.FGValue);
        this.FSelectedColor = this.RGBToGraphicsColor(this.FRValue,this.FGValue,this.FBValue);
        this.FHSColor.$assign(this.RGBToHS(this.FRValue,this.FGValue,this.FBValue));
        this.SetIndicator();
        this.DoGValueChanged(this.FGValue,this.FSelectedColor);
        this.DoSelectedColorChanged(this.FSelectedColor);
        this.Invalidate();
      };
    };
    this.SetRValue = function (Value) {
      if (this.FRValue !== Value) {
        this.FRValue = Value;
        this.FREdit.SetT(pas.SysUtils.IntToStr(Value));
        this.FHEXEdit.SetT(pas.SysUtils.IntToHex(this.FRValue,2) + pas.SysUtils.IntToHex(this.FGValue,2) + pas.SysUtils.IntToHex(this.FBValue,2));
        this.FRTrackBar.SetValue(this.FRValue);
        this.FSelectedColor = this.RGBToGraphicsColor(this.FRValue,this.FGValue,this.FBValue);
        this.FHSColor.$assign(this.RGBToHS(this.FRValue,this.FGValue,this.FBValue));
        this.SetIndicator();
        this.DoRValueChanged(this.FRValue,this.FSelectedColor);
        this.DoSelectedColorChanged(this.FSelectedColor);
        this.Invalidate();
      };
    };
    this.SetHEXValue = function (Value) {
      var str = "";
      var r = 0;
      var g = 0;
      var b = 0;
      if (Value.length === 6) {
        str = pas.System.Copy(Value,1,2);
        r = pas.SysUtils.StrToInt("$" + str);
        str = pas.System.Copy(Value,3,2);
        g = pas.SysUtils.StrToInt("$" + str);
        str = pas.System.Copy(Value,5,2);
        b = pas.SysUtils.StrToInt("$" + str);
        this.SetSelectedColor(this.RGBToGraphicsColor(r,g,b));
        this.FHSColor.$assign(this.RGBToHS(r,g,b));
        this.SetIndicator();
      };
    };
    this.GetHEXValue = function () {
      var Result = "";
      Result = this.FHEXEdit.GetT();
      return Result;
    };
    this.IsHEXValueStored = function () {
      var Result = false;
      Result = this.GetHEXValue() !== "FFFFFF";
      return Result;
    };
    this.SetFnt = function (Value) {
      this.FFont$1.AssignSource(Value);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.FFont$1.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FFont$1.FHeight,M,D));
      this.SetIndicator();
    };
    this.Draw = function (AGraphics, ARect) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      this.DrawColorPanel(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.DrawText(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DrawColorPanel = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var b = false;
      var df = false;
      var h = 0.0;
      h = 35 + this.FREdit.GetHeight() + this.FBEdit.GetHeight() + this.FGEdit.GetHeight() + this.FHEXEdit.GetHeight();
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.ScalePaintValue(25),this.ScalePaintValue(25)));
      pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(r,this.ScalePaintValue(30) + this.FImage.GetWidth(),h);
      r.Right = this.FREdit.GetLeft() + this.FREdit.GetWidth();
      AGraphics.FFill.SetColor(this.FSelectedColor);
      b = true;
      df = true;
      this.DoBeforeDrawSelectedColorPanel(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FSelectedColor,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }},{get: function () {
          return df;
        }, set: function (v) {
          df = v;
        }});
      if (b) {
        if (df) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        this.DoAfterDrawSelectedColorPanel(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FSelectedColor);
      };
    };
    this.DrawText = function (AGraphics, ARect) {
      AGraphics.FFont.AssignSource(this.FFont$1);
      AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(30 + this.FImage.GetWidth(),this.FREdit.GetTop() + 7)),"R",0,true,false,-1,-1);
      AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(30 + this.FImage.GetWidth(),this.FGEdit.GetTop() + 7)),"G",0,true,false,-1,-1);
      AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(30 + this.FImage.GetWidth(),this.FBEdit.GetTop() + 7)),"B",0,true,false,-1,-1);
      AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(30 + this.FImage.GetWidth(),this.FHEXEdit.GetTop() + 7)),"HEX",0,true,false,-1,-1);
    };
    this.RFieldKeyDown = function (Sender, Key, Shift) {
      var v = 0;
      if (Key.get() === 13) {
        v = this.FREdit.GetInt();
        if (v < 0) {
          v = 0}
         else if (v > 255) v = 255;
        if (v === this.FRValue) {
          this.FREdit.SetT(pas.SysUtils.IntToStr(v));
        } else {
          this.SetSelectedColor(this.RGBToGraphicsColor(v,this.FGValue,this.FBValue));
          this.FHSColor.$assign(this.RGBToHS(v,this.FGValue,this.FBValue));
          this.SetIndicator();
        };
      };
    };
    this.GFieldKeyDown = function (Sender, Key, Shift) {
      var v = 0;
      if (Key.get() === 13) {
        v = this.FGEdit.GetInt();
        if (v < 0) {
          v = 0}
         else if (v > 255) v = 255;
        if (v === this.FGValue) {
          this.FGEdit.SetT(pas.SysUtils.IntToStr(v));
        } else {
          this.SetSelectedColor(this.RGBToGraphicsColor(this.FRValue,v,this.FBValue));
          this.FHSColor.$assign(this.RGBToHS(this.FRValue,v,this.FBValue));
          this.SetIndicator();
        };
      };
    };
    this.BFieldKeyDown = function (Sender, Key, Shift) {
      var v = 0;
      if (Key.get() === 13) {
        v = this.FBEdit.GetInt();
        if (v < 0) {
          v = 0}
         else if (v > 255) v = 255;
        if (v === this.FBValue) {
          this.FBEdit.SetT(pas.SysUtils.IntToStr(v));
        } else {
          this.SetSelectedColor(this.RGBToGraphicsColor(this.FRValue,this.FGValue,v));
          this.FHSColor.$assign(this.RGBToHS(this.FRValue,this.FGValue,v));
          this.SetIndicator();
        };
      };
    };
    this.HEXFieldKeyDown = function (Sender, Key, Shift) {
      var str = "";
      var r = 0;
      var g = 0;
      var b = 0;
      if ((Key.get() === 13) && (this.FHEXEdit.GetT().length === 6)) {
        str = pas.System.Copy(this.FHEXEdit.GetT(),1,2);
        r = pas.SysUtils.StrToInt("$" + str);
        str = pas.System.Copy(this.FHEXEdit.GetT(),3,2);
        g = pas.SysUtils.StrToInt("$" + str);
        str = pas.System.Copy(this.FHEXEdit.GetT(),5,2);
        b = pas.SysUtils.StrToInt("$" + str);
        this.SetSelectedColor(this.RGBToGraphicsColor(r,g,b));
        this.FHSColor.$assign(this.RGBToHS(r,g,b));
        this.SetIndicator();
      };
    };
    this.DoBeforeDrawSelectedColorPanel = function (AGraphics, ARectF, ASelectedColor, AAllow, ADefaultDraw) {
      if (this.FOnBeforeDrawSelectedColorPanel != null) this.FOnBeforeDrawSelectedColorPanel(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARectF),ASelectedColor,AAllow,ADefaultDraw);
    };
    this.DoAfterDrawSelectedColorPanel = function (AGraphics, ARectF, ASelectedColor) {
      if (this.FOnAfterDrawSelectedColorPanel != null) this.FOnAfterDrawSelectedColorPanel(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARectF),ASelectedColor);
    };
    this.DoSelectedColorChanged = function (ASelectedColor) {
      if (this.FOnSelectedColorChanged != null) this.FOnSelectedColorChanged(this,ASelectedColor);
    };
    this.DoRValueChanged = function (AR, ASelectedColor) {
      if (this.FOnRValueChanged != null) this.FOnRValueChanged(this,AR,ASelectedColor);
    };
    this.DoGValueChanged = function (AG, ASelectedColor) {
      if (this.FOnGValueChanged != null) this.FOnGValueChanged(this,AG,ASelectedColor);
    };
    this.DoBValueChanged = function (AB, ASelectedColor) {
      if (this.FOnBValueChanged != null) this.FOnBValueChanged(this,AB,ASelectedColor);
    };
    this.ColorChanged = function (Sender) {
      this.SetSelectedColor(this.FImage.FPixelColor);
    };
    this.RTrackBarChanged = function (Sender) {
      this.SetRValue(Math.round(this.FRTrackBar.GetV()));
    };
    this.GTrackBarChanged = function (Sender) {
      this.SetGValue(Math.round(this.FGTrackBar.GetV()));
    };
    this.BTrackBarChanged = function (Sender) {
      this.SetBValue(Math.round(this.FBTrackBar.GetV()));
    };
    this.FillColorChanged = function (Sender) {
      this.FillChanged(this);
      this.FImage.FFill.SetColor(this.FColor);
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFill.SetColor(c);
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      this.FFill.SetColor(16777215);
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
      if (this.FImage != null) this.FImage.SetTop(Math.round((this.GetHeight() / 2) - (this.FImage.GetHeight() / 2)));
    };
    this.SetIndicator = function () {
      var angle = 0.0;
      var r = 0.0;
      var cp = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      cp.$assign(this.FImage.GetCenterPoint());
      r = this.FImage.GetRadius() - 0.5;
      angle = pas.Math.DegToRad(this.FHSColor.Hue);
      this.FImage.SetX(cp.X + (r * this.FHSColor.Saturation * Math.cos(angle)));
      this.FImage.SetY(cp.Y + (r * this.FHSColor.Saturation * Math.sin(angle)));
      this.FImage.Invalidate();
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,1,0);
      return Result;
    };
    this.RGBToHS = function (AR, AG, AB) {
      var Result = $mod.TTMSFNCColorWheelHSColor.$new();
      var minRGB = 0.0;
      var maxRGB = 0.0;
      var delta = 0.0;
      var h = 0.0;
      var s = 0.0;
      h = 0.0;
      maxRGB = Math.max(Math.max(AR,AG),AB);
      minRGB = Math.min(Math.min(AR,AG),AB);
      delta = maxRGB - minRGB;
      if (maxRGB === 0) {
        s = 0.0}
       else s = delta / maxRGB;
      if (delta === 0) {
        h = 0.0}
       else if (maxRGB === AR) {
        h = (AG - AB) / delta}
       else if (maxRGB === AG) {
        h = ((AB - AR) / delta) + 2}
       else if (maxRGB === AB) h = ((AR - AG) / delta) + 4;
      h = 60 * h;
      Result.Hue = h;
      Result.Saturation = s;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.SetWidth(350);
      this.SetHeight(175);
      this.FRValue = 255;
      this.FGValue = 255;
      this.FBValue = 255;
      this.FSelectedColor = 16777215;
      this.FFill.FOnChanged = rtl.createCallback(this,"FillColorChanged");
      this.FFont$1 = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FImage = $mod.TTMSFNCImageColor.$create("Create$1",[this]);
      this.FImage.SetParent(this);
      this.FImage.FBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCColorWheelResources"].GetColorWheelResource(),pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FImage.SetTop(Math.round((this.GetHeight() / 2) - (this.FImage.GetHeight() / 2)));
      this.FImage.SetLeft(10);
      this.FImage.FOnColorChanged = rtl.createCallback(this,"ColorChanged");
      this.FImage.SetStretch(true);
      this.FREdit = pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit.$create("Create$1",[this]);
      this.FREdit.SetParent(this);
      this.FREdit.SetWidth(35);
      this.FREdit.SetLeft(this.GetWidth() - this.FREdit.GetWidth() - 15);
      this.FREdit.SetTop(15);
      this.FREdit.SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etNumeric);
      this.FREdit.FOnKeyDown = rtl.createCallback(this,"RFieldKeyDown");
      this.FREdit.SetMaxLength(3);
      this.FREdit.SetT("255");
      this.FGEdit = pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit.$create("Create$1",[this]);
      this.FGEdit.SetParent(this);
      this.FGEdit.SetWidth(35);
      this.FGEdit.SetLeft(this.GetWidth() - this.FGEdit.GetWidth() - 15);
      this.FGEdit.SetTop(45);
      this.FGEdit.SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etNumeric);
      this.FGEdit.FOnKeyDown = rtl.createCallback(this,"GFieldKeyDown");
      this.FGEdit.SetMaxLength(3);
      this.FGEdit.SetT("255");
      this.FBEdit = pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit.$create("Create$1",[this]);
      this.FBEdit.SetParent(this);
      this.FBEdit.SetWidth(35);
      this.FBEdit.SetLeft(this.GetWidth() - this.FBEdit.GetWidth() - 15);
      this.FBEdit.SetTop(75);
      this.FBEdit.SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etNumeric);
      this.FBEdit.FOnKeyDown = rtl.createCallback(this,"BFieldKeyDown");
      this.FBEdit.SetMaxLength(3);
      this.FBEdit.SetT("255");
      this.FHEXEdit = pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit.$create("Create$1",[this]);
      this.FHEXEdit.SetParent(this);
      this.FHEXEdit.SetWidth(125);
      this.FHEXEdit.SetLeft(210);
      this.FHEXEdit.SetTop(105);
      this.FHEXEdit.SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etHex);
      this.FHEXEdit.FOnKeyDown = rtl.createCallback(this,"HEXFieldKeyDown");
      this.FHEXEdit.SetMaxLength(6);
      this.FHEXEdit.SetT("FFFFFF");
      this.FRTrackBar = $mod.TTMSFNCRGBTrackBar.$create("Create$1",[this]);
      this.FRTrackBar.SetParent(this);
      this.FRTrackBar.SetLeft(195);
      this.FRTrackBar.SetTop(this.FREdit.GetTop() - 1);
      this.FRTrackBar.SetValue(255);
      this.FRTrackBar.FOnChange = rtl.createCallback(this,"RTrackBarChanged");
      this.FGTrackBar = $mod.TTMSFNCRGBTrackBar.$create("Create$1",[this]);
      this.FGTrackBar.SetParent(this);
      this.FGTrackBar.SetLeft(195);
      this.FGTrackBar.SetTop(this.FGEdit.GetTop() - 1);
      this.FGTrackBar.SetValue(255);
      this.FGTrackBar.FOnChange = rtl.createCallback(this,"GTrackBarChanged");
      this.FBTrackBar = $mod.TTMSFNCRGBTrackBar.$create("Create$1",[this]);
      this.FBTrackBar.SetParent(this);
      this.FBTrackBar.SetLeft(195);
      this.FBTrackBar.SetTop(this.FBEdit.GetTop() - 1);
      this.FBTrackBar.SetValue(255);
      this.FBTrackBar.FOnChange = rtl.createCallback(this,"BTrackBarChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FImage");
      rtl.free(this,"FREdit");
      rtl.free(this,"FGEdit");
      rtl.free(this,"FBEdit");
      rtl.free(this,"FRTrackBar");
      rtl.free(this,"FGTrackBar");
      rtl.free(this,"FBTrackBar");
      rtl.free(this,"FFont$1");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.ColorToRValue = function (AColor) {
      var Result = 0;
      Result = AColor & 0xFF;
      return Result;
    };
    this.ColorToGValue = function (AColor) {
      var Result = 0;
      Result = Math.floor((AColor & 0xFF00) / 256);
      return Result;
    };
    this.ColorToBValue = function (AColor) {
      var Result = 0;
      Result = Math.floor((AColor & 0xFF0000) / 65536);
      return Result;
    };
    this.RGBToGraphicsColor = function (R, G, B) {
      var Result = 0;
      Result = pas["WEBLib.Graphics"].RGB(R,G,B);
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCColorWheel",this.TTMSFNCCustomColorWheel,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont$1","SetFnt");
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",4,{Default: 16777215});
    $r.addProperty("RValue",2,rtl.longint,"FRValue","SetRValue",4,{Default: 255});
    $r.addProperty("BValue",2,rtl.longint,"FBValue","SetBValue",4,{Default: 255});
    $r.addProperty("GValue",2,rtl.longint,"FGValue","SetGValue",4,{Default: 255});
    $r.addProperty("HEXValue",15,rtl.string,"GetHEXValue","SetHEXValue",4,{stored: "IsHEXValueStored"});
    $r.addProperty("OnBeforeDrawSelectedColorPanel",0,$mod.$rtti["TTMSFNCCustomColorWheelBeforeDrawSelectedColorPanelEvent"],"FOnBeforeDrawSelectedColorPanel","FOnBeforeDrawSelectedColorPanel");
    $r.addProperty("OnAfterDrawSelectedColorPanel",0,$mod.$rtti["TTMSFNCCustomColorWheelAfterDrawSelectedColorPanelEvent"],"FOnAfterDrawSelectedColorPanel","FOnAfterDrawSelectedColorPanel");
    $r.addProperty("OnSelectedColorChanged",0,$mod.$rtti["TTMSFNCCustomColorWheelSelectedColorChangedEvent"],"FOnSelectedColorChanged","FOnSelectedColorChanged");
    $r.addProperty("OnRValueChanged",0,$mod.$rtti["TTMSFNCCustomColorWheelRValueChangedEvent"],"FOnRValueChanged","FOnRValueChanged");
    $r.addProperty("OnGValueChanged",0,$mod.$rtti["TTMSFNCCustomColorWheelGValueChangedEvent"],"FOnGValueChanged","FOnGValueChanged");
    $r.addProperty("OnBValueChanged",0,$mod.$rtti["TTMSFNCCustomColorWheelBValueChangedEvent"],"FOnBValueChanged","FOnBValueChanged");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["Math","SysUtils","WEBLib.TMSFNCColorWheelResources"]);
rtl.module("WEBLib.TMSFNCColorSelector",["System","Classes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCCustomSelector","WEBLib.Controls","WEBLib.TMSFNCTypes","WEBLib.ExtCtrls","WEBLib.TMSFNCGraphicsTypes","WEBLib.StdCtrls","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 1;
  this.TMSFNCColorSelectorColorSetCount = 15;
  this.$rtti.$StaticArray("TMSFNCColorSelectorColorSet$a",{dims: [16], eltype: pas["WEBLib.Graphics"].$rtti["TColor"]});
  this.TMSFNCColorSelectorColorSet = [0,128,32768,32896,8388608,8388736,8421376,12632256,8421504,255,65280,65535,16711680,16711935,16776960,16777215];
  this.TMSFNCColorSelectorExtendedColorSetCount = 39;
  this.$rtti.$StaticArray("TMSFNCColorSelectorExtendedColorSet$a",{dims: [40], eltype: pas["WEBLib.Graphics"].$rtti["TColor"]});
  this.TMSFNCColorSelectorExtendedColorSet = [0,0x993300,0x333300,0x3300,0x3366,8388608,0x333335,0x333333,0x80,0x66FF,0x8080,0x8000,0x808000,0xFF0000,0x996666,0x808080,0xFF,0x99FF,0xCC99,0x669933,0xCCCC33,0xFF6633,0x800080,0x999999,0xFF00FF,0xCCFF,0xFFFF,0xFF00,0xFFFF00,0xFFCC00,0x663399,0xC0C0C0,0xCC99FF,0x99CCFF,0x99FFFF,0xCCFFCC,0xFFFFCC,0xFFCC99,0xFF99CC,0xFFFFFF];
  this.$rtti.$Class("TTMSFNCCustomColorSelector");
  rtl.createClass(this,"TTMSFNCColorSelectorItem",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.$init.call(this);
      this.FOwner$1 = null;
      this.FColor = 0;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.$final.call(this);
    };
    this.SetColor = function (Value) {
      if (this.FColor !== Value) {
        this.FColor = Value;
        if (this.FOwner$1 != null) this.FOwner$1.InvalidateItems();
      };
    };
    this.Create$1 = function (ACollection) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner$1 = rtl.as(this.FCollection,$mod.TTMSFNCColorSelectorItems).FOwner$2;
      return this;
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItem.Assign.apply(this,arguments);
      if ($mod.TTMSFNCColorSelectorItem.isPrototypeOf(Source)) this.FColor = rtl.as(Source,$mod.TTMSFNCColorSelectorItem).FColor;
    };
    var $r = this.$rtti;
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",4,{Default: -1});
  });
  rtl.createClass(this,"TTMSFNCColorSelectorItems",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.$init.call(this);
      this.FOwner$2 = null;
    };
    this.$final = function () {
      this.FOwner$2 = undefined;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.$final.call(this);
    };
    this.GetItem$2 = function (Index) {
      var Result = null;
      Result = this.GetItem$1(Index);
      return Result;
    };
    this.SetItem$2 = function (Index, Value) {
      this.SetItem$1(Index,Value);
    };
    this.CreateItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCColorSelectorItem;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.Create$3.apply(this,arguments);
      this.FOwner$2 = rtl.as(AOwner,$mod.TTMSFNCCustomColorSelector);
      return this;
    };
    this.Add$2 = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.Add$1.call(this);
      return Result;
    };
    this.Insert$2 = function (Index) {
      var Result = null;
      Result = pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelectorItems.Insert$1.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorColorSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorColorDeselected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCCustomSelectorColorClick",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.TTMSFNCCustomColorSelectorMode = {"0": "csmSimple", csmSimple: 0, "1": "csmExtended", csmExtended: 1, "2": "csmExtendedMore", csmExtendedMore: 2};
  this.$rtti.$Enum("TTMSFNCCustomColorSelectorMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCCustomColorSelectorMode});
  rtl.createClass(this,"TTMSFNCCustomColorSelector",pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCDefaultSelector,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCDefaultSelector.$init.call(this);
      this.w = 0.0;
      this.h = 0.0;
      this.FColorWheel = null;
      this.FPanel = null;
      this.FBackButton = null;
      this.FOnColorSelected = null;
      this.FOnColorDeselected = null;
      this.FMode = 0;
    };
    this.$final = function () {
      this.FColorWheel = undefined;
      this.FPanel = undefined;
      this.FBackButton = undefined;
      this.FOnColorSelected = undefined;
      this.FOnColorDeselected = undefined;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCDefaultSelector.$final.call(this);
    };
    this.SetSelectedColor = function (Value) {
      var $tmp = this.FMode;
      if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore) {
        if (this.GetItems().GetCount() > 0) this.GetItems().GetItem$2(this.GetItems().GetCount() - 1).SetColor(Value);
      };
      this.SetSelectedItemIndex(this.FindItemByColor(Value));
    };
    this.GetSelectedColor = function () {
      var Result = 0;
      Result = this.FindColorByItem(this.FSelectedItemIndex);
      return Result;
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FItems;
      return Result;
    };
    this.SetItems$1 = function (Value) {
      this.GetItems().Assign(Value);
    };
    this.SetMode = function (Value) {
      var s = 0.0;
      s = 1;
      if (this.FMode !== Value) {
        this.FMode = Value;
        var $tmp = this.FMode;
        if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmSimple) {
          this.SetWidth(Math.round(s * 135));
          this.SetHeight(Math.round(s * 135));
        } else if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtended) {
          this.SetWidth(Math.round(s * 200));
          this.SetHeight(Math.round(s * 135));
        } else if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore) {
          this.SetWidth(Math.round(s * 200));
          this.SetHeight(Math.round(s * 175));
        };
        this.AddColors();
      };
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,1,0);
      return Result;
    };
    this.BackButtonClicked = function (Sender) {
      if (this.FPanel != null) {
        this.FPanel.SetVisible(false);
        this.FPanel.SetParent(null);
        this.SetWidth(Math.round(this.w));
        this.SetHeight(Math.round(this.h));
        this.WrapperSizeChanged(this.w,this.h);
        this.Invalidate();
      };
    };
    this.ColorWheelChange = function (Sender, AColor) {
      if (this.FBlockChange) return;
      this.FBlockChange = true;
      this.NotifyDataBinderEdit();
      this.SetSelectedItemIndex(-1);
      this.NotifyDataBinderValueChanged();
      this.GetItems().GetItem$2(this.GetItems().GetCount() - 1).SetColor($impl.AsColorWheel(this.FColorWheel).FSelectedColor);
      this.SetSelectedColor($impl.AsColorWheel(this.FColorWheel).FSelectedColor);
      this.DoItemSelected(this.FSelectedItemIndex);
      this.Invalidate();
      this.FBlockChange = false;
    };
    this.DoItemClick = function (AItemIndex) {
      var l = 0.0;
      var t = 0.0;
      var r = 0.0;
      var b = 0.0;
      var nw = 0.0;
      var nh = 0.0;
      if (this.FClosedRemotely) {
        this.FClosedRemotely = false;
        pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemClick.apply(this,arguments);
        return;
      };
      if ((this.FMode === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore) && (this.FPanel != null) && (AItemIndex === (this.GetItems().GetCount() - 2))) {
        this.w = this.GetWidth();
        this.h = this.GetHeight();
        l = 0;
        t = 0;
        r = 0;
        b = 0;
        this.FColorWheel.GetControlMargins({get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }},{get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }},{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        nh = this.ScalePaintValue(205) + this.FBackButton.GetHeight() + t + b;
        this.SetHeight(Math.round(nh));
        nw = this.ScalePaintValue(350);
        this.SetWidth(Math.round(nw));
        this.WrapperSizeChanged(nw,nh);
        this.FBlockChange = true;
        $impl.AsColorWheel(this.FColorWheel).SetSelectedColor(this.FindColorByItem(AItemIndex + 1));
        this.FBlockChange = false;
        this.FPanel.SetVisible(true);
        this.FPanel.SetParent(this);
      };
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemClick.apply(this,arguments);
    };
    this.WrapperSizeChanged = function (AWidth, AHeight) {
    };
    this.DoItemSelected = function (AItemIndex) {
      var c = 0;
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemSelected.apply(this,arguments);
      c = this.FindColorByItem(AItemIndex);
      if ((this.FColorWheel != null) && !this.FBlockChange) {
        this.FBlockChange = true;
        $impl.AsColorWheel(this.FColorWheel).SetSelectedColor(c);
        if ((this.FMode === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore) && (this.GetItems().GetCount() > 0)) this.GetItems().GetItem$2(this.GetItems().GetCount() - 1).SetColor(c);
        this.FBlockChange = false;
      };
      if (this.FOnColorSelected != null) this.FOnColorSelected(this,c);
    };
    this.DoItemDeselected = function (AItemIndex) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemDeselected.apply(this,arguments);
      if (this.FOnColorDeselected != null) this.FOnColorDeselected(this,this.FindColorByItem(AItemIndex));
    };
    this.CreateItemsCollection = function () {
      var Result = null;
      Result = $mod.TTMSFNCColorSelectorItems.$create("Create$3",[this]);
      return Result;
    };
    this.DoItemBeforeDrawContent = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FMode === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore) {
        if ((AItemIndex >= 0) && (AItemIndex <= (this.GetItems().GetCount() - 1))) ADefaultDraw.set(!this.GetItems().GetItem$2(AItemIndex).FDataBoolean);
      };
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.DoItemBeforeDrawContent.apply(this,arguments);
    };
    this.DrawItemContent = function (AGraphics, ADisplayItem) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var it = null;
      var a = false;
      it = ADisplayItem.Item;
      if ((it != null) && $mod.TTMSFNCColorSelectorItem.isPrototypeOf(it)) {
        r.$assign(ADisplayItem.Rect);
        a = true;
        this.DoItemBeforeDrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex(),{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) {
          var $tmp = this.FMode;
          if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmSimple) {
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-5,-5)}
           else if (($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtended) || ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore)) pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-3,-3);
          AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
          AGraphics.FFill.SetColor(rtl.as(it,$mod.TTMSFNCColorSelectorItem).FColor);
          AGraphics.FStroke.SetColor(AGraphics.FFill.FColor);
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          this.DoItemAfterDrawContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex());
        };
      };
    };
    this.AddColors = function () {
      var I = 0;
      var it = null;
      this.BeginUpdate();
      this.GetItems().Clear();
      var $tmp = this.FMode;
      if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmSimple) {
        this.SetColumns(4);
        this.SetRows(4);
        for (I = 0; I <= 15; I++) this.GetItems().Add$2().SetColor($mod.TMSFNCColorSelectorColorSet[I]);
      } else if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtended) {
        this.SetColumns(8);
        this.SetRows(5);
        for (I = 0; I <= 39; I++) this.GetItems().Add$2().SetColor($mod.TMSFNCColorSelectorExtendedColorSet[I]);
      } else if ($tmp === $mod.TTMSFNCCustomColorSelectorMode.csmExtendedMore) {
        this.SetColumns(8);
        this.SetRows(7);
        for (I = 0; I <= 39; I++) this.GetItems().Add$2().SetColor($mod.TMSFNCColorSelectorExtendedColorSet[I]);
        it = this.GetItems().Insert$2(0);
        it.SetColor(0);
        it.SetColumnSpan(8);
        it.SetText("Automatic");
        it.FDataBoolean = true;
        it = this.GetItems().Add$2();
        it.SetColumnSpan(8);
        it.SetText("More Colors...");
        it.SetCanSelect(false);
        it.FDataBoolean = true;
        this.GetItems().Add$2().SetVisible(false);
      };
      this.EndUpdate();
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.ResetToDefaultStyle.call(this);
      this.BeginUpdate();
      this.FAppearance.FFont.SetColor(0x454545);
      this.FAppearance.FFill.SetColor(0xF9F2EE);
      this.FAppearance.FFillSelected.SetColor(0xF0BCA8);
      this.FAppearance.FStrokeSelected.SetColor(0xEF9B2D);
      this.FAppearance.FFillDown.SetColor(0xE6815A);
      this.FAppearance.FFillSelected.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFillDown.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFillHover.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStrokeSelected.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStrokeHover.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FStroke.SetColor(11119017);
      this.FAppearance.FStrokeHover.SetColor(this.FAppearance.FFillDown.FColor);
      this.FAppearance.FStrokeDown.Assign(this.FAppearance.FStroke);
      this.EndUpdate();
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.Create$1.apply(this,arguments);
      this.SetWidth(135);
      this.SetHeight(135);
      this.FMode = $mod.TTMSFNCCustomColorSelectorMode.csmSimple;
      this.FPanel = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$create("Create$1",[this]);
      this.FPanel.SetVisible(false);
      this.FPanel.FStored = false;
      this.FPanel.SetControlAlignment(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient);
      this.FBackButton = pas["WEBLib.StdCtrls"].TButton.$create("Create$1",[this.FPanel]);
      this.FBackButton.SetAlignWithMargins(true);
      this.FBackButton.FMargins.SetTop(3);
      this.FBackButton.FMargins.SetLeft(3);
      this.FBackButton.FMargins.SetBottom(3);
      this.FBackButton.FMargins.SetRight(3);
      this.FBackButton.SetCaption("Back");
      this.FBackButton.SetAlign(pas["WEBLib.Controls"].TAlign.alTop);
      this.FBackButton.SetParent(this.FPanel);
      this.FBackButton.FOnClick = rtl.createCallback(this,"BackButtonClicked");
      this.FColorWheel = pas["WEBLib.TMSFNCColorWheel"].TTMSFNCColorWheel.$create("Create$1",[this.FPanel]);
      $impl.AsColorWheel(this.FColorWheel).SetControlAlignment(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient);
      $impl.AsColorWheel(this.FColorWheel).SetControlMargins(3,0,3,3);
      $impl.AsColorWheel(this.FColorWheel).SetParent(this.FPanel);
      $impl.AsColorWheel(this.FColorWheel).FOnSelectedColorChanged = rtl.createCallback(this,"ColorWheelChange");
      if (this.IsDesignTime()) this.InitSample();
      return this;
    };
    this.FindItemByColor = function (AColor) {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = -1;
      for (var $l = 0, $end = this.GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = rtl.as(this.GetItems().GetItem$2(I),$mod.TTMSFNCColorSelectorItem);
        if ((it.FColor === AColor) && it.FCanSelect) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.FindColorByItem = function (AItem) {
      var Result = 0;
      var I = 0;
      var it = null;
      Result = -1;
      for (var $l = 0, $end = this.GetItems().GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        it = rtl.as(this.GetItems().GetItem$2(I),$mod.TTMSFNCColorSelectorItem);
        if (it.GetIndex() === AItem) {
          Result = it.FColor;
          break;
        };
      };
      return Result;
    };
    this.ColorWheelActive = function () {
      var Result = false;
      Result = (this.FPanel != null) && (this.FPanel.FParent != null) && this.FPanel.FVisible && (this.FColorWheel != null) && (this.FColorWheel.FParent != null) && this.FColorWheel.FVisible;
      return Result;
    };
    this.InitializeDefault = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.InitializeDefault.call(this);
      this.AddColors();
    };
    this.InitSample = function () {
      this.ResetToDefaultStyle();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCColorSelector",this.TTMSFNCCustomColorSelector,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomSelector"].TTMSFNCCustomSelector.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClasses([$mod.TTMSFNCColorSelector,$mod.TTMSFNCColorSelectorItem]);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",2,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("Rows",2,rtl.longint,"FRows","SetRows",4,{Default: 4});
    $r.addProperty("Columns",2,rtl.longint,"FColumns","SetColumns",4,{Default: 4});
    $r.addProperty("Items",3,$mod.$rtti["TTMSFNCColorSelectorItems"],"GetItems","SetItems$1");
    $r.addProperty("Mode",2,$mod.$rtti["TTMSFNCCustomColorSelectorMode"],"FMode","SetMode",4,{Default: $mod.TTMSFNCCustomColorSelectorMode.csmSimple});
    $r.addProperty("OnColorSelected",0,$mod.$rtti["TTMSFNCCustomSelectorColorSelected"],"FOnColorSelected","FOnColorSelected");
    $r.addProperty("OnColorDeselected",0,$mod.$rtti["TTMSFNCCustomSelectorColorDeselected"],"FOnColorDeselected","FOnColorDeselected");
    $r.addProperty("SelectedColor",3,pas["WEBLib.Graphics"].$rtti["TColor"],"GetSelectedColor","SetSelectedColor",4,{Default: -1});
    $r.addProperty("OnItemSelected",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemSelected"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("OnItemDeselected",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemDeselected"],"FOnItemDeselected","FOnItemDeselected");
    $r.addProperty("OnItemClick",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemClick"],"FOnItemClick","FOnItemClick");
    $r.addProperty("SelectedItemIndex",2,rtl.longint,"FSelectedItemIndex","SetSelectedItemIndex",4,{Default: -1});
    $r.addProperty("OnItemBeforeDrawBackground",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawBackground"],"FOnItemBeforeDrawBackground","FOnItemBeforeDrawBackground");
    $r.addProperty("OnItemAfterDrawBackground",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawBackground"],"FOnItemAfterDrawBackground","FOnItemAfterDrawBackground");
    $r.addProperty("OnItemBeforeDrawContent",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawContent"],"FOnItemBeforeDrawContent","FOnItemBeforeDrawContent");
    $r.addProperty("OnItemAfterDrawContent",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawContent"],"FOnItemAfterDrawContent","FOnItemAfterDrawContent");
    $r.addProperty("OnBeforeDraw",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorBeforeDraw"],"FOnBeforeDraw$1","FOnBeforeDraw$1");
    $r.addProperty("OnAfterDraw",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorAfterDraw"],"FOnAfterDraw$1","FOnAfterDraw$1");
    $r.addProperty("OnItemBeforeDrawText",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawText"],"FOnItemBeforeDrawText","FOnItemBeforeDrawText");
    $r.addProperty("OnItemAfterDrawText",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawText"],"FOnItemAfterDrawText","FOnItemAfterDrawText");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    $impl.AsColorWheel = function (AColorWheel) {
      var Result = null;
      Result = rtl.as(AColorWheel,pas["WEBLib.TMSFNCColorWheel"].TTMSFNCColorWheel);
      return Result;
    };
  };
},["SysUtils","WEBLib.TMSFNCUtils","WEBLib.TMSFNCColorWheel"]);
rtl.module("WEBLib.TMSFNCToolBarRes",["System"],function () {
  "use strict";
  var $mod = this;
  this.TMSFNCTOOLBAREXPAND = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOvwAADr8B" + "OAVTJAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4zjOaXUAAAACVJREFUGFdj+P//P07MEBYW9h8Xxi8J" + "AjglYACnBAzglMAEDAwARZ1DA4NRF38AAAAASUVORK5CYII=";
  this.TMSFNCTOOLBAREXPANDLARGE = this.TMSFNCTOOLBAREXPAND;
  this.TMSFNCTOOLBAREXPAND2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOvgAADr4" + "B6kKxwAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xNkRpr/UAAAA3SURBVBhXY3j69KktLgyS/I8LE5RsQxeE4jaQpCKIgSQIlgBi" + "RQYQADGgAqgSMABVkI2QYGAAANnukE/t/B6ZAAAAAElFTkSuQmCC";
  this.TMSFNCTOOLBAREXPAND2LARGE = this.TMSFNCTOOLBAREXPAND;
  this.TMSFNCTOOLBAROPTIONSMENU = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAJCAYAAAD+WDajAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOvwA" + "ADr8BOAVTJAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4zjOaXUAAAACpJREFUKFNjwAvCwsL+48IM///jxvh1YhOEYZz2giVg" + "AKcEDOCUwAQMDAAqj1EKDJG5XAAAAABJRU5ErkJggg==";
  this.TMSFNCTOOLBAROPTIONSMENULARGE = this.TMSFNCTOOLBAROPTIONSMENU;
  this.TMSFNCTOOLBARQUICKMENU = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADs" + "IBFShKgAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xNkRpr/UAAAAlSURBVBhXYwCC/9gwEAApKAMbJl4SnY0igCQIw3gkcUowMP" + "wHALBNZJw15C+yAAAAAElFTkSuQmCC";
  this.TMSFNCTOOLBARQUICKMENU2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAA" + "AAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAAL0lEQVQYV2P4jxswwCRBNAYGESCA" + "IQHCIAIEYAIgAGejC8D4YEBQEqvE/////wMA7H6pV7j5gXMAAAAASUVORK5CYII=";
  $mod.$init = function () {
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCTOOLBAREXPAND);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCTOOLBAREXPAND2);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCTOOLBAROPTIONSMENU);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCTOOLBARQUICKMENU);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCTOOLBARQUICKMENU2);
  };
},["WEBLib.TMSFNCTypes"]);
rtl.module("WEBLib.TMSFNCToolBar",["System","Classes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCListBox","WEBLib.TMSFNCStyles","WEBLib.TMSFNCCustomControl","WEBLib.Controls","Types","WEBLib.TMSFNCBitmapSelector","WEBLib.TMSFNCPopup","WEBLib.TMSFNCTypes","WEBLib.TMSFNCBitmapContainer","WEBLib.StdCtrls","WEBLib.TMSFNCColorSelector","WEBLib.TMSFNCToolBarRes","WEBLib.TMSFNCGraphicsTypes","contnrs","WEBLib.Menus","WEBLib.ExtCtrls"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 2;
  this.BLD_VER = 6;
  this.TMSFNCTOOLBAREXPANDSVG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdo" + "dD0iMTIiIHdpZHRoPSIxMCI+DQogIDxwYXRoIGQ9Ik0gMiA0IEwgNSA3IEwgOCA0IFoiIHN0eWxlPSJzdHJva2U6YmxhY2s7" + "c3Ryb2tlLXdpZHRoOjEiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgLz4NCjwvc3ZnPg==";
  this.$rtti.$Class("TTMSFNCCustomToolBar");
  this.$rtti.$Class("TTMSFNCCustomDockPanel");
  this.$rtti.$Class("TTMSFNCCustomToolBarSeparator");
  this.$rtti.$Class("TTMSFNCDefaultToolBarButton");
  this.$rtti.$Class("TTMSFNCToolBarButton");
  this.$rtti.$Class("TTMSFNCToolBarDropDownButton");
  rtl.createClass(this,"TTMSFNCToolBarCustomButtonAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FHoverStroke = null;
      this.FDownFill = null;
      this.FNormalFill = null;
      this.FDownStroke = null;
      this.FDisabledFill = null;
      this.FNormalStroke = null;
      this.FDisabledStroke = null;
      this.FHoverFill = null;
      this.FCorners = {};
      this.FRounding = 0.0;
      this.FTransparent = false;
      this.FShowInnerStroke = false;
      this.FInnerStroke = null;
      this.FFlatStyle = false;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FHoverStroke = undefined;
      this.FDownFill = undefined;
      this.FNormalFill = undefined;
      this.FDownStroke = undefined;
      this.FDisabledFill = undefined;
      this.FNormalStroke = undefined;
      this.FDisabledStroke = undefined;
      this.FHoverFill = undefined;
      this.FCorners = undefined;
      this.FInnerStroke = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetDisabledFill = function (Value) {
      this.FDisabledFill.Assign(Value);
    };
    this.SetDisabledStroke = function (Value) {
      this.FDisabledStroke.Assign(Value);
    };
    this.SetDownFill = function (Value) {
      this.FDownFill.Assign(Value);
    };
    this.SetDownStroke = function (Value) {
      this.FDownStroke.Assign(Value);
    };
    this.SetHoverFill = function (Value) {
      this.FHoverFill.Assign(Value);
    };
    this.SetHoverStroke = function (Value) {
      this.FHoverStroke.Assign(Value);
    };
    this.SetNormalFill = function (Value) {
      this.FNormalFill.Assign(Value);
    };
    this.SetNormalStroke = function (Value) {
      this.FNormalStroke.Assign(Value);
    };
    this.SetCorners = function (Value) {
      if (rtl.neSet(this.FCorners,Value)) {
        this.FCorners = rtl.refSet(Value);
        this.Changed();
      };
    };
    this.SetRounding = function (Value) {
      if (this.FRounding !== Value) {
        this.FRounding = Value;
        this.Changed();
      };
    };
    this.SetInnerStroke = function (Value) {
      this.FInnerStroke.Assign(Value);
    };
    this.SetShowInnerStroke = function (Value) {
      if (this.FShowInnerStroke !== Value) {
        this.FShowInnerStroke = Value;
        this.Changed();
      };
    };
    this.SetTransparent = function (Value) {
      if (this.FTransparent !== Value) {
        this.FTransparent = Value;
        this.Changed();
      };
    };
    this.IsRoundingStored = function () {
      var Result = false;
      Result = this.FRounding !== 3;
      return Result;
    };
    this.SetFlatStyle = function (Value) {
      var c = null;
      var I = 0;
      if (this.FFlatStyle !== Value) {
        this.FFlatStyle = Value;
        if (this.FOwner != null) {
          for (var $l = 0, $end = this.FOwner.GetControlsCount() - 1; $l <= $end; $l++) {
            I = $l;
            c = this.FOwner.GetControls(I);
            if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FAppearance.SetFlatStyle(this.FFlatStyle);
            if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCCustomToolBar).FAppearance.SetFlatStyle(this.FFlatStyle);
          };
        };
        this.Changed();
      };
    };
    this.FillChanged = function (Sender) {
      this.Changed();
    };
    this.StrokeChanged = function (Sender) {
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOwner != null) {
        this.FOwner.AppearanceChanged()}
       else if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCToolBarCustomButtonAppearance.isPrototypeOf(Source)) {
        this.FNormalFill.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FNormalFill);
        this.FDisabledFill.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FDisabledFill);
        this.FHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FHoverFill);
        this.FDownFill.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FDownFill);
        this.FNormalStroke.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FNormalStroke);
        this.FDisabledStroke.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FDisabledStroke);
        this.FHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FHoverStroke);
        this.FDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FDownStroke);
        this.FRounding = rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FRounding;
        this.FCorners = rtl.refSet(rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FCorners);
        this.FShowInnerStroke = rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FShowInnerStroke;
        this.FTransparent = rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FTransparent;
        this.FFlatStyle = rtl.as(Source,$mod.TTMSFNCToolBarCustomButtonAppearance).FFlatStyle;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FCorners = rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight);
      this.FRounding = 3;
      this.FTransparent = false;
      this.FShowInnerStroke = true;
      this.FFlatStyle = false;
      this.FNormalFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(249,251,252),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(230,235,235),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(220,220,236),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(220,225,236)]);
      this.FHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,231,232),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(210,215,215),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(200,200,216),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(200,205,216)]);
      this.FDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(219,221,222),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(200,205,205),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(190,190,206),pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(190,195,206)]);
      this.FDisabledFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,13882323,8421504,-1,-1]);
      this.FNormalStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FInnerStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,16777215,1.0]);
      this.FHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FDisabledStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FNormalFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FDisabledFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FInnerStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FNormalStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FHoverStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FDownStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FDisabledStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FNormalFill");
      rtl.free(this,"FHoverFill");
      rtl.free(this,"FDownFill");
      rtl.free(this,"FDisabledFill");
      rtl.free(this,"FInnerStroke");
      rtl.free(this,"FNormalStroke");
      rtl.free(this,"FHoverStroke");
      rtl.free(this,"FDownStroke");
      rtl.free(this,"FDisabledStroke");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCToolBarButtonAppearance",this.TTMSFNCToolBarCustomButtonAppearance,function () {
    var $r = this.$rtti;
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",4,{Default: false});
    $r.addProperty("ShowInnerStroke",2,rtl.boolean,"FShowInnerStroke","SetShowInnerStroke",4,{Default: true});
    $r.addProperty("Rounding",14,rtl.double,"FRounding","SetRounding",4,{stored: "IsRoundingStored"});
    $r.addProperty("Corners",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsCorners"],"FCorners","SetCorners",4,{Default: rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight)});
    $r.addProperty("InnerStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FInnerStroke","SetInnerStroke");
    $r.addProperty("NormalFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FNormalFill","SetNormalFill");
    $r.addProperty("NormalStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FNormalStroke","SetNormalStroke");
    $r.addProperty("HoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FHoverFill","SetHoverFill");
    $r.addProperty("HoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FHoverStroke","SetHoverStroke");
    $r.addProperty("DownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDownFill","SetDownFill");
    $r.addProperty("DownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDownStroke","SetDownStroke");
    $r.addProperty("DisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDisabledFill","SetDisabledFill");
    $r.addProperty("DisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDisabledStroke","SetDisabledStroke");
    $r.addProperty("FlatStyle",2,rtl.boolean,"FFlatStyle","SetFlatStyle",4,{Default: false});
  });
  rtl.createClass(this,"TTMSFNCToolBarCompactAppearance",this.TTMSFNCToolBarCustomButtonAppearance,function () {
    var $r = this.$rtti;
    $r.addProperty("NormalFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FNormalFill","SetNormalFill");
    $r.addProperty("NormalStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FNormalStroke","SetNormalStroke");
    $r.addProperty("HoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FHoverFill","SetHoverFill");
    $r.addProperty("HoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FHoverStroke","SetHoverStroke");
    $r.addProperty("DownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDownFill","SetDownFill");
    $r.addProperty("DownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDownStroke","SetDownStroke");
    $r.addProperty("DisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDisabledFill","SetDisabledFill");
    $r.addProperty("DisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDisabledStroke","SetDisabledStroke");
    $r.addProperty("FlatStyle",2,rtl.boolean,"FFlatStyle","SetFlatStyle",4,{Default: false});
  });
  rtl.createClass(this,"TTMSFNCToolBarQuickMenuButtonAppearance",this.TTMSFNCToolBarCustomButtonAppearance,function () {
    var $r = this.$rtti;
    $r.addProperty("NormalFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FNormalFill","SetNormalFill");
    $r.addProperty("NormalStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FNormalStroke","SetNormalStroke");
    $r.addProperty("HoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FHoverFill","SetHoverFill");
    $r.addProperty("HoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FHoverStroke","SetHoverStroke");
    $r.addProperty("DownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDownFill","SetDownFill");
    $r.addProperty("DownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDownStroke","SetDownStroke");
    $r.addProperty("DisabledFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDisabledFill","SetDisabledFill");
    $r.addProperty("DisabledStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDisabledStroke","SetDisabledStroke");
    $r.addProperty("FlatStyle",2,rtl.boolean,"FFlatStyle","SetFlatStyle",4,{Default: false});
  });
  this.TTMSFNCToolBarElementState = {"0": "esNormal", esNormal: 0, "1": "esLarge", esLarge: 1};
  this.$rtti.$Enum("TTMSFNCToolBarElementState",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCToolBarElementState});
  rtl.createClass(this,"TTMSFNCCustomToolBarElement",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FBlockUpdate = false;
      this.FOnUpdateToolBar = null;
      this.FOnUpdateToolBarControl = null;
      this.FCanCopy = false;
      this.FState = 0;
      this.FLastElement = false;
      this.FControlIndex = 0;
    };
    this.$final = function () {
      this.FOnUpdateToolBar = undefined;
      this.FOnUpdateToolBarControl = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetState = function (Value) {
      if (this.FState !== Value) {
        this.FState = Value;
        this.UpdateState();
      };
    };
    this.SetLastElement = function (Value) {
      if (this.FLastElement !== Value) {
        this.FLastElement = Value;
        this.UpdateToolBar();
      };
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/ttmsfnctoolbar";
      return Result;
    };
    this.UpdateState = function () {
    };
    this.UpdateToolBar = function () {
      if ((this.FOnUpdateToolBar != null) && !this.FBlockUpdate) this.FOnUpdateToolBar(this);
    };
    this.UpdateToolBarControl = function () {
      if (this.FOnUpdateToolBarControl != null) this.FOnUpdateToolBarControl(this);
    };
    this.VisibleChanging = function () {
      pas["WEBLib.Controls"].TControl.VisibleChanging.call(this);
      this.UpdateToolBar();
    };
    this.DefineProperties = function (Filer) {
      pas.Classes.TComponent.DefineProperties.apply(this,arguments);
      Filer.DefineProperty("ControlIndex",rtl.createCallback(this,"ReadControlIndex"),rtl.createCallback(this,"WriteControlIndex"),true);
    };
    this.ReadControlIndex = function (Reader) {
      this.FControlIndex = Reader.ReadInteger();
    };
    this.WriteControlIndex = function (Writer) {
      Writer.WriteInteger(this.FControlIndex);
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
      this.UpdateToolBar();
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(Source)) {
        this.FState = rtl.as(Source,$mod.TTMSFNCCustomToolBarElement).FState;
        this.FLastElement = rtl.as(Source,$mod.TTMSFNCCustomToolBarElement).FLastElement;
        this.FCanCopy = rtl.as(Source,$mod.TTMSFNCCustomToolBarElement).FCanCopy;
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.DisableBackground();
      this.FLastElement = false;
      this.FCanCopy = true;
      this.FState = $mod.TTMSFNCToolBarElementState.esNormal;
      return this;
    };
    this.Destroy = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TTMSFNCToolBarButtonBitmapPosition = {"0": "bbpLeft", bbpLeft: 0, "1": "bbpTop", bbpTop: 1};
  this.$rtti.$Enum("TTMSFNCToolBarButtonBitmapPosition",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCToolBarButtonBitmapPosition});
  this.TTMSFNCToolBarButtonLayout = {"0": "bblNone", bblNone: 0, "1": "bblBitmap", bblBitmap: 1, "2": "bblLabel", bblLabel: 2, "3": "bblLarge", bblLarge: 3};
  this.$rtti.$Enum("TTMSFNCToolBarButtonLayout",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCToolBarButtonLayout});
  rtl.createClass(this,"TTMSFNCDefaultToolBarButton",this.TTMSFNCCustomToolBarElement,function () {
    this.$init = function () {
      $mod.TTMSFNCCustomToolBarElement.$init.call(this);
      this.FOldHeight = 0.0;
      this.FBitmapVisible = false;
      this.FText = "";
      this.FPopup = null;
      this.FPopupPlacement = 0;
      this.FDropDownHeight = 0.0;
      this.FDropDownWidth = 0.0;
      this.FDown = false;
      this.FHover = false;
      this.FPrevHover = false;
      this.FAppearance = null;
      this.FBitmapContainer = null;
      this.FBitmaps = null;
      this.FApplyName = false;
      this.FDropDownControl = null;
      this.FFont$1 = null;
      this.FOnBeforeDropDown = null;
      this.FCloseOnSelection = false;
      this.FDownState = false;
      this.FTextVisible = false;
      this.FOnCloseDropDown = null;
      this.FOnDropDown = null;
      this.FVerticalTextAlign = 0;
      this.FHorizontalTextAlign = 0;
      this.FWordWrapping = false;
      this.FTrimming = 0;
      this.FBitmapSize = 0.0;
      this.FStretchText = false;
      this.FDisabledBitmaps = null;
      this.FHoverBitmaps = null;
      this.FShowFocus$1 = false;
      this.FDropDownAutoWidth = false;
      this.FHoverFontColor = 0;
      this.FDownFontColor = 0;
      this.FDisabledFontColor = 0;
      this.FStretchBitmapIfNoText = false;
      this.FBitmapPosition = 0;
      this.FMaximumLayout = 0;
      this.FMinimumLayout = 0;
      this.FLayout = 0;
      this.FCompactLayout = 0;
      this.FLargeLayoutBitmapSize = 0.0;
      this.FLargeLayoutBitmaps = null;
      this.FLargeLayoutHoverBitmaps = null;
      this.FLargeLayoutDisabledBitmaps = null;
      this.FAutoBitmapSize = false;
      this.FLargeLayoutAutoBitmapSize = false;
      this.FUseStyledDropDownIcon = false;
    };
    this.$final = function () {
      this.FPopup = undefined;
      this.FAppearance = undefined;
      this.FBitmapContainer = undefined;
      this.FBitmaps = undefined;
      this.FDropDownControl = undefined;
      this.FFont$1 = undefined;
      this.FOnBeforeDropDown = undefined;
      this.FOnCloseDropDown = undefined;
      this.FOnDropDown = undefined;
      this.FDisabledBitmaps = undefined;
      this.FHoverBitmaps = undefined;
      this.FLargeLayoutBitmaps = undefined;
      this.FLargeLayoutHoverBitmaps = undefined;
      this.FLargeLayoutDisabledBitmaps = undefined;
      $mod.TTMSFNCCustomToolBarElement.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
      this.UpdateLayout();
      this.Invalidate();
    };
    this.SetBitmaps = function (Value) {
      this.FBitmaps.Assign(Value);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.FTextVisible = Value !== "";
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetDropDownHeight = function (Value) {
      this.FDropDownHeight = Value;
      if ((this.FPopup != null) && !this.FDropDownAutoWidth) this.FPopup.SetDropDownHeight(this.FDropDownHeight);
    };
    this.SetDropDownWidth = function (Value) {
      this.FDropDownWidth = Value;
      if (this.FPopup != null) this.FPopup.SetDropDownWidth(this.FDropDownWidth);
    };
    this.SetBitmapVisible = function (Value) {
      this.FBitmapVisible = Value;
      this.UpdateLayout();
      this.Invalidate();
    };
    this.SetTextVisible = function (Value) {
      if (this.FTextVisible !== Value) {
        this.FTextVisible = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetFont$1 = function (Value) {
      this.FFont$1.Assign(Value);
    };
    this.SetDropDownControl = function (Value) {
      this.FDropDownControl = Value;
      if (this.FDropDownControl != null) {
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          if (this.FPopup != null) {
            this.FPopup.SetContentControl(this.FDropDownControl);
            this.FPopup.FFocusedControl = this.FDropDownControl;
          };
        } else if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
          this.SetDropDownHeight(this.FDropDownControl.GetHeight());
          this.SetDropDownWidth(this.FDropDownControl.GetWidth());
        };
      };
    };
    this.SetCloseOnSelection = function (Value) {
      if (this.FCloseOnSelection !== Value) {
        this.FCloseOnSelection = Value;
      };
    };
    this.SetDownState = function (Value) {
      this.FDownState = Value;
      this.Invalidate();
    };
    this.IsDropDownHeightStored = function () {
      var Result = false;
      Result = this.FDropDownHeight !== 135;
      return Result;
    };
    this.IsDropDownWidthStored = function () {
      var Result = false;
      Result = this.FDropDownWidth !== 135;
      return Result;
    };
    this.SetHorizontalTextAlign = function (Value) {
      if (this.FHorizontalTextAlign !== Value) {
        this.FHorizontalTextAlign = Value;
        this.Invalidate();
      };
    };
    this.SetVerticalTextAlign = function (Value) {
      if (this.FVerticalTextAlign !== Value) {
        this.FVerticalTextAlign = Value;
        this.Invalidate();
      };
    };
    this.SetWordWrapping = function (Value) {
      if (this.FWordWrapping !== Value) {
        this.FWordWrapping = Value;
        this.Invalidate();
      };
    };
    this.SetTrimming = function (Value) {
      if (this.FTrimming !== Value) {
        this.FTrimming = Value;
        this.Invalidate();
      };
    };
    this.IsBitmapSizeStored = function () {
      var Result = false;
      Result = this.FBitmapSize !== 24;
      return Result;
    };
    this.SetBitmapSize = function (Value) {
      if (this.FBitmapSize !== Value) {
        this.FBitmapSize = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetStretchText = function (Value) {
      if (this.FStretchText !== Value) {
        this.FStretchText = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetDisabledBitmaps = function (Value) {
      this.FDisabledBitmaps.Assign(Value);
    };
    this.SetHoverBitmaps = function (Value) {
      this.FHoverBitmaps.Assign(Value);
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetShowFocus$1 = function (Value) {
      if (this.FShowFocus$1 !== Value) {
        this.FShowFocus$1 = Value;
        this.Invalidate();
      };
    };
    this.SetDropDownAutoWidth = function (Value) {
      if (this.FDropDownAutoWidth !== Value) {
        this.FDropDownAutoWidth = Value;
        if (this.FPopup != null) {
          if (this.FDropDownAutoWidth) {
            this.FPopup.SetDropDownWidth(this.GetWidth())}
           else this.FPopup.SetDropDownWidth(this.FDropDownWidth);
        };
      };
    };
    this.SetDisabledFontColor = function (Value) {
      if (this.FDisabledFontColor !== Value) {
        this.FDisabledFontColor = Value;
        this.Invalidate();
      };
    };
    this.SetDownFontColor = function (Value) {
      if (this.FDownFontColor !== Value) {
        this.FDownFontColor = Value;
        this.Invalidate();
      };
    };
    this.SetHoverFontColor = function (Value) {
      if (this.FHoverFontColor !== Value) {
        this.FHoverFontColor = Value;
        this.Invalidate();
      };
    };
    this.SetStretchBitmapIfNoText = function (Value) {
      if (this.FStretchBitmapIfNoText !== Value) {
        this.FStretchBitmapIfNoText = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetBitmapPosition = function (Value) {
      if (this.FBitmapPosition !== Value) {
        this.FBitmapPosition = Value;
        this.Invalidate();
      };
    };
    this.SetMaximumLayout = function (Value) {
      if (this.FMaximumLayout !== Value) {
        this.FMaximumLayout = Value;
        this.UpdateToolBar();
      };
    };
    this.SetMinimumLayout = function (Value) {
      if (this.FMinimumLayout !== Value) {
        this.FMinimumLayout = Value;
        this.UpdateToolBar();
      };
    };
    this.SetLayout = function (Value) {
      if (this.FLayout !== Value) {
        this.FLayout = Value;
        this.UpdateLayout();
      };
    };
    this.SetCompactLayout = function (Value) {
      if (this.FCompactLayout !== Value) this.FCompactLayout = Value;
    };
    this.IsLargeLayoutBitmapSizeStored = function () {
      var Result = false;
      Result = this.FLargeLayoutBitmapSize !== 32;
      return Result;
    };
    this.SetLargeLayoutBitmaps = function (Value) {
      this.FLargeLayoutBitmaps.Assign(Value);
    };
    this.SetLargeLayoutBitmapSize = function (Value) {
      if (this.FLargeLayoutBitmapSize !== Value) {
        this.FLargeLayoutBitmapSize = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetLargeLayoutDisabledBitmaps = function (Value) {
      this.FLargeLayoutDisabledBitmaps.Assign(Value);
    };
    this.SetLargeLayoutHoverBitmaps = function (Value) {
      this.FLargeLayoutHoverBitmaps.Assign(Value);
    };
    this.SetAutoBitmapSize = function (Value) {
      if (this.FAutoBitmapSize !== Value) {
        this.FAutoBitmapSize = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetLargeLayoutAutoBitmapSize = function (Value) {
      if (this.FLargeLayoutAutoBitmapSize !== Value) {
        this.FLargeLayoutAutoBitmapSize = Value;
        this.UpdateLayout();
        this.Invalidate();
      };
    };
    this.SetUseStyledDropDownIcon = function (Value) {
      if (this.FUseStyledDropDownIcon !== Value) {
        this.FUseStyledDropDownIcon = Value;
        this.Invalidate();
      };
    };
    this.CanDrawDesignTime = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.HasHint = function () {
      var Result = false;
      Result = this.FHint !== "";
      return Result;
    };
    this.GetHintString = function () {
      var Result = "";
      Result = this.FHint;
      return Result;
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FText;
      return Result;
    };
    this.GetTextSize = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var g = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.cx = 0;
      Result.cy = 0;
      if (this.FTextVisible && (this.GetText() !== "")) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,this.FNativeCanvas,true]);
        if (!this.FNativeCanvas) g.BeginScene();
        g.FBitmapContainer = this.GetBitmapContainer();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        try {
          g.FFont.Assign(this.FFont$1);
          r.$assign(this.GetLocalRect());
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
          Result.$assign(g.CalculateTextSize(this.GetText(),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FWordWrapping,true));
        } finally {
          if (!this.FNativeCanvas) g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      return Result;
    };
    this.UpdateControlAfterResize = function () {
      $mod.TTMSFNCCustomToolBarElement.UpdateControlAfterResize.call(this);
      if (this.FLayout === $mod.TTMSFNCToolBarButtonLayout.bblLarge) this.FOldHeight = this.GetHeight();
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FNormalFill.SetColor(c);
        this.FAppearance.FNormalFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FDisabledFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Lighter(c,20));
        this.FAppearance.FDisabledFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FInnerStroke.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(this.FAppearance.FNormalFill.FColor,this.FAppearance.FNormalStroke.FColor,75));
        this.FAppearance.FInnerStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFont$1.SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundStrokeColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FNormalStroke.SetColor(c);
        this.FAppearance.FDownStroke.SetColor(c);
        this.FAppearance.FDisabledStroke.SetColor(c);
        this.FAppearance.FNormalStroke.SetColor(c);
        this.FAppearance.FDownStroke.SetColor(c);
        this.FAppearance.FDisabledStroke.SetColor(c);
        this.FAppearance.FHoverStroke.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FHoverFill.SetColor(c);
        this.FAppearance.FHoverFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FDownFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].Blend(c,this.FFill.FColor,20));
        this.FAppearance.FDownFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      };
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      this.FFont$1.SetColor(0);
      this.FAppearance.FNormalFill.SetColor(16777215);
      this.FAppearance.FHoverFill.SetColor(16777215);
      this.FAppearance.FDownFill.SetColor(16777215);
      this.FAppearance.FDisabledFill.SetColor(13882323);
      this.FAppearance.FNormalStroke.SetColor(8421504);
      this.FAppearance.FInnerStroke.SetColor(16777215);
      this.FAppearance.FHoverStroke.SetColor(8421504);
      this.FAppearance.FDownStroke.SetColor(8421504);
      this.FAppearance.FDisabledStroke.SetColor(8421504);
      this.FAppearance.FNormalFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      this.FAppearance.FHoverFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      this.FAppearance.FDownFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      this.FAppearance.FDisabledFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FNormalStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FInnerStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FHoverStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FDownStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FDisabledStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FNormalFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(249,251,252));
      this.FAppearance.FNormalFill.SetColorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(230,235,235));
      this.FAppearance.FNormalFill.SetColorMirror(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(220,220,236));
      this.FAppearance.FNormalFill.SetColorMirrorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(220,225,236));
      this.FAppearance.FHoverFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(229,231,232));
      this.FAppearance.FHoverFill.SetColorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(210,215,215));
      this.FAppearance.FHoverFill.SetColorMirror(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(200,200,216));
      this.FAppearance.FHoverFill.SetColorMirrorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(200,205,216));
      this.FAppearance.FDownFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(219,221,222));
      this.FAppearance.FDownFill.SetColorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(200,205,205));
      this.FAppearance.FDownFill.SetColorMirror(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(190,190,206));
      this.FAppearance.FDownFill.SetColorMirrorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(190,195,206));
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      if (this.FPopup != null) this.FPopup.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.BitmapsChanged = function (Sender) {
      var bmp = null;
      bmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FBitmaps,0,this.GetBitmapContainer());
      this.SetBitmapVisible((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp));
      if (!this.FBitmapVisible && (this.FLayout === $mod.TTMSFNCToolBarButtonLayout.bblLarge)) {
        bmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FLargeLayoutBitmaps,0,this.GetBitmapContainer());
        this.SetBitmapVisible((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp));
      };
      this.Invalidate();
    };
    this.DoFontChanged = function (Sender) {
      this.Invalidate();
    };
    this.UpdateLayout = function () {
      var sz = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var w = 0.0;
      if ((this.FLayout === $mod.TTMSFNCToolBarButtonLayout.bblNone) || this.FBlockUpdate) return;
      this.FBlockUpdate = true;
      var $tmp = this.FLayout;
      if ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblBitmap) {
        this.SetTextVisible(false);
        this.SetBitmapPosition($mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft);
        this.SetStretchText(false);
        this.SetHeight(Math.round(this.GetBitmapSize() + 6));
        this.SetWidth(Math.round(this.GetBitmapSize() + 6));
      } else if ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLabel) {
        this.SetTextVisible(true);
        this.SetBitmapPosition($mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft);
        this.SetStretchText(false);
        sz.$assign(this.GetTextSize());
        if (this.FBitmapVisible) {
          this.SetHeight(Math.round(Math.max(this.GetBitmapSize(),sz.cy) + 6));
          this.SetWidth(Math.round(this.GetBitmapSize() + sz.cx + 12));
        } else if (this.FTextVisible && (this.GetText() !== "")) {
          this.SetHeight(Math.round(sz.cy + 6));
          this.SetWidth(Math.round(sz.cx + 6));
        } else {
          this.SetWidth(75);
          this.SetHeight(24);
        };
      } else if ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLarge) {
        this.SetTextVisible(true);
        this.SetBitmapPosition($mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop);
        this.SetStretchText(!this.FBitmapVisible);
        sz.$assign(this.GetTextSize());
        w = 30;
        if (this.FBitmapVisible) w = Math.max(w,this.GetLargeLayoutBitmapSize() + 6);
        if (this.FTextVisible && (this.GetText() !== "")) w = Math.max(w,sz.cx + 12);
        this.SetWidth(Math.round(w));
        if (this.FOldHeight !== -1) this.SetHeight(Math.round(this.FOldHeight));
      };
      this.FBlockUpdate = false;
      this.UpdateToolBar();
    };
    this.DoClosePopup = function (Sender) {
      if (this.FOnCloseDropDown != null) this.FOnCloseDropDown(this);
    };
    this.DoPopup = function (Sender) {
      this.InitializePopup();
    };
    this.InitializePopup = function () {
    };
    this.UpdateState = function () {
      var f = 0.0;
      $mod.TTMSFNCCustomToolBarElement.UpdateState.call(this);
      var $tmp = this.FState;
      if ($tmp === $mod.TTMSFNCToolBarElementState.esNormal) {
        f = 0.8}
       else if ($tmp === $mod.TTMSFNCToolBarElementState.esLarge) {
        f = 1.25}
       else {
        f = 1;
      };
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.SetDropDownWidth(this.FDropDownWidth * f);
        this.SetDropDownHeight(this.FDropDownHeight * f);
        this.FFont$1.SetSize(Math.round(this.FFont$1.FSize * f));
        this.SetBounds(this.GetLeft(),this.GetTop(),Math.round(this.GetWidth() * f),Math.round(this.GetHeight() * f));
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FFont$1.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FFont$1.FHeight,M,D));
      this.SetBitmapSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FBitmapSize,M,D));
      this.SetLargeLayoutBitmapSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FLargeLayoutBitmapSize,M,D));
      if (this.FOldHeight !== -1) this.FOldHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FOldHeight,M,D);
      this.FDropDownHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDropDownHeight,M,D);
      this.FDropDownWidth = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDropDownWidth,M,D);
      this.FPopup.SetDropDownWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FPopup.FDropDownWidth,M,D));
      this.FPopup.SetDropDownHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FPopup.FDropDownHeight,M,D));
      this.EndUpdate();
    };
    this.AppearanceChanged = function () {
      this.Invalidate();
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FDropDownControl)) this.FDropDownControl = null;
    };
    this.SetName = function (Value) {
      var ChangeText = false;
      ChangeText = !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FName === this.GetText()) && (!(this.FOwner != null) || !pas.Classes.TComponent.isPrototypeOf(this.FOwner) || !(pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      pas["WEBLib.Controls"].TCustomControl.SetName.call(this,Value);
      if (ChangeText && this.FApplyName && this.CanChangeText()) this.SetText(pas.SysUtils.StringReplace(this.GetText(),"TMSFNCToolBar","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if (this.CanFocus()) this.SetFocus();
      this.FDown = true;
      this.Invalidate();
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      this.FHover = true;
      if (this.FPrevHover !== this.FHover) this.Invalidate();
      this.FPrevHover = this.FHover;
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      this.FDown = false;
      this.Invalidate();
    };
    this.HandleKeyUp = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyUp.apply(this,arguments);
      if (rtl.neSet(Shift,{})) return;
      var $tmp = Key.get();
      if (($tmp === 13) || ($tmp === 115)) {
        if (this.CanDropDown()) this.DropDown();
      };
    };
    this.HandleKeyDown = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      var $tmp = Key.get();
      if ($tmp === 36) {
        this.SelectFirstValue()}
       else if ($tmp === 35) {
        this.SelectLastValue()}
       else if (($tmp === 38) || ($tmp === 37)) {
        this.SelectPreviousValue()}
       else if (($tmp === 40) || ($tmp === 39)) {
        this.SelectNextValue()}
       else if ($tmp === 32) this.Click();
    };
    this.HandleKeyPress = function (Key) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyPress.apply(this,arguments);
      if ((Key.get() >= " ") && !(Key.get().charCodeAt() in rtl.createSet(113,13,32,27,36,35,38,37,40,39))) this.SelectValueWithCharacter(Key.get());
    };
    this.HandleMouseEnter = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseEnter.call(this);
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FDown = false;
      this.FHover = false;
      this.FPrevHover = false;
      this.Invalidate();
    };
    this.SelectFirstValue = function () {
    };
    this.SelectValueWithCharacter = function (ACharacter) {
    };
    this.SelectLastValue = function () {
    };
    this.SelectNextValue = function () {
    };
    this.SelectPreviousValue = function () {
    };
    this.DrawText = function (AGraphics) {
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var st = null;
      if (!this.FTextVisible || (this.GetText() === "")) return;
      tr.$assign(this.GetTextRect());
      st = AGraphics.SaveState(false);
      try {
        AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr));
        AGraphics.FFont.Assign(this.FFont$1);
        if (this.FEnabled) {
          if ((this.FDown || this.FDownState) && (this.FDownFontColor !== -1)) {
            AGraphics.FFont.SetColor(this.FDownFontColor)}
           else if (this.FHover && (this.FHoverFontColor !== -1)) AGraphics.FFont.SetColor(this.FHoverFontColor);
        } else if (this.FDisabledFontColor !== -1) AGraphics.FFont.SetColor(this.FDisabledFontColor);
        AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr),this.GetText(),this.FWordWrapping,this.FHorizontalTextAlign,this.FVerticalTextAlign,this.FTrimming,0,-1,-1,true,false,-1,-1);
      } finally {
        AGraphics.RestoreState(st,false);
      };
    };
    this.DrawBitmap = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpa = null;
      var bmp = null;
      var g = null;
      var x = 0;
      var y = 0;
      var bs = 0.0;
      var s = false;
      if (!this.FBitmapVisible) return;
      r.$assign(this.GetBitmapRect$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect)));
      if ($mod.TTMSFNCToolBarDropDownButton.isPrototypeOf(this) && this.GetAdaptToStyle() && this.FUseStyledDropDownIcon) {
        bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
        bmpa.SetSize(this.ScalePaintValue(7),this.ScalePaintValue(7));
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
        try {
          g.BeginScene();
          g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          g.FStroke.SetColor(pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.DefaultSelectionFillColor);
          for (var $l = this.ScalePaintValue(1), $end = this.ScalePaintValue(5); $l <= $end; $l++) {
            y = $l;
            x = Math.max(0,y - this.ScalePaintValue(2));
            g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(x,y)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(bmpa.GetWidth() - 1 - x,y)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
            if (x >= (bmpa.GetWidth() - 1 - x)) break;
          };
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
        try {
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
          try {
            bmp.Assign(bmpa);
            AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        } finally {
          bmpa = rtl.freeLoc(bmpa);
        };
      } else {
        AGraphics.FBitmapContainer = this.GetBitmapContainer();
        bs = this.GetBitmapSize();
        var $tmp = this.FLayout;
        if ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLarge) bs = this.GetLargeLayoutBitmapSize();
        s = false;
        if (!this.FTextVisible || (this.GetText() === "")) if (!((bs !== -1) && !this.FStretchBitmapIfNoText)) s = true;
        var $tmp1 = this.FLayout;
        if ($tmp1 === $mod.TTMSFNCToolBarButtonLayout.bblLarge) {
          if (this.FEnabled) {
            if (this.FHover && (this.FLargeLayoutHoverBitmaps.GetCount() > 0)) {
              AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FLargeLayoutHoverBitmaps,this.FResourceScaleFactor,true,s,true,false)}
             else if (this.FHover && (this.FHoverBitmaps.GetCount() > 0)) {
              AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FHoverBitmaps,this.FResourceScaleFactor,true,s,true,false)}
             else if (this.FLargeLayoutBitmaps.GetCount() > 0) {
              AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FLargeLayoutBitmaps,this.FResourceScaleFactor,true,s,true,false)}
             else AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FBitmaps,this.FResourceScaleFactor,true,s,true,false);
          } else {
            if (this.FLargeLayoutDisabledBitmaps.GetCount() > 0) {
              AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FLargeLayoutDisabledBitmaps,this.FResourceScaleFactor,true,s,true,false)}
             else if (this.FDisabledBitmaps.GetCount() > 0) {
              AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FDisabledBitmaps,this.FResourceScaleFactor,true,s,true,false)}
             else AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FBitmaps,this.FResourceScaleFactor,true,s,true,false);
          };
        } else {
          if (this.FEnabled) {
            if (this.FHover && (this.FHoverBitmaps.GetCount() > 0)) {
              AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FHoverBitmaps,this.FResourceScaleFactor,true,s,true,false)}
             else AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FBitmaps,this.FResourceScaleFactor,true,s,true,false);
          } else if (this.FDisabledBitmaps.GetCount() > 0) {
            AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FDisabledBitmaps,this.FResourceScaleFactor,true,s,true,false)}
           else AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FBitmaps,this.FResourceScaleFactor,true,s,true,false);
        };
      };
    };
    this.DrawButton = function (AGraphics) {
    };
    this.CanDropDown = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.CanChangeText = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetTextRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetLocalRect());
      bmpr.$assign(this.GetBitmapRect());
      dr.$assign(this.GetDropDownRect());
      if (!this.FStretchText) {
        var $tmp = this.FBitmapPosition;
        if ($tmp === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(bmpr.Right + 3,r.Top + 3,dr.Left - 3,r.Bottom - 3))}
         else if ($tmp === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,bmpr.Bottom + 3,dr.Left - 3,r.Bottom - 3));
      } else Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,dr.Left - 3,r.Bottom - 3));
      return Result;
    };
    this.GetDropDownRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetLocalRect());
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Right,r.Top,r.Right,r.Bottom));
      return Result;
    };
    this.GetBitmapRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(this.GetBitmapRect$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetLocalRect())));
      return Result;
    };
    this.GetBitmapRect$1 = function (ARect) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bs = 0.0;
      bs = this.GetBitmapSize();
      var $tmp = this.FLayout;
      if ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLarge) bs = this.GetLargeLayoutBitmapSize();
      r.$assign(ARect);
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Left,r.Bottom));
      if (this.FBitmapVisible) {
        var $tmp1 = this.FBitmapPosition;
        if ($tmp1 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,Result.Left + 3 + bs,Result.Bottom - 3))}
         else if ($tmp1 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,Result.Right - 3,Result.Top + 3 + bs));
      };
      return Result;
    };
    this.GetBitmapSize = function () {
      var Result = 0.0;
      var bmp = null;
      Result = this.FBitmapSize;
      if (this.FAutoBitmapSize) {
        bmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FBitmaps,0,this.GetBitmapContainer());
        if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) Result = Math.max(bmp.GetHeight(),bmp.GetWidth());
      };
      return Result;
    };
    this.GetLargeLayoutBitmapSize = function () {
      var Result = 0.0;
      var bmp = null;
      Result = this.FLargeLayoutBitmapSize;
      if (this.FLargeLayoutAutoBitmapSize) {
        bmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FLargeLayoutBitmaps,0,this.GetBitmapContainer());
        if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) Result = Math.max(bmp.GetHeight(),bmp.GetWidth());
      };
      return Result;
    };
    this.Assign = function (Source) {
      $mod.TTMSFNCCustomToolBarElement.Assign.apply(this,arguments);
      if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(Source)) {
        this.FLayout = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FLayout;
        this.FCompactLayout = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FCompactLayout;
        this.FMinimumLayout = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FMinimumLayout;
        this.FMaximumLayout = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FMaximumLayout;
        this.FBitmapPosition = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FBitmapPosition;
        this.FBitmapSize = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FBitmapSize;
        this.FLargeLayoutBitmapSize = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FLargeLayoutBitmapSize;
        this.FAutoBitmapSize = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FAutoBitmapSize;
        this.FLargeLayoutAutoBitmapSize = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FLargeLayoutAutoBitmapSize;
        this.FStretchBitmapIfNoText = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FStretchBitmapIfNoText;
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FAppearance);
        this.FBitmapContainer = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).GetBitmapContainer();
        this.FBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FBitmaps);
        this.FDisabledBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FDisabledBitmaps);
        this.FLargeLayoutHoverBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FLargeLayoutHoverBitmaps);
        this.FLargeLayoutBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FLargeLayoutBitmaps);
        this.FLargeLayoutDisabledBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FLargeLayoutDisabledBitmaps);
        this.FHoverBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FHoverBitmaps);
        this.FBitmapVisible = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FBitmapVisible;
        this.FText = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).GetText();
        this.FTextVisible = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FTextVisible;
        this.FDropDownHeight = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FDropDownHeight;
        this.FDropDownWidth = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FDropDownWidth;
        this.FDropDownAutoWidth = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FDropDownAutoWidth;
        this.FWordWrapping = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FWordWrapping;
        this.FHorizontalTextAlign = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FHorizontalTextAlign;
        this.FVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FVerticalTextAlign;
        this.FTrimming = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FTrimming;
        this.FFont$1.Assign(rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FFont$1);
        this.FHoverFontColor = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FHoverFontColor;
        this.FDownFontColor = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FDownFontColor;
        this.FDisabledFontColor = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FDisabledFontColor;
        this.FStretchText = rtl.as(Source,$mod.TTMSFNCDefaultToolBarButton).FStretchText;
        this.Invalidate();
      };
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomToolBarElement.Create$1.apply(this,arguments);
      this.FUseStyledDropDownIcon = true;
      this.FOldHeight = -1;
      this.FLayout = $mod.TTMSFNCToolBarButtonLayout.bblNone;
      this.FCompactLayout = $mod.TTMSFNCToolBarButtonLayout.bblNone;
      this.FMinimumLayout = $mod.TTMSFNCToolBarButtonLayout.bblBitmap;
      this.FMaximumLayout = $mod.TTMSFNCToolBarButtonLayout.bblLarge;
      this.FFont$1 = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont$1.FOnChanged = rtl.createCallback(this,"DoFontChanged");
      this.FHoverFontColor = -1;
      this.FDownFontColor = -1;
      this.FDisabledFontColor = -1;
      this.FDownState = false;
      this.FApplyName = true;
      this.FCloseOnSelection = true;
      this.FBitmapSize = 24;
      this.FLargeLayoutBitmapSize = 32;
      this.FAutoBitmapSize = false;
      this.FLargeLayoutAutoBitmapSize = false;
      this.FStretchBitmapIfNoText = true;
      this.FStretchText = false;
      this.FDropDownWidth = 135;
      this.FDropDownHeight = 135;
      this.FDropDownAutoWidth = false;
      this.FPopup = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FPopup.SetDragWithParent(true);
      this.FPopup.SetDropDownWidth(this.FDropDownWidth);
      this.FPopup.SetDropDownHeight(this.FDropDownHeight);
      this.FPopup.FOnPopup = rtl.createCallback(this,"DoPopup");
      this.FPopup.FOnClosePopup = rtl.createCallback(this,"DoClosePopup");
      this.FPopupPlacement = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppBottom;
      this.FBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FBitmaps.FOnChange = rtl.createCallback(this,"BitmapsChanged");
      this.FDisabledBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FDisabledBitmaps.FOnChange = rtl.createCallback(this,"BitmapsChanged");
      this.FHoverBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FHoverBitmaps.FOnChange = rtl.createCallback(this,"BitmapsChanged");
      this.FLargeLayoutBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FLargeLayoutBitmaps.FOnChange = rtl.createCallback(this,"BitmapsChanged");
      this.FLargeLayoutDisabledBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FLargeLayoutDisabledBitmaps.FOnChange = rtl.createCallback(this,"BitmapsChanged");
      this.FLargeLayoutHoverBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FLargeLayoutHoverBitmaps.FOnChange = rtl.createCallback(this,"BitmapsChanged");
      this.FAppearance = $mod.TTMSFNCToolBarButtonAppearance.$create("Create$1",[this]);
      this.FTextVisible = true;
      this.FBitmapVisible = false;
      this.FWordWrapping = false;
      this.FHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FTrimming = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter;
      this.FBitmapPosition = $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft;
      this.SetWidth(100);
      this.SetHeight(24);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFont$1");
      rtl.free(this,"FPopup");
      rtl.free(this,"FBitmaps");
      rtl.free(this,"FDisabledBitmaps");
      rtl.free(this,"FHoverBitmaps");
      rtl.free(this,"FLargeLayoutBitmaps");
      rtl.free(this,"FLargeLayoutDisabledBitmaps");
      rtl.free(this,"FLargeLayoutHoverBitmaps");
      rtl.free(this,"FAppearance");
      $mod.TTMSFNCCustomToolBarElement.Destroy.call(this);
    };
    this.Draw = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      if (!this.FAppearance.FTransparent) {
        if (this.FEnabled) {
          if (this.FDown || this.FDownState) {
            AGraphics.FFill.Assign(this.FAppearance.FDownFill);
            AGraphics.FStroke.Assign(this.FAppearance.FDownStroke);
          } else if (this.FHover) {
            AGraphics.FFill.Assign(this.FAppearance.FHoverFill);
            AGraphics.FStroke.Assign(this.FAppearance.FHoverStroke);
          } else {
            AGraphics.FFill.Assign(this.FAppearance.FNormalFill);
            AGraphics.FStroke.Assign(this.FAppearance.FNormalStroke);
          };
        } else {
          AGraphics.FFill.Assign(this.FAppearance.FDisabledFill);
          AGraphics.FStroke.Assign(this.FAppearance.FDisabledStroke);
        };
        r.$assign(this.GetLocalRect());
        if (this.FAppearance.FFlatStyle) {
          AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        } else AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FAppearance.FRounding,rtl.refSet(this.FAppearance.FCorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        if (this.FAppearance.FShowInnerStroke && !this.FAppearance.FFlatStyle) {
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-1,-1);
          AGraphics.FStroke.Assign(this.FAppearance.FInnerStroke);
          AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkNone);
          AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FAppearance.FRounding,rtl.refSet(this.FAppearance.FCorners),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        };
      };
      this.DrawBitmap(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      this.DrawText(AGraphics);
      this.DrawButton(AGraphics);
      if (this.FShowFocus$1 && this.IsFocused()) {
        r.$assign(this.GetTextRect());
        AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      };
      if (this.IsDesignTime() && this.CanDrawDesignTime()) AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.DropDown = function () {
      if (!(this.FPopup != null)) return;
      this.FPopup.SetPlacementControl(this);
      if (!this.FPopup.FIsOpen) {
        if (this.FOnBeforeDropDown != null) this.FOnBeforeDropDown(this);
        if (this.FDropDownAutoWidth) this.FPopup.SetDropDownWidth(this.GetWidth());
        this.FPopup.SetPlacement(this.FPopupPlacement);
        this.FPopup.SetIsOpen(true);
        if (this.FOnDropDown != null) this.FOnDropDown(this);
      } else this.FPopup.SetIsOpen(false);
    };
    this.CloseDropDown = function () {
      if (!(this.FPopup != null)) return;
      if (this.FPopup.FIsOpen) this.FPopup.SetIsOpen(false);
    };
    this.GetPopupControl = function () {
      var Result = null;
      Result = this.FPopup;
      return Result;
    };
    this.GetBitmap = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FBitmaps,0,this.FBitmapContainer);
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TTMSFNCToolBarButtonDropDownKind = {"0": "ddkNormal", ddkNormal: 0, "1": "ddkDropDown", ddkDropDown: 1, "2": "ddkDropDownButton", ddkDropDownButton: 2};
  this.$rtti.$Enum("TTMSFNCToolBarButtonDropDownKind",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCToolBarButtonDropDownKind});
  this.TTMSFNCToolBarButtonDropDownPosition = {"0": "ddpRight", ddpRight: 0, "1": "ddpBottom", ddpBottom: 1};
  this.$rtti.$Enum("TTMSFNCToolBarButtonDropDownPosition",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCToolBarButtonDropDownPosition});
  rtl.createClass(this,"TTMSFNCToolBarDropDownButton",this.TTMSFNCDefaultToolBarButton,function () {
    this.$init = function () {
      $mod.TTMSFNCDefaultToolBarButton.$init.call(this);
      this.FDefaultStyle = false;
    };
    this.SetDefaultStyle = function (Value) {
      if (this.FDefaultStyle !== Value) {
        this.FDefaultStyle = Value;
        this.Invalidate();
      };
    };
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarDropDownButton);
    };
    this.DrawBitmap = function (AGraphics, ARect) {
      var bmp = null;
      var bmpa = null;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      if (this.FDefaultStyle) {
        r.$assign(ARect);
        if (!((this.FOwner != null) && $mod.TTMSFNCCustomToolBarButton.isPrototypeOf(this.FOwner) && (rtl.as(this.FOwner,$mod.TTMSFNCCustomToolBarButton).FDropDownPosition === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom))) pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
        $mod.TTMSFNCDefaultToolBarButton.DrawBitmap.call(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
      } else {
        bmpa = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
        bmpa.SetSize(7,7);
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("Create$1",[bmpa.GetCanvas(),false]);
        try {
          g.BeginScene();
          g.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
          g.FStroke.SetColor(11119017);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(0,1)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6,1)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(0,2)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(6,2)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(1,3)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(5,3)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(2,4)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(4,4)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
          g.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(3,5)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(3,5)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
        try {
          r.$assign(ARect);
          bmp = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
          try {
            bmp.Assign(bmpa);
            AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),bmp,true,false,true,false);
          } finally {
            bmp = rtl.freeLoc(bmp);
          };
        } finally {
          bmpa = rtl.freeLoc(bmpa);
        };
      };
    };
    this.GetBitmapRect$1 = function (ARect) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(ARect);
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Right - 3,r.Bottom - 3));
      return Result;
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCDefaultToolBarButton.Create$1.apply(this,arguments);
      this.FDefaultStyle = true;
      return this;
    };
    this.LoadSettingsFromFile = function (AFileName) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromFile.apply(this,arguments);
      this.SetDefaultStyle(false);
    };
    this.LoadSettingsFromStream = function (AStream) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromStream.apply(this,arguments);
      this.SetDefaultStyle(false);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DefaultStyle",2,rtl.boolean,"FDefaultStyle","SetDefaultStyle",4,{Default: true});
    $r.addProperty("UseStyledDropDownIcon",2,rtl.boolean,"FUseStyledDropDownIcon","SetUseStyledDropDownIcon",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont$1","SetFont$1");
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus$1","SetShowFocus$1",4,{Default: false});
    $r.addProperty("TextVisible",2,rtl.boolean,"FTextVisible","SetTextVisible",4,{Default: true});
    $r.addProperty("StretchText",2,rtl.boolean,"FStretchText","SetStretchText",4,{Default: false});
    $r.addProperty("HoverFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverFontColor","SetHoverFontColor",4,{Default: -1});
    $r.addProperty("DownFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDownFontColor","SetDownFontColor",4,{Default: -1});
    $r.addProperty("DisabledFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledFontColor","SetDisabledFontColor",4,{Default: -1});
    $r.addProperty("WordWrapping",2,rtl.boolean,"FWordWrapping","SetWordWrapping",4,{Default: false});
    $r.addProperty("HorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalTextAlign","SetHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("Trimming",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],"FTrimming","SetTrimming",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter});
    $r.addProperty("Bitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FBitmaps","SetBitmaps");
    $r.addProperty("DisabledBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FDisabledBitmaps","SetDisabledBitmaps");
    $r.addProperty("HoverBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FHoverBitmaps","SetHoverBitmaps");
    $r.addProperty("BitmapVisible",2,rtl.boolean,"FBitmapVisible","SetBitmapVisible",4,{Default: false});
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("State",2,$mod.$rtti["TTMSFNCToolBarElementState"],"FState","SetState",4,{Default: $mod.TTMSFNCToolBarElementState.esNormal});
    $r.addProperty("LastElement",2,rtl.boolean,"FLastElement","SetLastElement",4,{Default: false});
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCToolBarButtonAppearance"],"FAppearance","SetAppearance");
  });
  this.$rtti.$ClassRef("TTMSFNCToolBarDropDownButtonClass",{instancetype: this.$rtti["TTMSFNCToolBarDropDownButton"]});
  rtl.createClass(this,"TTMSFNCCustomToolBarButton",this.TTMSFNCDefaultToolBarButton,function () {
    this.$init = function () {
      $mod.TTMSFNCDefaultToolBarButton.$init.call(this);
      this.FDropDownButton = null;
      this.FDropDownKind = 0;
      this.FDropDownPosition = 0;
      this.FHidden = false;
      this.FAutoOptionsMenuText = "";
    };
    this.$final = function () {
      this.FDropDownButton = undefined;
      $mod.TTMSFNCDefaultToolBarButton.$final.call(this);
    };
    this.SetDropDownKind = function (Value) {
      if (this.FDropDownKind !== Value) {
        this.FDropDownKind = Value;
        if (this.FDropDownButton != null) {
          var $tmp = this.FDropDownKind;
          if ($tmp === $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal) {
            this.FDropDownButton.SetVisible(false);
            this.FDropDownButton.SetParent(null);
            this.FDropDownButton.FAppearance.SetTransparent(false);
          } else if ($tmp === $mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDown) {
            this.FDropDownButton.SetVisible(false);
            this.FDropDownButton.SetParent(this);
            this.FDropDownButton.FAppearance.SetTransparent(true);
          } else if ($tmp === $mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDownButton) {
            this.FDropDownButton.SetVisible(true);
            this.FDropDownButton.SetParent(this);
            this.FDropDownButton.FAppearance.SetTransparent(false);
          };
        };
        this.Invalidate();
      };
    };
    this.SetDropDownPosition = function (Value) {
      var sc = 0.0;
      if (this.FDropDownPosition !== Value) {
        sc = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetDPIScale(this,96);
        this.FDropDownPosition = Value;
        if (this.FDropDownButton != null) {
          var $tmp = Value;
          if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
            this.FDropDownButton.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
            this.FDropDownButton.SetWidth(Math.round(sc * 17));
            this.FDropDownButton.FAppearance.SetCorners(rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight));
          } else if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) {
            this.FDropDownButton.SetAlign(pas["WEBLib.Controls"].TAlign.alBottom);
            this.FDropDownButton.SetHeight(Math.round(sc * 10));
            this.FDropDownButton.FAppearance.SetCorners(rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight));
          };
        };
      };
    };
    this.SetHidden = function (Value) {
      if (this.FHidden !== Value) {
        this.FHidden = Value;
        this.UpdateToolBarControl();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      $mod.TTMSFNCDefaultToolBarButton.ChangeDPIScale.apply(this,arguments);
    };
    this.SetAdaptToStyle = function (Value) {
      $mod.TTMSFNCDefaultToolBarButton.SetAdaptToStyle.apply(this,arguments);
      if (this.FDropDownButton != null) this.FDropDownButton.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.DoFontChanged$1 = function (Sender) {
      this.Invalidate();
    };
    this.AppearanceChanged = function () {
      $mod.TTMSFNCDefaultToolBarButton.AppearanceChanged.call(this);
      this.UpdateDropDownButton();
    };
    this.UpdateDropDownButton = function () {
      if (this.FDropDownButton != null) this.FDropDownButton.FAppearance.SetRounding(this.FAppearance.FRounding);
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      $mod.TTMSFNCDefaultToolBarButton.HandleMouseDown.apply(this,arguments);
      if (this.FDropDownKind === $mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDown) this.DropDown();
    };
    this.DropDownButtonClick = function (Sender) {
      this.DropDown();
    };
    this.DrawButton = function (AGraphics) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      $mod.TTMSFNCDefaultToolBarButton.DrawButton.apply(this,arguments);
      if ((this.FDropDownButton != null) && (this.FDropDownKind === $mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDown)) {
        var $tmp = this.FDropDownPosition;
        if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.GetWidth() - this.FDropDownButton.GetWidth(),0,this.GetWidth(),this.GetHeight()))}
         else if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,this.GetHeight() - this.FDropDownButton.GetHeight(),this.GetWidth(),this.GetHeight()));
        this.FDropDownButton.DrawBitmap(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
      };
    };
    this.SetEnabled = function (Value) {
      var d = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetEnabled.apply(this,arguments);
      d = this.GetDropDownButtonControl();
      if (d != null) d.SetEnabled(Value);
    };
    this.GetDropDownButtonClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarDropDownButton;
      return Result;
    };
    this.GetDropDownRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign($mod.TTMSFNCDefaultToolBarButton.GetDropDownRect.call(this));
      if ((this.FDropDownButton != null) && (this.FDropDownKind !== $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal)) {
        if (this.FDropDownKind === $mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDown) {
          var $tmp = this.FDropDownPosition;
          if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.GetWidth() - this.FDropDownButton.GetWidth(),0,this.GetWidth(),this.GetHeight()))}
           else if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,this.GetHeight() - this.FDropDownButton.GetHeight(),this.GetWidth(),this.GetHeight()));
        } else {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.FDropDownButton.GetLeft(),this.FDropDownButton.GetTop(),this.FDropDownButton.GetLeft() + this.FDropDownButton.GetWidth(),this.FDropDownButton.GetTop() + this.FDropDownButton.GetHeight()));
        };
      };
      return Result;
    };
    this.GetTextRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetLocalRect());
      bmpr.$assign(this.GetBitmapRect$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r)));
      dr.$assign(this.GetDropDownRect());
      if (this.FDropDownKind !== $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal) {
        if (!this.FStretchText) {
          var $tmp = this.FBitmapPosition;
          if ($tmp === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft) {
            var $tmp1 = this.FDropDownPosition;
            if ($tmp1 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
              Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(bmpr.Right + 3,r.Top + 3,dr.Left - 3,r.Bottom - 3))}
             else if ($tmp1 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(bmpr.Right + 3,r.Top + 3,r.Right - 3,dr.Top - 3));
          } else if ($tmp === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop) {
            var $tmp2 = this.FDropDownPosition;
            if ($tmp2 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
              Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,bmpr.Bottom + 3,dr.Left - 3,r.Bottom - 3))}
             else if ($tmp2 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,bmpr.Bottom + 3,r.Right - 3,dr.Top - 3));
          };
        } else {
          var $tmp3 = this.FDropDownPosition;
          if ($tmp3 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,dr.Left - 3,r.Bottom - 3))}
           else if ($tmp3 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Right - 3,dr.Top - 3));
        };
      } else {
        if (!this.FStretchText) {
          var $tmp4 = this.FBitmapPosition;
          if ($tmp4 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(bmpr.Right + 3,r.Top + 3,dr.Left - 3,r.Bottom - 3))}
           else if ($tmp4 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,bmpr.Bottom + 3,dr.Left - 3,r.Bottom - 3));
        } else Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,dr.Left - 3,r.Bottom - 3));
      };
      return Result;
    };
    this.GetBitmapRect$1 = function (ARect) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bs = 0.0;
      bs = this.GetBitmapSize();
      var $tmp = this.FLayout;
      if ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLarge) bs = this.GetLargeLayoutBitmapSize();
      r.$assign(ARect);
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Left,r.Bottom));
      if (this.FBitmapVisible) {
        if (this.FDropDownKind !== $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal) {
          dr.$assign(this.GetDropDownRect());
          var $tmp1 = this.FBitmapPosition;
          if ($tmp1 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft) {
            var $tmp2 = this.FDropDownPosition;
            if ($tmp2 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
              Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,Result.Left + 3 + bs,Result.Bottom - 3))}
             else if ($tmp2 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,Result.Left + 3 + bs,dr.Top - 3));
          } else if ($tmp1 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop) {
            var $tmp3 = this.FDropDownPosition;
            if ($tmp3 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
              Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,dr.Left - 3,Result.Top + 3 + bs))}
             else if ($tmp3 === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,r.Right - 3,Result.Top + 3 + bs));
          };
        } else if (!this.FTextVisible || (this.GetText() === "")) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Right - 3,r.Bottom - 3));
          if ((bs !== -1) && !this.FStretchBitmapIfNoText) {
            Result.Left = Math.round(r.Left + ((r.Right - r.Left - bs) / 2));
            Result.Top = Math.round(r.Top + ((r.Bottom - r.Top - bs) / 2));
            Result.Right = Result.Left + bs;
            Result.Bottom = Result.Top + bs;
          };
        } else if (this.FTextVisible && !(this.GetText() === "")) {
          var $tmp4 = this.FBitmapPosition;
          if ($tmp4 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Left + 3 + bs,r.Bottom - 3))}
           else if ($tmp4 === $mod.TTMSFNCToolBarButtonBitmapPosition.bbpTop) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Right - 3,r.Top + 3 + bs));
        };
      };
      return Result;
    };
    this.GetBitmapRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign($mod.TTMSFNCDefaultToolBarButton.GetBitmapRect.call(this));
      return Result;
    };
    this.CanDropDown = function () {
      var Result = false;
      Result = this.FDropDownKind !== $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal;
      return Result;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.Assign = function (Source) {
      $mod.TTMSFNCDefaultToolBarButton.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomToolBarButton.isPrototypeOf(Source)) {
        this.FDropDownKind = rtl.as(Source,$mod.TTMSFNCCustomToolBarButton).FDropDownKind;
        this.FDropDownPosition = rtl.as(Source,$mod.TTMSFNCCustomToolBarButton).FDropDownPosition;
        this.FAutoOptionsMenuText = rtl.as(Source,$mod.TTMSFNCCustomToolBarButton).FAutoOptionsMenuText;
        this.FHidden = rtl.as(Source,$mod.TTMSFNCCustomToolBarButton).FHidden;
        this.Invalidate();
      };
    };
    this.Create$1 = function (AOwner) {
      var res = "";
      $mod.TTMSFNCDefaultToolBarButton.Create$1.apply(this,arguments);
      this.FHidden = false;
      this.FDropDownPosition = $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight;
      this.FDropDownButton = this.GetDropDownButtonClass().$create("Create$1",[this]);
      this.FDropDownButton.SetTabStop(false);
      this.FDropDownButton.SetText("");
      this.FDropDownButton.FOnClick = rtl.createCallback(this,"DropDownButtonClick");
      this.FDropDownButton.SetVisible(false);
      this.FDropDownButton.SetWidth(17);
      this.FDropDownButton.FAppearance.SetCorners(rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcTopRight,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsCorner.gcBottomRight));
      this.FDropDownButton.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
      this.FDropDownButton.FStored = false;
      res = $mod.TMSFNCTOOLBAREXPANDSVG;
      this.FDropDownButton.FBitmaps.AddBitmapFromResource$1(res,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FDropDownButton.FDisabledBitmaps.AddBitmapFromResource$1(res,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FDropDownButton.FHoverBitmaps.AddBitmapFromResource$1(res,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FDropDownButton");
      $mod.TTMSFNCDefaultToolBarButton.Destroy.call(this);
    };
    this.GetDropDownButtonControl = function () {
      var Result = null;
      Result = this.FDropDownButton;
      return Result;
    };
    this.LoadSettingsFromFile = function (AFileName) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromFile.apply(this,arguments);
      if (this.FDropDownButton != null) {
        this.FDropDownButton.FAppearance.SetShowInnerStroke(this.FAppearance.FShowInnerStroke);
        this.FDropDownButton.FAppearance.FInnerStroke.Assign(this.FAppearance.FInnerStroke);
        this.FDropDownButton.FAppearance.FNormalFill.Assign(this.FAppearance.FNormalFill);
        this.FDropDownButton.FAppearance.FNormalStroke.Assign(this.FAppearance.FNormalStroke);
        this.FDropDownButton.FAppearance.FHoverFill.Assign(this.FAppearance.FHoverFill);
        this.FDropDownButton.FAppearance.FHoverStroke.Assign(this.FAppearance.FHoverStroke);
        this.FDropDownButton.FAppearance.FDownFill.Assign(this.FAppearance.FDownFill);
        this.FDropDownButton.FAppearance.FDownStroke.Assign(this.FAppearance.FDownStroke);
        this.FDropDownButton.FAppearance.FDisabledFill.Assign(this.FAppearance.FDisabledFill);
        this.FDropDownButton.FAppearance.FDisabledStroke.Assign(this.FAppearance.FDisabledStroke);
        this.FDropDownButton.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
        this.FDropDownButton.FFill.Assign(this.FFill);
        this.FDropDownButton.FStroke.Assign(this.FStroke);
      };
    };
    this.LoadSettingsFromStream = function (AStream) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromStream.apply(this,arguments);
      if (this.FDropDownButton != null) {
        this.FDropDownButton.FAppearance.SetShowInnerStroke(this.FAppearance.FShowInnerStroke);
        this.FDropDownButton.FAppearance.FInnerStroke.Assign(this.FAppearance.FInnerStroke);
        this.FDropDownButton.FAppearance.FNormalFill.Assign(this.FAppearance.FNormalFill);
        this.FDropDownButton.FAppearance.FNormalStroke.Assign(this.FAppearance.FNormalStroke);
        this.FDropDownButton.FAppearance.FHoverFill.Assign(this.FAppearance.FHoverFill);
        this.FDropDownButton.FAppearance.FHoverStroke.Assign(this.FAppearance.FHoverStroke);
        this.FDropDownButton.FAppearance.FDownFill.Assign(this.FAppearance.FDownFill);
        this.FDropDownButton.FAppearance.FDownStroke.Assign(this.FAppearance.FDownStroke);
        this.FDropDownButton.FAppearance.FDisabledFill.Assign(this.FAppearance.FDisabledFill);
        this.FDropDownButton.FAppearance.FDisabledStroke.Assign(this.FAppearance.FDisabledStroke);
        this.FDropDownButton.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
        this.FDropDownButton.FFill.Assign(this.FFill);
        this.FDropDownButton.FStroke.Assign(this.FStroke);
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomToolBarSeparatorAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FStroke = null;
      this.FInnerStroke = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FStroke = undefined;
      this.FInnerStroke = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetInnerStroke = function (Value) {
      this.FInnerStroke.Assign(Value);
    };
    this.StrokeChanged = function (Sender) {
      this.FOwner.Invalidate();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomToolBarSeparatorAppearance.isPrototypeOf(Source)) {
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarSeparatorAppearance).FStroke);
        this.FInnerStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarSeparatorAppearance).FInnerStroke);
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FInnerStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,16777215,1.0]);
      this.FInnerStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FInnerStroke");
      rtl.free(this,"FStroke");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCToolBarSeparatorAppearance",this.TTMSFNCCustomToolBarSeparatorAppearance,function () {
    var $r = this.$rtti;
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("InnerStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FInnerStroke","SetInnerStroke");
  });
  this.TTMSFNCToolBarSeperatorOrientation = {"0": "tbsoVertical", tbsoVertical: 0, "1": "tbsoHorizontal", tbsoHorizontal: 1};
  this.$rtti.$Enum("TTMSFNCToolBarSeperatorOrientation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCToolBarSeperatorOrientation});
  rtl.createClass(this,"TTMSFNCCustomToolBarSeparator",this.TTMSFNCCustomToolBarElement,function () {
    this.$init = function () {
      $mod.TTMSFNCCustomToolBarElement.$init.call(this);
      this.FAppearance = null;
      this.FOrientation = 0;
    };
    this.$final = function () {
      this.FAppearance = undefined;
      $mod.TTMSFNCCustomToolBarElement.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
    };
    this.SetOrientation = function (Value) {
      var t = 0;
      if (this.FOrientation !== Value) {
        this.FOrientation = Value;
        t = this.GetWidth();
        this.SetWidth(this.GetHeight());
        this.SetHeight(t);
        this.Invalidate();
      };
    };
    this.UpdateState = function () {
      var f = 0.0;
      $mod.TTMSFNCCustomToolBarElement.UpdateState.call(this);
      var $tmp = this.FState;
      if ($tmp === $mod.TTMSFNCToolBarElementState.esNormal) {
        f = 0.8}
       else if ($tmp === $mod.TTMSFNCToolBarElementState.esLarge) {
        f = 1.25}
       else {
        f = 1;
      };
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.SetBounds(this.GetLeft(),this.GetTop(),this.GetWidth(),Math.round(this.GetHeight() * f));
      };
    };
    this.Assign = function (Source) {
      $mod.TTMSFNCCustomToolBarElement.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomToolBarSeparator.isPrototypeOf(Source)) {
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarSeparator).FAppearance);
        this.Invalidate();
      };
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomToolBarElement.Create$1.apply(this,arguments);
      this.SetWidth(2);
      this.SetHeight(30);
      this.FOrientation = $mod.TTMSFNCToolBarSeperatorOrientation.tbsoVertical;
      this.FAppearance = $mod.TTMSFNCToolBarSeparatorAppearance.$create("Create$1",[this]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      $mod.TTMSFNCCustomToolBarElement.Destroy.call(this);
    };
    this.Draw = function (AGraphics, ARect) {
      var cp = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      r.$assign(this.GetLocalRect());
      cp.$assign(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,r.Top));
      var $tmp = this.FOrientation;
      if ($tmp === $mod.TTMSFNCToolBarSeperatorOrientation.tbsoVertical) {
        AGraphics.FStroke.Assign(this.FAppearance.FStroke);
        AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cp.X,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cp.X,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        AGraphics.FStroke.Assign(this.FAppearance.FInnerStroke);
        AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cp.X + 1,r.Top)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(cp.X + 1,r.Bottom)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      } else if ($tmp === $mod.TTMSFNCToolBarSeperatorOrientation.tbsoHorizontal) {
        AGraphics.FStroke.Assign(this.FAppearance.FStroke);
        AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,cp.Y)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,cp.Y)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
        AGraphics.FStroke.Assign(this.FAppearance.FInnerStroke);
        AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Left,cp.Y + 1)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right,cp.Y + 1)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCToolBarButton",this.TTMSFNCCustomToolBarButton,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarButton);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont$1","SetFont$1");
    $r.addProperty("AutoOptionsMenuText",0,rtl.string,"FAutoOptionsMenuText","FAutoOptionsMenuText");
    $r.addProperty("DropDownAutoWidth",2,rtl.boolean,"FDropDownAutoWidth","SetDropDownAutoWidth",4,{Default: false});
    $r.addProperty("DropDownKind",2,$mod.$rtti["TTMSFNCToolBarButtonDropDownKind"],"FDropDownKind","SetDropDownKind",4,{Default: $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal});
    $r.addProperty("DropDownPosition",2,$mod.$rtti["TTMSFNCToolBarButtonDropDownPosition"],"FDropDownPosition","SetDropDownPosition",4,{Default: $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight});
    $r.addProperty("DropDownHeight",14,rtl.double,"FDropDownHeight","SetDropDownHeight",4,{stored: "IsDropDownHeightStored"});
    $r.addProperty("DropDownWidth",14,rtl.double,"FDropDownWidth","SetDropDownWidth",4,{stored: "IsDropDownWidthStored"});
    $r.addProperty("DropDownControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FDropDownControl","SetDropDownControl");
    $r.addProperty("OnBeforeDropDown",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnBeforeDropDown","FOnBeforeDropDown");
    $r.addProperty("OnDropDown",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDropDown","FOnDropDown");
    $r.addProperty("OnCloseDropDown",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnCloseDropDown","FOnCloseDropDown");
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus$1","SetShowFocus$1",4,{Default: false});
    $r.addProperty("TextVisible",2,rtl.boolean,"FTextVisible","SetTextVisible",4,{Default: true});
    $r.addProperty("StretchText",2,rtl.boolean,"FStretchText","SetStretchText",4,{Default: false});
    $r.addProperty("HoverFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverFontColor","SetHoverFontColor",4,{Default: -1});
    $r.addProperty("DownFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDownFontColor","SetDownFontColor",4,{Default: -1});
    $r.addProperty("DisabledFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledFontColor","SetDisabledFontColor",4,{Default: -1});
    $r.addProperty("StretchBitmapIfNoText",2,rtl.boolean,"FStretchBitmapIfNoText","SetStretchBitmapIfNoText",4,{Default: true});
    $r.addProperty("HorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalTextAlign","SetHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("Trimming",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],"FTrimming","SetTrimming",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter});
    $r.addProperty("Bitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FBitmaps","SetBitmaps");
    $r.addProperty("LargeLayoutBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FLargeLayoutBitmaps","SetLargeLayoutBitmaps");
    $r.addProperty("Layout",2,$mod.$rtti["TTMSFNCToolBarButtonLayout"],"FLayout","SetLayout",4,{Default: $mod.TTMSFNCToolBarButtonLayout.bblNone});
    $r.addProperty("CompactLayout",2,$mod.$rtti["TTMSFNCToolBarButtonLayout"],"FCompactLayout","SetCompactLayout",4,{Default: $mod.TTMSFNCToolBarButtonLayout.bblNone});
    $r.addProperty("MinimumLayout",2,$mod.$rtti["TTMSFNCToolBarButtonLayout"],"FMinimumLayout","SetMinimumLayout",4,{Default: $mod.TTMSFNCToolBarButtonLayout.bblBitmap});
    $r.addProperty("MaximumLayout",2,$mod.$rtti["TTMSFNCToolBarButtonLayout"],"FMaximumLayout","SetMaximumLayout",4,{Default: $mod.TTMSFNCToolBarButtonLayout.bblLarge});
    $r.addProperty("BitmapPosition",2,$mod.$rtti["TTMSFNCToolBarButtonBitmapPosition"],"FBitmapPosition","SetBitmapPosition",4,{Default: $mod.TTMSFNCToolBarButtonBitmapPosition.bbpLeft});
    $r.addProperty("DisabledBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FDisabledBitmaps","SetDisabledBitmaps");
    $r.addProperty("HoverBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FHoverBitmaps","SetHoverBitmaps");
    $r.addProperty("LargeLayoutDisabledBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FLargeLayoutDisabledBitmaps","SetLargeLayoutDisabledBitmaps");
    $r.addProperty("LargeLayoutHoverBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FLargeLayoutHoverBitmaps","SetLargeLayoutHoverBitmaps");
    $r.addProperty("BitmapVisible",2,rtl.boolean,"FBitmapVisible","SetBitmapVisible",4,{Default: false});
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("BitmapSize",14,rtl.double,"FBitmapSize","SetBitmapSize",4,{stored: "IsBitmapSizeStored"});
    $r.addProperty("AutoBitmapSize",2,rtl.boolean,"FAutoBitmapSize","SetAutoBitmapSize",4,{Default: false});
    $r.addProperty("LargeLayoutBitmapSize",14,rtl.double,"FLargeLayoutBitmapSize","SetLargeLayoutBitmapSize",4,{stored: "IsLargeLayoutBitmapSizeStored"});
    $r.addProperty("LargeLayoutAutoBitmapSize",2,rtl.boolean,"FLargeLayoutAutoBitmapSize","SetLargeLayoutAutoBitmapSize",4,{Default: false});
    $r.addProperty("State",2,$mod.$rtti["TTMSFNCToolBarElementState"],"FState","SetState",4,{Default: $mod.TTMSFNCToolBarElementState.esNormal});
    $r.addProperty("LastElement",2,rtl.boolean,"FLastElement","SetLastElement",4,{Default: false});
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCToolBarButtonAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("WordWrapping",2,rtl.boolean,"FWordWrapping","SetWordWrapping",4,{Default: false});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$ClassRef("TTMSFNCToolBarButtonClass",{instancetype: this.$rtti["TTMSFNCToolBarButton"]});
  rtl.createClass(this,"TTMSFNCToolBarSeparator",this.TTMSFNCCustomToolBarSeparator,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarSeparator);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("State",2,$mod.$rtti["TTMSFNCToolBarElementState"],"FState","SetState",4,{Default: $mod.TTMSFNCToolBarElementState.esNormal});
    $r.addProperty("LastElement",2,rtl.boolean,"FLastElement","SetLastElement",4,{Default: false});
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCToolBarSeparatorAppearance"],"FAppearance","SetAppearance");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$ClassRef("TTMSFNCToolBarSeparatorClass",{instancetype: this.$rtti["TTMSFNCToolBarSeparator"]});
  this.$rtti.$MethodVar("TTMSFNCToolBarItemPickerItemSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCToolBarCustomItemPicker",this.TTMSFNCToolBarButton,function () {
    this.$init = function () {
      $mod.TTMSFNCToolBarButton.$init.call(this);
      this.FEdit = null;
      this.FTimer = null;
      this.FItemIndex = 0;
      this.FItems = null;
      this.FKeyboardUsed = false;
      this.FItemSelector = null;
      this.FOnItemSelected = null;
      this.FEditable = false;
      this.FOnEditChange = null;
    };
    this.$final = function () {
      this.FEdit = undefined;
      this.FTimer = undefined;
      this.FItems = undefined;
      this.FItemSelector = undefined;
      this.FOnItemSelected = undefined;
      this.FOnEditChange = undefined;
      $mod.TTMSFNCToolBarButton.$final.call(this);
    };
    this.GetSelectedItemIndex = function () {
      var Result = 0;
      Result = this.FItemIndex;
      return Result;
    };
    this.SetSelectedItemIndex = function (Value) {
      this.FItemIndex = Value;
      this.Invalidate();
    };
    this.GetSelectedItem = function () {
      var Result = "";
      Result = "";
      if ((this.FItems != null) && (this.FItemIndex >= 0) && (this.FItemIndex <= (this.FItems.GetCount() - 1))) Result = this.FItems.Get(this.FItemIndex);
      return Result;
    };
    this.SetSelectedItem = function (Value) {
      this.FItemIndex = this.FItems.IndexOf(Value);
      this.Invalidate();
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.SetEditable = function (Value) {
      if (this.FEditable !== Value) {
        this.FEditable = Value;
        if (this.FEdit != null) {
          if (this.FEditable) {
            this.FEdit.SetParent(this);
          } else this.FEdit.SetParent(null);
          this.FEdit.SetVisible(this.FEditable);
        };
        this.Invalidate();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      $mod.TTMSFNCCustomToolBarButton.ChangeDPIScale.apply(this,arguments);
    };
    this.CanChangeText = function () {
      var Result = false;
      Result = !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState);
      return Result;
    };
    this.GetText = function () {
      var Result = "";
      if (this.FEditable) {
        Result = this.FEdit.GetText()}
       else Result = this.GetSelectedItem();
      return Result;
    };
    this.EnterTimerChanged = function (Sender) {
      this.FEdit.SetFocus();
      this.FTimer.SetEnabled(false);
    };
    this.EditChange = function (Sender) {
      this.SetSelectedItem(this.FEdit.GetText());
      if (this.FOnEditChange != null) this.FOnEditChange(this);
    };
    this.HandleDialogKey = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDialogKey.apply(this,arguments);
      if (rtl.neSet(Shift,{})) return;
      if (this.FEditable && this.FEdit.IsFocused()) {
        var $tmp = Key.get();
        if ($tmp === 115) {
          if (!(pas.Classes.TShiftState$a.ssAlt in Shift)) this.DropDown();
        };
      };
    };
    this.InitializePopup = function () {
      this.FItemSelector.FItems.Clear();
      this.FItemSelector.FItems.Assign(this.FItems);
      this.FItemSelector.SetItemIndex(this.FItemIndex);
    };
    this.SelectValueWithString = function (AValue) {
      var I = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx(AValue + "*",this.FItems.Get(I),false)) {
          this.FItemIndex = I;
          this.DoItemSelected();
          this.Invalidate();
          break;
        };
      };
    };
    this.SelectValueWithCharacter = function (ACharacter) {
      var I = 0;
      $mod.TTMSFNCDefaultToolBarButton.SelectValueWithCharacter.apply(this,arguments);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx(ACharacter + "*",this.FItems.Get(I),false)) {
          this.FItemIndex = I;
          this.DoItemSelected();
          this.Invalidate();
          break;
        };
      };
    };
    this.SelectFirstValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectFirstValue.call(this);
      this.NotifyDataBinderEdit();
      this.FItemIndex = 0;
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.SelectLastValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectLastValue.call(this);
      this.NotifyDataBinderEdit();
      this.FItemIndex = this.FItems.GetCount() - 1;
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.SelectNextValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectNextValue.call(this);
      this.NotifyDataBinderEdit();
      if (this.FItemIndex === -1) {
        this.FItemIndex = 0}
       else this.FItemIndex = Math.min(this.FItems.GetCount() - 1,this.FItemIndex + 1);
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.SelectPreviousValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectPreviousValue.call(this);
      this.NotifyDataBinderEdit();
      if (this.FItemIndex === -1) {
        this.FItemIndex = 0}
       else this.FItemIndex = Math.max(0,this.FItemIndex - 1);
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.ItemKeyUp = function (Sender, Key, Shift) {
      if ((Key.get() === 13) || (Key.get() === 32)) {
        this.NotifyDataBinderEdit();
        this.FItemIndex = this.FItemSelector.GetItemIndex();
        this.NotifyDataBinderValueChanged();
        if (this.FCloseOnSelection) this.DropDown();
        this.DoItemSelected();
        this.Invalidate();
      };
      this.FKeyboardUsed = false;
    };
    this.ItemKeyDown = function (Sender, Key, Shift) {
      this.FKeyboardUsed = true;
    };
    this.ItemSelected = function (Sender) {
      if (this.FKeyboardUsed) return;
      this.NotifyDataBinderEdit();
      this.FItemIndex = this.FItemSelector.GetItemIndex();
      this.NotifyDataBinderValueChanged();
      if (this.FCloseOnSelection) this.DropDown();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.DoItemSelected = function () {
      if ((this.FEdit != null) && this.FEdit.HandleAllocated()) {
        this.FEdit.SetText(this.GetSelectedItem());
        this.FEdit.SetSelStart(this.FEdit.GetText().length);
      };
      if (this.FOnItemSelected != null) this.FOnItemSelected(this,this.GetSelectedItemIndex());
    };
    this.DoEnter = function () {
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      this.FTimer.SetEnabled(this.FEditable);
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomToolBarButton.Create$1.apply(this,arguments);
      this.FTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FTimer.SetInterval(1);
      this.FTimer.FOnTimer = rtl.createCallback(this,"EnterTimerChanged");
      this.FTimer.SetEnabled(false);
      this.FEdit = pas["WEBLib.StdCtrls"].TEdit.$create("Create$1",[this]);
      this.FEdit.SetTabStop(true);
      this.FEdit.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FEdit.FOnChange = rtl.createCallback(this,"EditChange");
      this.SetWidth(100);
      this.SetHeight(24);
      this.SetHorizontalTextAlign(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading);
      this.FItemIndex = -1;
      this.FItemSelector = pas["WEBLib.StdCtrls"].TListBox.$create("Create$1",[this]);
      this.FItemSelector.SetWidth(200);
      this.FItemSelector.SetHeight(150);
      this.FItemSelector.FFont.SetHeight(-11);
      this.FItemSelector.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FItemSelector.FOnClick = rtl.createCallback(this,"ItemSelected");
      this.FItemSelector.FOnKeyUp = rtl.createCallback(this,"ItemKeyUp");
      this.FItemSelector.FOnKeyDown = rtl.createCallback(this,"ItemKeyDown");
      this.SetDropDownControl(this.FItemSelector);
      this.SetDropDownKind($mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDownButton);
      this.SetDropDownWidth(this.FItemSelector.GetWidth());
      this.SetDropDownHeight(this.FItemSelector.GetHeight());
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      return this;
    };
    this.Draw = function (AGraphics, ARect) {
      if (!this.FEditable) $mod.TTMSFNCDefaultToolBarButton.Draw.apply(this,arguments);
    };
    this.Destroy = function () {
      rtl.free(this,"FTimer");
      rtl.free(this,"FItems");
      $mod.TTMSFNCCustomToolBarButton.Destroy.call(this);
    };
    this.DropDown = function () {
      $mod.TTMSFNCDefaultToolBarButton.DropDown.call(this);
      if (!(this.FPopup != null)) return;
      if (this.FPopup.FIsOpen && (this.FItemSelector != null)) {
        this.FItemSelector.SetItemIndex(-1);
        this.FItemSelector.SetItemIndex(this.GetSelectedItemIndex());
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCToolBarItemPicker",this.TTMSFNCToolBarCustomItemPicker,function () {
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCToolBarButton.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarItemPicker);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnItemSelected",0,$mod.$rtti["TTMSFNCToolBarItemPickerItemSelected"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("SelectedItemIndex",3,rtl.longint,"GetSelectedItemIndex","SetSelectedItemIndex",4,{Default: -1});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStringList"],"FItems","SetItems");
    $r.addProperty("Editable",2,rtl.boolean,"FEditable","SetEditable",4,{Default: false});
    $r.addProperty("OnEditChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEditChange","FOnEditChange");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCToolBarCustomComboBox",this.TTMSFNCToolBarButton,function () {
    this.$init = function () {
      $mod.TTMSFNCToolBarButton.$init.call(this);
      this.FEdit = null;
      this.FTimer = null;
      this.FItemIndex = 0;
      this.FItems = null;
      this.FKeyboardUsed = false;
      this.FItemSelector = null;
      this.FOnItemSelected = null;
      this.FEditable = false;
      this.FOnEditChange = null;
    };
    this.$final = function () {
      this.FEdit = undefined;
      this.FTimer = undefined;
      this.FItems = undefined;
      this.FItemSelector = undefined;
      this.FOnItemSelected = undefined;
      this.FOnEditChange = undefined;
      $mod.TTMSFNCToolBarButton.$final.call(this);
    };
    this.GetSelectedItemIndex = function () {
      var Result = 0;
      Result = this.FItemIndex;
      return Result;
    };
    this.SetSelectedItemIndex = function (Value) {
      this.FItemIndex = Value;
      this.Invalidate();
    };
    this.GetSelectedItem = function () {
      var Result = "";
      Result = "";
      if ((this.FItems != null) && (this.FItemIndex >= 0) && (this.FItemIndex <= (this.FItems.GetCount() - 1))) Result = this.FItems.Get(this.FItemIndex);
      return Result;
    };
    this.SetSelectedItem = function (Value) {
      this.FItemIndex = this.FItems.IndexOf(Value);
      this.Invalidate();
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.SetEditable = function (Value) {
      if (this.FEditable !== Value) {
        this.FEditable = Value;
        if (this.FEdit != null) {
          if (this.FEditable) {
            this.FEdit.SetParent(this);
          } else this.FEdit.SetParent(null);
          this.FEdit.SetVisible(this.FEditable);
        };
        this.Invalidate();
      };
    };
    this.ChangeDPIScale = function (M, D) {
      $mod.TTMSFNCCustomToolBarButton.ChangeDPIScale.apply(this,arguments);
    };
    this.CanChangeText = function () {
      var Result = false;
      Result = !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState);
      return Result;
    };
    this.GetText = function () {
      var Result = "";
      if (this.FEditable) {
        Result = this.FEdit.GetText()}
       else Result = this.GetSelectedItem();
      return Result;
    };
    this.EnterTimerChanged = function (Sender) {
      this.FEdit.SetFocus();
      this.FTimer.SetEnabled(false);
    };
    this.EditChange = function (Sender) {
      this.SetSelectedItem(this.FEdit.GetText());
      if (this.FOnEditChange != null) this.FOnEditChange(this);
    };
    this.HandleDialogKey = function (Key, Shift) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDialogKey.apply(this,arguments);
      if (rtl.neSet(Shift,{})) return;
      if (this.FEditable && this.FEdit.IsFocused()) {
        var $tmp = Key.get();
        if ($tmp === 115) {
          if (!(pas.Classes.TShiftState$a.ssAlt in Shift)) this.DropDown();
        };
      };
    };
    this.InitializePopup = function () {
      this.FItemSelector.BeginUpdate();
      this.FItemSelector.FItems.Clear$1();
      this.FItemSelector.LoadFromStrings(this.FItems);
      this.FItemSelector.SetItemIndex(this.FItemIndex);
      this.FItemSelector.EndUpdate();
    };
    this.SelectValueWithString = function (AValue) {
      var I = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx(AValue + "*",this.FItems.Get(I),false)) {
          this.FItemIndex = I;
          this.DoItemSelected();
          this.Invalidate();
          break;
        };
      };
    };
    this.SelectValueWithCharacter = function (ACharacter) {
      var I = 0;
      $mod.TTMSFNCDefaultToolBarButton.SelectValueWithCharacter.apply(this,arguments);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MatchStrEx(ACharacter + "*",this.FItems.Get(I),false)) {
          this.FItemIndex = I;
          this.DoItemSelected();
          this.Invalidate();
          break;
        };
      };
    };
    this.SelectFirstValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectFirstValue.call(this);
      this.NotifyDataBinderEdit();
      this.FItemIndex = 0;
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.SelectLastValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectLastValue.call(this);
      this.NotifyDataBinderEdit();
      this.FItemIndex = this.FItems.GetCount() - 1;
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.SelectNextValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectNextValue.call(this);
      this.NotifyDataBinderEdit();
      if (this.FItemIndex === -1) {
        this.FItemIndex = 0}
       else this.FItemIndex = Math.min(this.FItems.GetCount() - 1,this.FItemIndex + 1);
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.SelectPreviousValue = function () {
      $mod.TTMSFNCDefaultToolBarButton.SelectPreviousValue.call(this);
      this.NotifyDataBinderEdit();
      if (this.FItemIndex === -1) {
        this.FItemIndex = 0}
       else this.FItemIndex = Math.max(0,this.FItemIndex - 1);
      this.NotifyDataBinderValueChanged();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.ItemKeyUp = function (Sender, Key, Shift) {
      if ((Key.get() === 13) || (Key.get() === 32)) {
        this.NotifyDataBinderEdit();
        this.FItemIndex = this.FItemSelector.GetItemIndex();
        this.NotifyDataBinderValueChanged();
        if (this.FCloseOnSelection) this.DropDown();
        this.DoItemSelected();
        this.Invalidate();
      };
      this.FKeyboardUsed = false;
    };
    this.ItemKeyDown = function (Sender, Key, Shift) {
      this.FKeyboardUsed = true;
    };
    this.ItemSelected = function (Sender, AItem) {
      if (this.FKeyboardUsed) return;
      this.NotifyDataBinderEdit();
      this.FItemIndex = this.FItemSelector.GetItemIndex();
      this.NotifyDataBinderValueChanged();
      if (this.FCloseOnSelection) this.DropDown();
      this.DoItemSelected();
      this.Invalidate();
    };
    this.DoItemSelected = function () {
      if ((this.FEdit != null) && this.FEdit.HandleAllocated()) {
        this.FEdit.SetText(this.GetSelectedItem());
        this.FEdit.SetSelStart(this.FEdit.GetText().length);
      };
      if (this.FOnItemSelected != null) this.FOnItemSelected(this,this.GetSelectedItemIndex());
    };
    this.DoEnter = function () {
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      this.FTimer.SetEnabled(this.FEditable);
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomToolBarButton.Create$1.apply(this,arguments);
      this.FTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FTimer.SetInterval(1);
      this.FTimer.FOnTimer = rtl.createCallback(this,"EnterTimerChanged");
      this.FTimer.SetEnabled(false);
      this.FEdit = pas["WEBLib.StdCtrls"].TEdit.$create("Create$1",[this]);
      this.FEdit.SetTabStop(true);
      this.FEdit.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FEdit.FOnChange = rtl.createCallback(this,"EditChange");
      this.SetWidth(100);
      this.SetHeight(24);
      this.SetHorizontalTextAlign(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading);
      this.FItemIndex = -1;
      this.FItemSelector = pas["WEBLib.TMSFNCListBox"].TTMSFNCListBox.$create("Create$1",[this]);
      this.FItemSelector.SetWidth(200);
      this.FItemSelector.SetHeight(150);
      this.FItemSelector.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FItemSelector.FOnItemSelected = rtl.createCallback(this,"ItemSelected");
      this.FItemSelector.FOnKeyUp = rtl.createCallback(this,"ItemKeyUp");
      this.FItemSelector.FOnKeyDown = rtl.createCallback(this,"ItemKeyDown");
      this.SetDropDownControl(this.FItemSelector);
      this.SetDropDownKind($mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDownButton);
      this.SetDropDownWidth(this.FItemSelector.GetWidth());
      this.SetDropDownHeight(this.FItemSelector.GetHeight());
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      return this;
    };
    this.Draw = function (AGraphics, ARect) {
      if (!this.FEditable) $mod.TTMSFNCDefaultToolBarButton.Draw.apply(this,arguments);
    };
    this.Destroy = function () {
      rtl.free(this,"FTimer");
      rtl.free(this,"FItems");
      $mod.TTMSFNCCustomToolBarButton.Destroy.call(this);
    };
    this.DropDown = function () {
      $mod.TTMSFNCDefaultToolBarButton.DropDown.call(this);
      if (!(this.FPopup != null)) return;
      if (this.FPopup.FIsOpen && (this.FItemSelector != null)) {
        this.FItemSelector.SetItemIndex(-1);
        this.FItemSelector.SetItemIndex(this.GetSelectedItemIndex());
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCToolBarComboBox",this.TTMSFNCToolBarCustomComboBox,function () {
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCToolBarButton.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarComboBox);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnItemSelected",0,$mod.$rtti["TTMSFNCToolBarItemPickerItemSelected"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("SelectedItemIndex",3,rtl.longint,"GetSelectedItemIndex","SetSelectedItemIndex",4,{Default: -1});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStringList"],"FItems","SetItems");
    $r.addProperty("Editable",2,rtl.boolean,"FEditable","SetEditable",4,{Default: false});
    $r.addProperty("OnEditChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEditChange","FOnEditChange");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$MethodVar("TTMSFNCToolBarFontNamePickerFontNameSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFontName",rtl.string]]), methodkind: 0});
  this.$rtti.$ClassRef("TTMSFNCToolBarItemPickerClass",{instancetype: this.$rtti["TTMSFNCToolBarItemPicker"]});
  rtl.createClass(this,"TTMSFNCToolBarFontNamePicker",this.TTMSFNCToolBarCustomItemPicker,function () {
    this.$init = function () {
      $mod.TTMSFNCToolBarCustomItemPicker.$init.call(this);
      this.FOnFontNameSelected = null;
    };
    this.$final = function () {
      this.FOnFontNameSelected = undefined;
      $mod.TTMSFNCToolBarCustomItemPicker.$final.call(this);
    };
    this.GetSelectedFontName = function () {
      var Result = "";
      Result = this.GetSelectedItem();
      return Result;
    };
    this.SetSelectedFontName = function (Value) {
      this.SetSelectedItem(Value);
    };
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCToolBarButton.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarFontNamePicker);
    };
    this.DoItemSelected = function () {
      $mod.TTMSFNCToolBarCustomItemPicker.DoItemSelected.call(this);
      if (this.FOnFontNameSelected != null) this.FOnFontNameSelected(this,this.GetSelectedFontName());
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCToolBarCustomItemPicker.Create$1.apply(this,arguments);
      this.FAutoOptionsMenuText = "Font Name";
      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetFonts(this.FItems);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnFontNameSelected",0,$mod.$rtti["TTMSFNCToolBarFontNamePickerFontNameSelected"],"FOnFontNameSelected","FOnFontNameSelected");
    $r.addProperty("CloseOnSelection",2,rtl.boolean,"FCloseOnSelection","SetCloseOnSelection",4,{Default: true});
    $r.addProperty("Editable",2,rtl.boolean,"FEditable","SetEditable",4,{Default: false});
    $r.addProperty("OnEditChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEditChange","FOnEditChange");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$MethodVar("TTMSFNCToolBarFontSizePickerFontSizeSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFontSize",rtl.double]]), methodkind: 0});
  this.$rtti.$ClassRef("TTMSFNCToolBarFontNamePickerClass",{instancetype: this.$rtti["TTMSFNCToolBarFontNamePicker"]});
  rtl.createClass(this,"TTMSFNCToolBarFontSizePicker",this.TTMSFNCToolBarCustomItemPicker,function () {
    this.$init = function () {
      $mod.TTMSFNCToolBarCustomItemPicker.$init.call(this);
      this.FOnFontSizeSelected = null;
    };
    this.$final = function () {
      this.FOnFontSizeSelected = undefined;
      $mod.TTMSFNCToolBarCustomItemPicker.$final.call(this);
    };
    this.GetSelectedFontSize = function () {
      var Result = 0.0;
      var s = "";
      Result = -1;
      s = this.GetSelectedItem();
      if (s !== "") Result = pas.SysUtils.StrToFloat(this.GetSelectedItem());
      return Result;
    };
    this.SetSelectedFontSize = function (Value) {
      this.SetSelectedItem(pas.SysUtils.FloatToStr(Value));
    };
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCToolBarButton.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarFontSizePicker);
    };
    this.DoItemSelected = function () {
      $mod.TTMSFNCToolBarCustomItemPicker.DoItemSelected.call(this);
      if (this.FOnFontSizeSelected != null) this.FOnFontSizeSelected(this,this.GetSelectedFontSize());
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCToolBarCustomItemPicker.Create$1.apply(this,arguments);
      this.FAutoOptionsMenuText = "Font Size";
      this.FItems.Add("8");
      this.FItems.Add("9");
      this.FItems.Add("10");
      this.FItems.Add("11");
      this.FItems.Add("12");
      this.FItems.Add("14");
      this.FItems.Add("16");
      this.FItems.Add("18");
      this.FItems.Add("20");
      this.FItems.Add("22");
      this.FItems.Add("24");
      this.FItems.Add("26");
      this.FItems.Add("28");
      this.FItems.Add("36");
      this.FItems.Add("48");
      this.FItems.Add("72");
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnFontSizeSelected",0,$mod.$rtti["TTMSFNCToolBarFontSizePickerFontSizeSelected"],"FOnFontSizeSelected","FOnFontSizeSelected");
    $r.addProperty("CloseOnSelection",2,rtl.boolean,"FCloseOnSelection","SetCloseOnSelection",4,{Default: true});
    $r.addProperty("Editable",2,rtl.boolean,"FEditable","SetEditable",4,{Default: false});
    $r.addProperty("OnEditChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEditChange","FOnEditChange");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$MethodVar("TTMSFNCToolBarColorPickerColorSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"]]]), methodkind: 0});
  this.$rtti.$ClassRef("TTMSFNCToolBarFontSizePickerClass",{instancetype: this.$rtti["TTMSFNCToolBarFontSizePicker"]});
  rtl.createClass(this,"TTMSFNCToolBarColorPicker",this.TTMSFNCToolBarButton,function () {
    this.$init = function () {
      $mod.TTMSFNCToolBarButton.$init.call(this);
      this.FColorSelector = null;
      this.FOnColorSelected = null;
    };
    this.$final = function () {
      this.FColorSelector = undefined;
      this.FOnColorSelected = undefined;
      $mod.TTMSFNCToolBarButton.$final.call(this);
    };
    this.GetSelectedColor = function () {
      var Result = 0;
      Result = this.FColorSelector.GetSelectedColor();
      return Result;
    };
    this.SetSelectedColor = function (Value) {
      this.FColorSelector.SetSelectedColor(Value);
      this.Invalidate();
    };
    this.GetSelectedItemIndex = function () {
      var Result = 0;
      Result = this.FColorSelector.FSelectedItemIndex;
      return Result;
    };
    this.SetSelectedItemIndex = function (Value) {
      this.FColorSelector.SetSelectedItemIndex(Value);
      this.Invalidate();
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FColorSelector.GetItems();
      return Result;
    };
    this.SetItems = function (Value) {
      this.FColorSelector.GetItems().Assign(Value);
    };
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCToolBarButton.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarColorPicker);
    };
    this.SetAdaptToStyle = function (Value) {
      $mod.TTMSFNCCustomToolBarButton.SetAdaptToStyle.apply(this,arguments);
      if (this.FColorSelector != null) this.FColorSelector.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.DrawColor = function (AColor, ARect, AGraphics) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rounding = 0;
      var I = 0;
      var J = 0;
      var st = null;
      r.$assign(ARect);
      rounding = Math.round(Math.max(this.ScalePaintValue$1(3.5),this.FAppearance.FRounding / 4));
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-rounding,-rounding);
      pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(r,this.ScalePaintValue$1(0.5),this.ScalePaintValue$1(0.5));
      st = AGraphics.SaveState(false);
      try {
        AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
        AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AGraphics.FStroke.SetWidth(1);
        AGraphics.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(255,255,255));
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        AGraphics.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(211,211,211));
        for (var $l = 0, $end = pas.System.Trunc((r.Right - r.Left) / 5) + 1; $l <= $end; $l++) {
          I = $l;
          for (var $l1 = 0, $end1 = pas.System.Trunc((r.Bottom - r.Top) / 5) + 1; $l1 <= $end1; $l1++) {
            J = $l1;
            if (pas.System.Odd(I + J)) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(I * 5,J * 5,(I + 1) * 5,(J + 1) * 5)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmNone);
          };
        };
        AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AGraphics.FFill.SetColor(AColor);
        AGraphics.FStroke.SetColor(0);
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      } finally {
        AGraphics.RestoreState(st,false);
      };
    };
    this.ColorSelected = function (Sender, AColor) {
      if (this.FCloseOnSelection && !this.BlockChange()) this.CloseDropDown();
      this.DoColorSelected(AColor);
      this.Invalidate();
    };
    this.DoColorSelected = function (AColor) {
      if (this.FOnColorSelected != null) this.FOnColorSelected(this,AColor);
    };
    this.CanChangeText = function () {
      var Result = false;
      Result = !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState);
      return Result;
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomToolBarButton.Create$1.apply(this,arguments);
      this.SetWidth(40);
      this.SetHeight(24);
      this.FAutoOptionsMenuText = "Color";
      this.FColorSelector = pas["WEBLib.TMSFNCColorSelector"].TTMSFNCColorSelector.$create("Create$1",[this]);
      this.FColorSelector.FAppearance.SetHorizontalSpacing(2);
      this.FColorSelector.FAppearance.SetVerticalSpacing(2);
      this.FColorSelector.SetMode(pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelectorMode.csmExtended);
      this.FColorSelector.SetWidth(175);
      this.FColorSelector.SetHeight(125);
      this.FColorSelector.FStored = false;
      this.FColorSelector.SetSelectedColor(0);
      this.FColorSelector.FOnColorSelected = rtl.createCallback(this,"ColorSelected");
      this.SetDropDownControl(this.FColorSelector);
      this.SetDropDownWidth(this.FColorSelector.GetWidth());
      this.SetDropDownHeight(this.FColorSelector.GetHeight());
      this.SetDropDownKind($mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDownButton);
      return this;
    };
    this.BlockChange = function () {
      var Result = false;
      Result = this.FColorSelector.FBlockChange;
      return Result;
    };
    this.ColorSelector = function () {
      var Result = null;
      Result = this.FColorSelector;
      return Result;
    };
    this.Draw = function (AGraphics, ARect) {
      $mod.TTMSFNCDefaultToolBarButton.Draw.apply(this,arguments);
      this.DrawSelectedColor(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DrawSelectedColor = function (AGraphics, ARect) {
      var R = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var c = 0;
      var ct = null;
      ct = this.GetDropDownButtonControl();
      if (ct != null) {
        R.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.GetWidth() - ct.GetWidth(),this.GetHeight()));
        c = this.GetSelectedColor();
        this.DrawColor(c,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(R),AGraphics);
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnColorSelected",0,$mod.$rtti["TTMSFNCToolBarColorPickerColorSelected"],"FOnColorSelected","FOnColorSelected");
    $r.addProperty("SelectedColor",3,pas["WEBLib.Graphics"].$rtti["TColor"],"GetSelectedColor","SetSelectedColor",4,{Default: -1});
    $r.addProperty("SelectedItemIndex",3,rtl.longint,"GetSelectedItemIndex","SetSelectedItemIndex");
    $r.addProperty("Items",3,pas["WEBLib.TMSFNCColorSelector"].$rtti["TTMSFNCColorSelectorItems"],"GetItems","SetItems");
    $r.addProperty("CloseOnSelection",2,rtl.boolean,"FCloseOnSelection","SetCloseOnSelection",4,{Default: true});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$MethodVar("TTMSFNCToolBarBitmapPickerBitmapSelected",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABitmap",pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"]]]), methodkind: 0});
  this.$rtti.$ClassRef("TTMSFNCToolBarColorPickerClass",{instancetype: this.$rtti["TTMSFNCToolBarColorPicker"]});
  rtl.createClass(this,"TTMSFNCToolBarBitmapPicker",this.TTMSFNCToolBarButton,function () {
    this.$init = function () {
      $mod.TTMSFNCToolBarButton.$init.call(this);
      this.FBitmapSelector = null;
      this.FOnBitmapSelected = null;
    };
    this.$final = function () {
      this.FBitmapSelector = undefined;
      this.FOnBitmapSelected = undefined;
      $mod.TTMSFNCToolBarButton.$final.call(this);
    };
    this.GetSelectedBitmap = function () {
      var Result = null;
      Result = this.FBitmapSelector.GetSelectedBitmap();
      return Result;
    };
    this.GetSelectedItemIndex = function () {
      var Result = 0;
      Result = this.FBitmapSelector.FSelectedItemIndex;
      return Result;
    };
    this.SetSelectedItemIndex = function (Value) {
      this.FBitmapSelector.SetSelectedItemIndex(Value);
      this.FBitmaps.Clear();
      this.FDisabledBitmaps.Clear();
      this.FHoverBitmaps.Clear();
      this.FBitmaps.AddBitmap(this.GetSelectedBitmap(),1.0);
      this.FDisabledBitmaps.AddBitmap(this.GetSelectedBitmap(),1.0);
      this.FHoverBitmaps.AddBitmap(this.GetSelectedBitmap(),1.0);
      this.Invalidate();
    };
    this.GetItems = function () {
      var Result = null;
      Result = this.FBitmapSelector.GetItems();
      return Result;
    };
    this.SetItems = function (Value) {
      if (this.FBitmapSelector != null) this.FBitmapSelector.GetItems().Assign(Value);
    };
    this.SetBitmapContainer = function (Value) {
      $mod.TTMSFNCDefaultToolBarButton.SetBitmapContainer.apply(this,arguments);
      if (this.FBitmapSelector != null) this.FBitmapSelector.SetBitmapContainer(Value);
    };
    this.GetBitmapRect$1 = function (ARect) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(ARect);
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right,r.Bottom));
      if (this.FBitmapVisible) {
        if (this.FDropDownKind !== $mod.TTMSFNCToolBarButtonDropDownKind.ddkNormal) {
          dr.$assign(this.GetDropDownRect());
          var $tmp = this.FDropDownPosition;
          if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpRight) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,dr.Left - 3,Result.Bottom - 3))}
           else if ($tmp === $mod.TTMSFNCToolBarButtonDropDownPosition.ddpBottom) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,Result.Right - 3,dr.Top - 3));
        } else Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(Result.Left + 3,Result.Top + 3,Result.Right - 3,Result.Bottom - 3));
      };
      return Result;
    };
    this.CanChangeText = function () {
      var Result = false;
      Result = !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState);
      return Result;
    };
    this.RegisterRuntimeClasses = function () {
      $mod.TTMSFNCToolBarButton.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarBitmapPicker);
    };
    this.SetAdaptToStyle = function (Value) {
      $mod.TTMSFNCCustomToolBarButton.SetAdaptToStyle.apply(this,arguments);
      if (this.FBitmapSelector != null) this.FBitmapSelector.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.BitmapSelected = function (Sender, ABitmap) {
      this.FBitmaps.Clear();
      this.FDisabledBitmaps.Clear();
      this.FHoverBitmaps.Clear();
      this.FBitmaps.AddBitmap(ABitmap,1.0);
      this.FDisabledBitmaps.AddBitmap(ABitmap,1.0);
      this.FHoverBitmaps.AddBitmap(ABitmap,1.0);
      if (this.FCloseOnSelection && !this.BlockChange()) this.CloseDropDown();
      this.DoBitmapSelected(ABitmap);
    };
    this.DoBitmapSelected = function (ABitmap) {
      if (this.FOnBitmapSelected != null) this.FOnBitmapSelected(this,ABitmap);
    };
    this.Create$1 = function (AOwner) {
      $mod.TTMSFNCCustomToolBarButton.Create$1.apply(this,arguments);
      this.SetWidth(40);
      this.SetHeight(24);
      this.FAutoOptionsMenuText = "Bitmap";
      this.FBitmapSelector = pas["WEBLib.TMSFNCBitmapSelector"].TTMSFNCBitmapSelector.$create("Create$1",[this]);
      this.FBitmapSelector.FAppearance.SetHorizontalSpacing(2);
      this.FBitmapSelector.FAppearance.SetVerticalSpacing(2);
      this.FBitmapSelector.FStored = false;
      this.FBitmapSelector.FOnBitmapSelected = rtl.createCallback(this,"BitmapSelected");
      this.SetDropDownControl(this.FBitmapSelector);
      this.SetDropDownWidth(this.FBitmapSelector.GetWidth());
      this.SetDropDownHeight(this.FBitmapSelector.GetHeight());
      this.SetDropDownKind($mod.TTMSFNCToolBarButtonDropDownKind.ddkDropDownButton);
      return this;
    };
    this.BlockChange = function () {
      var Result = false;
      Result = this.FBitmapSelector.FBlockChange;
      return Result;
    };
    this.BitmapSelector = function () {
      var Result = null;
      Result = this.FBitmapSelector;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnBitmapSelected",0,$mod.$rtti["TTMSFNCToolBarBitmapPickerBitmapSelected"],"FOnBitmapSelected","FOnBitmapSelected");
    $r.addProperty("SelectedItemIndex",3,rtl.longint,"GetSelectedItemIndex","SetSelectedItemIndex");
    $r.addProperty("Items",3,pas["WEBLib.TMSFNCBitmapSelector"].$rtti["TTMSFNCBitmapSelectorItems"],"GetItems","SetItems");
    $r.addProperty("CloseOnSelection",2,rtl.boolean,"FCloseOnSelection","SetCloseOnSelection",4,{Default: true});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  this.$rtti.$ClassRef("TTMSFNCToolBarBitmapPickerClass",{instancetype: this.$rtti["TTMSFNCToolBarBitmapPicker"]});
  rtl.createClass(this,"TTMSFNCCustomToolBarAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FFill = null;
      this.FStroke = null;
      this.FVerticalSpacing = 0.0;
      this.FHorizontalSpacing = 0.0;
      this.FDragGripColor = 0;
      this.FDragGrip = false;
      this.FFlatStyle = false;
      this.FFont = null;
      this.FSeparatorStroke = null;
      this.FSeparator = false;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FFont = undefined;
      this.FSeparatorStroke = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetHorizontalSpacing = function (Value) {
      if (this.FHorizontalSpacing !== Value) {
        this.FHorizontalSpacing = Value;
        this.FOwner.UpdateControls();
      };
    };
    this.SetVerticalSpacing = function (Value) {
      if (this.FVerticalSpacing !== Value) {
        this.FVerticalSpacing = Value;
        this.FOwner.UpdateControls();
      };
    };
    this.SetDragGrip = function (Value) {
      if (this.FDragGrip !== Value) {
        this.FDragGrip = Value;
        this.FOwner.UpdateControls();
      };
    };
    this.SetDragGripColor = function (Value) {
      if (this.FDragGripColor !== Value) {
        this.FDragGripColor = Value;
        this.FOwner.Invalidate();
      };
    };
    this.IsHorizontalSpacingStored = function () {
      var Result = false;
      Result = this.FHorizontalSpacing !== 3;
      return Result;
    };
    this.IsVerticalSpacingStored = function () {
      var Result = false;
      Result = this.FVerticalSpacing !== 3;
      return Result;
    };
    this.SetFlatStyle = function (Value) {
      if (this.FFlatStyle !== Value) {
        this.FFlatStyle = Value;
        if (this.FOwner != null) this.FOwner.ApplyFlatStyle();
      };
    };
    this.SetSeparator = function (Value) {
      if (this.FSeparator !== Value) {
        this.FSeparator = Value;
        this.FOwner.Invalidate();
      };
    };
    this.SetSeparatorStroke = function (Value) {
      this.FSeparatorStroke.Assign(Value);
    };
    this.FillChanged = function (Sender) {
      this.FOwner.Invalidate();
    };
    this.StrokeChanged = function (Sender) {
      this.FOwner.Invalidate();
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomToolBarAppearance.isPrototypeOf(Source)) {
        this.FSeparatorStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FSeparatorStroke);
        this.FSeparator = rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FSeparator;
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FStroke);
        this.FHorizontalSpacing = rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FHorizontalSpacing;
        this.FVerticalSpacing = rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FVerticalSpacing;
        this.FDragGripColor = rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FDragGripColor;
        this.FDragGrip = rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FDragGrip;
        this.FFlatStyle = rtl.as(Source,$mod.TTMSFNCCustomToolBarAppearance).FFlatStyle;
      };
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFlatStyle = false;
      this.FHorizontalSpacing = 3;
      this.FVerticalSpacing = 3;
      this.FDragGrip = true;
      this.FDragGripColor = 13882323;
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient,16777215,pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(230,230,230),-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FSeparatorStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,16777215,1.0]);
      this.FSeparatorStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FSeparatorStroke");
      rtl.free(this,"FFont");
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCToolBarAppearance",this.TTMSFNCCustomToolBarAppearance,function () {
    var $r = this.$rtti;
    $r.addProperty("FlatStyle",2,rtl.boolean,"FFlatStyle","SetFlatStyle",4,{Default: false});
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("Separator",2,rtl.boolean,"FSeparator","SetSeparator",4,{Default: false});
    $r.addProperty("SeparatorStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FSeparatorStroke","SetSeparatorStroke");
    $r.addProperty("HorizontalSpacing",14,rtl.double,"FHorizontalSpacing","SetHorizontalSpacing",4,{stored: "IsHorizontalSpacingStored"});
    $r.addProperty("VerticalSpacing",14,rtl.double,"FVerticalSpacing","SetVerticalSpacing",4,{stored: "IsVerticalSpacingStored"});
    $r.addProperty("DragGrip",2,rtl.boolean,"FDragGrip","SetDragGrip",4,{Default: true});
    $r.addProperty("DragGripColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDragGripColor","SetDragGripColor",4,{Default: 13882323});
  });
  rtl.createClass(this,"TTMSFNCToolBarOptionMenuItem",pas["WEBLib.Menus"].TMenuItem,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TMenuItem.$init.call(this);
      this.FControl = null;
      this.FGlyphWidth = 0.0;
      this.FCalculate = false;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas["WEBLib.Menus"].TMenuItem.$final.call(this);
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCToolBarControl",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FControlIndex = 0;
      this.FControl = null;
      this.FLayout = 0;
      this.FBitmap = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      this.FBitmap = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function () {
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.$rtti.$ClassRef("TControlClass",{instancetype: pas["WEBLib.Controls"].$rtti["TControl"]});
  this.$rtti.$MethodVar("TTMSFNCToolBarCustomizeOptionsMenu",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["APopupMenu",pas["WEBLib.Menus"].$rtti["TPopupMenu"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCToolBarCustomizeOptionsMenuItem",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AControl",pas["WEBLib.Controls"].$rtti["TControl"]],["AMenuItem",pas["WEBLib.Menus"].$rtti["TMenuItem"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCToolBarCanShowOptionsMenuItem",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AControl",pas["WEBLib.Controls"].$rtti["TControl"]],["ACanShowItem",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCToolBarOptionsMenuItemClick",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AControl",pas["WEBLib.Controls"].$rtti["TControl"]],["AMenuItem",pas["WEBLib.Menus"].$rtti["TMenuItem"]],["AExecuteDefaultAction",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCToolBarIsLastElement",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AControl",pas["WEBLib.Controls"].$rtti["TControl"]],["AIsLastElement",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCToolBarAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AAnchor",rtl.string]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomToolBarOptionsMenu",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FShowItemText = false;
      this.FShowItemBitmap = false;
      this.FShowButton = false;
      this.FItemBitmapWidth = 0.0;
      this.FAutoItemBitmapWidth = false;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetShowButton = function (Value) {
      if (this.FShowButton !== Value) {
        this.FShowButton = Value;
        this.FOwner.FOptionsMenuButton.SetVisible(this.FShowButton);
        if (this.FShowButton) {
          this.FOwner.FOptionsMenuButton.SetParent(this.FOwner)}
         else this.FOwner.FOptionsMenuButton.SetParent(null);
        this.FOwner.UpdateControls();
      };
    };
    this.SetShowItemBitmap = function (Value) {
      if (this.FShowItemBitmap !== Value) {
        this.FShowItemBitmap = Value;
      };
    };
    this.SetShowItemText = function (Value) {
      if (this.FShowItemText !== Value) {
        this.FShowItemText = Value;
      };
    };
    this.SetAutoItemBitmapWidth = function (Value) {
      if (this.FAutoItemBitmapWidth !== Value) {
        this.FAutoItemBitmapWidth = Value;
      };
    };
    this.SetItemBitmapWidth = function (Value) {
      if (this.FItemBitmapWidth !== Value) {
        this.FItemBitmapWidth = Value;
      };
    };
    this.IsItemBitmapWidthStored = function () {
      var Result = false;
      Result = this.FItemBitmapWidth !== 50;
      return Result;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomToolBarOptionsMenu.isPrototypeOf(Source)) {
        this.FShowItemText = rtl.as(Source,$mod.TTMSFNCCustomToolBarOptionsMenu).FShowItemText;
        this.FShowItemBitmap = rtl.as(Source,$mod.TTMSFNCCustomToolBarOptionsMenu).FShowItemBitmap;
        this.FShowButton = rtl.as(Source,$mod.TTMSFNCCustomToolBarOptionsMenu).FShowButton;
        this.FAutoItemBitmapWidth = rtl.as(Source,$mod.TTMSFNCCustomToolBarOptionsMenu).FAutoItemBitmapWidth;
        this.FItemBitmapWidth = rtl.as(Source,$mod.TTMSFNCCustomToolBarOptionsMenu).FItemBitmapWidth;
      };
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FShowItemText = true;
      this.FShowButton = true;
      this.FShowItemBitmap = true;
      this.FAutoItemBitmapWidth = true;
      this.FItemBitmapWidth = 50;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCToolBarOptionsMenu",this.TTMSFNCCustomToolBarOptionsMenu,function () {
    var $r = this.$rtti;
    $r.addProperty("ShowButton",2,rtl.boolean,"FShowButton","SetShowButton",4,{Default: true});
    $r.addProperty("ShowItemBitmap",2,rtl.boolean,"FShowItemBitmap","SetShowItemBitmap",4,{Default: true});
    $r.addProperty("ShowItemText",2,rtl.boolean,"FShowItemText","SetShowItemText",4,{Default: true});
    $r.addProperty("AutoItemBitmapWidth",2,rtl.boolean,"FAutoItemBitmapWidth","SetAutoItemBitmapWidth",4,{Default: true});
    $r.addProperty("ItemBitmapWidth",14,rtl.double,"FItemBitmapWidth","SetItemBitmapWidth",4,{stored: "IsItemBitmapWidthStored"});
  });
  rtl.createClass(this,"TTMSFNCToolBarControlObjectList",pas.contnrs.TObjectList,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCToolBarControlList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TTMSFNCControlList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  this.$rtti.$MethodVar("TTMSFNCToolBarDragGripMovingEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DeltaX",rtl.double],["DeltaY",rtl.double]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCToolBarPopup",pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TTMSFNCToolBar");
  this.$rtti.$MethodVar("TTMSFNCToolBarCustomizeCompactToolBarEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACompactToolBar",this.$rtti["TTMSFNCToolBar"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomToolBar",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FCompactToolbar = null;
      this.FCompactPopup = null;
      this.FHover = false;
      this.FHoverP = false;
      this.FQuickMenuButtonHover = false;
      this.FQuickMenuButtonHoverP = false;
      this.FDown = false;
      this.FQuickMenuButtonDown = false;
      this.FOldWidth = 0.0;
      this.FOldMenuButtonState = false;
      this.FBitmapContainer = null;
      this.FInsideDrag = false;
      this.FDragGripMoving = false;
      this.FDragGripDown = false;
      this.FDragGripDownPt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      this.FTotalOptionsMenuWidth = 0.0;
      this.FHiddenControls = null;
      this.FCompactControls = null;
      this.FBlockUpdate = false;
      this.FBlockResize = false;
      this.FAutoSize = false;
      this.FAppearance = null;
      this.FAutoAlign = false;
      this.FOptionsMenuButton = null;
      this.FAutoOptionsMenu = null;
      this.FOnOptionsMenuCustomize = null;
      this.FOnOptionsMenuItemCustomize = null;
      this.FOnOptionsMenuButtonClick = null;
      this.FOptionsMenu = null;
      this.FCustomOptionsMenu = null;
      this.FOnOptionsMenuItemCanShow = null;
      this.FState = 0;
      this.FOnOptionsMenuItemClick = null;
      this.FOnOptionsMenuItemApplyStyle = null;
      this.FOnUpdateDockPanel = null;
      this.FOnUpdateControls = null;
      this.FOnIsLastElement = null;
      this.FOnDragGripMoving = null;
      this.FAutoMoveToolBar = false;
      this.FOnInternalDblClick$1 = null;
      this.FOnInternalMouseDown$1 = null;
      this.FOnInternalMouseMove$1 = null;
      this.FOnInternalMouseUp$1 = null;
      this.FAutoHeight = false;
      this.FAutoWidth = false;
      this.FOnInternalInsertControl = null;
      this.FAutoStretchHeight = false;
      this.FText = "";
      this.FFirstLoad = false;
      this.FFont$1 = null;
      this.FVerticalTextAlign = 0;
      this.FTrimming = 0;
      this.FHorizontalTextAlign = 0;
      this.FWordWrapping = false;
      this.FTextVisible = false;
      this.FMinimumWidth = 0.0;
      this.FCompact = false;
      this.FCanCompact = false;
      this.FCompactWidth = 0.0;
      this.FCompactAppearance = null;
      this.FCompactBitmaps = null;
      this.FOnCompactClick = null;
      this.FCompactBitmapSize = 0.0;
      this.FCompactBitmapVisible = false;
      this.FCompactExpanderBitmaps = null;
      this.FQuickMenuButton = false;
      this.FQuickMenuButtonAppearance = null;
      this.FOnQuickMenuButtonClick = null;
      this.FQuickMenuButtonBitmaps = null;
      this.FQuickMenuButtonHint = "";
      this.FCompactAutoBitmapSize = false;
      this.FOnAnchorClick = null;
      this.FDisabledFontColor = 0;
      this.FOnCustomizeCompactToolBar = null;
    };
    this.$final = function () {
      this.FCompactToolbar = undefined;
      this.FCompactPopup = undefined;
      this.FBitmapContainer = undefined;
      this.FDragGripDownPt = undefined;
      this.FHiddenControls = undefined;
      this.FCompactControls = undefined;
      this.FAppearance = undefined;
      this.FOptionsMenuButton = undefined;
      this.FAutoOptionsMenu = undefined;
      this.FOnOptionsMenuCustomize = undefined;
      this.FOnOptionsMenuItemCustomize = undefined;
      this.FOnOptionsMenuButtonClick = undefined;
      this.FOptionsMenu = undefined;
      this.FCustomOptionsMenu = undefined;
      this.FOnOptionsMenuItemCanShow = undefined;
      this.FOnOptionsMenuItemClick = undefined;
      this.FOnOptionsMenuItemApplyStyle = undefined;
      this.FOnUpdateDockPanel = undefined;
      this.FOnUpdateControls = undefined;
      this.FOnIsLastElement = undefined;
      this.FOnDragGripMoving = undefined;
      this.FOnInternalDblClick$1 = undefined;
      this.FOnInternalMouseDown$1 = undefined;
      this.FOnInternalMouseMove$1 = undefined;
      this.FOnInternalMouseUp$1 = undefined;
      this.FOnInternalInsertControl = undefined;
      this.FFont$1 = undefined;
      this.FCompactAppearance = undefined;
      this.FCompactBitmaps = undefined;
      this.FOnCompactClick = undefined;
      this.FCompactExpanderBitmaps = undefined;
      this.FQuickMenuButtonAppearance = undefined;
      this.FOnQuickMenuButtonClick = undefined;
      this.FQuickMenuButtonBitmaps = undefined;
      this.FOnAnchorClick = undefined;
      this.FOnCustomizeCompactToolBar = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
    };
    this.SetAS = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateControls();
      };
    };
    this.SetAutoAlign = function (Value) {
      if (this.FAutoAlign !== Value) {
        this.FAutoAlign = Value;
        this.UpdateControls();
      };
    };
    this.SetOptionsMenu = function (Value) {
      this.FOptionsMenu.Assign(Value);
    };
    this.SetState = function (Value) {
      var I = 0;
      var c = null;
      if (this.FState !== Value) {
        this.FState = Value;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          c = this.GetControls(I);
          if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCCustomToolBarElement).SetState(this.FState);
        };
      };
    };
    this.SetAutoHeight = function (Value) {
      if (this.FAutoHeight !== Value) {
        this.FAutoHeight = Value;
        this.UpdateControls();
      };
    };
    this.SetAutoWidth = function (Value) {
      if (this.FAutoWidth !== Value) {
        this.FAutoWidth = Value;
        this.UpdateControls();
      };
    };
    this.SetAutoStretchHeight = function (Value) {
      if (this.FAutoStretchHeight !== Value) {
        this.FAutoStretchHeight = Value;
        this.UpdateControls();
      };
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        this.UpdateControls();
      };
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetBitmapContainer = function (Value) {
      var I = 0;
      var c = null;
      var b = null;
      var $ir = rtl.createIntfRefs();
      try {
        this.FBitmapContainer = Value;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(c,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer),{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }})) b.SetBitmapContainer(Value);
        };
        this.Invalidate();
      } finally {
        $ir.free();
        rtl._Release(b);
      };
    };
    this.SetFont$1 = function (Value) {
      this.FFont$1.Assign(Value);
    };
    this.SetHorizontalTextAlign = function (Value) {
      if (this.FHorizontalTextAlign !== Value) {
        this.FHorizontalTextAlign = Value;
        this.Invalidate();
      };
    };
    this.SetTrimming = function (Value) {
      if (this.FTrimming !== Value) {
        this.FTrimming = Value;
        this.UpdateControls();
      };
    };
    this.SetVerticalTextAlign = function (Value) {
      if (this.FVerticalTextAlign !== Value) {
        this.FVerticalTextAlign = Value;
        this.UpdateControls();
      };
    };
    this.SetWordWrapping = function (Value) {
      if (this.FWordWrapping !== Value) {
        this.FWordWrapping = Value;
        this.UpdateControls();
      };
    };
    this.SetTextVisible = function (Value) {
      if (this.FTextVisible !== Value) {
        this.FTextVisible = Value;
        this.UpdateControls();
      };
    };
    this.IsMinimumWidthStored = function () {
      var Result = false;
      Result = this.FMinimumWidth !== 30;
      return Result;
    };
    this.SetMinimumWidth = function (Value) {
      if (this.FMinimumWidth !== Value) {
        this.FMinimumWidth = Value;
        this.UpdateControls();
      };
    };
    this.SetCompact = function (Value) {
      if (this.FCompact !== Value) {
        if (this.FCanCompact) {
          this.FCompact = Value;
          if (this.FCompact) {
            this.FOldMenuButtonState = this.FOptionsMenu.FShowButton;
            this.FOptionsMenu.SetShowButton(false);
            this.FOldWidth = this.GetWidth();
            this.CompactControls();
            this.SetWidth(Math.round(this.FCompactWidth));
          } else {
            this.SetWidth(Math.round(this.FOldWidth));
            this.UncompactControls();
            this.FOptionsMenu.SetShowButton(this.FOldMenuButtonState);
          };
          this.UpdateControls();
        };
      };
    };
    this.SetCanCompact = function (Value) {
      if (this.FCanCompact !== Value) this.FCanCompact = Value;
    };
    this.IsCompactWidthStored = function () {
      var Result = false;
      Result = this.FCompactWidth !== 50;
      return Result;
    };
    this.SetCompactWidth = function (Value) {
      if (this.FCompactWidth !== Value) {
        this.FCompactWidth = Value;
        if (this.FCompact) this.SetWidth(Math.round(this.FCompactWidth));
      };
    };
    this.SetCompactAppearance = function (Value) {
      this.FCompactAppearance.Assign(Value);
    };
    this.SetCompactBitmaps = function (Value) {
      this.FCompactBitmaps.Assign(Value);
    };
    this.IsCompactBitmapSizeStored = function () {
      var Result = false;
      Result = this.FCompactBitmapSize !== 24;
      return Result;
    };
    this.SetCompactBitmapSize = function (Value) {
      if (this.FCompactBitmapSize !== Value) {
        this.FCompactBitmapSize = Value;
        this.Invalidate();
      };
    };
    this.SetCompactBitmapVisible = function (Value) {
      if (this.FCompactBitmapVisible !== Value) {
        this.FCompactBitmapVisible = Value;
        this.Invalidate();
      };
    };
    this.SetCompactExpanderBitmaps = function (Value) {
      this.FCompactExpanderBitmaps.Assign(Value);
    };
    this.SetQuickMenuButton = function (Value) {
      if (this.FQuickMenuButton !== Value) {
        this.FQuickMenuButton = Value;
        this.Invalidate();
      };
    };
    this.SetQuickMenuButtonAppearance = function (Value) {
      this.FQuickMenuButtonAppearance.Assign(Value);
    };
    this.SetQuickMenuButtonBitmaps = function (Value) {
      this.FQuickMenuButtonBitmaps.Assign(Value);
    };
    this.SetCompactAutoBitmapSize = function (Value) {
      if (this.FCompactAutoBitmapSize !== Value) {
        this.FCompactAutoBitmapSize = Value;
        this.Invalidate();
      };
    };
    this.GetTextRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var h = 0.0;
      var sz = 0.0;
      sz = 0;
      if (this.FAppearance.FDragGrip) {
        if (this.FState === $mod.TTMSFNCToolBarElementState.esLarge) {
          sz = 3}
         else sz = 2;
      };
      r.$assign(this.GetLocalRect());
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + this.ScalePaintValue$1(sz),r.Top,r.Right,r.Bottom));
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,this.ScalePaintValue(-2),this.ScalePaintValue(-2));
      h = this.GetTextSize().cy;
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Bottom - h,r.Right,r.Bottom));
      return Result;
    };
    this.SetDisabledFontColor = function (Value) {
      if (this.FDisabledFontColor !== Value) {
        this.FDisabledFontColor = Value;
        this.Invalidate();
      };
    };
    this.GetSubComponentArray = function () {
      var Result = [];
      var I = 0;
      Result = rtl.arraySetLength(Result,null,this.GetControlsCount() + this.FHiddenControls.GetCount() + 1);
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        Result[I] = this.GetControls(I);
      };
      for (var $l1 = 0, $end1 = this.FHiddenControls.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        Result[I + this.GetControlsCount()] = this.FHiddenControls.GetItem$1(I).FControl;
      };
      Result[rtl.length(Result) - 1] = this.FOptionsMenuButton;
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/" + pas.SysUtils.LowerCase(this.$classname);
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,2,6);
      return Result;
    };
    this.CanDrawDesignTime = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.CanBuildControls = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetOptionsMenuButtonClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarDropDownButton;
      return Result;
    };
    this.GetBitmapPickerClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarBitmapPicker;
      return Result;
    };
    this.GetToolBarButtonClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarButton;
      return Result;
    };
    this.GetColorPickerClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarColorPicker;
      return Result;
    };
    this.GetItemPickerClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarItemPicker;
      return Result;
    };
    this.GetFontNamePickerClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarFontNamePicker;
      return Result;
    };
    this.GetFontSizePickerClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarFontSizePicker;
      return Result;
    };
    this.GetToolBarSeparatorClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarSeparator;
      return Result;
    };
    this.GetTextSize = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var g = null;
      var sz = 0.0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.cx = 0;
      Result.cy = 0;
      if (this.FTextVisible && (this.FText !== "")) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,this.FNativeCanvas,true]);
        if (!this.FNativeCanvas) g.BeginScene();
        g.FBitmapContainer = this.GetBitmapContainer();
        g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
        try {
          sz = 0;
          if (this.FAppearance.FDragGrip) {
            if (this.FState === $mod.TTMSFNCToolBarElementState.esLarge) {
              sz = 3}
             else sz = 2;
          };
          g.FFont.Assign(this.FFont$1);
          r.$assign(this.GetLocalRect());
          r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + sz,r.Top,r.Right,r.Bottom));
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-2,-2);
          Result.$assign(g.CalculateTextSize(this.FText,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FWordWrapping,true));
        } finally {
          if (!this.FNativeCanvas) g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      return Result;
    };
    this.GetHiddenControl = function (AControl) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.FHiddenControls.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FHiddenControls.GetItem$1(I).FControl === AControl) {
          Result = this.FHiddenControls.GetItem$1(I);
          break;
        };
      };
      return Result;
    };
    this.GetCompactControl = function (AControl) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.FCompactControls.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FCompactControls.GetItem$1(I).FControl === AControl) {
          Result = this.FCompactControls.GetItem$1(I);
          break;
        };
      };
      return Result;
    };
    this.GetHiddenControlCount = function (AControl) {
      var Result = 0;
      var I = 0;
      var lst = null;
      lst = $mod.TTMSFNCToolBarControlList.$create("Create$1");
      for (var $l = 0, $end = this.FHiddenControls.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        lst.Add(this.FHiddenControls.GetItem$1(I));
      };
      Result = 0;
      for (var $l1 = 0, $end1 = lst.GetCount() - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        if (lst.GetItem(I).FControl === AControl) {
          break}
         else Result += 1;
      };
      lst = rtl.freeLoc(lst);
      return Result;
    };
    this.GetCompactControlCount = function () {
      var Result = 0;
      Result = this.FCompactControls.GetCount();
      return Result;
    };
    this.GetCompactTextRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bmpr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetLocalRect());
      bmpr.$assign(this.GetCompactBitmapRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r)));
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,bmpr.Bottom + 3,r.Right - 3,r.Bottom - 23));
      return Result;
    };
    this.GetCompactBitmapRect = function (ARect) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bs = 0.0;
      r.$assign(ARect);
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Right,r.Top));
      if (this.FCompactBitmapVisible) {
        bs = this.GetCompactBitmapSize();
        if (!this.FTextVisible || (this.FText === "")) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Right - 3,r.Bottom - 3));
          if (bs !== -1) {
            Result.Left = Math.round(r.Left + ((r.Right - r.Left - bs) / 2));
            Result.Top = Math.round(r.Top + ((r.Bottom - r.Top - bs) / 2));
            Result.Right = Result.Left + bs;
            Result.Bottom = Result.Top + bs;
          };
        } else if (this.FTextVisible && !(this.FText === "")) Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + 3,r.Top + 3,r.Right - 3,r.Top + bs));
      };
      return Result;
    };
    this.GetCompactBitmapSize = function () {
      var Result = 0.0;
      var bmp = null;
      Result = this.FCompactBitmapSize;
      if (this.FCompactAutoBitmapSize) {
        bmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FCompactBitmaps,0,this.GetBitmapContainer());
        if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) Result = Math.max(bmp.GetHeight(),bmp.GetWidth());
      };
      return Result;
    };
    this.GetQuickMenuButtonRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(this.GetWidth() - 16,this.GetHeight() - 16,this.GetWidth(),this.GetHeight()));
      if (this.FAppearance.FSeparator) {
        Result.Left = Result.Left - this.FAppearance.FSeparatorStroke.FWidth;
        Result.Right = Result.Right - this.FAppearance.FSeparatorStroke.FWidth;
      };
      return Result;
    };
    this.HasHint = function () {
      var Result = false;
      Result = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.HasHint.call(this);
      if (this.FQuickMenuButtonHover) Result = this.FQuickMenuButtonHint !== "";
      return Result;
    };
    this.GetHintString = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBase.GetHintString.call(this);
      if (this.FQuickMenuButtonHover) Result = this.FQuickMenuButtonHint;
      return Result;
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.FFont$1.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FFont$1.FHeight,M,D));
      this.FAppearance.SetHorizontalSpacing(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FHorizontalSpacing,M,D));
      this.FAppearance.SetVerticalSpacing(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FAppearance.FVerticalSpacing,M,D));
      this.SetCompactWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FCompactWidth,M,D));
      this.SetCompactBitmapSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FCompactBitmapSize,M,D));
    };
    this.HandleQuickMenuButton = function () {
      if (this.FOnQuickMenuButtonClick != null) this.FOnQuickMenuButtonClick(this);
    };
    this.CompactAppearanceChanged = function (Sender) {
      this.Invalidate();
    };
    this.QuickMenuButtonAppearanceChanged = function (Sender) {
      this.Invalidate();
    };
    this.CompactBitmapsChanged = function (Sender) {
      var bmp = null;
      bmp = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.GetScaledBitmap(this.FCompactBitmaps,0,this.GetBitmapContainer());
      this.SetCompactBitmapVisible((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp));
      this.Invalidate();
    };
    this.CompactExpanderBitmapsChanged = function (Sender) {
      this.Invalidate();
    };
    this.QuickMenuButtonBitmapsChanged = function (Sender) {
      this.Invalidate();
    };
    this.ApplyFlatStyle = function () {
      var I = 0;
      var c = null;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        c = this.GetControls(I);
        if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
        if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCCustomToolBar).FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      };
      this.Invalidate();
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      this.UpdateControls();
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FFill.SetColor(c);
      };
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColorTo({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FFill.SetColorTo(c);
      };
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFont$1.SetColor(c);
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      this.FAppearance.SetDragGripColor(13882323);
      this.FAppearance.FFill.SetColor(16777215);
      this.FAppearance.FStroke.SetColor(8421504);
      this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      this.FAppearance.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FFill.SetColor(16777215);
      this.FAppearance.FFill.SetColorTo(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(230,230,230));
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseDown.apply(this,arguments);
      if (this.FAppearance.FDragGrip && !this.FDragGripMoving) {
        this.FDragGripDown = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetDragGripRect(true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
        this.FDragGripDownPt.$assign(pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
      };
      if (!this.FDragGripDown) {
        if (this.FCompact) {
          this.FDown = true;
          this.Invalidate();
          this.CaptureEx();
        } else if (this.FQuickMenuButton) {
          this.FQuickMenuButtonDown = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetQuickMenuButtonRect(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
          if (this.FQuickMenuButtonDown) {
            this.Invalidate();
            this.CaptureEx();
          };
        };
      };
      if ((this.FOnInternalMouseDown$1 != null) && !(Button === pas["WEBLib.Controls"].TMouseButton.mbRight)) this.FOnInternalMouseDown$1(this);
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var absx = 0.0;
      var absy = 0.0;
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var d = null;
      var a = "";
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseMove.apply(this,arguments);
      if (this.FCompact) {
        this.FHoverP = this.FHover;
        this.FHover = true;
        if (this.FHover !== this.FHoverP) this.Invalidate();
      } else if (this.FQuickMenuButton) {
        this.FQuickMenuButtonHoverP = this.FQuickMenuButtonHover;
        this.FQuickMenuButtonHover = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetQuickMenuButtonRect(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y));
        if (this.FQuickMenuButtonHover !== this.FQuickMenuButtonHoverP) this.Invalidate();
      };
      if (this.FAppearance.FDragGrip) {
        if (this.FDragGripDown) {
          if (!this.FDragGripMoving) {
            this.CaptureEx();
            this.FDragGripMoving = true;
          };
          if (this.FDragGripMoving) {
            absx = this.FDragGripDownPt.X - X;
            absy = this.FDragGripDownPt.Y - Y;
            if (this.FAutoMoveToolBar) {
              pt.$assign(pas["WEBLib.TMSFNCTypes"].PointF(this.GetLeft() - absx,this.GetTop() - absy));
              if ($mod.TTMSFNCCustomDockPanel.isPrototypeOf(this.FParent)) {
                d = rtl.as(this.FParent,$mod.TTMSFNCCustomDockPanel);
                if (d.FAutoAlign) {
                  if (pt.Y < d.FAppearance.FMargins.FTop) pt.Y = Math.round(d.FAppearance.FMargins.FTop);
                  if (pt.X < d.FAppearance.FMargins.FLeft) {
                    pt.X = Math.round(d.FAppearance.FMargins.FLeft)}
                   else if ((pt.X + this.GetWidth()) > (d.GetWidth() - d.FAppearance.FMargins.FRight)) pt.X = Math.round(d.GetWidth() - d.FAppearance.FMargins.FRight - this.GetWidth());
                  this.SetBounds(Math.round(pt.X),Math.round(pt.Y),this.GetWidth(),this.GetHeight());
                };
              };
            };
            this.FDragGripDownPt.$assign(pas["WEBLib.TMSFNCTypes"].PointF(X + absx,Y + absy));
            this.DoDragGripMoving(absx,absy);
          };
        } else {
          r.$assign(this.GetDragGripRect(true));
          if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(r,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
            if (!this.FInsideDrag) {
              this.FInsideDrag = true;
              this.SetControlCursor(5);
            };
          } else if (this.FInsideDrag) {
            this.FInsideDrag = false;
            this.SetControlCursor(0);
          };
        };
      };
      a = this.XYToAnchor(X,Y);
      if (a !== "") {
        this.SetControlCursor(21)}
       else if (this.FCursor === 21) this.SetControlCursor(0);
      if (this.FOnInternalMouseMove$1 != null) this.FOnInternalMouseMove$1(this);
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FHoverP = false;
      this.FQuickMenuButtonHover = false;
      this.SetControlCursor(0);
      this.FInsideDrag = false;
      if (this.FHoverP !== this.FHover) {
        this.FHover = false;
        this.Invalidate();
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var a = "";
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseUp.apply(this,arguments);
      if (this.FDragGripDown) {
        this.ReleaseCaptureEx()}
       else if (this.FDown && this.FCompact) {
        this.Invalidate();
        this.ReleaseCaptureEx();
        this.HandleCompact();
      } else if (this.FQuickMenuButtonDown && this.FQuickMenuButton && !this.FCompact) {
        this.Invalidate();
        this.ReleaseCaptureEx();
        this.HandleQuickMenuButton();
      };
      this.FDragGripDown = false;
      this.FDragGripMoving = false;
      this.FDown = false;
      this.FQuickMenuButtonDown = false;
      a = this.XYToAnchor(X,Y);
      if (a !== "") this.DoAnchorClick(a);
      if ((this.FOnInternalMouseUp$1 != null) && !(Button === pas["WEBLib.Controls"].TMouseButton.mbRight)) this.FOnInternalMouseUp$1(this);
    };
    this.HandleCompact = function () {
      var I = 0;
      var cc = null;
      this.DeactivateAllPopups();
      if (this.FCompactToolbar != null) {
        rtl.free(this,"FCompactToolbar");
        this.FCompactToolbar = null;
      };
      if (this.FCompactPopup != null) {
        rtl.free(this,"FCompactPopup");
        this.FCompactPopup = null;
      };
      this.FCompactPopup = $mod.TTMSFNCToolBarPopup.$create("Create$1",[this]);
      this.FCompactPopup.FOnClosePopup = rtl.createCallback(this,"DoCloseCompactPopup");
      this.FCompactToolbar = $mod.TTMSFNCToolBar.$create("Create$1",[this.FCompactPopup]);
      this.FCompactToolbar.Assign(this);
      this.FCompactToolbar.SetCompact(false);
      this.FCompactToolbar.SetAS(true);
      this.FCompactToolbar.SetAutoHeight(false);
      this.FCompactToolbar.SetAutoWidth(true);
      this.FCompactToolbar.SetAutoStretchHeight(false);
      this.FCompactToolbar.FAppearance.SetSeparator(false);
      this.FCompactToolbar.SetControlMargins(1,1,1,1);
      this.FCompactToolbar.SetHeight(this.GetHeight() + 2);
      this.DoCustomizeCompactToolBar(this.FCompactToolbar);
      for (var $l = this.FCompactControls.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        cc = this.FCompactControls.GetItem$1(I);
        if (cc.FControl != null) {
          if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cc.FControl)) rtl.as(cc.FControl,$mod.TTMSFNCDefaultToolBarButton).SetLayout(rtl.as(cc.FControl,$mod.TTMSFNCDefaultToolBarButton).FCompactLayout);
          cc.FControl.SetVisible(true);
          cc.FControl.SetParent(this.FCompactToolbar);
        };
      };
      this.FCompactToolbar.UpdateControls();
      this.FCompactPopup.SetPlacementControl(this);
      this.FCompactPopup.SetContentControl(this.FCompactToolbar);
      this.FCompactPopup.SetIsOpen(true);
      this.DoCompactClick();
    };
    this.DeactivateAllPopups = function () {
      var I = 0;
      if ((this.FParent != null) && pas["WEBLib.Controls"].TWinControl.isPrototypeOf(this.FParent)) for (var $l = 0, $end = rtl.as(this.FParent,pas["WEBLib.Controls"].TWinControl).GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(rtl.as(this.FParent,pas["WEBLib.Controls"].TWinControl).GetControls(I))) rtl.as(rtl.as(this.FParent,pas["WEBLib.Controls"].TWinControl).GetControls(I),$mod.TTMSFNCCustomToolBar).CloseCompactPopup();
      };
    };
    this.DoCompactClick = function () {
      if (this.FOnCompactClick != null) this.FOnCompactClick(this);
    };
    this.DoCustomizeCompactToolBar = function (ACompactToolBar) {
      if (this.FOnCustomizeCompactToolBar != null) this.FOnCustomizeCompactToolBar(this,ACompactToolBar);
    };
    this.HandleDblClick = function (X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDblClick.apply(this,arguments);
      if (this.FOnInternalDblClick$1 != null) this.FOnInternalDblClick$1(this);
    };
    this.UpdateDockPanel = function () {
      if (this.FOnUpdateDockPanel != null) this.FOnUpdateDockPanel(this);
    };
    this.InsertToolBarControl = function (AControl, AIndex) {
      AControl.SetParent(this);
      if (AIndex > -1) this.SetChildOrder(AControl,AIndex);
      if (this.FOnInternalInsertControl != null) this.FOnInternalInsertControl(AControl);
    };
    this.DoDragGripMoving = function (ADeltaX, ADeltaY) {
      if (this.FOnDragGripMoving != null) this.FOnDragGripMoving(this,ADeltaX,ADeltaY);
    };
    this.VisibleChanging = function () {
      pas["WEBLib.Controls"].TControl.VisibleChanging.call(this);
      this.UpdateDockPanel();
    };
    this.GetDragGripRect = function (AInteraction) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var f = 0.0;
      r.$assign(this.GetLocalRect());
      f = 1;
      if (this.FState === $mod.TTMSFNCToolBarElementState.esLarge) f = 1.75;
      if (AInteraction) {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top,r.Left + this.ScalePaintValue$1(8 * f),r.Bottom))}
       else Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left + this.ScalePaintValue(3),r.Top + this.ScalePaintValue(3),r.Left + this.ScalePaintValue$1(6 * f),r.Bottom - this.ScalePaintValue(3)));
      return Result;
    };
    this.CompactControls = function () {
      var I = 0;
      var cc = null;
      var c = null;
      this.FBlockUpdate = true;
      this.FCompactControls.Clear();
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        I = $l;
        c = this.GetControls(I);
        if (c !== this.FOptionsMenuButton) {
          cc = $mod.TTMSFNCToolBarControl.$create("Create$1");
          cc.FControl = c;
          if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c)) {
            cc.FLayout = rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FLayout;
            if ((rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FCompactLayout === $mod.TTMSFNCToolBarButtonLayout.bblNone) && (rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FLayout !== $mod.TTMSFNCToolBarButtonLayout.bblNone)) rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).SetCompactLayout(rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FMaximumLayout);
          };
          if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) {
            cc.FControlIndex = rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FControlIndex}
           else cc.FControlIndex = c.FTag$1;
          c.SetParent(null);
          c.SetVisible(false);
          this.FCompactControls.Add$1(cc);
        };
      };
      this.FBlockUpdate = true;
      this.UpdateControls();
      this.Invalidate();
    };
    this.UncompactControls = function () {
      var I = 0;
      var cc = null;
      var c = null;
      this.FBlockUpdate = true;
      for (var $l = this.FCompactControls.GetCount() - 1; $l >= 0; $l--) {
        I = $l;
        cc = this.FCompactControls.GetItem$1(I);
        c = cc.FControl;
        if (c != null) {
          if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FBlockUpdate = true;
          c.SetParent(this);
          c.SetVisible(true);
          if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FBlockUpdate = false;
        };
      };
      this.FBlockUpdate = false;
      this.UpdateControls();
      this.Invalidate();
    };
    this.DoCustomizeOptionsMenu = function () {
      if (this.FOnOptionsMenuCustomize != null) this.FOnOptionsMenuCustomize(this,this.FAutoOptionsMenu);
    };
    this.DoCustomizeOptionsMenuItem = function (AControl, AMenuItem) {
      if (this.FOnOptionsMenuItemCustomize != null) this.FOnOptionsMenuItemCustomize(this,AControl,AMenuItem);
    };
    this.DoCanShowOptionsMenuItem = function (AControl, ACanShowItem) {
      if (this.FOnOptionsMenuItemCanShow != null) this.FOnOptionsMenuItemCanShow(this,AControl,ACanShowItem);
    };
    this.UpdateToolBar = function (Sender) {
      this.UpdateControls();
    };
    this.DoIsLastElement = function (AControl, ALastElement) {
      if (this.FOnIsLastElement != null) this.FOnIsLastElement(this,AControl,ALastElement);
    };
    this.UpdateToolBarControl = function (Sender) {
      var tb = null;
      var bmp = null;
      var c = null;
      var tc = null;
      var tci = 0;
      if (!(Sender != null)) return;
      this.FBlockUpdate = true;
      c = rtl.as(Sender,pas["WEBLib.Controls"].TControl);
      tb = this.GetHiddenControl(c);
      if (tb != null) {
        tc = tb.FControl;
        tci = Math.max(0,Math.min(this.GetControlsCount(),tb.FControlIndex - this.GetHiddenControlCount(tc)));
        this.FHiddenControls.Remove$1(tb);
        this.InsertToolBarControl(tc,tci);
        tc.SetVisible(true);
      } else {
        tb = $mod.TTMSFNCToolBarControl.$create("Create$1");
        if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) {
          tb.FControlIndex = rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FControlIndex}
         else tb.FControlIndex = c.FTag$1;
        tb.FControl = c;
        this.FBlockUpdate = true;
        bmp = c.MakeScreenshot();
        this.FBlockUpdate = false;
        tb.FBitmap.Assign(bmp);
        bmp = rtl.freeLoc(bmp);
        this.FHiddenControls.Add$1(tb);
        c.SetParent(null);
        c.SetVisible(false);
      };
      this.FBlockUpdate = false;
      this.UpdateControls();
    };
    this.OptionMenuItemClick = function (Sender) {
      var a = false;
      var c = null;
      a = true;
      c = null;
      if ($mod.TTMSFNCToolBarOptionMenuItem.isPrototypeOf(Sender)) c = rtl.as(Sender,$mod.TTMSFNCToolBarOptionMenuItem).FControl;
      if ((this.FOnOptionsMenuItemClick != null) && pas["WEBLib.Menus"].TMenuItem.isPrototypeOf(Sender)) this.FOnOptionsMenuItemClick(this,c,rtl.as(Sender,pas["WEBLib.Menus"].TMenuItem),{get: function () {
          return a;
        }, set: function (v) {
          a = v;
        }});
      if (a) this.UpdateToolBarControl(c);
    };
    this.OptionsButtonClick = function (Sender) {
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      if (this.FOnOptionsMenuButtonClick != null) {
        this.FOnOptionsMenuButtonClick(this)}
       else {
        pt.$assign(pas["WEBLib.TMSFNCTypes"].PointF(this.FOptionsMenuButton.GetLeft(),this.FOptionsMenuButton.GetTop()));
        pt.$assign(this.LocalToScreenEx(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(pt.X,pt.Y + this.FOptionsMenuButton.GetHeight()))));
        this.ShowOptionsMenu(pt.X,pt.Y);
      };
    };
    this.DoCloseCompactPopup = function (Sender) {
      var I = 0;
      var cc = null;
      this.FCompactPopup.SetContentControl(null);
      for (var $l = 0, $end = this.FCompactControls.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        cc = this.FCompactControls.GetItem$1(I);
        if (cc.FControl != null) {
          if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cc.FControl)) rtl.as(cc.FControl,$mod.TTMSFNCDefaultToolBarButton).SetLayout(cc.FLayout);
          cc.FControl.SetParent(null);
          cc.FControl.SetVisible(false);
        };
      };
      if (this.FCompactToolbar != null) {
        rtl.free(this,"FCompactToolbar");
        this.FCompactToolbar = null;
      };
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FCustomOptionsMenu)) this.FCustomOptionsMenu = null;
    };
    this.AlignControls = function (AControl, Rect) {
      pas["WEBLib.Controls"].TControl.AlignControls.apply(this,arguments);
      this.UpdateControls();
    };
    this.UpdateControlAfterResize = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.UpdateControlAfterResize.call(this);
      this.UpdateDockPanel();
    };
    this.UpdateControls = function () {
      var $Self = this;
      var I = 0;
      var c = null;
      var idx = 0;
      var fu = false;
      var hc = null;
      var maxx = 0;
      var x = 0;
      var w = 0;
      var y = 0;
      var h = 0;
      var hs = 0;
      var hsm = 0;
      var vs = 0;
      var xs = 0;
      var ys = 0;
      var txth = 0;
      var txtw = 0;
      var mgr = null;
      var l = false;
      var ia = null;
      var sz = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var cn = null;
      var lm = 0.0;
      var tm = 0.0;
      var rm = 0.0;
      var bm = 0.0;
      function GetControl(AIndex) {
        var Result = null;
        Result = null;
        if ((AIndex >= 0) && (AIndex <= ($Self.GetControlsCount() - 1))) {
          if ($Self.GetControls(AIndex).FVisible) {
            Result = $Self.GetControls(AIndex);
            return Result;
          };
        };
        while ((AIndex >= 0) && (AIndex <= ($Self.GetControlsCount() - 1))) {
          AIndex += 1;
          if ((AIndex >= 0) && (AIndex <= ($Self.GetControlsCount() - 1))) {
            if ($Self.GetControls(AIndex).FVisible) {
              Result = $Self.GetControls(AIndex);
              return Result;
            };
          };
        };
        return Result;
      };
      function IsLoadingEx() {
        var Result = false;
        var ii = 0;
        var ctl = null;
        Result = $Self.CheckIsLoading();
        if (!Result) {
          for (var $l = $Self.GetControlsCount() - 1; $l >= 0; $l--) {
            ii = $l;
            ctl = $Self.GetControls(ii);
            if (pas.Classes.TComponentStateItem.csLoading in ctl.FComponentState) {
              Result = true;
              return Result;
            };
          };
        };
        return Result;
      };
      var $ir = rtl.createIntfRefs();
      try {
        if (this.FBlockUpdate || this.FBlockResize || IsLoadingEx() || this.IsDestroying() || !this.CanBuildControls()) return;
        this.FFirstLoad = false;
        this.FBlockUpdate = true;
        hs = Math.round(this.FAppearance.FHorizontalSpacing);
        vs = Math.round(this.FAppearance.FVerticalSpacing);
        x = hs;
        if (this.FAppearance.FDragGrip) {
          x = x + Math.round(this.GetDragGripRect(false).Right);
          if (hs === 0) x = x + this.ScalePaintValue(3);
        };
        y = vs;
        xs = x;
        ys = y;
        hsm = this.ScalePaintValue(30);
        txth = 0;
        txtw = 0;
        sz.$assign(this.GetTextSize());
        if (sz.cy > 0) txth = Math.round(sz.cy + this.ScalePaintValue(4));
        if (sz.cx > 0) txtw = Math.round(sz.cx + this.ScalePaintValue(8));
        w = txtw;
        maxx = 0;
        h = 0;
        idx = 0;
        fu = false;
        for (var $l = 0, $end = $Self.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          c = $Self.GetControls(I);
          hc = this.GetHiddenControl(c);
          fu = !(hc != null);
          if (fu) break;
        };
        l = false;
        for (var $l1 = 0, $end1 = $Self.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          c = $Self.GetControls(I);
          if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(c,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle),{get: function () {
              return ia;
            }, set: function (v) {
              ia = v;
            }})) ia.SetAdaptToStyle(this.GetAdaptToStyle());
          if (l) {
            x = xs;
            y = h;
            ys = y;
          };
          l = false;
          if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) {
            l = rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FLastElement;
            rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FOnUpdateToolBar = rtl.createCallback($Self,"UpdateToolBar");
            rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FOnUpdateToolBarControl = rtl.createCallback($Self,"UpdateToolBarControl");
          };
          this.DoIsLastElement(c,{get: function () {
              return l;
            }, set: function (v) {
              l = v;
            }});
          if (!(c === this.FOptionsMenuButton)) {
            if (fu) {
              if ($mod.TTMSFNCCustomToolBarElement.isPrototypeOf(c)) {
                rtl.as(c,$mod.TTMSFNCCustomToolBarElement).FControlIndex = idx}
               else c.FTag$1 = idx;
            };
            if (c.FVisible) {
              if (c.FAlignWithMargins) {
                if (this.FAutoAlign) {
                  c.SetLeft(x + c.FMargins.FLeft);
                  c.SetTop(y + c.FMargins.FTop);
                };
                if (this.FAutoStretchHeight || ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c) && (rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FLayout === $mod.TTMSFNCToolBarButtonLayout.bblLarge))) {
                  h = this.GetHeight() - c.FMargins.FBottom - txth - y;
                  c.SetHeight(h);
                } else h = Math.max(h,c.GetTop() + c.GetHeight() + vs + c.FMargins.FBottom);
                cn = GetControl(I + 1);
                if ((cn != null) && $mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cn)) {
                  var $tmp = rtl.as(cn,$mod.TTMSFNCDefaultToolBarButton).FLayout;
                  if (($tmp === $mod.TTMSFNCToolBarButtonLayout.bblBitmap) || ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLabel)) {
                    y = Math.max(y,c.GetTop() + c.GetHeight() + vs + c.FMargins.FBottom);
                    if ((y + cn.FMargins.FTop + cn.GetHeight()) > (this.GetHeight() - cn.FMargins.FBottom - txth)) {
                      x = Math.max(x,Math.max(maxx,c.GetLeft() + c.GetWidth() + hs + c.FMargins.FRight));
                      y = ys;
                    } else {
                      c.SetLeft(x + c.FMargins.FLeft);
                      maxx = Math.max(x,Math.max(maxx,c.GetLeft() + c.GetWidth() + hs + c.FMargins.FRight));
                    };
                  } else if (($tmp === $mod.TTMSFNCToolBarButtonLayout.bblNone) || ($tmp === $mod.TTMSFNCToolBarButtonLayout.bblLarge)) {
                    x = Math.max(x,c.GetLeft() + c.GetWidth() + hs + c.FMargins.FRight);
                    y = ys;
                  };
                } else {
                  x = Math.max(x,Math.max(maxx,c.GetLeft() + c.GetWidth() + hs + c.FMargins.FRight));
                  y = ys;
                };
              } else {
                if (this.FAutoAlign) {
                  c.SetLeft(x);
                  c.SetTop(y);
                };
                if (this.FAutoStretchHeight || ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c) && (rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FLayout === $mod.TTMSFNCToolBarButtonLayout.bblLarge))) {
                  h = this.GetHeight() - txth - y;
                  c.SetHeight(h);
                } else h = Math.max(h,c.GetTop() + c.GetHeight() + vs);
                cn = GetControl(I + 1);
                if ((cn != null) && $mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cn)) {
                  var $tmp1 = rtl.as(cn,$mod.TTMSFNCDefaultToolBarButton).FLayout;
                  if (($tmp1 === $mod.TTMSFNCToolBarButtonLayout.bblBitmap) || ($tmp1 === $mod.TTMSFNCToolBarButtonLayout.bblLabel)) {
                    y = Math.max(y,c.GetTop() + c.GetHeight() + vs);
                    if ((y + cn.GetHeight()) > (this.GetHeight() - txth)) {
                      x = Math.max(x,Math.max(maxx,c.GetLeft() + c.GetWidth() + hs));
                      y = ys;
                    } else {
                      c.SetLeft(x);
                      maxx = Math.max(x,Math.max(maxx,c.GetLeft() + c.GetWidth() + hs));
                    };
                  } else if (($tmp1 === $mod.TTMSFNCToolBarButtonLayout.bblNone) || ($tmp1 === $mod.TTMSFNCToolBarButtonLayout.bblLarge)) {
                    x = Math.max(x,c.GetLeft() + c.GetWidth() + hs);
                    y = ys;
                  };
                } else {
                  x = Math.max(x,Math.max(maxx,c.GetLeft() + c.GetWidth() + hs));
                  y = ys;
                };
              };
              w = Math.max(w,x);
            };
            idx += 1;
          };
        };
        if (h === 0) h = hsm;
        this.FOptionsMenuButton.SetVisible(this.FOptionsMenu.FShowButton);
        if (this.FOptionsMenu.FShowButton) {
          this.FOptionsMenuButton.SetParent($Self)}
         else this.FOptionsMenuButton.SetParent(null);
        if (this.FOptionsMenuButton.FVisible) {
          this.FOptionsMenuButton.FControlIndex = $Self.GetControlsCount() - 1;
          this.FOptionsMenuButton.SetTop(this.FOptionsMenuButton.FMargins.FTop);
          mgr = this.FOptionsMenuButton.FMargins;
          if (!this.FOptionsMenuButton.FAlignWithMargins) {
            mgr.SetLeft(0);
            mgr.SetTop(0);
            mgr.SetRight(0);
            mgr.SetBottom(0);
          };
          if (this.FAutoSize) {
            this.FOptionsMenuButton.SetLeft(w + mgr.FLeft);
            if (this.FAutoHeight) {
              this.FOptionsMenuButton.SetHeight(h - mgr.FBottom - mgr.FTop)}
             else if (this.FAutoStretchHeight) this.FOptionsMenuButton.SetHeight(this.GetHeight() - mgr.FBottom - txth - mgr.FTop);
          } else {
            this.FOptionsMenuButton.SetLeft(this.GetWidth() - this.FOptionsMenuButton.GetWidth() - mgr.FRight);
            this.FOptionsMenuButton.SetHeight(this.GetHeight() - mgr.FBottom - mgr.FTop - txth);
          };
          w = w + this.FOptionsMenuButton.GetWidth() + mgr.FRight + mgr.FLeft;
        };
        if (this.FAutoSize) {
          if (this.FAppearance.FSeparator) w = w + Math.round(this.FAppearance.FSeparatorStroke.FWidth);
          w = Math.round(Math.max(this.FMinimumWidth,w));
          if (this.GetControlAlignment() === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone) {
            lm = 0;
            rm = 0;
            tm = 0;
            bm = 0;
            this.GetControlMargins({get: function () {
                return lm;
              }, set: function (v) {
                lm = v;
              }},{get: function () {
                return tm;
              }, set: function (v) {
                tm = v;
              }},{get: function () {
                return rm;
              }, set: function (v) {
                rm = v;
              }},{get: function () {
                return bm;
              }, set: function (v) {
                bm = v;
              }});
            w = w + Math.round(lm + rm);
          };
          h = h + txth;
          if (this.FAutoHeight && this.FAutoWidth && (this.GetControlAlignment() === pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone)) {
            this.SetBounds(this.GetLeft(),this.GetTop(),w,h)}
           else if (this.FAutoHeight && !(this.GetControlAlignment() in rtl.createSet(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caLeft,pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caRight,pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient))) {
            this.SetBounds(this.GetLeft(),this.GetTop(),this.GetWidth(),h)}
           else if (this.FAutoWidth && !(this.GetControlAlignment() in rtl.createSet(pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caTop,pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caBottom,pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caClient))) this.SetBounds(this.GetLeft(),this.GetTop(),w,this.GetHeight());
        };
        if (this.FOnUpdateControls != null) this.FOnUpdateControls($Self);
        this.FBlockUpdate = false;
      } finally {
        $ir.free();
        rtl._Release(ia);
      };
    };
    this.InitializeOptionsMenu = function () {
    };
    this.DrawDragGrip = function (AGraphics) {
      var $Self = this;
      var cnt = 0;
      function DrawDots(ARect) {
        var i = 0;
        var rdg = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var sz = 0;
        if ($Self.FState === $mod.TTMSFNCToolBarElementState.esLarge) {
          sz = $Self.ScalePaintValue(3)}
         else sz = $Self.ScalePaintValue(2);
        ARect.Left = ARect.Left;
        ARect.Top = ARect.Top;
        cnt = rtl.trunc(Math.round(ARect.Bottom) / (Math.round(sz) * 2));
        for (var $l = 1, $end = cnt; $l <= $end; $l++) {
          i = $l;
          rdg.$assign(pas["WEBLib.TMSFNCTypes"].RectF(ARect.Left + ((ARect.Right - ARect.Left - sz) / 2),ARect.Top + 1,ARect.Left + sz + ((ARect.Right - ARect.Left - sz) / 2),ARect.Top + 1 + sz));
          rdg.$assign(pas["WEBLib.TMSFNCTypes"].RectF(pas.System.Int(rdg.Left),pas.System.Int(rdg.Top),pas.System.Int(rdg.Right),pas.System.Int(rdg.Bottom)));
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(rdg),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          ARect.Top = ARect.Top + (sz * 2);
        };
      };
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      AGraphics.FFill.SetColor(this.FAppearance.FDragGripColor);
      AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      r.$assign(this.GetDragGripRect(false));
      DrawDots(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
    };
    this.DrawText = function (AGraphics) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FTextVisible && (this.FText !== "")) {
        AGraphics.FFont.Assign(this.FFont$1);
        if (!this.FEnabled && (this.FDisabledFontColor !== -1)) AGraphics.FFont.SetColor(this.FDisabledFontColor);
        r.$assign(this.GetTextRect());
        AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FText,this.FWordWrapping,this.FHorizontalTextAlign,this.FVerticalTextAlign,this.FTrimming,0,-1,-1,true,false,-1,-1);
      };
    };
    this.DrawCompactBitmap = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetCompactBitmapRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect)));
      AGraphics.FBitmapContainer = this.GetBitmapContainer();
      AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FCompactBitmaps,0,true,false,true,false);
    };
    this.DrawCompactText = function (AGraphics) {
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var st = null;
      if (!this.FTextVisible || (this.FText === "")) return;
      tr.$assign(this.GetCompactTextRect());
      st = AGraphics.SaveState(false);
      try {
        AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr));
        AGraphics.FFont.Assign(this.FFont$1);
        AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr),this.FText,this.FWordWrapping,this.FHorizontalTextAlign,this.FVerticalTextAlign,this.FTrimming,0,-1,-1,true,false,-1,-1);
      } finally {
        AGraphics.RestoreState(st,false);
      };
    };
    this.DrawCompactExpander = function (AGraphics) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.$assign(this.GetLocalRect());
      r.$assign(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Bottom - 20,r.Right,r.Bottom));
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-2,-2);
      AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FCompactExpanderBitmaps,0,true,false,true,false);
    };
    this.ShowOptionsMenu = function (X, Y) {
    };
    this.CheckIsLoading = function () {
      var Result = false;
      Result = this.IsLoading();
      return Result;
    };
    this.XYToAnchor = function (AX, AY) {
      var Result = "";
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      Result = "";
      r.$assign(this.GetTextRect());
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
      g.BeginScene();
      g.FBitmapContainer = this.GetBitmapContainer();
      try {
        g.FFont.Assign(this.FFont$1);
        Result = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FText,this.FWordWrapping,this.FHorizontalTextAlign,this.FVerticalTextAlign,this.FTrimming,0,-1,-1,true,true,AX,AY);
      } finally {
        g.EndScene();
        g = rtl.freeLoc(g);
      };
      return Result;
    };
    this.DoAnchorClick = function (AAnchor) {
      if (this.FOnAnchorClick != null) {
        this.FOnAnchorClick(this,AAnchor)}
       else pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.Assign = function (Source) {
      var c = null;
      var cc = null;
      var I = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(Source)) {
        this.FCompactAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactAppearance);
        this.FQuickMenuButtonAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FQuickMenuButtonAppearance);
        this.FQuickMenuButton = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FQuickMenuButton;
        this.FCompactBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactBitmaps);
        this.FCompact = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompact;
        this.FCanCompact = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCanCompact;
        this.FMinimumWidth = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FMinimumWidth;
        this.FCompactWidth = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactWidth;
        this.FCompactBitmapSize = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactBitmapSize;
        this.FCompactAutoBitmapSize = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactAutoBitmapSize;
        this.FCompactExpanderBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactExpanderBitmaps);
        this.FQuickMenuButtonBitmaps.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FQuickMenuButtonBitmaps);
        this.FCompactBitmapVisible = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FCompactBitmapVisible;
        this.FText = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FText;
        this.FTextVisible = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FTextVisible;
        this.FWordWrapping = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FWordWrapping;
        this.FHorizontalTextAlign = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FHorizontalTextAlign;
        this.FVerticalTextAlign = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FVerticalTextAlign;
        this.FTrimming = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FTrimming;
        this.FFont$1.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FFont$1);
        this.FAutoSize = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAutoSize;
        this.FAutoHeight = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAutoHeight;
        this.FAutoWidth = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAutoWidth;
        this.FAutoAlign = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAutoAlign;
        this.FAutoStretchHeight = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAutoStretchHeight;
        this.FAutoMoveToolBar = rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAutoMoveToolBar;
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBar).FAppearance);
        for (var $l = 0, $end = rtl.as(Source,$mod.TTMSFNCCustomToolBar).GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          cc = rtl.as(Source,$mod.TTMSFNCCustomToolBar).GetControls(I);
          if (($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cc) && rtl.as(cc,$mod.TTMSFNCDefaultToolBarButton).FCanCopy) || !($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cc) && pas["WEBLib.Controls"].TControl.isPrototypeOf(cc))) {
            if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cc)) rtl.as(cc,$mod.TTMSFNCDefaultToolBarButton).FApplyName = false;
            c = rtl.as(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.Clone(cc),pas["WEBLib.Controls"].TControl);
            if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(cc)) rtl.as(cc,$mod.TTMSFNCDefaultToolBarButton).FApplyName = true;
            this.AddCustomControl(c,-1);
          };
        };
        this.Invalidate();
      } else pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FFirstLoad = true;
      this.FHiddenControls = $mod.TTMSFNCToolBarControlObjectList.$create("Create$2");
      this.FCompactControls = $mod.TTMSFNCToolBarControlObjectList.$create("Create$2");
      this.FState = $mod.TTMSFNCToolBarElementState.esNormal;
      this.FDisabledFontColor = -1;
      this.FAppearance = $mod.TTMSFNCToolBarAppearance.$create("Create$1",[this]);
      this.FCompactAppearance = $mod.TTMSFNCToolBarCompactAppearance.$create("Create$1",[null]);
      this.FCompactAppearance.FOnChange = rtl.createCallback(this,"CompactAppearanceChanged");
      this.FQuickMenuButtonAppearance = $mod.TTMSFNCToolBarQuickMenuButtonAppearance.$create("Create$1",[null]);
      this.FQuickMenuButtonAppearance.FOnChange = rtl.createCallback(this,"QuickMenuButtonAppearanceChanged");
      this.FCompactBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FCompactBitmaps.FOnChange = rtl.createCallback(this,"CompactBitmapsChanged");
      this.FOptionsMenu = $mod.TTMSFNCToolBarOptionsMenu.$create("Create$1",[this]);
      this.FMinimumWidth = 30;
      this.FCompactWidth = 50;
      this.FCompactBitmapSize = 24;
      this.FCompactAutoBitmapSize = false;
      this.FCompactBitmapVisible = false;
      this.FCompactExpanderBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FCompactExpanderBitmaps.FOnChange = rtl.createCallback(this,"CompactExpanderBitmapsChanged");
      this.FQuickMenuButtonBitmaps = pas["WEBLib.TMSFNCTypes"].TTMSFNCScaledBitmaps.$create("Create$3",[this]);
      this.FQuickMenuButtonBitmaps.FOnChange = rtl.createCallback(this,"QuickMenuButtonBitmapsChanged");
      this.FCanCompact = true;
      this.FQuickMenuButton = false;
      this.FCompact = false;
      this.FAutoSize = true;
      this.FAutoWidth = true;
      this.FAutoHeight = true;
      this.FAutoAlign = true;
      this.FAutoStretchHeight = false;
      this.FAutoMoveToolBar = true;
      this.FOptionsMenuButton = this.GetOptionsMenuButtonClass().$create("Create$1",[this]);
      this.FOptionsMenuButton.FAppearance.FNormalFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      c = 13882323;
      this.FOptionsMenuButton.FAppearance.FNormalFill.SetColor(c);
      this.FOptionsMenuButton.FAppearance.SetShowInnerStroke(false);
      this.FOptionsMenuButton.FAppearance.SetRounding(0);
      this.FOptionsMenuButton.FAppearance.FHoverFill.Assign(this.FOptionsMenuButton.FAppearance.FNormalFill);
      this.FOptionsMenuButton.FAppearance.FDisabledFill.Assign(this.FOptionsMenuButton.FAppearance.FNormalFill);
      this.FOptionsMenuButton.FAppearance.FDownFill.Assign(this.FOptionsMenuButton.FAppearance.FNormalFill);
      this.FOptionsMenuButton.FAppearance.FHoverFill.SetColor(15128749);
      this.FOptionsMenuButton.FAppearance.FDownFill.SetColor(14599344);
      this.FOptionsMenuButton.FAppearance.FDisabledFill.SetColor(13882323);
      this.FOptionsMenuButton.SetAlignWithMargins(true);
      this.FOptionsMenuButton.FMargins.SetTop(3);
      this.FOptionsMenuButton.FMargins.SetBottom(3);
      this.FOptionsMenuButton.FMargins.SetRight(3);
      this.FOptionsMenuButton.FCanCopy = false;
      this.FAutoOptionsMenu = pas["WEBLib.Menus"].TPopupMenu.$create("Create$1",[this]);
      this.FOptionsMenuButton.FOnClick = rtl.createCallback(this,"OptionsButtonClick");
      this.FOptionsMenuButton.SetWidth(17);
      this.FOptionsMenuButton.SetText("");
      this.FOptionsMenuButton.FStored = false;
      this.FOptionsMenuButton.FBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBAROPTIONSMENU,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FOptionsMenuButton.FBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBAROPTIONSMENULARGE,pas["WEBLib.TMSFNCTypes"].HInstance(),1.5);
      this.FOptionsMenuButton.FDisabledBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBAROPTIONSMENU,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FOptionsMenuButton.FDisabledBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBAROPTIONSMENULARGE,pas["WEBLib.TMSFNCTypes"].HInstance(),1.5);
      this.FOptionsMenuButton.FHoverBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBAROPTIONSMENU,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FOptionsMenuButton.FHoverBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBAROPTIONSMENULARGE,pas["WEBLib.TMSFNCTypes"].HInstance(),1.5);
      this.FHorizontalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FVerticalTextAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FTrimming = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter;
      this.FWordWrapping = false;
      this.FTextVisible = true;
      this.FFont$1 = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FCompactExpanderBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCGraphics"].TMSFNCGRAPHICSDOWN,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FQuickMenuButtonBitmaps.AddBitmapFromResource$1(pas["WEBLib.TMSFNCToolBarRes"].TMSFNCTOOLBARQUICKMENU,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FQuickMenuButtonBitmaps");
      rtl.free(this,"FCompactExpanderBitmaps");
      rtl.free(this,"FCompactPopup");
      rtl.free(this,"FQuickMenuButtonAppearance");
      rtl.free(this,"FCompactAppearance");
      rtl.free(this,"FCompactBitmaps");
      rtl.free(this,"FFont$1");
      rtl.free(this,"FOptionsMenu");
      rtl.free(this,"FAppearance");
      rtl.free(this,"FHiddenControls");
      rtl.free(this,"FCompactControls");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Build = function () {
      this.UpdateControls();
    };
    this.Draw = function (AGraphics, ARect) {
      var qr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var w = 0.0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      r.$assign(this.GetLocalRect());
      if (this.FCompact) {
        if (this.FDown) {
          AGraphics.FFill.Assign(this.FCompactAppearance.FDownFill);
          AGraphics.FStroke.Assign(this.FCompactAppearance.FDownStroke);
        } else if (this.FHover) {
          AGraphics.FFill.Assign(this.FCompactAppearance.FHoverFill);
          AGraphics.FStroke.Assign(this.FCompactAppearance.FHoverStroke);
        } else {
          AGraphics.FFill.Assign(this.FCompactAppearance.FNormalFill);
          AGraphics.FStroke.Assign(this.FCompactAppearance.FNormalStroke);
        };
        if (this.FCompactAppearance.FFlatStyle) AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(r.Left,r.Top + 2,r.Right - 3,r.Bottom - 2)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      } else {
        AGraphics.FFill.Assign(this.FAppearance.FFill);
        AGraphics.FStroke.Assign(this.FAppearance.FStroke);
        if (this.FAppearance.FFlatStyle) AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      };
      if (this.FCompact) {
        this.DrawCompactBitmap(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
        this.DrawCompactText(AGraphics);
        this.DrawCompactExpander(AGraphics);
      } else {
        if (this.FAppearance.FDragGrip) this.DrawDragGrip(AGraphics);
        this.DrawText(AGraphics);
        if (this.FQuickMenuButton) {
          if (this.FQuickMenuButtonDown) {
            AGraphics.FFill.Assign(this.FQuickMenuButtonAppearance.FDownFill);
            AGraphics.FStroke.Assign(this.FQuickMenuButtonAppearance.FDownStroke);
          } else if (this.FQuickMenuButtonHover) {
            AGraphics.FFill.Assign(this.FQuickMenuButtonAppearance.FHoverFill);
            AGraphics.FStroke.Assign(this.FQuickMenuButtonAppearance.FHoverStroke);
          } else {
            AGraphics.FFill.Assign(this.FQuickMenuButtonAppearance.FNormalFill);
            AGraphics.FStroke.Assign(this.FQuickMenuButtonAppearance.FNormalStroke);
          };
          if (this.FQuickMenuButtonAppearance.FFlatStyle) AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
          qr.$assign(this.GetQuickMenuButtonRect());
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(qr),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(qr,-2,-2);
          AGraphics.DrawScaledBitmap(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(qr),this.FQuickMenuButtonBitmaps,0,true,false,true,false);
        };
      };
      if (this.FAppearance.FSeparator) {
        AGraphics.FStroke.Assign(this.FAppearance.FSeparatorStroke);
        w = this.FAppearance.FSeparatorStroke.FWidth;
        AGraphics.DrawLine$1(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - w,r.Top + 4)),pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(r.Right - w,r.Bottom - 4)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyPointMode.gcpmRightDown);
      };
      if (this.IsDesignTime() && this.CanDrawDesignTime()) AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.CanExpand = function () {
      var Result = false;
      var I = 0;
      var c = null;
      var btn = null;
      Result = false;
      if (this.FCompact) {
        Result = true;
        return Result;
      };
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        I = $l;
        c = this.GetControls(I);
        if (c !== this.FOptionsMenuButton) {
          if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c)) {
            btn = rtl.as(c,$mod.TTMSFNCDefaultToolBarButton);
            if ((btn.FLayout < btn.FMaximumLayout) && (btn.FLayout !== $mod.TTMSFNCToolBarButtonLayout.bblNone)) {
              Result = true;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.CanShrink = function () {
      var Result = false;
      var I = 0;
      var c = null;
      var btn = null;
      Result = false;
      if (!this.FCompact && this.FCanCompact) {
        Result = true;
        return Result;
      };
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        I = $l;
        c = this.GetControls(I);
        if (c !== this.FOptionsMenuButton) {
          if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c)) {
            btn = rtl.as(c,$mod.TTMSFNCDefaultToolBarButton);
            if ((btn.FLayout > btn.FMinimumLayout) && (btn.FLayout !== $mod.TTMSFNCToolBarButtonLayout.bblNone)) {
              Result = true;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.DropDownActive = function () {
      var Result = false;
      var I = 0;
      var c = null;
      Result = false;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        c = this.GetControls(I);
        if ($mod.TTMSFNCDefaultToolBarButton.isPrototypeOf(c)) {
          if (rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FPopup != null) {
            Result = rtl.as(c,$mod.TTMSFNCDefaultToolBarButton).FPopup.FIsOpen;
            if (Result) break;
          };
        };
      };
      return Result;
    };
    this.CloseCompactPopup = function () {
      if (this.FCompactPopup != null) this.FCompactPopup.SetIsOpen(false);
    };
    this.AddCustomControl = function (AControl, AIndex) {
      this.FBlockUpdate = true;
      this.InsertToolBarControl(AControl,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
    };
    this.AddCustomControlClass = function (AControlClass, AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = AControlClass.$create("Create$1",[this]);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddButton = function (AWidth, AHeight, AResource, AResourceLarge, AText, AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetToolBarButtonClass().$create("Create$1",[this]);
      Result.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      Result.SetText(AText);
      if (AWidth !== -1) {
        Result.SetWidth(Math.round(AWidth));
      };
      if (AHeight !== -1) {
        Result.SetHeight(Math.round(AHeight));
      };
      if (AResource !== "") {
        Result.FBitmaps.AddBitmapFromResource$1(AResource,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
        Result.FDisabledBitmaps.AddBitmapFromResource$1(AResource,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
        Result.FHoverBitmaps.AddBitmapFromResource$1(AResource,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      };
      if (AResourceLarge !== "") {
        Result.FBitmaps.AddBitmapFromResource$1(AResourceLarge,pas["WEBLib.TMSFNCTypes"].HInstance(),1.5);
        Result.FDisabledBitmaps.AddBitmapFromResource$1(AResourceLarge,pas["WEBLib.TMSFNCTypes"].HInstance(),1.5);
        Result.FHoverBitmaps.AddBitmapFromResource$1(AResourceLarge,pas["WEBLib.TMSFNCTypes"].HInstance(),1.5);
      };
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddSeparator = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetToolBarSeparatorClass().$create("Create$1",[this]);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddFontNamePicker = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetFontNamePickerClass().$create("Create$1",[this]);
      Result.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddFontSizePicker = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetFontSizePickerClass().$create("Create$1",[this]);
      Result.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddColorPicker = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetColorPickerClass().$create("Create$1",[this]);
      Result.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddItemPicker = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetItemPickerClass().$create("Create$1",[this]);
      Result.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.AddBitmapPicker = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = this.GetBitmapPickerClass().$create("Create$1",[this]);
      Result.FAppearance.SetFlatStyle(this.FAppearance.FFlatStyle);
      this.InsertToolBarControl(Result,AIndex);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    this.GetOptionsMenuButtonControl = function () {
      var Result = null;
      Result = this.FOptionsMenuButton;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCStylesManager);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCToolBar",this.TTMSFNCCustomToolBar,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBar);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCStylesManager);
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnOptionsMenuButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnOptionsMenuButtonClick","FOnOptionsMenuButtonClick");
    $r.addProperty("OnOptionsMenuItemCanShow",0,$mod.$rtti["TTMSFNCToolBarCanShowOptionsMenuItem"],"FOnOptionsMenuItemCanShow","FOnOptionsMenuItemCanShow");
    $r.addProperty("OnOptionsMenuCustomize",0,$mod.$rtti["TTMSFNCToolBarCustomizeOptionsMenu"],"FOnOptionsMenuCustomize","FOnOptionsMenuCustomize");
    $r.addProperty("OnOptionsMenuItemCustomize",0,$mod.$rtti["TTMSFNCToolBarCustomizeOptionsMenuItem"],"FOnOptionsMenuItemCustomize","FOnOptionsMenuItemCustomize");
    $r.addProperty("OnOptionsMenuItemApplyStyle",0,$mod.$rtti["TTMSFNCToolBarCustomizeOptionsMenuItem"],"FOnOptionsMenuItemApplyStyle","FOnOptionsMenuItemApplyStyle");
    $r.addProperty("OnOptionsMenuItemClick",0,$mod.$rtti["TTMSFNCToolBarOptionsMenuItemClick"],"FOnOptionsMenuItemClick","FOnOptionsMenuItemClick");
    $r.addProperty("OnIsLastElement",0,$mod.$rtti["TTMSFNCToolBarIsLastElement"],"FOnIsLastElement","FOnIsLastElement");
    $r.addProperty("OnDragGripMoving",0,$mod.$rtti["TTMSFNCToolBarDragGripMovingEvent"],"FOnDragGripMoving","FOnDragGripMoving");
    $r.addProperty("OnQuickMenuButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnQuickMenuButtonClick","FOnQuickMenuButtonClick");
    $r.addProperty("OnAnchorClick",0,$mod.$rtti["TTMSFNCToolBarAnchorClickEvent"],"FOnAnchorClick","FOnAnchorClick");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("AutoHeight",2,rtl.boolean,"FAutoHeight","SetAutoHeight",4,{Default: true});
    $r.addProperty("AutoWidth",2,rtl.boolean,"FAutoWidth","SetAutoWidth",4,{Default: true});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAS",4,{Default: true});
    $r.addProperty("AutoAlign",2,rtl.boolean,"FAutoAlign","SetAutoAlign",4,{Default: true});
    $r.addProperty("AutoStretchHeight",2,rtl.boolean,"FAutoStretchHeight","SetAutoStretchHeight",4,{Default: false});
    $r.addProperty("OnCustomizeCompactToolBar",0,$mod.$rtti["TTMSFNCToolBarCustomizeCompactToolBarEvent"],"FOnCustomizeCompactToolBar","FOnCustomizeCompactToolBar");
    $r.addProperty("AutoMoveToolBar",0,rtl.boolean,"FAutoMoveToolBar","FAutoMoveToolBar",4,{Default: true});
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCToolBarAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("CanCompact",2,rtl.boolean,"FCanCompact","SetCanCompact",4,{Default: true});
    $r.addProperty("OnCompactClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnCompactClick","FOnCompactClick");
    $r.addProperty("CompactBitmapVisible",2,rtl.boolean,"FCompactBitmapVisible","SetCompactBitmapVisible",4,{Default: false});
    $r.addProperty("CompactBitmaps",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCScaledBitmaps"],"FCompactBitmaps","SetCompactBitmaps");
    $r.addProperty("Compact",2,rtl.boolean,"FCompact","SetCompact",4,{Default: false});
    $r.addProperty("CompactWidth",14,rtl.double,"FCompactWidth","SetCompactWidth",4,{stored: "IsCompactWidthStored"});
    $r.addProperty("CompactAppearance",2,$mod.$rtti["TTMSFNCToolBarCompactAppearance"],"FCompactAppearance","SetCompactAppearance");
    $r.addProperty("CompactBitmapSize",14,rtl.double,"FCompactBitmapSize","SetCompactBitmapSize",4,{stored: "IsCompactBitmapSizeStored"});
    $r.addProperty("CompactAutoBitmapSize",2,rtl.boolean,"FCompactAutoBitmapSize","SetCompactAutoBitmapSize",4,{Default: false});
    $r.addProperty("QuickMenuButtonHint",0,rtl.string,"FQuickMenuButtonHint","FQuickMenuButtonHint");
    $r.addProperty("QuickMenuButton",2,rtl.boolean,"FQuickMenuButton","SetQuickMenuButton",4,{Default: false});
    $r.addProperty("QuickMenuButtonAppearance",2,$mod.$rtti["TTMSFNCToolBarQuickMenuButtonAppearance"],"FQuickMenuButtonAppearance","SetQuickMenuButtonAppearance");
    $r.addProperty("MinimumWidth",14,rtl.double,"FMinimumWidth","SetMinimumWidth",4,{stored: "IsMinimumWidthStored"});
    $r.addProperty("WordWrapping",2,rtl.boolean,"FWordWrapping","SetWordWrapping",4,{Default: false});
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("Trimming",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextTrimming"],"FTrimming","SetTrimming",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter});
    $r.addProperty("HorizontalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalTextAlign","SetHorizontalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalTextAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTextAlign","SetVerticalTextAlign",4,{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("Font",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont$1","SetFont$1");
    $r.addProperty("DisabledFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledFontColor","SetDisabledFontColor",4,{Default: -1});
    $r.addProperty("OptionsMenu",2,$mod.$rtti["TTMSFNCToolBarOptionsMenu"],"FOptionsMenu","SetOptionsMenu");
    $r.addProperty("CustomOptionsMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FCustomOptionsMenu","FCustomOptionsMenu");
    $r.addProperty("State",2,$mod.$rtti["TTMSFNCToolBarElementState"],"FState","SetState",4,{Default: $mod.TTMSFNCToolBarElementState.esNormal});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCCustomDockPanelAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FFill = null;
      this.FStroke = null;
      this.FMargins = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FMargins = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
    };
    this.FillChanged = function (Sender) {
      this.FOwner.Invalidate();
    };
    this.StrokeChanged = function (Sender) {
      this.FOwner.Invalidate();
    };
    this.MarginsChanged = function (Sender) {
      this.FOwner.UpdateControls();
    };
    this.Create$1 = function (AOwner) {
      this.FOwner = AOwner;
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,8421504,1.0]);
      this.FFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FMargins = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FMargins.SetLeft(3);
      this.FMargins.SetTop(3);
      this.FMargins.SetBottom(3);
      this.FMargins.SetRight(3);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FMargins");
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      pas.System.TObject.Destroy.call(this);
    };
  });
  rtl.createClass(this,"TTMSFNCDockPanelAppearance",this.TTMSFNCCustomDockPanelAppearance,function () {
    var $r = this.$rtti;
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
  });
  rtl.createClass(this,"TTMSFNCCustomDockPanel",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FBlockUpdate = false;
      this.FAppearance = null;
      this.FAutoSize = false;
      this.FAutoAlign = false;
      this.FState = 0;
    };
    this.$final = function () {
      this.FAppearance = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
    };
    this.SetAutoAlign = function (Value) {
      if (this.FAutoAlign !== Value) {
        this.FAutoAlign = Value;
        this.UpdateControls();
      };
    };
    this.SetAS = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateControls();
      };
    };
    this.SetState = function (Value) {
      var I = 0;
      var c = null;
      if (this.FState !== Value) {
        this.FState = Value;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          c = this.GetControls(I);
          if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(c)) rtl.as(c,$mod.TTMSFNCCustomToolBar).SetState(this.FState);
        };
      };
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/ttmsfnctoolbar";
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,2,6);
      return Result;
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      this.UpdateControls();
    };
    this.UpdateControls = function () {
      var I = 0;
      var h = 0;
      var hsm = 0;
      var c = null;
      var ia = null;
      var $ir = rtl.createIntfRefs();
      try {
        if (this.FBlockUpdate || this.IsLoading() || this.IsDestroying()) return;
        this.FBlockUpdate = true;
        h = 0;
        hsm = this.ScalePaintValue(30);
        if (this.FAutoAlign) {
          this.InitializeControls();
          this.RearrangeControls();
        };
        if (this.FAutoSize) {
          for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
            I = $l;
            c = this.GetControls(I);
            if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(c,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle),{get: function () {
                return ia;
              }, set: function (v) {
                ia = v;
              }})) ia.SetAdaptToStyle(this.GetAdaptToStyle());
            if (c.FVisible) h = Math.round(Math.max(h,c.GetTop() + c.GetHeight() + this.FAppearance.FMargins.FBottom));
          };
          if (h === 0) h = hsm;
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) h = h + this.ScalePaintValue(15);
          this.SetBounds(this.GetLeft(),this.GetTop(),this.GetWidth(),h);
        };
        this.FBlockUpdate = false;
      } finally {
        $ir.free();
        rtl._Release(ia);
      };
    };
    this.InitializeControls = function () {
      var I = 0;
      var c = null;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        c = this.GetControls(I);
        if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(c)) {
          rtl.as(c,$mod.TTMSFNCCustomToolBar).FOnUpdateDockPanel = rtl.createCallback(this,"UpdateDockPanel");
          if (rtl.as(c,$mod.TTMSFNCCustomToolBar).FDragGripMoving) continue;
        };
        if (c.FVisible) {
          if (c.GetTop() < this.FAppearance.FMargins.FTop) c.SetTop(Math.round(this.FAppearance.FMargins.FTop));
          if (c.GetLeft() < this.FAppearance.FMargins.FLeft) {
            c.SetLeft(Math.round(this.FAppearance.FMargins.FLeft))}
           else if ((c.GetLeft() + c.GetWidth()) > (this.GetWidth() - this.FAppearance.FMargins.FRight)) c.SetLeft(Math.round(this.GetWidth() - this.FAppearance.FMargins.FRight - c.GetWidth()));
        };
      };
    };
    this.RearrangeControls = function () {
      var c = null;
      var cl = null;
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var clr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var J = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        c = this.GetControls(I);
        if (!c.FVisible) continue;
        if ($mod.TTMSFNCCustomToolBar.isPrototypeOf(c)) {
          if (rtl.as(c,$mod.TTMSFNCCustomToolBar).FDragGripMoving) continue;
        };
        for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          cl = this.GetControls(J);
          if ((cl === c) || !cl.FVisible) continue;
          cr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(c.GetLeft(),c.GetTop(),c.GetLeft() + c.GetWidth(),c.GetTop() + c.GetHeight()));
          clr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cl.GetLeft(),cl.GetTop(),cl.GetLeft() + cl.GetWidth(),cl.GetTop() + cl.GetHeight()));
          if ((clr.Left >= (cr.Left - 3)) && (clr.Left <= (cr.Right + 3))) {
            if ((clr.Top < pas["WEBLib.TMSFNCTypes"].CenterPointEx(cr).Y) && (clr.Top >= (cr.Top - 3))) {
              cl.SetLeft(c.GetLeft() + c.GetWidth() + 3);
              cl.SetTop(c.GetTop());
            } else if ((clr.Top >= pas["WEBLib.TMSFNCTypes"].CenterPointEx(cr).Y) && (clr.Top <= (cr.Bottom + 3))) {
              cl.SetTop(c.GetTop() + c.GetHeight() + 3);
              cl.SetLeft(c.GetLeft());
            };
          };
        };
      };
    };
    this.UpdateDockPanel = function (Sender) {
      this.UpdateControls();
    };
    this.ApplyStyle = function () {
      var c = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FFill.SetColor(c);
      };
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColorTo({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FFill.SetColorTo(c);
      };
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
    };
    this.AlignControls = function (AControl, Rect) {
      pas["WEBLib.Controls"].TControl.AlignControls.apply(this,arguments);
      this.UpdateControls();
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomDockPanel.isPrototypeOf(Source)) {
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomDockPanel).FAppearance);
        this.SetAS(rtl.as(Source,$mod.TTMSFNCCustomDockPanel).FAutoSize);
        this.SetAutoAlign(rtl.as(Source,$mod.TTMSFNCCustomDockPanel).FAutoAlign);
        this.SetState(rtl.as(Source,$mod.TTMSFNCCustomDockPanel).FState);
      } else pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Assign.apply(this,arguments);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FState = $mod.TTMSFNCToolBarElementState.esNormal;
      this.FAppearance = $mod.TTMSFNCDockPanelAppearance.$create("Create$1",[this]);
      this.FAutoSize = true;
      this.FAutoAlign = true;
      this.SetAlign(pas["WEBLib.Controls"].TAlign.alTop);
      this.SetHeight(40);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.Draw = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      AGraphics.FFill.Assign(this.FAppearance.FFill);
      AGraphics.FStroke.Assign(this.FAppearance.FStroke);
      r.$assign(this.GetLocalRect());
      AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
    };
    this.AddToolBar = function (AIndex) {
      var Result = null;
      this.FBlockUpdate = true;
      Result = $mod.TTMSFNCToolBar.$create("Create$1",[this]);
      Result.SetParent(this);
      this.FBlockUpdate = false;
      this.UpdateControls();
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCDockPanel",this.TTMSFNCCustomDockPanel,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCDockPanelAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAS",4,{Default: true});
    $r.addProperty("AutoAlign",2,rtl.boolean,"FAutoAlign","SetAutoAlign",4,{Default: true});
    $r.addProperty("State",2,$mod.$rtti["TTMSFNCToolBarElementState"],"FState","SetState",4,{Default: $mod.TTMSFNCToolBarElementState.esNormal});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TControlOpen",pas["WEBLib.Controls"].TControl,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
  $mod.$init = function () {
    pas.Classes.RegisterClass($mod.TTMSFNCToolBarButton);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCTOOLBAREXPANDSVG);
  };
},["Math","SysUtils","WEBLib.TMSFNCUtils","WEBLib.Graphics","StrUtils"]);
rtl.module("WEBLib.TMSFNCEdit",["System","Classes","WEBLib.TMSFNCToolBar","WEBLib.TMSFNCToolBarRes","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCTypes","WEBLib.TMSFNCPopup","WEBLib.ExtCtrls","WEBLib.StdCtrls","WEBLib.Graphics","WEBLib.Controls","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCBitmapContainer","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 4;
  this.BLD_VER = 3;
  this.LOOKUPITEMHEIGHT = 18;
  this.TTMSFNCEditType = {"0": "etString", etString: 0, "1": "etNumeric", etNumeric: 1, "2": "etSignedNumeric", etSignedNumeric: 2, "3": "etFloat", etFloat: 3, "4": "etSignedFloat", etSignedFloat: 4, "5": "etUpperCase", etUpperCase: 5, "6": "etMixedCase", etMixedCase: 6, "7": "etLowerCase", etLowerCase: 7, "8": "etMoney", etMoney: 8, "9": "etHex", etHex: 9, "10": "etAlphaNumeric", etAlphaNumeric: 10, "11": "etValidChars", etValidChars: 11};
  this.$rtti.$Enum("TTMSFNCEditType",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TTMSFNCEditType});
  this.TTMSFNCEditPrecisionDisplay = {"0": "pdNormal", pdNormal: 0, "1": "pdShortest", pdShortest: 1};
  this.$rtti.$Enum("TTMSFNCEditPrecisionDisplay",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCEditPrecisionDisplay});
  this.$rtti.$Class("TTMSFNCEdit");
  rtl.createClass(this,"TTMSFNCEditLookupSettings",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FDisplayList = null;
      this.FValueList = null;
      this.FDisplayCount = 0;
      this.FColor = 0;
      this.FEnabled = false;
      this.FNumChars = 0;
      this.FCaseSensitive = false;
      this.FHistory = false;
      this.FMulti = false;
      this.FSeparator = "\x00";
      this.FAcceptOnTab = false;
      this.FWidth = 0;
      this.FHeight = 0;
      this.FUseValueList = false;
      this.FMinimumWidth = 0;
      this.FMinimumHeight = 0;
    };
    this.$final = function () {
      this.FDisplayList = undefined;
      this.FValueList = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetDisplayList = function (Value) {
      this.FDisplayList.Assign(Value);
    };
    this.SetValueList = function (Value) {
      this.FValueList.Assign(Value);
    };
    this.SetNumChars = function (Value) {
      if (Value > 0) this.FNumChars = Value;
    };
    this.SetHeight = function (Value) {
      this.FHeight = Value;
    };
    this.SetWidth = function (Value) {
      this.FWidth = Value;
    };
    this.SetMinimumHeight = function (Value) {
      this.FMinimumHeight = Value;
    };
    this.SetMinimumWidth = function (Value) {
      this.FMinimumWidth = Value;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FUseValueList = true;
      this.FWidth = 0;
      this.FMinimumWidth = 0;
      this.FHeight = 0;
      this.FMinimumHeight = 0;
      this.FDisplayList = pas.Classes.TStringList.$create("Create$1");
      this.FDisplayList.SetSorted(true);
      this.FDisplayList.FDuplicates = pas.Types.TDuplicates.dupIgnore;
      this.FValueList = pas.Classes.TStringList.$create("Create$1");
      this.FColor = 16777215;
      this.FDisplayCount = 4;
      this.FNumChars = 2;
      this.FEnabled = false;
      this.FSeparator = ";";
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FValueList");
      rtl.free(this,"FDisplayList");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCEditLookupSettings.isPrototypeOf(Source)) {
        this.FAcceptOnTab = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FAcceptOnTab;
        this.FCaseSensitive = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FCaseSensitive;
        this.FColor = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FColor;
        this.FDisplayCount = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FDisplayCount;
        this.FDisplayList.Assign(rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FDisplayList);
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FEnabled;
        this.FHistory = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FHistory;
        this.FNumChars = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FNumChars;
        this.FValueList.Assign(rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FValueList);
        this.FMulti = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FMulti;
        this.FSeparator = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FSeparator;
        this.FWidth = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FWidth;
        this.FHeight = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FHeight;
        this.FMinimumWidth = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FMinimumWidth;
        this.FMinimumHeight = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FMinimumHeight;
        this.FUseValueList = rtl.as(Source,$mod.TTMSFNCEditLookupSettings).FUseValueList;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("CaseSensitive",0,rtl.boolean,"FCaseSensitive","FCaseSensitive",4,{Default: false});
    $r.addProperty("DisplayCount",0,rtl.longint,"FDisplayCount","FDisplayCount",4,{Default: 4});
    $r.addProperty("DisplayList",2,pas.Classes.$rtti["TStringList"],"FDisplayList","SetDisplayList");
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",4,{Default: false});
    $r.addProperty("History",0,rtl.boolean,"FHistory","FHistory",4,{Default: false});
    $r.addProperty("NumChars",2,rtl.longint,"FNumChars","SetNumChars",4,{Default: 2});
    $r.addProperty("ValueList",2,pas.Classes.$rtti["TStringList"],"FValueList","SetValueList");
    $r.addProperty("Multi",0,rtl.boolean,"FMulti","FMulti",4,{Default: false});
    $r.addProperty("Separator",0,rtl.char,"FSeparator","FSeparator");
    $r.addProperty("Width",2,rtl.longint,"FWidth","SetWidth",4,{Default: 0});
    $r.addProperty("Height",2,rtl.longint,"FHeight","SetHeight",4,{Default: 0});
    $r.addProperty("MinimumWidth",2,rtl.longint,"FMinimumWidth","SetMinimumWidth",4,{Default: 0});
    $r.addProperty("MinimumHeight",2,rtl.longint,"FMinimumHeight","SetMinimumHeight",4,{Default: 0});
    $r.addProperty("UseValueList",0,rtl.boolean,"FUseValueList","FUseValueList",4,{Default: true});
  });
  this.$rtti.$MethodVar("TTMSFNCEditLookupSelectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Value",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCEditLookupIndexSelectEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Index",rtl.longint],["Value",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCEditLookupNeedDataEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Value",rtl.string],["List",pas.Classes.$rtti["TStrings"]],["ItemIndex",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$DynArray("TTMSFNCEditHexCharacterArray",{eltype: rtl.char});
  rtl.createClass(this,"TTMSFNCLookupListBoxItem",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FIdx = 0;
    };
    this.Create$1 = function (AIdx) {
      this.FIdx = AIdx;
      return this;
    };
  });
  rtl.createClass(this,"TTMSFNCLookupList",pas.Classes.TList,function () {
  });
  rtl.createClass(this,"TTMSFNCEdit",pas["WEBLib.StdCtrls"].TCustomEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.$init.call(this);
      this.FLookupListBoxItems = null;
      this.FStyleElements = {};
      this.FAllowFocus = false;
      this.FLookupFormTimer = null;
      this.FKeyDown = 0;
      this.FShiftState = {};
      this.FEditType$1 = 0;
      this.FValidChars = "";
      this.FLookupList = null;
      this.FLookupListBox = null;
      this.FLookup = null;
      this.FOnLookupSelect = null;
      this.FOnLookupIndexSelect = null;
      this.FSigned = false;
      this.FPrefix = "";
      this.FSuffix = "";
      this.FIsModified = false;
      this.FLengthLimit = 0;
      this.FFullTextSearch = false;
      this.FAutoThousandSeparator = false;
      this.FPrecision = 0;
      this.FPrecisionDisplay = 0;
      this.FBlockChange = false;
      this.FAllowNumericNullValue = false;
      this.FAutoComplete = false;
      this.FOnCloseWithEscape = null;
      this.FOnLookupNeedData = null;
      this.FAutoClose = false;
      this.FOnLookupClose = null;
      this.FOnLookupOpen = null;
    };
    this.$final = function () {
      this.FLookupListBoxItems = undefined;
      this.FStyleElements = undefined;
      this.FLookupFormTimer = undefined;
      this.FShiftState = undefined;
      this.FLookupList = undefined;
      this.FLookupListBox = undefined;
      this.FLookup = undefined;
      this.FOnLookupSelect = undefined;
      this.FOnLookupIndexSelect = undefined;
      this.FOnCloseWithEscape = undefined;
      this.FOnLookupNeedData = undefined;
      this.FOnLookupClose = undefined;
      this.FOnLookupOpen = undefined;
      pas["WEBLib.StdCtrls"].TCustomEdit.$final.call(this);
    };
    this.CloseLookup = function () {
      if (this.CanFocus()) this.SetFocus();
      if (this.FLookupList != null) {
        if (this.FLookupList.FIsOpen) this.DoLookupClose();
        this.FLookupList.SetIsOpen(false);
      };
    };
    this.DoneLookup = function () {
      var idx = 0;
      var vp = 0;
      var NewValue = "";
      var LookupText = "";
      var NewText = "";
      var obj = null;
      if (!(this.FLookupListBox != null)) return;
      if (this.FLookupListBox.GetItemIndex() !== -1) {
        idx = -1;
        obj = this.FLookupListBox.FItems.GetObject(this.FLookupListBox.GetItemIndex());
        if (obj != null) idx = obj.FIdx;
        if ((idx >= 0) && (idx < this.FLookup.FValueList.GetCount()) && this.FLookup.FUseValueList) {
          NewValue = this.FLookup.FValueList.Get(idx)}
         else NewValue = this.FLookupListBox.FItems.Get(this.FLookupListBox.GetItemIndex());
        if (this.FOnLookupSelect != null) this.FOnLookupSelect(this,{get: function () {
            return NewValue;
          }, set: function (v) {
            NewValue = v;
          }});
        if (this.FOnLookupIndexSelect != null) this.FOnLookupIndexSelect(this,idx,{get: function () {
            return NewValue;
          }, set: function (v) {
            NewValue = v;
          }});
        if (this.FLookup.FMulti) {
          NewValue = NewValue + this.FLookup.FSeparator;
          LookupText = this.GetT();
          NewText = "";
          vp = -1;
          while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(this.FLookup.FSeparator,LookupText,{get: function () {
              return vp;
            }, set: function (v) {
              vp = v;
            }}) > 0) {
            NewText = NewText + pas.System.Copy(LookupText,1,vp);
            pas.System.Delete({get: function () {
                return LookupText;
              }, set: function (v) {
                LookupText = v;
              }},1,vp);
          };
          this.SetT(NewText + NewValue);
        } else this.SetT(NewValue);
        if (this.FLookup.FMulti) {
          this.SetSelStart(this.GetT().length)}
         else this.SelectAll();
        this.CloseLookup();
      };
    };
    this.UpdateAutoComplete = function () {
      var s = "";
      var ms = "";
      var i = 0;
      var vp = 0;
      if (!this.FAutoComplete) return;
      s = this.GetT();
      ms = "";
      if (s.length >= 1) {
        for (var $l = 1, $end = this.FLookup.FDisplayList.GetCount(); $l <= $end; $l++) {
          i = $l;
          if (this.FLookup.FCaseSensitive) {
            if (pas.System.Pos(s,this.FLookup.FDisplayList.Get(i - 1)) === 1) {
              ms = this.FLookup.FDisplayList.Get(i - 1);
              break;
            };
          } else {
            vp = pas.System.Pos(pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(s),pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(this.FLookup.FDisplayList.Get(i - 1)));
            if (vp === 1) {
              ms = this.FLookup.FDisplayList.Get(i - 1);
              break;
            };
          };
        };
        if (ms !== "") {
          this.SetT($impl.CleanString(ms));
          this.SetSelStart(s.length);
          this.SetSelLength(this.GetT().length - this.GetSelStart());
        };
      };
    };
    this.SetLookup = function (Value) {
      this.FLookup.Assign(Value);
    };
    this.AllowMin = function (ch) {
      var Result = false;
      Result = this.FSigned && (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat,$mod.TTMSFNCEditType.etNumeric,$mod.TTMSFNCEditType.etSignedNumeric,$mod.TTMSFNCEditType.etMoney)) && (ch === "-");
      return Result;
    };
    this.FixedLength = function (s) {
      var Result = 0;
      var i = 0;
      s = $impl.StripThousandSep(s);
      i = pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s);
      if (i > 0) {
        Result = i}
       else Result = s.length + 1;
      if (this.FSigned && (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat,$mod.TTMSFNCEditType.etNumeric,$mod.TTMSFNCEditType.etSignedNumeric,$mod.TTMSFNCEditType.etMoney)) && (pas.System.Pos("-",s) > 0)) Result = Result - 1;
      return Result;
    };
    this.SetPrefix = function (Value) {
      this.FPrefix = Value;
    };
    this.SetSuffix = function (Value) {
      this.FSuffix = Value;
    };
    this.SetModified = function (Value) {
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if (this.FReadOnly) return;
      this.FIsModified = Value;
    };
    this.DecimalPos = function () {
      var Result = 0;
      var i = 0;
      i = pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,this.GetT());
      if (i === 0) {
        Result = this.FPrefix.length + this.GetT().length + this.FSuffix.length + 1}
       else Result = this.FPrefix.length + i;
      return Result;
    };
    this.AutoSeparators = function () {
      var s = "";
      var si = "";
      var neg = "";
      var d = 0.0;
      var Diffl = 0;
      var OldSelStart = 0;
      var OldPrec = 0;
      s = this.GetT();
      Diffl = s.length;
      if (this.GetSelLength() === 0) {
        OldSelStart = this.GetSelStart()}
       else OldSelStart = this.GetSelStart() + this.GetSelLength();
      if (s === "") return;
      if (pas.System.Pos("-",s) === 1) {
        pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},1,1);
        neg = "-";
      } else neg = "";
      if (pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s) > 0) {
        s = pas.System.Copy(s,pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s),255)}
       else s = "";
      d = pas.System.Trunc(Math.abs(this.GetFloat()));
      if (this.FAutoThousandSeparator) {
        si = pas.SysUtils.Format("%n",pas.System.VarRecs(3,d))}
       else si = pas.SysUtils.Format("%f",pas.System.VarRecs(3,d));
      si = pas.System.Copy(si,1,pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,si) - 1);
      OldPrec = this.FPrecision;
      this.FPrecision = 0;
      this.FBlockChange = this.GetT() !== (this.FPrefix + neg + si + s + this.FSuffix);
      if (this.FBlockChange) {
        pas["WEBLib.StdCtrls"].TCustomEdit.SetText.call(this,this.FPrefix + neg + si + s + this.FSuffix);
      };
      this.FBlockChange = false;
      this.FPrecision = OldPrec;
      Diffl = this.GetT().length - Diffl;
      this.SetSelStart(OldSelStart + Diffl);
      this.SetSelLength(0);
    };
    this.GetFloat = function () {
      var Result = 0.0;
      var s = "";
      Result = 0;
      var $tmp = this.FEditType$1;
      if ($tmp === $mod.TTMSFNCEditType.etHex) {
        if (this.GetT() !== "") Result = $impl.HexToInt(this.GetT())}
       else if ($tmp === $mod.TTMSFNCEditType.etString) {
        Result = this.EStrToFloat(this.GetT());
      } else if (($tmp === $mod.TTMSFNCEditType.etNumeric) || ($tmp === $mod.TTMSFNCEditType.etFloat) || ($tmp === $mod.TTMSFNCEditType.etSignedFloat) || ($tmp === $mod.TTMSFNCEditType.etSignedNumeric)) {
        if (this.GetT() !== "") {
          s = this.GetT();
          if (s === "-") {
            Result = 0}
           else Result = this.EStrToFloat(s);
        }}
       else if ($tmp === $mod.TTMSFNCEditType.etMoney) if (this.GetT() !== "") {
        s = $impl.StripThousandSep(this.GetT());
        if (pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s) === s.length) pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s),1);
        if ((s === "") || (s === "-")) {
          Result = 0}
         else Result = this.EStrToFloat(s);
      };
      return Result;
    };
    this.SetFloat = function (Value) {
      var s = "";
      var $tmp = this.FEditType$1;
      if ($tmp === $mod.TTMSFNCEditType.etHex) {
        this.SetT(pas.SysUtils.IntToHex(pas.System.Trunc(Value),0))}
       else if (($tmp === $mod.TTMSFNCEditType.etNumeric) || ($tmp === $mod.TTMSFNCEditType.etSignedNumeric)) {
        if (this.FPrecision >= 0) {
          this.SetT(pas.SysUtils.Format("%." + pas.SysUtils.IntToStr(this.FPrecision) + "n",pas.System.VarRecs(3,Value)))}
         else this.SetT(pas.SysUtils.Format("%g",pas.System.VarRecs(3,Value)))}
       else if (($tmp === $mod.TTMSFNCEditType.etFloat) || ($tmp === $mod.TTMSFNCEditType.etSignedFloat) || ($tmp === $mod.TTMSFNCEditType.etString)) {
        if (this.FPrecision >= 0) {
          s = pas.SysUtils.Format("%." + pas.SysUtils.IntToStr(this.FPrecision) + "f",pas.System.VarRecs(3,Value));
          this.SetT(s);
        } else this.SetT(pas.SysUtils.Format("%g",pas.System.VarRecs(3,Value)))}
       else if ($tmp === $mod.TTMSFNCEditType.etMoney) {
        if (this.FPrecision >= 0) {
          this.SetT(pas.SysUtils.Format("%." + pas.SysUtils.IntToStr(this.FPrecision) + "f",pas.System.VarRecs(3,Value)))}
         else this.SetT(pas.SysUtils.Format("%g",pas.System.VarRecs(3,Value)));
        this.AutoSeparators();
      };
      this.SetModified(true);
    };
    this.SetAutoThousandSeparator = function (Value) {
      this.FAutoThousandSeparator = Value;
      if (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etNumeric,$mod.TTMSFNCEditType.etSignedNumeric,$mod.TTMSFNCEditType.etMoney,$mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat)) this.AutoSeparators();
    };
    this.SetPrecision = function (Value) {
      var at = 0;
      if ((this.FPrecision !== Value) && (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat,$mod.TTMSFNCEditType.etMoney,$mod.TTMSFNCEditType.etString))) {
        this.FPrecision = Value;
        if ((this.GetT() !== "") || !this.FAllowNumericNullValue) {
          at = $impl.IsType(this.GetT());
          if (at in rtl.createSet($impl.TTMSFNCEditAutoType.atFloat,$impl.TTMSFNCEditAutoType.atNumeric)) {
            this.SetFloat(this.GetFloat())}
           else this.SetFloat(0.0);
        };
      };
    };
    this.SetPrecisionDisplay = function (Value) {
      if (this.FPrecisionDisplay !== Value) {
        this.FPrecisionDisplay = Value;
        this.SetFloat(this.GetFloat());
      };
    };
    this.EStrToFloat = function (s) {
      var Result = 0.0;
      Result = 0;
      if (pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) > 0) s = $impl.StripThousandSep(s);
      if ((this.FPrecision > 0) && (s.length > this.FPrecision)) if (s.charAt(s.length - this.FPrecision - 1) === pas.SysUtils.FormatSettings.ThousandSeparator.charAt(-1)) s = rtl.setCharAt(s,s.length - this.FPrecision - 1,pas.SysUtils.FormatSettings.DecimalSeparator.charAt(-1));
      try {
        pas.SysUtils.TryStrToFloat(s,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
      } catch ($e) {
        Result = 0;
      };
      return Result;
    };
    this.GetInt = function () {
      var Result = 0;
      Result = 0;
      var $tmp = this.FEditType$1;
      if ($tmp === $mod.TTMSFNCEditType.etHex) {
        if (this.GetT() !== "") Result = $impl.HexToInt(this.GetT())}
       else if (($tmp === $mod.TTMSFNCEditType.etSignedNumeric) || ($tmp === $mod.TTMSFNCEditType.etNumeric) || ($tmp === $mod.TTMSFNCEditType.etSignedFloat) || ($tmp === $mod.TTMSFNCEditType.etFloat)) {
        Result = $impl.ValStr(this.GetT())}
       else if ($tmp === $mod.TTMSFNCEditType.etMoney) Result = $impl.ValStr($impl.StripThousandSep(this.GetT()));
      return Result;
    };
    this.SetInt = function (Value) {
      var $tmp = this.FEditType$1;
      if ($tmp === $mod.TTMSFNCEditType.etHex) {
        this.SetT(pas.SysUtils.IntToHex(Value,0))}
       else if (($tmp === $mod.TTMSFNCEditType.etSignedNumeric) || ($tmp === $mod.TTMSFNCEditType.etNumeric) || ($tmp === $mod.TTMSFNCEditType.etSignedFloat) || ($tmp === $mod.TTMSFNCEditType.etFloat)) {
        this.SetT(pas.SysUtils.IntToStr(Value))}
       else if ($tmp === $mod.TTMSFNCEditType.etMoney) {
        this.SetT(pas.SysUtils.IntToStr(Value));
        this.AutoSeparators();
      };
      this.SetModified(true);
    };
    this.SetEditType$1 = function (Value) {
      var at = 0;
      if (this.FEditType$1 !== Value) {
        this.FEditType$1 = Value;
        if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
        if ((this.GetT() !== "") || !this.FAllowNumericNullValue) {
          at = $impl.IsType(this.GetT());
          var $tmp = this.FEditType$1;
          if ($tmp === $mod.TTMSFNCEditType.etHex) {
            if (!(at in rtl.createSet($impl.TTMSFNCEditAutoType.atNumeric,$impl.TTMSFNCEditAutoType.atHex))) this.SetInt(0)}
           else if (($tmp === $mod.TTMSFNCEditType.etNumeric) || ($tmp === $mod.TTMSFNCEditType.etSignedNumeric)) {
            if (at !== $impl.TTMSFNCEditAutoType.atNumeric) this.SetInt(0)}
           else if (($tmp === $mod.TTMSFNCEditType.etFloat) || ($tmp === $mod.TTMSFNCEditType.etSignedFloat) || ($tmp === $mod.TTMSFNCEditType.etMoney)) if (!(at in rtl.createSet($impl.TTMSFNCEditAutoType.atFloat,$impl.TTMSFNCEditAutoType.atNumeric))) this.SetFloat(0.0);
        };
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && ((this.FEditType$1 === $mod.TTMSFNCEditType.etFloat) || (this.FEditType$1 === $mod.TTMSFNCEditType.etSignedFloat)) && (this.FPrecision === 0)) this.SetPrecision(pas.SysUtils.FormatSettings.CurrencyDecimals);
      };
      var $tmp1 = this.FEditType$1;
      if (($tmp1 === $mod.TTMSFNCEditType.etValidChars) || ($tmp1 === $mod.TTMSFNCEditType.etAlphaNumeric) || ($tmp1 === $mod.TTMSFNCEditType.etMoney) || ($tmp1 === $mod.TTMSFNCEditType.etString) || ($tmp1 === $mod.TTMSFNCEditType.etUpperCase) || ($tmp1 === $mod.TTMSFNCEditType.etMixedCase) || ($tmp1 === $mod.TTMSFNCEditType.etLowerCase)) {
        this.SetEditType(pas["WEBLib.StdCtrls"].TEditType.weString)}
       else if ($tmp1 === $mod.TTMSFNCEditType.etNumeric) {
        this.SetEditType(pas["WEBLib.StdCtrls"].TEditType.weNumeric)}
       else if ($tmp1 === $mod.TTMSFNCEditType.etSignedNumeric) {
        this.SetEditType(pas["WEBLib.StdCtrls"].TEditType.weSignedNumeric)}
       else if ($tmp1 === $mod.TTMSFNCEditType.etFloat) {
        this.SetEditType(pas["WEBLib.StdCtrls"].TEditType.weFloat)}
       else if ($tmp1 === $mod.TTMSFNCEditType.etSignedFloat) {
        this.SetEditType(pas["WEBLib.StdCtrls"].TEditType.weSignedFloat)}
       else if ($tmp1 === $mod.TTMSFNCEditType.etHex) this.SetEditType(pas["WEBLib.StdCtrls"].TEditType.weHex);
      this.SetCharCase(pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal);
      var $tmp2 = this.FEditType$1;
      if ($tmp2 === $mod.TTMSFNCEditType.etUpperCase) {
        this.SetCharCase(pas["WEBLib.StdCtrls"].TEditCharCase.wecUpperCase)}
       else if ($tmp2 === $mod.TTMSFNCEditType.etMixedCase) {
        this.SetCharCase(pas["WEBLib.StdCtrls"].TEditCharCase.wecMixedCase)}
       else if ($tmp2 === $mod.TTMSFNCEditType.etLowerCase) this.SetCharCase(pas["WEBLib.StdCtrls"].TEditCharCase.wecLowerCase);
    };
    this.IsLookupListVisible = function () {
      var Result = false;
      Result = (this.FLookupList != null) && this.FLookupList.FIsOpen;
      return Result;
    };
    this.GetAllowFocus = function () {
      var Result = false;
      Result = this.FAllowFocus;
      return Result;
    };
    this.SetAllowFocus = function (Value) {
      this.FAllowFocus = Value;
    };
    this.SelectAfterDecimal = function () {
      var i = 0;
      i = pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,this.GetT());
      if (i > 0) {
        this.SetSelStart(i + this.FPrefix.length)}
       else this.SetSelStart(this.FPrefix.length);
    };
    this.UpdateLookup = function () {
      var i = 0;
      var cnt = 0;
      var mw = 0;
      var mh = 0;
      var tw = 0;
      var vp = 0;
      var LookupText = "";
      var ismatch = false;
      var idx = 0;
      var obj = null;
      if (!(this.FLookup != null) || !this.FLookup.FEnabled || !(this.FLookupListBox != null)) return;
      if (this.FLookup.FMulti) {
        LookupText = this.GetT();
        vp = -1;
        while (pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.VarPos(this.FLookup.FSeparator,LookupText,{get: function () {
            return vp;
          }, set: function (v) {
            vp = v;
          }}) > 0) pas.System.Delete({get: function () {
            return LookupText;
          }, set: function (v) {
            LookupText = v;
          }},1,vp);
      } else LookupText = this.GetT();
      if (LookupText.length >= this.FLookup.FNumChars) {
        mh = (18 * this.FLookup.FDisplayCount) + 4;
        this.FLookupListBox.SetParent(this);
        this.CleanupLookupList();
        this.FLookupListBox.FItems.Clear();
        for (var $l = 1, $end = this.FLookup.FDisplayList.GetCount(); $l <= $end; $l++) {
          i = $l;
          if (this.FLookup.FCaseSensitive) {
            if (pas.System.Pos(LookupText,this.FLookup.FDisplayList.Get(i - 1)) === 1) {
              obj = $mod.TTMSFNCLookupListBoxItem.$create("Create$1",[i - 1]);
              this.FLookupListBox.FItems.AddObject($impl.CleanString(this.FLookup.FDisplayList.Get(i - 1)),obj);
              this.FLookupListBoxItems.Add(obj);
            };
          } else {
            vp = pas.System.Pos(pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(LookupText),pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(this.FLookup.FDisplayList.Get(i - 1)));
            if (this.FFullTextSearch) {
              ismatch = vp > 0}
             else ismatch = vp === 1;
            if (ismatch) {
              obj = $mod.TTMSFNCLookupListBoxItem.$create("Create$1",[i - 1]);
              this.FLookupListBox.FItems.AddObject($impl.CleanString(this.FLookup.FDisplayList.Get(i - 1)),obj);
              this.FLookupListBoxItems.Add(obj);
            };
          };
        };
        idx = 0;
        this.DoLookupNeedData(LookupText,this.FLookupListBox.FItems,{get: function () {
            return idx;
          }, set: function (v) {
            idx = v;
          }});
        cnt = this.FLookupListBox.FItems.GetCount();
        if ((this.FLookup.FDisplayList.GetCount() > 0) && (this.FLookupListBox.FItems.GetCount() > 0)) this.FLookupListBox.SetItemIndex(idx);
        if (cnt < this.FLookup.FDisplayCount) mh = (cnt * 18) + 4;
        this.FLookupListBox.SetSorted(true);
        mw = 50;
        this.FLookupList.SetDropDownWidth(0);
        if (cnt > 0) {
          for (var $l1 = 1, $end1 = cnt; $l1 <= $end1; $l1++) {
            i = $l1;
            tw = 0;
            if (this.FLookupListBox.GetCanvas() != null) tw = Math.round(this.FLookupListBox.GetCanvas().TextWidth(this.FLookupListBox.FItems.Get(i - 1)));
            if (tw > mw) mw = tw;
          };
          mw = mw + 26;
        };
        if (this.FLookup.FWidth > 0) mw = this.FLookup.FWidth;
        if (this.FLookup.FHeight > 0) mh = this.FLookup.FHeight;
        this.FLookupList.SetPlacementControl(this);
        if (cnt > 0) {
          this.FLookupList.SetDropDownWidth(Math.max(this.FLookup.FMinimumWidth,mw));
          this.FLookupList.SetDropDownHeight(Math.max(this.FLookup.FMinimumHeight,mh));
          if (this.FLookupList.HasPopupForm()) {
            this.FLookupListBox.SetParent(this.FLookupList.FPopupForm);
            this.FLookupList.FPopupForm.SetWidth(Math.round(this.FLookupList.FDropDownWidth));
            this.FLookupList.FPopupForm.SetHeight(Math.round(this.FLookupList.FDropDownHeight));
          };
          if (!this.FLookupList.FIsOpen) this.DoLookupOpen();
          this.FLookupList.SetIsOpen(true);
          this.FLookupFormTimer.SetEnabled(this.FAutoClose);
        } else {
          if (this.FLookupList.FIsOpen) this.DoLookupClose();
          this.FLookupList.SetIsOpen(false);
        };
      } else {
        if (this.FLookupList.FIsOpen) this.DoLookupClose();
        this.FLookupList.SetIsOpen(false);
      };
    };
    this.GetVersionNumber = function (AMaj, AMin, ARel, ABld) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.Validate = function (AValue) {
      var Result = false;
      var i = 0;
      var kch = "\x00";
      var isValid = false;
      pas["WEBLib.StdCtrls"].TCustomEdit.Validate.apply(this,arguments);
      Result = true;
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        i = $l;
        kch = AValue.charAt(i - 1);
        isValid = true;
        var $tmp = this.FEditType$1;
        if ($tmp === $mod.TTMSFNCEditType.etNumeric) {
          if (!pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch)) isValid = false;
        } else if ($tmp === $mod.TTMSFNCEditType.etFloat) {
          if (!(pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator))) isValid = false;
        } else if (($tmp === $mod.TTMSFNCEditType.etSignedFloat) || ($tmp === $mod.TTMSFNCEditType.etSignedNumeric)) {
          if (!(pas["WEBLib.TMSFNCTypes"].CharInArray(kch,["-"]) || pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator))) isValid = false;
        } else if ($tmp === $mod.TTMSFNCEditType.etMoney) {
          if (!(pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator) || (kch === pas.SysUtils.FormatSettings.ThousandSeparator))) isValid = false;
        } else if ($tmp === $mod.TTMSFNCEditType.etHex) {
          if (!pas["WEBLib.TMSFNCTypes"].CharIsHex(kch)) isValid = false;
        } else if ($tmp === $mod.TTMSFNCEditType.etAlphaNumeric) {
          if (!pas["WEBLib.TMSFNCTypes"].CharIsLetterOrNumber(kch)) isValid = false;
        };
        if (!isValid) {
          Result = false;
          break;
        };
      };
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,4,3);
      return Result;
    };
    this.DoLookupFormTimer = function (Sender) {
      if (!(this.FLookupList != null) || !(this.FLookupListBox != null)) {
        this.FLookupFormTimer.SetEnabled(false);
        return;
      };
      if (this.FLookupList.FPopupForm != null) this.FLookupList.FPopupForm.ApplyPlacement();
      if (!this.FLookupList.FIsOpen || (!this.IsFocused() && !this.FLookupList.IsFocused() && !this.FLookupListBox.Focused())) {
        if (this.LookupList().FIsOpen) this.DoLookupClose();
        this.FLookupList.SetIsOpen(false);
        this.FLookupFormTimer.SetEnabled(false);
      };
    };
    this.GetT = function () {
      var Result = "";
      var s = "";
      s = pas["WEBLib.StdCtrls"].TCustomEdit.GetText.call(this);
      if ((this.FPrefix !== "") && (pas.System.Pos(pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(this.FPrefix),pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(s)) === 1)) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,this.FPrefix.length);
      if (this.FSuffix !== "") pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},(s.length - this.FSuffix.length) + 1,this.FSuffix.length);
      Result = s;
      return Result;
    };
    this.GetCaretPosition = function () {
      var Result = 0;
      Result = this.GetSelStart();
      return Result;
    };
    this.CleanupLookupList = function () {
      var I = 0;
      var obj = null;
      if (!(this.FLookupListBoxItems != null)) return;
      for (var $l = 0, $end = this.FLookupListBoxItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        obj = rtl.getObject(this.FLookupListBoxItems.Get(I));
        if (obj != null) obj = rtl.freeLoc(obj);
      };
      this.FLookupListBoxItems.Clear();
    };
    this.SetCaretPosition = function (ACaretPosition) {
      this.SetSelStart(ACaretPosition);
      this.SetSelLength(0);
    };
    this.SetT = function (Value) {
      var fmt = "";
      var neg = "";
      var f = 0.0;
      var v = "";
      v = Value;
      if (!((v === "") && this.FAllowNumericNullValue)) {
        var $tmp = this.FEditType$1;
        if ($tmp === $mod.TTMSFNCEditType.etFloat) {
          if (!($impl.IsType(v) in rtl.createSet($impl.TTMSFNCEditAutoType.atFloat,$impl.TTMSFNCEditAutoType.atNumeric))) v = "0"}
         else if ($tmp === $mod.TTMSFNCEditType.etMoney) {
          if (!($impl.IsType(v) in rtl.createSet($impl.TTMSFNCEditAutoType.atFloat,$impl.TTMSFNCEditAutoType.atNumeric))) v = "0"}
         else if ($tmp === $mod.TTMSFNCEditType.etHex) {
          if (!($impl.IsType(v) in rtl.createSet($impl.TTMSFNCEditAutoType.atHex,$impl.TTMSFNCEditAutoType.atNumeric))) v = "0"}
         else if ($tmp === $mod.TTMSFNCEditType.etNumeric) if (!($impl.IsType(v) in rtl.createSet($impl.TTMSFNCEditAutoType.atNumeric))) v = "0";
        if (this.FPrecisionDisplay === $mod.TTMSFNCEditPrecisionDisplay.pdNormal) {
          if (((this.FPrecision >= 0) || (this.FEditType$1 === $mod.TTMSFNCEditType.etMoney)) && (v !== "")) {
            if ((this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etMoney)) && (this.FPrecision >= 0)) {
              if (pas.System.Pos("-",Value) > 0) {
                neg = "-"}
               else neg = "";
              fmt = "%." + pas.SysUtils.IntToStr(this.FPrecision) + "n";
              v = pas.SysUtils.Format(fmt,pas.System.VarRecs(3,this.EStrToFloat(v)));
            };
            if (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat)) {
              fmt = "%." + pas.SysUtils.IntToStr(this.FPrecision) + "f";
              f = this.EStrToFloat(v);
              v = pas.SysUtils.Format(fmt,pas.System.VarRecs(3,f));
            };
          };
        } else {
          if (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etMoney,$mod.TTMSFNCEditType.etSignedFloat)) {
            f = this.EStrToFloat(v);
            v = pas.SysUtils.Format("%g",pas.System.VarRecs(3,f));
          };
        };
      };
      if (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etHex,$mod.TTMSFNCEditType.etUpperCase)) {
        v = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(v)}
       else if (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etLowerCase)) v = pas["WEBLib.TMSFNCTypes"].AnsiLowerCase(v);
      pas["WEBLib.StdCtrls"].TCustomEdit.SetText.call(this,this.FPrefix + v + this.FSuffix);
      this.SetModified(false);
    };
    this.InsertText = function (AText) {
      var TmpS = "";
      var ss = 0;
      if (this.FReadOnly) return;
      TmpS = this.GetT();
      ss = this.GetSelStart();
      pas.System.Delete({get: function () {
          return TmpS;
        }, set: function (v) {
          TmpS = v;
        }},this.GetSelStart() + 1,this.GetSelLength());
      pas.System.Insert(AText,{get: function () {
          return TmpS;
        }, set: function (v) {
          TmpS = v;
        }},this.GetSelStart() + 1);
      if ((this.FMaxLength <= 0) || (TmpS.length <= this.FMaxLength)) {
        this.SetT(TmpS);
        this.SetCaretPosition(ss + AText.length);
      };
      this.SetSelLength(0);
    };
    this.ListKeyUp = function (Sender, Key, Shift) {
      if (Key.get() === 13) this.DoneLookup();
      if ((Key.get() === 9) && this.FLookup.FAcceptOnTab) this.DoneLookup();
    };
    this.ListMouseUp = function (Sender, Button, Shift, X, Y) {
      this.DoneLookup();
    };
    this.KeyPress = function (Key) {
      var $Self = this;
      var oldSelStart = 0;
      var oldprec = 0;
      var s = "";
      var cl = "";
      var st = "";
      var allowclip = false;
      var at = 0;
      var ismod = false;
      var d = 0;
      var kch = "\x00";
      var b = false;
      function ScanPrecision(s, inspos) {
        var Result = false;
        var mdist = 0;
        Result = false;
        inspos = inspos - $Self.FPrefix.length;
        if ($Self.FPrecision <= 0) return Result;
        if ((s.length - inspos) > $Self.FPrecision) {
          Result = false;
          return Result;
        };
        if (pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s) > 0) {
          mdist = s.length - pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s);
          if ((inspos >= pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,s)) && (mdist >= $Self.FPrecision)) Result = true;
        };
        return Result;
      };
      function ScanDistance(s, inspos) {
        var Result = false;
        var mdist = 0;
        Result = false;
        inspos = inspos - $Self.FPrefix.length;
        mdist = s.length;
        if (pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) === 0) {
          Result = false;
          return Result;
        };
        while (pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) > 0) {
          if (Math.abs(pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) - inspos) < mdist) mdist = Math.abs(pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) - inspos);
          if (Math.abs(pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) - inspos) < 3) {
            Result = true;
            break;
          };
          if (inspos > pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s)) inspos = inspos - pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s));
        };
        if (mdist > 3) {
          Result = true;
        };
        return Result;
      };
      function EatKey() {
        if (!($Self.FKeyDown in rtl.createSet(38,40))) Key.set("\x00");
      };
      if (!(this.FLookupListBox != null)) {
        pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
        return;
      };
      s = Key.get();
      kch = Key.get();
      if ((this.FKeyDown === 18) || (this.FKeyDown === 27)) {
        this.CloseLookup();
      };
      if ((this.FKeyDown === 8) && (this.FPrefix !== "")) if ((this.GetSelStart() <= this.FPrefix.length) && (this.GetSelLength() === 0)) return;
      if ((this.FLengthLimit > 0) && (this.FixedLength($Self.GetT()) > this.FLengthLimit) && (this.GetSelLength() === 0) && (this.GetSelStart() < this.DecimalPos()) && (this.FKeyDown !== 8) && (this.FKeyDown !== pas.SysUtils.FormatSettings.DecimalSeparator.charCodeAt(0 - 1)) && !this.AllowMin(kch)) {
        EatKey();
        return;
      };
      if (this.FKeyDown in rtl.createSet(36,35,9,37,39,33,34,46,8)) {
        if (this.FKeyDown === 8) {
          s = $Self.GetT();
          if (this.GetSelLength() === 0) {
            pas.System.Delete({get: function () {
                return s;
              }, set: function (v) {
                s = v;
              }},this.GetSelStart() - this.FPrefix.length,1)}
           else pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},Math.max(1,this.GetSelStart() - this.FPrefix.length),this.GetSelLength());
          ismod = (s !== this.GetT()) || this.FIsModified;
          this.SetModified(ismod);
          pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
          if (this.FEditType$1 === $mod.TTMSFNCEditType.etMoney) this.AutoSeparators();
          if ((this.GetT() === "") && ((s !== "") || ismod)) {
            this.Change();
          };
          this.SetModified(ismod);
          this.UpdateLookup();
          return;
        } else {
          b = true;
          if (this.FKeyDown in rtl.createSet(36,35,9,37,39,33,34)) {
            b = false;
            if (this.FAutoComplete && (this.GetSelLength() > 0) && this.IsLookupListVisible()) this.CloseLookup();
          };
          if (b) {
            st = $Self.GetT();
            pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
            if ($Self.GetT() !== st) this.SetModified(true);
          } else pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
        };
        return;
      };
      if ((this.FKeyDown === 13) && this.IsLookupListVisible()) {
        pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
        this.DoneLookup();
        return;
      };
      if (this.FKeyDown in rtl.createSet(9,13,27)) {
        pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
        return;
      };
      if ((this.FKeyDown === 36) && this.IsLookupListVisible()) {
        if (this.FLookupListBox.FItems.GetCount() > 0) {
          this.FLookupListBox.SetItemIndex(0)}
         else this.FLookupListBox.SetItemIndex(-1);
        return;
      };
      if ((this.FKeyDown === 35) && this.IsLookupListVisible()) {
        if (this.FLookupListBox.FItems.GetCount() > 0) {
          this.FLookupListBox.SetItemIndex(this.FLookupListBox.FItems.GetCount() - 1)}
         else this.FLookupListBox.SetItemIndex(-1);
        return;
      };
      if ((this.FKeyDown === 34) && this.IsLookupListVisible()) {
        if (this.FLookupListBox.FItems.GetCount() > 0) {
          if ((this.FLookupListBox.GetItemIndex() + this.FLookup.FDisplayCount) < this.FLookupListBox.FItems.GetCount()) {
            this.FLookupListBox.SetItemIndex(this.FLookupListBox.GetItemIndex() + this.FLookup.FDisplayCount)}
           else this.FLookupListBox.SetItemIndex(this.FLookupListBox.FItems.GetCount() - 1);
        } else this.FLookupListBox.SetItemIndex(-1);
        return;
      };
      if ((this.FKeyDown === 33) && this.IsLookupListVisible()) {
        if (this.FLookupListBox.FItems.GetCount() > 0) {
          if (this.FLookupListBox.GetItemIndex() > this.FLookup.FDisplayCount) {
            this.FLookupListBox.SetItemIndex(this.FLookupListBox.GetItemIndex() - this.FLookup.FDisplayCount)}
           else this.FLookupListBox.SetItemIndex(0);
        } else this.FLookupListBox.SetItemIndex(-1);
        return;
      };
      if ((this.FKeyDown === 38) && this.IsLookupListVisible()) {
        if (this.FLookupListBox.FItems.GetCount() > 0) {
          if (this.FLookupListBox.GetItemIndex() > 0) this.FLookupListBox.SetItemIndex(this.FLookupListBox.GetItemIndex() - 1);
        } else this.FLookupListBox.SetItemIndex(-1);
        pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
        return;
      };
      if ((this.FKeyDown === 40) && this.IsLookupListVisible()) {
        if (this.FLookupListBox.FItems.GetCount() > 0) {
          if ((this.FLookupListBox.GetItemIndex() + 1) < this.FLookupListBox.FItems.GetCount()) this.FLookupListBox.SetItemIndex(this.FLookupListBox.GetItemIndex() + 1);
        } else this.FLookupListBox.SetItemIndex(-1);
        pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
        return;
      };
      if ((this.FKeyDown === 27) && this.IsLookupListVisible()) {
        this.CloseLookup();
        return;
      };
      if ((this.FKeyDown === 46) && (this.GetSelStart() >= this.FPrefix.length)) {
        s = $Self.GetT();
        if (this.GetSelLength() === 0) {
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},(this.GetSelStart() - this.FPrefix.length) + 1,1)}
         else pas.System.Delete({get: function () {
            return s;
          }, set: function (v) {
            s = v;
          }},(this.GetSelStart() - this.FPrefix.length) + 1,this.GetSelLength());
        if ((this.FLengthLimit > 0) && ((this.FixedLength(s) - 1) > this.FLengthLimit)) {
          EatKey();
          return;
        };
        this.SetModified(true);
      };
      if ((this.FMaxLength > 0) && (this.GetSelLength() === 0) && (this.GetT().length >= this.FMaxLength)) return;
      if ((this.FPrefix !== "") && (this.GetSelStart() < this.FPrefix.length)) this.SetSelStart(this.FPrefix.length);
      if (rtl.eqSet(this.FShiftState,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl))) {
        if (this.FKeyDown === 86) {
          cl = pas["WEBLib.TMSFNCUtils"].TTMSFNCClipBoard.GetText();
          at = $impl.IsType(cl);
          allowclip = true;
          var $tmp = this.FEditType$1;
          if ($tmp === $mod.TTMSFNCEditType.etNumeric) {
            allowclip = at === $impl.TTMSFNCEditAutoType.atNumeric}
           else if ($tmp === $mod.TTMSFNCEditType.etSignedNumeric) {
            allowclip = at === $impl.TTMSFNCEditAutoType.atNumeric}
           else if (($tmp === $mod.TTMSFNCEditType.etFloat) || ($tmp === $mod.TTMSFNCEditType.etSignedFloat)) {
            allowclip = at === $impl.TTMSFNCEditAutoType.atFloat}
           else if ($tmp === $mod.TTMSFNCEditType.etUpperCase) {
            cl = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(cl)}
           else if ($tmp === $mod.TTMSFNCEditType.etMixedCase) {
            cl = $impl.ShiftCase(cl)}
           else if ($tmp === $mod.TTMSFNCEditType.etLowerCase) {
            cl = pas["WEBLib.TMSFNCTypes"].AnsiLowerCase(cl)}
           else if ($tmp === $mod.TTMSFNCEditType.etMoney) {
            allowclip = at === $impl.TTMSFNCEditAutoType.atFloat}
           else if ($tmp === $mod.TTMSFNCEditType.etHex) allowclip = at in rtl.createSet($impl.TTMSFNCEditAutoType.atHex,$impl.TTMSFNCEditAutoType.atNumeric);
          if (allowclip) this.InsertText(cl);
          EatKey();
        } else if (this.FKeyDown === 65) {
          this.SelectAll();
          EatKey();
        } else {
          pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
          EatKey();
        };
        return;
      };
      var $tmp1 = this.FEditType$1;
      if ($tmp1 === $mod.TTMSFNCEditType.etString) {}
      else if ($tmp1 === $mod.TTMSFNCEditType.etNumeric) {
        if (!pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch)) EatKey();
      } else if (($tmp1 === $mod.TTMSFNCEditType.etFloat) || ($tmp1 === $mod.TTMSFNCEditType.etSignedFloat)) {
        if (((kch === ",") && (pas.SysUtils.FormatSettings.DecimalSeparator !== ",")) || ((kch === ".") && (pas.SysUtils.FormatSettings.DecimalSeparator !== "."))) {
          EatKey();
          return;
        };
        if (pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === ".") || (kch === ",") || (kch === pas.SysUtils.FormatSettings.DecimalSeparator) || (kch === pas.SysUtils.FormatSettings.ThousandSeparator) || ((this.FEditType$1 === $mod.TTMSFNCEditType.etSignedFloat) && (kch === "-"))) {
          if ((kch === pas.SysUtils.FormatSettings.DecimalSeparator) && (pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,$Self.GetSelText()) === 0) && ((pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,$Self.GetT()) > 0) || (this.FPrecision === 0))) {
            if (this.FPrecision > 0) this.SelectAfterDecimal();
            EatKey();
            return;
          };
          if ((kch === ",") && (pas.System.Pos(",",$Self.GetT()) > 0) && (pas.System.Pos(",",$Self.GetSelText()) === 0) && (kch !== pas.SysUtils.FormatSettings.ThousandSeparator)) {
            EatKey();
            return;
          };
          if ((kch === pas.SysUtils.FormatSettings.ThousandSeparator) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) {
            if (ScanDistance($Self.GetT(),this.GetSelStart())) {
              EatKey();
              return;
            };
          };
          if (ScanPrecision($Self.GetT(),this.GetSelStart()) && (pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) && (this.GetSelLength() === 0)) {
            if ((this.FPrecision > 0) && ((this.GetSelStart() - this.FPrefix.length) >= pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,$Self.GetT())) && pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) && ((this.GetSelStart() - this.FPrefix.length) < $Self.GetT().length)) {
              oldSelStart = this.GetSelStart();
              this.SetText(pas.SysUtils.TStringHelper.Substring$1.call({p: this.GetT(), get: function () {
                  return this.p;
                }, set: function (v) {
                  this.p = v;
                }},0,this.GetSelStart()) + kch + pas.SysUtils.TStringHelper.Substring$1.call({p: this.GetT(), get: function () {
                  return this.p;
                }, set: function (v) {
                  this.p = v;
                }},this.GetSelStart() + 1,this.GetT().length));
              this.SetSelStart(oldSelStart + 1);
              EatKey();
              return;
            } else {
              EatKey();
              return;
            };
          };
          if ((this.GetSelStart() === 0) && ($Self.GetT() === "") && (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) {
            this.SetText("0" + pas.SysUtils.FormatSettings.DecimalSeparator);
            this.SetSelStart(2);
            this.SetModified(true);
            EatKey();
            return;
          };
          if (this.FEditType$1 === $mod.TTMSFNCEditType.etSignedFloat) {
            if ((kch === "-") && (this.GetSelLength() === 0)) {
              s = $Self.GetT();
              oldprec = this.FPrecision;
              this.FPrecision = 0;
              oldSelStart = this.GetSelStart();
              if (pas.System.Pos("-",s) !== 0) {
                pas.System.Delete({get: function () {
                    return s;
                  }, set: function (v) {
                    s = v;
                  }},1,1);
                this.SetText(s + this.FSuffix);
                this.SetModified(true);
                if ((oldSelStart > 0) && (oldSelStart > this.FPrefix.length)) {
                  this.SetSelStart(oldSelStart - 1)}
                 else this.SetSelStart(this.FPrefix.length);
              } else {
                if ((this.GetFloat() !== 0) || (1 > 0)) {
                  this.SetText("-" + $Self.GetT() + this.FSuffix);
                  this.SetSelLength(0);
                  this.SetSelStart(oldSelStart + 1);
                  this.SetModified(true);
                };
              };
              this.FPrecision = oldprec;
              EatKey();
              return;
            };
          };
        } else EatKey();
      } else if ($tmp1 === $mod.TTMSFNCEditType.etSignedNumeric) {
        if (!(pas["WEBLib.TMSFNCTypes"].CharInArray(kch,["-"]) || pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch))) EatKey();
        if ((pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,this.GetT()) > 0) && (Key.get() === pas.SysUtils.FormatSettings.DecimalSeparator)) EatKey();
        if ((pas.System.Pos("-",this.GetT()) > 0) && (Key.get() === "-") && !(this.GetSelLength() === this.GetT().length)) EatKey();
        if ((kch === "-") && (this.GetSelLength() === 0)) {
          s = $Self.GetT();
          oldSelStart = this.GetSelStart();
          if (pas.System.Pos("-",s) !== 0) {
            pas.System.Delete({get: function () {
                return s;
              }, set: function (v) {
                s = v;
              }},1,1);
            this.SetText(s + this.FSuffix);
            this.SetModified(true);
            if ((oldSelStart > 0) && (oldSelStart > this.FPrefix.length)) {
              this.SetSelStart(oldSelStart - 1)}
             else this.SetSelStart(this.FPrefix.length);
          } else {
            if ((this.GetFloat() !== 0) || (1 > 0)) {
              this.SetText("-" + $Self.GetT() + this.FSuffix);
              this.SetSelLength(0);
              this.SetSelStart(oldSelStart + 1);
              this.SetModified(true);
            };
          };
          EatKey();
          return;
        };
      } else if ($tmp1 === $mod.TTMSFNCEditType.etUpperCase) {
        s = pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(s);
        kch = s.charAt(0);
        Key.set(kch);
      } else if ($tmp1 === $mod.TTMSFNCEditType.etLowerCase) {
        s = pas["WEBLib.TMSFNCTypes"].AnsiLowerCase(s);
        kch = s.charAt(0);
        Key.set(kch);
      } else if ($tmp1 === $mod.TTMSFNCEditType.etMoney) {
        if ((kch === pas.SysUtils.FormatSettings.DecimalSeparator) && ((pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,$Self.GetT()) > 0) || (this.FPrecision === 0))) {
          if (this.FPrecision > 0) {
            if (this.GetSelLength() === this.GetT().length) this.SetT("0,0");
            this.SelectAfterDecimal();
            EatKey();
          };
          this.FBlockChange = false;
          return;
        };
        if (pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === "-") || (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) {
          if ((kch === pas.SysUtils.FormatSettings.ThousandSeparator) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) {
            if (ScanDistance($Self.GetT(),this.GetSelStart())) return;
          };
          if (ScanPrecision($Self.GetT(),this.GetSelStart()) && (pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) || (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) && (this.GetSelLength() === 0)) {
            if ((this.FPrecision > 0) && ((this.GetSelStart() - this.FPrefix.length) >= pas.System.Pos(pas.SysUtils.FormatSettings.DecimalSeparator,$Self.GetT())) && pas["WEBLib.TMSFNCTypes"].CharIsNumber(kch) && ((this.GetSelStart() - this.FPrefix.length) < $Self.GetT().length)) {
              this.SetSelLength(1);
            } else {
              EatKey();
              return;
            };
          };
          if ((this.GetSelStart() === 0) && ($Self.GetT() === "") && (kch === pas.SysUtils.FormatSettings.DecimalSeparator)) {
            this.SetText("0" + pas.SysUtils.FormatSettings.DecimalSeparator);
            this.SetSelStart(2);
            this.SetModified(true);
            return;
          };
          if ((kch === "-") && (this.GetSelLength() === 0)) {
            s = $Self.GetT();
            oldprec = this.FPrecision;
            this.FPrecision = 0;
            oldSelStart = this.GetSelStart();
            if (pas.System.Pos("-",s) !== 0) {
              pas.System.Delete({get: function () {
                  return s;
                }, set: function (v) {
                  s = v;
                }},1,1);
              this.SetText(s + this.FSuffix);
              this.SetModified(true);
              if ((oldSelStart > 0) && (oldSelStart > this.FPrefix.length)) {
                this.SetSelStart(oldSelStart - 1)}
               else this.SetSelStart(this.FPrefix.length);
            } else {
              if ((this.GetFloat() !== 0) || (1 > 0)) {
                this.SetText("-" + $Self.GetT() + this.FSuffix);
                this.SetSelLength(0);
                this.SetSelStart(oldSelStart + 1);
                this.SetModified(true);
              };
            };
            this.FPrecision = oldprec;
            EatKey();
            return;
          };
        } else {
          EatKey();
          return;
        };
      } else if ($tmp1 === $mod.TTMSFNCEditType.etHex) {
        if (!pas["WEBLib.TMSFNCTypes"].CharIsHex(kch)) EatKey();
      } else if ($tmp1 === $mod.TTMSFNCEditType.etAlphaNumeric) {
        if (!pas["WEBLib.TMSFNCTypes"].CharIsLetterOrNumber(kch)) EatKey();
      } else if ($tmp1 === $mod.TTMSFNCEditType.etValidChars) {
        if (this.FValidChars !== "") if (pas.System.Pos(pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(s),pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(this.FValidChars)) === 0) EatKey();
      };
      s = $Self.GetT();
      pas["WEBLib.StdCtrls"].TCustomEdit.KeyPress.apply(this,arguments);
      if ($Self.GetT() !== s) this.SetModified(true);
      if (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat,$mod.TTMSFNCEditType.etMoney)) {
        d = this.GetT().length - s.length;
        if (d > 1) this.SetCaretPosition(this.GetCaretPosition() + d);
      };
      if (rtl.eqSet(this.FShiftState,{})) this.UpdateLookup();
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      this.FKeyDown = Key.get();
      this.FShiftState = rtl.refSet(Shift);
    };
    this.KeyUp = function (Key, Shift) {
      var oldSelStart = 0;
      var kch = "\x00";
      pas["WEBLib.Controls"].TControl.KeyUp.apply(this,arguments);
      if (Key.get() === 0) return;
      kch = String.fromCharCode(Key.get());
      if (!(Key.get() in rtl.createSet(113,13,38,40,27))) this.UpdateLookup();
      if ((Key.get() === 9) && this.IsLookupListVisible() && this.FLookup.FAcceptOnTab) this.DoneLookup();
      if (this.FEditType$1 === $mod.TTMSFNCEditType.etMixedCase) {
        oldSelStart = this.GetSelStart();
        this.SetT($impl.ShiftCase(this.GetT()));
        this.SetSelStart(oldSelStart);
      };
      if ((kch !== "") && (kch !== "\b")) this.UpdateAutoComplete();
    };
    this.DoLookupNeedData = function (Value, List, ItemIndex) {
      if (this.FOnLookupNeedData != null) this.FOnLookupNeedData(this,Value,List,ItemIndex);
    };
    this.DoLookupOpen = function () {
      if (this.FOnLookupOpen != null) this.FOnLookupOpen(this);
    };
    this.DoLookupClose = function () {
      if (this.FOnLookupClose != null) this.FOnLookupClose(this);
    };
    this.DoExit = function () {
      var TT = "";
      var OldModified = false;
      pas["WEBLib.Controls"].TControl.DoExit.call(this);
      if ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if ((this.FPrecision >= 0) && (this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat,$mod.TTMSFNCEditType.etMoney))) {
        if ((this.GetT() !== "") || !this.FAllowNumericNullValue) {
          OldModified = this.FIsModified;
          this.SetFloat(this.GetFloat());
          this.SetModified(OldModified);
        };
      };
      if ((this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etNumeric,$mod.TTMSFNCEditType.etSignedNumeric)) && (this.GetT() === "") && !this.FAllowNumericNullValue) this.SetT("0");
      if ((this.FEditType$1 in rtl.createSet($mod.TTMSFNCEditType.etFloat,$mod.TTMSFNCEditType.etSignedFloat,$mod.TTMSFNCEditType.etMoney)) && (this.GetT() === "") && !this.FAllowNumericNullValue) this.SetFloat(0.0);
      TT = pas.SysUtils.Trim(this.GetT());
      if (this.FLookup.FEnabled && this.FLookup.FHistory && (TT !== "")) {
        if (this.FLookup.FDisplayList.IndexOf(TT) === -1) this.FLookup.FDisplayList.Add(TT);
      };
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      pas["WEBLib.StdCtrls"].TCustomEdit.DoHandleChange.apply(this,arguments);
      if (this.FEditType$1 === $mod.TTMSFNCEditType.etMoney) this.AutoSeparators();
      return Result;
    };
    this.LookupListbox = function () {
      var Result = null;
      Result = this.FLookupListBox;
      return Result;
    };
    this.LookupList = function () {
      var Result = null;
      Result = this.FLookupList;
      return Result;
    };
    this.CanFocus = function () {
      var Result = false;
      Result = pas["WEBLib.Controls"].TControl.CanFocus.call(this);
      Result = Result && this.GetAllowFocus();
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FAutoClose = true;
      this.FAllowFocus = true;
      this.SetAutoCompletion(pas["WEBLib.StdCtrls"].TAutoCompletion.acNone);
      this.FLookupFormTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FLookupFormTimer.FOnTimer = rtl.createCallback(this,"DoLookupFormTimer");
      this.FLookupFormTimer.SetEnabled(false);
      this.FLookupFormTimer.SetInterval(1);
      this.FAutoThousandSeparator = true;
      this.FLengthLimit = 0;
      this.FAutoComplete = false;
      this.FLookup = $mod.TTMSFNCEditLookupSettings.$create("Create$1");
      this.FLookupListBoxItems = $mod.TTMSFNCLookupList.$create("Create$1");
      this.FLookupList = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FLookupList.FStaysOpen = true;
      this.FLookupListBox = pas["WEBLib.StdCtrls"].TListBox.$create("Create$1",[this]);
      this.FLookupListBox.SetItemHeight(18);
      this.FLookupListBox.FOnKeyUp = rtl.createCallback(this,"ListKeyUp");
      this.FLookupListBox.FOnMouseUp = rtl.createCallback(this,"ListMouseUp");
      this.FLookupListBox.SetVisible(false);
      this.FLookupListBox.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.SetAutoSize(false);
      this.FLookupList.SetContentControl(this.FLookupListBox);
      this.FLookupList.FFocusedControl = this;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FLookupFormTimer");
      rtl.free(this,"FLookup");
      this.CleanupLookupList();
      if (this.FLookupListBox != null) {
        rtl.free(this,"FLookupListBox");
        this.FLookupListBox = null;
      };
      rtl.free(this,"FLookupListBoxItems");
      if (this.FLookupList != null) {
        rtl.free(this,"FLookupList");
        this.FLookupList = null;
      };
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.DisplayLookup = function () {
      var i = 0;
      var cnt = 0;
      var mw = 0;
      var mh = 0;
      var tw = 0;
      var LookupText = "";
      var idx = 0;
      var obj = null;
      if (!(this.FLookup != null) || !this.FLookup.FEnabled || !(this.FLookupListBox != null)) return;
      mh = (18 * this.FLookup.FDisplayCount) + 4;
      this.FLookupListBox.SetParent(this);
      this.CleanupLookupList();
      this.FLookupListBox.FItems.Clear();
      for (var $l = 1, $end = this.FLookup.FDisplayList.GetCount(); $l <= $end; $l++) {
        i = $l;
        obj = $mod.TTMSFNCLookupListBoxItem.$create("Create$1",[i - 1]);
        this.FLookupListBox.FItems.AddObject($impl.CleanString(this.FLookup.FDisplayList.Get(i - 1)),obj);
        this.FLookupListBoxItems.Add(obj);
      };
      idx = 0;
      this.DoLookupNeedData(LookupText,this.FLookupListBox.FItems,{get: function () {
          return idx;
        }, set: function (v) {
          idx = v;
        }});
      cnt = this.FLookupListBox.FItems.GetCount();
      if ((this.FLookup.FDisplayList.GetCount() > 0) && (this.FLookupListBox.FItems.GetCount() > 0)) this.FLookupListBox.SetItemIndex(idx);
      if (cnt < this.FLookup.FDisplayCount) mh = (cnt * 18) + 4;
      this.FLookupListBox.SetSorted(true);
      mw = 50;
      this.FLookupList.SetDropDownWidth(0);
      if (cnt > 0) {
        for (var $l1 = 1, $end1 = cnt; $l1 <= $end1; $l1++) {
          i = $l1;
          tw = 0;
          if (this.FLookupListBox.GetCanvas() != null) tw = Math.round(this.FLookupListBox.GetCanvas().TextWidth(this.FLookupListBox.FItems.Get(i - 1)));
          if (tw > mw) mw = tw;
        };
        mw = mw + 26;
      };
      if (this.FLookup.FWidth > 0) mw = this.FLookup.FWidth;
      if (this.FLookup.FHeight > 0) mh = this.FLookup.FHeight;
      this.FLookupList.SetPlacementControl(this);
      if (cnt > 0) {
        this.FLookupList.SetDropDownWidth(Math.max(this.FLookup.FMinimumWidth,mw));
        this.FLookupList.SetDropDownHeight(Math.max(this.FLookup.FMinimumHeight,mh));
        if (this.FLookupList.HasPopupForm()) {
          this.FLookupListBox.SetParent(this.FLookupList.FPopupForm);
          this.FLookupList.FPopupForm.SetWidth(Math.round(this.FLookupList.FDropDownWidth));
          this.FLookupList.FPopupForm.SetHeight(Math.round(this.FLookupList.FDropDownHeight));
        };
        if (!this.FLookupList.FIsOpen) this.DoLookupOpen();
        this.FLookupList.SetIsOpen(true);
        this.FLookupFormTimer.SetEnabled(this.FAutoClose);
      } else {
        if (this.FLookupList.FIsOpen) this.DoLookupClose();
        this.FLookupList.SetIsOpen(false);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AllowFocus",3,rtl.boolean,"GetAllowFocus","SetAllowFocus",4,{Default: true});
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",4,{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",4,{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",4,{Default: true});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",4,{Default: false});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",4,{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DoubleBuffered",0,rtl.boolean,"FDoubleBuffered","FDoubleBuffered",4,{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",4,{Default: 0});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",4,{Default: "\x00"});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",4,{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",4,{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("Text",3,rtl.string,"GetT","SetT");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("AutoComplete",0,rtl.boolean,"FAutoComplete","FAutoComplete",4,{Default: false});
    $r.addProperty("EditType",2,$mod.$rtti["TTMSFNCEditType"],"FEditType$1","SetEditType$1",4,{Default: $mod.TTMSFNCEditType.etString});
    $r.addProperty("Lookup",2,$mod.$rtti["TTMSFNCEditLookupSettings"],"FLookup","SetLookup");
    $r.addProperty("ValidChars",0,rtl.string,"FValidChars","FValidChars");
    $r.addProperty("AllowNumericNullValue",0,rtl.boolean,"FAllowNumericNullValue","FAllowNumericNullValue",4,{Default: false});
    $r.addProperty("AutoThousandSeparator",2,rtl.boolean,"FAutoThousandSeparator","SetAutoThousandSeparator",4,{Default: true});
    $r.addProperty("FullTextSearch",0,rtl.boolean,"FFullTextSearch","FFullTextSearch",4,{Default: false});
    $r.addProperty("LengthLimit",0,rtl.smallint,"FLengthLimit","FLengthLimit",4,{Default: 0});
    $r.addProperty("Precision",2,rtl.smallint,"FPrecision","SetPrecision",4,{Default: 0});
    $r.addProperty("PrecisionDisplay",2,$mod.$rtti["TTMSFNCEditPrecisionDisplay"],"FPrecisionDisplay","SetPrecisionDisplay",4,{Default: $mod.TTMSFNCEditPrecisionDisplay.pdNormal});
    $r.addProperty("OnLookupSelect",0,$mod.$rtti["TTMSFNCEditLookupSelectEvent"],"FOnLookupSelect","FOnLookupSelect");
    $r.addProperty("OnLookupIndexSelect",0,$mod.$rtti["TTMSFNCEditLookupIndexSelectEvent"],"FOnLookupIndexSelect","FOnLookupIndexSelect");
    $r.addProperty("OnLookupNeedData",0,$mod.$rtti["TTMSFNCEditLookupNeedDataEvent"],"FOnLookupNeedData","FOnLookupNeedData");
    $r.addProperty("OnLookupOpen",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnLookupOpen","FOnLookupOpen");
    $r.addProperty("OnLookupClose",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnLookupClose","FOnLookupClose");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  rtl.createClass(this,"TTMSFNCEditButton",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FBlockDropDown = false;
      this.FPopup = null;
      this.FEdit = null;
      this.FButton = null;
      this.FPopupControl = null;
      this.FOnButtonClick = null;
      this.FModalPopup = false;
      this.FBitmap = null;
      this.FBitmapName = "";
      this.FButtonSize = 0;
      this.FBitmapContainer = null;
    };
    this.$final = function () {
      this.FPopup = undefined;
      this.FEdit = undefined;
      this.FButton = undefined;
      this.FPopupControl = undefined;
      this.FOnButtonClick = undefined;
      this.FBitmap = undefined;
      this.FBitmapContainer = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.SetPopupControl = function (Value) {
      this.FPopupControl = Value;
      this.FPopup.SetContentControl(this.FPopupControl);
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FEdit.GetT();
      return Result;
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetBitmap = function (Value) {
      this.FBitmap = Value;
      if (this.FButton != null) {
        this.FButton.FBitmaps.Clear();
        this.FButton.FBitmaps.AddBitmap(Value,1.0);
      };
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
      if (this.FButton != null) this.FButton.SetBitmapContainer(Value);
    };
    this.SetBitmapName = function (Value) {
      this.FBitmapName = Value;
      if (this.FButton != null) {
        this.FButton.FBitmaps.Clear();
        this.FButton.FBitmaps.AddBitmapName(Value,1.0);
      };
    };
    this.SetButtonSize = function (Value) {
      this.FButtonSize = Value;
      if (this.FButton != null) this.FButton.SetWidth(Value);
    };
    this.SetText = function (Value) {
      this.FEdit.SetT(Value);
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.SetButtonSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FButtonSize,M,D));
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      if (this.FButton != null) this.FButton.SetAdaptToStyle(this.GetAdaptToStyle());
    };
    this.BeforeDropDown = function () {
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if ((this.FButton != null) && (this.FBitmapContainer != null) && (this.FBitmapName !== "")) {
        this.FButton.FBitmaps.Clear();
        this.FButton.FBitmaps.AddBitmapName(this.FBitmapName,1.0);
      };
    };
    this.EditKeyDown = function (Sender, Key, Shift) {
      if (this.FOnKeyDown != null) this.FOnKeyDown(this,Key,rtl.refSet(Shift));
      if (!(pas.Classes.TShiftState$a.ssAlt in Shift) && (Key.get() === 115)) {
        this.DropDown();
        return;
      };
    };
    this.EditKeyUp = function (Sender, Key, Shift) {
      if (this.FOnKeyUp != null) this.FOnKeyUp(this,Key,rtl.refSet(Shift));
    };
    this.PopupKeyDown = function (Sender, Key, Shift) {
      var $tmp = Key.get();
      if ($tmp === 13) {
        this.DropDown();
      };
    };
    this.Notification = function (AComponent, Operation) {
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FPopupControl)) this.FPopupControl = null;
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FBitmapContainer)) this.FBitmapContainer = null;
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
    };
    this.ButtonClick = function (Sender) {
      if (!this.FBlockDropDown) this.DropDown();
      this.FBlockDropDown = false;
      if (this.FOnButtonClick != null) this.FOnButtonClick(this);
    };
    this.BitmapChanged = function (Sender) {
      if (this.FButton != null) {
        this.FButton.FBitmaps.Clear();
        this.FButton.FBitmaps.AddBitmap(this.FBitmap,1.0);
      };
    };
    this.Create$1 = function (AOwner) {
      var res = "";
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      this.FModalPopup = false;
      this.FButton = pas["WEBLib.TMSFNCToolBar"].TTMSFNCToolBarDropDownButton.$create("Create$1",[this]);
      this.FButton.SetTabStop(false);
      this.FButton.SetAllowFocus(false);
      this.FButton.FStored = false;
      this.FButton.SetWidth(18);
      this.FButton.FAppearance.SetRounding(0);
      this.FButton.SetAlign(pas["WEBLib.Controls"].TAlign.alRight);
      this.FButton.SetParent(this);
      this.FButton.FOnClick = rtl.createCallback(this,"ButtonClick");
      res = pas["WEBLib.TMSFNCToolBar"].TMSFNCTOOLBAREXPANDSVG;
      this.FButton.FBitmaps.AddBitmapFromResource$1(res,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FButton.FDisabledBitmaps.AddBitmapFromResource$1(res,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FButton.FHoverBitmaps.AddBitmapFromResource$1(res,pas["WEBLib.TMSFNCTypes"].HInstance(),1.0);
      this.FEdit = $mod.TTMSFNCEdit.$create("Create$1",[this]);
      this.FEdit.SetParent(this);
      this.FEdit.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      this.FEdit.FOnKeyDown = rtl.createCallback(this,"EditKeyDown");
      this.FEdit.FOnKeyUp = rtl.createCallback(this,"EditKeyUp");
      this.FPopup = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FPopup.SetPlacement(pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppBottom);
      this.FPopup.FStored = false;
      this.FPopup.SetDragWithParent(true);
      this.FPopup.SetWidth(240);
      this.FPopup.SetHeight(160);
      this.FButtonSize = 18;
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.SetWidth(118);
      this.SetHeight(22);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FButton");
      rtl.free(this,"FPopup");
      rtl.free(this,"FBitmap");
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Destroy.call(this);
    };
    this.DropDown = function () {
      if (this.FPopupControl != null) {
        this.FPopup.SetPlacementControl(this);
        if (!this.FPopup.FIsOpen) {
          this.BeforeDropDown();
          this.FPopup.Popup(this.FModalPopup);
        } else this.FPopup.SetIsOpen(false);
      };
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("BitmapContainer",3,pas["WEBLib.TMSFNCBitmapContainer"].$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
    $r.addProperty("BitmapName",2,rtl.string,"FBitmapName","SetBitmapName");
    $r.addProperty("ButtonSize",2,rtl.longint,"FButtonSize","SetButtonSize",4,{Default: 18});
    $r.addProperty("PopupControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FPopupControl","SetPopupControl");
    $r.addProperty("OnButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnButtonClick","FOnButtonClick");
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    $impl.TTMSFNCEditAutoType = {"0": "atNumeric", atNumeric: 0, "1": "atFloat", atFloat: 1, "2": "atString", atString: 2, "3": "atDate", atDate: 3, "4": "atTime", atTime: 4, "5": "atHex", atHex: 5};
    $mod.$rtti.$Enum("TTMSFNCEditAutoType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: $impl.TTMSFNCEditAutoType});
    rtl.createClass($impl,"TTMSFNCPopupOpen",pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    $impl.CheckTerminator = function (ch) {
      var Result = false;
      Result = pas["WEBLib.TMSFNCTypes"].CharInArray(ch,[" ",",",".","/","\\",":","*","$","-","(",")","[","]",'"',"'","&"]);
      return Result;
    };
    $impl.ShiftCase = function (AName) {
      var Result = "";
      var I = 0;
      var L = 0;
      var NewName = "";
      var First = false;
      First = true;
      NewName = AName;
      L = AName.length;
      for (var $l = 1, $end = L; $l <= $end; $l++) {
        I = $l;
        if ($impl.CheckTerminator(NewName.charAt(I - 1))) {
          First = true}
         else if (First) {
          NewName = rtl.setCharAt(NewName,I - 1,pas["WEBLib.TMSFNCTypes"].AnsiUpperCase(AName).charAt(I - 1));
          First = false;
        } else NewName = rtl.setCharAt(NewName,I - 1,pas["WEBLib.TMSFNCTypes"].AnsiLowerCase(AName).charAt(I - 1));
        if ((pas.System.Copy(NewName,1,I) === "Mc") || (pas.System.Copy(NewName,1,I) === "Mac") || ((pas.System.Pos(" Mc",NewName) === (I - 2)) && (I > 2)) || ((I > (L - 3)) && ((pas.System.Copy(NewName,I - 1,2) === " I") || (pas.System.Copy(NewName,I - 2,3) === " II")))) First = true;
      };
      Result = NewName;
      return Result;
    };
    $impl.IsType = function (s) {
      var Result = 0;
      var i = 0;
      var isI = false;
      var isF = false;
      var isH = false;
      var th = 0;
      var de = 0;
      var mi = 0;
      Result = $impl.TTMSFNCEditAutoType.atString;
      isI = true;
      isF = true;
      isH = true;
      if (s === "") {
        isI = false;
        isF = false;
        isH = false;
      };
      th = -1;
      de = 0;
      mi = 0;
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        if (!pas["WEBLib.TMSFNCTypes"].CharIsNumber(s.charAt(i - 1))) isI = false;
        if (!pas["WEBLib.TMSFNCTypes"].CharIsNumber(s.charAt(i - 1)) && !pas["WEBLib.TMSFNCTypes"].CharInArray(s.charAt(i - 1),[".",","])) isF = false;
        if (!pas["WEBLib.TMSFNCTypes"].CharIsNumber(s.charAt(i - 1)) && !pas["WEBLib.TMSFNCTypes"].CharIsLetter(s.charAt(i - 1))) isH = false;
        if ((s.charAt(i - 1) === pas.SysUtils.FormatSettings.ThousandSeparator) && ((i - th) < 3)) isF = false;
        if (s.charAt(i - 1) === pas.SysUtils.FormatSettings.ThousandSeparator) th = i;
        if (s.charAt(i - 1) === pas.SysUtils.FormatSettings.DecimalSeparator) de += 1;
        if (s.charAt(i - 1) === "-") mi += 1;
      };
      if (isH && !isI) Result = $impl.TTMSFNCEditAutoType.atHex;
      if (isI) {
        Result = $impl.TTMSFNCEditAutoType.atNumeric}
       else {
        if (isF) Result = $impl.TTMSFNCEditAutoType.atFloat;
      };
      if ((mi > 1) || (de > 1)) Result = $impl.TTMSFNCEditAutoType.atString;
      return Result;
    };
    $impl.HexToInt = function (s) {
      var Result = 0;
      var i = 0;
      var r = 0;
      var m = 0;
      function CharVal(c) {
        var Result = 0;
        Result = 0;
        if ((c >= "0") && (c <= "9")) Result = c.charCodeAt() - 48;
        if ((c >= "A") && (c <= "F")) Result = (c.charCodeAt() - 65) + 10;
        if ((c >= "a") && (c <= "f")) Result = (c.charCodeAt() - 97) + 10;
        return Result;
      };
      r = 0;
      m = 1;
      for (var $l = s.length; $l >= 1; $l--) {
        i = $l;
        r = r + (m * CharVal(s.charAt(i - 1)));
        m = m << 4;
      };
      Result = r;
      return Result;
    };
    $impl.ValStr = function (s) {
      var Result = 0;
      var err = 0;
      pas.System.val$6(s,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      return Result;
    };
    $impl.CleanString = function (s) {
      var Result = "";
      var i = 0;
      i = pas.System.Pos("\r",s);
      if (i > 0) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},i,1);
      i = pas.System.Pos("\n",s);
      if (i > 0) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},i,1);
      i = pas.System.Pos("\x0B",s);
      if (i > 0) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},i,1);
      Result = s;
      return Result;
    };
    $impl.StripThousandSep = function (s) {
      var Result = "";
      while (pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s) > 0) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,s),1);
      Result = s;
      return Result;
    };
    rtl.createClass($impl,"TTMSFNCControlOpen",pas["WEBLib.Controls"].TControl,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    rtl.createClass($impl,"TTMSFNCToolBarDropDownButtonOpen",pas["WEBLib.TMSFNCToolBar"].TTMSFNCToolBarDropDownButton,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
  $mod.$init = function () {
    pas.Classes.RegisterClass($mod.TTMSFNCEditButton);
  };
},["SysUtils","Types","WEBLib.TMSFNCUtils","Math"]);
rtl.module("WEBLib.TMSFNCColorPicker",["System","Classes","WEBLib.TMSFNCCustomPicker","WEBLib.Controls","WEBLib.TMSFNCColorSelector","WEBLib.TMSFNCCustomSelector","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphicsTypes","Types"],function () {
  "use strict";
  var $mod = this;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 1;
  this.$rtti.$Class("TTMSFNCCustomColorPicker");
  rtl.createClass(this,"TTMSFNCColorSelectorEx",pas["WEBLib.TMSFNCColorSelector"].TTMSFNCColorSelector,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCColorSelector"].TTMSFNCColorSelector.$init.call(this);
      this.FPicker = null;
    };
    this.$final = function () {
      this.FPicker = undefined;
      pas["WEBLib.TMSFNCColorSelector"].TTMSFNCColorSelector.$final.call(this);
    };
    this.WrapperSizeChanged = function (AWidth, AHeight) {
      var sz = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelector.WrapperSizeChanged.apply(this,arguments);
      if (this.FPicker != null) {
        this.FPicker.SetDropDownHeight(AHeight);
        this.FPicker.SetDropDownWidth(AWidth);
        sz.cx = AWidth;
        sz.cy = AHeight;
        this.FPicker.GetPopup().SetPopupFormSize(sz);
        this.SetWidth(this.GetWidth() + 1);
        this.SetWidth(this.GetWidth() - 1);
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelector.Create$1.apply(this,arguments);
      if ((AOwner != null) && $mod.TTMSFNCCustomColorPicker.isPrototypeOf(AOwner)) this.FPicker = rtl.as(AOwner,$mod.TTMSFNCCustomColorPicker);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCCustomColorPicker",pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCDefaultPicker,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCDefaultPicker.$init.call(this);
      this.FColorSelector = null;
      this.FOnColorSelected = null;
      this.FCloseOnSelection = false;
      this.FOnColorDeselected = null;
    };
    this.$final = function () {
      this.FColorSelector = undefined;
      this.FOnColorSelected = undefined;
      this.FOnColorDeselected = undefined;
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCDefaultPicker.$final.call(this);
    };
    this.GetSelectedColor = function () {
      var Result = 0;
      Result = this.FColorSelector.GetSelectedColor();
      return Result;
    };
    this.SetSelectedColor = function (Value) {
      this.FColorSelector.SetSelectedColor(Value);
      this.Invalidate();
    };
    this.GetItems$1 = function () {
      var Result = null;
      Result = this.FColorSelector.GetItems();
      return Result;
    };
    this.SetItems$1 = function (Value) {
      this.FColorSelector.GetItems().Assign(Value);
    };
    this.GetMode = function () {
      var Result = 0;
      Result = this.FColorSelector.FMode;
      return Result;
    };
    this.SetMode = function (Value) {
      var s = 0.0;
      this.FColorSelector.SetMode(Value);
      s = 1;
      var $tmp = this.GetMode();
      if ($tmp === pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelectorMode.csmSimple) {
        this.SetDropDownWidth(s * 135);
        this.SetDropDownHeight(s * 135);
      } else if ($tmp === pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelectorMode.csmExtended) {
        this.SetDropDownWidth(s * 200);
        this.SetDropDownHeight(s * 135);
      } else if ($tmp === pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelectorMode.csmExtendedMore) {
        this.SetDropDownWidth(s * 200);
        this.SetDropDownHeight(s * 175);
      };
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.ChangeDPIScale.apply(this,arguments);
    };
    this.DoColorSelected = function () {
      if (this.FOnColorSelected != null) this.FOnColorSelected(this,this.GetSelectedColor());
      this.Invalidate();
    };
    this.ColorSelected = function (Sender, AColor) {
      if (this.FCloseOnSelection && !this.GetSelector().FBlockChange) this.DropDown();
      if (this.FOnColorSelected != null) this.FOnColorSelected(this,AColor);
      this.Invalidate();
    };
    this.ColorDeselected = function (Sender, AColor) {
      if (this.FOnColorDeselected != null) this.FOnColorDeselected(this,AColor);
      this.Invalidate();
    };
    this.DrawContent = function (AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var J = 0;
      var st = null;
      r.$assign(ARect);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,this.ScalePaintValue$1(-3.0),this.ScalePaintValue$1(-4.0));
      pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(r,this.ScalePaintValue$1(1.0),0.5);
      st = AGraphics.SaveState(false);
      try {
        AGraphics.ClipRect(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskNone);
        AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AGraphics.FStroke.SetWidth(1);
        AGraphics.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(255,255,255));
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
        AGraphics.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(211,211,211));
        for (var $l = 0, $end = pas.System.Trunc((r.Right - r.Left) / 5) + 1; $l <= $end; $l++) {
          I = $l;
          for (var $l1 = 0, $end1 = pas.System.Trunc((r.Bottom - r.Top) / 5) + 1; $l1 <= $end1; $l1++) {
            J = $l1;
            if (pas.System.Odd(I + J)) AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(I * 5,J * 5,(I + 1) * 5,(J + 1) * 5)),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmNone);
          };
        };
        AGraphics.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        AGraphics.FFill.SetColor(this.GetSelectedColor());
        AGraphics.FStroke.SetColor(0);
        AGraphics.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
        AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
      } finally {
        AGraphics.RestoreState(st,false);
      };
    };
    this.SelectFirstValue = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectFirstValue.call(this);
      if (this.FColorSelector.GetItems().GetCount() > 0) {
        this.NotifyDataBinderEdit();
        this.FColorSelector.SetSelectedItemIndex(0);
        this.NotifyDataBinderValueChanged();
        this.DoColorSelected();
      };
    };
    this.SelectLastValue = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectLastValue.call(this);
      if (this.FColorSelector.GetItems().GetCount() > 0) {
        this.NotifyDataBinderEdit();
        this.FColorSelector.SetSelectedItemIndex(this.FColorSelector.GetItems().GetCount() - 1);
        this.NotifyDataBinderValueChanged();
        this.DoColorSelected();
      };
    };
    this.SelectNextValue = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectNextValue.call(this);
      if (this.FColorSelector.GetItems().GetCount() > 0) {
        this.NotifyDataBinderEdit();
        if (this.FColorSelector.FSelectedItemIndex === -1) {
          this.FColorSelector.SetSelectedItemIndex(0)}
         else this.FColorSelector.SetSelectedItemIndex(Math.min(this.FColorSelector.GetItems().GetCount() - 1,this.FColorSelector.FSelectedItemIndex + 1));
        this.NotifyDataBinderValueChanged();
        this.DoColorSelected();
      };
    };
    this.SelectPreviousValue = function () {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.SelectPreviousValue.call(this);
      if (this.FColorSelector.GetItems().GetCount() > 0) {
        this.NotifyDataBinderEdit();
        if (this.FColorSelector.FSelectedItemIndex === -1) {
          this.FColorSelector.SetSelectedItemIndex(0)}
         else this.FColorSelector.SetSelectedItemIndex(Math.max(0,this.FColorSelector.FSelectedItemIndex - 1));
        this.NotifyDataBinderValueChanged();
        this.DoColorSelected();
      };
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,1);
      return Result;
    };
    this.CreateSelector = function () {
      var Result = null;
      this.FColorSelector = $mod.TTMSFNCColorSelectorEx.$create("Create$1",[this]);
      this.FColorSelector.FOnColorSelected = rtl.createCallback(this,"ColorSelected");
      this.FColorSelector.FOnColorDeselected = rtl.createCallback(this,"ColorDeselected");
      this.FColorSelector.InitializeDefault();
      Result = this.FColorSelector;
      return Result;
    };
    this.GetFocusedControl = function () {
      var Result = null;
      Result = this.FColorSelector;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomPicker"].TTMSFNCCustomPicker.Create$1.apply(this,arguments);
      this.FCloseOnSelection = true;
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCColorPicker",this.TTMSFNCCustomColorPicker,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCColorPicker);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("DropDownWidth",14,rtl.double,"FDropDownWidth","SetDropDownWidth",4,{stored: "IsDropDownWidthStored"});
    $r.addProperty("DropDownHeight",14,rtl.double,"FDropDownHeight","SetDropDownHeight",4,{stored: "IsDropDownHeightStored"});
    $r.addProperty("Appearance",3,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorAppearance"],"GetAppearance","SetAppearance");
    $r.addProperty("Rows",3,rtl.longint,"GetRows","SetRows",4,{Default: 4});
    $r.addProperty("Columns",3,rtl.longint,"GetColumns","SetColumns",4,{Default: 4});
    $r.addProperty("Items",3,pas["WEBLib.TMSFNCColorSelector"].$rtti["TTMSFNCColorSelectorItems"],"GetItems$1","SetItems$1");
    $r.addProperty("Mode",3,pas["WEBLib.TMSFNCColorSelector"].$rtti["TTMSFNCCustomColorSelectorMode"],"GetMode","SetMode",4,{Default: pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelectorMode.csmSimple});
    $r.addProperty("CloseOnSelection",0,rtl.boolean,"FCloseOnSelection","FCloseOnSelection",4,{Default: true});
    $r.addProperty("OnColorSelected",0,pas["WEBLib.TMSFNCColorSelector"].$rtti["TTMSFNCCustomSelectorColorSelected"],"FOnColorSelected","FOnColorSelected");
    $r.addProperty("OnColorDeselected",0,pas["WEBLib.TMSFNCColorSelector"].$rtti["TTMSFNCCustomSelectorColorDeselected"],"FOnColorDeselected","FOnColorDeselected");
    $r.addProperty("SelectedColor",3,pas["WEBLib.Graphics"].$rtti["TColor"],"GetSelectedColor","SetSelectedColor",4,{Default: -1});
    $r.addProperty("OnItemSelected",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemSelected"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("OnItemDeselected",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemDeselected"],"FOnItemDeselected","FOnItemDeselected");
    $r.addProperty("OnItemClick",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemClick"],"FOnItemClick","FOnItemClick");
    $r.addProperty("SelectedItemIndex",3,rtl.longint,"GetSelectedItemIndex","SetSelectedItemIndex",4,{Default: -1});
    $r.addProperty("OnPickerBeforeDraw",0,pas["WEBLib.TMSFNCCustomPicker"].$rtti["TTMSFNCCustomPickerBeforeDraw"],"FOnPickerBeforeDraw","FOnPickerBeforeDraw");
    $r.addProperty("OnPickerAfterDraw",0,pas["WEBLib.TMSFNCCustomPicker"].$rtti["TTMSFNCCustomPickerAfterDraw"],"FOnPickerAfterDraw","FOnPickerAfterDraw");
    $r.addProperty("OnItemBeforeDrawBackground",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawBackground"],"FOnItemBeforeDrawBackground","FOnItemBeforeDrawBackground");
    $r.addProperty("OnItemAfterDrawBackground",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawBackground"],"FOnItemAfterDrawBackground","FOnItemAfterDrawBackground");
    $r.addProperty("OnItemBeforeDrawContent",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawContent"],"FOnItemBeforeDrawContent","FOnItemBeforeDrawContent");
    $r.addProperty("OnItemAfterDrawContent",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawContent"],"FOnItemAfterDrawContent","FOnItemAfterDrawContent");
    $r.addProperty("OnBeforeDraw",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorBeforeDraw"],"FOnBeforeDraw$1","FOnBeforeDraw$1");
    $r.addProperty("OnAfterDraw",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorAfterDraw"],"FOnAfterDraw$1","FOnAfterDraw$1");
    $r.addProperty("OnItemBeforeDrawText",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemBeforeDrawText"],"FOnItemBeforeDrawText","FOnItemBeforeDrawText");
    $r.addProperty("OnItemAfterDrawText",0,pas["WEBLib.TMSFNCCustomSelector"].$rtti["TTMSFNCCustomSelectorItemAfterDrawText"],"FOnItemAfterDrawText","FOnItemAfterDrawText");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
},["Math","WEBLib.TMSFNCUtils"]);
rtl.module("WEBLib.TMSFNCToolBarPopup",["System","Classes","WEBLib.TMSFNCPopup","WEBLib.TMSFNCToolBar","WEBLib.TMSFNCTypes"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MAJ_VER = 1;
  this.MIN_VER = 0;
  this.REL_VER = 0;
  this.BLD_VER = 0;
  this.$rtti.$Class("TTMSFNCCustomToolBarPopup");
  rtl.createClass(this,"TTMSFNCToolBarPopupButton",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FOwner = null;
      this.FButton = null;
      this.FText = "";
      this.FDataBoolean = false;
      this.FTag = 0;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FWidth = 0.0;
      this.FHeight = 0.0;
      this.FEnabled = false;
      this.FVisible = false;
      this.FTop = 0.0;
      this.FLeft = 0.0;
      this.FLastElement = false;
      this.FBitmap = null;
      this.FDataPointer = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FButton = undefined;
      this.FDataObject = undefined;
      this.FBitmap = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetText = function (Value) {
      if (this.FText !== Value) {
        this.FText = Value;
        if (this.FButton != null) this.FButton.SetText(this.FText);
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.SetHeight = function (Value) {
      if (this.FHeight !== Value) {
        this.FHeight = Value;
        if ((this.FButton != null) && (this.FHeight > -1)) this.FButton.SetHeight(Math.round(this.FHeight));
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.SetWidth = function (Value) {
      if (this.FWidth !== Value) {
        this.FWidth = Value;
        if ((this.FButton != null) && (this.FWidth > -1)) this.FButton.SetWidth(Math.round(this.FWidth));
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.IsHeightStored = function () {
      var Result = false;
      Result = this.FHeight !== -1;
      return Result;
    };
    this.IsWidthStored = function () {
      var Result = false;
      Result = this.FWidth !== -1;
      return Result;
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        if (this.FButton != null) this.FButton.SetEnabled(this.FEnabled);
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        if (this.FButton != null) this.FButton.SetVisible(this.FVisible);
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.IsLeftStored = function () {
      var Result = false;
      Result = this.FLeft !== -1;
      return Result;
    };
    this.IsTopStored = function () {
      var Result = false;
      Result = this.FTop !== -1;
      return Result;
    };
    this.SetLeft = function (Value) {
      if (this.FLeft !== Value) {
        this.FLeft = Value;
        if ((this.FButton != null) && (this.FLeft > -1)) this.FButton.SetLeft(Math.round(this.FLeft));
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.SetTop = function (Value) {
      if (this.FTop !== Value) {
        this.FTop = Value;
        if ((this.FButton != null) && (this.FTop > -1)) this.FButton.SetTop(Math.round(this.FTop));
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.SetLastElement = function (Value) {
      if (this.FLastElement !== Value) {
        this.FLastElement = Value;
        if (this.FButton != null) this.FButton.SetLastElement(this.FLastElement);
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.SetBitmap = function (Value) {
      if (this.FBitmap !== Value) {
        this.FBitmap.Assign(Value);
        if ((this.FButton != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FBitmap)) {
          this.FButton.FBitmaps.Clear();
          this.FButton.FBitmaps.AddBitmap(this.FBitmap,1.0);
        };
        if (this.FOwner != null) this.FOwner.UpdateToolBar();
      };
    };
    this.BitmapChanged = function (Sender) {
      if ((this.FButton != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(this.FBitmap)) {
        this.FButton.FBitmaps.Clear();
        this.FButton.FBitmaps.AddBitmap(this.FBitmap,1.0);
      };
      if (this.FOwner != null) this.FOwner.UpdateToolBar();
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner = rtl.as(this.FCollection,$mod.TTMSFNCToolBarPopupButtons).FOwner$1;
      this.FBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FBitmap.FOnChange = rtl.createCallback(this,"BitmapChanged");
      this.FWidth = -1;
      this.FHeight = -1;
      this.FTop = -1;
      this.FLeft = -1;
      this.FVisible = true;
      this.FEnabled = true;
      this.FLastElement = false;
      if ((this.FOwner != null) && (this.FOwner.FToolBar != null)) {
        this.FButton = pas["WEBLib.TMSFNCToolBar"].TTMSFNCToolBarButton.$create("Create$1",[this.FOwner.FToolBar]);
        this.FButton.SetTabStop(false);
        this.FButton.SetAllowFocus(false);
        this.FButton.SetParent(this.FOwner.FToolBar);
        this.FButton.FOnClick = rtl.createCallback(this.FOwner,"ToolBarButtonClick");
      };
      if (this.FOwner != null) {
        if (this.FOwner.FToolBar != null) this.FOwner.FToolBar.AddCustomControl(this.FButton,this.GetIndex());
        this.FOwner.UpdateToolBar();
      };
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCToolBarPopupButton.isPrototypeOf(Source)) {
        this.FText = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FText;
        this.FWidth = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FWidth;
        this.FHeight = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FHeight;
        this.FLeft = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FLeft;
        this.FTop = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FTop;
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FEnabled;
        this.FVisible = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FVisible;
        this.FBitmap.Assign(rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FBitmap);
        this.FLastElement = rtl.as(Source,$mod.TTMSFNCToolBarPopupButton).FLastElement;
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FBitmap");
      pas.Classes.TCollectionItem.Destroy.call(this);
      if (this.FOwner != null) this.FOwner.UpdateToolBar();
    };
    var $r = this.$rtti;
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag");
    $r.addProperty("Left",14,rtl.double,"FLeft","SetLeft",4,{stored: "IsLeftStored"});
    $r.addProperty("Top",14,rtl.double,"FTop","SetTop",4,{stored: "IsTopStored"});
    $r.addProperty("Width",14,rtl.double,"FWidth","SetWidth",4,{stored: "IsWidthStored"});
    $r.addProperty("Height",14,rtl.double,"FHeight","SetHeight",4,{stored: "IsHeightStored"});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",4,{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",4,{Default: true});
    $r.addProperty("LastElement",2,rtl.boolean,"FLastElement","SetLastElement",4,{Default: false});
    $r.addProperty("Bitmap",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FBitmap","SetBitmap");
  });
  rtl.createClass(this,"TTMSFNCToolBarPopupButtons",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.CreateItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCToolBarPopupButton;
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner$1;
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,this.CreateItemClass());
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
  });
  this.$rtti.$MethodVar("TTMSFNCToolBarPopupButtonClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AButton",this.$rtti["TTMSFNCToolBarPopupButton"]]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCCustomToolBarPopup",pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomNonFocusablePopup,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomNonFocusablePopup.$init.call(this);
      this.FActivate = false;
      this.FToolBar = null;
      this.FButtons = null;
      this.FButtonClick = null;
      this.FOnDeactivate = null;
      this.FOnActivate = null;
    };
    this.$final = function () {
      this.FToolBar = undefined;
      this.FButtons = undefined;
      this.FButtonClick = undefined;
      this.FOnDeactivate = undefined;
      this.FOnActivate = undefined;
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomNonFocusablePopup.$final.call(this);
    };
    this.SetButtons = function (Value) {
      this.FButtons.Assign(Value);
    };
    this.GetAutoAlign = function () {
      var Result = false;
      Result = this.FToolBar.FAutoAlign;
      return Result;
    };
    this.SetAutoAlign = function (Value) {
      this.FToolBar.SetAutoAlign(Value);
    };
    this.GetDragGrip = function () {
      var Result = false;
      Result = this.FToolBar.FAppearance.FDragGrip;
      return Result;
    };
    this.SetDragGrip = function (Value) {
      this.FToolBar.FAppearance.SetDragGrip(Value);
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,0);
      return Result;
    };
    this.CreateToolBar = function () {
      var Result = null;
      Result = pas["WEBLib.TMSFNCToolBar"].TTMSFNCToolBar.$create("Create$1",[this]);
      return Result;
    };
    this.FindPopupButton = function (AButton) {
      var Result = null;
      var I = 0;
      Result = null;
      for (var $l = 0, $end = this.FButtons.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (AButton === this.FButtons.GetItem$1(I).FButton) {
          Result = this.FButtons.GetItem$1(I);
          break;
        };
      };
      return Result;
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomPopup.SetAdaptToStyle.apply(this,arguments);
      if (this.FToolBar != null) this.FToolBar.SetAdaptToStyle(this.FAdaptToStyle);
    };
    this.UpdateControls = function (Sender) {
      this.UpdateToolBar();
    };
    this.UpdateToolBar = function () {
      if ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.SetDropDownWidth(this.FToolBar.GetWidth());
      this.SetDropDownHeight(this.FToolBar.GetHeight());
    };
    this.PrepareToolBar = function () {
      if (this.FToolBar != null) this.FToolBar.SetAdaptToStyle(this.FAdaptToStyle);
    };
    this.ActivatePopup = function () {
      this.DoCreatePopup(false);
    };
    this.DeactivatePopup = function () {
      this.ClosePopup();
    };
    this.DoClosePopup = function () {
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomPopup.DoClosePopup.call(this);
      this.DestroyPopupForm();
    };
    this.ToolBarClick = function (Sender) {
      this.ActivatePreviousWindow();
    };
    this.ToolBarButtonClick = function (Sender) {
      if (this.FButtonClick != null) this.FButtonClick(this,this.FindPopupButton(rtl.as(Sender,pas["WEBLib.TMSFNCToolBar"].TTMSFNCToolBarButton)));
      this.ActivatePreviousWindow();
    };
    this.DoDragGripMoving = function (Sender, ADeltaX, ADeltaY) {
      if (this.FPopupForm != null) {
        this.FPopupForm.SetLeft(this.FPopupForm.GetLeft() - Math.round(ADeltaX));
        this.FPopupForm.SetTop(this.FPopupForm.GetTop() - Math.round(ADeltaY));
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomNonFocusablePopup.Create$1.apply(this,arguments);
      this.SetPlacement(pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppMouse);
      this.FButtons = $mod.TTMSFNCToolBarPopupButtons.$create("Create$3",[this]);
      this.FToolBar = this.CreateToolBar();
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.FToolBar.SetParent(this);
      this.FToolBar.SetAutoAlign(true);
      this.FToolBar.FOnClick = rtl.createCallback(this,"ToolBarClick");
      this.FToolBar.SetTabStop(false);
      this.FToolBar.SetAllowFocus(false);
      this.FToolBar.FOptionsMenu.SetShowButton(false);
      this.FToolBar.FAppearance.SetDragGrip(false);
      this.FToolBar.FOnDragGripMoving = rtl.createCallback(this,"DoDragGripMoving");
      this.FToolBar.FAutoMoveToolBar = false;
      this.FToolBar.FOnUpdateControls = rtl.createCallback(this,"UpdateControls");
      this.SetContentControl(this.FToolBar);
      return this;
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomPopup.Assign.apply(this,arguments);
      if ($mod.TTMSFNCCustomToolBarPopup.isPrototypeOf(Source)) {
        this.FButtons.Assign(rtl.as(Source,$mod.TTMSFNCCustomToolBarPopup).FButtons);
        this.SetAutoAlign(rtl.as(Source,$mod.TTMSFNCCustomToolBarPopup).GetAutoAlign());
        this.SetDragGrip(rtl.as(Source,$mod.TTMSFNCCustomToolBarPopup).GetDragGrip());
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FButtons");
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomNonFocusablePopup.Destroy.call(this);
    };
    this.Activate = function () {
      var frm = null;
      if (this.Activated()) this.Deactivate();
      if (this.FToolBar != null) {
        this.FToolBar.SetParent(frm);
        this.FToolBar.SetVisible(false);
      };
      this.PrepareToolBar();
      this.ActivatePopup();
      this.UpdateToolBar();
      this.FActivate = true;
      if (this.FOnActivate != null) this.FOnActivate(this);
    };
    this.Deactivate = function () {
      this.DeactivatePopup();
      this.FActivate = false;
      if (this.FOnDeactivate != null) this.FOnDeactivate(this);
    };
    this.DropDownActive = function () {
      var Result = false;
      Result = false;
      if (this.FToolBar != null) Result = this.FToolBar.DropDownActive();
      return Result;
    };
    this.Activated = function () {
      var Result = false;
      Result = this.HasPopupForm();
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCToolBarPopup",this.TTMSFNCCustomToolBarPopup,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCToolBarPopup);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AdaptToStyle",2,rtl.boolean,"FAdaptToStyle","SetAdaptToStyle",4,{Default: false});
    $r.addProperty("OnButtonClick",0,$mod.$rtti["TTMSFNCToolBarPopupButtonClickEvent"],"FButtonClick","FButtonClick");
    $r.addProperty("AutoAlign",3,rtl.boolean,"GetAutoAlign","SetAutoAlign",4,{Default: true});
    $r.addProperty("Buttons",2,$mod.$rtti["TTMSFNCToolBarPopupButtons"],"FButtons","SetButtons");
    $r.addProperty("Placement",2,pas["WEBLib.TMSFNCPopup"].$rtti["TTMSFNCPopupPlacement"],"FPlacement","SetPlacement",4,{Default: pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppBottom});
    $r.addProperty("PlacementRectangle",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FPlacementRectangle","SetPlacementRectangle");
    $r.addProperty("PlacementControl",2,pas["WEBLib.Controls"].$rtti["TControl"],"FPlacementControl","SetPlacementControl");
    $r.addProperty("OnActivate",0,pas.Classes.$rtti["TNotifyEvent"],"FOnActivate","FOnActivate");
    $r.addProperty("OnDeactivate",0,pas.Classes.$rtti["TNotifyEvent"],"FOnDeactivate","FOnDeactivate");
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("DragGrip",3,rtl.boolean,"GetDragGrip","SetDragGrip",4,{Default: false});
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTMSFNCToolBarOpen",pas["WEBLib.TMSFNCToolBar"].TTMSFNCToolBar,function () {
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCStylesManager);
      rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
      rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
      rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
      rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
      rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
      rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
},["WEBLib.Forms","WEBLib.TMSFNCUtils","Types"]);
rtl.module("WEBLib.TMSFNCCustomGrid",["System","Classes","WEBLib.TMSFNCEdit","WEBLib.TMSFNCPersistence","WEBLib.TMSFNCCustomComponent","WEBLib.StdCtrls","WEBLib.TMSFNCColorPicker","WEBLib.TMSFNCImage","WEBLib.TMSFNCGridData","WEBLib.TMSFNCGridCell","WEBLib.TMSFNCPopup","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCToolBarPopup","Types","WEBLib.TMSFNCTypes","WEBLib.Controls","WEBLib.TMSFNCGridOptions","WEBLib.TMSFNCGridDataUtil","WEBLib.TMSFNCGraphicsTypes","WEBLib.ExtCtrls"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TTMSFNCGridDocURL = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/ttmsfncgrid/";
  this.MAJ_VER = 1;
  this.MIN_VER = 1;
  this.REL_VER = 0;
  this.BLD_VER = 8;
  this.SCROLLINGDELAY = 0;
  this.SWIPECOUNT = 300;
  this.DOWNCOUNT = 100;
  this.$rtti.$Class("TTMSFNCCustomGrid");
  this.TTMSFNCGridCustomToolBarPopupMode = {"0": "tpmActiveCell", tpmActiveCell: 0, "1": "tpmHoverCell", tpmHoverCell: 1, "2": "tpmHoverNormalCell", tpmHoverNormalCell: 2, "3": "tpmNone", tpmNone: 3};
  this.$rtti.$Enum("TTMSFNCGridCustomToolBarPopupMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGridCustomToolBarPopupMode});
  rtl.createClass(this,"TTMSFNCGridCustomToolBarPopup",pas["WEBLib.TMSFNCToolBarPopup"].TTMSFNCCustomToolBarPopup,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCToolBarPopup"].TTMSFNCCustomToolBarPopup.$init.call(this);
      this.FGrid = null;
      this.FGridCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
    };
    this.$final = function () {
      this.FGrid = undefined;
      this.FGridCell = undefined;
      pas["WEBLib.TMSFNCToolBarPopup"].TTMSFNCCustomToolBarPopup.$final.call(this);
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.TMSFNCPopup"].TTMSFNCCustomPopup.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FGrid)) this.FGrid = null;
    };
    this.Create$1 = function (AOwner) {
      var I = 0;
      pas["WEBLib.TMSFNCToolBarPopup"].TTMSFNCCustomToolBarPopup.Create$1.apply(this,arguments);
      if (this.IsDesignTime() && (AOwner != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AOwner)) {
        for (var $l = 0, $end = AOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ($mod.TTMSFNCCustomGrid.isPrototypeOf(AOwner.GetComponent(I))) {
            this.FGrid = rtl.as(AOwner.GetComponent(I),$mod.TTMSFNCCustomGrid);
            this.FGrid.FToolBarPopup = this;
            break;
          };
        };
      };
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridColorPicker",pas["WEBLib.TMSFNCColorPicker"].TTMSFNCColorPicker,function () {
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridEdit",pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit,function () {
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit.Create$1.apply(this,arguments);
      this.FAutoClose = false;
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridComboBox",pas["WEBLib.StdCtrls"].TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridTrackBar",pas["WEBLib.ExtCtrls"].TTrackBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridMemo",pas["WEBLib.StdCtrls"].TMemo,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridDatePicker",pas["WEBLib.StdCtrls"].TDateTimePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridSpinBox",pas["WEBLib.StdCtrls"].TSpinEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTMSFNCGridProtectedControl",pas["WEBLib.Controls"].TWinControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellClass",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellClassType",pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellClass"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridTopLeftChanged",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ATopRow",rtl.longint],["ALeftCol",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellData",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellString",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellProperties",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Cell",pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCell"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellMergeInfo",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["ABaseCol",rtl.longint,1],["ABaseRow",rtl.longint,1],["AColSpan",rtl.longint,1],["ARowSpan",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellEditorCustomClassType",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditorCustomClassType",pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridEditorClass"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellEditorType",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditorType",pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridEditorType"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditGetData",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["CellString",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellEditorProperties",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditValidateData",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["CellString",rtl.string,1],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditSetData",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["CellString",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellComboCloseUp",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["ItemIndex",rtl.longint],["AValue",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditGetColor",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["CellColor",pas["WEBLib.Graphics"].$rtti["TColor"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditValidateColor",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["CellColor",pas["WEBLib.Graphics"].$rtti["TColor"],1],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditSetColor",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["CellColor",pas["WEBLib.Graphics"].$rtti["TColor"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditDone",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellEditCancel",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanSizeColumn",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanSizeRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnColumnSize",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["NewWidth",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnRowSize",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["NewHeight",rtl.double,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnColumnSized",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["NewWidth",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnRowSized",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["NewHeight",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnColumnDragged",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["FromCol",rtl.longint],["ToCol",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnRowDragged",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["FromRow",rtl.longint],["ToRow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnBeforeRowDrop",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["FromRow",rtl.longint],["ToRow",rtl.longint,1],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnBeforeColumnDrop",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["FromColumn",rtl.longint],["ToColumn",rtl.longint,1],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanSortColumn",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnColumnSorted",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["Direction",pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridSortDirection"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellAnchorClick",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AAnchor",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellReadOnly",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AReadOnly",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellLayout",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["ALayout",pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"]],["ACellState",pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridCellState"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCellClick",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellIsFixed",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["ACellFixed",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetCellRotation",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["Angle",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnGetRowIsBand",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["ARowBand",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanInsertRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanDeleteRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanAppendColumn",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnCanAppendRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnInsertRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnDeleteRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnAppendColumn",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridOnAppendRow",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARow",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridCellControlEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["ACell",pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCell"]]]), methodkind: 0});
  this.$rtti.$DynArray("TTMSFNCGridCellArray$a",{eltype: pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCell"]});
  this.$rtti.$DynArray("TTMSFNCGridCellArray",{eltype: this.$rtti["TTMSFNCGridCellArray$a"]});
  this.TTMSFNCGridSizeMode = {"0": "smColumnSizing", smColumnSizing: 0, "1": "smRowSizing", smRowSizing: 1, "2": "smPreviousColumnSizing", smPreviousColumnSizing: 2, "3": "smPreviousRowSizing", smPreviousRowSizing: 3};
  this.$rtti.$Enum("TTMSFNCGridSizeMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCGridSizeMode});
  this.TTMSFNCGridDraggingMode = {"0": "dmNone", dmNone: 0, "1": "dmRowDragging", dmRowDragging: 1, "2": "dmColumnDragging", dmColumnDragging: 2};
  this.$rtti.$Enum("TTMSFNCGridDraggingMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridDraggingMode});
  this.$rtti.$MethodVar("TTMSFNCGridCellBeforeDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"],1],["ATextRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"],1],["ADrawText",rtl.boolean,1],["ADrawBackGround",rtl.boolean,1],["ADrawBorder",rtl.boolean,1],["AllowDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridCellEditBeforeExit",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["CellEditor",pas["WEBLib.Controls"].$rtti["TWinControl"]],["AllowExit",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCGridCellAfterDraw",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACol",rtl.longint],["ARow",rtl.longint],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ATextRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]]]), methodkind: 0});
  this.TTMSFNCGridEditCellStart = {"0": "csNone", csNone: 0, "1": "csStart", csStart: 1, "2": "csEnd", csEnd: 2};
  this.$rtti.$Enum("TTMSFNCGridEditCellStart",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridEditCellStart});
  this.TTMSFNCGridTabKeyMode = {"0": "tkmNone", tkmNone: 0, "1": "tkmNormal", tkmNormal: 1, "2": "tkmShift", tkmShift: 2};
  this.$rtti.$Enum("TTMSFNCGridTabKeyMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTMSFNCGridTabKeyMode});
  rtl.createClass(this,"TTMSFNCGridAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FBandLayout = null;
      this.FFocusedLayout = null;
      this.FFixedSelectedLayout = null;
      this.FNormalLayout = null;
      this.FSummaryLayout = null;
      this.FOnChange = null;
      this.FSelectedLayout = null;
      this.FFixedLayout = null;
      this.FGroupLayout = null;
      this.FProgressLayout = null;
      this.FShowFocus = false;
    };
    this.$final = function () {
      this.FBandLayout = undefined;
      this.FFocusedLayout = undefined;
      this.FFixedSelectedLayout = undefined;
      this.FNormalLayout = undefined;
      this.FSummaryLayout = undefined;
      this.FOnChange = undefined;
      this.FSelectedLayout = undefined;
      this.FFixedLayout = undefined;
      this.FGroupLayout = undefined;
      this.FProgressLayout = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetBandLayout = function (Value) {
      this.FBandLayout.Assign(Value);
    };
    this.SetFixedLayout = function (Value) {
      this.FFixedLayout.Assign(Value);
    };
    this.SetFixedSelectedLayout = function (Value) {
      this.FFixedSelectedLayout.Assign(Value);
    };
    this.SetFocusedLayout = function (Value) {
      this.FFocusedLayout.Assign(Value);
    };
    this.SetGroupLayout = function (Value) {
      this.FGroupLayout.Assign(Value);
    };
    this.SetNormalLayout = function (Value) {
      this.FNormalLayout.Assign(Value);
    };
    this.SetSelectedLayout = function (Value) {
      this.FSelectedLayout.Assign(Value);
    };
    this.SetSummaryLayout = function (Value) {
      this.FSummaryLayout.Assign(Value);
    };
    this.SetProgressLayout = function (Value) {
      this.FProgressLayout.Assign(Value);
    };
    this.SetShowFocus = function (Value) {
      if (this.FShowFocus !== Value) {
        this.FShowFocus = Value;
        this.LayoutChanged(this);
      };
    };
    this.LayoutChanged = function (Sender) {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.InitializeDefaultLayout = function () {
      this.FNormalLayout.FFill.SetColor(-1);
      this.FFixedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FFixedLayout.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(230,230,230));
      this.FFixedLayout.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      this.FFixedSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FFixedSelectedLayout.FFill.SetColor(14599344);
      this.FFocusedLayout.FFill.SetColor(14599344);
      this.FFocusedLayout.FFont.SetColor(16777215);
      this.FSelectedLayout.FFill.SetColor(14599344);
      this.FSelectedLayout.FFont.SetColor(16777215);
      this.FBandLayout.FFill.SetColor(14745599);
      this.FGroupLayout.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(110,147,195));
      this.FGroupLayout.FFont.SetColor(16777215);
      this.FSummaryLayout.FFill.SetColor(pas["WEBLib.TMSFNCGraphicsTypes"].MakeGraphicsColor(185,197,213));
    };
    this.Create$1 = function () {
      this.FBandLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FFixedLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FNormalLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FGroupLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FSummaryLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FSelectedLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FFocusedLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FFixedSelectedLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      this.FProgressLayout = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellProgressLayout.$create("Create$1");
      this.FShowFocus = true;
      this.InitializeDefaultLayout();
      this.FProgressLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FBandLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FFixedLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FNormalLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FGroupLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FSummaryLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FSelectedLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FFocusedLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FFixedSelectedLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCGridAppearance.isPrototypeOf(Source)) {
        this.FBandLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FBandLayout);
        this.FFixedSelectedLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FFixedSelectedLayout);
        this.FFixedLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FFixedLayout);
        this.FNormalLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FNormalLayout);
        this.FGroupLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FGroupLayout);
        this.FSummaryLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FSummaryLayout);
        this.FSelectedLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FSelectedLayout);
        this.FFocusedLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FFocusedLayout);
        this.FProgressLayout.Assign(rtl.as(Source,$mod.TTMSFNCGridAppearance).FProgressLayout);
        this.FShowFocus = rtl.as(Source,$mod.TTMSFNCGridAppearance).FShowFocus;
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FProgressLayout");
      rtl.free(this,"FBandLayout");
      rtl.free(this,"FFixedLayout");
      rtl.free(this,"FNormalLayout");
      rtl.free(this,"FGroupLayout");
      rtl.free(this,"FSummaryLayout");
      rtl.free(this,"FSelectedLayout");
      rtl.free(this,"FFocusedLayout");
      rtl.free(this,"FFixedSelectedLayout");
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addProperty("FixedLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FFixedLayout","SetFixedLayout");
    $r.addProperty("NormalLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FNormalLayout","SetNormalLayout");
    $r.addProperty("GroupLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FGroupLayout","SetGroupLayout");
    $r.addProperty("SummaryLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FSummaryLayout","SetSummaryLayout");
    $r.addProperty("SelectedLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FSelectedLayout","SetSelectedLayout");
    $r.addProperty("FocusedLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FFocusedLayout","SetFocusedLayout");
    $r.addProperty("FixedSelectedLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FFixedSelectedLayout","SetFixedSelectedLayout");
    $r.addProperty("BandLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellLayout"],"FBandLayout","SetBandLayout");
    $r.addProperty("ProgressLayout",2,pas["WEBLib.TMSFNCGridCell"].$rtti["TTMSFNCGridCellProgressLayout"],"FProgressLayout","SetProgressLayout");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",4,{Default: true});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TTMSFNCGridAdapter",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$init.call(this);
      this.FBlockAdd = false;
      this.FGrid = null;
      this.FActive = false;
    };
    this.$final = function () {
      this.FGrid = undefined;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.$final.call(this);
    };
    this.SetActive = function (Value) {
      this.FActive = Value;
      if (!(this.FGrid != null)) return;
      this.Initialize();
    };
    this.SetGrid = function (Value) {
      if (this.FGrid !== Value) {
        this.FGrid = Value;
        if (this.FBlockAdd) return;
        this.FBlockAdd = true;
        if (this.FGrid != null) {
          this.FGrid.SetAdapter(this);
          this.Initialize();
        };
        this.FBlockAdd = false;
      };
    };
    this.GetInstance = function () {
      var Result = 0;
      Result = pas["WEBLib.TMSFNCTypes"].HInstance();
      return Result;
    };
    this.AlternateDisplayBuildUp = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.CanCancelEdit = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.StartBuild = function (ARow) {
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FGrid)) this.FGrid = null;
    };
    this.UpdateBounds = function () {
    };
    this.Initialize = function () {
    };
    this.ScrollGrid = function (ADelta, ABeforeDisplayCells, AScrollOnly) {
    };
    this.SelectCell = function (ACell) {
    };
    this.GetCellData = function (ACol, ARow, ACellData) {
    };
    this.GetCellClass = function (ACol, ARow, ACellClassType) {
    };
    this.GetCellProperties = function (ACol, ARow, ACell) {
    };
    this.GetCellEditorProperties = function (ACol, ARow, CellEditor) {
    };
    this.GetCellEditorType = function (ACol, ARow, ACellEditorType) {
    };
    this.GetCellReadOnly = function (ACol, ARow, AReadOnly) {
    };
    this.CellEditGetData = function (ACol, ARow, CellEditor, CellString) {
    };
    this.CellEditValidateData = function (ACol, ARow, CellEditor, CellString, Allow) {
    };
    this.CellEditSetData = function (ACol, ARow, CellEditor, CellString) {
    };
    this.CellEditDone = function (ACol, ARow, CellEditor) {
    };
    this.CellEditCancel = function (ACol, ARow) {
    };
    this.CellBeforeEdit = function (ACol, ARow) {
    };
    this.CellCheckBoxClick = function (ACol, ARow, ACell) {
    };
    this.CellBeforeEditExit = function (ACol, ARow, CellEditor, AllowExit) {
    };
    this.ExportNotification = function (AState, ARow) {
    };
    this.GetColumnDisplayName = function (ACol) {
      var Result = "";
      Result = "";
      return Result;
    };
    this.Create$1 = function (AOwner) {
      var I = 0;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Create$1.apply(this,arguments);
      this.FActive = false;
      if (this.IsDesignTime() && (AOwner != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AOwner)) {
        for (var $l = 0, $end = AOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          I = $l;
          if ($mod.TTMSFNCCustomGrid.isPrototypeOf(AOwner.GetComponent(I))) {
            this.SetGrid(rtl.as(AOwner.GetComponent(I),$mod.TTMSFNCCustomGrid));
            break;
          };
        };
      };
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Active",2,rtl.boolean,"FActive","SetActive",4,{Default: false});
    $r.addProperty("Grid",2,$mod.$rtti["TTMSFNCCustomGrid"],"FGrid","SetGrid");
  });
  rtl.createClass(this,"TTMSFNCCustomGrid",pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.$init.call(this);
      this.FToolBarPopupCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FDummyButtonBitmap = null;
      this.FBlockUpdateAdapter = 0;
      this.FBlockAdd = false;
      this.FKeyUsed = false;
      this.FTimeStart$1 = 0.0;
      this.FTimeStop$1 = 0.0;
      this.FAnimating$1 = false;
      this.FAnimateVerticalPos$1 = false;
      this.FAnimateHorizontalPos$1 = false;
      this.FScrollVTo$1 = 0.0;
      this.FScrollHTo$1 = 0.0;
      this.FAnimateTimer$1 = null;
      this.FFreeEditControlTimer = null;
      this.FDoubleSelection$1 = false;
      this.FSpX$1 = 0.0;
      this.FSpY$1 = 0.0;
      this.FScrollX$1 = 0.0;
      this.FScrollY$1 = 0.0;
      this.FCommentPopup = null;
      this.FDoTouchScroll = false;
      this.FFilterPopup = null;
      this.FActiveComment = "";
      this.FActiveCommentTextColor = 0;
      this.FNodeOpenBitmap = null;
      this.FNodeClosedBitmap = null;
      this.FCellKeyDown = false;
      this.FCellPosX = 0;
      this.FCellPosY = 0;
      this.FContainerWidth = 0.0;
      this.FContainerHeight = 0.0;
      this.FClearMouseDown = false;
      this.ChangeCursor = false;
      this.OldCursor = 0;
      this.FBlockHide = false;
      this.FTabKey = 0;
      this.FTopr = 0;
      this.FLeftC = 0;
      this.FDblClick = false;
      this.FSaveTopCell = null;
      this.FPrevSelection = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$new();
      this.FCellAnchor = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FCellAnchorString = "";
      this.FLookupString = "";
      this.FDraggingMode = 0;
      this.FDragBitmap = null;
      this.FDragFixed = false;
      this.FTouchScrolling$1 = false;
      this.FMouseX$1 = 0.0;
      this.FMouseY$1 = 0.0;
      this.FDragCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FDragScrollCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FEditCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FEditControl = null;
      this.FCellEdit = null;
      this.FCellComboBox = null;
      this.FRealCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FX = 0.0;
      this.FY = 0.0;
      this.FPrevX = 0.0;
      this.FPrevY = 0.0;
      this.FSizeX = 0.0;
      this.FSaveDragX = 0.0;
      this.FSaveDragY = 0.0;
      this.FSizeY = 0.0;
      this.FDragX = 0.0;
      this.FDragY = 0.0;
      this.FDownX$1 = 0.0;
      this.FDownY$1 = 0.0;
      this.FTouchX = 0.0;
      this.FTouchY = 0.0;
      this.FScrollTimer = null;
      this.FDragTimer = null;
      this.FPrevSelectedCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FFirstCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FSaveCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      this.FMouseDown = false;
      this.FMouseDblClick = false;
      this.FMouseUp$1 = false;
      this.FMouseScrollingUp = false;
      this.FMouseSizing = false;
      this.FSizing = false;
      this.FSizeMode = 0;
      this.FMouseDragging = false;
      this.FCStart = 0;
      this.FRStart = 0;
      this.FCStop = 0;
      this.FRStop = 0;
      this.FOldTopRow = 0;
      this.FReset = false;
      this.FCellArray = [];
      this.FOnGetCellClass = null;
      this.FOnGetCellData = null;
      this.FFreezeRows = 0;
      this.FFreezeColumns = 0;
      this.FOnGetCellMergeInfo = null;
      this.FOnCellEditSetData = null;
      this.FOnCellEditDone = null;
      this.FOnGetCellEditorCustomClassType = null;
      this.FOnCellEditValidateData = null;
      this.FOnCellEditGetData = null;
      this.FOnGetCellEditorProperties = null;
      this.FOnCellRadioButtonClick = null;
      this.FOnCellCheckBoxClick = null;
      this.FOnCellBitmapClick = null;
      this.FOnCellCommentClick = null;
      this.FOnCellSortClick = null;
      this.FOnRowSized = null;
      this.FOnColumnSized = null;
      this.FOnCanSizeRow = null;
      this.FOnCanSizeColumn = null;
      this.FOnCanDragRow = null;
      this.FOnCanDragColumn = null;
      this.FOnColumnDragged = null;
      this.FOnRowDragged = null;
      this.FOnRowSize = null;
      this.FOnColumnSize = null;
      this.FOnCellNodeClick = null;
      this.FOnCanSortColumn = null;
      this.FOnColumnSorted = null;
      this.FOnCellAnchorClick = null;
      this.FOnCellClick = null;
      this.FOnFixedCellClick = null;
      this.FOnCellRightClick = null;
      this.FOnFixedCellRightClick = null;
      this.FOnGetCellReadOnly = null;
      this.FOnGetCellLayout = null;
      this.FOnGetCellIsFixed = null;
      this.FOnGetCellEditorType = null;
      this.FCellSpinBox = null;
      this.FCellColorPicker = null;
      this.FCellDatePicker = null;
      this.FCellTrackBar = null;
      this.FOnCellEditGetColor = null;
      this.FOnCellEditSetColor = null;
      this.FOnCellEditValidateColor = null;
      this.FOnGetRowIsBand = null;
      this.FOnCanDeleteRow = null;
      this.FOnCanAppendRow = null;
      this.FOnCanAppendColumn = null;
      this.FOnCanInsertRow = null;
      this.FOnDeleteRow = null;
      this.FOnAppendRow = null;
      this.FOnAppendColumn = null;
      this.FOnInsertRow = null;
      this.FOnCellAfterDraw = null;
      this.FOnCellBeforeDraw = null;
      this.FOnFixedCellDropDownButtonClick = null;
      this.FEditing = false;
      this.FFilterListBox = null;
      this.FFilterTimer = null;
      this.FOnTopLeftChanged = null;
      this.FOnCellEditCancel = null;
      this.FCellMemo = null;
      this.FOnBeforeRowDrop = null;
      this.FOnBeforeColumnDrop = null;
      this.FOnGetCellProperties = null;
      this.FAppearance = null;
      this.FOnBeforeCellEditExit = null;
      this.FAdapter = null;
      this.FOnCellButtonClick = null;
      this.FToolBarPopupMode = 0;
      this.FToolBarPopup = null;
      this.FOnCellComboCloseUp = null;
      this.FOnInternalCellEditDone = null;
      this.FDesignTimeSampleData = false;
      this.FOnFixedCellDblClick = null;
      this.FOnCellDblClick = null;
      this.FOnGetCellRotation = null;
    };
    this.$final = function () {
      this.FToolBarPopupCell = undefined;
      this.FDummyButtonBitmap = undefined;
      this.FAnimateTimer$1 = undefined;
      this.FFreeEditControlTimer = undefined;
      this.FCommentPopup = undefined;
      this.FFilterPopup = undefined;
      this.FNodeOpenBitmap = undefined;
      this.FNodeClosedBitmap = undefined;
      this.FSaveTopCell = undefined;
      this.FPrevSelection = undefined;
      this.FCellAnchor = undefined;
      this.FDragBitmap = undefined;
      this.FDragCell = undefined;
      this.FDragScrollCell = undefined;
      this.FEditCell = undefined;
      this.FEditControl = undefined;
      this.FCellEdit = undefined;
      this.FCellComboBox = undefined;
      this.FRealCell = undefined;
      this.FScrollTimer = undefined;
      this.FDragTimer = undefined;
      this.FPrevSelectedCell = undefined;
      this.FFirstCell = undefined;
      this.FSaveCell = undefined;
      this.FCellArray = undefined;
      this.FOnGetCellClass = undefined;
      this.FOnGetCellData = undefined;
      this.FOnGetCellMergeInfo = undefined;
      this.FOnCellEditSetData = undefined;
      this.FOnCellEditDone = undefined;
      this.FOnGetCellEditorCustomClassType = undefined;
      this.FOnCellEditValidateData = undefined;
      this.FOnCellEditGetData = undefined;
      this.FOnGetCellEditorProperties = undefined;
      this.FOnCellRadioButtonClick = undefined;
      this.FOnCellCheckBoxClick = undefined;
      this.FOnCellBitmapClick = undefined;
      this.FOnCellCommentClick = undefined;
      this.FOnCellSortClick = undefined;
      this.FOnRowSized = undefined;
      this.FOnColumnSized = undefined;
      this.FOnCanSizeRow = undefined;
      this.FOnCanSizeColumn = undefined;
      this.FOnCanDragRow = undefined;
      this.FOnCanDragColumn = undefined;
      this.FOnColumnDragged = undefined;
      this.FOnRowDragged = undefined;
      this.FOnRowSize = undefined;
      this.FOnColumnSize = undefined;
      this.FOnCellNodeClick = undefined;
      this.FOnCanSortColumn = undefined;
      this.FOnColumnSorted = undefined;
      this.FOnCellAnchorClick = undefined;
      this.FOnCellClick = undefined;
      this.FOnFixedCellClick = undefined;
      this.FOnCellRightClick = undefined;
      this.FOnFixedCellRightClick = undefined;
      this.FOnGetCellReadOnly = undefined;
      this.FOnGetCellLayout = undefined;
      this.FOnGetCellIsFixed = undefined;
      this.FOnGetCellEditorType = undefined;
      this.FCellSpinBox = undefined;
      this.FCellColorPicker = undefined;
      this.FCellDatePicker = undefined;
      this.FCellTrackBar = undefined;
      this.FOnCellEditGetColor = undefined;
      this.FOnCellEditSetColor = undefined;
      this.FOnCellEditValidateColor = undefined;
      this.FOnGetRowIsBand = undefined;
      this.FOnCanDeleteRow = undefined;
      this.FOnCanAppendRow = undefined;
      this.FOnCanAppendColumn = undefined;
      this.FOnCanInsertRow = undefined;
      this.FOnDeleteRow = undefined;
      this.FOnAppendRow = undefined;
      this.FOnAppendColumn = undefined;
      this.FOnInsertRow = undefined;
      this.FOnCellAfterDraw = undefined;
      this.FOnCellBeforeDraw = undefined;
      this.FOnFixedCellDropDownButtonClick = undefined;
      this.FFilterListBox = undefined;
      this.FFilterTimer = undefined;
      this.FOnTopLeftChanged = undefined;
      this.FOnCellEditCancel = undefined;
      this.FCellMemo = undefined;
      this.FOnBeforeRowDrop = undefined;
      this.FOnBeforeColumnDrop = undefined;
      this.FOnGetCellProperties = undefined;
      this.FAppearance = undefined;
      this.FOnBeforeCellEditExit = undefined;
      this.FAdapter = undefined;
      this.FOnCellButtonClick = undefined;
      this.FToolBarPopup = undefined;
      this.FOnCellComboCloseUp = undefined;
      this.FOnInternalCellEditDone = undefined;
      this.FOnFixedCellDblClick = undefined;
      this.FOnCellDblClick = undefined;
      this.FOnGetCellRotation = undefined;
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.$final.call(this);
    };
    this.SetFreezeColumns = function (Value) {
      if (this.FFreezeColumns !== Value) {
        this.FFreezeColumns = Value;
        this.UpdateControl(true,true);
      };
    };
    this.SetFreezeRows = function (Value) {
      if (this.FFreezeRows !== Value) {
        this.FFreezeRows = Value;
        this.UpdateControl(true,true);
      };
    };
    this.SetLeftCol = function (Value) {
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      cl.Row = Math.max(this.FFixedRows,Math.min(this.FRStart,this.GetRowCount() - 1 - this.FFixedFooterRows));
      cl.Col = Math.max(this.FFixedColumns,Math.min(Value,this.GetColumnCount() - 1 - this.FFixedRightColumns));
      this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),true);
    };
    this.SetTopRow = function (Value) {
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      cl.Row = Math.max(this.FFixedRows,Math.min(Value,this.GetRowCount() - 1 - this.FFixedFooterRows));
      cl.Col = Math.max(this.FFixedColumns,Math.min(this.FCStart,this.GetColumnCount() - 1 - this.FFixedRightColumns));
      this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),true);
    };
    this.SetC = function (Value) {
      this.SetControlCursor(Value);
      if (this.ChangeCursor) this.OldCursor = Value;
    };
    this.GetLeftCol = function () {
      var Result = 0;
      Result = this.FCStart;
      return Result;
    };
    this.GetTopRow = function () {
      var Result = 0;
      Result = this.FRStart;
      return Result;
    };
    this.GetCellMemo = function () {
      var Result = null;
      if (!(this.FCellMemo != null)) {
        this.FCellMemo = $mod.TTMSFNCGridMemo.$create("Create$1",[this]);
        this.FCellMemo.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        this.FCellMemo.SetAutoSize(false);
        this.FCellMemo.SetTabStop(false);
        this.FCellMemo.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        this.FCellMemo.FDoubleBuffered = false;
        this.FCellMemo.SetShowFocus(false);
        this.FCellMemo.FOnKeyDown = rtl.createCallback(this,"CellEditKeyDown");
        this.FCellMemo.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellMemo;
      return Result;
    };
    this.GetCellEdit = function () {
      var Result = null;
      if (!(this.FCellEdit != null)) {
        this.FCellEdit = $mod.TTMSFNCGridEdit.$create("Create$1",[this]);
        this.FCellEdit.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        this.FCellEdit.SetAutoSize(false);
        this.FCellEdit.SetShowFocus(false);
        this.FCellEdit.SetTabStop(false);
        this.FCellEdit.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        this.FCellEdit.FDoubleBuffered = false;
        this.FCellEdit.FOnKeyDown = rtl.createCallback(this,"CellEditKeyDown");
        this.FCellEdit.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellEdit;
      return Result;
    };
    this.GetCellSpinBox = function () {
      var Result = null;
      if (!(this.FCellSpinBox != null)) {
        this.FCellSpinBox = $mod.TTMSFNCGridSpinBox.$create("Create$1",[this]);
        this.FCellSpinBox.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        this.FCellSpinBox.FAutoSize = false;
        this.FCellSpinBox.SetShowFocus(false);
        this.FCellSpinBox.SetTabStop(false);
        this.FCellSpinBox.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        this.FCellSpinBox.FDoubleBuffered = false;
        this.FCellSpinBox.FOnKeyDown = rtl.createCallback(this,"CellControlKeyDown");
        this.FCellSpinBox.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellSpinBox;
      return Result;
    };
    this.GetCellColorPicker = function () {
      var Result = null;
      if (!(this.FCellColorPicker != null)) {
        this.FCellColorPicker = $mod.TTMSFNCGridColorPicker.$create("Create$1",[this]);
        this.FCellColorPicker.FCloseOnSelection = true;
        this.FCellColorPicker.SetMode(pas["WEBLib.TMSFNCColorSelector"].TTMSFNCCustomColorSelectorMode.csmExtended);
        this.FCellColorPicker.FOnKeyDown = rtl.createCallback(this,"CellComboBoxKeyDown");
        this.FCellColorPicker.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellColorPicker;
      return Result;
    };
    this.GetCellDatePicker = function () {
      var Result = null;
      if (!(this.FCellDatePicker != null)) {
        this.FCellDatePicker = $mod.TTMSFNCGridDatePicker.$create("Create$1",[this]);
        this.FCellDatePicker.SetShowFocus(false);
        this.FCellDatePicker.FOnKeyDown = rtl.createCallback(this,"CellComboBoxKeyDown");
        this.FCellDatePicker.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellDatePicker;
      return Result;
    };
    this.GetCellTrackBar = function () {
      var Result = null;
      if (!(this.FCellTrackBar != null)) {
        this.FCellTrackBar = $mod.TTMSFNCGridTrackBar.$create("Create$1",[this]);
        this.FCellTrackBar.SetShowFocus(false);
        this.FCellTrackBar.FOnKeyDown = rtl.createCallback(this,"CellControlKeyDown");
        this.FCellTrackBar.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellTrackBar;
      return Result;
    };
    this.GetCellComboBox = function () {
      var Result = null;
      if (!(this.FCellComboBox != null)) {
        this.FCellComboBox = $mod.TTMSFNCGridComboBox.$create("Create$1",[this]);
        this.FCellComboBox.SetStyle(pas["WEBLib.StdCtrls"].TComboBoxStyle.csDropDownList);
        this.FCellComboBox.FOnChange = rtl.createCallback(this,"CellComboBoxChange");
        this.FCellComboBox.SetShowFocus(false);
        this.FCellComboBox.FOnKeyDown = rtl.createCallback(this,"CellComboBoxKeyDown");
        this.FCellComboBox.FOnExit = rtl.createCallback(this,"CellExit");
      };
      Result = this.FCellComboBox;
      return Result;
    };
    this.GetC = function () {
      var Result = 0;
      Result = this.FCursor;
      return Result;
    };
    this.SetAppearance = function (Value) {
      if (this.FAppearance !== Value) {
        this.FAppearance.Assign(Value);
      };
    };
    this.SetAdapter = function (Value) {
      if (this.FAdapter !== Value) {
        this.FAdapter = Value;
        if (this.FBlockAdd) return;
        this.FBlockAdd = true;
        if (this.FAdapter != null) {
          this.FAdapter.SetGrid(this);
          this.FAdapter.Initialize();
        };
        this.FBlockAdd = false;
      };
    };
    this.GetBottomRow = function () {
      var Result = 0;
      Result = this.FRStop;
      return Result;
    };
    this.GetRightCol = function () {
      var Result = 0;
      Result = this.FCStop;
      return Result;
    };
    this.GetPrevFocusedCell = function () {
      var Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      Result.$assign(this.FPrevSelectedCell);
      return Result;
    };
    this.SetDesignTimeSampleData = function (Value) {
      this.FDesignTimeSampleData = Value;
      if (this.FDesignTimeSampleData && ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) || (pas.Classes.TComponentStateItem.csReading in this.FComponentState)) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
        this.LoadSampleData();
      };
    };
    this.Animate$1 = function (Sender) {
      var dx = 0.0;
      var dy = 0.0;
      var posx = 0.0;
      var posy = 0.0;
      var animh = false;
      var animv = false;
      posy = this.GetVScrollValue();
      posx = this.GetHScrollValue();
      dx = Math.abs(this.FScrollHTo$1 - posx) / Math.max(1,Math.abs(this.FSpX$1) * 6);
      dy = Math.abs(this.FScrollVTo$1 - posy) / Math.max(1,Math.abs(this.FSpY$1) * 6);
      animv = false;
      if (this.FAnimateVerticalPos$1) animv = $impl.AnimateDouble({get: function () {
          return posy;
        }, set: function (v) {
          posy = v;
        }},{p: this, get: function () {
          return this.p.FScrollVTo$1;
        }, set: function (v) {
          this.p.FScrollVTo$1 = v;
        }},dy,0.01);
      animh = false;
      if (this.FAnimateHorizontalPos$1) animh = $impl.AnimateDouble({get: function () {
          return posx;
        }, set: function (v) {
          posx = v;
        }},{p: this, get: function () {
          return this.p.FScrollHTo$1;
        }, set: function (v) {
          this.p.FScrollHTo$1 = v;
        }},dx,0.01);
      this.FAnimating$1 = animv || animh;
      if (this.FAnimating$1) {
        this.Scroll(posx,posy)}
       else {
        this.FAnimateVerticalPos$1 = false;
        this.FAnimateTimer$1.SetEnabled(false);
        this.FAnimateHorizontalPos$1 = false;
      };
    };
    this.DoFreeEditControl = function (Sender) {
      if (this.FEditControl != null) {
        rtl.free(this,"FEditControl");
        this.FEditControl = null;
      };
      this.FFreeEditControlTimer.SetEnabled(false);
    };
    this.ApplyStyle = function () {
      var c = 0;
      var I = 0;
      var J = 0;
      var cp = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ApplyStyle.call(this);
      this.BeginUpdate();
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleBackgroundFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) this.FFill.SetColor(c);
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleLineFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FStroke.SetColor(c);
        this.FAppearance.FFixedLayout.FStroke.SetColor(c);
        this.FAppearance.FFixedSelectedLayout.FStroke.SetColor(c);
        this.FAppearance.FSelectedLayout.FStroke.SetColor(c);
        this.FAppearance.FNormalLayout.FStroke.SetColor(c);
        this.FAppearance.FFocusedLayout.FStroke.SetColor(c);
        this.FAppearance.FBandLayout.FStroke.SetColor(c);
        this.FAppearance.FGroupLayout.FStroke.SetColor(c);
        this.FAppearance.FSummaryLayout.FStroke.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFixedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FFixedLayout.FFill.SetColor(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleHeaderFillColorTo({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFixedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FFixedLayout.FFill.SetColorTo(c);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFixedSelectedLayout.FFill.SetColor(c);
        this.FAppearance.FFocusedLayout.FFill.SetColor(c);
        this.FAppearance.FSelectedLayout.FFill.SetColor(c);
        this.FAppearance.FGroupLayout.FFill.SetColor(c);
        this.FAppearance.FSummaryLayout.FFill.SetColor(c);
        this.FAppearance.FProgressLayout.SetColor(c);
        this.FAppearance.FFixedSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FFocusedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FGroupLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
        this.FAppearance.FSummaryLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleSelectionFillColorTo({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FAppearance.FFixedSelectedLayout.FFill.SetColorTo(c);
        this.FAppearance.FFocusedLayout.FFill.SetColorTo(c);
        this.FAppearance.FSelectedLayout.FFill.SetColorTo(c);
        this.FAppearance.FGroupLayout.FFill.SetColorTo(c);
        this.FAppearance.FSummaryLayout.FFill.SetColorTo(c);
        this.FAppearance.FFixedSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FFocusedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FGroupLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
        this.FAppearance.FSummaryLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkGradient);
      };
      c = -1;
      if (pas["WEBLib.TMSFNCStyles"].TTMSFNCStyles.GetStyleTextFontColor({get: function () {
          return c;
        }, set: function (v) {
          c = v;
        }})) {
        this.FDefaultFont.SetColor(c);
        this.FAppearance.FFixedLayout.FFont.SetColor(c);
        this.FAppearance.FNormalLayout.FFont.SetColor(c);
        this.FAppearance.FFixedSelectedLayout.FFont.SetColor(c);
        this.FAppearance.FSelectedLayout.FFont.SetColor(c);
        this.FAppearance.FFocusedLayout.FFont.SetColor(c);
        this.FAppearance.FGroupLayout.FFont.SetColor(c);
        this.FAppearance.FSummaryLayout.FFont.SetColor(c);
      };
      this.RemoveAllCells();
      for (var $l = 0, $end = this.FRowList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FRowList.GetItem(I) != null) {
          for (var $l1 = 0, $end1 = this.FRowList.GetItem(I).FData.GetCount() - 1; $l1 <= $end1; $l1++) {
            J = $l1;
            cp = this.FRowList.GetItem(I).FData.GetObject(J);
            if (cp != null) cp.FFontColor = c;
          };
        };
      };
      this.EndUpdate();
    };
    this.SetAdaptToStyle = function (Value) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.SetAdaptToStyle.apply(this,arguments);
      if (this.FCommentPopup != null) this.FCommentPopup.SetAdaptToStyle(true);
      if (this.FFilterPopup != null) this.FFilterPopup.SetAdaptToStyle(true);
    };
    this.ResetToDefaultStyle = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ResetToDefaultStyle.call(this);
      this.FAppearance.InitializeDefaultLayout();
      this.FAppearance.SetShowFocus(true);
      this.FAppearance.FFixedLayout.FFill.SetColor(0xF9F2EE);
      this.FAppearance.FFixedLayout.FFont.SetColor(0x454545);
      this.FAppearance.FNormalLayout.FFill.SetColor(0xFCF8F6);
      this.FAppearance.FNormalLayout.FFont.SetColor(0x7A7A7A);
      this.FAppearance.FSelectedLayout.FFill.SetColor(0xFADEBB);
      this.FAppearance.FSelectedLayout.FFont.SetColor(0x454545);
      this.FAppearance.FFocusedLayout.FFill.SetColor(0xF4BD74);
      this.FAppearance.FFocusedLayout.FFont.SetColor(0x454545);
      this.FAppearance.FBandLayout.FFill.SetColor(0xFEFFFF);
      this.FAppearance.FBandLayout.FFont.SetColor(0x7A7A7A);
      this.FAppearance.FSelectedLayout.FStroke.SetColor(12632256);
      this.FAppearance.FFocusedLayout.FStroke.SetColor(12632256);
      this.FAppearance.FNormalLayout.FStroke.SetColor(12632256);
      this.FAppearance.FNormalLayout.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FFixedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFixedLayout.FStroke.SetColor(12632256);
      this.FAppearance.FFixedLayout.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FFixedLayout.FFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.SetFontSize(this.FAppearance.FFixedLayout.FFont,14,1);
      this.FAppearance.FFixedSelectedLayout.FFont.SetColor(0);
      this.FAppearance.FFixedSelectedLayout.FStroke.SetColor(12632256);
      this.FAppearance.FFixedSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FSelectedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FBandLayout.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FAppearance.FBandLayout.FStroke.SetColor(12632256);
      this.FAppearance.FGroupLayout.FFont.SetColor(0);
      this.FAppearance.FGroupLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FSummaryLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FSummaryLayout.FFont.SetColor(0);
      this.FAppearance.FFocusedLayout.FFill.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid);
      this.FAppearance.FFocusedLayout.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FFill.SetColor(16777215);
      this.FStroke.SetColor(12632256);
      this.RemoveAllCells();
      this.UpdateGridCells(false);
    };
    this.BeforeExport = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.BeforeExport.call(this);
      this.UpdateControl(true,true);
    };
    this.AfterExport = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.AfterExport.call(this);
      this.UpdateControl(true,true);
    };
    this.ChangeDPIScale = function (M, D) {
      var I = 0;
      var J = 0;
      var cp = null;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FOptions.FFiltering.FDropDownWidth = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FOptions.FFiltering.FDropDownWidth,M,D);
      this.FOptions.FFiltering.FDropDownHeight = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FOptions.FFiltering.FDropDownHeight,M,D);
      this.SetDefaultRowHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDefaultRowHeight,M,D));
      this.SetDefaultColumnWidth(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FDefaultColumnWidth,M,D));
      this.FDefaultFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FDefaultFont.FHeight,M,D));
      this.FAppearance.FFixedLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FFixedLayout.FFont.FHeight,M,D));
      this.FAppearance.FNormalLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FNormalLayout.FFont.FHeight,M,D));
      this.FAppearance.FGroupLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FGroupLayout.FFont.FHeight,M,D));
      this.FAppearance.FSummaryLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FSummaryLayout.FFont.FHeight,M,D));
      this.FAppearance.FSelectedLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FSelectedLayout.FFont.FHeight,M,D));
      this.FAppearance.FFocusedLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FFocusedLayout.FFont.FHeight,M,D));
      this.FAppearance.FFixedSelectedLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FFixedSelectedLayout.FFont.FHeight,M,D));
      this.FAppearance.FBandLayout.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FBandLayout.FFont.FHeight,M,D));
      this.CreateColumnProp();
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FColumns.GetItem$1(I).FFixedFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FFixedFont.FHeight,M,D));
        this.FColumns.GetItem$1(I).FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FColumns.GetItem$1(I).FFont.FHeight,M,D));
      };
      for (var $l1 = this.FRowList.GetCount() - 1; $l1 >= 0; $l1--) {
        I = $l1;
        if (this.FRowList.GetItem(I) != null) {
          for (var $l2 = 0, $end1 = this.FRowList.GetItem(I).FData.GetCount() - 1; $l2 <= $end1; $l2++) {
            J = $l2;
            cp = this.FRowList.GetItem(I).FData.GetObject(J);
            if ((cp != null) && cp.IsBaseCell(J,I)) cp.FFontSize = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(cp.FFontSize,M,D);
          };
        };
      };
      this.EndUpdate();
    };
    this.SetRowSelect = function (Row, Value) {
      if (!this.FBlockUpdate && Value) {
        this.FBlockSelectEventHandler = true;
        this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(pas["WEBLib.TMSFNCGridData"].MakeCell(this.FFixedColumns,Row)),rtl.createSet(pas.Classes.TShiftState$a.ssCtrl),false);
        this.FBlockSelectEventHandler = false;
      } else pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.SetRowSelect.apply(this,arguments);
    };
    this.GetColumnDisplayName = function (ACol) {
      var Result = "";
      Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.GetColumnDisplayName.call(this,ACol);
      if (this.FAdapter != null) Result = this.FAdapter.GetColumnDisplayName(ACol);
      return Result;
    };
    this.GetCellAppearance = function (AState, ACol, ARow) {
      var Result = null;
      var c = null;
      var rr = 0;
      var $tmp = AState;
      if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csNormal) {
        if (this.FGroupColumn !== -1) {
          rr = ARow;
          if (this.IsNode(rr)) {
            c = this.GetDefaultGroupLayout()}
           else if (this.IsSummary(rr)) {
            c = this.GetDefaultSummaryLayout()}
           else {
            if (this.IsBand(this.DisplToRealRow(ARow)) && this.FOptions.FBands.FEnabled) {
              c = this.GetDefaultBandLayout()}
             else c = this.GetDefaultNormalLayout();
          };
        } else {
          if (this.IsBand(this.DisplToRealRow(ARow)) && this.FOptions.FBands.FEnabled) {
            c = this.GetDefaultBandLayout()}
           else c = this.GetDefaultNormalLayout();
        };
      } else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFocused) {
        c = this.GetDefaultFocusedLayout()}
       else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFixed) {
        c = this.GetDefaultFixedLayout()}
       else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFixedSelected) {
        c = this.GetDefaultFixedSelectedLayout()}
       else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csSelected) {
        c = this.GetDefaultSelectedLayout()}
       else {
        c = null;
      };
      Result = c;
      return Result;
    };
    this.GetPageScrollSize = function () {
      var Result = 0;
      if ((this.FOptions.FKeyboard.FPageScrollSize === 0) && ((this.GetVerticalScrollMax() * this.GetRowCount()) > 0)) {
        Result = Math.round((this.GetVerticalContentViewPortSize() / this.GetVerticalScrollMax()) * this.GetRowCount())}
       else Result = this.FOptions.FKeyboard.FPageScrollSize;
      return Result;
    };
    this.GetColumnViewPortSize = function () {
      var Result = 0.0;
      var I = 0;
      var cnt = 0;
      var w = 0.0;
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result = 0;
      w = this.GetFixedWidth() + this.GetFixedRightWidth();
      cnt = 0;
      contentr.$assign(this.GetContentRect());
      for (var $l = this.GetColumnCount() - 1 - this.FFixedRightColumns; $l >= 0; $l--) {
        I = $l;
        w = w + this.GetColWidths(I);
        if (w > (contentr.Right - contentr.Left)) {
          Result = Math.max(1,cnt);
          break;
        };
        cnt += 1;
      };
      return Result;
    };
    this.GetRowViewPortSize = function () {
      var Result = 0.0;
      var I = 0;
      var cnt = 0;
      var h = 0.0;
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result = 0;
      h = this.GetFixedHeight() + this.GetFixedFooterHeight();
      cnt = 0;
      contentr.$assign(this.GetContentRect());
      for (var $l = this.GetRowCount() - 1 - this.FFixedFooterRows; $l >= 0; $l--) {
        I = $l;
        h = h + this.GetRowHeights(I);
        if (h > (contentr.Bottom - contentr.Top)) {
          Result = Math.max(1,cnt);
          break;
        };
        cnt += 1;
      };
      return Result;
    };
    this.GetVersion = function () {
      var Result = "";
      Result = this.$class.GetVersionNumber(1,0,0,1);
      return Result;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = $mod.TTMSFNCGridDocURL;
      return Result;
    };
    this.GetHorizontalContentCount = function () {
      var Result = 0;
      Result = this.GetColumnCount() - this.FFixedColumns - this.FFreezeColumns - this.FFixedRightColumns;
      return Result;
    };
    this.GetHorizontalContentViewPortSize = function () {
      var Result = 0.0;
      Result = this.GetColumnViewPortSize();
      return Result;
    };
    this.GetVerticalContentCount = function () {
      var Result = 0;
      Result = this.GetRowCount() - this.FFixedRows - this.FFreezeRows - this.FFixedFooterRows;
      return Result;
    };
    this.GetVerticalContentViewPortSize = function () {
      var Result = 0.0;
      Result = this.GetRowViewPortSize();
      return Result;
    };
    this.GetHorizontalPos = function (AStartCol, AStopCol) {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = AStartCol, $end = AStopCol - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + this.GetColWidths(I);
      };
      return Result;
    };
    this.GetVerticalPos = function (AStartRow, AStopRow) {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = AStartRow, $end = AStopRow - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + this.GetRowHeights(I);
      };
      return Result;
    };
    this.DoIsCellSelected = function (ACol, ARow) {
      var Result = false;
      if (this.FOptions.FSelection.FMode in rtl.createSet(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell)) {
        Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoIsCellSelected.call(this,ACol,ARow)}
       else Result = (ACol >= this.FStartCell.Col) && (ARow >= this.FStartCell.Row) && (ACol <= this.FStopCell.Col) && (ARow <= this.FStopCell.Row);
      return Result;
    };
    this.DoIsFixedCellSelected = function (ACol, ARow) {
      var Result = false;
      Result = ((ACol >= this.FStartCell.Col) && (ACol <= this.FStopCell.Col) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange)) || ((ARow >= this.FStartCell.Row) && (ARow <= this.FStopCell.Row) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) && (this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange));
      if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
        Result = this.GetRowSelect(ARow)}
       else if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) {
        Result = this.GetColumnSelect(ACol)}
       else if (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) Result = this.GetFixedCellSelect(ACol,ARow);
      return Result;
    };
    this.GetDefaultFixedLayout = function () {
      var Result = null;
      Result = this.FAppearance.FFixedLayout;
      return Result;
    };
    this.GetDefaultNormalLayout = function () {
      var Result = null;
      Result = this.FAppearance.FNormalLayout;
      return Result;
    };
    this.GetDefaultGroupLayout = function () {
      var Result = null;
      Result = this.FAppearance.FGroupLayout;
      return Result;
    };
    this.GetDefaultSummaryLayout = function () {
      var Result = null;
      Result = this.FAppearance.FSummaryLayout;
      return Result;
    };
    this.GetDefaultSelectedLayout = function () {
      var Result = null;
      Result = this.FAppearance.FSelectedLayout;
      return Result;
    };
    this.GetDefaultFocusedLayout = function () {
      var Result = null;
      Result = this.FAppearance.FFocusedLayout;
      return Result;
    };
    this.GetDefaultFixedSelectedLayout = function () {
      var Result = null;
      Result = this.FAppearance.FFixedSelectedLayout;
      return Result;
    };
    this.GetDefaultBandLayout = function () {
      var Result = null;
      Result = this.FAppearance.FBandLayout;
      return Result;
    };
    this.GetNodeBitmap = function (AState) {
      var Result = null;
      var $tmp = AState;
      if ($tmp === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsOpen) {
        if (!(this.FNodeClosedBitmap != null)) this.FNodeClosedBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource$1($mod.TMSFNCGRIDCELLNODECLOSED,pas["WEBLib.TMSFNCTypes"].HInstance());
        Result = this.FNodeClosedBitmap;
      } else if ($tmp === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridNodeState.nsClosed) {
        if (!(this.FNodeOpenBitmap != null)) this.FNodeOpenBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource$1($mod.TMSFNCGRIDCELLNODEOPEN,pas["WEBLib.TMSFNCTypes"].HInstance());
        Result = this.FNodeOpenBitmap;
      } else {
        Result = null;
      };
      return Result;
    };
    this.GetDummyButtonBitmap = function (ACell) {
      var Result = null;
      if ((this.FDummyButtonBitmap != null) && ((this.FDummyButtonBitmap.GetWidth() !== ACell.FWidth) || (this.FDummyButtonBitmap.GetHeight() !== ACell.FHeight))) {
        rtl.free(this,"FDummyButtonBitmap");
        this.FDummyButtonBitmap = null;
      };
      if (!(this.FDummyButtonBitmap != null)) {
        this.FDummyButtonBitmap = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
        this.FDummyButtonBitmap.SetSize(ACell.FButtonWidth,ACell.FButtonHeight);
      };
      Result = this.FDummyButtonBitmap;
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.Notification.apply(this,arguments);
      if ((AComponent === this.FAdapter) && (Operation === pas.Classes.TOperation.opRemove)) this.SetAdapter(null);
      if ((AComponent === this.FToolBarPopup) && (Operation === pas.Classes.TOperation.opRemove)) this.FToolBarPopup = null;
    };
    this.AppearanceChanged = function (Sender) {
      this.UpdateControl(true,true);
    };
    this.DoPaintCommentPopup = function (Sender, AGraphics, ARect) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      AGraphics.FFont.SetColor(this.FActiveCommentTextColor);
      r.$assign(ARect);
      pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,-4,-4);
      AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FActiveComment,true,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
    };
    this.ClearFixedSorting = function (ACell) {
      var c = 0;
      var r = 0;
      var ctl = null;
      var cell = null;
      for (var $l = 0, $end = rtl.length(this.FCellArray) - 1; $l <= $end; $l++) {
        c = $l;
        for (var $l1 = 0, $end1 = this.FFixedRows - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          cell = this.FCellArray[c][r];
          if ((cell != null) && pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(cell) && (cell !== ACell)) {
            ctl = rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell);
            ctl.FSortIndex = -1;
            ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone;
          };
        };
      };
    };
    this.HandleMouseLeave = function () {
      var p = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      if ((this.FToolBarPopup != null) && this.FToolBarPopup.Activated() && !this.FEditing) {
        p.$assign(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetMousePos());
        if (!this.FToolBarPopup.PointInPopup(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(p)) && !this.FToolBarPopup.DropDownActive()) this.FToolBarPopup.Deactivate();
      };
    };
    this.HandleDblClick = function (X, Y) {
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDblClick.apply(this,arguments);
      this.FDblClick = true;
      if (this.FMouseDblClick) {
        this.FMouseDblClick = false;
        var $tmp = this.FSizeMode;
        if (($tmp === $mod.TTMSFNCGridSizeMode.smPreviousColumnSizing) || ($tmp === $mod.TTMSFNCGridSizeMode.smColumnSizing)) {
          if (this.FOptions.FMouse.FColumnAutoSizeOnDblClick) this.AutoSizeColumn(this.FDragCell.Col,true,5)}
         else if (($tmp === $mod.TTMSFNCGridSizeMode.smPreviousRowSizing) || ($tmp === $mod.TTMSFNCGridSizeMode.smRowSizing)) if (this.FOptions.FMouse.FRowAutoSizeOnDblClick) this.AutoSizeRow(this.FDragCell.Row,5);
      };
      pt.$assign(this.ScreenToLocalEx(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.GetMousePos())));
      cl.$assign(this.XYToCell(pt.X,pt.Y));
      if ((cl.Col !== -1) && (cl.Row !== -1)) {
        if (this.IsFixed(cl.Col,cl.Row)) {
          this.DoFixedCellDblClick(cl.Col,cl.Row)}
         else this.DoCellDblClick(cl.Col,cl.Row);
      };
      this.FClearMouseDown = true;
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var obj = null;
      var sx = 0.0;
      var sy = 0.0;
      var fixed = false;
      var rowsz = false;
      var colsz = false;
      var allow = false;
      var bctl = false;
      var ct = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var s = false;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HandleMouseDown.apply(this,arguments);
      if (!this.HideEdit(false,true)) {
        ct.$assign(this.XYToCell(X,Y));
        s = true;
        if ((ct.Col !== this.FEditCell.Col) || (ct.Row !== this.FEditCell.Row)) {
          this.CancelEdit();
          s = false;
        };
        if (s) return;
      };
      if (this.CanFocus()) this.SetFocus();
      if ((!(this.FPopupMenu != null) && (pas["WEBLib.Controls"].TMouseButton.mbRight === Button)) || (pas["WEBLib.Controls"].TMouseButton.mbRight !== Button)) this.CaptureEx();
      if (!(Button === pas["WEBLib.Controls"].TMouseButton.mbLeft)) return;
      sx = X;
      sy = Y;
      cell.$assign(this.XYToCell(X,Y));
      obj = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cell))));
      if (obj != null) {
        this.FDragCell.$assign(cell);
        fixed = this.IsFixed(cell.Col,cell.Row);
        if (fixed) {
          rowsz = this.FOptions.FMouse.FFixedRowSizing;
          colsz = this.FOptions.FMouse.FFixedColumnSizing;
        } else {
          rowsz = this.FOptions.FMouse.FRowSizing;
          colsz = this.FOptions.FMouse.FColumnSizing;
        };
        if (rowsz && (((cell.Row < (this.GetRowCount() - this.FFixedFooterRows)) && fixed) || !fixed) && (sy >= ((obj.FTop + obj.FHeight) - this.FOptions.FMouse.FRowSizeMargin)) && (sx > (obj.FLeft + this.FOptions.FMouse.FColumnSizeMargin)) && (sx < ((obj.FLeft + obj.FWidth) - this.FOptions.FMouse.FColumnSizeMargin))) {
          allow = true;
          this.DoCanSizeRow(cell.Row,{get: function () {
              return allow;
            }, set: function (v) {
              allow = v;
            }});
          if (allow) {
            this.FMouseSizing = true;
            this.FSizeMode = $mod.TTMSFNCGridSizeMode.smRowSizing;
          };
        } else if (rowsz && (((cell.Row > this.FFixedRows) && fixed) || !fixed) && (sy <= (obj.FTop + this.FOptions.FMouse.FRowSizeMargin)) && (sx > (obj.FLeft + this.FOptions.FMouse.FColumnSizeMargin)) && (sx < ((obj.FLeft + obj.FWidth) - this.FOptions.FMouse.FColumnSizeMargin))) {
          allow = true;
          this.DoCanSizeRow(cell.Row - 1,{get: function () {
              return allow;
            }, set: function (v) {
              allow = v;
            }});
          if (allow) {
            this.FMouseSizing = true;
            this.FSizeMode = $mod.TTMSFNCGridSizeMode.smPreviousRowSizing;
          };
        } else if (colsz && (((cell.Col < (this.GetColumnCount() - this.FFixedRightColumns)) && fixed) || !fixed) && (sx >= ((obj.FLeft + obj.FWidth) - this.FOptions.FMouse.FColumnSizeMargin)) && (sy > (obj.FTop + this.FOptions.FMouse.FRowSizeMargin)) && (sy < ((obj.FTop + obj.FHeight) - this.FOptions.FMouse.FRowSizeMargin))) {
          allow = true;
          this.DoCanSizeColumn(cell.Col,{get: function () {
              return allow;
            }, set: function (v) {
              allow = v;
            }});
          if (allow) {
            this.FMouseSizing = true;
            this.FSizeMode = $mod.TTMSFNCGridSizeMode.smColumnSizing;
          };
        } else if (colsz && (((cell.Col > this.FFixedColumns) && fixed) || !fixed) && (sx <= (obj.FLeft - this.FOptions.FMouse.FColumnSizeMargin)) && (sy > (obj.FTop + this.FOptions.FMouse.FRowSizeMargin)) && (sy < ((obj.FTop + obj.FHeight) - this.FOptions.FMouse.FRowSizeMargin))) {
          allow = true;
          this.DoCanSizeColumn(cell.Col - 1,{get: function () {
              return allow;
            }, set: function (v) {
              allow = v;
            }});
          if (allow) {
            this.FMouseSizing = true;
            this.FSizeMode = $mod.TTMSFNCGridSizeMode.smPreviousColumnSizing;
          };
        } else {
          this.FMouseDown = true;
          this.FMouseUp$1 = true;
          bctl = false;
          if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(obj)) {
            bctl = false;
            rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).HandleMouseDown(Button,rtl.refSet(Shift),X,Y,{get: function () {
                return bctl;
              }, set: function (v) {
                bctl = v;
              }});
            if (bctl) this.Invalidate();
          };
          if (!bctl) {
            if (!this.IsFixed(cell.Col,cell.Row)) {
              cell.$assign(this.BaseCell(cell.Col,cell.Row));
              if ((cell.Col === this.GetFocusedCell().Col) && (cell.Row === this.GetFocusedCell().Row) && !this.FOptions.FMouse.FDirectEdit) {
                this.FMouseUp$1 = false;
                allow = true;
                this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                    return allow;
                  }, set: function (v) {
                    allow = v;
                  }});
                this.FMouseUp$1 = !allow;
                if (allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csNone,false,"",0);
              } else this.HideEdit(false,false);
            } else {
              this.FDragFixed = this.FOptions.FMouse.FRowDragging && ((cell.Col < this.FFixedColumns) || (cell.Col > (this.GetColumnCount() - 1 - this.FFixedRightColumns)));
              this.FDragFixed = this.FDragFixed || (((this.FOptions.FSorting.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmNone) || this.FOptions.FMouse.FColumnDragging) && ((cell.Row < this.FFixedRows) || (cell.Row > (this.GetRowCount() - 1 - this.FFixedFooterRows))));
            };
          };
        };
      };
      this.FTouchScrolling$1 = false;
      this.FPrevX = X;
      this.FPrevY = Y;
      this.FSizeX = this.FPrevX;
      this.FSizeY = this.FPrevY;
      this.FDragX = this.FPrevX;
      this.FDragY = this.FPrevY;
      this.FDownX$1 = this.FPrevX;
      this.FDownY$1 = this.FPrevY;
      this.FTouchX = this.FPrevX;
      this.FTouchY = this.FPrevY;
      this.FScrollX$1 = this.FPrevX;
      this.FScrollY$1 = this.FPrevY;
      this.FMouseX$1 = this.FPrevX;
      this.FMouseY$1 = this.FPrevY;
      if (this.GetHVisible()) {
        this.FScrollHTo$1 = this.GetHScrollValue()}
       else this.FScrollHTo$1 = 0;
      if (this.GetVVisible()) {
        this.FScrollVTo$1 = this.GetVScrollValue()}
       else this.FScrollVTo$1 = 0;
      this.FCellAnchor.Col = -1;
      this.FCellAnchor.Row = -1;
      this.FFirstCell.Col = -1;
      this.FFirstCell.Row = -1;
      this.FCellAnchorString = "";
      this.FDoubleSelection$1 = !this.FAnimateTimer$1.FEnabled;
      this.FTimeStart$1 = $impl.GetTickCountX();
      this.FTimeStop$1 = this.FTimeStart$1;
      this.FIsMouseDown = true;
      this.FMouseScrollingUp = false;
    };
    this.HandleMouseMove = function (Shift, X, Y) {
      var $Self = this;
      var res = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var enablescroll = false;
      var obj = null;
      var sx = 0.0;
      var sy = 0.0;
      var fixed = false;
      var rowsz = false;
      var colsz = false;
      var cell = null;
      var g = null;
      var bmp = null;
      var dx = 0.0;
      var dy = 0.0;
      var Allow = false;
      var newsz = 0.0;
      var newposx = 0.0;
      var newposy = 0.0;
      var vss = 0.0;
      var hss = 0.0;
      var fxd = false;
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var bctl = false;
      var cr = 0;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var f = 0.0;
      var h = 0.0;
      var v = 0.0;
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      function ShowToolBar() {
        $Self.FToolBarPopup.SetPlacementControl($Self);
        $Self.FToolBarPopup.SetPlacement(pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppAbsolute);
        $Self.FToolBarPopup.FGrid = $Self;
        $Self.FToolBarPopupCell.$assign(res);
        $Self.FToolBarPopup.FGridCell.$assign($Self.FToolBarPopupCell);
        $Self.FToolBarPopup.Activate();
        pt.$assign(pas["WEBLib.TMSFNCTypes"].PointF(obj.FLeft + ((obj.FWidth - $Self.FToolBarPopup.FToolBar.GetWidth()) / 2),(obj.FTop - $Self.FToolBarPopup.FToolBar.GetHeight()) + 1));
        pt.$assign($Self.ConvertClientToScreen(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pt)));
        $Self.FToolBarPopup.FPlacementRectangle.SetLeft(pt.X);
        $Self.FToolBarPopup.FPlacementRectangle.SetTop(pt.Y);
        $Self.FToolBarPopup.FPlacementRectangle.SetRight(pt.X);
        $Self.FToolBarPopup.FPlacementRectangle.SetBottom(pt.Y);
      };
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HandleMouseMove.apply(this,arguments);
      if (this.FMouseDown && !this.HideEdit(false,true)) return;
      if (this.FClearMouseDown) {
        this.FMouseDown = false;
        this.FClearMouseDown = false;
      };
      if (this.FDblClick) {
        this.FDblClick = false;
        this.FMouseDown = false;
        this.ReleaseCaptureEx();
      };
      this.FCellAnchor.Col = -1;
      this.FCellAnchor.Row = -1;
      this.FCellAnchorString = "";
      this.FX = X;
      this.FY = Y;
      r.$assign(this.GetContentClipRect());
      if (this.FMouseDown && ((this.FX < (this.FDownX$1 - this.FOptions.FMouse.FClickMargin)) || (this.FX > (this.FDownX$1 + this.FOptions.FMouse.FClickMargin)) || (this.FY < (this.FDownY$1 - this.FOptions.FMouse.FClickMargin)) || (this.FY > (this.FDownY$1 + this.FOptions.FMouse.FClickMargin)))) {
        if (!this.FDragFixed) {
          this.HideEdit(false,false);
          hss = this.GetCellContainerPosX();
          vss = this.GetCellContainerPosY();
          contentr.$assign(this.GetContentRect());
          this.FDoTouchScroll = this.FOptions.FMouse.FTouchScrolling && ((this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleCell) || (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) || (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) || (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone));
          enablescroll = false;
          if (((-hss > 0) && (this.FX < this.GetFixedWidth())) || ((-hss < (this.GetTotalContentWidth() - this.GetFixedRightWidth())) && (this.FX > (contentr.Right - contentr.Left - this.GetFixedRightWidth()))) || ((-vss > 0) && (this.FY < this.GetFixedHeight())) || ((-vss < (this.GetTotalContentHeight() - this.GetFixedFooterHeight())) && (this.FY > (contentr.Bottom - contentr.Top - this.GetFixedFooterHeight())))) enablescroll = this.FOptions.FMouse.FAutoScrolling && !this.FDoTouchScroll;
          if (this.FX > (contentr.Right - contentr.Left - this.GetFixedRightWidth())) enablescroll = !(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsRow in this.FOptions.FMouse.FFixedCellSelection) && !(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsRowRange in this.FOptions.FMouse.FFixedCellSelection);
          if (this.FY > (contentr.Bottom - contentr.Top - this.GetFixedFooterHeight())) enablescroll = !(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsColumn in this.FOptions.FMouse.FFixedCellSelection) && !(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsColumnRange in this.FOptions.FMouse.FFixedCellSelection);
          this.FScrollTimer.SetEnabled(enablescroll);
          if (!this.FScrollTimer.FEnabled) {
            if (this.FOptions.FMouse.FTouchScrolling && this.FDoTouchScroll) {
              f = this.FOptions.FMouse.FTouchScrollingSensitivity;
              if (this.FScrollMode === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) f = f / 10;
              if (this.FTouchScrolling$1 || (Math.abs(this.FMouseX$1 - X) > 3) || (Math.abs(this.FMouseY$1 - Y) > 3)) {
                if ((Math.abs(X - this.FTouchX) > 0) || (Math.abs(Y - this.FTouchY) > 0)) {
                  this.FTouchScrolling$1 = true;
                  this.FDoubleSelection$1 = false;
                  if (this.FIsMouseDown && !this.FMouseScrollingUp) {
                    if (this.GetHVisible()) {
                      h = this.GetHScrollValue() - ((X - this.FTouchX) * f)}
                     else h = 0;
                    if (this.GetVVisible()) {
                      v = this.GetVScrollValue() - ((Y - this.FTouchY) * f)}
                     else v = 0;
                    this.Scroll(h,v);
                    this.FTouchY = Y;
                    this.FTouchX = X;
                  };
                };
              };
            } else {
              this.FMouseDragging = true;
              res.$assign(this.XYToCell(X,Y));
              if ((res.Col !== -1) && (res.Row !== -1)) {
                fxd = this.IsFixed(res.Col,res.Row);
                var $tmp = this.FOptions.FSelection.FMode;
                if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) {
                  if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsRow in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
                 else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) {
                  if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsColumn in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
                 else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) {
                  if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsRowRange in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
                 else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange) if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsColumnRange in this.FOptions.FMouse.FFixedCellSelection) fxd = false;
                if (!fxd) this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(res),rtl.refSet(Shift),this.FMouseDragging);
              };
            };
          };
        } else {
          if ((this.FDragCell.Col !== -1) && (this.FDragCell.Row !== -1)) {
            if (!(this.FDragBitmap != null)) {
              cell = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.FDragCell))));
              if (cell != null) {
                Allow = this.FOptions.FMouse.FColumnDragging;
                if (Allow) this.DoCanDragColumn(this.FDragCell.Col,{get: function () {
                    return Allow;
                  }, set: function (v) {
                    Allow = v;
                  }});
                if (((this.FDragCell.Row < this.FFixedRows) || (this.FDragCell.Row > (this.GetRowCount() - 1 - this.FFixedFooterRows))) && Allow) {
                  this.UpdateCursor(10);
                  this.FDragBitmap = pas["WEBLib.TMSFNCImage"].TTMSFNCImage.$create("Create$1",[$Self]);
                  this.FDragBitmap.SetWidth(Math.round(cell.FWidth) + 2);
                  this.FDragBitmap.SetHeight(Math.round(Math.min(this.GetHeight(),r.Bottom - r.Top)) + 2);
                  dx = -cell.FLeft;
                  this.FDragBitmap.SetLeft(Math.round(-dx));
                  this.FDragBitmap.SetTop(0);
                  g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[Math.round(this.FDragBitmap.GetWidth()),Math.round(this.FDragBitmap.GetHeight()),false,true]);
                  g.BeginScene();
                  g.FBitmapContainer = this.GetBitmapContainer();
                  g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
                  bmp = this.MakeScreenshot();
                  try {
                    g.BeginScene();
                    g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FDragBitmap.GetWidth(),this.FDragBitmap.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                    g.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(this.FDragBitmap.GetLeft(),this.FDragBitmap.GetTop(),(this.FDragBitmap.GetLeft() + this.FDragBitmap.GetWidth()) - 2,(this.FDragBitmap.GetTop() + this.FDragBitmap.GetHeight()) - 2)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FDragBitmap.GetWidth(),this.FDragBitmap.GetHeight())),bmp,true,false,true,false);
                    g.EndScene();
                    this.FDragBitmap.FBitmaps.AddDrawBitmap(g.FBitmap,1.0);
                  } finally {
                    bmp = rtl.freeLoc(bmp);
                    g.EndScene();
                    g = rtl.freeLoc(g);
                  };
                  this.FDraggingMode = $mod.TTMSFNCGridDraggingMode.dmColumnDragging;
                  this.FSaveDragX = this.FDragBitmap.GetLeft();
                  this.FDragBitmap.SetParent($Self);
                  this.FDragX = this.FX;
                  this.FDragY = this.FY;
                } else {
                  Allow = this.FOptions.FMouse.FRowDragging;
                  if (Allow) this.DoCanDragRow(this.FDragCell.Row,{get: function () {
                      return Allow;
                    }, set: function (v) {
                      Allow = v;
                    }});
                  if (((this.FDragCell.Col < this.FFixedColumns) || (this.FDragCell.Col > (this.GetColumnCount() - 1 - this.FFixedRightColumns))) && Allow) {
                    this.UpdateCursor(10);
                    this.FDragBitmap = pas["WEBLib.TMSFNCImage"].TTMSFNCImage.$create("Create$1",[$Self]);
                    this.FDragBitmap.SetWidth(Math.round(Math.min(this.GetWidth(),r.Right - r.Left)) + 2);
                    this.FDragBitmap.SetHeight(Math.round(cell.FHeight) + 2);
                    dy = -cell.FTop;
                    this.FDragBitmap.SetLeft(0);
                    this.FDragBitmap.SetTop(Math.round(-dy));
                    g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[Math.round(this.FDragBitmap.GetWidth()),Math.round(this.FDragBitmap.GetHeight()),false,true]);
                    g.BeginScene();
                    g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
                    g.FBitmapContainer = this.GetBitmapContainer();
                    bmp = this.MakeScreenshot();
                    try {
                      g.BeginScene();
                      g.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FDragBitmap.GetWidth(),this.FDragBitmap.GetHeight())),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                      g.DrawBitmapPart$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(this.FDragBitmap.GetLeft(),this.FDragBitmap.GetTop(),(this.FDragBitmap.GetLeft() + this.FDragBitmap.GetWidth()) - 2,(this.FDragBitmap.GetTop() + this.FDragBitmap.GetHeight()) - 2)),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,this.FDragBitmap.GetWidth(),this.FDragBitmap.GetHeight())),bmp,true,false,true,false);
                      g.EndScene();
                      this.FDragBitmap.FBitmaps.AddDrawBitmap(g.FBitmap,1.0);
                    } finally {
                      bmp = rtl.freeLoc(bmp);
                      g.EndScene();
                      g = rtl.freeLoc(g);
                    };
                    this.FDraggingMode = $mod.TTMSFNCGridDraggingMode.dmRowDragging;
                    this.FSaveDragY = this.FDragBitmap.GetTop();
                    this.FDragBitmap.SetParent($Self);
                    this.FDragX = this.FX;
                    this.FDragY = this.FY;
                  };
                };
              };
            } else {
              if (((this.FDragCell.Row < this.FFixedRows) || (this.FDragCell.Row > (this.GetRowCount() - 1 - this.FFixedFooterRows))) && this.FOptions.FMouse.FColumnDragging) {
                newposx = this.FSaveDragX + (this.FX - this.FDragX);
                if ((newposx <= (r.Right - r.Left - this.FDragBitmap.GetWidth())) && (newposx >= 0)) {
                  this.FDragBitmap.SetLeft(Math.round(Math.max(0,Math.min(r.Right - r.Left - this.FDragBitmap.GetWidth(),newposx))));
                  this.FSaveDragX = this.FDragBitmap.GetLeft();
                  this.FDragTimer.SetEnabled(false);
                  if ((newposx > this.GetFixedWidth()) && (newposx < (r.Right - r.Left - this.GetFixedRightWidth()))) this.FDragScrollCell.$assign(this.XYToCell(newposx,(r.Bottom - r.Top) / 2));
                } else if (newposx > (r.Right - r.Left - this.FDragBitmap.GetWidth())) {
                  this.FDragBitmap.SetLeft(Math.round(r.Right - r.Left - this.FDragBitmap.GetWidth()));
                  this.FSaveDragX = newposx;
                  this.FDragTimer.SetEnabled(true);
                } else if (newposx < 0) {
                  this.FDragBitmap.SetLeft(0);
                  this.FSaveDragX = newposx;
                  this.FDragTimer.SetEnabled(true);
                };
                this.FDragX = this.FX;
                this.FDragY = this.FY;
              } else if (((this.FDragCell.Col < this.FFixedColumns) || (this.FDragCell.Col > (this.GetColumnCount() - 1 - this.FFixedRightColumns))) && this.FOptions.FMouse.FRowDragging) {
                newposy = this.FSaveDragY + (this.FY - this.FDragY);
                if (newposy <= (r.Bottom - r.Top - this.FDragBitmap.GetHeight())) {
                  this.FDragBitmap.SetTop(Math.round(Math.max(0,Math.min(r.Bottom - r.Top - this.FDragBitmap.GetHeight(),newposy))));
                  this.FSaveDragY = this.FDragBitmap.GetTop();
                  this.FDragTimer.SetEnabled(false);
                  if ((newposy > this.GetFixedHeight()) && (newposy < (r.Bottom - r.Top - this.GetFixedFooterHeight()))) this.FDragScrollCell.$assign(this.XYToCell((r.Right - r.Left) / 2,newposy));
                } else if (newposy > (r.Bottom - r.Top - this.FDragBitmap.GetHeight())) {
                  this.FDragBitmap.SetTop(Math.round(r.Bottom - r.Top - this.FDragBitmap.GetHeight()));
                  this.FSaveDragY = newposy;
                  this.FDragTimer.SetEnabled(true);
                };
                this.FDragX = this.FX;
                this.FDragY = this.FY;
              };
              if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetLocalRect(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
                this.UpdateCursor(10)}
               else this.UpdateCursor(13);
            };
          };
        };
      } else if (!this.FMouseSizing) {
        sx = X;
        sy = Y;
        res.$assign(this.XYToCell(X,Y));
        if ((res.Col !== -1) && (res.Row !== -1)) {
          obj = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(res))));
          if (obj != null) {
            fixed = this.IsFixed(res.Col,res.Row);
            if ((this.FToolBarPopup != null) && (this.FToolBarPopupMode !== $mod.TTMSFNCGridCustomToolBarPopupMode.tpmNone)) {
              if (this.FToolBarPopupMode === $mod.TTMSFNCGridCustomToolBarPopupMode.tpmActiveCell) {
                if ((res.Col === this.GetFocusedCell().Col) && (res.Row === this.GetFocusedCell().Row) && !this.FToolBarPopup.Activated()) ShowToolBar();
                if (((res.Col !== this.GetFocusedCell().Col) || (res.Row !== this.GetFocusedCell().Row)) && (this.FToolBarPopup != null) && this.FToolBarPopup.Activated() && !this.FToolBarPopup.DropDownActive()) this.FToolBarPopup.Deactivate();
              };
              if (this.FToolBarPopupMode in rtl.createSet($mod.TTMSFNCGridCustomToolBarPopupMode.tpmHoverCell,$mod.TTMSFNCGridCustomToolBarPopupMode.tpmHoverNormalCell)) {
                if (((res.Col !== this.FToolBarPopupCell.Col) || (res.Row !== this.FToolBarPopupCell.Row)) && !this.FToolBarPopup.Activated()) {
                  if (!fixed || (this.FToolBarPopupMode === $mod.TTMSFNCGridCustomToolBarPopupMode.tpmHoverCell)) ShowToolBar();
                };
                if (((res.Col !== this.FToolBarPopupCell.Col) || (res.Row !== this.FToolBarPopupCell.Row)) && this.FToolBarPopup.Activated() && !this.FToolBarPopup.DropDownActive()) this.FToolBarPopup.Deactivate();
              };
            };
            if (fixed) {
              rowsz = this.FOptions.FMouse.FFixedRowSizing;
              colsz = this.FOptions.FMouse.FFixedColumnSizing;
            } else {
              rowsz = this.FOptions.FMouse.FRowSizing;
              colsz = this.FOptions.FMouse.FColumnSizing;
            };
            if (rowsz && (res.Row > this.FFixedRows) && (sy <= (obj.FTop + this.FOptions.FMouse.FRowSizeMargin)) && (sx > (obj.FLeft + this.FOptions.FMouse.FColumnSizeMargin)) && (sx < ((obj.FLeft + obj.FWidth) - this.FOptions.FMouse.FColumnSizeMargin))) {
              Allow = true;
              this.DoCanSizeRow(res.Row - 1,{get: function () {
                  return Allow;
                }, set: function (v) {
                  Allow = v;
                }});
              if (Allow) this.UpdateCursor(7);
            } else if (rowsz && (((res.Row < (this.GetRowCount() - this.FFixedRows)) && fixed) || !fixed) && (sy >= ((obj.FTop + obj.FHeight) - this.FOptions.FMouse.FRowSizeMargin)) && (sx > (obj.FLeft + this.FOptions.FMouse.FColumnSizeMargin)) && (sx < ((obj.FLeft + obj.FWidth) - this.FOptions.FMouse.FColumnSizeMargin))) {
              Allow = true;
              this.DoCanSizeRow(res.Row,{get: function () {
                  return Allow;
                }, set: function (v) {
                  Allow = v;
                }});
              if (Allow) this.UpdateCursor(7);
            } else if (colsz && (res.Col > this.FFixedColumns) && (sx <= (obj.FLeft - this.FOptions.FMouse.FColumnSizeMargin)) && (sy > (obj.FTop + this.FOptions.FMouse.FRowSizeMargin)) && (sy < ((obj.FTop + obj.FHeight) - this.FOptions.FMouse.FRowSizeMargin))) {
              Allow = true;
              this.DoCanSizeColumn(res.Col - 1,{get: function () {
                  return Allow;
                }, set: function (v) {
                  Allow = v;
                }});
              if (Allow) this.UpdateCursor(9);
            } else if (colsz && (((res.Col < (this.GetColumnCount() - this.FFixedColumns)) && fixed) || !fixed) && (sx >= ((obj.FLeft + obj.FWidth) - this.FOptions.FMouse.FColumnSizeMargin)) && (sy > (obj.FTop + this.FOptions.FMouse.FRowSizeMargin)) && (sy < ((obj.FTop + obj.FHeight) - this.FOptions.FMouse.FRowSizeMargin))) {
              Allow = true;
              this.DoCanSizeColumn(res.Col,{get: function () {
                  return Allow;
                }, set: function (v) {
                  Allow = v;
                }});
              if (Allow) this.UpdateCursor(9);
            } else {
              if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(obj)) {
                bctl = false;
                cr = this.OldCursor;
                rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).HandleMouseMove(rtl.refSet(Shift),X,Y,{get: function () {
                    return bctl;
                  }, set: function (v) {
                    bctl = v;
                  }},{get: function () {
                    return cr;
                  }, set: function (v) {
                    cr = v;
                  }});
                if (bctl) {
                  this.UpdateCursor(cr);
                  this.Invalidate();
                };
                if (!bctl) {
                  if (rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).IsHTML()) {
                    this.FCellAnchorString = rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).XYToAnchor(X,Y)}
                   else {
                    this.FCellAnchorString = rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FText;
                    if (!pas["WEBLib.TMSFNCGridDataUtil"].IsURL(this.FCellAnchorString)) this.FCellAnchorString = "";
                  };
                  if ((this.FCellAnchorString !== "") && this.FOptions.FURL.FShow) {
                    this.UpdateCursor(21)}
                   else this.UpdateCursor(this.OldCursor);
                };
              };
            };
          };
        } else this.UpdateCursor(this.OldCursor);
      } else {
        if ((this.FDragCell.Col !== -1) && (this.FDragCell.Col !== -1)) {
          this.HideEdit(false,false);
          var $tmp1 = this.FSizeMode;
          if ($tmp1 === $mod.TTMSFNCGridSizeMode.smColumnSizing) {
            newsz = this.GetColWidths(this.FDragCell.Col) + (this.FX - this.FSizeX);
            this.DoColumnSize(this.FDragCell.Col,{get: function () {
                return newsz;
              }, set: function (v) {
                newsz = v;
              }});
            this.SetColWidths(this.FDragCell.Col,newsz);
          } else if ($tmp1 === $mod.TTMSFNCGridSizeMode.smRowSizing) {
            newsz = this.GetRowHeights(this.FDragCell.Row) + (this.FY - this.FSizeY);
            this.DoRowSize(this.FDragCell.Row,{get: function () {
                return newsz;
              }, set: function (v) {
                newsz = v;
              }});
            this.SetRowHeights(this.FDragCell.Row,newsz);
          } else if ($tmp1 === $mod.TTMSFNCGridSizeMode.smPreviousColumnSizing) {
            newsz = this.GetColWidths(this.FDragCell.Col - 1) + (this.FX - this.FSizeX);
            this.DoColumnSize(this.FDragCell.Col - 1,{get: function () {
                return newsz;
              }, set: function (v) {
                newsz = v;
              }});
            this.SetColWidths(this.FDragCell.Col - 1,newsz);
          } else if ($tmp1 === $mod.TTMSFNCGridSizeMode.smPreviousRowSizing) {
            newsz = this.GetRowHeights(this.FDragCell.Row - 1) + (this.FY - this.FSizeY);
            this.DoRowSize(this.FDragCell.Row - 1,{get: function () {
                return newsz;
              }, set: function (v) {
                newsz = v;
              }});
            this.SetRowHeights(this.FDragCell.Row - 1,newsz);
          };
          this.FSizeX = this.FX;
          this.FSizeY = this.FY;
          this.UpdateControl(true,true);
          this.FSizing = true;
        };
      };
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var res = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var Allow = false;
      var obj = null;
      var fxd = false;
      var bctl = false;
      var b = false;
      var f = 0.0;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HandleMouseUp.apply(this,arguments);
      if (!this.HideEdit(false,true)) return;
      this.ReleaseCaptureEx();
      if (!(Button === pas["WEBLib.Controls"].TMouseButton.mbLeft)) {
        if (Button === pas["WEBLib.Controls"].TMouseButton.mbRight) {
          res.$assign(this.XYToCell(X,Y));
          if ((res.Col !== -1) && (res.Row !== -1)) {
            fxd = this.IsFixed(res.Col,res.Row);
            if (fxd) {
              this.DoFixedCellRightClick(res.Col,res.Row)}
             else this.DoCellRightClick(res.Col,res.Row);
          };
        };
        return;
      };
      if (!this.FIsMouseDown) return;
      this.FMouseScrollingUp = true;
      this.FIsMouseDown = false;
      this.FScrollTimer.SetEnabled(false);
      this.FDragTimer.SetEnabled(false);
      if (this.FSizing) {
        var $tmp = this.FSizeMode;
        if ($tmp === $mod.TTMSFNCGridSizeMode.smColumnSizing) {
          this.DoColumnSized(this.FDragCell.Col,this.GetColWidths(this.FDragCell.Col))}
         else if ($tmp === $mod.TTMSFNCGridSizeMode.smRowSizing) {
          this.DoRowSized(this.FDragCell.Row,this.GetRowHeights(this.FDragCell.Row))}
         else if ($tmp === $mod.TTMSFNCGridSizeMode.smPreviousColumnSizing) {
          this.DoColumnSized(this.FDragCell.Col - 1,this.GetColWidths(this.FDragCell.Col - 1))}
         else if ($tmp === $mod.TTMSFNCGridSizeMode.smPreviousRowSizing) this.DoRowSized(this.FDragCell.Row - 1,this.GetRowHeights(this.FDragCell.Row - 1));
        this.UpdateControl(true,true);
      };
      if (this.FDragBitmap != null) {
        this.FDragBitmap.SetParent(null);
        rtl.free(this,"FDragBitmap");
        this.FDragBitmap = null;
      };
      if (!this.FDoubleSelection$1 && this.FOptions.FMouse.FTouchScrolling && this.FDoTouchScroll) {
        f = this.FOptions.FMouse.FTouchScrollingSensitivity;
        if (this.FScrollMode === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) f = f / 10;
        this.FTimeStop$1 = $impl.GetTickCountX();
        if (((this.FTimeStop$1 - this.FTimeStart$1) < 300) && ((this.FTimeStop$1 - this.FTimeStart$1) > 0)) {
          this.FSpY$1 = Math.abs(Y - this.FScrollY$1) / (this.FTimeStop$1 - this.FTimeStart$1);
          if (this.FSpY$1 > 0) {
            if (this.GetVVisible()) {
              if ((Y - this.FScrollY$1) > 0) {
                this.FScrollVTo$1 = Math.max(0,Math.min(this.GetVMax() - this.GetVViewPortSize(),this.FScrollVTo$1 - Math.round(Math.abs(Y - this.FScrollY$1) * this.FSpY$1 * f * 3)))}
               else this.FScrollVTo$1 = Math.max(0,Math.min(this.GetVMax() - this.GetVViewPortSize(),this.FScrollVTo$1 + Math.round(Math.abs(Y - this.FScrollY$1) * this.FSpY$1 * f * 3)));
            } else this.FScrollVTo$1 = 0;
            this.FAnimateVerticalPos$1 = true;
            this.FAnimateTimer$1.SetEnabled(true);
          };
          this.FSpX$1 = Math.abs(X - this.FScrollX$1) / (this.FTimeStop$1 - this.FTimeStart$1);
          if (this.FSpX$1 > 0) {
            if (this.GetHVisible()) {
              if ((X - this.FScrollX$1) > 0) {
                this.FScrollHTo$1 = Math.max(0,Math.min(this.GetHMax() - this.GetHViewPortSize(),this.FScrollHTo$1 - Math.round(Math.abs(X - this.FScrollX$1) * this.FSpX$1 * f * 3)))}
               else this.FScrollHTo$1 = Math.max(0,Math.min(this.GetHMax() - this.GetHViewPortSize(),this.FScrollHTo$1 + Math.round(Math.abs(X - this.FScrollX$1) * this.FSpX$1 * f * 3)));
            } else this.FScrollHTo$1 = 0;
            this.FAnimateHorizontalPos$1 = true;
            this.FAnimateTimer$1.SetEnabled(true);
          };
        };
      };
      bctl = false;
      if (this.FMouseUp$1) {
        res.$assign(this.XYToCell(X,Y));
        if ((res.Col !== -1) && (res.Row !== -1)) {
          obj = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(res))));
          if (obj != null) {
            this.FCellAnchor.Col = -1;
            this.FCellAnchor.Row = -1;
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(obj) && !this.FMouseDragging) {
              bctl = false;
              rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).HandleMouseUp(Button,rtl.refSet(Shift),X,Y,{get: function () {
                  return bctl;
                }, set: function (v) {
                  bctl = v;
                }});
              if (bctl) this.Invalidate();
              if (rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).IsHTML()) {
                this.FCellAnchorString = rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).XYToAnchor(X,Y)}
               else {
                this.FCellAnchorString = rtl.as(obj,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FText;
                if (!pas["WEBLib.TMSFNCGridDataUtil"].IsURL(this.FCellAnchorString) || !this.FOptions.FURL.FShow) this.FCellAnchorString = "";
              };
              if (this.FCellAnchorString !== "") this.FCellAnchor.$assign(res);
            };
          };
          if (!bctl) {
            if ((this.FCellAnchor.Col === -1) && (this.FCellAnchor.Row === -1) && (this.FCellAnchorString === "")) {
              fxd = this.IsFixed(res.Col,res.Row);
              var $tmp1 = this.FOptions.FSelection.FMode;
              if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smCellRange) {
                if ((pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsAll in this.FOptions.FMouse.FFixedCellSelection) && (res.Col < this.FFixedColumns) && (res.Row < this.FFixedRows)) fxd = false;
              } else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) {
                if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsRow in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
               else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) {
                if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsColumn in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
               else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) {
                if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsRowRange in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
               else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange) {
                if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsColumnRange in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
               else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
                if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsDisjunctRow in this.FOptions.FMouse.FFixedCellSelection) fxd = false}
               else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) if (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsDisjunctColumn in this.FOptions.FMouse.FFixedCellSelection) fxd = false;
              if (!fxd && !this.FDragFixed && !this.FTouchScrolling$1) {
                this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(res),rtl.refSet(Shift),this.FMouseDragging);
                this.DoCellClick(res.Col,res.Row);
                if (!this.FMouseDragging && this.FOptions.FMouse.FDirectEdit) {
                  Allow = true;
                  this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                      return Allow;
                    }, set: function (v) {
                      Allow = v;
                    }});
                  if (Allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csNone,false,"",0);
                };
              } else {
                if (this.FDraggingMode === $mod.TTMSFNCGridDraggingMode.dmColumnDragging) {
                  b = true;
                  this.DoBeforeColumnDrop(this.FDragCell.Col,{p: res, get: function () {
                      return this.p.Col;
                    }, set: function (v) {
                      this.p.Col = v;
                    }},{get: function () {
                      return b;
                    }, set: function (v) {
                      b = v;
                    }});
                  if (b) {
                    this.BeginUpdate();
                    this.MoveColumn(this.FDragCell.Col,res.Col);
                    this.EndUpdate();
                    this.DoColumnDragged(this.FDragCell.Col,res.Col);
                  };
                } else if (this.FDraggingMode === $mod.TTMSFNCGridDraggingMode.dmRowDragging) {
                  b = true;
                  this.DoBeforeRowDrop(this.FDragCell.Row,{p: res, get: function () {
                      return this.p.Row;
                    }, set: function (v) {
                      this.p.Row = v;
                    }},{get: function () {
                      return b;
                    }, set: function (v) {
                      b = v;
                    }});
                  if (b) {
                    this.BeginUpdate();
                    this.MoveRow(this.FDragCell.Row,res.Row);
                    this.EndUpdate();
                    this.DoRowDragged(this.FDragCell.Row,res.Row);
                  };
                } else this.DoFixedCellClick(rtl.refSet(Shift),res.Col,res.Row);
              };
            } else this.DoCellAnchorClick(this.FCellAnchor.Col,this.FCellAnchor.Row,this.FCellAnchorString);
          };
        };
      };
      this.FTouchScrolling$1 = false;
      this.FDraggingMode = $mod.TTMSFNCGridDraggingMode.dmNone;
      this.FDragFixed = false;
      this.FFirstCell.Row = -1;
      this.FFirstCell.Col = -1;
      this.FMouseDown = false;
      this.FMouseUp$1 = false;
      this.FMouseDragging = false;
      this.FMouseDblClick = this.FMouseSizing;
      this.FMouseSizing = false;
      this.FSizing = false;
    };
    this.HandleMouseWheel = function (Shift, WheelDelta, Handled) {
      var sel = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var r = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseWheel.apply(this,arguments);
      if (Handled.get()) return;
      if ((pas.Classes.TShiftState$a.ssCtrl in Shift) || this.FOptions.FMouse.FWheelScrollKeepSelection) {
        if (WheelDelta > 0) {
          this.SetTopRow(this.GetTopRow() - this.FOptions.FMouse.FWheelScrollSize)}
         else this.SetTopRow(this.GetTopRow() + this.FOptions.FMouse.FWheelScrollSize);
        r = this.GetTopRow();
        cl.$assign(this.BaseCell(this.GetLeftCol(),r));
        this.SetTopRow(cl.Row);
      } else {
        sel.$assign(this.GetFocusedCell());
        if (WheelDelta > 0) {
          sel.Row = sel.Row - this.FOptions.FMouse.FWheelScrollSize}
         else sel.Row = sel.Row + this.FOptions.FMouse.FWheelScrollSize;
        cl.$assign(this.BaseCell(sel.Col,sel.Row));
        sel.$assign(cl);
        this.CancelEdit();
        this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(sel),rtl.refSet(Shift),false);
      };
      Handled.set(true);
    };
    this.HandleKeyDown = function (Key, Shift) {
      var sel = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var real = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cs = 0;
      var rs = 0;
      var i = 0;
      var j = 0;
      var Allow = false;
      if (Key.get() === 9) return;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      if (Key.get() in rtl.createSet(27,45,46,38,40,37,39,36,35,33,34,9)) this.FLookupString = "";
      if (this.FOptions.FEditing.FEnabled) {
        Allow = true;
        this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
            return Allow;
          }, set: function (v) {
            Allow = v;
          }});
        if (Allow) {
          if ((Key.get() === 113) || (Key.get() === 13)) {
            this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csNone,false,"",0);
            return;
          };
        };
      };
      if (Key.get() === 32) {
        Key.set(32);
        if ((this.GetFocusedCell().Row !== -1) && (this.GetFocusedCell().Col !== -1)) this.DoCellKeyDown(this.GetFocusedCell().Col,this.GetFocusedCell().Row,Key,rtl.refSet(Shift));
        return;
      };
      this.FPrevSelectedCell.$assign(this.GetFocusedCell());
      if ((pas.Classes.TShiftState$a.ssShift in Shift) && !(pas.Classes.TShiftState$a.ssCtrl in Shift) && !(pas.Classes.TShiftState$a.ssAlt in Shift) && (Key.get() === 45) && !this.FEditing && this.FOptions.FClipboard.FEnabled) this.PasteFromClipboard();
      if ((pas.Classes.TShiftState$a.ssCtrl in Shift) && !(pas.Classes.TShiftState$a.ssShift in Shift) && !(pas.Classes.TShiftState$a.ssAlt in Shift)) {
        var $tmp = Key.get();
        if ($tmp === 77) {
          if (this.FOptions.FKeyboard.FAllowCellMergeShortCut) this.MergeSelection(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(this.GetSelection()))}
         else if ($tmp === 83) {
          if (this.FOptions.FKeyboard.FAllowCellMergeShortCut) this.SplitCell(this.GetSelection().StartCol,this.GetSelection().StartRow)}
         else if ($tmp === 88) {
          if (this.FOptions.FClipboard.FEnabled && !this.FEditing) this.CutToClipboard(true);
        } else if ($tmp === 67) {
          if (this.FOptions.FClipboard.FEnabled && !this.FEditing) this.CopyToClipboard(true);
        } else if ($tmp === 86) {
          if (this.FOptions.FClipboard.FEnabled && !this.FEditing) this.PasteFromClipboard();
        } else if ($tmp === 65) {
          if (this.FOptions.FSelection.FMode in rtl.createSet(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smCellRange,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow)) {
            this.SetStartCell(this.FFixedColumns,this.FFixedRows);
            this.SetStopCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.GetRowCount() - 1 - this.FFixedFooterRows);
            this.SetFocusCell(this.FFixedColumns,this.FFixedRows);
          };
          if (this.FOptions.FSelection.FMode in rtl.createSet(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow)) {
            this.FBlockUpdate = true;
            for (var $l = this.FFixedRows, $end = this.GetRowCount() - this.FFixedFooterRows - 1; $l <= $end; $l++) {
              i = $l;
              this.SetRowSelect(i,true);
            };
            this.FBlockUpdate = false;
          };
          if (this.FOptions.FSelection.FMode in rtl.createSet(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn)) {
            this.FBlockUpdate = true;
            for (var $l1 = this.FFixedColumns, $end1 = this.GetColumnCount() - 1 - this.FFixedRightColumns; $l1 <= $end1; $l1++) {
              i = $l1;
              this.SetColumnSelect(i,true);
            };
            this.FBlockUpdate = false;
          };
          if (this.FOptions.FSelection.FMode in rtl.createSet(pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell)) {
            this.FBlockUpdate = true;
            for (var $l2 = this.FFixedColumns, $end2 = this.GetColumnCount() - 1 - this.FFixedRightColumns; $l2 <= $end2; $l2++) {
              i = $l2;
              for (var $l3 = this.FFixedRows, $end3 = this.GetRowCount() - this.FFixedFooterRows - 1; $l3 <= $end3; $l3++) {
                j = $l3;
                this.SetCellSelect(i,j,true);
              };
            };
            this.FBlockUpdate = false;
          };
          this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),false);
          if (this.FOnSelectedCell != null) this.FOnSelectedCell(this,this.GetFocusedCell().Col,this.GetFocusedCell().Row);
        } else if ($tmp === 46) {
          if (this.FOptions.FClipboard.FEnabled) this.CutToClipboard(true);
        } else if ($tmp === 45) {
          if (this.FOptions.FClipboard.FEnabled) this.CopyToClipboard(true);
        } else if ($tmp === 34) {
          this.SetTopRow(this.GetTopRow() + this.GetPageScrollSize())}
         else if ($tmp === 33) {
          this.SetTopRow(this.GetTopRow() - this.GetPageScrollSize())}
         else if ($tmp === 38) {
          this.SetTopRow(this.GetTopRow() - 1);
        } else if ($tmp === 40) {
          rs = this.RowSpan(this.GetLeftCol(),this.GetTopRow());
          if (rs > 0) {
            this.SetTopRow(this.GetTopRow() + rs)}
           else this.SetTopRow(this.GetTopRow() + 1);
        } else if ($tmp === 37) {
          this.SetLeftCol(this.GetLeftCol() - 1)}
         else if ($tmp === 39) {
          cs = this.ColSpan(this.GetLeftCol(),this.GetTopRow());
          if (cs > 0) {
            this.SetLeftCol(this.GetLeftCol() + cs)}
           else this.SetLeftCol(this.GetLeftCol() + 1);
        } else if ($tmp === 36) {
          this.SetTopRow(this.FFixedRows)}
         else if ($tmp === 35) this.SetTopRow(this.GetRowCount() - 1 - this.FFixedFooterRows);
      } else {
        sel.$assign(this.GetFocusedCell());
        real.$assign(this.FRealCell);
        var $tmp1 = Key.get();
        if ($tmp1 === 46) {
          if (rtl.eqSet(Shift,{})) {
            if (this.FOptions.FKeyboard.FDeleteKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridDeleteKeyHandling.dkhDeleteRow) {
              if (this.GetRowCount() > (this.FFixedRows + this.FFixedFooterRows)) {
                Allow = true;
                this.DoCanDeleteRow(sel.Row,{get: function () {
                    return Allow;
                  }, set: function (v) {
                    Allow = v;
                  }});
                if (Allow) {
                  this.DeleteRow(sel.Row);
                  sel.Row = Math.max(this.FFixedRows,Math.min(sel.Row,this.GetRowCount() - 1 - this.FFixedFooterRows));
                  this.DoDeleteRow(sel.Row);
                };
              };
            };
          };
        } else if ($tmp1 === 45) {
          if (rtl.eqSet(Shift,{})) {
            if (sel.Row === -1) sel.Row = this.FFixedRows - 1;
            var $tmp2 = this.FOptions.FKeyboard.FInsertKeyHandling;
            if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridInsertKeyHandling.ikhInsertRowBefore) {
              Allow = true;
              this.DoCanInsertRow(sel.Row,{get: function () {
                  return Allow;
                }, set: function (v) {
                  Allow = v;
                }});
              if (Allow) {
                this.InsertRow(sel.Row);
                sel.Row = Math.max(this.FFixedRows,Math.min(sel.Row,this.GetRowCount() - 1 - this.FFixedFooterRows));
                this.DoInsertRow(sel.Row);
              };
            } else if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridInsertKeyHandling.ikhInsertRowAfter) {
              Allow = true;
              this.DoCanInsertRow(sel.Row,{get: function () {
                  return Allow;
                }, set: function (v) {
                  Allow = v;
                }});
              if (Allow) {
                this.InsertRow(sel.Row + 1);
                sel.Row = Math.max(this.FFixedRows,Math.min(sel.Row + 1,this.GetRowCount() - 1 - this.FFixedFooterRows));
                this.DoInsertRow(sel.Row);
              };
            };
          };
        } else if ($tmp1 === 34) {
          sel.$assign(this.NextSelectableRow(sel.Col,(sel.Row + this.GetPageScrollSize()) - 1));
          sel.Col = real.Col;
        } else if ($tmp1 === 33) {
          sel.$assign(this.PreviousSelectableRow(sel.Col,(sel.Row - this.GetPageScrollSize()) + 1));
          sel.Col = real.Col;
        } else if ($tmp1 === 38) {
          sel.$assign(this.PreviousSelectableRow(sel.Col,sel.Row));
          sel.Col = real.Col;
        } else if ($tmp1 === 40) {
          sel.$assign(this.NextSelectableRow(sel.Col,sel.Row));
          sel.Col = real.Col;
        } else if ($tmp1 === 37) {
          sel.$assign(this.PreviousSelectableColumn(sel.Col,sel.Row));
          sel.Row = real.Row;
        } else if ($tmp1 === 39) {
          sel.$assign(this.NextSelectableColumn(sel.Col,sel.Row));
          sel.Row = real.Row;
        } else if ($tmp1 === 36) {
          if (pas.Classes.TShiftState$a.ssAlt in Shift) {
            sel.Row = this.FFixedRows;
            sel.Col = real.Col;
            sel.$assign(this.NextSelectableRow(sel.Col,sel.Row - 1));
          } else {
            sel.Col = this.FFixedColumns;
            sel.Row = real.Row;
            sel.$assign(this.NextSelectableColumn(sel.Col - 1,sel.Row));
          };
        } else if ($tmp1 === 35) {
          if (pas.Classes.TShiftState$a.ssAlt in Shift) {
            sel.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
            sel.Col = real.Col;
            sel.$assign(this.PreviousSelectableRow(sel.Col,sel.Row + 1));
          } else {
            sel.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
            sel.Row = real.Row;
            sel.$assign(this.PreviousSelectableColumn(sel.Col + 1,sel.Row));
          };
        };
        var $tmp3 = Key.get();
        if (($tmp3 === 38) || ($tmp3 === 37) || ($tmp3 === 40) || ($tmp3 === 39) || ($tmp3 === 36) || ($tmp3 === 35) || ($tmp3 === 34) || ($tmp3 === 33) || ($tmp3 === 46) || ($tmp3 === 45)) {
          if (pas.Classes.TShiftState$a.ssCtrl in Shift) {
            this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(sel),false)}
           else this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(sel),rtl.refSet(Shift),false);
          Key.set(0);
        };
      };
    };
    this.HandleKeyPress = function (Key) {
      var Allow = false;
      var k = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyPress.apply(this,arguments);
      k = Key.get().charCodeAt();
      if (k in rtl.createSet(9)) return;
      if (!this.FOptions.FEditing.FEnabled && this.FOptions.FLookup.FEnabled) {
        if (k in rtl.createSet(27,45,46,38,40,37,39,36,35,33,34,9)) {
          this.FLookupString = ""}
         else {
          if (this.FOptions.FLookup.FIncremental) {
            this.FLookupString = this.FLookupString + Key.get()}
           else this.FLookupString = Key.get();
          this.LookupInColumn(this.GetFocusedCell().Col,this.FLookupString,true,true);
        };
      };
      if (this.FOptions.FEditing.FEnabled) {
        Allow = true;
        this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
            return Allow;
          }, set: function (v) {
            Allow = v;
          }});
        if (Allow) {
          if (k >= 32) {
            this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csStart,true,Key.get(),Key.get().charCodeAt());
            Key.set("\x00");
            return;
          };
        };
      };
    };
    this.HandleDialogKey = function (Key, Shift) {
      this.FTabKey = $mod.TTMSFNCGridTabKeyMode.tkmNone;
      if ((Key.get() === 9) && (this.FOptions.FKeyboard.FTabKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhMixed)) {
        if (pas.Classes.TShiftState$a.ssShift in Shift) {
          this.FTabKey = $mod.TTMSFNCGridTabKeyMode.tkmShift}
         else this.FTabKey = $mod.TTMSFNCGridTabKeyMode.tkmNormal;
      };
      if (this.IsFocused() || ((this.FEditControl !== null) && this.FEditControl.IsFocused())) this.ProcessTab(Key,rtl.refSet(Shift),this.FOptions.FKeyboard.FTabKeyDirection,this.FOptions.FKeyboard.FTabKeyHandling,this.FOptions.FKeyboard.FTabKeyDirectEdit,$mod.TTMSFNCGridEditCellStart.csNone);
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDialogKey.apply(this,arguments);
    };
    this.HandleFilterListClick = function (Sender) {
      this.FFilterTimer.SetEnabled(true);
    };
    this.HandleFilterTimer = function (Sender) {
      var fd = null;
      var cnd = "";
      var i = 0;
      var filtercol = 0;
      var u = false;
      this.FFilterTimer.SetEnabled(false);
      if (this.FFilterListBox != null) {
        filtercol = this.FFilterListBox.FTag$1;
        if (this.FOptions.FFiltering.FMultiColumn) {
          for (var $l = this.FFilter.GetCount() - 1; $l >= 0; $l--) {
            i = $l;
            if (this.FFilter.GetItem$1(i).FColumn === filtercol) this.FFilter.Delete(i);
          };
        } else this.FFilter.Clear();
        fd = this.FFilter.Add$1();
        fd.FColumn = filtercol;
        cnd = "";
        if ((this.FFilterListBox.GetItemIndex() >= 0) && (this.FFilterListBox.GetItemIndex() <= (this.FFilterListBox.FItems.GetCount() - 1))) cnd = this.FFilterListBox.FItems.Get(this.FFilterListBox.GetItemIndex());
        if (pas.System.Pos(" ",cnd) > 0) cnd = '"' + cnd + '"';
        this.FFilterPopup.SetIsOpen(false);
        if (cnd === rtl.getResStr($mod,"sTMSFNCGridFilterAll")) {
          this.FBlockUpdate = true;
          this.UnHideRowsAll();
          this.FBlockUpdate = false;
          this.FFilter.Clear();
          this.ApplyFilter();
        } else {
          this.DoFilterSelect(fd.FColumn,{get: function () {
              return cnd;
            }, set: function (v) {
              cnd = v;
            }});
          fd.FCondition = cnd;
          this.FBlockUpdate = true;
          this.UnHideRowsAll();
          this.FBlockUpdate = false;
          this.ApplyFilter();
        };
        u = false;
        this.DoAfterApplyFilter(fd.FColumn,cnd,{get: function () {
            return u;
          }, set: function (v) {
            u = v;
          }});
        if (u) {
          this.BeginUpdate();
          this.UpdateCalculations();
          this.EndUpdate();
        };
      };
    };
    this.HandleKeyUp = function (Key, Shift) {
      if (Key.get() === 9) return;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyUp.apply(this,arguments);
      if (Key.get() === 32) {
        Key.set(32);
        if ((this.GetFocusedCell().Row !== -1) && (this.GetFocusedCell().Col !== -1)) this.DoCellKeyUp(this.GetFocusedCell().Col,this.GetFocusedCell().Row,Key,rtl.refSet(Shift));
      };
    };
    this.DoCellKeyDown = function (ACol, ARow, Key, Shift) {
      var cell = null;
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      cl.Col = ACol;
      cl.Row = ARow;
      cell = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl))));
      if (cell != null) {
        var $tmp = Key.get();
        if ($tmp === 32) this.FCellKeyDown = true;
      };
    };
    this.DoCellKeyUp = function (ACol, ARow, Key, Shift) {
      var cell = null;
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      cl.Col = ACol;
      cl.Row = ARow;
      cell = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl))));
      if (cell != null) {
        var $tmp = Key.get();
        if ($tmp === 32) {
          if (this.FCellKeyDown && !this.IsReadOnly(cl.Col,cl.Row)) {
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(cell)) {
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetChecked(!rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked)}
             else if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetChecked(!rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FChecked);
          };
          this.FCellKeyDown = false;
        };
      };
    };
    this.ProcessTab = function (Key, Shift, Mode, Handling, DirectEdit, CellStart) {
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var clc = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var rl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var c = 0;
      var r = 0;
      var a = false;
      var Allow = false;
      var SaveFocusCell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      if ((Key.get() === 9) && (this.GetRowCount() > (this.FFixedRows + this.FFixedFooterRows)) && (this.GetColumnCount() > (this.FFixedColumns + this.FFixedRightColumns))) {
        SaveFocusCell.$assign(this.GetFocusedCell());
        a = this.HideEdit(false,false);
        if (!a) return;
        this.SetFocusedCell(SaveFocusCell);
        if (this.IsFocused()) {
          var $tmp = Handling;
          if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell) {
            Key.set(0)}
           else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhMixed) {
            if (pas.Classes.TShiftState$a.ssShift in Shift) {
              cl.Col = this.FFixedColumns;
              cl.Row = this.FFixedRows;
              if (this.IsNormalFixed(cl.Col,cl.Row)) {
                var $tmp1 = Mode;
                if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell) {
                  cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row))}
                 else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextRowCell) cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
              };
              if ((Handling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhMixed) && !((this.GetFocusedCell().Col === cl.Col) && (this.GetFocusedCell().Row === cl.Row))) Key.set(0);
            } else {
              cl.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
              cl.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
              if (this.IsNormalFixed(cl.Col,cl.Row)) {
                var $tmp2 = Mode;
                if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell) {
                  cl.$assign(this.PreviousSelectableColumn(cl.Col,cl.Row))}
                 else if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextRowCell) cl.$assign(this.PreviousSelectableRow(cl.Col,cl.Row));
              };
              if ((Handling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhMixed) && !((this.GetFocusedCell().Col === cl.Col) && (this.GetFocusedCell().Row === cl.Row))) Key.set(0);
            };
          };
          if (Key.get() === 0) {
            var $tmp3 = Handling;
            if (($tmp3 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell) || ($tmp3 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhMixed)) {
              cl.$assign(this.GetFocusedCell());
              rl.$assign(this.FRealCell);
              cl.$assign(this.BaseCell(cl.Col,cl.Row));
              if (pas.Classes.TShiftState$a.ssShift in Shift) {
                clc.$assign(pas["WEBLib.TMSFNCGridData"].MakeCell(this.FFixedColumns,this.FFixedRows));
                if ((this.GetFocusedCell().Col === clc.Col) && (this.GetFocusedCell().Row === clc.Row)) {
                  clc.$assign(pas["WEBLib.TMSFNCGridData"].MakeCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.GetRowCount() - 1 - this.FFixedFooterRows));
                  this.SetFocusedCell(clc);
                  return;
                };
                var $tmp4 = Mode;
                if ($tmp4 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell) {
                  c = cl.Col;
                  cl.$assign(this.PreviousSelectableColumn(cl.Col,cl.Row));
                  cl.Row = rl.Row;
                  if (c === cl.Col) {
                    r = cl.Row;
                    cl.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
                    cl.$assign(this.PreviousSelectableColumn(cl.Col,cl.Row));
                    if (r === cl.Row) {
                      cl.$assign(this.PreviousSelectableColumn(this.GetColumnCount() - this.FFixedRightColumns,cl.Row - 1));
                      while ((cl.Col === (this.GetColumnCount() - this.FFixedRightColumns)) && (cl.Row === (r - 1))) {
                        r = cl.Row;
                        cl.$assign(this.PreviousSelectableColumn(this.GetColumnCount() - this.FFixedRightColumns,cl.Row - 1));
                      };
                    };
                    if ((Handling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell) && ((cl.Row < this.FFixedRows) || (r === cl.Row))) {
                      cl.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
                      cl.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
                      cl.$assign(this.PreviousSelectableColumn(cl.Col,cl.Row));
                    };
                  };
                } else if ($tmp4 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextRowCell) {
                  r = cl.Row;
                  cl.$assign(this.PreviousSelectableRow(cl.Col,cl.Row));
                  cl.Col = rl.Col;
                  if (r === cl.Row) {
                    c = cl.Col;
                    cl.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
                    cl.$assign(this.PreviousSelectableRow(cl.Col,cl.Row));
                    if (c === cl.Col) {
                      cl.$assign(this.PreviousSelectableRow(cl.Col - 1,this.GetRowCount() - this.FFixedFooterRows));
                      while ((cl.Row === (this.GetRowCount() - this.FFixedFooterRows)) && (cl.Col === (c - 1))) {
                        c = cl.Col;
                        cl.$assign(this.PreviousSelectableRow(cl.Col - 1,this.GetRowCount() - this.FFixedFooterRows));
                      };
                    };
                    if ((Handling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell) && ((cl.Col < this.FFixedColumns) || (c === cl.Col))) {
                      cl.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
                      cl.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
                      cl.$assign(this.PreviousSelectableRow(cl.Col,cl.Row));
                    };
                  };
                };
                this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),{},false);
                if (DirectEdit) {
                  Allow = true;
                  this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                      return Allow;
                    }, set: function (v) {
                      Allow = v;
                    }});
                  if (Allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),CellStart,false,"",0);
                };
              } else {
                clc.$assign(pas["WEBLib.TMSFNCGridData"].MakeCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.GetRowCount() - 1 - this.FFixedFooterRows));
                if ((this.GetFocusedCell().Col === clc.Col) && (this.GetFocusedCell().Row === clc.Row)) {
                  clc.$assign(pas["WEBLib.TMSFNCGridData"].MakeCell(this.FFixedColumns,this.FFixedRows));
                  this.SetFocusedCell(clc);
                  return;
                };
                var $tmp5 = Mode;
                if ($tmp5 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell) {
                  c = cl.Col;
                  cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
                  cl.Row = rl.Row;
                  if (c === cl.Col) {
                    r = cl.Row;
                    cl.Col = this.FFixedColumns;
                    cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
                    if (r === cl.Row) {
                      cl.$assign(this.NextSelectableColumn(this.FFixedColumns - 1,cl.Row + 1));
                      while ((cl.Col === (this.FFixedColumns - 1)) && (cl.Row === (r + 1))) {
                        r = cl.Row;
                        cl.$assign(this.NextSelectableColumn(this.FFixedColumns - 1,cl.Row + 1));
                      };
                    };
                    if ((Handling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell) && ((cl.Row > (this.GetRowCount() - 1 - this.FFixedFooterRows)) || (r === cl.Row))) {
                      cl.Col = this.FFixedColumns;
                      cl.Row = this.FFixedRows;
                      cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
                    };
                  };
                } else if ($tmp5 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextRowCell) {
                  r = cl.Row;
                  cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
                  cl.Col = rl.Col;
                  if (r === cl.Row) {
                    c = cl.Col;
                    cl.Row = this.FFixedRows;
                    cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
                    if (c === cl.Col) {
                      cl.$assign(this.NextSelectableRow(cl.Col + 1,this.FFixedRows - 1));
                      while ((cl.Row === (this.FFixedRows - 1)) && (cl.Col === (c + 1))) {
                        c = cl.Col;
                        cl.$assign(this.NextSelectableRow(cl.Col + 1,this.FFixedRows - 1));
                      };
                    };
                    if ((Handling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell) && ((cl.Col > (this.GetColumnCount() - 1 - this.FFixedRightColumns)) || (c === cl.Col))) {
                      cl.Col = this.FFixedColumns;
                      cl.Row = this.FFixedRows;
                      cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
                    };
                  };
                };
                this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),{},false);
                if (DirectEdit) {
                  Allow = true;
                  this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                      return Allow;
                    }, set: function (v) {
                      Allow = v;
                    }});
                  if (Allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),CellStart,false,"",0);
                };
              };
            };
          };
        } else {
          if (Handling !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextControl) {
            if (pas.Classes.TShiftState$a.ssShift in Shift) {
              cl.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
              cl.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
              if (this.IsNormalFixed(cl.Col,cl.Row)) {
                var $tmp6 = Mode;
                if ($tmp6 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell) {
                  cl.$assign(this.PreviousSelectableColumn(cl.Col,cl.Row))}
                 else if ($tmp6 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextRowCell) cl.$assign(this.PreviousSelectableRow(cl.Col,cl.Row));
              };
              this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),{},false);
            } else {
              cl.Col = this.FFixedColumns;
              cl.Row = this.FFixedRows;
              if (this.IsNormalFixed(cl.Col,cl.Row)) {
                var $tmp7 = Mode;
                if ($tmp7 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell) {
                  cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row))}
                 else if ($tmp7 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextRowCell) cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
              };
              this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),{},false);
            };
          };
        };
      };
    };
    this.UpdateCursor = function (ACursor) {
      this.ChangeCursor = false;
      this.SetC(ACursor);
      this.ChangeCursor = true;
    };
    this.DoExit = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.DoExit.call(this);
      this.FClearMouseDown = this.FBlockHide;
      this.FDblClick = false;
      this.FMouseDown = false;
      this.FMouseDblClick = false;
      this.UpdateGridCellDisplay();
    };
    this.DoEnter = function () {
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      if (this.FTabKey === $mod.TTMSFNCGridTabKeyMode.tkmNormal) {
        this.SetFocusedCell(pas["WEBLib.TMSFNCGridData"].MakeCell(this.FFixedColumns,this.FFixedRows))}
       else if (this.FTabKey === $mod.TTMSFNCGridTabKeyMode.tkmShift) {
        cl.Col = this.GetColumnCount() - 1 - this.FFixedRightColumns;
        cl.Row = this.GetRowCount() - 1 - this.FFixedFooterRows;
        this.SetFocusedCell(cl);
      } else this.UpdateGridCellDisplay();
      this.FTabKey = $mod.TTMSFNCGridTabKeyMode.tkmNone;
    };
    this.StopAnimationTimer = function () {
      this.FAnimateTimer$1.SetEnabled(false);
      this.FAnimating$1 = false;
    };
    this.UpdateControlCache = function () {
      var r = 0.0;
      var scol = 0;
      var ecol = 0;
      var i = 0;
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      if ((this.FUpdateCount$1 > 0) || this.FBlockUpdate || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if ((this.FOldSize > 0) && this.FOptions.FColumnSize.FSyncWithGrid) {
        r = this.GetWidth() / this.FOldSize;
        if (this.FOptions.FColumnSize.FSyncNormalCellsOnly) {
          scol = this.FFixedColumns;
          ecol = this.GetColumnCount() - 1 - this.FFixedRightColumns;
        } else {
          scol = 0;
          ecol = this.GetColumnCount() - 1;
        };
        for (var $l = scol, $end = ecol; $l <= $end; $l++) {
          i = $l;
          if (this.FOrigColumnW.GetCount() > i) this.SetColWidths(i,this.FOrigColumnW.GetItem$1(i).FValue * r);
        };
      };
      if (this.FOptions.FColumnSize.FStretch) this.StretchColumn(this.FOptions.FColumnSize.FStretchColumn,-1);
      this.UpdateControlScrollBars(true,true);
      this.FContainerWidth = this.GetTotalColumnWidth();
      this.FContainerHeight = this.GetTotalRowHeight();
      this.UpdateControlScrollBars(false,false);
      if (this.FOptions.FColumnSize.FStretch) this.StretchColumn(this.FOptions.FColumnSize.FStretchColumn,-1);
      this.FContainerWidth = this.GetTotalColumnWidth();
      this.FContainerHeight = this.GetTotalRowHeight();
      if ((this.GetColumnCount() > this.FFixedColumns) && (this.GetRowCount() > this.FFixedRows)) {
        if (!this.FFirstCellApply) {
          cl.Col = this.FFixedColumns;
          cl.Row = this.FFixedRows;
          if (this.IsNormalFixed(cl.Col,cl.Row)) cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
          this.SetStartCell(cl.Col,cl.Row);
          this.SetStopCell(cl.Col,cl.Row);
          this.SetFocusCell(cl.Col,cl.Row);
          this.FPrevSelectedCell.$assign(this.GetFocusedCell());
          this.FSaveCell.$assign(this.GetFocusedCell());
          this.FFirstCell.Col = -1;
          this.FFirstCell.Row = -1;
          this.FRealCell.$assign(this.GetFocusedCell());
          this.FPrevSelection.$assign(this.GetSelection());
          var $tmp = this.FOptions.FSelection.FMode;
          if (($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow)) {
            this.SetStopCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FStopCell.Row)}
           else if (($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn)) this.SetStopCell(this.FStopCell.Col,this.GetRowCount() - 1 - this.FFixedFooterRows);
          this.FBlockUpdate = true;
          var $tmp1 = this.FOptions.FSelection.FMode;
          if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
            this.SetRowSelect(this.GetFocusedCell().Row,true)}
           else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) {
            this.SetColumnSelect(this.GetFocusedCell().Col,true)}
           else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) this.SetCellSelect(this.GetFocusedCell().Col,this.GetFocusedCell().Row,true);
          this.FBlockUpdate = false;
          this.FFirstCellApply = true;
        } else {
          var $tmp2 = this.FOptions.FSelection.FMode;
          if (($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) || ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) || ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow)) {
            this.SetStopCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FStopCell.Row)}
           else if (($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange) || ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) || ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn)) this.SetStopCell(this.FStopCell.Col,this.GetRowCount() - 1 - this.FFixedFooterRows);
        };
      } else {
        cl.Col = -1;
        cl.Row = -1;
        this.FStartCell.$assign(cl);
        this.FStopCell.$assign(cl);
        this.FFocusedCell.$assign(cl);
        this.FPrevSelectedCell.$assign(this.GetFocusedCell());
        this.FSaveCell.$assign(this.GetFocusedCell());
        this.FFirstCell.Col = -1;
        this.FFirstCell.Row = -1;
        this.FRealCell.$assign(this.GetFocusedCell());
        this.FPrevSelection.$assign(this.GetSelection());
      };
      this.UpdateGridCells(false);
    };
    this.UpdateControlDisplay = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.UpdateControlDisplay.call(this);
      this.UpdateGridCellDisplay();
    };
    this.VerticalScrollPositionChanged = function () {
      if (this.FReset) return;
      this.StopEdit();
      this.UpdateGridCells(true);
    };
    this.HorizontalScrollPositionChanged = function () {
      if (this.FReset) return;
      this.StopEdit();
      this.UpdateGridCells(true);
    };
    this.HideEdit = function (AEnterKey, ATestHiding) {
      var Result = false;
      var str = "";
      var allow = false;
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var rl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var nav = false;
      var cellEditor = 0;
      var col = 0;
      var r = 0;
      var c = 0;
      Result = true;
      if (!(this.FEditControl != null) || this.FBlockHide) return Result;
      this.FBlockHide = true;
      try {
        if (this.FEditControl != null) {
          str = "";
          if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl)) {
            str = rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).GetT()}
           else if ($mod.TTMSFNCGridMemo.isPrototypeOf(this.FEditControl)) {
            str = rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).GetText()}
           else if ($mod.TTMSFNCGridSpinBox.isPrototypeOf(this.FEditControl)) {
            str = rtl.as(this.FEditControl,$mod.TTMSFNCGridSpinBox).GetText()}
           else if ($mod.TTMSFNCGridDatePicker.isPrototypeOf(this.FEditControl)) {
            str = pas.SysUtils.DateToStr(rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).GetDate())}
           else if ($mod.TTMSFNCGridColorPicker.isPrototypeOf(this.FEditControl)) {
            col = rtl.as(this.FEditControl,$mod.TTMSFNCGridColorPicker).GetSelectedColor()}
           else if ($mod.TTMSFNCGridTrackBar.isPrototypeOf(this.FEditControl)) {
            str = pas.SysUtils.IntToStr(rtl.as(this.FEditControl,$mod.TTMSFNCGridTrackBar).GetPosition())}
           else if ($mod.TTMSFNCGridComboBox.isPrototypeOf(this.FEditControl)) str = rtl.as(this.FEditControl,$mod.TTMSFNCGridComboBox).GetText();
          allow = true;
          if ($mod.TTMSFNCGridColorPicker.isPrototypeOf(this.FEditControl)) {
            this.DoCellEditValidateColor(this.FEditCell.Col,this.FEditCell.Row,this.FEditControl,{get: function () {
                return col;
              }, set: function (v) {
                col = v;
              }},{get: function () {
                return allow;
              }, set: function (v) {
                allow = v;
              }})}
           else this.DoCellEditValidateData(this.FEditCell.Col,this.FEditCell.Row,this.FEditControl,{get: function () {
              return str;
            }, set: function (v) {
              str = v;
            }},{get: function () {
              return allow;
            }, set: function (v) {
              allow = v;
            }});
          if (ATestHiding) {
            Result = allow;
            return Result;
          };
          if (allow) {
            this.FEditing = false;
            if ($mod.TTMSFNCGridColorPicker.isPrototypeOf(this.FEditControl)) {
              this.DoCellEditSetColor(this.FEditCell.Col,this.FEditCell.Row,this.FEditControl,{get: function () {
                  return col;
                }, set: function (v) {
                  col = v;
                }})}
             else this.DoCellEditSetData(this.FEditCell.Col,this.FEditCell.Row,this.FEditControl,{get: function () {
                return str;
              }, set: function (v) {
                str = v;
              }});
            if (this.FOptions.FEditing.FAutoHistory && $mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl)) {
              this.FOptions.FEditing.FAutoCompleteItems.Add(str);
            };
            this.DoCellEditDone(this.FEditCell.Col,this.FEditCell.Row,this.FEditControl);
            cellEditor = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etEdit;
            this.DoGetCellEditorType(this.FEditCell.Col,this.FEditCell.Row,{get: function () {
                return cellEditor;
              }, set: function (v) {
                cellEditor = v;
              }});
            if (cellEditor !== pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etCustom) {
              if (this.FEditControl != null) {
                this.FEditControl.SetParent(null);
                this.FEditControl = null;
              };
            } else this.FFreeEditControlTimer.SetEnabled(true);
            nav = false;
            cl.$assign(this.GetFocusedCell());
            rl.$assign(this.FRealCell);
            if (AEnterKey) {
              var $tmp = this.FOptions.FKeyboard.FEnterKeyHandling;
              if (($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumn) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnInRow) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnAndAppend) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnAndRowAppend)) {
                nav = true;
                c = cl.Col;
                cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
                cl.Row = rl.Row;
                allow = true;
                this.DoCanAppendColumn(cl.Col + 1,{get: function () {
                    return allow;
                  }, set: function (v) {
                    allow = v;
                  }});
                if (allow && (this.FOptions.FKeyboard.FEnterKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnAndAppend)) {
                  while (c === cl.Col) {
                    this.InsertRow(this.GetColumnCount() - this.FFixedRightColumns);
                    cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
                    this.DoAppendColumn(this.GetColumnCount() - this.FFixedRightColumns - 1);
                  };
                };
                if (c === cl.Col) {
                  r = cl.Row;
                  cl.Col = this.FFixedColumns - 1;
                  cl.$assign(this.NextSelectableColumn(cl.Col,cl.Row));
                  if (r === cl.Row) {
                    if (this.FOptions.FKeyboard.FEnterKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnInRow) {
                      cl.$assign(this.NextSelectableColumn(this.FFixedColumns - 1,cl.Row - 1))}
                     else {
                      allow = true;
                      this.DoCanAppendRow(cl.Row + 1,{get: function () {
                          return allow;
                        }, set: function (v) {
                          allow = v;
                        }});
                      if (allow && (cl.Row === (this.GetRowCount() - 1 - this.FFixedFooterRows))) {
                        if (this.FOptions.FKeyboard.FEnterKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnAndRowAppend) {
                          while (r === cl.Row) {
                            this.InsertRow(this.GetRowCount() - this.FFixedFooterRows);
                            cl.$assign(this.NextSelectableColumn(this.FFixedColumns - 1,cl.Row + 1));
                            this.DoAppendRow(this.GetRowCount() - this.FFixedFooterRows - 1);
                          };
                        };
                      } else cl.$assign(this.NextSelectableColumn(this.FFixedColumns - 1,cl.Row + 1));
                    };
                    while ((cl.Col === (this.FFixedColumns - 1)) && (cl.Row === (r + 1))) {
                      r = cl.Row;
                      cl.$assign(this.NextSelectableColumn(this.FFixedColumns - 1,cl.Row + 1));
                    };
                  };
                };
              } else if (($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextRow) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextRowInColumn) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextRowAndAppend) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextRowAndColumnAppend)) {
                nav = true;
                r = cl.Row;
                cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
                cl.Col = rl.Col;
                allow = true;
                this.DoCanAppendRow(cl.Row + 1,{get: function () {
                    return allow;
                  }, set: function (v) {
                    allow = v;
                  }});
                if (allow && (this.FOptions.FKeyboard.FEnterKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextRowAndAppend)) {
                  while (r === cl.Row) {
                    this.InsertRow(this.GetRowCount() - this.FFixedFooterRows);
                    cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
                    this.DoAppendRow(this.GetRowCount() - this.FFixedFooterRows - 1);
                  };
                };
                if (r === cl.Row) {
                  c = cl.Col;
                  cl.Row = this.FFixedRows - 1;
                  cl.$assign(this.NextSelectableRow(cl.Col,cl.Row));
                  if (c === cl.Col) {
                    if (this.FOptions.FKeyboard.FEnterKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextColumnInRow) {
                      cl.$assign(this.NextSelectableRow(cl.Col - 1,this.FFixedRows - 1))}
                     else {
                      allow = true;
                      this.DoCanAppendColumn(cl.Col + 1,{get: function () {
                          return allow;
                        }, set: function (v) {
                          allow = v;
                        }});
                      if (allow && (cl.Col === (this.GetColumnCount() - 1 - this.FFixedRightColumns))) {
                        if (this.FOptions.FKeyboard.FEnterKeyHandling === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridEnterKeyHandling.ekhNextRowAndColumnAppend) {
                          while (c === cl.Col) {
                            this.InsertColumn(this.GetColumnCount() - this.FFixedRightColumns);
                            cl.$assign(this.NextSelectableRow(cl.Col + 1,this.FFixedRows - 1));
                            this.DoAppendColumn(this.GetColumnCount() - this.FFixedRightColumns - 1);
                          };
                        };
                      } else cl.$assign(this.NextSelectableRow(cl.Col + 1,this.FFixedRows - 1));
                    };
                    while ((cl.Row === (this.FFixedRows - 1)) && (cl.Col === (c + 1))) {
                      c = cl.Col;
                      cl.$assign(this.NextSelectableRow(cl.Col + 1,this.FFixedRows - 1));
                    };
                  };
                };
              };
            };
            if (this.CanFocus()) this.SetFocus();
            if (nav) {
              this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl),{},false);
              if (AEnterKey && this.FOptions.FKeyboard.FEnterKeyDirectEdit) {
                allow = true;
                this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                    return allow;
                  }, set: function (v) {
                    allow = v;
                  }});
                if (allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csNone,false,"",0);
              };
            };
            Result = true;
          } else Result = false;
        };
      } finally {
        this.FBlockHide = false;
      };
      return Result;
    };
    this.CellControlKeyDown = function (Sender, Key, Shift) {
      var $tmp = Key.get();
      if ($tmp === 9) this.HandleDialogKey(Key,rtl.refSet(Shift));
      if (rtl.neSet(Shift,{})) return;
      var $tmp1 = Key.get();
      if ($tmp1 === 27) {
        this.CancelEdit()}
       else if (($tmp1 === 13) || ($tmp1 === 113)) {
        this.HideEdit(Key.get() === 13,false);
        if (Key.get() === 13) Key.set(0);
      };
    };
    this.CellEditKeyDown = function (Sender, Key, Shift) {
      var k = 0;
      var a = false;
      var Allow = false;
      var $tmp = Key.get();
      if ($tmp === 9) this.HandleDialogKey(Key,rtl.refSet(Shift));
      if (rtl.neSet(Shift,{})) return;
      var $tmp1 = Key.get();
      if ($tmp1 === 27) {
        this.CancelEdit()}
       else if (($tmp1 === 13) || ($tmp1 === 113)) {
        this.HideEdit(Key.get() === 13,false)}
       else if ($tmp1 === 37) {
        if (this.FOptions.FKeyboard.FArrowKeyDirectEdit) {
          if (((this.FEditControl === this.GetCellEdit()) && (this.GetCellEdit().GetSelStart() === 0)) || ((this.FEditControl === this.GetCellMemo()) && (this.GetCellMemo().GetSelStart() === 0))) {
            k = 9;
            Key.set(0);
            this.ProcessTab({get: function () {
                return k;
              }, set: function (v) {
                k = v;
              }},rtl.createSet(pas.Classes.TShiftState$a.ssShift),pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell,true,$mod.TTMSFNCGridEditCellStart.csEnd);
          };
        };
      } else if ($tmp1 === 39) {
        if (this.FOptions.FKeyboard.FArrowKeyDirectEdit) {
          if (((this.FEditControl === this.GetCellEdit()) && (this.GetCellEdit().GetSelStart() === this.GetCellEdit().GetT().length)) || ((this.FEditControl === this.GetCellMemo()) && (this.GetCellMemo().GetSelStart() === this.GetCellMemo().GetText().length))) {
            k = 9;
            Key.set(0);
            this.ProcessTab({get: function () {
                return k;
              }, set: function (v) {
                k = v;
              }},{},pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell,true,$mod.TTMSFNCGridEditCellStart.csStart);
          };
        };
      } else if (($tmp1 === 38) || ($tmp1 === 40)) {
        a = this.HideEdit(false,false);
        if (a) {
          this.HandleKeyDown(Key,rtl.refSet(Shift));
          if (this.FOptions.FKeyboard.FArrowKeyDirectEdit) {
            Allow = true;
            this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (Allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csNone,false,"",0);
          };
        };
      };
    };
    this.CellExit = function (Sender) {
      var b = false;
      var p = null;
      if (pas["WEBLib.TMSFNCColorPicker"].TTMSFNCColorPicker.isPrototypeOf(Sender)) {
        p = rtl.as(Sender,pas["WEBLib.TMSFNCColorPicker"].TTMSFNCColorPicker).GetPopup();
        if ((p != null) && p.FIsOpen) return;
      };
      if (pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit.isPrototypeOf(Sender)) {
        p = rtl.as(Sender,pas["WEBLib.TMSFNCEdit"].TTMSFNCEdit).LookupList();
        if ((p != null) && p.FIsOpen) return;
      };
      b = true;
      if (this.FEditing && (this.FEditControl != null)) this.DoBeforeCellEditExit(this.FEditCell.Col,this.FEditCell.Row,this.FEditControl,{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      if (b) this.StopEdit();
    };
    this.CellEditBtnKeyDown = function (Sender, Key, Shift) {
      var k = 0;
      var a = false;
      var Allow = false;
      var $tmp = Key.get();
      if ($tmp === 9) this.HandleDialogKey(Key,rtl.refSet(Shift));
      if (rtl.neSet(Shift,{})) return;
      var $tmp1 = Key.get();
      if ($tmp1 === 27) {
        this.CancelEdit()}
       else if (($tmp1 === 13) || ($tmp1 === 113)) {
        this.HideEdit(Key.get() === 13,false)}
       else if ($tmp1 === 37) {
        if (this.FOptions.FKeyboard.FArrowKeyDirectEdit) {
          if (this.FEditControl === this.GetCellEdit()) {
            if (this.GetCellEdit().GetSelStart() === 0) {
              k = 9;
              Key.set(0);
              this.ProcessTab({get: function () {
                  return k;
                }, set: function (v) {
                  k = v;
                }},rtl.createSet(pas.Classes.TShiftState$a.ssShift),pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell,true,$mod.TTMSFNCGridEditCellStart.csEnd);
            };
          };
        };
      } else if ($tmp1 === 39) {
        if (this.FOptions.FKeyboard.FArrowKeyDirectEdit) {
          if (this.FEditControl === this.GetCellEdit()) {
            if (this.GetCellEdit().GetSelStart() === this.GetCellEdit().GetT().length) {
              k = 9;
              Key.set(0);
              this.ProcessTab({get: function () {
                  return k;
                }, set: function (v) {
                  k = v;
                }},{},pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyDirection.tkdNextColumnCell,pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridTabKeyHandling.tkhNextCell,true,$mod.TTMSFNCGridEditCellStart.csStart);
            };
          };
        };
      } else if (($tmp1 === 38) || ($tmp1 === 40)) {
        a = this.HideEdit(false,false);
        if (a) {
          this.HandleKeyDown(Key,rtl.refSet(Shift));
          if (this.FOptions.FKeyboard.FArrowKeyDirectEdit) {
            Allow = true;
            this.DoCanEditCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row,{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (Allow) this.EditCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),$mod.TTMSFNCGridEditCellStart.csNone,false,"",0);
          };
        };
      };
    };
    this.CellComboBoxKeyDown = function (Sender, Key, Shift) {
      var $tmp = Key.get();
      if ($tmp === 9) this.HandleDialogKey(Key,rtl.refSet(Shift));
      this.FKeyUsed = true;
      if (rtl.neSet(Shift,{})) return;
      var $tmp1 = Key.get();
      if ($tmp1 === 115) {
        if (this.FEditControl === this.GetCellDatePicker()) ;
      } else if (($tmp1 === 13) || ($tmp1 === 113)) {
        this.HideEdit(Key.get() === 13,false);
        if (Key.get() === 13) Key.set(0);
      } else if ($tmp1 === 27) this.CancelEdit();
    };
    this.CellComboBoxChange = function (Sender) {
      if (this.FKeyUsed) {
        this.FKeyUsed = false;
        return;
      };
      if (this.FOptions.FEditing.FDirectComboClose && this.FEditing) this.StopEdit();
    };
    this.CellComboBoxCloseUp = function (Sender) {
      var v = "";
      var i = 0;
      i = -1;
      v = "";
      if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(Sender)) {
        i = rtl.as(Sender,pas["WEBLib.StdCtrls"].TComboBox).GetItemIndex();
        if (i >= 0) {
          v = rtl.as(Sender,pas["WEBLib.StdCtrls"].TComboBox).FItems.Get(i)}
         else v = "";
      };
      if (this.FOptions.FEditing.FDirectComboClose) this.HideEdit(true,false);
      this.DoCellComboCloseUp(this.GetFocusedCell().Col,this.GetFocusedCell().Row,i,v);
      this.CellComboBoxChange(Sender);
    };
    this.ScrollTimer = function (Sender) {
      var c = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!this.FOptions.FMouse.FAutoScrolling) {
        this.FScrollTimer.SetEnabled(false);
        return;
      };
      contentr.$assign(this.GetContentRect());
      if (this.FX >= (contentr.Right - contentr.Left - this.GetFixedRightWidth())) {
        c.$assign(this.GetFocusedCell());
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          c.Col = c.Col + (Math.round(this.FX - (contentr.Right - contentr.Left - this.GetFixedRightWidth())) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else c.Col = c.Col + this.FOptions.FMouse.FAutoScrollingSpeed;
        this.SetFocusCell(c.Col,c.Row);
        this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),{},this.FMouseDragging);
      } else if (this.FX <= this.GetFixedWidth()) {
        c.$assign(this.GetFocusedCell());
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          c.Col = c.Col + (Math.round(this.FX - this.GetFixedWidth()) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else c.Col = c.Col - this.FOptions.FMouse.FAutoScrollingSpeed;
        this.SetFocusCell(c.Col,c.Row);
        this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),{},this.FMouseDragging);
      };
      if (this.FY >= (contentr.Bottom - contentr.Top - this.GetFixedFooterHeight())) {
        c.$assign(this.GetFocusedCell());
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          c.Row = c.Row + (Math.round(this.FY - (contentr.Bottom - contentr.Top - this.GetFixedFooterHeight())) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else c.Row = c.Row + this.FOptions.FMouse.FAutoScrollingSpeed;
        this.SetFocusCell(c.Col,c.Row);
        this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),{},this.FMouseDragging);
      } else if (this.FY <= this.GetFixedHeight()) {
        c.$assign(this.GetFocusedCell());
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          c.Row = c.Row + (Math.round(this.FY - this.GetFixedHeight()) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else c.Row = c.Row - this.FOptions.FMouse.FAutoScrollingSpeed;
        this.SetFocusCell(c.Col,c.Row);
        this.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),{},this.FMouseDragging);
      };
    };
    this.DragTimer = function (Sender) {
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!this.FOptions.FMouse.FAutoDragging) {
        this.FDragTimer.SetEnabled(false);
        return;
      };
      contentr.$assign(this.GetContentRect());
      if (this.FX >= (contentr.Right - contentr.Left)) {
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          this.FDragScrollCell.Col = this.FDragScrollCell.Col + (Math.round(this.FX - (contentr.Right - contentr.Left)) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else this.FDragScrollCell.Col = this.FDragScrollCell.Col + this.FOptions.FMouse.FAutoScrollingSpeed;
        this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.FDragScrollCell),false);
      } else if (this.FX <= 0) {
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          this.FDragScrollCell.Col = this.FDragScrollCell.Col + (Math.round(this.FX) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else this.FDragScrollCell.Col = this.FDragScrollCell.Col - this.FOptions.FMouse.FAutoScrollingSpeed;
        this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.FDragScrollCell),false);
      };
      if (this.FY >= (contentr.Bottom - contentr.Top)) {
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          this.FDragScrollCell.Row = this.FDragScrollCell.Row + (Math.round(this.FY - (contentr.Bottom - contentr.Top)) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else this.FDragScrollCell.Row = this.FDragScrollCell.Row + this.FOptions.FMouse.FAutoScrollingSpeed;
        this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.FDragScrollCell),false);
      } else if (this.FY <= 0) {
        if (this.FOptions.FMouse.FAutoScrollingSpeedMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoScrollingSpeedMode.asmPixels) {
          this.FDragScrollCell.Row = this.FDragScrollCell.Row + (Math.round(this.FY) * this.FOptions.FMouse.FAutoScrollingSpeed)}
         else this.FDragScrollCell.Row = this.FDragScrollCell.Row - this.FOptions.FMouse.FAutoScrollingSpeed;
        this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.FDragScrollCell),false);
      };
    };
    this.AutoSizeColumnInt = function (ACol, Accurate, Padding) {
      var i = 0;
      var k = 0;
      var cell = null;
      var cellclasstype = null;
      var prevclasstype = null;
      var cellstr = "";
      var m = 0.0;
      var nw = 0.0;
      var tw = 0.0;
      var ctl = null;
      var l = null;
      var bmp = null;
      var totalh = 0.0;
      var rs = 0;
      var c = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var a = 0;
      l = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      m = 0;
      nw = 0;
      cell = null;
      prevclasstype = null;
      if (!Accurate) {
        prevclasstype = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell;
        cell = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.$create("Create$1",[this]);
        cell.FScaleFactor = this.FPaintScaleFactor;
        this.DoGetCellLayout(this.FFixedColumns,this.FFixedRows,cell.FLayout,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csNormal);
        cell.SetWidth(10000);
        cell.SetHeight(10000);
        rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetText("g");
        nw = rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).GetTextWidth();
      };
      for (var $l = 0, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.IsXMergedCell(ACol,i)) continue;
        cellclasstype = null;
        this.DoGetCellClass(ACol,i,{get: function () {
            return cellclasstype;
          }, set: function (v) {
            cellclasstype = v;
          }});
        cellstr = "";
        this.DoGetCellData(ACol,i,{get: function () {
            return cellstr;
          }, set: function (v) {
            cellstr = v;
          }});
        if ((prevclasstype !== cellclasstype) && (prevclasstype !== null) && (cell != null)) cell = rtl.freeLoc(cell);
        if (prevclasstype !== cellclasstype) {
          cell = cellclasstype.$create("Create$1",[this]);
          if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
            rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FBitmapContainer = this.GetBitmapContainer();
            rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
          };
        };
        cell.FScaleFactor = this.FPaintScaleFactor;
        prevclasstype = cellclasstype;
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
          a = 0;
          this.DoGetCellRotation(ACol,i,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }});
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetAngle(a);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetText(cellstr);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetDisplayHTMLFormatting(this.FOptions.FCell.FDisplayHTMLFormatting);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetWidth(this.GetColWidths(ACol));
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetHeight(this.GetRowHeights(i));
        };
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell.isPrototypeOf(cell)) {
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetFormat(this.FAppearance.FProgressLayout.FFormat);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetTextColor(this.FAppearance.FProgressLayout.FTextColor);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetColor(this.FAppearance.FProgressLayout.FColor);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetShowText(this.FAppearance.FProgressLayout.FShowText);
        };
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetControlBitmap(this.GetCheckBoxBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked,false,true));
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetControlBitmap(this.GetRadioButtonBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FChecked,false,true));
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).SetControlBitmap(this.GetNodeBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).FState));
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetControlBitmap(this.GetDummyButtonBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell)));
        this.ApplyCellState(ACol,i,cell);
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
          l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
          this.DoGetCellLayout(ACol,i,l,this.GetCellState(ACol,i));
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
        };
        this.DoGetCellProperties(ACol,i,cell);
        totalh = 0;
        c.$assign(pas["WEBLib.TMSFNCGridData"].MakeCell(ACol,i));
        c.$assign(this.BaseCell(c.Col,c.Row));
        rs = this.RowSpan(c.Col,c.Row);
        if (rs > 0) {
          for (var $l1 = c.Row, $end1 = (c.Row + rs) - 1; $l1 <= $end1; $l1++) {
            k = $l1;
            totalh = totalh + this.GetRowHeights(k);
          };
        } else totalh = this.GetRowHeights(c.Row);
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
          ctl = rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
          ctl.SetWidth(10000);
          ctl.SetHeight(totalh - 4);
          if (!Accurate) {
            tw = ctl.GetStrippedHTMLText().length * nw;
            bmp = ctl.GetControlBitmap();
            if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) tw = tw + bmp.GetWidth();
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(ctl)) {
              if (rtl.as(ctl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FShowDropDownButton) nw = nw + 19;
              if (rtl.as(ctl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FSortKind !== pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone) nw = nw + 16;
            };
            if (tw > m) m = tw;
          } else {
            nw = ctl.GetTextWidth();
            bmp = ctl.GetControlBitmap();
            if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) nw = nw + bmp.GetWidth();
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(ctl)) {
              if (rtl.as(ctl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FShowDropDownButton) nw = nw + 19;
              if (rtl.as(ctl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FSortKind !== pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone) nw = nw + 16;
            };
            if (nw > m) m = nw;
          };
        };
      };
      if (cell != null) cell = rtl.freeLoc(cell);
      this.SetColWidths(ACol,m + Padding);
      l = rtl.freeLoc(l);
    };
    this.AutoSizeRowInt = function (ARow, Padding) {
      var i = 0;
      var k = 0;
      var cell = null;
      var cellclasstype = null;
      var prevclasstype = null;
      var cellstr = "";
      var m = 0.0;
      var nw = 0.0;
      var ctl = null;
      var l = null;
      var bmp = null;
      var c = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var totalw = 0.0;
      var cs = 0;
      var a = 0;
      l = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      m = 0;
      prevclasstype = null;
      cell = null;
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.IsYMergedCell(i,ARow)) continue;
        cellclasstype = null;
        this.DoGetCellClass(i,ARow,{get: function () {
            return cellclasstype;
          }, set: function (v) {
            cellclasstype = v;
          }});
        cellstr = "";
        this.DoGetCellData(i,ARow,{get: function () {
            return cellstr;
          }, set: function (v) {
            cellstr = v;
          }});
        if ((prevclasstype !== cellclasstype) && (prevclasstype !== null) && (cell != null)) cell = rtl.freeLoc(cell);
        if (prevclasstype !== cellclasstype) {
          cell = cellclasstype.$create("Create$1",[this]);
          if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
            rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetLayout(null);
            rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FBitmapContainer = this.GetBitmapContainer();
            rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
          };
        };
        cell.FScaleFactor = this.FPaintScaleFactor;
        prevclasstype = cellclasstype;
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
          a = 0;
          this.DoGetCellRotation(i,ARow,{get: function () {
              return a;
            }, set: function (v) {
              a = v;
            }});
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetAngle(a);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetText(cellstr);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetDisplayHTMLFormatting(this.FOptions.FCell.FDisplayHTMLFormatting);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetWidth(this.GetColWidths(i));
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetHeight(this.GetRowHeights(ARow));
        };
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell.isPrototypeOf(cell)) {
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetFormat(this.FAppearance.FProgressLayout.FFormat);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetTextColor(this.FAppearance.FProgressLayout.FTextColor);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetColor(this.FAppearance.FProgressLayout.FColor);
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetShowText(this.FAppearance.FProgressLayout.FShowText);
        };
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetControlBitmap(this.GetCheckBoxBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked,false,true));
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetControlBitmap(this.GetRadioButtonBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FChecked,false,true));
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).SetControlBitmap(this.GetNodeBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).FState));
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetControlBitmap(this.GetDummyButtonBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell)));
        this.ApplyCellState(i,ARow,cell);
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
          l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
          this.DoGetCellLayout(i,ARow,l,this.GetCellState(i,ARow));
          rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
        };
        this.DoGetCellProperties(i,ARow,cell);
        totalw = 0;
        c.$assign(pas["WEBLib.TMSFNCGridData"].MakeCell(i,ARow));
        c.$assign(this.BaseCell(c.Col,c.Row));
        cs = this.ColSpan(c.Col,c.Row);
        if (cs > 0) {
          for (var $l1 = c.Col, $end1 = (c.Col + cs) - 1; $l1 <= $end1; $l1++) {
            k = $l1;
            totalw = totalw + this.GetColWidths(k);
          };
        } else totalw = this.GetColWidths(c.Col);
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
          ctl = rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
          ctl.SetWidth(totalw - 4);
          ctl.SetHeight(10000);
          nw = ctl.GetTextHeight();
          bmp = ctl.GetControlBitmap();
          if ((bmp != null) && !pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(bmp)) {
            if (bmp.GetHeight() > nw) nw = bmp.GetHeight();
          };
          if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(ctl)) {
            if (rtl.as(ctl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FShowDropDownButton) {
              if (15 > nw) nw = 15;
            };
            if (rtl.as(ctl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FSortKind !== pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone) {
              if (12 > nw) nw = 12;
            };
          };
          if (nw > m) m = nw;
        };
      };
      if (cell != null) cell = rtl.freeLoc(cell);
      this.SetRowHeights(ARow,m + Padding);
      l = rtl.freeLoc(l);
    };
    this.DoCheckBoxClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      this.StopEdit();
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) {
          if (this.FAdapter != null) this.FAdapter.CellCheckBoxClick(cell.Col,cell.Row,cl);
          this.DoCellCheckBoxClick(cell.Col,cell.Row,cl);
        };
      };
    };
    this.DoRadioButtonClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoCellRadioButtonClick(cell.Col,cell.Row,cl);
      };
    };
    this.DoButtonClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoCellButtonClick(cell.Col,cell.Row,cl);
      };
    };
    this.DoNodeClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoCellNodeClick(cell.Col,cell.Row,cl);
      };
    };
    this.DoBitmapClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoCellBitmapClick(cell.Col,cell.Row,cl);
      };
    };
    this.DoCommentClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoCellCommentClick(cell.Col,cell.Row,cl);
      };
    };
    this.DoFixedDropDownButtonClick = function (Sender) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoFixedCellDropDownButtonClick(cell.Col,cell.Row,cl);
      };
    };
    this.DoCellAnchorClick = function (ACol, ARow, AAnchor) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellAnchorClick.apply(this,arguments);
      if (this.FOptions.FURL.FOpen) pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.OpenURL(AAnchor);
      if (this.FOnCellAnchorClick != null) this.FOnCellAnchorClick(this,ACol,ARow,AAnchor);
    };
    this.DoCanSizeColumn = function (ACol, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanSizeColumn.apply(this,arguments);
      if (this.FOnCanSizeColumn != null) this.FOnCanSizeColumn(this,ACol,Allow);
    };
    this.DoCanSizeRow = function (ARow, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanSizeRow.apply(this,arguments);
      if (this.FOnCanSizeRow != null) this.FOnCanSizeRow(this,ARow,Allow);
    };
    this.DoColumnSize = function (ACol, NewWidth) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoColumnSize.apply(this,arguments);
      if (this.FOnColumnSize != null) this.FOnColumnSize(this,ACol,NewWidth);
    };
    this.DoRowSize = function (ARow, NewHeight) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoRowSize.apply(this,arguments);
      if (this.FOnRowSize != null) this.FOnRowSize(this,ARow,NewHeight);
    };
    this.DoColumnSized = function (ACol, NewWidth) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoColumnSized.apply(this,arguments);
      if (this.FOnColumnSized != null) this.FOnColumnSized(this,ACol,NewWidth);
    };
    this.DoRowSized = function (ARow, NewHeight) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoRowSized.apply(this,arguments);
      if (this.FOnRowSized != null) this.FOnRowSized(this,ARow,NewHeight);
    };
    this.DoCanSortColumn = function (ACol, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanSortColumn.apply(this,arguments);
      if (this.FOnCanSortColumn != null) this.FOnCanSortColumn(this,ACol,Allow);
    };
    this.DoColumnSorted = function (ACol, Direction) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoColumnSorted.apply(this,arguments);
      if (this.FOnColumnSorted != null) this.FOnColumnSorted(this,ACol,Direction);
    };
    this.DoCanDragColumn = function (ACol, Allow) {
      if (this.FOnCanDragColumn != null) this.FOnCanDragColumn(this,ACol,Allow);
    };
    this.DoCanDragRow = function (ARow, Allow) {
      if (this.FOnCanDragRow != null) this.FOnCanDragRow(this,ARow,Allow);
    };
    this.DoColumnDragged = function (FromColumn, ToColumn) {
      if (this.FOnColumnDragged != null) this.FOnColumnDragged(this,FromColumn,ToColumn);
    };
    this.DoRowDragged = function (FromRow, ToRow) {
      if (this.FOnRowDragged != null) this.FOnRowDragged(this,FromRow,ToRow);
    };
    this.DoBeforeCellEditExit = function (ACol, ARow, CellEditor, AllowExit) {
      if (this.FAdapter != null) this.FAdapter.CellBeforeEditExit(ACol,ARow,CellEditor,AllowExit);
      if (this.FOnBeforeCellEditExit != null) this.FOnBeforeCellEditExit(this,ACol,ARow,CellEditor,AllowExit);
    };
    this.DoBeforeColumnDrop = function (FromColumn, ToColumn, Allow) {
      if (this.FOnBeforeColumnDrop != null) this.FOnBeforeColumnDrop(this,FromColumn,ToColumn,Allow);
    };
    this.DoBeforeRowDrop = function (FromRow, ToRow, Allow) {
      if (this.FOnBeforeRowDrop != null) this.FOnBeforeRowDrop(this,FromRow,ToRow,Allow);
    };
    this.DoFixedCellDropDownButtonClick = function (ACol, ARow, ACell) {
      var sl = null;
      var i = 0;
      var c = 0;
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoFixedCellDropDownButtonClick.apply(this,arguments);
      if (this.FOptions.FFiltering.FDropDown && (this.FOptions.FFiltering.FDropDownFixedRow === ARow)) {
        sl = pas.Classes.TStringList.$create("Create$1");
        try {
          sl.FDuplicates = pas.Types.TDuplicates.dupIgnore;
          sl.SetSorted(true);
          sl.Add(rtl.getResStr($mod,"sTMSFNCGridFilterAll"));
          c = this.DisplToRealColumn(ACol);
          for (var $l = this.FFixedRows, $end = (this.GetRowCount() - this.FFixedFooterRows - 1) + this.GetHiddenRowCount(); $l <= $end; $l++) {
            i = $l;
            sl.Add(pas.SysUtils.Trim(this.GetAllCells(c,i)));
          };
          this.DoNeedFilterDropDownData(c,ARow,sl);
          this.FFilterListBox.SetParent(this);
          this.FFilterListBox.FItems.Assign(sl);
          this.FFilterListBox.SetItemIndex(-1);
          this.FFilterListBox.SetParent(null);
          this.FFilterListBox.FTag$1 = ACol;
        } finally {
          sl = rtl.freeLoc(sl);
        };
      };
      this.FFilterPopup.SetPlacementControl(this);
      pt.$assign(this.LocalToScreenEx(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF((ACell.FLeft + ACell.FWidth) - (17 * this.FPaintScaleFactor),ACell.FTop + ((ACell.FHeight + (15 * this.FPaintScaleFactor)) / 2)))));
      this.FFilterPopup.FPlacementRectangle.SetLeft(pt.X);
      this.FFilterPopup.FPlacementRectangle.SetTop(pt.Y);
      this.FFilterPopup.FPlacementRectangle.SetRight(pt.X + this.FFilterPopup.FDropDownWidth);
      this.FFilterPopup.FPlacementRectangle.SetBottom(pt.Y + this.FFilterPopup.FDropDownHeight);
      this.FFilterListBox.SetWidth(this.FOptions.FFiltering.FDropDownWidth);
      this.FFilterListBox.SetHeight(this.FOptions.FFiltering.FDropDownHeight);
      this.FFilterPopup.SetDropDownHeight(this.FOptions.FFiltering.FDropDownHeight);
      this.FFilterPopup.SetDropDownWidth(this.FOptions.FFiltering.FDropDownWidth);
      this.FFilterPopup.SetContentControl(this.FFilterListBox);
      this.FFilterPopup.FFocusedControl = this.FFilterListBox;
      this.FFilterPopup.Popup(false);
      if (this.FOnFixedCellDropDownButtonClick != null) this.FOnFixedCellDropDownButtonClick(this,ACol,ARow,ACell);
    };
    this.DoCellCheckBoxClick = function (ACol, ARow, ACell) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellCheckBoxClick.apply(this,arguments);
      if (this.FOnCellCheckBoxClick != null) this.FOnCellCheckBoxClick(this,ACol,ARow,ACell);
    };
    this.DoCellRadioButtonClick = function (ACol, ARow, ACell) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellRadioButtonClick.apply(this,arguments);
      if (this.FOnCellRadioButtonClick != null) this.FOnCellRadioButtonClick(this,ACol,ARow,ACell);
    };
    this.DoCellButtonClick = function (ACol, ARow, ACell) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellButtonClick.apply(this,arguments);
      if (this.FOnCellButtonClick != null) this.FOnCellButtonClick(this,ACol,ARow,ACell);
    };
    this.DoGetCellIsFixed = function (ACol, ARow, ACellFixed) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellIsFixed.apply(this,arguments);
      if (this.FOnGetCellIsFixed != null) this.FOnGetCellIsFixed(this,ACol,ARow,ACellFixed);
    };
    this.DoGetRowIsBand = function (ARow, ARowBand) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetRowIsBand.apply(this,arguments);
      if (this.FOnGetRowIsBand != null) this.FOnGetRowIsBand(this,ARow,ARowBand);
    };
    this.DoCellBitmapClick = function (ACol, ARow, ACell) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellBitmapClick.apply(this,arguments);
      if (this.FOnCellBitmapClick != null) this.FOnCellBitmapClick(this,ACol,ARow,ACell);
    };
    this.DoCellCommentClick = function (ACol, ARow, ACell) {
      var g = null;
      var sz = pas["WEBLib.TMSFNCTypes"].TSizeF.$new();
      var pt = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellCommentClick.apply(this,arguments);
      this.FCommentPopup.SetPlacementControl(this);
      this.FActiveComment = rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell).FCommentText;
      this.FActiveCommentTextColor = rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell).FCommentTextColor;
      g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
      g.BeginScene();
      g.FBitmapContainer = this.GetBitmapContainer();
      g.FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
      try {
        sz.$assign(g.CalculateTextSize(this.FActiveComment,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(0,0,10000,10000)),true,true));
        this.FCommentPopup.SetDropDownHeight(sz.cy + 10);
        this.FCommentPopup.SetDropDownWidth(sz.cx + 10);
      } finally {
        g.EndScene();
        g = rtl.freeLoc(g);
      };
      pt.$assign(this.LocalToScreenEx(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF((ACell.FLeft + ACell.FWidth) - this.FCommentPopup.FDropDownWidth,ACell.FTop - this.FCommentPopup.FDropDownHeight))));
      this.FCommentPopup.FPlacementRectangle.SetLeft(pt.X);
      this.FCommentPopup.FPlacementRectangle.SetTop(pt.Y);
      this.FCommentPopup.FPlacementRectangle.SetRight(pt.X + this.FCommentPopup.FDropDownWidth);
      this.FCommentPopup.FPlacementRectangle.SetBottom(pt.Y + this.FCommentPopup.FDropDownHeight);
      this.FCommentPopup.Popup(false);
      if (this.FOnCellCommentClick != null) this.FOnCellCommentClick(this,ACol,ARow,ACell);
    };
    this.DoCellSortClick = function (Shift, ACol, ARow, Direction, ACell) {
      var AllowSort = false;
      var sortc = null;
      if (this.FOptions.FSorting.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmNone) {
        AllowSort = true;
        this.DoCanSortColumn(ACol,{get: function () {
            return AllowSort;
          }, set: function (v) {
            AllowSort = v;
          }});
        if (AllowSort) {
          sortc = rtl.as(ACell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell);
          if (sortc != null) {
            if (this.FOptions.FSorting.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmIndexed) {
              if (!(pas.Classes.TShiftState$a.ssShift in Shift)) {
                this.FSortIndexes.Clear();
                this.ClearFixedSorting(sortc);
              };
            } else this.ClearFixedSorting(sortc);
            var $tmp = sortc.FSortKind;
            if ($tmp === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skAscending) {
              Direction = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdDescending;
              if (this.FOptions.FSorting.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmIndexed) {
                if (this.FSortIndexes.FindIndex(ACol) === -1) {
                  this.FSortIndexes.AddIndex(ACol,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdDescending)}
                 else this.FSortIndexes.ToggleIndex(ACol);
                sortc.FSortIndex = this.FSortIndexes.FindIndex(ACol) + 1;
              } else sortc.FSortIndex = -1;
              sortc.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skDescending;
            } else if (($tmp === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone) || ($tmp === pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skDescending)) {
              Direction = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdAscending;
              if (this.FOptions.FSorting.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmIndexed) {
                if (this.FSortIndexes.FindIndex(ACol) === -1) {
                  this.FSortIndexes.AddIndex(ACol,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdAscending)}
                 else this.FSortIndexes.ToggleIndex(ACol);
                sortc.FSortIndex = this.FSortIndexes.FindIndex(ACol) + 1;
              } else sortc.FSortIndex = -1;
              sortc.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skAscending;
            };
            pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellSortClick.call(this,rtl.refSet(Shift),ACol,ARow,Direction,ACell);
            if (this.FOnCellSortClick != null) this.FOnCellSortClick(this,ACol,ARow,ACell);
            this.DoColumnSorted(ACol,Direction);
          };
        };
      };
    };
    this.DoCellNodeClick = function (ACol, ARow, ACell) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellNodeClick.apply(this,arguments);
      if (this.FOnCellNodeClick != null) this.FOnCellNodeClick(this,ACol,ARow,ACell);
    };
    this.DoInsertRow = function (ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoInsertRow.apply(this,arguments);
      if (this.FOnInsertRow != null) this.FOnInsertRow(this,ARow);
    };
    this.DoDeleteRow = function (ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoDeleteRow.apply(this,arguments);
      if (this.FOnDeleteRow != null) this.FOnDeleteRow(this,ARow);
    };
    this.DoAppendRow = function (ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoAppendRow.apply(this,arguments);
      if (this.FOnAppendRow != null) this.FOnAppendRow(this,ARow);
    };
    this.DoAppendColumn = function (ACol) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoAppendColumn.apply(this,arguments);
      if (this.FOnAppendColumn != null) this.FOnAppendColumn(this,ACol);
    };
    this.DoCanInsertRow = function (ARow, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanInsertRow.apply(this,arguments);
      if (this.FOnCanInsertRow != null) this.FOnCanInsertRow(this,ARow,Allow);
    };
    this.DoCanDeleteRow = function (ARow, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanDeleteRow.apply(this,arguments);
      if (this.FOnCanDeleteRow != null) this.FOnCanDeleteRow(this,ARow,Allow);
    };
    this.DoCanAppendRow = function (ARow, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanAppendRow.apply(this,arguments);
      if (this.FOnCanAppendRow != null) this.FOnCanAppendRow(this,ARow,Allow);
    };
    this.DoCanAppendColumn = function (ACol, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCanAppendColumn.apply(this,arguments);
      if (this.FOnCanAppendColumn != null) this.FOnCanAppendColumn(this,ACol,Allow);
    };
    this.DoCellRightClick = function (ACol, ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellRightClick.apply(this,arguments);
      if (this.FOnCellRightClick != null) this.FOnCellRightClick(this,ACol,ARow);
    };
    this.DoFixedCellRightClick = function (ACol, ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoFixedCellRightClick.apply(this,arguments);
      if (this.FOnFixedCellRightClick != null) this.FOnFixedCellRightClick(this,ACol,ARow);
    };
    this.DoCellClick = function (ACol, ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellClick.apply(this,arguments);
      if (this.FOnCellClick != null) this.FOnCellClick(this,ACol,ARow);
    };
    this.DoFixedCellClick = function (Shift, ACol, ARow) {
      var cell = null;
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoFixedCellClick.apply(this,arguments);
      cl.Col = ACol;
      cl.Row = ARow;
      cell = this.GetCellObject(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(cl))));
      if (cell != null) {
        if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(cell) && (ARow === this.FOptions.FSorting.FRow)) this.DoCellSortClick(rtl.refSet(Shift),ACol,ARow,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdAscending,cell);
      };
      if (this.FOnFixedCellClick != null) this.FOnFixedCellClick(this,ACol,ARow);
    };
    this.DoCellDblClick = function (ACol, ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellDblClick.apply(this,arguments);
      if (this.FOnCellDblClick != null) this.FOnCellDblClick(this,ACol,ARow);
    };
    this.DoFixedCellDblClick = function (ACol, ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoFixedCellDblClick.apply(this,arguments);
      if (this.FOnFixedCellDblClick != null) this.FOnFixedCellDblClick(this,ACol,ARow);
    };
    this.DoGetCellClass = function (ACol, ARow, CellClassType) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellClass.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetCellClass(ACol,ARow,CellClassType);
      if (this.FOnGetCellClass != null) this.FOnGetCellClass(this,ACol,ARow,CellClassType);
    };
    this.DoGetCellData = function (ACol, ARow, CellString) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellData.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetCellData(ACol,ARow,CellString);
      if (this.FOnGetCellData != null) this.FOnGetCellData(this,ACol,ARow,CellString);
    };
    this.DoGetCellRotation = function (ACol, ARow, Angle) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellRotation.apply(this,arguments);
      if (this.FOnGetCellRotation != null) this.FOnGetCellRotation(this,ACol,ARow,Angle);
    };
    this.DoGetCellLayout = function (ACol, ARow, ALayout, ACellState) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellLayout.apply(this,arguments);
      if (this.FOnGetCellLayout != null) this.FOnGetCellLayout(this,ACol,ARow,ALayout,ACellState);
    };
    this.DoGetCellProperties = function (ACol, ARow, Cell) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellProperties.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetCellProperties(ACol,ARow,Cell);
      if (this.FOnGetCellProperties != null) this.FOnGetCellProperties(this,ACol,ARow,Cell);
    };
    this.DoGetCellMergeInfo = function (ACol, ARow, ABaseCol, ABaseRow, AColSpan, ARowSpan) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellMergeInfo.apply(this,arguments);
      if (this.FOnGetCellMergeInfo != null) this.FOnGetCellMergeInfo(this,ACol,ARow,ABaseCol,ABaseRow,AColSpan,ARowSpan);
    };
    this.DoGetCellEditorCustomClassType = function (ACol, ARow, CellEditorCustomClassType) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellEditorCustomClassType.apply(this,arguments);
      if (this.FOnGetCellEditorCustomClassType != null) this.FOnGetCellEditorCustomClassType(this,ACol,ARow,CellEditorCustomClassType);
    };
    this.DoGetCellEditorType = function (ACol, ARow, CellEditorType) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellEditorType.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetCellEditorType(ACol,ARow,CellEditorType);
      if (this.FOnGetCellEditorType != null) this.FOnGetCellEditorType(this,ACol,ARow,CellEditorType);
    };
    this.DoCellEditGetData = function (ACol, ARow, CellEditor, CellString) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditGetData.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.CellEditGetData(ACol,ARow,CellEditor,CellString);
      if (this.FOnCellEditGetData != null) this.FOnCellEditGetData(this,ACol,ARow,CellEditor,CellString);
    };
    this.DoCellEditValidateData = function (ACol, ARow, CellEditor, CellString, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditValidateData.apply(this,arguments);
      if (this.FOnCellEditValidateData != null) this.FOnCellEditValidateData(this,ACol,ARow,CellEditor,CellString,Allow);
      if (this.FAdapter != null) this.FAdapter.CellEditValidateData(ACol,ARow,CellEditor,CellString,Allow);
    };
    this.DoCellEditSetData = function (ACol, ARow, CellEditor, CellString) {
      if (this.FAdapter != null) this.FAdapter.CellEditSetData(ACol,ARow,CellEditor,CellString);
      if (this.FOnCellEditSetData != null) this.FOnCellEditSetData(this,ACol,ARow,CellEditor,CellString);
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditSetData.apply(this,arguments);
    };
    this.DoCellComboCloseUp = function (ACol, ARow, ItemIndex, Value) {
      if (this.FOnCellComboCloseUp != null) this.FOnCellComboCloseUp(this,ACol,ARow,ItemIndex,Value);
    };
    this.DoCellEditGetColor = function (ACol, ARow, CellEditor, CellColor) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditGetColor.apply(this,arguments);
      if (this.FOnCellEditGetColor != null) this.FOnCellEditGetColor(this,ACol,ARow,CellEditor,CellColor);
    };
    this.DoCellEditValidateColor = function (ACol, ARow, CellEditor, CellColor, Allow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditValidateColor.apply(this,arguments);
      if (this.FOnCellEditValidateColor != null) this.FOnCellEditValidateColor(this,ACol,ARow,CellEditor,CellColor,Allow);
    };
    this.DoCellEditSetColor = function (ACol, ARow, CellEditor, CellColor) {
      if (this.FOnCellEditSetColor != null) this.FOnCellEditSetColor(this,ACol,ARow,CellEditor,CellColor);
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditSetColor.apply(this,arguments);
    };
    this.DoCellEditDone = function (ACol, ARow, CellEditor) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoCellEditDone.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.CellEditDone(ACol,ARow,CellEditor);
      if (this.FOnCellEditDone != null) this.FOnCellEditDone(this,ACol,ARow,CellEditor);
      if (this.FOnInternalCellEditDone != null) this.FOnInternalCellEditDone(this,ACol,ARow,CellEditor);
    };
    this.DoCellEditCancel = function (ACol, ARow) {
      if (this.FAdapter != null) this.FAdapter.CellEditCancel(ACol,ARow);
      if (this.FOnCellEditCancel != null) this.FOnCellEditCancel(this,ACol,ARow);
    };
    this.DoGetCellEditorProperties = function (ACol, ARow, CellEditor) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellEditorProperties.apply(this,arguments);
      if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(CellEditor)) rtl.as(CellEditor,pas["WEBLib.StdCtrls"].TComboBox).SetParent(this);
      if (this.FAdapter != null) this.FAdapter.GetCellEditorProperties(ACol,ARow,CellEditor);
      if (this.FOnGetCellEditorProperties != null) this.FOnGetCellEditorProperties(this,ACol,ARow,CellEditor);
      if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(CellEditor)) rtl.as(CellEditor,pas["WEBLib.StdCtrls"].TComboBox).SetParent(null);
    };
    this.DoGetCellReadOnly = function (ACol, ARow, AReadOnly) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.DoGetCellReadOnly.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.GetCellReadOnly(ACol,ARow,AReadOnly);
      if (this.FOnGetCellReadOnly != null) this.FOnGetCellReadOnly(this,ACol,ARow,AReadOnly);
    };
    this.DoBeforeDrawCell = function (Sender, AGraphics, ARect, ATextRect, ADrawText, ADrawBackGround, ADrawBorder, AllowDraw) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoBeforeDrawGridCell(cell.Col,cell.Row,AGraphics,ARect,ATextRect,ADrawText,ADrawBackGround,ADrawBorder,AllowDraw);
      };
    };
    this.DoAfterDrawCell = function (Sender, AGraphics, ARect, ATextRect) {
      var cell = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cl = null;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Sender)) {
        cl = rtl.as(Sender,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        cell.$assign(this.GetCellByObject(cl));
        if ((cell.Row !== -1) && (cell.Col !== -1)) this.DoAfterDrawGridCell(cell.Col,cell.Row,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ATextRect));
      };
    };
    this.DoBeforeDrawGridCell = function (ACol, ARow, AGraphics, ARect, ATextRect, ADrawText, ADrawBackGround, ADrawBorder, AllowDraw) {
      if (this.FOnCellBeforeDraw != null) this.FOnCellBeforeDraw(this,ACol,ARow,AGraphics,ARect,ATextRect,ADrawText,ADrawBackGround,ADrawBorder,AllowDraw);
    };
    this.DoAfterDrawGridCell = function (ACol, ARow, AGraphics, ARect, ATextRect) {
      if (this.FOnCellAfterDraw != null) this.FOnCellAfterDraw(this,ACol,ARow,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ATextRect));
    };
    this.DisplayCellsAlternate = function (x, y, xOrig, yOrig, CStart, CStop, RStart, RStop, Ci, Ri, ResetCi, Fixed) {
      var cw = 0.0;
      var rh = 0.0;
      var cwr = 0.0;
      var rhr = 0.0;
      var cwrt = 0.0;
      var rhrt = 0.0;
      var xr = 0.0;
      var yr = 0.0;
      var cell = null;
      var c = 0;
      var r = 0;
      var bc = 0;
      var br = 0;
      var cs = 0;
      var rs = 0;
      var cellclasstype = null;
      var cellr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cellstr = "";
      var I = 0;
      var l = null;
      var a = 0;
      l = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      for (var $l = RStart, $end = RStop; $l <= $end; $l++) {
        r = $l;
        rh = this.GetRowHeights(r);
        if (this.FAdapter != null) this.FAdapter.StartBuild(r);
        for (var $l1 = CStart, $end1 = CStop; $l1 <= $end1; $l1++) {
          c = $l1;
          bc = c;
          br = r;
          cs = 0;
          rs = 0;
          cw = this.GetColWidths(c);
          this.DoGetCellMergeInfo(c,r,{get: function () {
              return bc;
            }, set: function (v) {
              bc = v;
            }},{get: function () {
              return br;
            }, set: function (v) {
              br = v;
            }},{get: function () {
              return cs;
            }, set: function (v) {
              cs = v;
            }},{get: function () {
              return rs;
            }, set: function (v) {
              rs = v;
            }});
          cellclasstype = null;
          this.DoGetCellClass(bc,br,{get: function () {
              return cellclasstype;
            }, set: function (v) {
              cellclasstype = v;
            }});
          cell = null;
          if (rtl.length(this.FCellArray) > Ci) if (rtl.length(this.FCellArray[Ci]) > Ri) {
            cell = this.FCellArray[Ci][Ri];
          };
          if (cell != null) {
            if (cell.$class.ClassType() !== cellclasstype) {
              cell = rtl.freeLoc(cell);
              cell = null;
              this.FCellArray[Ci][Ri] = null;
            };
          };
          cwr = cw;
          rhr = rh;
          cwrt = 0;
          for (var $l2 = bc, $end2 = (bc + cs) - 1; $l2 <= $end2; $l2++) {
            I = $l2;
            cwrt = cwrt + this.GetColWidths(I);
          };
          if (cwrt > 0) cwr = cwrt;
          rhrt = 0;
          for (var $l3 = br, $end3 = (br + rs) - 1; $l3 <= $end3; $l3++) {
            I = $l3;
            rhrt = rhrt + this.GetRowHeights(I);
          };
          if (rhrt > 0) rhr = rhrt;
          xr = 0;
          for (var $l4 = bc, $end4 = c - 1; $l4 <= $end4; $l4++) {
            I = $l4;
            xr = xr + this.GetColWidths(I);
          };
          yr = 0;
          for (var $l5 = br, $end5 = r - 1; $l5 <= $end5; $l5++) {
            I = $l5;
            yr = yr + this.GetRowHeights(I);
          };
          cellr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x - xr,y - yr,(x - xr) + cwr + 1,(y - yr) + rhr + 1));
          if (!(cell != null)) {
            cell = cellclasstype.$create("Create$1",[this]);
            if (rtl.length(this.FCellArray) <= Ci) this.FCellArray = rtl.arraySetLength(this.FCellArray,[],Ci + 1);
            if (rtl.length(this.FCellArray[Ci]) <= Ri) this.FCellArray[Ci] = rtl.arraySetLength(this.FCellArray[Ci],null,Ri + 1);
          };
          if (cell != null) {
            cell.FScaleFactor = this.FPaintScaleFactor;
            this.FCellArray[bc][br] = cell;
            cellstr = "";
            this.DoGetCellData(bc,br,{get: function () {
                return cellstr;
              }, set: function (v) {
                cellstr = v;
              }});
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
              a = 0;
              this.DoGetCellRotation(bc,br,{get: function () {
                  return a;
                }, set: function (v) {
                  a = v;
                }});
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetAngle(a);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOnBeforeDraw = rtl.createCallback(this,"DoBeforeDrawCell");
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOnAfterDraw = rtl.createCallback(this,"DoAfterDrawCell");
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetLayout(null);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetText(cellstr);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetDisplayHTMLFormatting(this.FOptions.FCell.FDisplayHTMLFormatting);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FBitmapContainer = this.GetBitmapContainer();
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
            };
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell.isPrototypeOf(cell)) {
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetFormat(this.FAppearance.FProgressLayout.FFormat);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetTextColor(this.FAppearance.FProgressLayout.FTextColor);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetColor(this.FAppearance.FProgressLayout.FColor);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetShowText(this.FAppearance.FProgressLayout.FShowText);
            };
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).FOnControlClick = rtl.createCallback(this,"DoNodeClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell).FOnControlClick = rtl.createCallback(this,"DoCommentClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell).FOnControlClick = rtl.createCallback(this,"DoBitmapClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FOnControlClick = rtl.createCallback(this,"DoFixedDropDownButtonClick");
            cell.SetLeft(cellr.Left);
            cell.SetTop(cellr.Top);
            cell.SetWidth(cellr.Right - cellr.Left);
            cell.SetHeight(cellr.Bottom - cellr.Top);
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = rtl.createCallback(this,"DoCheckBoxClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).FOnControlClick = rtl.createCallback(this,"DoButtonClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged = rtl.createCallback(this,"DoRadioButtonClick");
            this.ApplyCellState(bc,br,cell);
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
              l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
              this.DoGetCellLayout(bc,br,l,this.GetCellState(bc,br));
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
            };
            this.DoGetCellProperties(bc,br,cell);
          };
          x = x + cw;
          Ci += 1;
        };
        x = xOrig;
        y = y + rh;
        Ri += 1;
        Ci = CStart;
      };
      l = rtl.freeLoc(l);
    };
    this.DisplayCellsNormal = function (x, y, xOrig, yOrig, CStart, CStop, RStart, RStop, Ci, Ri, ResetCi, Fixed) {
      var cw = 0.0;
      var rh = 0.0;
      var cwr = 0.0;
      var rhr = 0.0;
      var cwrt = 0.0;
      var rhrt = 0.0;
      var xr = 0.0;
      var yr = 0.0;
      var cell = null;
      var c = 0;
      var r = 0;
      var bc = 0;
      var br = 0;
      var cs = 0;
      var rs = 0;
      var cellclasstype = null;
      var cellr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cellstr = "";
      var I = 0;
      var l = null;
      var a = 0;
      l = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      for (var $l = CStart, $end = CStop; $l <= $end; $l++) {
        c = $l;
        cw = this.GetColWidths(c);
        for (var $l1 = RStart, $end1 = RStop; $l1 <= $end1; $l1++) {
          r = $l1;
          if (this.FAdapter != null) this.FAdapter.StartBuild(r);
          bc = c;
          br = r;
          cs = 0;
          rs = 0;
          rh = this.GetRowHeights(r);
          this.DoGetCellMergeInfo(c,r,{get: function () {
              return bc;
            }, set: function (v) {
              bc = v;
            }},{get: function () {
              return br;
            }, set: function (v) {
              br = v;
            }},{get: function () {
              return cs;
            }, set: function (v) {
              cs = v;
            }},{get: function () {
              return rs;
            }, set: function (v) {
              rs = v;
            }});
          cellclasstype = null;
          this.DoGetCellClass(bc,br,{get: function () {
              return cellclasstype;
            }, set: function (v) {
              cellclasstype = v;
            }});
          cell = null;
          if (rtl.length(this.FCellArray) > Ci) if (rtl.length(this.FCellArray[Ci]) > Ri) {
            cell = this.FCellArray[Ci][Ri];
          };
          if (cell != null) {
            if (cell.$class.ClassType() !== cellclasstype) {
              cell = rtl.freeLoc(cell);
              cell = null;
              this.FCellArray[Ci][Ri] = null;
            };
          };
          cwr = cw;
          rhr = rh;
          cwrt = 0;
          for (var $l2 = bc, $end2 = (bc + cs) - 1; $l2 <= $end2; $l2++) {
            I = $l2;
            cwrt = cwrt + this.GetColWidths(I);
          };
          if (cwrt > 0) cwr = cwrt;
          rhrt = 0;
          for (var $l3 = br, $end3 = (br + rs) - 1; $l3 <= $end3; $l3++) {
            I = $l3;
            rhrt = rhrt + this.GetRowHeights(I);
          };
          if (rhrt > 0) rhr = rhrt;
          xr = 0;
          for (var $l4 = bc, $end4 = c - 1; $l4 <= $end4; $l4++) {
            I = $l4;
            xr = xr + this.GetColWidths(I);
          };
          yr = 0;
          for (var $l5 = br, $end5 = r - 1; $l5 <= $end5; $l5++) {
            I = $l5;
            yr = yr + this.GetRowHeights(I);
          };
          cellr.$assign(pas["WEBLib.TMSFNCTypes"].RectF(x - xr,y - yr,(x - xr) + cwr + 1,(y - yr) + rhr + 1));
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(cellr,this.GetContentRect().Left,this.GetContentRect().Top);
          if (!(cell != null)) {
            cell = cellclasstype.$create("Create$1",[this]);
            if (rtl.length(this.FCellArray) <= Ci) this.FCellArray = rtl.arraySetLength(this.FCellArray,[],Ci + 1);
            if (rtl.length(this.FCellArray[Ci]) <= Ri) this.FCellArray[Ci] = rtl.arraySetLength(this.FCellArray[Ci],null,Ri + 1);
          };
          if (cell != null) {
            a = 0;
            this.DoGetCellRotation(bc,br,{get: function () {
                return a;
              }, set: function (v) {
                a = v;
              }});
            rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetAngle(a);
            cell.FScaleFactor = this.FPaintScaleFactor;
            this.FCellArray[Ci][Ri] = cell;
            cellstr = "";
            this.DoGetCellData(bc,br,{get: function () {
                return cellstr;
              }, set: function (v) {
                cellstr = v;
              }});
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOnBeforeDraw = rtl.createCallback(this,"DoBeforeDrawCell");
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOnAfterDraw = rtl.createCallback(this,"DoAfterDrawCell");
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetLayout(null);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetText(cellstr);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).SetDisplayHTMLFormatting(this.FOptions.FCell.FDisplayHTMLFormatting);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FBitmapContainer = this.GetBitmapContainer();
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FOptimizedHTMLDrawing = this.FOptimizedHTMLDrawing;
            };
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell.isPrototypeOf(cell)) {
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetFormat(this.FAppearance.FProgressLayout.FFormat);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetTextColor(this.FAppearance.FProgressLayout.FTextColor);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetColor(this.FAppearance.FProgressLayout.FColor);
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCProgressGridCell).SetShowText(this.FAppearance.FProgressLayout.FShowText);
            };
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).FOnControlClick = rtl.createCallback(this,"DoNodeClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCommentGridCell).FOnControlClick = rtl.createCallback(this,"DoCommentClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCBitmapGridCell).FOnControlClick = rtl.createCallback(this,"DoBitmapClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell).FOnControlClick = rtl.createCallback(this,"DoFixedDropDownButtonClick");
            cell.SetLeft(cellr.Left);
            cell.SetTop(cellr.Top);
            cell.SetWidth(cellr.Right - cellr.Left);
            cell.SetHeight(cellr.Bottom - cellr.Top);
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FOnCheckChanged = rtl.createCallback(this,"DoCheckBoxClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).FOnControlClick = rtl.createCallback(this,"DoButtonClick");
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FOnCheckChanged = rtl.createCallback(this,"DoRadioButtonClick");
            this.ApplyCellState(bc,br,cell);
            if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
              l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
              this.DoGetCellLayout(bc,br,l,this.GetCellState(bc,br));
              rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
            };
            this.DoGetCellProperties(bc,br,cell);
          };
          y = y + rh;
          Ri += 1;
        };
        y = yOrig;
        x = x + cw;
        Ci += 1;
        Ri = ResetCi;
      };
      l = rtl.freeLoc(l);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.Create$1.apply(this,arguments);
      this.UpdateScrollingMode(pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling);
      this.ChangeCursor = true;
      this.FLeftC = 0;
      this.FTopr = 0;
      this.FFreezeRows = 0;
      this.FFreezeColumns = 0;
      this.FToolBarPopupMode = $mod.TTMSFNCGridCustomToolBarPopupMode.tpmActiveCell;
      this.FFreeEditControlTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FFreeEditControlTimer.SetInterval(1);
      this.FFreeEditControlTimer.SetEnabled(false);
      this.FFreeEditControlTimer.FOnTimer = rtl.createCallback(this,"DoFreeEditControl");
      this.FAnimateTimer$1 = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FAnimateTimer$1.SetInterval(1);
      this.FAnimateTimer$1.SetEnabled(false);
      this.FAnimateTimer$1.FOnTimer = rtl.createCallback(this,"Animate$1");
      this.FScrollTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FScrollTimer.FOnTimer = rtl.createCallback(this,"ScrollTimer");
      this.FScrollTimer.SetInterval(this.FOptions.FMouse.FAutoScrollingInterval);
      this.FScrollTimer.SetEnabled(false);
      this.FDragTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FDragTimer.FOnTimer = rtl.createCallback(this,"DragTimer");
      this.FDragTimer.SetInterval(this.FOptions.FMouse.FAutoScrollingInterval);
      this.FDragTimer.SetEnabled(false);
      this.FActiveCommentTextColor = 0;
      this.FActiveComment = "";
      this.FFilterListBox = pas["WEBLib.StdCtrls"].TListBox.$create("Create$1",[this]);
      this.FFilterListBox.FTag$1 = -1;
      this.FFilterListBox.FOnClick = rtl.createCallback(this,"HandleFilterListClick");
      this.FFilterTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FFilterTimer.FOnTimer = rtl.createCallback(this,"HandleFilterTimer");
      this.FFilterTimer.SetInterval(100);
      this.FFilterTimer.SetEnabled(false);
      this.FCommentPopup = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FCommentPopup.SetPlacement(pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppAbsolute);
      this.FCommentPopup.FOnPopupPaint = rtl.createCallback(this,"DoPaintCommentPopup");
      this.FFilterPopup = pas["WEBLib.TMSFNCPopup"].TTMSFNCPopup.$create("Create$1",[this]);
      this.FFilterPopup.SetPlacement(pas["WEBLib.TMSFNCPopup"].TTMSFNCPopupPlacement.ppAbsolute);
      this.FAppearance = $mod.TTMSFNCGridAppearance.$create("Create$1");
      this.FAppearance.FOnChange = rtl.createCallback(this,"AppearanceChanged");
      this.SetWidth(370);
      this.SetHeight(270);
      if (this.IsDesignTime()) this.InitSample();
      this.FDesignTimeSampleData = true;
      return this;
    };
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FDragTimer;
        }, set: function (v) {
          this.p.FDragTimer = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFilterTimer;
        }, set: function (v) {
          this.p.FFilterTimer = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FScrollTimer;
        }, set: function (v) {
          this.p.FScrollTimer = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FAnimateTimer$1;
        }, set: function (v) {
          this.p.FAnimateTimer$1 = v;
        }});
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FFreeEditControlTimer;
        }, set: function (v) {
          this.p.FFreeEditControlTimer = v;
        }});
      this.RemoveAllCells();
      if (this.FDummyButtonBitmap != null) rtl.free(this,"FDummyButtonBitmap");
      if (this.FNodeOpenBitmap != null) rtl.free(this,"FNodeOpenBitmap");
      if (this.FNodeClosedBitmap != null) rtl.free(this,"FNodeClosedBitmap");
      if (this.FCellMemo != null) rtl.free(this,"FCellMemo");
      if (this.FCellEdit != null) rtl.free(this,"FCellEdit");
      if (this.FCellColorPicker != null) rtl.free(this,"FCellColorPicker");
      if (this.FCellSpinBox != null) rtl.free(this,"FCellSpinBox");
      if (this.FCellComboBox != null) rtl.free(this,"FCellComboBox");
      if (this.FCellDatePicker != null) rtl.free(this,"FCellDatePicker");
      if (this.FCellTrackBar != null) rtl.free(this,"FCellTrackBar");
      rtl.free(this,"FFilterListBox");
      rtl.free(this,"FCommentPopup");
      rtl.free(this,"FFilterPopup");
      rtl.free(this,"FAppearance");
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.Destroy.call(this);
    };
    this.VisibleRowCount = function () {
      var Result = 0;
      Result = (this.FRStop - this.FRStart) + this.FFixedFooterRows + this.GetFixedRows() + 1;
      return Result;
    };
    this.VisibleColumnCount = function () {
      var Result = 0;
      Result = (this.FCStop - this.FCStart) + this.FFixedRightColumns + this.GetFixedCols() + 1;
      return Result;
    };
    this.GetDisplayCell = function (ACell) {
      var Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var maxc = 0;
      var maxr = 0;
      maxc = rtl.length(this.FCellArray) - 1;
      if (ACell.Col > (this.GetColumnCount() - 1 - this.FFixedRightColumns)) {
        Result.Col = ((this.FCStop - this.FCStart) + this.FFixedRightColumns + this.FFixedColumns) - (this.GetColumnCount() - ACell.Col - 1)}
       else if (ACell.Col >= this.GetFixedCols()) {
        Result.Col = (ACell.Col - this.FCStart) + this.GetFixedCols()}
       else Result.Col = ACell.Col;
      Result.Col = Math.max(0,Math.min(Result.Col,maxc));
      maxr = 0;
      if ((Result.Col >= 0) && (Result.Col <= maxc)) {
        maxr = rtl.length(this.FCellArray[Result.Col]) - 1;
        if (ACell.Row > (this.GetRowCount() - 1 - this.FFixedRightColumns)) {
          Result.Row = ((this.FRStop - this.FRStart) + this.FFixedFooterRows + this.FFixedRows) - (this.GetRowCount() - ACell.Row - 1)}
         else if (ACell.Row >= this.GetFixedRows()) {
          Result.Row = (ACell.Row - this.FRStart) + this.GetFixedRows()}
         else Result.Row = ACell.Row;
      };
      Result.Row = Math.max(0,Math.min(Result.Row,maxr));
      return Result;
    };
    this.GetRealCell = function (ACell) {
      var Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      if (ACell.Col > (rtl.length(this.FCellArray) - 1 - this.FFixedRightColumns)) {
        Result.Col = this.GetColumnCount() - 1 - (rtl.length(this.FCellArray) - 1 - ACell.Col)}
       else if (ACell.Col >= this.GetFixedCols()) {
        Result.Col = (ACell.Col + this.FCStart) - this.GetFixedCols()}
       else Result.Col = ACell.Col;
      if ((ACell.Col >= 0) && (ACell.Col <= (rtl.length(this.FCellArray) - 1))) {
        if (ACell.Row > (rtl.length(this.FCellArray[ACell.Col]) - 1 - this.FFixedRightColumns)) {
          Result.Row = this.GetRowCount() - 1 - (rtl.length(this.FCellArray[ACell.Col]) - 1 - ACell.Row)}
         else if (ACell.Row >= this.GetFixedRows()) {
          Result.Row = (ACell.Row + this.FRStart) - this.GetFixedRows()}
         else Result.Row = ACell.Row;
      };
      return Result;
    };
    this.GetCellObject = function (ACell) {
      var Result = null;
      Result = null;
      if ((ACell.Col >= 0) && (ACell.Col <= (rtl.length(this.FCellArray) - 1))) if ((ACell.Row >= 0) && (ACell.Row <= (rtl.length(this.FCellArray[ACell.Col]) - 1))) Result = this.FCellArray[ACell.Col][ACell.Row];
      return Result;
    };
    this.GetCell = function (ACell) {
      var Result = null;
      ACell.$assign(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(ACell)));
      Result = null;
      if ((ACell.Col >= 0) && (ACell.Col <= (rtl.length(this.FCellArray) - 1))) if ((ACell.Row >= 0) && (ACell.Row <= (rtl.length(this.FCellArray[ACell.Col]) - 1))) Result = this.FCellArray[ACell.Col][ACell.Row];
      return Result;
    };
    this.GetCellByObject = function (Cell) {
      var Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var c = 0;
      var r = 0;
      Result.Col = -1;
      Result.Row = -1;
      for (var $l = 0, $end = rtl.length(this.FCellArray) - 1; $l <= $end; $l++) {
        c = $l;
        for (var $l1 = 0, $end1 = rtl.length(this.FCellArray[c]) - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (this.FCellArray[c][r] === Cell) {
            Result.Col = c;
            Result.Row = r;
            Result.$assign(this.GetRealCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(Result)));
            return Result;
          };
        };
      };
      return Result;
    };
    this.GetDisplayCellByObject = function (Cell) {
      var Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var c = 0;
      var r = 0;
      Result.Col = -1;
      Result.Row = -1;
      for (var $l = 0, $end = rtl.length(this.FCellArray) - 1; $l <= $end; $l++) {
        c = $l;
        for (var $l1 = 0, $end1 = rtl.length(this.FCellArray[c]) - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (this.FCellArray[c][r] === Cell) {
            Result.Col = c;
            Result.Row = r;
            return Result;
          };
        };
      };
      return Result;
    };
    this.GetTotalColumnWidth = function () {
      var Result = 0.0;
      var I = 0;
      Result = (this.GetColumnCount() - Math.min(this.GetColumnCount(),this.FColumnW.GetCount())) * this.FDefaultColumnWidth;
      for (var $l = 0, $end = Math.min(this.GetColumnCount() - 1,this.FColumnW.GetCount() - 1); $l <= $end; $l++) {
        I = $l;
        Result = Result + this.FColumnW.GetItem$1(I).FValue;
      };
      return Result;
    };
    this.GetTotalRowHeight = function () {
      var Result = 0.0;
      var I = 0;
      Result = (this.GetRowCount() - Math.min(this.GetRowCount(),this.FRowH.GetCount())) * this.FDefaultRowHeight;
      for (var $l = 0, $end = Math.min(this.GetRowCount() - 1,this.FRowH.GetCount() - 1); $l <= $end; $l++) {
        I = $l;
        Result = Result + this.FRowH.GetItem$1(I).FValue;
      };
      return Result;
    };
    this.GetTotalContentWidth = function () {
      var Result = 0.0;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.GetTotalContentWidth.call(this);
      Result = this.FContainerWidth;
      return Result;
    };
    this.GetTotalContentHeight = function () {
      var Result = 0.0;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.GetTotalContentHeight.call(this);
      Result = this.FContainerHeight;
      return Result;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.EndUpdate.call(this);
      if (this.FDragTimer != null) this.FDragTimer.SetInterval(this.FOptions.FMouse.FAutoScrollingInterval);
      if (this.FScrollTimer != null) this.FScrollTimer.SetInterval(this.FOptions.FMouse.FAutoScrollingInterval);
    };
    this.RemoveAllCells = function () {
      var c = 0;
      var r = 0;
      for (var $l = 0, $end = rtl.length(this.FCellArray) - 1; $l <= $end; $l++) {
        c = $l;
        for (var $l1 = 0, $end1 = rtl.length(this.FCellArray[c]) - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (this.FCellArray[c][r] != null) {
            rtl.free(this.FCellArray[c],r);
            this.FCellArray[c][r] = null;
          };
        };
      };
      this.FCellArray = rtl.arraySetLength(this.FCellArray,[],0);
    };
    this.ClearSelection = function () {
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      cl.Col = -1;
      cl.Row = -1;
      this.FStartCell.$assign(cl);
      this.FStopCell.$assign(cl);
      this.FFocusedCell.$assign(cl);
      this.FPrevSelectedCell.$assign(this.GetFocusedCell());
      this.FSaveCell.$assign(this.GetFocusedCell());
      this.FFirstCell.Col = -1;
      this.FFirstCell.Row = -1;
      this.FRealCell.$assign(this.GetFocusedCell());
      this.FPrevSelection.$assign(this.GetSelection());
      this.UpdateGridCells(false);
    };
    this.ExportNotification = function (AState, ARow) {
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.ExportNotification.apply(this,arguments);
      if (this.FAdapter != null) this.FAdapter.ExportNotification(AState,ARow);
    };
    this.ApplyCellState = function (ACol, ARow, Cell) {
      var cl = null;
      var ctl = null;
      var idx = 0;
      if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(Cell)) {
        cl = rtl.as(Cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell);
        if (cl != null) {
          if ((this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone) && (this.GetFocusedCell().Row === ARow) && (this.GetFocusedCell().Col === ACol) && this.IsFocused()) {
            cl.AssignLayout(this.GetCellAppearance(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFocused,ACol,ARow))}
           else {
            if (this.IsFixed(ACol,ARow)) {
              if ((this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone) && this.FOptions.FSelection.FShowSelectionInFixedCells && this.DoIsFixedCellSelected(ACol,ARow) && !this.IsNormalFixed(ACol,ARow)) {
                cl.AssignLayout(this.GetCellAppearance(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFixedSelected,ACol,ARow))}
               else cl.AssignLayout(this.GetCellAppearance(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFixed,ACol,ARow));
            } else if ((this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone) && this.DoIsCellSelected(ACol,ARow)) {
              cl.AssignLayout(this.GetCellAppearance(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csSelected,ACol,ARow))}
             else cl.AssignLayout(this.GetCellAppearance(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csNormal,ACol,ARow));
          };
          if (this.IsFixed(ACol,ARow)) {
            var $tmp = this.FOptions.FBorders.FFixedCellBorders;
            if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridBorders.bNone) {
              cl.FLayout.SetSides({})}
             else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridBorders.bVertical) {
              cl.FLayout.SetSides(rtl.diffSet(cl.FLayout.FSides,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom)))}
             else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridBorders.bHorizontal) cl.FLayout.SetSides(rtl.diffSet(cl.FLayout.FSides,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight)));
          } else {
            var $tmp1 = this.FOptions.FBorders.FCellBorders;
            if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridBorders.bNone) {
              cl.FLayout.SetSides({})}
             else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridBorders.bVertical) {
              cl.FLayout.SetSides(rtl.diffSet(cl.FLayout.FSides,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsTop,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsBottom)))}
             else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridBorders.bHorizontal) cl.FLayout.SetSides(rtl.diffSet(cl.FLayout.FSides,rtl.createSet(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsLeft,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsSide.gsRight)));
          };
          if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell.isPrototypeOf(cl) && (ARow === this.FOptions.FSorting.FRow)) {
            ctl = rtl.as(cl,pas["WEBLib.TMSFNCGridCell"].TTMSFNCFixedGridCell);
            ctl.FSortIndex = -1;
            ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone;
            var $tmp2 = this.FOptions.FSorting.FMode;
            if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmNone) {
              ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skNone}
             else if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmNormal) {
              if (ACol === this.FSortColumn) {
                var $tmp3 = this.FSortDirection;
                if ($tmp3 === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdAscending) {
                  ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skAscending}
                 else if ($tmp3 === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridSortDirection.sdDescending) ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skDescending;
              };
            } else if ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSortingMode.gsmIndexed) {
              idx = this.FSortIndexes.FindIndex(ACol);
              if (idx !== -1) {
                ctl.FSortIndex = idx + 1;
                if (this.FSortIndexes.GetSortDirections(idx)) {
                  ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skAscending}
                 else ctl.FSortKind = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridSortKind.skDescending;
              };
            };
          };
        };
      };
    };
    this.GetCellState = function (ACol, ARow) {
      var Result = 0;
      if ((this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone) && (this.GetFocusedCell().Row === ARow) && (this.GetFocusedCell().Col === ACol)) {
        Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFocused}
       else {
        if (this.IsFixed(ACol,ARow)) {
          if ((this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone) && this.FOptions.FSelection.FShowSelectionInFixedCells && this.DoIsFixedCellSelected(ACol,ARow)) {
            Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFixedSelected}
           else Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csFixed;
        } else if ((this.FOptions.FSelection.FMode !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smNone) && this.DoIsCellSelected(ACol,ARow)) {
          Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csSelected}
         else Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellState.csNormal;
      };
      return Result;
    };
    this.XYToCell = function (X, Y) {
      var Result = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var I = 0;
      var val = 0.0;
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.Row = -1;
      Result.Col = -1;
      if ((this.GetRowCount() === 0) || (this.GetColumnCount() === 0)) return Result;
      contentr.$assign(this.GetContentRect());
      if (!pas["WEBLib.TMSFNCTypes"].PtInRectEx(contentr,pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) return Result;
      if (Y < this.GetFixedHeight()) {
        val = 0;
        for (var $l = 0, $end = this.GetFixedRows(); $l <= $end; $l++) {
          I = $l;
          val = val + this.GetRowHeights(I);
          if (val >= Y) {
            Result.Row = I;
            break;
          };
        };
      } else if (Y > (contentr.Bottom - contentr.Top - this.GetFixedFooterHeight())) {
        val = contentr.Bottom - contentr.Top;
        for (var $l1 = this.GetRowCount() - 1, $end1 = this.GetRowCount() - 1 - this.FFixedFooterRows; $l1 >= $end1; $l1--) {
          I = $l1;
          val = val - this.GetRowHeights(I);
          if (val <= Y) {
            Result.Row = I;
            break;
          };
        };
      } else {
        val = this.GetCellContainerPosY();
        for (var $l2 = 0, $end2 = this.FRStop; $l2 <= $end2; $l2++) {
          I = $l2;
          val = val + this.GetRowHeights(I);
          if (val >= Y) {
            Result.Row = I;
            break;
          };
        };
      };
      if (X < this.GetFixedWidth()) {
        val = 0;
        for (var $l3 = 0, $end3 = this.GetFixedCols(); $l3 <= $end3; $l3++) {
          I = $l3;
          val = val + this.GetColWidths(I);
          if (val >= X) {
            Result.Col = I;
            break;
          };
        };
      } else if (X > (contentr.Right - contentr.Left - this.GetFixedRightWidth())) {
        val = contentr.Right - contentr.Left;
        for (var $l4 = this.GetColumnCount() - 1, $end4 = this.GetColumnCount() - 1 - this.FFixedRightColumns; $l4 >= $end4; $l4--) {
          I = $l4;
          val = val - this.GetColWidths(I);
          if (val <= X) {
            Result.Col = I;
            break;
          };
        };
      } else {
        val = this.GetCellContainerPosX();
        for (var $l5 = 0, $end5 = this.FCStop; $l5 <= $end5; $l5++) {
          I = $l5;
          val = val + this.GetColWidths(I);
          if (val >= X) {
            Result.Col = I;
            break;
          };
        };
      };
      return Result;
    };
    this.GetFixedCols = function () {
      var Result = 0;
      Result = this.FFixedColumns + this.FFreezeColumns;
      return Result;
    };
    this.GetFixedRows = function () {
      var Result = 0;
      Result = this.FFixedRows + this.FFreezeRows;
      return Result;
    };
    this.GetFixedWidth = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = 0, $end = (this.FFixedColumns + this.FFreezeColumns) - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + this.GetColWidths(I);
      };
      return Result;
    };
    this.GetFixedOnlyHeight = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = 0, $end = this.FFixedRows - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + this.GetRowHeights(I);
      };
      return Result;
    };
    this.GetFixedOnlyWidth = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = 0, $end = this.FFixedColumns - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + this.GetColWidths(I);
      };
      return Result;
    };
    this.GetFixedHeight = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = 0, $end = (this.FFixedRows + this.FFreezeRows) - 1; $l <= $end; $l++) {
        I = $l;
        Result = Result + this.GetRowHeights(I);
      };
      return Result;
    };
    this.GetFixedRightWidth = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = this.GetColumnCount() - 1, $end = this.GetColumnCount() - this.FFixedRightColumns; $l >= $end; $l--) {
        I = $l;
        Result = Result + this.GetColWidths(I);
      };
      return Result;
    };
    this.GetFixedFooterHeight = function () {
      var Result = 0.0;
      var I = 0;
      Result = 0;
      for (var $l = this.GetRowCount() - 1, $end = this.GetRowCount() - this.FFixedFooterRows; $l >= $end; $l--) {
        I = $l;
        Result = Result + this.GetRowHeights(I);
      };
      return Result;
    };
    this.GetCellContainerPosX = function () {
      var Result = 0;
      Result = this.FCellPosX;
      return Result;
    };
    this.GetCellContainerPosY = function () {
      var Result = 0;
      Result = this.FCellPosY;
      return Result;
    };
    this.ColumnStretchingActive = function () {
      var Result = false;
      Result = this.FOptions.FColumnSize.FStretch && this.FOptions.FColumnSize.FStretchAll;
      return Result;
    };
    this.DrawContent = function (AGraphics, ARect) {
      var cfs = 0;
      var rfs = 0;
      var cfst = 0;
      var rfst = 0;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.DrawContent.apply(this,arguments);
      AGraphics.FBitmapContainer = this.GetBitmapContainer();
      cfs = this.GetFixedCols();
      rfs = this.GetFixedRows();
      cfst = this.FFixedRightColumns;
      rfst = this.FFixedFooterRows;
      if ((this.GetColumnCount() > this.FFixedColumns) && (this.GetRowCount() > this.FFixedRows)) this.PaintCells(AGraphics,this.FCStart,this.FCStop,this.FRStart,this.FRStop,cfs,rfs,rfs);
      if (this.GetRowCount() > this.FFixedRows) this.PaintCells(AGraphics,0,cfs - 1,this.FRStart,this.FRStop,0,rfs,rfs);
      if (this.GetColumnCount() > this.FFixedColumns) this.PaintCells(AGraphics,this.FCStart,this.FCStop,0,rfs - 1,cfs,0,0);
      this.PaintCells(AGraphics,0,cfs - 1,0,rfs - 1,0,0,0);
      if ((this.GetColumnCount() > (this.FFixedColumns + this.FFixedRightColumns)) && (this.GetRowCount() > this.FFixedRows)) {
        this.PaintCells(AGraphics,this.GetColumnCount() - cfst,this.GetColumnCount() - 1,this.FRStart,this.FRStop,(this.FCStop - this.FCStart) + cfs + 1,rfs,rfs);
        this.PaintCells(AGraphics,this.GetColumnCount() - cfst,this.GetColumnCount() - 1,0,rfs - 1,(this.FCStop - this.FCStart) + cfs + 1,0,0);
      };
      if ((this.GetColumnCount() > this.FFixedColumns) && (this.GetRowCount() > (this.FFixedRows + this.FFixedFooterRows))) this.PaintCells(AGraphics,this.FCStart,this.FCStop,this.GetRowCount() - rfst,this.GetRowCount() - 1,cfs,(this.FRStop - this.FRStart) + rfs + 1,(this.FRStop - this.FRStart) + rfs + 1);
      if ((this.GetColumnCount() > (this.FFixedColumns + this.FFixedRightColumns)) && (this.GetRowCount() > (this.FFixedRows + this.FFixedFooterRows))) this.PaintCells(AGraphics,this.GetColumnCount() - cfst,this.GetColumnCount() - 1,this.GetRowCount() - rfst,this.GetRowCount() - 1,(this.FCStop - this.FCStart) + cfs + 1,(this.FRStop - this.FRStart) + rfs + 1,(this.FRStop - this.FRStart) + rfs + 1);
      if (this.GetRowCount() > this.FFixedRows) this.PaintCells(AGraphics,0,cfs - 1,this.GetRowCount() - rfst,this.GetRowCount() - 1,0,(this.FRStop - this.FRStart) + rfs + 1,(this.FRStop - this.FRStart) + rfs + 1);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        AGraphics.FFont.SetColor(255);
        AGraphics.FFont.SetStyle({});
        AGraphics.DrawText(pas["WEBLib.TMSFNCTypes"].TPointF.$clone(pas["WEBLib.TMSFNCTypes"].PointF(2,2)),"For new developments, please use TTMSFNCDataGrid",0,true,false,-1,-1);
      };
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCCustomGrid.isPrototypeOf(Source)) {
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCCustomGrid).FAppearance);
        this.FOptions.Assign(rtl.as(Source,$mod.TTMSFNCCustomGrid).FOptions);
        this.SetColumnCount(rtl.as(Source,$mod.TTMSFNCCustomGrid).GetColumnCount());
        this.SetRowCount(rtl.as(Source,$mod.TTMSFNCCustomGrid).GetRowCount());
        this.SetFixedColumns(rtl.as(Source,$mod.TTMSFNCCustomGrid).FFixedColumns);
        this.SetFixedRows(rtl.as(Source,$mod.TTMSFNCCustomGrid).FFixedRows);
        this.SetFixedRightColumns(rtl.as(Source,$mod.TTMSFNCCustomGrid).FFixedRightColumns);
        this.SetFixedFooterRows(rtl.as(Source,$mod.TTMSFNCCustomGrid).FFixedFooterRows);
        this.SetFreezeColumns(rtl.as(Source,$mod.TTMSFNCCustomGrid).FFreezeColumns);
        this.SetFreezeRows(rtl.as(Source,$mod.TTMSFNCCustomGrid).FFreezeRows);
        this.SetBitmapContainer(rtl.as(Source,$mod.TTMSFNCCustomGrid).GetBitmapContainer());
        this.SetEnabled(rtl.as(Source,$mod.TTMSFNCCustomGrid).FEnabled);
        this.SetDefaultColumnWidth(rtl.as(Source,$mod.TTMSFNCCustomGrid).FDefaultColumnWidth);
        this.SetDefaultRowHeight(rtl.as(Source,$mod.TTMSFNCCustomGrid).FDefaultRowHeight);
        this.SetLeftCol(rtl.as(Source,$mod.TTMSFNCCustomGrid).GetLeftCol());
        this.SetTopRow(rtl.as(Source,$mod.TTMSFNCCustomGrid).GetTopRow());
      };
    };
    this.EditCell = function (ACell, CellStart, InsertKey, Value, Key) {
      var $Self = this;
      function CreateCaretPos(ALine, APos) {
        var Result = pas.Types.TPoint.$new();
        Result.x = ALine;
        Result.y = APos;
        return Result;
      };
      var CellEditorClassType = null;
      var cellstring = "";
      var ctl = null;
      var realc = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var AReadOnly = false;
      var EditorType = 0;
      var c = 0;
      var dtc = false;
      var s = "";
      var ectl = null;
      var ioe = null;
      var fc = 0;
      var $ir = rtl.createIntfRefs();
      try {
        if (!this.FOptions.FEditing.FEnabled || this.IsFixed(ACell.Col,ACell.Row)) return;
        this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(ACell),false);
        AReadOnly = false;
        this.DoGetCellReadOnly(ACell.Col,ACell.Row,{get: function () {
            return AReadOnly;
          }, set: function (v) {
            AReadOnly = v;
          }});
        dtc = this.DoGetCellIsDataCheckBox(ACell.Col,ACell.Row);
        if (AReadOnly || dtc) return;
        if (this.FAdapter != null) this.FAdapter.CellBeforeEdit(ACell.Col,ACell.Row);
        realc.$assign(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(ACell)));
        ctl = null;
        if ((realc.Col >= 0) && (realc.Col <= (rtl.length(this.FCellArray) - 1))) {
          if ((realc.Row >= 0) && (realc.Row <= (rtl.length(this.FCellArray[realc.Col]) - 1))) ctl = this.FCellArray[realc.Col][realc.Row];
        };
        if ((ctl != null) && pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(ctl)) {
          EditorType = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etEdit;
          this.FEditControl = this.GetCellEdit();
          CellEditorClassType = $mod.TTMSFNCGridEdit;
          this.DoGetCellEditorType(ACell.Col,ACell.Row,{get: function () {
              return EditorType;
            }, set: function (v) {
              EditorType = v;
            }});
          if (EditorType === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etCustom) {
            this.DoGetCellEditorCustomClassType(ACell.Col,ACell.Row,{get: function () {
                return CellEditorClassType;
              }, set: function (v) {
                CellEditorClassType = v;
              }});
            if (CellEditorClassType !== null) {
              this.FEditControl = CellEditorClassType.$create("Create$1",[$Self]);
              this.FEditControl.SetShowFocus(false);
              this.FEditControl.FOnKeyDown = rtl.createCallback($Self,"CellControlKeyDown");
              this.FEditControl.FOnExit = rtl.createCallback($Self,"CellExit");
            };
          } else {
            var $tmp = EditorType;
            if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etMemo) {
              this.FEditControl = this.GetCellMemo()}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etSpinBox) {
              this.FEditControl = this.GetCellSpinBox()}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etColorPicker) {
              this.FEditControl = this.GetCellColorPicker()}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etComboBox) {
              this.FEditControl = this.GetCellComboBox()}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etDatePicker) {
              this.FEditControl = this.GetCellDatePicker()}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etTrackBar) {
              this.FEditControl = this.GetCellTrackBar()}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etString)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etNumericEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etNumeric)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etSignedNumericEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etSignedNumeric)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etFloatEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etFloat)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etSignedFloatEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etSignedFloat)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etUppercaseEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etUpperCase)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etMixedCaseEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etMixedCase)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etLowerCaseEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etLowerCase)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etMoneyEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etMoney)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etHexEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etHex)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etAlphaNumericEdit) {
              this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etAlphaNumeric)}
             else if ($tmp === pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etValidCharsEdit) this.GetCellEdit().SetEditType$1(pas["WEBLib.TMSFNCEdit"].TTMSFNCEditType.etValidChars);
            if ((EditorType in rtl.createSet(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etEdit)) && (this.FOptions.FEditing.FAutoComplete !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoComplete.acDisabled)) {
              this.GetCellEdit().FLookup.FDisplayList.Assign(this.FOptions.FEditing.FAutoCompleteItems);
              this.GetCellEdit().FAutoComplete = this.FOptions.FEditing.FAutoComplete === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoComplete.acNormal;
              this.GetCellEdit().FLookup.FEnabled = this.FOptions.FEditing.FAutoComplete !== pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridAutoComplete.acNormal;
            };
          };
          if (this.FEditControl != null) {
            if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,pas["WEBLib.StdCtrls"].TComboBox).SetParent($Self);
            this.DoGetCellEditorProperties(ACell.Col,ACell.Row,this.FEditControl);
            if (pas["WEBLib.StdCtrls"].TComboBox.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,pas["WEBLib.StdCtrls"].TComboBox).SetParent(null);
            cellstring = this.GetCells(ACell.Col,ACell.Row);
            if (!this.FOptions.FEditing.FEditWithTags && pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(cellstring)) cellstring = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(cellstring);
            c = this.GetColors(ACell.Col,ACell.Row);
            if ($mod.TTMSFNCGridColorPicker.isPrototypeOf(this.FEditControl)) {
              this.DoCellEditGetColor(ACell.Col,ACell.Row,this.FEditControl,{get: function () {
                  return c;
                }, set: function (v) {
                  c = v;
                }})}
             else this.DoCellEditGetData(ACell.Col,ACell.Row,this.FEditControl,{get: function () {
                return cellstring;
              }, set: function (v) {
                cellstring = v;
              }});
            if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(this.FEditControl,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCTypes"].ITMSFNCCustomEditor),{get: function () {
                return ioe;
              }, set: function (v) {
                ioe = v;
              }})) {
              if (InsertKey) ioe.SetText(Value);
            };
            if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl) || $mod.TTMSFNCGridMemo.isPrototypeOf(this.FEditControl)) {
              if (InsertKey) {
                if ($mod.TTMSFNCGridMemo.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetText("");
                if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetT("");
                if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl) && (EditorType in rtl.createSet(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etMoneyEdit,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etFloatEdit,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etSignedFloatEdit,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etNumericEdit))) {
                  this.FEditControl.SetParent($Self);
                  this.FEditControl.SelectAll();
                  this.FEditControl.SetParent(null);
                };
                s = Value;
                if ($mod.TTMSFNCGridMemo.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetText(s);
                if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetT(s);
              } else {
                if ($mod.TTMSFNCGridMemo.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetText(cellstring);
                if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetT(cellstring);
              };
            } else if ($mod.TTMSFNCGridTrackBar.isPrototypeOf(this.FEditControl)) {
              if (cellstring !== "") {
                rtl.as(this.FEditControl,$mod.TTMSFNCGridTrackBar).SetPosition(pas.SysUtils.StrToInt(cellstring))}
               else rtl.as(this.FEditControl,$mod.TTMSFNCGridTrackBar).SetPosition(0);
            } else if ($mod.TTMSFNCGridColorPicker.isPrototypeOf(this.FEditControl)) {
              rtl.as(this.FEditControl,$mod.TTMSFNCGridColorPicker).SetSelectedColor(c)}
             else if ($mod.TTMSFNCGridSpinBox.isPrototypeOf(this.FEditControl)) {
              rtl.as(this.FEditControl,$mod.TTMSFNCGridSpinBox).SetText(cellstring)}
             else if ($mod.TTMSFNCGridDatePicker.isPrototypeOf(this.FEditControl)) {
              rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).SetParent($Self);
              if (cellstring === "") {
                rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).SetDate(pas.System.Int(pas.SysUtils.Now()));
                rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).SetText(pas.SysUtils.DateToStr(pas.SysUtils.Now()));
              } else {
                rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).SetDate(pas["WEBLib.TMSFNCTypes"].VarToDateTime(cellstring));
                rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).SetText(cellstring);
              };
              rtl.as(this.FEditControl,$mod.TTMSFNCGridDatePicker).SetParent(null);
            } else if ($mod.TTMSFNCGridComboBox.isPrototypeOf(this.FEditControl)) {
              rtl.as(this.FEditControl,$mod.TTMSFNCGridComboBox).SetParent($Self);
              rtl.as(this.FEditControl,$mod.TTMSFNCGridComboBox).SetItemIndex(rtl.as(this.FEditControl,$mod.TTMSFNCGridComboBox).FItems.IndexOf(cellstring));
              rtl.as(this.FEditControl,$mod.TTMSFNCGridComboBox).SetParent(null);
            };
            ectl = this.FEditControl;
            if ($mod.TTMSFNCGridEdit.isPrototypeOf(ectl)) {
              fc = rtl.as(ectl,$mod.TTMSFNCGridEdit).FFont.FColor;
              rtl.as(ectl,$mod.TTMSFNCGridEdit).FFont.Assign(ctl.FLayout.FFont);
              rtl.as(ectl,$mod.TTMSFNCGridEdit).FFont.SetColor(fc);
              var $tmp1 = ctl.FLayout.FTextAlign;
              if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter) {
                rtl.as(ectl,$mod.TTMSFNCGridEdit).SetAlignment(pas.Classes.TAlignment.taCenter)}
               else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading) {
                rtl.as(ectl,$mod.TTMSFNCGridEdit).SetAlignment(pas.Classes.TAlignment.taLeftJustify)}
               else if ($tmp1 === pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaTrailing) rtl.as(ectl,$mod.TTMSFNCGridEdit).SetAlignment(pas.Classes.TAlignment.taRightJustify);
              r.$assign(ctl.GetTextRect(false));
            } else r.$assign(ctl.GetTextRect(false));
            ectl.SetBounds(Math.round(ctl.FLeft + r.Left),Math.round(ctl.FTop + r.Top),Math.round(r.Right - r.Left),Math.round(r.Bottom - r.Top));
            ectl.SetBounds(Math.round(ectl.GetLeft() + ((r.Right - r.Left - ectl.GetWidth()) / 2)),Math.round(ectl.GetTop() + ((r.Bottom - r.Top - ectl.GetHeight()) / 2)),ectl.GetWidth(),ectl.GetHeight());
            if ((pas["WEBLib.StdCtrls"].TCustomEdit.isPrototypeOf(ectl) || pas["WEBLib.StdCtrls"].TCustomMemo.isPrototypeOf(ectl)) && !$mod.TTMSFNCGridSpinBox.isPrototypeOf(ectl) && (ectl.GetHeight() > (r.Bottom - r.Top))) {
              ectl.SetTop(ectl.GetTop() + 4);
              ectl.SetHeight(ectl.GetHeight() - 8);
            };
            this.FEditControl.SetParent($Self);
            this.FEditControl.SetVisible(true);
            this.FEditControl.BringToFront();
            if (pas.SysUtils.Supports$1($ir.ref(2,rtl.queryIntfT(this.FEditControl,pas.System.IUnknown)),rtl.getIntfGUIDR(pas["WEBLib.TMSFNCTypes"].ITMSFNCCustomEditor),{get: function () {
                return ioe;
              }, set: function (v) {
                ioe = v;
              }})) {
              if (InsertKey) {
                ioe.SetSelStart(ioe.GetTextLength());
                ioe.SetSelLength(0);
              } else {
                var $tmp2 = CellStart;
                if ($tmp2 === $mod.TTMSFNCGridEditCellStart.csNone) {
                  ioe.SetSelStart(0);
                  ioe.SetSelLength(ioe.GetTextLength());
                } else if ($tmp2 === $mod.TTMSFNCGridEditCellStart.csStart) {
                  ioe.SetSelStart(0);
                  ioe.SetSelLength(0);
                } else if ($tmp2 === $mod.TTMSFNCGridEditCellStart.csEnd) {
                  ioe.SetSelStart(ioe.GetTextLength());
                  ioe.SetSelLength(0);
                };
              };
            };
            if ($mod.TTMSFNCGridEdit.isPrototypeOf(this.FEditControl)) {
              try {
                if (InsertKey) {
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelStart(rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).GetT().length);
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelLength(0);
                } else {
                  var $tmp3 = CellStart;
                  if ($tmp3 === $mod.TTMSFNCGridEditCellStart.csNone) {
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelStart(0);
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelLength(rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).GetT().length);
                  } else if ($tmp3 === $mod.TTMSFNCGridEditCellStart.csStart) {
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelStart(0);
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelLength(0);
                  } else if ($tmp3 === $mod.TTMSFNCGridEditCellStart.csEnd) {
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelStart(rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).GetT().length);
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridEdit).SetSelLength(0);
                  };
                };
              } finally {
              };
            };
            if ($mod.TTMSFNCGridMemo.isPrototypeOf(this.FEditControl)) {
              if (InsertKey) {
                if (rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() > 0) {
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FCaretPosition.$assign(CreateCaretPos(rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() - 1,rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.Get(rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() - 1).length))}
                 else rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FCaretPosition.$assign(CreateCaretPos(0,0));
                rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetSelLength(0);
              } else {
                var $tmp4 = CellStart;
                if ($tmp4 === $mod.TTMSFNCGridEditCellStart.csNone) {
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FCaretPosition.$assign(CreateCaretPos(0,0));
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetSelLength(rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() - 1);
                } else if ($tmp4 === $mod.TTMSFNCGridEditCellStart.csStart) {
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FCaretPosition.$assign(CreateCaretPos(0,0));
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetSelLength(0);
                } else if ($tmp4 === $mod.TTMSFNCGridEditCellStart.csEnd) {
                  if (rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() > 0) {
                    rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FCaretPosition.$assign(CreateCaretPos(rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() - 1,rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.Get(rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FLines.GetCount() - 1).length))}
                   else rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).FCaretPosition.$assign(CreateCaretPos(0,0));
                  rtl.as(this.FEditControl,$mod.TTMSFNCGridMemo).SetSelLength(0);
                };
              };
            };
            if (this.FOptions.FEditing.FDirectComboDrop) {
              if ($mod.TTMSFNCGridComboBox.isPrototypeOf(this.FEditControl)) if ($mod.TTMSFNCGridComboBox.isPrototypeOf(this.FEditControl)) rtl.as(this.FEditControl,$mod.TTMSFNCGridComboBox).SetDroppedDown(true);
              if ($mod.TTMSFNCGridDatePicker.isPrototypeOf(this.FEditControl)) ;
            };
            if (this.FEditControl.CanFocus()) this.FEditControl.SetFocus();
            this.FEditCell.$assign(ACell);
            this.FEditing = true;
          };
        };
        this.Invalidate();
      } finally {
        $ir.free();
        rtl._Release(ioe);
      };
    };
    this.CancelEdit = function () {
      var celleditor = 0;
      if (this.FBlockHide) return;
      this.FBlockHide = true;
      celleditor = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etEdit;
      this.DoGetCellEditorType(this.FEditCell.Col,this.FEditCell.Row,{get: function () {
          return celleditor;
        }, set: function (v) {
          celleditor = v;
        }});
      if (celleditor !== pas["WEBLib.TMSFNCGridData"].TTMSFNCGridEditorType.etCustom) {
        if (this.FEditControl != null) this.FEditControl.SetParent(null);
        this.FEditControl = null;
      } else this.FFreeEditControlTimer.SetEnabled(true);
      this.FEditing = false;
      this.DoCellEditCancel(this.FEditCell.Col,this.FEditCell.Row);
      if (this.CanFocus()) this.SetFocus();
      this.FBlockHide = false;
    };
    this.StopEdit = function () {
      this.HideEdit(false,false);
    };
    this.NextPage = function () {
      var c = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      c.$assign(this.GetFocusedCell());
      this.SetFocusedCell(this.NextSelectableRow(c.Col,(c.Row + this.GetPageScrollSize()) - 1));
    };
    this.PreviousPage = function () {
      var c = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      c.$assign(this.GetFocusedCell());
      this.SetFocusedCell(this.NextSelectableRow(c.Col,(c.Row - this.GetPageScrollSize()) + 1));
    };
    this.LoadSettingsFromFile = function (AFileName) {
      this.FUseColumns = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromFile.apply(this,arguments);
    };
    this.LoadSettingsFromStream = function (AStream) {
      this.FUseColumns = false;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.LoadSettingsFromStream.apply(this,arguments);
    };
    this.Navigate = function (ACell, ForceScroll) {
      var hs = 0.0;
      var vs = 0.0;
      var rhs = 0.0;
      var rvs = 0.0;
      var vss = 0.0;
      var hss = 0.0;
      var totalh = 0.0;
      var totalw = 0.0;
      var cs = 0;
      var rs = 0;
      var c = 0;
      var r = 0;
      var toth = 0.0;
      var totw = 0.0;
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FBlockUpdate) return;
      contentr.$assign(this.GetContentRect());
      vs = this.GetVerticalScrollPosition();
      hs = this.GetHorizontalScrollPosition();
      vss = vs;
      hss = hs;
      if (this.FScrollMode === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) {
        vss = -this.GetCellContainerPosY();
        hss = -this.GetCellContainerPosX();
      };
      totalw = 0;
      totalh = 0;
      ACell.$assign(this.BaseCell(ACell.Col,ACell.Row));
      cs = this.ColSpan(ACell.Col,ACell.Row);
      rs = this.RowSpan(ACell.Col,ACell.Row);
      if (cs > 0) {
        for (var $l = ACell.Col, $end = (ACell.Col + cs) - 1; $l <= $end; $l++) {
          c = $l;
          totalw = totalw + this.GetColWidths(c);
        };
      } else totalw = this.GetColWidths(ACell.Col);
      if (rs > 0) {
        for (var $l1 = ACell.Row, $end1 = (ACell.Row + rs) - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          totalh = totalh + this.GetRowHeights(r);
        };
      } else totalh = this.GetRowHeights(ACell.Row);
      rvs = this.GetVerticalPos(0,ACell.Row);
      if (ForceScroll) {
        var $tmp = this.FScrollMode;
        if ($tmp === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling) {
          vs = rvs - this.GetFixedHeight()}
         else if ($tmp === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) vs = ACell.Row - this.FFixedRows - this.FFreezeRows;
      } else {
        if (rvs < (vss + this.GetFixedHeight())) {
          var $tmp1 = this.FScrollMode;
          if ($tmp1 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling) {
            vs = rvs - this.GetFixedHeight()}
           else if ($tmp1 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) vs = ACell.Row - this.FFixedRows - this.FFreezeRows;
        } else {
          var $tmp2 = this.FScrollMode;
          if ($tmp2 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling) {
            if ((rvs + totalh) > ((vss + (contentr.Bottom - contentr.Top)) - this.GetFixedFooterHeight())) vs = ((rvs + totalh) - (contentr.Bottom - contentr.Top)) + this.GetFixedFooterHeight();
          } else if ($tmp2 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) {
            while ((rvs + totalh) > ((vss + (contentr.Bottom - contentr.Top)) - this.GetFixedFooterHeight())) {
              toth = 0;
              vs = vs + 1;
              cl.$assign(this.BaseCell(ACell.Col,Math.round(vs)));
              rs = this.RowSpan(cl.Col,cl.Row);
              if (rs > 0) {
                for (var $l2 = cl.Row, $end2 = (cl.Row + rs) - 1; $l2 <= $end2; $l2++) {
                  r = $l2;
                  toth = toth + this.GetRowHeights(r);
                };
              } else {
                rs = 1;
                toth = this.GetRowHeights(cl.Row);
              };
              vs = (vs + rs) - 1;
              vss = vss + toth;
            };
          };
        };
      };
      rhs = this.GetHorizontalPos(0,ACell.Col);
      if (ForceScroll) {
        var $tmp3 = this.FScrollMode;
        if ($tmp3 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling) {
          hs = rhs - this.GetFixedWidth()}
         else if ($tmp3 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) hs = ACell.Col - this.FFixedColumns - this.FFreezeColumns;
      } else {
        if (rhs < (hss + this.GetFixedWidth())) {
          var $tmp4 = this.FScrollMode;
          if ($tmp4 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling) {
            hs = rhs - this.GetFixedWidth()}
           else if ($tmp4 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) hs = ACell.Col - this.FFixedColumns - this.FFreezeColumns;
        } else {
          var $tmp5 = this.FScrollMode;
          if ($tmp5 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling) {
            if ((rhs + totalw) > ((hss + (contentr.Right - contentr.Left)) - this.GetFixedRightWidth())) hs = ((rhs + totalw) - (contentr.Right - contentr.Left)) + this.GetFixedRightWidth();
          } else if ($tmp5 === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) {
            while ((rhs + totalw) > ((hss + (contentr.Right - contentr.Left)) - this.GetFixedRightWidth())) {
              totw = 0;
              hs = hs + 1;
              cl.$assign(this.BaseCell(Math.round(hs),ACell.Row));
              cs = this.ColSpan(cl.Col,cl.Row);
              if (cs > 0) {
                for (var $l3 = cl.Col, $end3 = (cl.Col + cs) - 1; $l3 <= $end3; $l3++) {
                  c = $l3;
                  totw = totw + this.GetColWidths(c);
                };
              } else {
                cs = 1;
                totw = this.GetColWidths(cl.Col);
              };
              hs = (hs + cs) - 1;
              hss = hss + totw;
            };
          };
        };
      };
      this.Scroll(hs,vs);
    };
    this.UpdateControlAfterResize = function () {
      var a = false;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.UpdateControlAfterResize.call(this);
      a = true;
      if (this.FAdapter != null) {
        this.FAdapter.UpdateBounds();
        a = this.FAdapter.CanCancelEdit();
      };
      if (this.FEditing && a) this.CancelEdit();
    };
    this.AutoSizeGrid = function (Accurate, PaddingCol, PaddingRow) {
      this.AutoSizeColumns(Accurate,PaddingCol);
      this.AutoSizeRows(PaddingRow);
    };
    this.AutoSizeColumn = function (ACol, Accurate, Padding) {
      this.AutoSizeColumnInt(ACol,Accurate,Padding);
      this.UpdateControl(true,true);
    };
    this.AutoSizeColumns = function (Accurate, Padding) {
      var i = 0;
      for (var $l = 0, $end = this.GetColumnCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.AutoSizeColumn(i,Accurate,Padding);
      };
      this.UpdateControl(true,true);
    };
    this.AutoSizeRow = function (ARow, Padding) {
      this.AutoSizeRowInt(ARow,Padding);
      this.UpdateControl(true,true);
    };
    this.AutoSizeRows = function (Padding) {
      var i = 0;
      for (var $l = 0, $end = this.GetRowCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.AutoSizeRowInt(i,Padding);
      };
      this.UpdateControl(true,true);
    };
    this.StretchColumn = function (ACol, ANewWidth) {
      var i = 0;
      var w = 0.0;
      var nw = 0.0;
      var d = 0.0;
      var cnt = 0;
      var contentr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      contentr.$assign(this.GetContentRect());
      if (ANewWidth === -1) {
        nw = contentr.Right - contentr.Left - 1}
       else nw = ANewWidth;
      cnt = this.GetColumnCount();
      if (ACol === -1) ACol = cnt - 1;
      if ((cnt === 0) || !this.FOptions.FColumnSize.FStretch) return;
      if (ACol >= cnt) throw pas.SysUtils.Exception.$create("Create$1",["Stretch column index out of range"]);
      if (cnt === 1) {
        this.SetColWidths(0,contentr.Right - contentr.Left - 1);
        return;
      };
      w = 0;
      if (this.FOptions.FColumnSize.FStretchAll) {
        if ((cnt - this.FFixedColumns - this.FFixedRightColumns) > 0) {
          d = nw;
          for (var $l = 1, $end = this.FFixedColumns; $l <= $end; $l++) {
            i = $l;
            d = d - this.GetColWidths(i - 1);
          };
          for (var $l1 = 1, $end1 = this.FFixedRightColumns; $l1 <= $end1; $l1++) {
            i = $l1;
            d = d - this.GetColWidths(cnt - i);
          };
          w = d / (cnt - this.FFixedColumns - this.FFixedRightColumns);
          for (var $l2 = this.FFixedColumns, $end2 = cnt - this.FFixedRightColumns - 1; $l2 <= $end2; $l2++) {
            i = $l2;
            this.SetColWidths(i,w);
          };
        };
      } else {
        for (var $l3 = 0, $end3 = cnt - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          if (i !== ACol) w = w + this.GetColWidths(i);
        };
        if (w < this.GetWidth()) this.SetColWidths(ACol,nw - w);
      };
    };
    this.SelectCell = function (Cell, Shift, MouseDragging) {
      var sta = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var stc = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var rs = 0;
      var cs = 0;
      var rsstart = 0;
      var csstart = 0;
      var bs = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var cst = 0;
      var rst = 0;
      var ic = 0;
      var ir = 0;
      var I = 0;
      var J = 0;
      var doUpdate = false;
      var Allow = false;
      var key = 0;
      var k = "\x00";
      var cntr = 0;
      var cntc = 0;
      var cntcl = 0;
      pas["WEBLib.TMSFNCGridData"].TTMSFNCGridData.SelectCell.apply(this,arguments);
      this.FPrevSelection.$assign(this.GetSelection());
      if ((Cell.Row < this.FFixedRows) && (Cell.Col < this.FFixedColumns) && (pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridFixedCellSelectionMode.fcsAll in this.FOptions.FMouse.FFixedCellSelection)) {
        k = "\x1F";
        key = 65;
        this.HandleKeyPress({get: function () {
            return k;
          }, set: function (v) {
            k = v;
          }});
        this.HandleKeyDown({get: function () {
            return key;
          }, set: function (v) {
            key = v;
          }},rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
        return;
      };
      Cell.Row = Math.max(this.FFixedRows,Math.min(Cell.Row,this.GetRowCount() - 1 - this.FFixedFooterRows));
      Cell.Col = Math.max(this.FFixedColumns,Math.min(Cell.Col,this.GetColumnCount() - 1 - this.FFixedRightColumns));
      Allow = true;
      if ((this.FOnSelectCell != null) && !this.FBlockSelectEventHandler) this.FOnSelectCell(this,Cell.Col,Cell.Row,{get: function () {
          return Allow;
        }, set: function (v) {
          Allow = v;
        }});
      if (!Allow) return;
      this.FPrevSelectedCell.$assign(this.GetFocusedCell());
      this.FRealCell.$assign(Cell);
      Cell.$assign(this.BaseCell(Cell.Col,Cell.Row));
      this.SetFocusCell(Cell.Col,Cell.Row);
      var $tmp = this.FOptions.FSelection.FMode;
      if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleCell) {
        this.SetStartCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
        this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
      } else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleRow) {
        this.SetStartCell(this.FFixedColumns,this.GetFocusedCell().Row);
        this.SetStopCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.GetFocusedCell().Row);
      } else if ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smSingleColumn) {
        this.SetStartCell(this.GetFocusedCell().Col,this.FFixedRows);
        this.SetStopCell(this.GetFocusedCell().Col,this.GetRowCount() - 1 - this.FFixedFooterRows);
      } else if (($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smCellRange) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) || ($tmp === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell)) {
        doUpdate = true;
        if ((!MouseDragging || (this.FFirstCell.Row === -1) || (this.FFirstCell.Col === -1)) && !(pas.Classes.TShiftState$a.ssShift in Shift) && !(pas.Classes.TShiftState$a.ssCtrl in Shift)) {
          this.SetStartCell(this.FRealCell.Col,this.GetFocusedCell().Row);
          this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
          this.FFirstCell.$assign(this.FStartCell);
          this.FSaveCell.$assign(this.FStartCell);
        } else if ((pas.Classes.TShiftState$a.ssShift in Shift) && ((this.FSaveCell.Row === -1) || (this.FSaveCell.Col === -1))) {
          this.SetStartCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
          this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
          this.FSaveCell.$assign(this.FStartCell);
        } else if ((pas.Classes.TShiftState$a.ssCtrl in Shift) && ((this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) || (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) || (this.FOptions.FSelection.FMode === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell))) {
          var $tmp1 = this.FOptions.FSelection.FMode;
          if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
            if (this.GetFocusedCell().Row < this.FStartCell.Row) {
              this.SetStartCell(this.FRealCell.Col,this.GetFocusedCell().Row);
              this.FFirstCell.$assign(this.FStopCell);
              this.FSaveCell.$assign(this.FStopCell);
            } else if (this.GetFocusedCell().Row > this.FStopCell.Row) {
              this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
              this.FFirstCell.$assign(this.FStartCell);
              this.FSaveCell.$assign(this.FStartCell);
            } else doUpdate = false;
          } else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) {
            if (this.GetFocusedCell().Col < this.FStartCell.Col) {
              this.SetStartCell(this.GetFocusedCell().Col,this.FRealCell.Row);
              this.FFirstCell.$assign(this.FStopCell);
              this.FSaveCell.$assign(this.FStopCell);
            } else if (this.GetFocusedCell().Col > this.FStopCell.Col) {
              this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
              this.FFirstCell.$assign(this.FStartCell);
              this.FSaveCell.$assign(this.FStartCell);
            } else doUpdate = false;
          } else if ($tmp1 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) {
            doUpdate = false;
            if (this.GetFocusedCell().Col < this.FStartCell.Col) {
              if (this.GetFocusedCell().Row < this.FStartCell.Row) {
                this.SetStartCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row)}
               else if (this.GetFocusedCell().Row > this.FStopCell.Row) {
                this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row)}
               else if ((this.GetFocusedCell().Row >= this.FStartCell.Row) || (this.GetFocusedCell().Row <= this.FStopCell.Row)) this.SetStartCell(this.GetFocusedCell().Col,this.FStartCell.Row);
            } else if (this.GetFocusedCell().Col > this.FStopCell.Col) {
              if (this.GetFocusedCell().Row < this.FStartCell.Row) {
                this.SetStartCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row)}
               else if (this.GetFocusedCell().Row > this.FStopCell.Row) {
                this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row)}
               else if ((this.GetFocusedCell().Row >= this.FStartCell.Row) || (this.GetFocusedCell().Row >= this.FStopCell.Row)) this.SetStopCell(this.GetFocusedCell().Col,this.FStopCell.Row);
            } else if ((this.GetFocusedCell().Col >= this.FStartCell.Col) && (this.GetFocusedCell().Col <= this.FStopCell.Col)) {
              if (this.GetFocusedCell().Row < this.FStartCell.Row) {
                this.SetStartCell(this.FStartCell.Col,this.GetFocusedCell().Row)}
               else if (this.GetFocusedCell().Row > this.FStopCell.Row) this.SetStopCell(this.FStopCell.Col,this.GetFocusedCell().Row);
            };
          };
        };
        if (pas.Classes.TShiftState$a.ssShift in Shift) this.FFirstCell.$assign(this.FSaveCell);
        if (doUpdate) {
          if (this.GetFocusedCell().Col < this.FFirstCell.Col) {
            this.SetStartCell(this.GetFocusedCell().Col,this.FStartCell.Row);
            this.SetStopCell(this.FFirstCell.Col,this.FStopCell.Row);
          } else {
            this.SetStopCell(this.GetFocusedCell().Col,this.FStopCell.Row);
            this.SetStartCell(this.FFirstCell.Col,this.FStartCell.Row);
          };
          if (this.GetFocusedCell().Row < this.FFirstCell.Row) {
            this.SetStartCell(this.FStartCell.Col,this.GetFocusedCell().Row);
            this.SetStopCell(this.FStopCell.Col,this.FFirstCell.Row);
          } else {
            this.SetStopCell(this.FStopCell.Col,this.GetFocusedCell().Row);
            this.SetStartCell(this.FStartCell.Col,this.FFirstCell.Row);
          };
        };
        var $tmp2 = this.FOptions.FSelection.FMode;
        if (($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) || ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) || ($tmp2 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell)) {
          if (!(pas.Classes.TShiftState$a.ssCtrl in Shift) && !(pas.Classes.TShiftState$a.ssShift in Shift)) {
            this.SetStartCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
            this.SetStopCell(this.GetFocusedCell().Col,this.GetFocusedCell().Row);
            this.FSaveCell.$assign(this.GetFocusedCell());
          };
        };
        var $tmp3 = this.FOptions.FSelection.FMode;
        if (($tmp3 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smRowRange) || ($tmp3 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow)) {
          this.SetStartCell(this.FFixedColumns,this.FStartCell.Row);
          this.SetStopCell(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FStopCell.Row);
        } else if (($tmp3 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smColumnRange) || ($tmp3 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn)) {
          this.SetStartCell(this.FStartCell.Col,this.FFixedRows);
          this.SetStopCell(this.FStopCell.Col,this.GetRowCount() - 1 - this.FFixedFooterRows);
        };
      };
      stc.$assign(this.FStopCell);
      sta.$assign(this.FStartCell);
      if (this.FStopCell.Col < this.FStartCell.Col) {
        this.SetStopCell(sta.Col,this.FStopCell.Row);
        this.SetStartCell(stc.Col,this.FStartCell.Row);
      };
      if (this.FStopCell.Row < this.FStartCell.Row) {
        this.SetStopCell(this.FStopCell.Col,sta.Row);
        this.SetStartCell(this.FStartCell.Col,stc.Row);
      };
      this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),false);
      cs = this.FStopCell.Col;
      csstart = this.FStartCell.Col;
      rs = this.FStopCell.Row;
      rsstart = this.FStartCell.Row;
      for (var $l = Math.max(this.FCStart,csstart), $end = Math.min(this.FCStop,cs); $l <= $end; $l++) {
        ic = $l;
        for (var $l1 = Math.max(this.FRStart,rsstart), $end1 = Math.min(this.FRStop,rs); $l1 <= $end1; $l1++) {
          ir = $l1;
          bs.$assign(this.BaseCell(ic,ir));
          cst = this.ColSpan(bs.Col,bs.Row);
          if (((bs.Col + cst) - 1) > cs) cs = (bs.Col + cst) - 1;
          if (bs.Col < csstart) csstart = bs.Col;
          rst = this.RowSpan(bs.Col,bs.Row);
          if (((bs.Row + rst) - 1) > rs) rs = (bs.Row + rst) - 1;
          if (bs.Row < rsstart) rsstart = bs.Row;
        };
      };
      this.SetStopCell(cs,rs);
      this.SetStartCell(csstart,rsstart);
      var $tmp4 = this.FOptions.FSelection.FMode;
      if ($tmp4 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctRow) {
        this.FBlockUpdate = true;
        if (!(pas.Classes.TShiftState$a.ssCtrl in Shift)) this.ClearRowSelect();
        if (pas.Classes.TShiftState$a.ssShift in Shift) {
          for (var $l2 = this.FStartCell.Row, $end2 = this.FStopCell.Row; $l2 <= $end2; $l2++) {
            I = $l2;
            this.SetRowSelect(I,!this.GetRowSelect(I));
          };
        } else {
          this.SetRowSelect(this.GetFocusedCell().Row,!this.GetRowSelect(this.GetFocusedCell().Row));
          cntr = this.GetSelectedRowCount();
          if (!this.GetRowSelect(this.GetFocusedCell().Row) && (cntr === 0)) this.SetRowSelect(this.GetFocusedCell().Row,true);
        };
        if (!this.GetRowSelect(this.GetFocusedCell().Row)) for (var $l3 = this.FStartCell.Row, $end3 = this.FStopCell.Row; $l3 <= $end3; $l3++) {
          I = $l3;
          if ((I !== this.GetFocusedCell().Row) && this.GetRowSelect(I)) this.SetFocusCell(this.GetFocusedCell().Col,I);
        };
        this.FBlockUpdate = false;
      } else if ($tmp4 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctColumn) {
        this.FBlockUpdate = true;
        if (!(pas.Classes.TShiftState$a.ssCtrl in Shift)) this.ClearColumnSelect();
        if (pas.Classes.TShiftState$a.ssShift in Shift) {
          for (var $l4 = this.FStartCell.Col, $end4 = this.FStopCell.Col; $l4 <= $end4; $l4++) {
            I = $l4;
            this.SetColumnSelect(I,!this.GetColumnSelect(I));
          };
        } else {
          this.SetColumnSelect(this.GetFocusedCell().Col,!this.GetColumnSelect(this.GetFocusedCell().Col));
          cntc = this.GetSelectedColumnCount();
          if (!this.GetColumnSelect(this.GetFocusedCell().Col) && (cntc === 0)) this.SetColumnSelect(this.GetFocusedCell().Col,true);
        };
        if (!this.GetColumnSelect(this.GetFocusedCell().Col)) for (var $l5 = this.FStartCell.Col, $end5 = this.FStopCell.Col; $l5 <= $end5; $l5++) {
          I = $l5;
          if ((I !== this.GetFocusedCell().Col) && this.GetColumnSelect(I)) this.SetFocusCell(I,this.GetFocusedCell().Row);
        };
        this.FBlockUpdate = false;
      } else if ($tmp4 === pas["WEBLib.TMSFNCGridOptions"].TTMSFNCGridSelectionMode.smDisjunctCell) {
        this.FBlockUpdate = true;
        if (!(pas.Classes.TShiftState$a.ssCtrl in Shift)) this.ClearCellSelect();
        if (pas.Classes.TShiftState$a.ssShift in Shift) {
          for (var $l6 = this.FStartCell.Col, $end6 = this.FStartCell.Row; $l6 <= $end6; $l6++) {
            I = $l6;
            for (var $l7 = this.FStartCell.Row, $end7 = this.FStopCell.Row; $l7 <= $end7; $l7++) {
              J = $l7;
              this.SetCellSelect(I,J,!this.GetCellSelect(I,J));
            };
          };
        } else {
          this.SetCellSelect(this.GetFocusedCell().Col,this.GetFocusedCell().Row,!this.GetCellSelect(this.GetFocusedCell().Col,this.GetFocusedCell().Row));
          cntcl = this.GetSelectedCellCount();
          if (!this.GetCellSelect(this.GetFocusedCell().Col,this.GetFocusedCell().Row) && (cntcl === 0)) this.SetCellSelect(this.GetFocusedCell().Col,this.GetFocusedCell().Row,true);
        };
        if (!this.GetCellSelect(this.GetFocusedCell().Col,this.GetFocusedCell().Row)) for (var $l8 = this.FStartCell.Col, $end8 = this.FStartCell.Row; $l8 <= $end8; $l8++) {
          I = $l8;
          for (var $l9 = this.FStartCell.Row, $end9 = this.FStopCell.Row; $l9 <= $end9; $l9++) {
            J = $l9;
            if ((I !== this.GetFocusedCell().Col) && (J !== this.GetFocusedCell().Row) && this.GetCellSelect(I,J)) this.SetFocusCell(I,J);
          };
        };
        this.FBlockUpdate = false;
      };
      this.Navigate(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()),false);
      if (Allow && (this.FAdapter != null)) this.FAdapter.SelectCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(this.GetFocusedCell()));
      if (Allow && (this.FOnSelectedCell != null) && !this.FBlockSelectEventHandler) this.FOnSelectedCell(this,this.GetFocusedCell().Col,this.GetFocusedCell().Row);
    };
    this.UpdateGridCells = function (AScrollOnly) {
      var vVal = 0.0;
      var hVal = 0.0;
      var cw = 0.0;
      var rh = 0.0;
      var x = 0.0;
      var y = 0.0;
      var xs = 0.0;
      var ys = 0.0;
      var rBounds = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var xOrig = 0.0;
      var yOrig = 0.0;
      var scrollv = 0.0;
      var scrollh = 0.0;
      var i = 0;
      var fw = 0.0;
      var fh = 0.0;
      var fwr = 0.0;
      var fhr = 0.0;
      var cfs = 0;
      var rfs = 0;
      var cfst = 0;
      var rfst = 0;
      var hMax = 0.0;
      var vMax = 0.0;
      var containerh = 0.0;
      var containerw = 0.0;
      if ((this.FUpdateCount$1 > 0) || this.FBlockUpdate || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.FBlockUpdate = true;
      vVal = this.GetVerticalScrollPosition();
      hVal = this.GetHorizontalScrollPosition();
      hMax = this.GetHorizontalScrollMax();
      vMax = this.GetVerticalScrollMax();
      scrollv = 0;
      scrollh = 0;
      if (this.FScrollMode === pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmItemScrolling) {
        hMax = this.GetTotalContentWidth();
        vMax = this.GetTotalContentHeight();
        for (var $l = this.FFixedRows + this.FFreezeRows, $end = (Math.round(vVal) - 1) + this.FFixedRows + this.FFreezeRows; $l <= $end; $l++) {
          i = $l;
          scrollv = scrollv + this.GetRowHeights(i);
        };
        for (var $l1 = this.FFixedColumns + this.FFreezeColumns, $end1 = (Math.round(hVal) - 1) + this.FFixedColumns + this.FFreezeColumns; $l1 <= $end1; $l1++) {
          i = $l1;
          scrollh = scrollh + this.GetColWidths(i);
        };
        vVal = scrollv;
        hVal = scrollh;
      };
      this.FCellPosX = Math.round(-hVal);
      this.FCellPosY = Math.round(-vVal);
      containerw = this.GetTotalContentWidth();
      containerh = this.GetTotalContentHeight();
      if ((containerw > 0) && (containerh > 0)) {
        cfs = this.GetFixedCols();
        rfs = this.GetFixedRows();
        cfst = this.FFixedRightColumns;
        rfst = this.FFixedFooterRows;
        this.FOldTopRow = this.FRStart;
        this.FCStart = cfs;
        this.FRStart = rfs;
        rBounds.$assign(this.GetContentRect());
        rBounds.$assign(pas["WEBLib.TMSFNCTypes"].RectF(rBounds.Left,rBounds.Top,rBounds.Right - 1,rBounds.Bottom - 1));
        fw = this.GetFixedWidth();
        fh = this.GetFixedHeight();
        fwr = this.GetFixedRightWidth();
        fhr = this.GetFixedFooterHeight();
        xOrig = 0;
        yOrig = 0;
        if ((hVal > (hMax / 2)) && (this.FColumnW.GetCount() === 0)) {
          this.FCStop = this.GetColumnCount() - 1 - cfst;
          x = containerw - fwr;
          do {
            cw = this.GetColWidths(this.FCStop);
            if ((x - cw) > ((hVal + (rBounds.Right - rBounds.Left)) - fwr)) {
              x = x - cw;
              this.FCStop -= 1;
            };
          } while (!((x - cw) <= ((hVal + (rBounds.Right - rBounds.Left)) - fwr)));
        } else {
          x = fw;
          do {
            cw = this.GetColWidths(this.FCStart);
            if ((x + cw) <= (hVal + fw)) {
              x = x + cw;
              this.FCStart += 1;
            };
          } while (!((x + cw) > (hVal + fw)));
          xOrig = x;
        };
        if ((vVal > (vMax / 2)) && (this.FRowH.GetCount() === 0)) {
          this.FRStop = this.GetRowCount() - 1 - rfst;
          y = containerh - fhr;
          do {
            rh = this.GetRowHeights(this.FRStop);
            if ((y - rh) > ((vVal + (rBounds.Bottom - rBounds.Top)) - fhr)) {
              y = y - rh;
              this.FRStop -= 1;
            };
          } while (!((y - rh) <= ((vVal + (rBounds.Bottom - rBounds.Top)) - fhr)));
        } else {
          y = fh;
          do {
            rh = this.GetRowHeights(this.FRStart);
            if ((y + rh) <= (vVal + fh)) {
              y = y + rh;
              this.FRStart += 1;
            };
          } while (!((y + rh) > (vVal + fh)));
          yOrig = y;
        };
        if ((hVal > (hMax / 2)) && (this.FColumnW.GetCount() === 0)) {
          this.FCStart = this.FCStop;
          while ((this.FCStart > 0) && (x > (hVal + fw))) {
            x = x - this.GetColWidths(this.FCStart);
            if (!((this.FCStart > 0) && (x > (hVal + fw)))) break;
            this.FCStart -= 1;
          };
          xOrig = x;
        } else {
          this.FCStop = this.FCStart;
          while ((this.FCStop < (this.GetColumnCount() - 1)) && (x < ((hVal + (rBounds.Right - rBounds.Left)) - fwr))) {
            x = x + this.GetColWidths(this.FCStop);
            if (!((this.FCStop < (this.GetColumnCount() - 1)) && (x < ((hVal + (rBounds.Right - rBounds.Left)) - fwr)))) break;
            this.FCStop += 1;
          };
        };
        if ((vVal > (vMax / 2)) && (this.FRowH.GetCount() === 0)) {
          this.FRStart = this.FRStop;
          while ((this.FRStart > 0) && (y > (vVal + fh))) {
            y = y - this.GetRowHeights(this.FRStart);
            if (!((this.FRStart > 0) && (y > (vVal + fh)))) break;
            this.FRStart -= 1;
          };
          yOrig = y;
        } else {
          this.FRStop = this.FRStart;
          while ((this.FRStop < (this.GetRowCount() - 1)) && (y < ((vVal + (rBounds.Bottom - rBounds.Top)) - fhr))) {
            y = y + this.GetRowHeights(this.FRStop);
            if (!((this.FRStop < (this.GetRowCount() - 1)) && (y < ((vVal + (rBounds.Bottom - rBounds.Top)) - fhr)))) break;
            this.FRStop += 1;
          };
        };
        this.FRStart = Math.max(this.FFixedRows,Math.min(this.GetRowCount() - 1 - this.FFixedFooterRows,this.FRStart));
        this.FCStart = Math.max(this.FFixedColumns,Math.min(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FCStart));
        this.FRStop = Math.max(this.FFixedRows,Math.min(this.GetRowCount() - 1 - this.FFixedFooterRows,this.FRStop));
        this.FCStop = Math.max(this.FFixedColumns,Math.min(this.GetColumnCount() - 1 - this.FFixedRightColumns,this.FCStop));
        if ((this.FAdapter != null) && (this.FBlockUpdateAdapter === 0)) {
          this.FBlockUpdateAdapter += 1;
          this.FAdapter.ScrollGrid(this.GetTopRow() - this.FOldTopRow,true,AScrollOnly);
          this.FBlockUpdateAdapter -= 1;
        };
        x = xOrig - hVal;
        y = yOrig - vVal;
        xs = 0;
        ys = 0;
        if ((this.GetColumnCount() > this.GetFixedCols()) && (this.GetRowCount() > this.GetFixedRows())) this.DisplayCells(x,y,x,y,this.FCStart,this.FCStop,this.FRStart,this.FRStop,cfs,rfs,rfs,false);
        if (this.GetRowCount() > this.GetFixedRows()) this.DisplayCells(xs,y,xs,y,0,cfs - 1,this.FRStart,this.FRStop,0,rfs,rfs,true);
        if (this.GetColumnCount() > this.GetFixedCols()) this.DisplayCells(x,ys,x,ys,this.FCStart,this.FCStop,0,rfs - 1,cfs,0,0,true);
        this.DisplayCells(xs,ys,xs,ys,0,cfs - 1,0,rfs - 1,0,0,0,true);
        if ((this.GetColumnCount() > (this.GetFixedCols() + this.FFixedRightColumns)) && (this.GetRowCount() > this.GetFixedRows())) {
          this.DisplayCells((xs + (rBounds.Right - rBounds.Left)) - fwr,y,(xs + (rBounds.Right - rBounds.Left)) - fwr,y,this.GetColumnCount() - cfst,this.GetColumnCount() - 1,this.FRStart,this.FRStop,(this.FCStop - this.FCStart) + cfs + 1,rfs,rfs,true);
          this.DisplayCells((xs + (rBounds.Right - rBounds.Left)) - fwr,ys,(xs + (rBounds.Right - rBounds.Left)) - fwr,ys,this.GetColumnCount() - cfst,this.GetColumnCount() - 1,0,rfs - 1,(this.FCStop - this.FCStart) + cfs + 1,0,0,true);
        };
        if ((this.GetColumnCount() > this.GetFixedCols()) && (this.GetRowCount() > (this.GetFixedRows() + this.FFixedFooterRows))) {
          this.DisplayCells(x,(ys + (rBounds.Bottom - rBounds.Top)) - fhr,xs,(ys + (rBounds.Bottom - rBounds.Top)) - fhr,this.FCStart,this.FCStop,this.GetRowCount() - rfst,this.GetRowCount() - 1,cfs,(this.FRStop - this.FRStart) + rfs + 1,(this.FRStop - this.FRStart) + rfs + 1,true);
        };
        if ((this.GetColumnCount() > (this.GetFixedCols() + this.FFixedRightColumns)) && (this.GetRowCount() > (this.GetFixedRows() + this.FFixedFooterRows))) {
          this.DisplayCells((xs + (rBounds.Right - rBounds.Left)) - fwr,(ys + (rBounds.Bottom - rBounds.Top)) - fhr,(xs + (rBounds.Right - rBounds.Left)) - fwr,(ys + (rBounds.Bottom - rBounds.Top)) - fhr,this.GetColumnCount() - cfst,this.GetColumnCount() - 1,this.GetRowCount() - rfst,this.GetRowCount() - 1,(this.FCStop - this.FCStart) + cfs + 1,(this.FRStop - this.FRStart) + rfs + 1,(this.FRStop - this.FRStart) + rfs + 1,true);
        };
        if (this.GetRowCount() > this.GetFixedRows()) {
          this.DisplayCells(xs,(ys + (rBounds.Bottom - rBounds.Top)) - fhr,xs,(ys + (rBounds.Bottom - rBounds.Top)) - fhr,0,cfs - 1,this.GetRowCount() - rfst,this.GetRowCount() - 1,0,(this.FRStop - this.FRStart) + rfs + 1,(this.FRStop - this.FRStart) + rfs + 1,true);
        };
      } else this.RemoveAllCells();
      if ((this.FEditControl != null) && this.FEditing && !this.FFreeEditControlTimer.FEnabled) {
        this.FEditControl.BringToFront();
        this.FEditControl.SetVisible(true);
        if (this.FEditControl.CanFocus()) this.FEditControl.SetFocus();
      };
      if ((this.FTopr !== this.GetTopRow()) || (this.FLeftC !== this.GetLeftCol())) {
        if (this.FOnTopLeftChanged != null) this.FOnTopLeftChanged(this,this.GetTopRow(),this.GetLeftCol());
      };
      this.FTopr = this.GetTopRow();
      this.FLeftC = this.GetLeftCol();
      this.FBlockUpdate = false;
      if ((this.FAdapter != null) && (this.FBlockUpdateAdapter === 0)) {
        this.FBlockUpdateAdapter += 1;
        this.FAdapter.ScrollGrid(this.GetTopRow() - this.FOldTopRow,false,AScrollOnly);
        this.FBlockUpdateAdapter -= 1;
      };
      this.Invalidate();
    };
    this.UpdateControlScroll = function (AHorizontalPos, AVerticalPos, ANewHorizontalPos, ANewVerticalPos) {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.UpdateControlScroll.apply(this,arguments);
      if ((AHorizontalPos !== ANewHorizontalPos) || (AVerticalPos !== ANewVerticalPos)) {
        this.UpdateGridCells(false)}
       else this.UpdateGridCellDisplay();
    };
    this.UpdateGridCellDisplay = function () {
      var cl = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$new();
      if ((this.FUpdateCount$1 > 0) || this.FBlockUpdate || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      this.FBlockUpdate = true;
      cl.StartCol = this.FPrevSelection.StartCol;
      cl.EndCol = this.FPrevSelection.EndCol;
      cl.StartRow = 0;
      cl.EndRow = this.FFixedRows - 1;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      cl.StartCol = 0;
      cl.EndCol = this.FFixedColumns - 1;
      cl.StartRow = this.FPrevSelection.StartRow;
      cl.EndRow = this.FPrevSelection.EndRow;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      cl.StartCol = this.FPrevSelection.StartCol;
      cl.EndCol = this.FPrevSelection.EndCol;
      cl.StartRow = this.GetRowCount() - this.FFixedFooterRows;
      cl.EndRow = this.GetRowCount() - 1;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      cl.StartCol = this.GetColumnCount() - this.FFixedRightColumns;
      cl.EndCol = this.GetColumnCount() - 1;
      cl.StartRow = this.FPrevSelection.StartRow;
      cl.EndRow = this.FPrevSelection.EndRow;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(this.FPrevSelection));
      cl.StartCol = this.GetSelection().StartCol;
      cl.EndCol = this.GetSelection().EndCol;
      cl.StartRow = 0;
      cl.EndRow = this.FFixedRows - 1;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      cl.StartCol = 0;
      cl.EndCol = this.FFixedColumns - 1;
      cl.StartRow = this.GetSelection().StartRow;
      cl.EndRow = this.GetSelection().EndRow;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      cl.StartCol = this.GetSelection().StartCol;
      cl.EndCol = this.GetSelection().EndCol;
      cl.StartRow = this.GetRowCount() - this.FFixedFooterRows;
      cl.EndRow = this.GetRowCount() - 1;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      cl.StartCol = this.GetColumnCount() - this.FFixedRightColumns;
      cl.EndCol = this.GetColumnCount() - 1;
      cl.StartRow = this.GetSelection().StartRow;
      cl.EndRow = this.GetSelection().EndRow;
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(cl));
      this.DoUpdateGridCellDisplay(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRecRange.$clone(this.GetSelection()));
      this.FBlockUpdate = false;
      this.Invalidate();
    };
    this.DoUpdateGridCellDisplay = function (ASelection) {
      var c = 0;
      var r = 0;
      var ci = 0;
      var ri = 0;
      var cell = null;
      var bc = 0;
      var br = 0;
      var cs = 0;
      var rs = 0;
      var fc = 0;
      var fr = 0;
      var incfr = false;
      var incfc = false;
      var cStart = 0;
      var cStop = 0;
      var rStart = 0;
      var rStop = 0;
      var clStart = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var clStop = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      var l = null;
      l = pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCellLayout.$create("Create$1");
      fc = 0;
      this.FSaveTopCell = null;
      incfc = false;
      cStart = ASelection.StartCol;
      cStop = ASelection.EndCol;
      rStart = ASelection.StartRow;
      rStop = ASelection.EndRow;
      clStart.Col = cStart;
      clStop.Col = cStop;
      clStart.Row = rStart;
      clStop.Row = rStop;
      clStart.$assign(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(clStart)));
      clStop.$assign(this.GetDisplayCell(pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$clone(clStop)));
      for (var $l = clStart.Col, $end = clStop.Col; $l <= $end; $l++) {
        c = $l;
        if ((c >= 0) && (c <= (rtl.length(this.FCellArray) - 1))) {
          if (incfc) fc += 1;
          fr = 0;
          incfr = false;
          for (var $l1 = clStart.Row, $end1 = clStop.Row; $l1 <= $end1; $l1++) {
            r = $l1;
            if ((r >= 0) && (r <= (rtl.length(this.FCellArray[c]) - 1))) {
              if (incfr) fr += 1;
              cell = this.FCellArray[c][r];
              if (cell != null) {
                if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
                  bc = (c + this.FCStart) - this.GetFixedCols();
                  if (bc > this.FCStop) {
                    bc = (this.GetColumnCount() - this.FFixedRightColumns) + fc;
                    incfc = true;
                  } else if (bc < this.FCStart) bc = c;
                  br = (r + this.FRStart) - this.GetFixedRows();
                  if (br > this.FRStop) {
                    br = (this.GetRowCount() - this.FFixedFooterRows) + fr;
                    incfr = true;
                  } else if (br < this.FRStart) br = r;
                  cs = 0;
                  rs = 0;
                  this.DoGetCellMergeInfo(bc,br,{get: function () {
                      return bc;
                    }, set: function (v) {
                      bc = v;
                    }},{get: function () {
                      return br;
                    }, set: function (v) {
                      br = v;
                    }},{get: function () {
                      return cs;
                    }, set: function (v) {
                      cs = v;
                    }},{get: function () {
                      return rs;
                    }, set: function (v) {
                      rs = v;
                    }});
                  ci = bc;
                  ri = br;
                  ci = Math.max(0,Math.min(ci,this.GetColumnCount() - 1));
                  ri = Math.max(0,Math.min(ri,this.GetRowCount() - 1));
                  if ((ci === this.GetFocusedCell().Col) && (ri === this.GetFocusedCell().Row)) this.FSaveTopCell = cell;
                  this.ApplyCellState(ci,ri,cell);
                  if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell.isPrototypeOf(cell)) {
                    l.Assign(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).FLayout);
                    this.DoGetCellLayout(ci,ri,l,this.GetCellState(ci,ri));
                    rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCGridCell).AssignLayout(l);
                  };
                  this.DoGetCellProperties(ci,ri,cell);
                };
              };
            };
          };
        };
      };
      l = rtl.freeLoc(l);
    };
    this.PaintCells = function (AGraphics, CStart, CStop, RStart, RStop, Ci, Ri, ResetCi) {
      var c = 0;
      var r = 0;
      var cell = null;
      var rctl = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var rt = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ck = false;
      var dr = false;
      var bc = pas["WEBLib.TMSFNCGridData"].TTMSFNCGridCellRec.$new();
      for (var $l = CStart, $end = CStop; $l <= $end; $l++) {
        c = $l;
        for (var $l1 = RStart, $end1 = RStop; $l1 <= $end1; $l1++) {
          r = $l1;
          if (rtl.length(this.FCellArray) > Ci) {
            if (rtl.length(this.FCellArray[Ci]) > Ri) {
              dr = true;
              ck = (this.GetFocusedCell().Col === c) && (this.GetFocusedCell().Row === r);
              if (this.IsMerged(c,r)) {
                bc.$assign(this.BaseCell(c,r));
                ck = ck || ((bc.Col === this.GetFocusedCell().Col) && (bc.Row === this.GetFocusedCell().Row));
              };
              if (this.FEditing && ck) dr = false;
              cell = this.FCellArray[Ci][Ri];
              if (cell != null) {
                rctl.$assign(pas["WEBLib.TMSFNCTypes"].RectF(cell.FLeft,cell.FTop,cell.FLeft + cell.FWidth,cell.FTop + cell.FHeight));
                if (((rctl.Bottom - rctl.Top) > 1) && ((rctl.Right - rctl.Left) > 1)) {
                  if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).SetControlBitmap(this.GetCheckBoxBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCCheckGridCell).FChecked,false,true));
                  if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).SetControlBitmap(this.GetRadioButtonBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCRadioGridCell).FChecked,false,true));
                  if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).SetControlBitmap(this.GetNodeBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCNodeGridCell).FState));
                  if (pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell.isPrototypeOf(cell)) rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell).SetControlBitmap(this.GetDummyButtonBitmap(rtl.as(cell,pas["WEBLib.TMSFNCGridCell"].TTMSFNCButtonGridCell)));
                  if (!dr) {
                    cell.FLayout.FFill.Assign(this.FAppearance.FNormalLayout.FFill);
                    cell.FLayout.FStroke.Assign(this.FAppearance.FNormalLayout.FStroke);
                  };
                  rt.$assign(cell.GetTextRect(false));
                  pas["WEBLib.TMSFNCTypes"].InflateRectEx(rt,-2,-2);
                  cell.Draw(AGraphics,dr,dr,true);
                  if ((this.GetFocusedCell().Col === c) && (this.GetFocusedCell().Row === r) && !this.FEditing && this.IsFocused() && dr && this.FAppearance.FShowFocus) AGraphics.DrawFocusRectangle$3(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(pas["WEBLib.TMSFNCTypes"].RectF(rctl.Left + 1,rctl.Top + 1,rctl.Right - 1,rctl.Bottom - 1)),0,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
                };
              };
            };
          };
          Ri += 1;
        };
        Ci += 1;
        Ri = ResetCi;
      };
    };
    this.DisplayCells = function (x, y, xOrig, yOrig, CStart, CStop, RStart, RStop, Ci, Ri, ResetCi, Fixed) {
      if ((this.FAdapter != null) && this.FAdapter.AlternateDisplayBuildUp()) {
        this.DisplayCellsAlternate(x,y,xOrig,yOrig,CStart,CStop,RStart,RStop,Ci,Ri,ResetCi,Fixed)}
       else this.DisplayCellsNormal(x,y,xOrig,yOrig,CStart,CStop,RStart,RStop,Ci,Ri,ResetCi,Fixed);
    };
    this.InitSample = function () {
      var I = 0;
      this.BeginUpdate();
      this.FUseColumns = false;
      this.ResetToDefaultStyle();
      this.SetDefaultRowHeight(this.ScalePaintValue(40));
      this.SetFixedColumns(0);
      this.FOptions.FBands.SetEnabled(true);
      for (var $l = 0, $end = this.FColumns.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FColumns.GetItem$1(I).SetWidth(this.ScalePaintValue(90));
        this.FColumns.GetItem$1(I).FFixedFont.SetColor(0x454545);
        this.FColumns.GetItem$1(I).FFont.SetColor(0x7A7A7A);
      };
      this.FColumns.GetItem$1(0).SetWidth(this.ScalePaintValue(70));
      this.FColumns.GetItem$1(1).SetWidth(this.ScalePaintValue(250));
      this.FColumns.GetItem$1(2).SetWidth(this.ScalePaintValue(100));
      this.FColumns.GetItem$1(3).SetWidth(this.ScalePaintValue(100));
      this.LoadSampleData();
      this.SetColumnCount(4);
      this.SetWidth(this.ScalePaintValue(520));
      this.EndUpdate();
    };
    this.LoadSampleData = function () {
      var I = 0;
      var J = 0;
      var s = "";
      var p = "";
      var d = 0.0;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FFixedRows - 1; $l <= $end; $l++) {
        I = $l;
        if (I > 0) {
          p = "Sub "}
         else p = "";
        for (var $l1 = this.FFixedColumns, $end1 = this.GetColumnCount() - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          var $tmp = J;
          if ($tmp === 0) {
            s = p + "ID"}
           else if ($tmp === 1) {
            s = p + "Name"}
           else if ($tmp === 2) {
            s = p + "Joined"}
           else if ($tmp === 3) {
            s = p + "Status"}
           else {
            s = p + "Number";
          };
          this.SetCells(J,I,s);
        };
      };
      for (var $l2 = this.FFixedRows, $end2 = this.GetRowCount() - 1; $l2 <= $end2; $l2++) {
        I = $l2;
        for (var $l3 = this.FFixedColumns, $end3 = this.GetColumnCount() - 1; $l3 <= $end3; $l3++) {
          J = $l3;
          s = "";
          var $tmp1 = J;
          if ($tmp1 === 0) {
            s = "00" + pas.SysUtils.TIntegerHelper.ToString$1.call({get: function () {
                return I;
              }, set: function (v) {
                I = v;
              }})}
           else if ($tmp1 === 1) {
            var $tmp2 = pas.System.Random(120) % 5;
            if ($tmp2 === 0) {
              s = "David"}
             else if ($tmp2 === 1) {
              s = "Laura"}
             else if ($tmp2 === 2) {
              s = "Isaac"}
             else if ($tmp2 === 3) {
              s = "Marie"}
             else {
              s = "Leon";
            };
            var $tmp3 = pas.System.Random(120) % 5;
            if ($tmp3 === 0) {
              s = s + " Kleermakers"}
             else if ($tmp3 === 1) {
              s = s + " Tailor"}
             else if ($tmp3 === 2) {
              s = s + " Terzi"}
             else if ($tmp3 === 3) {
              s = s + " Sastre"}
             else {
              s = s + " Schneider";
            };
          } else if ($tmp1 === 2) {
            d = Math.round(pas.SysUtils.Now()) - pas.System.Random(5475);
            s = pas.SysUtils.DateToStr(d);
          } else if ($tmp1 === 3) {
            var $tmp4 = pas.System.Random(120) % 5;
            if ($tmp4 === 0) {
              s = "Flight"}
             else if ($tmp4 === 1) {
              s = "On Leave"}
             else if ($tmp4 === 2) {
              s = "Abroad"}
             else {
              s = "Office";
            };
          } else {
            s = pas.SysUtils.TIntegerHelper.ToString$1.call({a: pas.System.Random(100), get: function () {
                return this.a;
              }, set: function (v) {
                this.a = v;
              }});
          };
          this.SetCells(J,I,s);
        };
      };
      this.EndUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TMSFNCGRIDCELLNODEOPEN = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlY" + "WR5ccllPAAAARJJREFUeNpi/P//P0NcX2oCAwNDJhCbMRAGp4B4+qKi2QsYY3tT6hTFVRrdTQIYZETkCep88u" + "Yhw84zGxjuv7xTzwSyMdo5mUFRQpGBlYWJIAapA6kH6WMBEhIifAIMpAB2VrB6CSYIhwkrLqzrxSkHAiCbGVi" + "ZmXDagk8OrJnhPx434pEDa/77DyGQUdmJoiC1HMGf0V6OqfnPH4TAlGaEgpzaThQ+sjq45p+//+F0Gj45sObv" + "P3/jVIBPDqz587cfWCXLczNwysE0P3329rk0Nwcf0Ynk649PIOops767Eefrjy+dBLllGP79YwT68Q9e/OHrR" + "4ZD1zYxfP7xvosRmqvqoLlKggiLX0BzVRNAgAEAJkJ1yu0zs+kAAAAASUVORK5CYII=";
  this.TMSFNCGRIDCELLNODECLOSED = "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJ" + "lYWR5ccllPAAAAOxJREFUeNpi/P//P0NcX2oCAwNDJhCbMRAGp4B4+qKi2QsYY3tT6hTFVRrdTQIYZETkCe" + "p88uYhw84zGxjuv7xTzwSyMdo5mUFRQpGBlYWJIAapA6kH6WMBEhIifAIMpAB2VrB6CRYIh4mBHADWzMpMg" + "WaG/wzka/77DyGQUdmJU/GM9nJMzX/+IASmNJfj1IysDq755+9/5Dv7+8/f5Gv+/O0H2ZqfPnv7XJqbg49o" + "TV9/fAJRT5n13Y04X3986STILcPw7x8j0P9/8OIPXz8yHLq2ieHzj/ddjNBcVQfNVRJEWPwCmquaAAIMAGY" + "uZD5GuUOeAAAAAElFTkSuQmCC";
  $mod.$resourcestrings = {sTMSFNCGridFilterAll: {org: "(All)"}};
  $mod.$implcode = function () {
    $impl.GetTickCountX = function () {
      var Result = 0;
      var h = 0;
      var m = 0;
      var s = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(pas.SysUtils.Now(),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }},{get: function () {
          return m;
        }, set: function (v) {
          m = v;
        }},{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = ms + (s * 1000) + (m * 60 * 1000) + (h * 60 * 60 * 1000);
      return Result;
    };
    $impl.AnimateDouble = function (Start, Stop, Delta, Margin) {
      var Result = false;
      Result = true;
      if ((Start.get() > (Stop.get() - Margin)) && (Start.get() < (Stop.get() + Margin))) {
        Start.set(Stop.get());
        Result = false;
      } else {
        Delta = Math.max(Margin,Delta);
        if (Start.get() < Stop.get()) {
          Start.set(Start.get() + Delta)}
         else Start.set(Start.get() - Delta);
      };
      return Result;
    };
    $impl.PtInR = function (Rect, P) {
      var Result = false;
      Result = (P.X >= Rect.Left) && (P.X < Rect.Right) && (P.Y >= Rect.Top) && (P.Y < Rect.Bottom);
      return Result;
    };
  };
  $mod.$init = function () {
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRIDCELLNODEOPEN);
    pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.CreateFromResource($mod.TMSFNCGRIDCELLNODECLOSED);
  };
},["WEBLib.TMSFNCCustomScrollControl","WEBLib.TMSFNCUtils","SysUtils","WEBLib.TMSFNCColorSelector","Math","WEBLib.Graphics","WEBLib.Forms","WEBLib.TMSFNCStyles","WEBLib.Dialogs"]);
rtl.module("WEBLib.TMSFNCGrid",["System","Classes","WEBLib.TMSFNCCustomGrid","WEBLib.TMSFNCGridData"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TTMSFNCGrid",pas["WEBLib.TMSFNCCustomGrid"].TTMSFNCCustomGrid,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClasses([$mod.TTMSFNCGrid,pas["WEBLib.TMSFNCGridData"].TTMSFNCGridColumn]);
    };
    rtl.addIntf(this,pas["WEBLib.TMSFNCBitmapContainer"].ITMSFNCBitmapContainer);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderGrid);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphicsTypes"].ITMSFNCAppearanceGlobalFont);
    rtl.addIntf(this,pas["WEBLib.TMSFNCGraphics"].ITMSFNCGraphicsExport);
    rtl.addIntf(this,pas["WEBLib.TMSFNCPersistence"].ITMSFNCPersistence);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderSelection);
    rtl.addIntf(this,pas["WEBLib.TMSFNCDataBinding"].ITMSFNCDataBinderNotificationManagerReference);
    rtl.addIntf(this,pas["WEBLib.TMSFNCStyles"].ITMSFNCAdaptToStyle);
    rtl.addIntf(this,pas["WEBLib.TMSFNCTypes"].ITMSFNCProductInfo);
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Adapter",2,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridAdapter"],"FAdapter","SetAdapter");
    $r.addProperty("HorizontalScrollBarVisible",2,rtl.boolean,"FHorizontalScrollBarVisible","SetHorizontalScrollBarVisible",4,{Default: true});
    $r.addProperty("VerticalScrollBarVisible",2,rtl.boolean,"FVerticalScrollBarVisible","SetVerticalScrollBarVisible",4,{Default: true});
    $r.addProperty("Columns",2,pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridColumns"],"FColumns","SetColumns");
    $r.addProperty("ToolBarPopup",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCustomToolBarPopup"],"FToolBarPopup","FToolBarPopup");
    $r.addProperty("ToolBarPopupMode",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCustomToolBarPopupMode"],"FToolBarPopupMode","FToolBarPopupMode",4,{Default: pas["WEBLib.TMSFNCCustomGrid"].TTMSFNCGridCustomToolBarPopupMode.tpmActiveCell});
    $r.addProperty("Version",1,rtl.string,"GetVersion","");
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("DefaultFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FDefaultFont","SetDefaultFont");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("TopRow",3,rtl.longint,"GetTopRow","SetTopRow");
    $r.addProperty("Appearance",2,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("LeftCol",3,rtl.longint,"GetLeftCol","SetLeftCol");
    $r.addProperty("ScrollMode",2,pas["WEBLib.TMSFNCCustomScrollControl"].$rtti["TTMSFNCCustomScrollControlMode"],"FScrollMode","SetScrollMode",4,{Default: pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlMode.scmPixelScrolling});
    $r.addProperty("ScrollUpdate",2,pas["WEBLib.TMSFNCCustomScrollControl"].$rtti["TTMSFNCCustomScrollControlUpdate"],"FScrollUpdate","SetScrollUpdate",4,{Default: pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControlUpdate.scuContinuous});
    $r.addProperty("CustomScrollBars",2,rtl.boolean,"FCustomScrollBars","SetCustomScrollBars",4,{Default: false});
    $r.addProperty("FreezeColumns",2,rtl.longint,"FFreezeColumns","SetFreezeColumns",4,{Default: 0});
    $r.addProperty("FreezeRows",2,rtl.longint,"FFreezeRows","SetFreezeRows",4,{Default: 0});
    $r.addProperty("GlobalFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCAppearanceGlobalFont"],"FGlobalFont","SetGlobalFont");
    $r.addProperty("DesignTimeSampleData",2,rtl.boolean,"FDesignTimeSampleData","SetDesignTimeSampleData");
    $r.addProperty("OnTopLeftChanged",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridTopLeftChanged"],"FOnTopLeftChanged","FOnTopLeftChanged");
    $r.addProperty("OnGetCellClass",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellClass"],"FOnGetCellClass","FOnGetCellClass");
    $r.addProperty("OnGetCellData",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellData"],"FOnGetCellData","FOnGetCellData");
    $r.addProperty("OnGetCellRotation",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellRotation"],"FOnGetCellRotation","FOnGetCellRotation");
    $r.addProperty("OnGetCellProperties",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellProperties"],"FOnGetCellProperties","FOnGetCellProperties");
    $r.addProperty("OnGetCellLayout",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellLayout"],"FOnGetCellLayout","FOnGetCellLayout");
    $r.addProperty("OnGetCellMergeInfo",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellMergeInfo"],"FOnGetCellMergeInfo","FOnGetCellMergeInfo");
    $r.addProperty("OnGetCellReadOnly",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellReadOnly"],"FOnGetCellReadOnly","FOnGetCellReadOnly");
    $r.addProperty("OnGetRowIsBand",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetRowIsBand"],"FOnGetRowIsBand","FOnGetRowIsBand");
    $r.addProperty("OnCanInsertRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanInsertRow"],"FOnCanInsertRow","FOnCanInsertRow");
    $r.addProperty("OnCanAppendRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanAppendRow"],"FOnCanAppendRow","FOnCanAppendRow");
    $r.addProperty("OnCanAppendColumn",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanAppendColumn"],"FOnCanAppendColumn","FOnCanAppendColumn");
    $r.addProperty("OnCanDeleteRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanDeleteRow"],"FOnCanDeleteRow","FOnCanDeleteRow");
    $r.addProperty("OnInsertRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnInsertRow"],"FOnInsertRow","FOnInsertRow");
    $r.addProperty("OnAppendRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnAppendRow"],"FOnAppendRow","FOnAppendRow");
    $r.addProperty("OnAppendColumn",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnAppendColumn"],"FOnAppendColumn","FOnAppendColumn");
    $r.addProperty("OnDeleteRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnDeleteRow"],"FOnDeleteRow","FOnDeleteRow");
    $r.addProperty("OnCellAnchorClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellAnchorClick"],"FOnCellAnchorClick","FOnCellAnchorClick");
    $r.addProperty("OnGetCellEditorCustomClassType",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellEditorCustomClassType"],"FOnGetCellEditorCustomClassType","FOnGetCellEditorCustomClassType");
    $r.addProperty("OnGetCellEditorType",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellEditorType"],"FOnGetCellEditorType","FOnGetCellEditorType");
    $r.addProperty("OnCellEditGetData",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditGetData"],"FOnCellEditGetData","FOnCellEditGetData");
    $r.addProperty("OnCellEditValidateData",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditValidateData"],"FOnCellEditValidateData","FOnCellEditValidateData");
    $r.addProperty("OnCellEditSetData",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditSetData"],"FOnCellEditSetData","FOnCellEditSetData");
    $r.addProperty("OnCellEditGetColor",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditGetColor"],"FOnCellEditGetColor","FOnCellEditGetColor");
    $r.addProperty("OnCellEditValidateColor",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditValidateColor"],"FOnCellEditValidateColor","FOnCellEditValidateColor");
    $r.addProperty("OnCellEditSetColor",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditSetColor"],"FOnCellEditSetColor","FOnCellEditSetColor");
    $r.addProperty("OnCellEditDone",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditDone"],"FOnCellEditDone","FOnCellEditDone");
    $r.addProperty("OnCellEditCancel",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellEditCancel"],"FOnCellEditCancel","FOnCellEditCancel");
    $r.addProperty("OnGetCellEditorProperties",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellEditorProperties"],"FOnGetCellEditorProperties","FOnGetCellEditorProperties");
    $r.addProperty("OnGetCellIsFixed",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnGetCellIsFixed"],"FOnGetCellIsFixed","FOnGetCellIsFixed");
    $r.addProperty("OnFixedCellDropDownButtonClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnFixedCellDropDownButtonClick","FOnFixedCellDropDownButtonClick");
    $r.addProperty("OnCellComboCloseUp",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellComboCloseUp"],"FOnCellComboCloseUp","FOnCellComboCloseUp");
    $r.addProperty("OnCellBeforeDraw",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellBeforeDraw"],"FOnCellBeforeDraw","FOnCellBeforeDraw");
    $r.addProperty("OnCellAfterDraw",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellAfterDraw"],"FOnCellAfterDraw","FOnCellAfterDraw");
    $r.addProperty("OnCellBitmapClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellBitmapClick","FOnCellBitmapClick");
    $r.addProperty("OnCellRadioButtonClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellRadioButtonClick","FOnCellRadioButtonClick");
    $r.addProperty("OnCellCheckBoxClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellCheckBoxClick","FOnCellCheckBoxClick");
    $r.addProperty("OnCellButtonClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellButtonClick","FOnCellButtonClick");
    $r.addProperty("OnCellCommentClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellCommentClick","FOnCellCommentClick");
    $r.addProperty("OnCellSortClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellSortClick","FOnCellSortClick");
    $r.addProperty("OnCellNodeClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellControlEvent"],"FOnCellNodeClick","FOnCellNodeClick");
    $r.addProperty("OnCanSizeColumn",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanSizeColumn"],"FOnCanSizeColumn","FOnCanSizeColumn");
    $r.addProperty("OnCanSizeRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanSizeRow"],"FOnCanSizeRow","FOnCanSizeRow");
    $r.addProperty("OnColumnSize",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnColumnSize"],"FOnColumnSize","FOnColumnSize");
    $r.addProperty("OnRowSize",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnRowSize"],"FOnRowSize","FOnRowSize");
    $r.addProperty("OnColumnSized",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnColumnSized"],"FOnColumnSized","FOnColumnSized");
    $r.addProperty("OnRowSized",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnRowSized"],"FOnRowSized","FOnRowSized");
    $r.addProperty("OnCanDragColumn",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanSizeColumn"],"FOnCanDragColumn","FOnCanDragColumn");
    $r.addProperty("OnCanDragRow",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanSizeRow"],"FOnCanDragRow","FOnCanDragRow");
    $r.addProperty("OnColumnDragged",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnColumnDragged"],"FOnColumnDragged","FOnColumnDragged");
    $r.addProperty("OnRowDragged",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnRowDragged"],"FOnRowDragged","FOnRowDragged");
    $r.addProperty("OnBeforeColumnDrop",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnBeforeColumnDrop"],"FOnBeforeColumnDrop","FOnBeforeColumnDrop");
    $r.addProperty("OnBeforeCellEditExit",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridCellEditBeforeExit"],"FOnBeforeCellEditExit","FOnBeforeCellEditExit");
    $r.addProperty("OnBeforeRowDrop",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnBeforeRowDrop"],"FOnBeforeRowDrop","FOnBeforeRowDrop");
    $r.addProperty("OnColumnSorted",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnColumnSorted"],"FOnColumnSorted","FOnColumnSorted");
    $r.addProperty("OnCanSortColumn",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCanSortColumn"],"FOnCanSortColumn","FOnCanSortColumn");
    $r.addProperty("OnCellRightClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellClick"],"FOnCellRightClick","FOnCellRightClick");
    $r.addProperty("OnFixedCellRightClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellClick"],"FOnFixedCellRightClick","FOnFixedCellRightClick");
    $r.addProperty("OnCellClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellClick"],"FOnCellClick","FOnCellClick");
    $r.addProperty("OnFixedCellClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellClick"],"FOnFixedCellClick","FOnFixedCellClick");
    $r.addProperty("OnCellDblClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellClick"],"FOnCellDblClick","FOnCellDblClick");
    $r.addProperty("OnFixedCellDblClick",0,pas["WEBLib.TMSFNCCustomGrid"].$rtti["TTMSFNCGridOnCellClick"],"FOnFixedCellDblClick","FOnFixedCellDblClick");
    $r.addProperty("OnSelectCell",0,pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridOnSelectCell"],"FOnSelectCell","FOnSelectCell");
    $r.addProperty("OnSelectedCell",0,pas["WEBLib.TMSFNCGridData"].$rtti["TTMSFNCGridOnSelectedCell"],"FOnSelectedCell","FOnSelectedCell");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[1]];
  });
});
rtl.module("Unit3",["System","SysUtils","Classes","JS","Web","WEBLib.Graphics","WEBLib.Controls","WEBLib.Forms","WEBLib.Dialogs","Types","WEBLib.StdCtrls","WEBLib.StdCtrls","WEBLib.Controls","WEBLib.Grids","WEBLib.Grids","WEBLib.TMSFNCTypes","WEBLib.TMSFNCUtils","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCGridCell","WEBLib.TMSFNCGridOptions","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCCustomScrollControl","WEBLib.TMSFNCGridData","WEBLib.TMSFNCCustomGrid","WEBLib.TMSFNCGrid"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TForm3",pas["WEBLib.Forms"].TForm,function () {
    this.$init = function () {
      pas["WEBLib.Forms"].TForm.$init.call(this);
      this.SG_SumTable1 = null;
      this.WebButton1 = null;
    };
    this.$final = function () {
      this.SG_SumTable1 = undefined;
      this.WebButton1 = undefined;
      pas["WEBLib.Forms"].TForm.$final.call(this);
    };
    this.WebButton1Click = function (Sender) {
      this.SG_SumTable1.BeginUpdate();
      this.SG_SumTable1.SetRowCount(this.SG_SumTable1.FRowCount + 1);
      this.SG_SumTable1.SetCells(0,this.SG_SumTable1.FRowCount - 1,"Test");
      this.SG_SumTable1.EndUpdate();
    };
    this.LoadDFMValues = function () {
      pas["WEBLib.Forms"].TCustomForm.LoadDFMValues.call(this);
      this.SG_SumTable1 = pas["WEBLib.Grids"].TStringGrid.$create("Create$1",[this]);
      this.WebButton1 = pas["WEBLib.StdCtrls"].TButton.$create("Create$1",[this]);
      this.SG_SumTable1.BeforeLoadDFMValues();
      this.WebButton1.BeforeLoadDFMValues();
      try {
        this.SetName("Form3");
        this.SetWidth(1444);
        this.SetHeight(480);
        this.SG_SumTable1.SetParentComponent(this);
        this.SG_SumTable1.SetName("SG_SumTable1");
        this.SG_SumTable1.SetLeft(0);
        this.SG_SumTable1.SetTop(137);
        this.SG_SumTable1.SetWidth(1444);
        this.SG_SumTable1.SetHeight(343);
        this.SG_SumTable1.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
        this.SG_SumTable1.SetTabOrder(0);
        this.SG_SumTable1.FFixedFont.FCharset = 1;
        this.SG_SumTable1.FFixedFont.SetColor(65793);
        this.SG_SumTable1.FFixedFont.SetHeight(-18);
        this.SG_SumTable1.FFixedFont.SetName("Segoe UI");
        this.SG_SumTable1.FFixedFont.SetStyle({});
        this.SG_SumTable1.FRange.FMax = 100.000000000000000000;
        this.SG_SumTable1.FRange.FStep = 1.000000000000000000;
        this.SG_SumTable1.SetHeightPercent(100.000000000000000000);
        this.SG_SumTable1.SetWidthPercent(100.000000000000000000);
        this.WebButton1.SetParentComponent(this);
        this.WebButton1.SetName("WebButton1");
        this.WebButton1.SetLeft(0);
        this.WebButton1.SetTop(0);
        this.WebButton1.SetWidth(1444);
        this.WebButton1.SetHeight(137);
        this.WebButton1.SetAlign(pas["WEBLib.Controls"].TAlign.alTop);
        this.WebButton1.SetCaption("Add a new row");
        this.WebButton1.SetChildOrderEx(1);
        this.WebButton1.SetHeightPercent(100.000000000000000000);
        this.WebButton1.SetWidthPercent(100.000000000000000000);
        this.SetEvent$1(this.WebButton1,this,"OnClick","WebButton1Click");
      } finally {
        this.SG_SumTable1.AfterLoadDFMValues();
        this.WebButton1.AfterLoadDFMValues();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addField("SG_SumTable1",pas["WEBLib.Grids"].$rtti["TStringGrid"],4);
    $r.addField("WebButton1",pas["WEBLib.StdCtrls"].$rtti["TButton"],4);
    $r.addMethod("WebButton1Click",0,[["Sender",pas.System.$rtti["TObject"]]],4);
  });
  this.Form3 = null;
});
rtl.module("program",["System","WEBLib.Forms","WEBLib.Forms","Unit3"],function () {
  "use strict";
  var $mod = this;
  $mod.$implcode = function () {
    pas.System.$rtti["TArray<RTTI.TValue>"].eltype = pas.RTTI.$rtti["TValue"];
    pas.System.$rtti["TArray<RTTI.TRttiType>"].eltype = pas.RTTI.$rtti["TRttiType"];
    pas.System.$rtti["TArray<RTTI.TRttiField>"].eltype = pas.RTTI.$rtti["TRttiField"];
    pas.System.$rtti["TArray<RTTI.TRttiParameter>"].eltype = pas.RTTI.$rtti["TRttiParameter"];
    pas.System.$rtti["TArray<RTTI.TRttiMethod>"].eltype = pas.RTTI.$rtti["TRttiMethod"];
    pas.System.$rtti["TArray<RTTI.TRttiProperty>"].eltype = pas.RTTI.$rtti["TRttiProperty"];
    pas.System.$rtti["TArray<Classes.TPersistentClass>"].eltype = pas.Classes.$rtti["TPersistentClass"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>>"].eltype = pas["Generics.Collections"].$rtti["TPair<Generics.Collections.TDictionary.TKey,Generics.Collections.TDictionary.TValue>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>>"].eltype = pas["Generics.Collections"].$rtti["TPair<Generics.Collections.TObjectDictionary.TKey,Generics.Collections.TObjectDictionary.TValue>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.Longint,Generics.Collections.TPair<System.Double,System.Double>>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.Double,System.Double>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.Double,System.Double>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.String,System.TObject>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.String,System.TObject>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.Longint,System.TObject>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.Longint,System.TObject>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.Longint,System.Longint>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.Longint,System.Longint>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.Longint,System.Boolean>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.Longint,System.Boolean>"];
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.Longint,System.Double>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.Longint,System.Double>"];
    pas["Generics.Collections"].TEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas.System.$rtti["TArray<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>"].eltype = pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"];
    pas["Generics.Collections"].TEnumerable$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].$rtti["TCollectionNotifyEvent<WEBLib.TMSFNCPersistence.TTMSFNCObjectReference>"].init();
    pas["Generics.Defaults"].IComparer$$$G$$generics$defaults$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TArrayHelper$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TCustomList$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Defaults"].IEnumerator$$$G$$generics$defaults$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Defaults"].IEnumerable$$$G$$generics$defaults$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TList$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCObjectReference.$initSpec();
    pas["Generics.Collections"].TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas.System.$rtti["TArray<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>"].eltype = pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"];
    pas["Generics.Collections"].TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].$rtti["TCollectionNotifyEvent<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>"].init();
    pas["Generics.Defaults"].IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Defaults"].IEnumerator$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Defaults"].IEnumerable$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Collections"].TEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas.System.$rtti["TArray<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>"].eltype = pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"];
    pas["Generics.Collections"].TEnumerable$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].$rtti["TCollectionNotifyEvent<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassItem>"].init();
    pas["Generics.Defaults"].IComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TCustomArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TArrayHelper$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TCustomList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TCustomListEnumerator$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Defaults"].IEnumerator$$$G$$generics$defaults$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Defaults"].IEnumerable$$$G$$generics$defaults$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TObjectList$$$G$$generics$collections$$TTMSFNCJSONToClassItem.$initSpec();
    pas["Generics.Collections"].TPair$$$G$$generics$collections$$String$$TIconData.$initSpec();
    pas.System.$rtti["TArray<Generics.Collections.TPair<System.String,WEBLib.DesignIntf.TIconData>>"].eltype = pas["Generics.Collections"].$rtti["TPair<System.String,WEBLib.DesignIntf.TIconData>"];
    pas["Generics.Collections"].TEnumerator$$$G$$generics$collections$$TIconData.$initSpec();
    pas.System.$rtti["TArray<WEBLib.DesignIntf.TIconData>"].eltype = pas["WEBLib.DesignIntf"].$rtti["TIconData"];
    pas["Generics.Collections"].TEnumerable$$$G$$generics$collections$$TIconData.$initSpec();
    pas["Generics.Collections"].$rtti["TCollectionNotifyEvent<WEBLib.DesignIntf.TIconData>"].init();
    pas["Generics.Collections"].TDictionary$$$G$$generics$collections$$String$$TIconData.$initSpec();
    pas["Generics.Collections"].TObjectDictionary$$$G$$generics$collections$$String$$TIconData.$initSpec();
    pas["Generics.Defaults"].$rtti["TOnComparison<WEBLib.TMSFNCPersistence.TTMSFNCJSONToClassProperty>"].init();
    pas["Generics.Defaults"].TComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Defaults"].TDefaultComparer$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$initSpec();
    pas["Generics.Defaults"].TDelegatedComparerEvents$$$G$$generics$defaults$$TTMSFNCJSONToClassProperty.$initSpec();
  };
  $mod.$main = function () {
    pas["WEBLib.Forms"].Application.Initialize();
    pas["WEBLib.Forms"].Application.FMainFormOnTaskBar = true;
    pas["WEBLib.Forms"].Application.CreateForm(pas.Unit3.TForm3,{p: pas.Unit3, get: function () {
        return this.p.Form3;
      }, set: function (v) {
        this.p.Form3 = v;
      }});
    pas["WEBLib.Forms"].Application.Run();
  };
});
//# sourceMappingURL=Project3.js.map
